dune-fem 2.8.0
Loading...
Searching...
No Matches
lagrange.hh
Go to the documentation of this file.
1#ifndef HAVE_DUNE_FEM_SPACE_LAGRANGE
2#define HAVE_DUNE_FEM_SPACE_LAGRANGE
3
4#include <memory>
5
6#include <dune/common/gmpfield.hh>
7
9
10#if HAVE_DUNE_LOCALFUNCTIONS
11#include <dune/localfunctions/lagrange.hh>
12#include <dune/localfunctions/lagrange/equidistantpoints.hh>
13#endif // #if HAVE_DUNE_LOCALFUNCTIONS
14
19
20namespace Dune
21{
22
23 namespace Fem
24 {
25
26 // LagrangeFiniteElementMap
27 // ------------------------
28
29#if HAVE_DUNE_LOCALFUNCTIONS
30 template< class FunctionSpace, class GridPart, template< class, unsigned int > class PointSet = EquidistantPointSet >
31 class LagrangeFiniteElementMap
32 {
33 typedef LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet > ThisType;
34
35 public:
36 typedef GridPart GridPartType;
37
38 typedef unsigned int KeyType;
39
40 typedef typename FunctionSpace::DomainFieldType DomainFieldType;
41 typedef typename FunctionSpace::RangeFieldType RangeFieldType;
42
43 static const int dimLocal = GridPart::dimension;
44
45 typedef LagrangeLocalFiniteElement< PointSet,dimLocal,double,double,
46 // GMPField<64>, GMPField<256> > LocalFiniteElementType;
47 double,
48#if HAVE_GMP
49 GMPField<256>
50#else
51 long double
52#endif
53 > LocalFiniteElementType;
54 typedef typename LocalFiniteElementType::Traits::LocalBasisType LocalBasisType;
55 typedef typename LocalFiniteElementType::Traits::LocalCoefficientsType LocalCoefficientsType;
56 typedef typename LocalFiniteElementType::Traits::LocalInterpolationType LocalInterpolationType;
57
58 // -1 is default value if PointSet has no member pointSetId
59 static const int pointSetId = detail::SelectPointSetId< PointSet<double, dimLocal> >::value;
60
61 LagrangeFiniteElementMap ( const GridPart &gridPart, unsigned int order )
62 : gridPart_( gridPart ), order_( order ), localFeVector_( size() )
63 {}
64
65 static std::size_t size () { return LocalGeometryTypeIndex::size(dimLocal); }
66
67 int order () const { return order_; }
68
69 template< class Entity >
70 int order ( const Entity &entity ) const { return order(); }
71
72 template< class Entity >
73 std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & >
74 operator() ( const Entity &e ) const
75 {
76 unsigned int index = localFiniteElement(e.type());
77 const LocalFiniteElementType &lfe = *(localFeVector_[index]);
78 return std::tuple< std::size_t, const LocalBasisType &, const LocalInterpolationType & >
79 { index, lfe.localBasis(), lfe.localInterpolation() };
80 }
81
82 bool hasCoefficients ( const GeometryType &type ) const { return PointSet<double,0>::supports(type,order()); }
83
84 const LocalCoefficientsType& localCoefficients ( const GeometryType &type ) const
85 {
86 unsigned int index = localFiniteElement(type);
87 return localFeVector_[index]->localCoefficients();
88 }
89
90 const GridPartType &gridPart () const { return gridPart_; }
91
92 private:
93 std::size_t localFiniteElement ( const GeometryType &type ) const
94 {
95 std::size_t index = LocalGeometryTypeIndex::index(type);
96 if ( !localFeVector_[ index ] )
97 localFeVector_[ index ].reset( new LocalFiniteElementType( type, order_ ) );
98 return index;
99 }
100
101 const GridPartType &gridPart_;
102 unsigned int order_;
103 mutable std::vector< std::unique_ptr< LocalFiniteElementType > > localFeVector_;
104 };
105
106 template< class FunctionSpace, class GridPart, unsigned int order,
107 template< class, unsigned int > class PointSet = EquidistantPointSet>
108 struct FixedOrderLagrangeFiniteElementMap
109 : public LagrangeFiniteElementMap<FunctionSpace,GridPart,PointSet>
110 {
111 typedef std::tuple<> KeyType; // no key
112 static const unsigned int polynomialOrder = order;
113 typedef typename GeometryWrapper<
115 GridPart::dimension
116 >::ImplType ImplType;
117 typedef GenericLagrangeBaseFunction<
118 typename FunctionSpace::ScalarFunctionSpaceType, ImplType, order
119 > GenericBaseFunctionType;
120 static const unsigned int numBasisFunctions = GenericBaseFunctionType::numBaseFunctions;
121 FixedOrderLagrangeFiniteElementMap ( const GridPart &gridPart, const KeyType & )
122 : LagrangeFiniteElementMap<FunctionSpace,GridPart,PointSet>(gridPart,order) {
123 }
124 };
125
126 // LagrangeSpace
127 // -------------
128
129 template< class FunctionSpace, class GridPart,
130 template< class, unsigned int > class PointSet = EquidistantPointSet,
131 class Storage = CachingStorage >
132 using LagrangeSpace = LocalFiniteElementSpace<
133 LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet >,
134 FunctionSpace, Storage >;
135 template< class FunctionSpace, class GridPart, unsigned int order,
136 template< class, unsigned int > class PointSet = EquidistantPointSet,
137 class Storage = CachingStorage >
138 using FixedOrderLagrangeSpace = LocalFiniteElementSpace<
139 FixedOrderLagrangeFiniteElementMap< FunctionSpace, GridPart, order, PointSet >,
140 FunctionSpace, Storage >;
141 template< class FunctionSpace, class GridPart,
142 template< class, unsigned int > class PointSet = EquidistantPointSet,
143 class Storage = CachingStorage >
144 using DGLagrangeSpace = DiscontinuousLocalFiniteElementSpace<
145 LagrangeFiniteElementMap< FunctionSpace, GridPart, PointSet >,
146 FunctionSpace, Storage >;
147 template< class FunctionSpace, class GridPart, unsigned int order,
148 template< class, unsigned int > class PointSet = EquidistantPointSet,
149 class Storage = CachingStorage >
150 using FixedOrderDGLagrangeSpace = DiscontinuousLocalFiniteElementSpace<
151 FixedOrderLagrangeFiniteElementMap< FunctionSpace, GridPart, order, PointSet >,
152 FunctionSpace, Storage >;
153#else // #if HAVE_DUNE_LOCALFUNCTIONS
154 // LagrangeSpace
155 // -------------
156 template< class FunctionSpace, class GridPart,
157 class Storage = CachingStorage >
159
160#endif // #if HAVE_DUNE_LOCALFUNCTIONS
161
162 } // namespace Fem
163
164} // namespace Dune
165
166#endif // #ifndef HAVE_DUNE_FEM_SPACE_LAGRANGE
Definition: bindguard.hh:11
DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > LagrangeSpace
Definition: lagrange.hh:158
specialize with 'true' for if the codimension 0 entity of the grid part has only one possible geometr...
Definition: gridpart/common/capabilities.hh:29
Lagrange discrete function space.
Definition: lagrange/space.hh:131
FunctionSpaceTraits::ScalarFunctionSpaceType ScalarFunctionSpaceType
corresponding scalar function space
Definition: functionspaceinterface.hh:83