2 #ifndef DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH
3 #define DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH
8 #include <dune/common/deprecated.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>
52 assert(k >= 0 and k <= 1);
57 static constexpr std::size_t
size(GeometryType gt)
59 if (gt == GeometryTypes::vertex)
61 if (gt == GeometryTypes::line)
62 return k > 0 ? k - 1 : 1;
78 template<
typename GV,
typename D,
typename R,
unsigned int k>
81 Dune::LagrangeSimplexLocalFiniteElement<D,R,2,k>
83 PkLocalFiniteElementMapBase<GV,D,R,k,2>
87 typedef Dune::LagrangeSimplexLocalFiniteElement<D,R,2,k> FE;
98 std::array<unsigned int, 3>
p = {0,1,2};
99 for (
int i = 0; i < 6; ++i)
102 std::next_permutation(
p.begin(),
p.end());
107 template<
typename Entity>
111 if (!
e.type().isSimplex())
114 const typename GV::IndexSet& is = _gv.indexSet();
115 unsigned int n0 = is.subIndex(
e,0,2);
116 unsigned int n1 = is.subIndex(
e,1,2);
117 unsigned int n2 = is.subIndex(
e,2,2);
119 unsigned int n0_compressed = (n0 > n1) + (n0 > n2);
121 return _variant[2 * n0_compressed + (n1 > n2)];
138 return k > 2 || k == 0;
140 assert(
false &&
"Invalid codim specified!");
145 static constexpr std::size_t
size(GeometryType gt)
147 if (gt == GeometryTypes::vertex)
148 return k > 0 ? 1 : 0;
149 if (gt == GeometryTypes::line)
150 return k > 1 ? k - 1 : 0;
151 if (gt == GeometryTypes::triangle)
152 return k > 2 ? (k-2)*(k-1)/2 : (k == 0);
158 return (k+1)*(k+2)/2;
162 std::array<FE,6> _variant;
172 template<
typename GV,
typename D,
typename R,
unsigned int k>
175 Dune::LagrangeSimplexLocalFiniteElement<D,R,3,k>
177 PkLocalFiniteElementMapBase<GV,D,R,k,3>
181 typedef Dune::LagrangeSimplexLocalFiniteElement<D,R,3,k> FE;
191 std::fill(_perm_index.begin(),_perm_index.end(),0);
195 std::array<unsigned int, 4> vertexmap = {0, 1, 2, 3};
197 _variant[n] = FE(vertexmap);
198 _perm_index[compressPerm(vertexmap)] = n++;
200 while(std::next_permutation(vertexmap.begin(), vertexmap.end()));
204 template<
typename Entity>
208 if (!
e.type().isSimplex())
212 const typename GV::IndexSet& is = _gv.indexSet();
213 std::array<unsigned int, 4> vertexmap;
214 for (
unsigned int i = 0; i < 4; ++i)
215 vertexmap[i] = is.subIndex(
e,i,3);
218 for (
unsigned int i = 0; i < 4; ++i)
221 for (
unsigned int j = 0; j < 4; ++j)
222 if ((min_index < 0 || vertexmap[j] < vertexmap[min_index]) && vertexmap[j] >= i)
224 assert(min_index >= 0);
225 vertexmap[min_index] = i;
227 return _variant[_perm_index[compressPerm(vertexmap)]];
246 return k == 0 || k > 3;
248 assert(
false &&
"Invalid codim specified!");
253 static constexpr std::size_t
size(GeometryType gt)
255 if (gt == GeometryTypes::vertex)
256 return k > 0 ? 1 : 0;
257 if (gt == GeometryTypes::line)
258 return k > 1 ? k - 1 : 0;
259 if (gt == GeometryTypes::triangle)
260 return k > 2 ? (k-2)*(k-1)/2 : 0;
261 if (gt == GeometryTypes::tetrahedron)
262 return k == 0 ? 1 : (k-3)*(k-2)*(k-1)/6;
268 return (k+1)*(k+2)*(k+3)/6;
273 unsigned int compressPerm(
const std::array<unsigned int, 4> vertexmap)
const
275 return vertexmap[0] + (vertexmap[1]<<2) + (vertexmap[2]<<4) + (vertexmap[3]<<6);
278 std::array<FE,24> _variant;
279 std::array<unsigned int,256> _perm_index;
287 template<
typename GV,
typename D,
typename R,
unsigned int k>
298 : fem::PkLocalFiniteElementMapBase<GV,D,R,k,GV::
dimension>(gv)
const P & p
Definition: constraints.hh:148
const Entity & e
Definition: localfunctionspace.hh:123
For backward compatibility – Do not use this!
Definition: adaptivity.hh:28
FiniteElementMap exception raised when trying to obtain a finite element for an unsupported GeometryT...
Definition: finiteelementmap.hh:23
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
collect types exported by a finite element map
Definition: finiteelementmap.hh:38
interface for a finite element map
Definition: finiteelementmap.hh:43
simple implementation where all entities have the same finite element
Definition: finiteelementmap.hh:101
static constexpr bool hasDOFs(int codim)
Definition: pkfem.hh:43
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:35
static constexpr std::size_t size(GeometryType gt)
Definition: pkfem.hh:57
static constexpr std::size_t maxLocalSize()
Definition: pkfem.hh:66
static constexpr bool fixedSize()
Definition: pkfem.hh:38
static constexpr bool hasDOFs(int codim)
Definition: pkfem.hh:129
static constexpr bool fixedSize()
Definition: pkfem.hh:124
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:92
static constexpr std::size_t maxLocalSize()
Definition: pkfem.hh:156
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:94
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:108
static constexpr std::size_t size(GeometryType gt)
Definition: pkfem.hh:145
static constexpr bool hasDOFs(int codim)
Definition: pkfem.hh:235
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:186
static constexpr std::size_t size(GeometryType gt)
Definition: pkfem.hh:253
static constexpr std::size_t maxLocalSize()
Definition: pkfem.hh:266
static constexpr bool fixedSize()
Definition: pkfem.hh:230
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:205
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:188
PkLocalFiniteElementMap(const GV &gv)
Definition: pkfem.hh:297
static constexpr int dimension
The dimension of the finite elements returned by this map.
Definition: pkfem.hh:295