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>
52 assert(
false &&
"Invalid codim specified!");
57 std::size_t
size(GeometryType gt)
const 62 return k > 0 ? k - 1 : 1;
78 template<
typename GV,
typename D,
typename R,
unsigned int k>
81 Dune::PkLocalFiniteElement<D,R,2,k>
83 PkLocalFiniteElementMapBase<GV,D,R,k,2>
87 typedef Dune::PkLocalFiniteElement<D,R,2,k> FE;
98 unsigned int p[3] = {0,1,2};
99 for (
int i = 0; i < 6; ++i)
102 std::next_permutation(p,p+3);
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 std::size_t
size(GeometryType gt)
const 148 return k > 0 ? 1 : 0;
150 return k > 1 ? k - 1 : 0;
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::PkLocalFiniteElement<D,R,3,k>
177 PkLocalFiniteElementMapBase<GV,D,R,k,3>
181 typedef Dune::PkLocalFiniteElement<D,R,3,k> FE;
191 std::fill(_perm_index.begin(),_perm_index.end(),0);
195 unsigned int vertexmap[4];
196 for(vertexmap[0] = 0; vertexmap[0] < 4; ++vertexmap[0])
198 for(vertexmap[1] = 0; vertexmap[1] < 4; ++vertexmap[1])
200 if (vertexmap[0] == vertexmap[1])
202 for(vertexmap[2] = 0; vertexmap[2] < 4; ++vertexmap[2])
204 if (vertexmap[0] == vertexmap[2] ||
205 vertexmap[1] == vertexmap[2])
207 vertexmap[3] = 6 - vertexmap[0] - vertexmap[1] - vertexmap[2];
208 _variant[n] = FE(vertexmap);
209 _perm_index[compressPerm(vertexmap)] = n++;
216 template<
typename Entity>
220 if (!e.type().isSimplex())
224 const typename GV::IndexSet& is = _gv.indexSet();
225 unsigned int vertexmap[4];
226 for (
unsigned int i = 0; i < 4; ++i)
227 vertexmap[i] = is.subIndex(e,i,3);
230 for (
unsigned int i = 0; i < 4; ++i)
233 for (
unsigned int j = 0; j < 4; ++j)
234 if ((min_index < 0 || vertexmap[j] < vertexmap[min_index]) && vertexmap[j] >= i)
236 assert(min_index >= 0);
237 vertexmap[min_index] = i;
239 return _variant[_perm_index[compressPerm(vertexmap)]];
258 return k == 0 || k > 3;
260 assert(
false &&
"Invalid codim specified!");
265 std::size_t
size(GeometryType gt)
const 268 return k > 0 ? 1 : 0;
270 return k > 1 ? k - 1 : 0;
272 return k > 2 ? (k-2)*(k-1)/2 : 0;
273 if (gt.isTetrahedron())
274 return k == 0 ? 1 : (k-3)*(k-2)*(k-1)/6;
280 return (k+1)*(k+2)*(k+3)/6;
285 unsigned int compressPerm(
const unsigned int vertexmap[4])
const 287 return vertexmap[0] + (vertexmap[1]<<2) + (vertexmap[2]<<4) + (vertexmap[3]<<6);
290 std::array<FE,24> _variant;
291 std::array<unsigned int,256> _perm_index;
299 template<
typename GV,
typename D,
typename R,
unsigned int k>
307 : fem::PkLocalFiniteElementMapBase<GV,D,R,k,GV::dimension>(gv)
316 #endif // DUNE_PDELAB_FINITEELEMENTMAP_PKFEM_HH bool hasDOFs(int codim) const
Definition: pkfem.hh:129
std::size_t maxLocalSize() const
Definition: pkfem.hh:156
bool hasDOFs(int codim) const
Definition: pkfem.hh:247
collect types exported by a finite element map
Definition: finiteelementmap.hh:38
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:145
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:92
std::size_t maxLocalSize() const
Definition: pkfem.hh:278
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:35
simple implementation where all entities have the same finite element
Definition: finiteelementmap.hh:95
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:108
const P & p
Definition: constraints.hh:147
const Traits::FiniteElementType & find(const Entity &e) const
get local basis functions for entity
Definition: pkfem.hh:217
bool hasDOFs(int codim) const
Definition: pkfem.hh:43
bool fixedSize() const
Definition: pkfem.hh:124
bool fixedSize() const
Definition: pkfem.hh:242
For backward compatibility – Do not use this!
Definition: adaptivity.hh:27
bool fixedSize() const
Definition: pkfem.hh:38
const Entity & e
Definition: localfunctionspace.hh:111
std::size_t maxLocalSize() const
Definition: pkfem.hh:66
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:94
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:57
LocalFiniteElementMapTraits< FE > Traits
export type of the signature
Definition: pkfem.hh:186
T FiniteElementType
Type of finite element from local functions.
Definition: finiteelementmap.hh:30
PkLocalFiniteElementMapBase(const GV &gv)
Definition: pkfem.hh:188
interface for a finite element map
Definition: finiteelementmap.hh:42
std::size_t size(GeometryType gt) const
Definition: pkfem.hh:265
FiniteElementMap exception raised when trying to obtain a finite element for an unsupported GeometryT...
Definition: finiteelementmap.hh:23
PkLocalFiniteElementMap(const GV &gv)
Definition: pkfem.hh:306