DUNE-FEM (unstable)

brezzidouglasfortinmarini.hh
1#ifndef DUNE_FEM_SPACE_BREZZIDOUGLASFORTINMARINI_HH
2#define DUNE_FEM_SPACE_BREZZIDOUGLASFORTINMARINI_HH
3
4#if HAVE_DUNE_LOCALFUNCTIONS
5
6// C++ includes
7#include <array>
8#include <tuple>
9
10// dune-common includes
11#include <dune/common/math.hh>
13
14// dune-geometry includes
15#include <dune/geometry/type.hh>
16
17// dune-localfunction includes
18#include <dune/localfunctions/brezzidouglasfortinmarini/bdfmcube.hh>
19#include <dune/localfunctions/common/virtualwrappers.hh>
20
21// dune-fem includes
22#include <dune/fem/space/common/uniquefacetorientation.hh>
23#include <dune/fem/space/basisfunctionset/piolatransformation.hh>
24#include <dune/fem/space/localfiniteelement/space.hh>
25
26
27namespace Dune
28{
29
30 namespace Fem
31 {
32
33 // BrezziDouglasFortinMariniLocalFiniteElementMap
34 // ----------------------------------------------
35
36 template< class GridPart, class FunctionSpace, int polOrder = -1 >
37 class BrezziDouglasFortinMariniLocalFiniteElementMap
38 {
39 using hasSingleGeometryType = GridPartCapabilities::hasSingleGeometryType< GridPart >;
40
41 static_assert( hasSingleGeometryType::v, "`GridPart` has more the one geometry type." );
42 static_assert( GridPart::dimension == 2, "`BDFM` basis only defined for quadrilaterals." );
43
44 static constexpr int dimLocal = GridPart::dimension;
45 static constexpr unsigned int topologyId = hasSingleGeometryType::topologyId;
46 static_assert( topologyId == Dune::GeometryTypes::cube(dimLocal).id(),
47 "Only defined for cube grids." );
48
49 static_assert( dimLocal == FunctionSpace::dimRange, "`dimRange` has to be equal to `GridPart::dimension`" );
50
51 using Geometry = typename GridPart::template Codim< 0 >::EntityType::Geometry;
52
53 // for dynamic space the pOrder is passed as negative value
54 static const bool dynamicOrder = polOrder < 0 ;
55 public:
56 using GridPartType = GridPart;
57
58 using DomainFieldType = typename FunctionSpace::DomainFieldType;
59 using RangeFieldType = typename FunctionSpace::RangeFieldType;
60
61 protected:
62 using DomainType = typename FunctionSpace::DomainType;
63 using RangeType = typename FunctionSpace::RangeType;
64 typedef LocalBasisTraits<DomainFieldType, FunctionSpace::dimDomain, DomainType,
65 RangeFieldType, FunctionSpace::dimRange, RangeType,
67
68 public:
69 // type of LocalFiniteElement
70 typedef typename std::conditional< dynamicOrder,
71 // virtual LFE type
72 LocalFiniteElementVirtualInterface< LBT >,
73 // real implementation type
74 BDFMCubeLocalFiniteElement< DomainFieldType, RangeFieldType, dimLocal, polOrder > > :: type LocalFiniteElementType;
75
76 typedef unsigned int KeyType;
77
78 using TransformationType = PiolaTransformation< Geometry, FunctionSpace::dimRange >;
79
80 using LocalBasisType = typename LocalFiniteElementType::Traits::LocalBasisType;
81 using LocalCoefficientsType = typename LocalFiniteElementType::Traits::LocalCoefficientsType;
82 using LocalInterpolationType = typename LocalFiniteElementType::Traits::LocalInterpolationType;
83
84 static constexpr auto size () -> std::size_t { return Dune::power( int(2), int(2*dimLocal) ); }
85
86 BrezziDouglasFortinMariniLocalFiniteElementMap ( const GridPartType& gridPart, const unsigned int ord )
87 : orientation_( gridPart ), order_( dynamicOrder ? ord : polOrder )
88 {
89 if constexpr ( dynamicOrder )
90 {
91 if ( order_ == 1 )
92 this->template createLFE< 1 >();
93 else if ( order_ == 2 )
94 this->template createLFE< 2 >();
95 else if ( order_ == 3 )
96 this->template createLFE< 3 >();
97 else
98 DUNE_THROW(NotImplemented,"BDFMLocalFiniteElement not implemented for your choice." );
99 }
100 else
101 {
102 for ( auto i : range( size() ) )
103 map_[ i ].reset( new LocalFiniteElementType( i ) );
104 }
105 }
106
107 int order () const { return order_; }
108
109 template< class Entity >
110 int order ( const Entity& entity ) const { return order(); }
111
112 template< class Entity >
113 auto operator() ( const Entity& entity ) const
114 -> std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >
115 {
116 auto o = orientation_( entity );
117 return std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >(
118 static_cast< std::size_t >( o ), map( o ).localBasis(), map( o ).localInterpolation() );
119 }
120
121 auto localCoefficients ( const GeometryType& type ) const
122 -> const LocalCoefficientsType&
123 {
124 return map( 0 ).localCoefficients();
125 }
126
127 bool hasCoefficients ( const GeometryType& type ) const { return type == GeometryType( topologyId, dimLocal ); }
128 auto gridPart () const -> const GridPartType& { return orientation_.gridPart(); }
129
130 private:
131 template <int p>
132 void createLFE()
133 {
134 using LFEImpl = BDFMCubeLocalFiniteElement< DomainFieldType, RangeFieldType, dimLocal, p >;
135 //if constexpr ( LFEImpl::numOrientations > 0 )
136 {
137 using LFEObject = LocalFiniteElementVirtualImp< LFEImpl >;
138 for ( auto i : range( size() ) )
139 {
140 LFEImpl imp( i );
141 map_[ i ].reset( new LFEObject( imp ) );
142 }
143 }
144 /*
145 else
146 {
147 DUNE_THROW(NotImplemented,"BDFMLocalFiniteElement not implemented for your choice." );
148 }
149 */
150 }
151
152 const LocalFiniteElementType& map( const std::size_t i ) const
153 {
154 assert( map_[ i ] );
155 return *map_[ i ];
156 }
157
158
159 UniqueFacetOrientation< GridPartType > orientation_;
160 std::array< std::unique_ptr< LocalFiniteElementType >, size() > map_;
161
162 const int order_;
163 };
164
165
166 // BrezziDouglasFortinMariniSpace
167 // ------------------------------
168
169 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
170 using BrezziDouglasFortinMariniSpace
171 = LocalFiniteElementSpace< BrezziDouglasFortinMariniLocalFiniteElementMap< GridPart, FunctionSpace, polOrder >, FunctionSpace, Storage >;
172
173 template< class FunctionSpace, class GridPart, class Storage = CachingStorage >
174 using DynamicBrezziDouglasFortinMariniSpace
175 = LocalFiniteElementSpace< BrezziDouglasFortinMariniLocalFiniteElementMap< GridPart, FunctionSpace >, FunctionSpace, Storage >;
176
177
178 } // namespace Fem
179
180} // namespace Dune
181
182#endif // HAVE_DUNE_LOCALFUNCTIONS
183
184#endif // #ifndef DUNE_FEM_SPACE_BREZZIDOUGLASFORTINMARINI_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
constexpr unsigned int id() const
Return the topology id of the type.
Definition: type.hh:365
GeometryType
Type representing VTK's entity geometry types.
Definition: common.hh:132
#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
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
Some useful basic math stuff.
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
constexpr Base power(Base m, Exponent p)
Power method for integer exponents.
Definition: math.hh:75
A unique label for each type of element that can occur in a grid.
Traits for type conversions and type information.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (May 9, 22:32, 2026)