DUNE-FEM (unstable)

brezzidouglasmarini.hh
1#ifndef DUNE_FEM_SPACE_BREZZIDOUGLASMARINI_HH
2#define DUNE_FEM_SPACE_BREZZIDOUGLASMARINI_HH
3
4#if HAVE_DUNE_LOCALFUNCTIONS
5
6#include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1cube2d.hh>
7#include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1cube3d.hh>
8#include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini1simplex2d.hh>
9#include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini2cube2d.hh>
10#include <dune/localfunctions/brezzidouglasmarini/brezzidouglasmarini2simplex2d.hh>
11#include <dune/localfunctions/common/virtualwrappers.hh>
12
13#include <dune/fem/space/common/uniquefacetorientation.hh>
14#include <dune/fem/space/basisfunctionset/piolatransformation.hh>
15#include <dune/fem/space/localfiniteelement/space.hh>
16
17namespace Dune
18{
19
20 namespace Fem
21 {
22
23 namespace Impl
24 {
25
26 // BDMLocalFiniteElement
27 // ---------------------
28
29 template< unsigned int id, class DomainField, class RangeField, int dimension, int order >
30 struct BDMLocalFiniteElement
31 {
32 static const int numOrientations = 0;
33 //static_assert( AlwaysFalse< DomainField >::value, "BDMLocalFiniteElement not implemented for your choice." );
34 };
35
36 // The following local finite elements are implemented
37
38 // 2d, Cube, first order
39 template< class D >
40 struct BDMLocalFiniteElement< Dune::GeometryTypes::cube(2).id(), D, D, 2, 1 >
41 : public BDM1Cube2DLocalFiniteElement< D, D >
42 {
43 static const int numOrientations = 16;
44 template< class ... Args >
45 BDMLocalFiniteElement ( Args && ... args )
46 : BDM1Cube2DLocalFiniteElement< D, D >( std::forward< Args >( args ) ... ) {}
47 };
48
49 // 3d, Cube, first order
50 template< class D >
51 struct BDMLocalFiniteElement< Dune::GeometryTypes::cube(3).id(), D, D, 3, 1 >
52 : public BDM1Cube3DLocalFiniteElement< D, D >
53 {
54 static const int numOrientations = 64;
55 template< class ... Args >
56 BDMLocalFiniteElement ( Args && ... args )
57 : BDM1Cube3DLocalFiniteElement< D, D >( std::forward< Args >( args ) ... ) {}
58 };
59
60 // 2d, Cube, second order
61 template< class D >
62 struct BDMLocalFiniteElement< Dune::GeometryTypes::cube(2).id(), D, D, 2, 2 >
63 : public BDM2Cube2DLocalFiniteElement< D, D >
64 {
65 static const int numOrientations = 16;
66 template< class ... Args >
67 BDMLocalFiniteElement ( Args && ... args )
68 : BDM2Cube2DLocalFiniteElement< D, D >( std::forward< Args >( args ) ... ) {}
69 };
70
71
72 // 2d, simplex, first order
73 template< class D >
74 struct BDMLocalFiniteElement< Dune::GeometryTypes::simplex(2).id(), D, D, 2, 1 >
75 : public BDM1Simplex2DLocalFiniteElement< D, D >
76 {
77 static const int numOrientations = 8;
78 template< class ... Args >
79 BDMLocalFiniteElement ( Args && ... args )
80 : BDM1Simplex2DLocalFiniteElement< D, D >( std::forward< Args >( args ) ... ) {}
81 };
82
83 // 2d, simplex, second order
84 template< class D >
85 struct BDMLocalFiniteElement< Dune::GeometryTypes::simplex(2).id(), D, D, 2, 2 >
86 : public BDM2Simplex2DLocalFiniteElement< D, D >
87 {
88 static const int numOrientations = 8;
89 template< class ... Args >
90 BDMLocalFiniteElement ( Args && ... args )
91 : BDM2Simplex2DLocalFiniteElement< D, D >( std::forward< Args >( args ) ... ) {}
92 };
93
94 }
95
96 // BrezziDouglasMariniLocalFiniteElementMap
97 // ----------------------------------------
98
99 template< class GridPart, class FunctionSpace, int polOrder = -1 >
100 class BrezziDouglasMariniLocalFiniteElementMap
101 {
102 typedef BrezziDouglasMariniLocalFiniteElementMap< GridPart, FunctionSpace, polOrder > ThisType;
104 "GridPart has more than one geometry type." );
105
107
108 public:
109 typedef unsigned int KeyType;
110
111 typedef GridPart GridPartType;
112
113 typedef typename FunctionSpace::DomainFieldType DomainFieldType;
114 typedef typename FunctionSpace::RangeFieldType RangeFieldType;
115
116 typedef typename GridPartType::template Codim< 0 >::EntityType EntityType;
117
118 typedef PiolaTransformation< typename EntityType::Geometry, FunctionSpace::dimRange > TransformationType;
119
120 static const int dimLocal = GridPart::dimension;
121
122 protected:
123 using DomainType = typename FunctionSpace::DomainType;
124 using RangeType = typename FunctionSpace::RangeType;
125 typedef LocalBasisTraits<DomainFieldType, FunctionSpace::dimDomain, DomainType,
126 RangeFieldType, FunctionSpace::dimRange, RangeType,
128
129 // for dynamic space the pOrder is passed as negative value
130 static const bool dynamicOrder = polOrder < 0 ;
131 public:
132 // type of LocalFinitElement
133 typedef typename std::conditional< dynamicOrder,
134 // virtual LFE type
135 LocalFiniteElementVirtualInterface< LBT >,
136 // real implementation type
137 Impl::BDMLocalFiniteElement< topologyId, DomainFieldType,
138 RangeFieldType, dimLocal, polOrder > > :: type LocalFiniteElementType;
139
140
141 typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
142 typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
143 typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
144
145 BrezziDouglasMariniLocalFiniteElementMap ( const GridPart &gridPart, const unsigned int ord )
146 : orientation_( gridPart ), order_( dynamicOrder ? ord : polOrder )
147 {
148 if constexpr ( dynamicOrder )
149 {
150 if ( order_ == 1 )
151 this->template createLFE< 1 >();
152 else if ( order_ == 2 )
153 this->template createLFE< 2 >();
154 else
155 DUNE_THROW(NotImplemented,"RaviartThomasLocalFiniteElement not implemented for your choice." );
156 }
157 else
158 {
159 for ( auto i : range( size() ) )
160 map_[ i ].reset( new LocalFiniteElementType( i ) );
161 }
162 }
163
164 // this is the same for each order, so take order 1 which exists for all combinations
165 static constexpr std::size_t numOrientations = Impl::BDMLocalFiniteElement< topologyId, DomainFieldType,
166 RangeFieldType, dimLocal, 1 >::numOrientations;
167
168 static constexpr std::size_t size () { return numOrientations; }
169
170 int order () const { return order_; }
171
172 template< class Entity >
173 int order ( const Entity &entity ) const { return order(); }
174
175 template< class Entity >
176 auto operator() ( const Entity &e ) const
177 {
178 unsigned int orient = orientation_( e );
179 return std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >
180 { static_cast< std::size_t >( orient ),
181 map( orient ).localBasis(),
182 map( orient ).localInterpolation() };
183 }
184
185 bool hasCoefficients ( const GeometryType &t ) const
186 {
187 Dune::GeometryType type( GridPartCapabilities::hasSingleGeometryType< GridPart >::topologyId, GridPart::dimension );
188 return (type == t);
189 }
190
191 const LocalCoefficientsType &localCoefficients ( const GeometryType &type ) const
192 {
193 return map( 0 ).localCoefficients();
194 }
195
196 const GridPartType &gridPart () const { return orientation_.gridPart(); }
197
198 private:
199 template <int p>
200 void createLFE()
201 {
202 using LFEImpl = Impl::BDMLocalFiniteElement< topologyId, DomainFieldType, RangeFieldType, dimLocal, p >;
203 if constexpr ( LFEImpl::numOrientations > 0 )
204 {
205 using LFEObject = LocalFiniteElementVirtualImp< LFEImpl >;
206 for ( auto i : range( size() ) )
207 {
208 LFEImpl imp( i );
209 map_[ i ].reset( new LFEObject( imp ) );
210 }
211 }
212 else
213 {
214 DUNE_THROW(NotImplemented,"BDMLocalFiniteElement not implemented for your choice." );
215 }
216 }
217
218 const LocalFiniteElementType& map( const std::size_t i ) const
219 {
220 assert( map_[ i ] );
221 return *map_[ i ];
222 }
223
224 UniqueFacetOrientation< GridPartType > orientation_;
225 std::array< std::unique_ptr< LocalFiniteElementType >, numOrientations > map_;
226
227 const int order_;
228 };
229
230
231 // BrezziDouglasMariniSpace
232 // ------------------------
233
234 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
235 using BrezziDouglasMariniSpace
236 = LocalFiniteElementSpace< BrezziDouglasMariniLocalFiniteElementMap< GridPart, FunctionSpace, polOrder >,
237 FunctionSpace, Storage >;
238
239 template< class FunctionSpace, class GridPart, class Storage = CachingStorage >
240 using DynamicBrezziDouglasMariniSpace
241 = LocalFiniteElementSpace< BrezziDouglasMariniLocalFiniteElementMap< GridPart, FunctionSpace >,
242 FunctionSpace, Storage >;
243
244 } // namespace Fem
245
246} // namespace Dune
247
248#endif // #if HAVE_DUNE_LOCALFUNCTIONS
249
250#endif // #ifndef DUNE_FEM_SPACE_BREZZIDOUGLASMARINI_HH
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:60
FunctionSpaceTraits::RangeType RangeType
Type of range vector (using type of range field) has a Dune::FieldVector type interface.
Definition: functionspaceinterface.hh:71
@ dimDomain
dimension of domain vector space
Definition: functionspaceinterface.hh:46
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
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
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr GeometryType cube(unsigned int dim)
Returns a GeometryType representing a hypercube of dimension dim.
Definition: type.hh:462
constexpr GeometryType simplex(unsigned int dim)
Returns a GeometryType representing a simplex of dimension dim.
Definition: type.hh:453
static constexpr IntegralRange< std::decay_t< T > > range(T &&from, U &&to) noexcept
free standing function for setting up a range based for loop over an integer range for (auto i: range...
Definition: rangeutilities.hh:288
Dune namespace
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
STL namespace.
specialize with 'true' for if the codimension 0 entity of the grid part has only one possible geometr...
Definition: capabilities.hh:29
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (May 9, 22:32, 2026)