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
20// dune-fem includes
21#include <dune/fem/space/common/uniquefacetorientation.hh>
22#include <dune/fem/space/basisfunctionset/piolatransformation.hh>
23#include <dune/fem/space/localfiniteelement/space.hh>
24
25
26namespace Dune
27{
28
29 namespace Fem
30 {
31
32 // BrezziDouglasFortinMariniLocalFiniteElementMap
33 // ----------------------------------------------
34
35 template< class GridPart, class FunctionSpace, int polOrder >
36 class BrezziDouglasFortinMariniLocalFiniteElementMap
37 {
38 using hasSingleGeometryType = GridPartCapabilities::hasSingleGeometryType< GridPart >;
39
40 static_assert( hasSingleGeometryType::v, "`GridPart` has more the one geometry type." );
41 static_assert( GridPart::dimension == 2, "`BDFM` basis only defined for quadrilaterals." );
42
43 static constexpr int dimLocal = GridPart::dimension;
44 static constexpr unsigned int topologyId = hasSingleGeometryType::topologyId;
45 static_assert( topologyId == Dune::GeometryTypes::cube(dimLocal).id(),
46 "Only defined for cube grids." );
47
48 static_assert( dimLocal == FunctionSpace::dimRange, "`dimRange` has to be equal to `GridPart::dimension`" );
49
50 using Geometry = typename GridPart::template Codim< 0 >::EntityType::Geometry;
51
52 public:
53 using GridPartType = GridPart;
54
55 using DomainFieldType = typename FunctionSpace::DomainFieldType;
56 using RangeFieldType = typename FunctionSpace::RangeFieldType;
57
58 using KeyType = std::tuple<>;
59
60 using TransformationType = PiolaTransformation< Geometry, FunctionSpace::dimRange >;
61
62 using LocalFiniteElementType = BDFMCubeLocalFiniteElement< DomainFieldType, RangeFieldType, dimLocal, polOrder >;
63
64 using LocalBasisType = typename LocalFiniteElementType::Traits::LocalBasisType;
65 using LocalCoefficientsType = typename LocalFiniteElementType::Traits::LocalCoefficientsType;
66 using LocalInterpolationType = typename LocalFiniteElementType::Traits::LocalInterpolationType;
67
68 static constexpr auto size () -> std::size_t { return Dune::power( int(2), int(2*dimLocal) ); }
69
70 template< class ... Args >
71 BrezziDouglasFortinMariniLocalFiniteElementMap ( const GridPartType& gridPart, Args&& ... )
72 : orientation_( gridPart )
73 {
74 for ( auto i : range( size() ) )
75 map_[ i ] = LocalFiniteElementType( i );
76 }
77
78 int order () const { return polOrder; }
79
80 template< class Entity >
81 int order ( const Entity& entity ) const { return order; }
82
83 template< class Entity >
84 auto operator() ( const Entity& entity ) const
85 -> std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >
86 {
87 auto o = orientation_( entity );
88 return std::tuple< std::size_t, const LocalBasisType&, const LocalInterpolationType& >(
89 static_cast< std::size_t >( o ), map_[ o ].localBasis(), map_[ o ].localInterpolation() );
90 }
91
92 auto localCoefficients ( const GeometryType& type ) const
93 -> const LocalCoefficientsType&
94 {
95 return map_[ 0 ].localCoefficients();
96 }
97
98 bool hasCoefficients ( const GeometryType& type ) const { return type == GeometryType( topologyId, dimLocal ); }
99 auto gridPart () const -> const GridPartType& { return orientation_.gridPart(); }
100
101 private:
102 UniqueFacetOrientation< GridPartType > orientation_;
103 std::array< LocalFiniteElementType, size() > map_;
104 };
105
106
107 // BrezziDouglasFortinMariniSpace
108 // ------------------------------
109
110 template< class FunctionSpace, class GridPart, int polOrder, class Storage = CachingStorage >
111 using BrezziDouglasFortinMariniSpace
112 = LocalFiniteElementSpace< BrezziDouglasFortinMariniLocalFiniteElementMap< GridPart, FunctionSpace, polOrder >, FunctionSpace, Storage >;
113
114
115 } // namespace Fem
116
117} // namespace Dune
118
119#endif // HAVE_DUNE_LOCALFUNCTIONS
120
121#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
@ dimRange
dimension of range vector space
Definition: functionspaceinterface.hh:48
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
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 (Mar 8, 23:37, 2026)