dune-fem 2.8.0
Loading...
Searching...
No Matches
space/shapefunctionset/simple.hh
Go to the documentation of this file.
1#ifndef DUNE_FEM_SHAPEFUNCTIONSET_SIMPLE_HH
2#define DUNE_FEM_SHAPEFUNCTIONSET_SIMPLE_HH
3
4// C++ includes
5#include <cstddef>
6#include <vector>
7
9
10namespace Dune
11{
12
13 namespace Fem
14 {
15
16 // AbstractShapeFunction
17 // ---------------------
18
19 template< class FunctionSpace >
21 {
23
24 public:
26
31
33
34 virtual void evaluate ( const DomainType &x, RangeType &value ) const = 0;
35
36 virtual void jacobian ( const DomainType &x, JacobianRangeType &jacobian ) const = 0;
37
38 virtual void hessian ( const DomainType &x, HessianRangeType &hessian ) const = 0;
39
40 const ThisType *clone () const = 0;
41 };
42
43
44
45 // SimpleShapeFunctionSet
46 // ----------------------
47
48 template< class ShapeFunction >
50 {
52
53 public:
54 typedef ShapeFunction ShapeFunctionType;
55
57
58 typedef typename ShapeFunction::FunctionSpaceType FunctionSpaceType;
59 typedef typename FunctionSpaceType::DomainType DomainType;
60 typedef typename FunctionSpaceType::RangeType RangeType;
61 typedef typename FunctionSpaceType::JacobianRangeType JacobianRangeType;
62 typedef typename FunctionSpaceType::HessianRangeType HessianRangeType;
63
64 // this number is positive if the shape function set
65 // is using Lagrange polynomials
66 static const int lagrangePointId = -1;
67
68 template< class Factory >
69 explicit SimpleShapeFunctionSet ( const Factory &factory );
70
72
73 const ThisType &operator= ( const ThisType &other );
74
76
77 int order () const { return order_; }
78
79 // Shape Function Set Interface Methods
80 std::size_t size () const { return shapeFunctions_.size(); }
81
82 template< class Point, class Functor >
83 void evaluateEach ( const Point &x, Functor functor ) const;
84
85 template< class Point, class Functor >
86 void jacobianEach ( const Point &x, Functor functor ) const;
87
88 template< class Point, class Functor >
89 void hessianEach ( const Point &x, Functor functor ) const;
90
91 protected:
92 std::vector< const ShapeFunctionType * > shapeFunctions_;
93 int order_;
94 };
95
96
97
98 // Implementation of SimpleShapeFunctionSet
99 // ----------------------------------------
100
101 template< class ShapeFunction >
102 template< class Factory >
104 ::SimpleShapeFunctionSet ( const Factory &factory )
105 {
106 const std::size_t numShapeFunctions = factory.numShapeFunctions();
107 shapeFunctions_.resize( numShapeFunctions );
108 for( std::size_t i = 0; i < numShapeFunctions; ++i )
109 shapeFunctions_[ i ] = factory.createShapeFunction( i );
110 order_ = factory.order();
111 }
112
113 template< class ShapeFunction >
116 {
117 *this = other;
118 }
119
120 template< class ShapeFunction >
123 {
124 if( this == &other )
125 return *this;
126
127 for( std::size_t i = 0; i < size(); ++i )
128 delete shapeFunctions_[ i ];
129
130 const std::size_t numShapeFunctions = other.size();
131 shapeFunctions_.resize( numShapeFunctions );
132 for( std::size_t i = 0; i < numShapeFunctions; ++i )
133 shapeFunctions_[ i ] = other.shapeFunctions_[ i ]->clone();
134
135 order_ = other.order_;
136 return *this;
137 }
138
139
140 template< class ShapeFunction >
142 {
143 for( std::size_t i = 0; i < size(); ++i )
144 delete shapeFunctions_[ i ];
145 }
146
147
148 template< class ShapeFunction >
149 template< class Point, class Functor >
151 ::evaluateEach ( const Point &x, Functor functor ) const
152 {
153 for( std::size_t i = 0; i < size(); ++i )
154 {
155 RangeType value;
156 shapeFunctions_[ i ]->evaluate( coordinate( x ), value );
157 functor( i, value );
158 }
159 }
160
161
162 template< class ShapeFunction >
163 template< class Point, class Functor >
165 ::jacobianEach ( const Point &x, Functor functor ) const
166 {
167 for( std::size_t i = 0; i < size(); ++i )
168 {
169 JacobianRangeType jacobian;
170 shapeFunctions_[ i ]->jacobian( coordinate( x ), jacobian );
171 functor( i, jacobian );
172 }
173 }
174
175
176 template< class ShapeFunction >
177 template< class Point, class Functor >
179 ::hessianEach ( const Point &x, Functor functor ) const
180 {
181 for( std::size_t i = 0; i < size(); ++i )
182 {
183 HessianRangeType hessian;
184 shapeFunctions_[ i ]->hessian( coordinate( x ), hessian );
185 functor( i, hessian );
186 }
187 }
188
189 } // namespace Fem
190
191} // namespace Dune
192
193#endif // #ifndef DUNE_FEM_SHAPEFUNCTIONSET_SIMPLE_HH
Definition: bindguard.hh:11
static const Point & coordinate(const Point &x)
Definition: coordinate.hh:14
Definition: explicitfieldvector.hh:75
A vector valued function space.
Definition: functionspace.hh:60
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
FunctionSpaceTraits::LinearMappingType JacobianRangeType
Intrinsic type used for the jacobian values has a Dune::FieldMatrix type interface.
Definition: functionspaceinterface.hh:75
FunctionSpaceTraits::DomainType DomainType
Type of domain vector (using type of domain field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:67
Definition: space/shapefunctionset/simple.hh:21
virtual void evaluate(const DomainType &x, RangeType &value) const =0
FunctionSpaceType::DomainType DomainType
Definition: space/shapefunctionset/simple.hh:27
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: space/shapefunctionset/simple.hh:29
FunctionSpace FunctionSpaceType
Definition: space/shapefunctionset/simple.hh:25
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: space/shapefunctionset/simple.hh:30
FunctionSpaceType::RangeType RangeType
Definition: space/shapefunctionset/simple.hh:28
virtual void jacobian(const DomainType &x, JacobianRangeType &jacobian) const =0
virtual void hessian(const DomainType &x, HessianRangeType &hessian) const =0
const ThisType * clone() const =0
virtual ~AbstractShapeFunction()
Definition: space/shapefunctionset/simple.hh:32
Definition: space/shapefunctionset/simple.hh:50
std::size_t size() const
Definition: space/shapefunctionset/simple.hh:80
~SimpleShapeFunctionSet()
Definition: space/shapefunctionset/simple.hh:141
SimpleShapeFunctionSet(const ThisType &other)
Definition: space/shapefunctionset/simple.hh:115
SimpleShapeFunctionSet(const Factory &factory)
Definition: space/shapefunctionset/simple.hh:104
ThisType ScalarFunctionSpaceType
Definition: space/shapefunctionset/simple.hh:56
FunctionSpaceType::JacobianRangeType JacobianRangeType
Definition: space/shapefunctionset/simple.hh:61
ShapeFunction::FunctionSpaceType FunctionSpaceType
Definition: space/shapefunctionset/simple.hh:58
void evaluateEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/simple.hh:151
std::vector< const ShapeFunctionType * > shapeFunctions_
Definition: space/shapefunctionset/simple.hh:92
FunctionSpaceType::HessianRangeType HessianRangeType
Definition: space/shapefunctionset/simple.hh:62
void hessianEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/simple.hh:179
int order() const
Definition: space/shapefunctionset/simple.hh:77
void jacobianEach(const Point &x, Functor functor) const
Definition: space/shapefunctionset/simple.hh:165
int order_
Definition: space/shapefunctionset/simple.hh:93
FunctionSpaceType::RangeType RangeType
Definition: space/shapefunctionset/simple.hh:60
static const int lagrangePointId
Definition: space/shapefunctionset/simple.hh:66
FunctionSpaceType::DomainType DomainType
Definition: space/shapefunctionset/simple.hh:59
ShapeFunction ShapeFunctionType
Definition: space/shapefunctionset/simple.hh:54
const ThisType & operator=(const ThisType &other)
Definition: space/shapefunctionset/simple.hh:122