DUNE-FEM (unstable)

dofstorage.hh
1#ifndef DUNE_FEM_DOFSTORAGE_HH
2#define DUNE_FEM_DOFSTORAGE_HH
3
4#include <cassert>
5
6namespace Dune
7{
8
9 namespace Fem
10 {
11
16 enum DofStoragePolicy { PointBased, VariableBased };
17
20 template <DofStoragePolicy p>
22
24 template <>
25 class DofConversionUtility<PointBased> {
26 public:
29 DofConversionUtility(int numComponents) :
30 numComponents_(numComponents)
31 {}
32
34 static DofStoragePolicy policy() { return PointBased; }
35
40 void newSize(int size) {} // just do nothing
41
44 int component(int combinedIndex) const {
45 return combinedIndex%numComponents_;
46 }
48 int containedDof(int combinedIndex) const {
49 return combinedIndex/numComponents_;
50 }
51
54 int combinedDof(int containedIndex, int component) const {
55 return containedIndex*numComponents_ + component;
56 }
57
58 private:
59 const int numComponents_;
60 };
61
63 template <>
64 class DofConversionUtility<VariableBased> {
65 public:
69 size_(size)
70 {}
71
73 static DofStoragePolicy policy() { return VariableBased; }
74
76 void newSize(int size) { size_ = size; }
77
80 int component(int combinedIndex) const {
81 return combinedIndex/size_;
82 }
83
85 int containedDof(int combinedIndex) const {
86 return combinedIndex%size_;
87 }
88
91 int combinedDof(int containedIndex, int component) const {
92 return containedIndex + component*size_;
93 }
94
95 private:
96 int size_;
97 };
98
100 template <unsigned int dimRange>
102 public:
106 {
107 // make sure that we use the correct number of components
108 assert( numComponents == int(dimRange) );
109 }
110
112 static DofStoragePolicy policy() { return PointBased; }
113
118 void newSize(const int size) {} // just do nothing
119
122 int component(const int combinedIndex) const
123 {
124 return combinedIndex % dimRange;
125 }
127 int containedDof(const int combinedIndex) const
128 {
129 return combinedIndex / dimRange;
130 }
131
134 int combinedDof(const int containedIndex,
135 const int component) const
136 {
137 return containedIndex * dimRange + component;
138 }
139 };
140
141 } // namespace Fem
142
143} // namespace Dune
144
145#endif // #ifndef DUNE_FEM_DOFSTORAGE_HH
static DofStoragePolicy policy()
Find out what type of policy this is.
Definition: dofstorage.hh:34
DofConversionUtility(int numComponents)
Definition: dofstorage.hh:29
int containedDof(int combinedIndex) const
Number of the (scalar) base function belonging to base function index.
Definition: dofstorage.hh:48
void newSize(int size)
Definition: dofstorage.hh:40
int combinedDof(int containedIndex, int component) const
Definition: dofstorage.hh:54
int component(int combinedIndex) const
Definition: dofstorage.hh:44
int containedDof(int combinedIndex) const
Number of the (scalar) base function belonging to base function index.
Definition: dofstorage.hh:85
DofConversionUtility(int size)
Definition: dofstorage.hh:68
void newSize(int size)
Set new size after adaptation.
Definition: dofstorage.hh:76
int component(int combinedIndex) const
Definition: dofstorage.hh:80
int combinedDof(int containedIndex, int component) const
Definition: dofstorage.hh:91
static DofStoragePolicy policy()
Find out what type of policy this is.
Definition: dofstorage.hh:73
Definition: dofstorage.hh:21
Specialisation for PointBased approach.
Definition: dofstorage.hh:101
int component(const int combinedIndex) const
Definition: dofstorage.hh:122
void newSize(const int size)
Definition: dofstorage.hh:118
static DofStoragePolicy policy()
Find out what type of policy this is.
Definition: dofstorage.hh:112
PointBasedDofConversionUtility(int numComponents)
Definition: dofstorage.hh:105
int combinedDof(const int containedIndex, const int component) const
Definition: dofstorage.hh:134
int containedDof(const int combinedIndex) const
Number of the (scalar) base function belonging to base function index.
Definition: dofstorage.hh:127
Dune namespace.
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)