DOLFIN
DOLFIN C++ interface
BasisFunction.h
1// Copyright (C) 2013 Anders Logg
2//
3// This file is part of DOLFIN.
4//
5// DOLFIN is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// DOLFIN is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
17//
18// First added: 2009-01-01
19// Last changed: 2013-03-04
20
21#ifndef __BASIS_FUNCTION_H
22#define __BASIS_FUNCTION_H
23
24#include <memory>
25#include <vector>
26#include <ufc.h>
27#include <dolfin/fem/FiniteElement.h>
28
29namespace dolfin
30{
31
33
44
45 class BasisFunction : public ufc::function
46 {
47 public:
48
57 BasisFunction(std::size_t index,
58 std::shared_ptr<const FiniteElement> element,
59 const std::vector<double>& coordinate_dofs)
60 : _index(index), _element(element), _coordinate_dofs(coordinate_dofs) {}
61
64
69 void update_index(std::size_t index)
70 { _index = index; }
71
78 void eval(double* values, const double* x) const
79 {
80 // Note: assuming cell_orientation = 0
81 dolfin_assert(_element);
82 _element->evaluate_basis(_index, values, x, _coordinate_dofs.data(), 0);
83 }
84
93 void eval_derivatives(double* values, const double* x, std::size_t n) const
94 {
95 // Note: assuming cell_orientation = 0
96 dolfin_assert(_element);
97 _element->evaluate_basis_derivatives(_index, n, values, x,
98 _coordinate_dofs.data(), 0);
99 }
100
101 //--- Implementation of ufc::function interface ---
102
111 void evaluate(double* values, const double* coordinates,
112 const ufc::cell& cell) const
113 { eval(values, coordinates); }
114
115 private:
116
117 // The index
118 std::size_t _index;
119
120 // The finite element
121 std::shared_ptr<const FiniteElement> _element;
122
123 // Cell coordinates
124 const std::vector<double> _coordinate_dofs;
125
126 };
127
128}
129
130#endif
Represention of a finite element basis function.
Definition: BasisFunction.h:46
BasisFunction(std::size_t index, std::shared_ptr< const FiniteElement > element, const std::vector< double > &coordinate_dofs)
Definition: BasisFunction.h:57
void eval(double *values, const double *x) const
Definition: BasisFunction.h:78
void eval_derivatives(double *values, const double *x, std::size_t n) const
Definition: BasisFunction.h:93
void update_index(std::size_t index)
Definition: BasisFunction.h:69
~BasisFunction()
Destructor.
Definition: BasisFunction.h:63
void evaluate(double *values, const double *coordinates, const ufc::cell &cell) const
Definition: BasisFunction.h:111
Definition: adapt.h:30