AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
Twist.hpp
1#pragma once
2
3#include <vector>
4
5#include <dune/geometry/referenceelements.hh>
6#include <dune/localfunctions/common/localkey.hh>
7
8#include <amdis/Output.hpp>
9
10namespace AMDiS
11{
13 template <class IdSet, int dim>
14 class Twist
15 {
16 using IdType = typename IdSet::IdType;
17
18 using RefElements = typename Dune::ReferenceElements<double,dim>;
19 using RefElement = typename RefElements::ReferenceElement;
20
21 public:
23 Twist(IdSet const& idSet)
24 : idSet_(idSet)
25 {}
26
28 template <class Element>
29 void bind(Element const& element)
30 {
31 static_assert(dim == Element::mydimension, "");
32 refElem_ = &RefElements::general(element.type());
33
34 ids_.resize(refElem_->size(dim));
35 for (int i = 0; i < refElem_->size(dim); ++i)
36 ids_[i] = idSet_.subId(element, i, dim);
37 }
38
40
48 unsigned int get(Dune::LocalKey const& localKey, unsigned int size) const
49 {
50 int subDim = dim - localKey.codim();
51 if (subDim == 1 && 1 < dim) // facet == edge
52 return id(localKey,0) < id(localKey,1) ? localKey.index() : size - localKey.index() - 1;
53 else if (subDim == 2 && 2 < dim) { // facet == face
54 test_exit(size == 1, "Bases with more then one DoF per subentity are not yet supported.");
55 return localKey.index();
56 }
57
58 return localKey.index();
59 }
60
61 private:
62 IdType const& id(Dune::LocalKey const& localKey, int ii) const
63 {
64 return ids_[refElem_->subEntity(localKey.subEntity(), localKey.codim(), ii, dim)];
65 }
66
67 private:
68 IdSet const& idSet_;
69 RefElement const* refElem_ = nullptr;
70 std::vector<IdType> ids_;
71 };
72
73} // end namespace AMDiS
Permutate the dof indices w.r.t. a global entity orientation.
Definition: Twist.hpp:15
Twist(IdSet const &idSet)
Constructor. Stores a reference to the passed idSet.
Definition: Twist.hpp:23
void bind(Element const &element)
Bind the twist to a codim-0 element. Calculates the global ids of all the element vertices.
Definition: Twist.hpp:29
unsigned int get(Dune::LocalKey const &localKey, unsigned int size) const
Get the permutated local dof index, living on a subEntity of the bound element.
Definition: Twist.hpp:48