Dune-Fufem 2.11-git
Loading...
Searching...
No Matches
cachedcomponentwrapper.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE-FUFEM Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3
4#ifndef CACHED_COMPONENT_WRAPPER_HH
5#define CACHED_COMPONENT_WRAPPER_HH
6
7#warning This header is deprecated and will be removed after 2.11.
8
16#include <vector>
17#include <map>
18
21
22
23
27template<class RT>
28struct
29[[deprecated("This class is deprecated and will be removed after 2.11.")]]
31{
32 template<class RFT>
33 static void setComponent(RT& x, int i, const RFT& xi)
34 {
35 x = xi;
36 }
37
38 template<class RFT>
39 static void getComponent(const RT& x, int i, RFT& xi)
40 {
41 xi = x;
42 }
43 static int size(const RT& x)
44 {
45 return 1;
46 }
47};
48
52template<class T, int n>
53struct
54[[deprecated("This class is deprecated and will be removed after 2.11.")]]
56{
57 typedef typename Dune::FieldVector<T, n> RT;
58
59 template<class RFT>
60 static void setComponent(RT& x, int i, const RFT& xi)
61 {
62 x[i] = xi;
63 }
64
65 template<class RFT>
66 static void getComponent(const RT& x, int i, RFT& xi)
67 {
68 xi = x[i];
69 }
70
71 static int size(const RT& x)
72 {
73 return n;
74 }
75};
76
80template<class T, int n, int m>
81struct
82[[deprecated("This class is deprecated and will be removed after 2.11.")]]
84{
86
87 template<class RFT>
88 static void setComponent(RT& x, int i, const RFT& xi)
89 {
90 x[i/m][i%m] = xi;
91 }
92
93 template<class RFT>
94 static void getComponent(const RT& x, int i, RFT& xi)
95 {
96 xi = x[i/m][i%m];
97 }
98
99 static int size(const RT& x)
100 {
101 return n*m;
102 }
103};
104
108template<class T>
109struct
110[[deprecated("This class is deprecated and will be removed after 2.11.")]]
112{
113 typedef typename std::vector<T> RT;
114
115 template<class RFT>
116 static void setComponent(RT& x, int i, const RFT& xi)
117 {
118 x[i] = xi;
119 }
120
121 template<class RFT>
122 static void getComponent(const RT& x, int i, RFT& xi)
123 {
124 xi = x[i];
125 }
126
127 static int size(const RT& x)
128 {
129 return x.size();
130 }
131};
132
133
134
145template <class Imp, class AllRangeType, class FunctionBaseClass>
146class
147[[deprecated("This class is deprecated and will be removed after 2.11.")]]
149{
150 public:
151 typedef typename FunctionBaseClass::DomainType DomainType;
152 typedef typename FunctionBaseClass::RangeType RangeType;
153
154 private:
155 typedef DomainType Position;
156 struct DomainCmp
157 {
158 bool operator() (const DomainType& a, const DomainType& b) const
159 {
160 for(int i=0; i<DomainType::dimension; ++i)
161 {
162 if (a[i]<b[i])
163 return true;
164 if (a[i]>b[i])
165 return false;
166 }
167 return false;
168 }
169 };
170 typedef typename std::map<DomainType, AllRangeType, DomainCmp> EvaluationCache;
171
172 public:
173
174 CachedComponentWrapper(const int i=0) :
175 i_(i)
176 {}
177
182 void setIndex(int i)
183 {
184 i_ = i;
185 }
186
193 {
194 RangeType y;
195 typename EvaluationCache::const_iterator it = evalCache_.find(x);
196 if (it != evalCache_.end())
198 else
199 {
200 AllRangeType& yy = evalCache_[x];
201 asImp().evaluateAll(x, yy);
203 }
204 return y;
205 }
206
207 protected:
208
209 const Imp& asImp () const
210 {
211 return static_cast<const Imp &> (*this);
212 }
213
214 int i_;
215
217};
218
219#endif
220
virtual void operator()()=0
Definition cachedcomponentwrapper.hh:31
static int size(const RT &x)
Definition cachedcomponentwrapper.hh:43
static void setComponent(RT &x, int i, const RFT &xi)
Definition cachedcomponentwrapper.hh:33
static void getComponent(const RT &x, int i, RFT &xi)
Definition cachedcomponentwrapper.hh:39
static void getComponent(const RT &x, int i, RFT &xi)
Definition cachedcomponentwrapper.hh:66
Dune::FieldVector< T, n > RT
Definition cachedcomponentwrapper.hh:57
static int size(const RT &x)
Definition cachedcomponentwrapper.hh:71
static void setComponent(RT &x, int i, const RFT &xi)
Definition cachedcomponentwrapper.hh:60
static int size(const RT &x)
Definition cachedcomponentwrapper.hh:99
Dune::FieldMatrix< T, n, m > RT
Definition cachedcomponentwrapper.hh:85
static void getComponent(const RT &x, int i, RFT &xi)
Definition cachedcomponentwrapper.hh:94
static void setComponent(RT &x, int i, const RFT &xi)
Definition cachedcomponentwrapper.hh:88
std::vector< T > RT
Definition cachedcomponentwrapper.hh:113
static int size(const RT &x)
Definition cachedcomponentwrapper.hh:127
static void setComponent(RT &x, int i, const RFT &xi)
Definition cachedcomponentwrapper.hh:116
static void getComponent(const RT &x, int i, RFT &xi)
Definition cachedcomponentwrapper.hh:122
Cached evaluation of local basis functions.
Definition cachedcomponentwrapper.hh:149
CachedComponentWrapper(const int i=0)
Definition cachedcomponentwrapper.hh:174
EvaluationCache evalCache_
Definition cachedcomponentwrapper.hh:216
FunctionBaseClass::DomainType DomainType
Definition cachedcomponentwrapper.hh:151
int i_
Definition cachedcomponentwrapper.hh:214
const Imp & asImp() const
Definition cachedcomponentwrapper.hh:209
FunctionBaseClass::RangeType RangeType
Definition cachedcomponentwrapper.hh:152
void setIndex(int i)
Select local basis function to evaluate.
Definition cachedcomponentwrapper.hh:182
RangeType operator()(const DomainType &x) const
Evaluate local basis function selected last using setIndex.
Definition cachedcomponentwrapper.hh:192
T size(T... args)