2 #ifndef DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH
3 #define DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH
7 #include <dune/common/deprecated.hh>
8 #include <dune/common/array.hh>
9 #include <dune/common/exceptions.hh>
10 #include <dune/geometry/type.hh>
11 #include <dune/localfunctions/lagrange/pk.hh>
20 template<
typename GV,
typename D,
typename R,
unsigned int k,
unsigned int d>
28 template<
typename GV,
typename D,
typename R,
unsigned int k>
43 std::size_t
size(GeometryType gt)
const
48 return k > 0 ? k - 1 : 1;
64 template<
typename GV,
typename D,
typename R,
unsigned int k>
67 Dune::PkLocalFiniteElement<D,R,2,k>
69 PkLocalFiniteElementMapBase<GV,D,R,k,2>
73 typedef Dune::PkLocalFiniteElement<D,R,2,k> FE;
84 unsigned int p[3] = {0,1,2};
85 for (
int i = 0; i < 6; ++i)
88 std::next_permutation(p,p+3);
93 template<
typename Entity>
97 if (!e.type().isSimplex())
100 const typename GV::IndexSet& is = _gv.indexSet();
101 unsigned int n0 = is.subIndex(e,0,2);
102 unsigned int n1 = is.subIndex(e,1,2);
103 unsigned int n2 = is.subIndex(e,2,2);
105 unsigned int n0_compressed = (n0 > n1) + (n0 > n2);
107 return _variant[2 * n0_compressed + (n1 > n2)];
115 std::size_t
size(GeometryType gt)
const
118 return k > 0 ? 1 : 0;
120 return k > 1 ? k - 1 : 0;
122 return k > 2 ? (k-2)*(k-1)/2 : (k == 0);
128 return (k+1)*(k+2)/2;
132 std::array<FE,6> _variant;
142 template<
typename GV,
typename D,
typename R,
unsigned int k>
145 Dune::PkLocalFiniteElement<D,R,3,k>
147 PkLocalFiniteElementMapBase<GV,D,R,k,3>
151 typedef Dune::PkLocalFiniteElement<D,R,3,k> FE;
161 std::fill(_perm_index.begin(),_perm_index.end(),0);
165 unsigned int vertexmap[4];
166 for(vertexmap[0] = 0; vertexmap[0] < 4; ++vertexmap[0])
168 for(vertexmap[1] = 0; vertexmap[1] < 4; ++vertexmap[1])
170 if (vertexmap[0] == vertexmap[1])
172 for(vertexmap[2] = 0; vertexmap[2] < 4; ++vertexmap[2])
174 if (vertexmap[0] == vertexmap[2] ||
175 vertexmap[1] == vertexmap[2])
177 vertexmap[3] = 6 - vertexmap[0] - vertexmap[1] - vertexmap[2];
178 _variant[n] = FE(vertexmap);
179 _perm_index[compressPerm(vertexmap)] = n++;
186 template<
typename Entity>
190 if (!e.type().isSimplex())
194 const typename GV::IndexSet& is = _gv.indexSet();
195 unsigned int vertexmap[4];
196 for (
unsigned int i = 0; i < 4; ++i)
197 vertexmap[i] = is.subIndex(e,i,3);
200 for (
unsigned int i = 0; i < 4; ++i)
203 for (
unsigned int j = 0; j < 4; ++j)
204 if ((min_index < 0 || vertexmap[j] < vertexmap[min_index]) && vertexmap[j] >= i)
206 assert(min_index >= 0);
207 vertexmap[min_index] = i;
209 return _variant[_perm_index[compressPerm(vertexmap)]];
217 std::size_t
size(GeometryType gt)
const
220 return k > 0 ? 1 : 0;
222 return k > 1 ? k - 1 : 0;
224 return k > 2 ? (k-2)*(k-1)/2 : 0;
225 if (gt.isTetrahedron())
226 return k == 0 ? 1 : (k-3)*(k-2)*(k-1)/6;
232 return (k+1)*(k+2)*(k+3)/6;
237 unsigned int compressPerm(
const unsigned int vertexmap[4])
const
239 return vertexmap[0] + (vertexmap[1]<<2) + (vertexmap[2]<<4) + (vertexmap[3]<<6);
242 std::array<FE,24> _variant;
243 std::array<unsigned int,256> _perm_index;
251 template<
typename GV,
typename D,
typename R,
unsigned int k>
259 : fem::PkLocalFiniteElementMapBase<GV,D,R,k,GV::dimension>(gv)
268 #endif // DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:35
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:78
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:115
FiniteElementMap exception raised when trying to obtain a finite element for an unsupported GeometryT...
Definition: finiteelementmap.hh:23
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:43
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:156
PkLocalFiniteElementMap(const GV &gv)
Definition: pkfem.hh:258
const E & e
Definition: interpolate.hh:172
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:94
collect types exported by a finite element map
Definition: finiteelementmap.hh:38
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
bool fixedSize() const
Definition: pkfem.hh:38
Definition: adaptivity.hh:27
simple implementation where all entities have the same finite element
Definition: finiteelementmap.hh:107
interface for a finite element map
Definition: finiteelementmap.hh:42
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:80
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:217
std::size_t maxLocalSize() const
Definition: pkfem.hh:52
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:158
const P & p
Definition: constraints.hh:146
std::size_t maxLocalSize() const
Definition: pkfem.hh:126
std::size_t maxLocalSize() const
Definition: pkfem.hh:230
bool fixedSize() const
Definition: pkfem.hh:212
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:187
bool fixedSize() const
Definition: pkfem.hh:110