DUNE-FEM (unstable)

lagrange.hh
1#ifndef HAVE_DUNE_FEM_SPACE_LAGRANGE
2#define HAVE_DUNE_FEM_SPACE_LAGRANGE
3
4#include <memory>
5
8
9#include <dune/fem/space/lagrange/space.hh>
10
11#if HAVE_DUNE_LOCALFUNCTIONS
13#include <dune/localfunctions/lagrange/equidistantpoints.hh>
14#endif // #if HAVE_DUNE_LOCALFUNCTIONS
15
16#include <dune/fem/gridpart/common/capabilities.hh>
17#include <dune/fem/space/localfiniteelement/space.hh>
18#include <dune/fem/space/localfiniteelement/dgspace.hh>
19#include <dune/fem/space/localfiniteelement/quadratureinterpolation.hh>
20
21namespace Dune
22{
23
24 namespace Fem
25 {
26
27 // LagrangeFiniteElementMap
28 // ------------------------
29
30#if HAVE_DUNE_LOCALFUNCTIONS
31 template< class FunctionSpace, class GridPart, template< class, unsigned int > class PointSet = EquidistantPointSetDerived >
32 class LagrangeFiniteElementMap
33 {
34 typedef LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet > ThisType;
35
36 public:
37 typedef GridPart GridPartType;
38
39 typedef unsigned int KeyType;
40
41 typedef typename FunctionSpace::DomainFieldType DomainFieldType;
42 typedef typename FunctionSpace::RangeFieldType RangeFieldType;
43
44 static const int dimLocal = GridPart::dimension;
45
46 typedef LagrangeLocalFiniteElement< PointSet,dimLocal,double,double,
47 // GMPField<64>, GMPField<256> > LocalFiniteElementType;
48 double,
49#if HAVE_GMP
50 GMPField<256>
51#else
52 long double
53#endif
54 > LocalFiniteElementType;
55 typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
56 typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
57 typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
58
59 // -1 is default value if PointSet has no member pointSetId
60 static const int pointSetId = detail::SelectPointSetId< PointSet<double, dimLocal> >::value;
61
62 LagrangeFiniteElementMap ( const GridPart &gridPart, unsigned int order )
63 : gridPart_( gridPart ), order_( order ), localFeVector_( size() )
64 {
65 if( order_ == 0 )
66 {
67 DUNE_THROW(NotImplemented, "LagrangeFiniteElementMap is not implemented for order=0, Use FiniteVolume space instead!");
68 }
69 }
70
71 static std::size_t size () { return LocalGeometryTypeIndex::size(dimLocal); }
72
73 int order () const { return order_; }
74
75 template< class Entity >
76 int order ( const Entity &entity ) const { return order(); }
77
78 template< class Entity >
79 std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & >
80 operator() ( const Entity &e ) const
81 {
82 unsigned int index = localFiniteElement(e.type());
83 const LocalFiniteElementType &lfe = *(localFeVector_[index]);
84 return std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & >
85 { index, lfe.localBasis(), lfe.localInterpolation() };
86 }
87
88 bool hasCoefficients ( const GeometryType &type ) const { return PointSet<double,0>::supports(type,order()); }
89
90 const LocalCoefficientsType& localCoefficients ( const GeometryType &type ) const
91 {
92 unsigned int index = localFiniteElement(type);
93 return localFeVector_[index]->localCoefficients();
94 }
95
96 const GridPartType &gridPart () const { return gridPart_; }
97
98 private:
99 std::size_t localFiniteElement ( const GeometryType &type ) const
100 {
101 std::size_t index = LocalGeometryTypeIndex::index(type);
102 if ( !localFeVector_[ index ] )
103 localFeVector_[ index ].reset( new LocalFiniteElementType( type, order_ ) );
104 return index;
105 }
106
107 const GridPartType &gridPart_;
108 unsigned int order_;
109 mutable std::vector< std::unique_ptr< LocalFiniteElementType > > localFeVector_;
110 };
111
112 template< class FunctionSpace, class GridPart, unsigned int order,
113 template< class, unsigned int > class PointSet = EquidistantPointSetDerived >
114 struct FixedOrderLagrangeFiniteElementMap
115 : public LagrangeFiniteElementMap<FunctionSpace,GridPart,PointSet>
116 {
117 typedef std::tuple<> KeyType; // no key
118 static const unsigned int polynomialOrder = order;
119 typedef typename GeometryWrapper<
121 GridPart::dimension
122 >::ImplType ImplType;
123 typedef GenericLagrangeBaseFunction<
124 typename FunctionSpace::ScalarFunctionSpaceType, ImplType, order
125 > GenericBaseFunctionType;
126 static const unsigned int numBasisFunctions = GenericBaseFunctionType::numBaseFunctions;
127 FixedOrderLagrangeFiniteElementMap ( const GridPart &gridPart, const KeyType & )
128 : LagrangeFiniteElementMap<FunctionSpace,GridPart,PointSet>(gridPart,order) {
129 }
130 };
131
132 // LagrangeSpace
133 // -------------
134
135 template< class FunctionSpace, class GridPart,
136 template< class, unsigned int > class PointSet = EquidistantPointSetDerived,
137 class Storage = CachingStorage >
138 using LagrangeSpace = LocalFiniteElementSpace<
139 LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet >,
140 FunctionSpace, Storage >;
141 template< class FunctionSpace, class GridPart, unsigned int order,
142 template< class, unsigned int > class PointSet = EquidistantPointSetDerived,
143 class Storage = CachingStorage >
144 using FixedOrderLagrangeSpace = LocalFiniteElementSpace<
145 FixedOrderLagrangeFiniteElementMap< FunctionSpace, GridPart, order, PointSet >,
146 FunctionSpace, Storage >;
147 template< class FunctionSpace, class GridPart,
148 template< class, unsigned int > class PointSet = EquidistantPointSetDerived,
149 class Storage = CachingStorage >
150 using DGLagrangeSpace = DiscontinuousLocalFiniteElementSpace<
151 LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet >,
152 FunctionSpace, Storage >;
153 template< class FunctionSpace, class GridPart, unsigned int order,
154 template< class, unsigned int > class PointSet = EquidistantPointSetDerived,
155 class Storage = CachingStorage >
156 using FixedOrderDGLagrangeSpace = DiscontinuousLocalFiniteElementSpace<
157 FixedOrderLagrangeFiniteElementMap< FunctionSpace, GridPart, order, PointSet >,
158 FunctionSpace, Storage >;
159#else // #if HAVE_DUNE_LOCALFUNCTIONS
160 // LagrangeSpace
161 // -------------
162 template< class FunctionSpace, class GridPart,
163 class Storage = CachingStorage >
164 using LagrangeSpace = DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage >;
165
166#endif // #if HAVE_DUNE_LOCALFUNCTIONS
167
168 } // namespace Fem
169
170} // namespace Dune
171
172#endif // #ifndef HAVE_DUNE_FEM_SPACE_LAGRANGE
FunctionSpaceTraits::DomainFieldType DomainFieldType
Intrinsic type used for values in the domain field (usually a double)
Definition: functionspaceinterface.hh:60
FunctionSpaceTraits::RangeFieldType RangeFieldType
Intrinsic type used for values in the range field (usually a double)
Definition: functionspaceinterface.hh:63
FunctionSpaceTraits::ScalarFunctionSpaceType ScalarFunctionSpaceType
corresponding scalar function space
Definition: functionspaceinterface.hh:83
Lagrange discrete function space.
Definition: space.hh:131
static constexpr std::size_t size(std::size_t dim)
Compute total number of geometry types for the given dimension.
Definition: typeindex.hh:61
static constexpr std::size_t index(const GeometryType &gt)
Compute the index for the given geometry type within its dimension.
Definition: typeindex.hh:73
A few common exception classes.
Convenience header that includes all implementations of Lagrange finite elements.
Wrapper for the GNU multiprecision (GMP) library.
#define DUNE_THROW(E, m)
Definition: exceptions.hh:218
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
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  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)