dune-fem 2.12-git
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
8
10
11#if HAVE_DUNE_LOCALFUNCTIONS
14#endif // #if HAVE_DUNE_LOCALFUNCTIONS
15
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 >
80 operator() ( const Entity &e ) const
81 {
82 unsigned int index = localFiniteElement(e.type());
83 const LocalFiniteElementType &lfe = *(localFeVector_[index]);
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_;
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 >
165
166#endif // #if HAVE_DUNE_LOCALFUNCTIONS
167
168 } // namespace Fem
169
170} // namespace Dune
171
172#endif // #ifndef HAVE_DUNE_FEM_SPACE_LAGRANGE
int size() const
std::ptrdiff_t index() const
virtual void operator()()=0
#define DUNE_THROW(E,...)
DynamicLagrangeDiscreteFunctionSpace< FunctionSpace, GridPart, Storage > LagrangeSpace
Definition lagrange.hh:164
GridImp::template Codim< cd >::Entity Entity
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