Class documentation of Concepts

Loading...
Searching...
No Matches
functionBase.hh
Go to the documentation of this file.
1
6#ifndef hpFunctionBase2d_hh
7#define hpFunctionBase2d_hh
8
9#include "space/function.hh"
10#include "toolbox/stiffArray.hh"
11#include "quad.hh"
12
13namespace hp2D {
14
15 using concepts::Real;
16 using concepts::Real2d;
17
18 // ******************************************************* ElementFunction **
19
35 template<uint dim, typename F = Real, typename Q = Quad<Real> >
37 public concepts::ElementFunction<F, typename Q::type>
38 {
39 public:
41
43 virtual uint n() const { return dim; }
44
45 virtual void operator() (const Element& elm,
46 const concepts::Array<F>& coeff,
47 concepts::Array<F>& val, const uint *i) const;
48 virtual void operator() (const Element& elm,
49 const uint* j,
50 concepts::Array<F>& val, const uint* i) const;
51 virtual void operator() (const Element& elm,
52 const concepts::Array<F>& coeff,
53 concepts::Array<F>& val, const Real p,
54 const Real t = 0.0) const;
55 virtual void operator() (const Element& elm,
56 const concepts::Array<F>& coeff,
57 concepts::Array<F>& val, const Real2d& p,
58 const Real t = 0.0) const;
59 virtual void operator() (const Element& elm,
60 const concepts::Array<F>& coeff,
62 const concepts::Real3d& p,
63 const Real t = 0.0) const;
64 private:
65 virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
67 const uint i[2]) const = 0;
68
69 virtual void compute_(const Q& elm, const uint j[3],
71 const uint i[2]) const = 0;
72
73 virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
75 const Real2d& p, const Real t = 0.0) const = 0;
76 };
77
78 template<uint dim, typename F, typename Q>
79 void ElementFunction<dim,F,Q>::operator()
80 (const Element& elm, const concepts::Array<F>& coeff,
81 concepts::Array<F>& val, const uint *i) const {
82 // Quadrilaterial
83 const Q* quad = dynamic_cast<const Q*>(&elm);
84 if (quad) return compute_(*quad, coeff, val, i);
85
86 throw conceptsException(concepts::MissingFeature("element not supported"));
87 }
88
89 template<uint dim, typename F, typename Q>
90 void ElementFunction<dim,F,Q>::operator()
91 (const Element& elm, const uint* j,
92 concepts::Array<F>& val, const uint *i) const {
93 // Quadrilaterial
94 const Q* quad = dynamic_cast<const Q*>(&elm);
95 if (quad) return compute_(*quad, j, val, i);
96
97 throw conceptsException(concepts::MissingFeature("element not supported"));
98 }
99
100 template<uint dim, typename F, typename Q>
101 void ElementFunction<dim,F,Q>::operator()
102 (const Element& elm, const concepts::Array<F>& coeff,
103 concepts::Array<F>& val, const Real p, const Real t) const {
104 const Real2d p2(p);
105
106 // Quadrilaterial
107 const Q* quad = dynamic_cast<const Q*>(&elm);
108 if (quad) return compute_(*quad, coeff, val, p2, t);
109
110 throw conceptsException(concepts::MissingFeature("element not supported"));
111 }
112
113 template<uint dim, typename F, typename Q>
114 void ElementFunction<dim,F,Q>::operator()
115 (const Element& elm, const concepts::Array<F>& coeff,
116 concepts::Array<F>& val, const Real2d& p, const Real t) const {
117 // Quadrilaterial
118 const Q* quad = dynamic_cast<const Q*>(&elm);
119 if (quad) return compute_(*quad, coeff, val, p, t);
120
121 throw conceptsException(concepts::MissingFeature("element not supported"));
122 }
123
124 template<uint dim, typename F, typename Q>
125 void ElementFunction<dim,F,Q>::operator()
126 (const Element& elm, const concepts::Array<F>& coeff,
127 concepts::Array<F>& val, const concepts::Real3d& p, const Real t) const {
128 const Real2d p2(p);
129
130 // Quadrilaterial
131 const Q* quad = dynamic_cast<const Q*>(&elm);
132 if (quad) return compute_(*quad, coeff, val, p2, t);
133
134 throw conceptsException(concepts::MissingFeature("element not supported"));
135 }
136
137 // **************************************************** ElementFunction<1> **
138
139 template<typename F, typename Q>
140 class ElementFunction<1,F,Q> :
141 public concepts::ElementFunction<F, typename Q::type> {
142 public:
144
146 virtual uint n() const { return 1; }
147 virtual void operator() (const Element& elm,
148 const concepts::Array<F>& coeff,
149 concepts::Array<F>& val, const uint *i) const;
150 virtual void operator() (const Element& elm,
151 const uint* j,
152 concepts::Array<F>& val, const uint* i) const;
153 virtual void operator() (const Element& elm,
154 const concepts::Array<F>& coeff,
155 concepts::Array<F>& val, const Real p,
156 const Real t = 0.0) const;
157 virtual void operator() (const Element& elm,
158 const concepts::Array<F>& coeff,
159 concepts::Array<F>& val, const Real2d& p,
160 const Real t = 0.0) const;
161 virtual void operator() (const Element& elm,
162 const concepts::Array<F>& coeff,
164 const concepts::Real3d& p,
165 const Real t = 0.0) const;
166
167 virtual void operator() (const Element& elm,
168 const concepts::Array<F>& coeff,
169 F& val, const uint *i) const;
170 virtual void operator() (const Element& elm,
171 const uint* j,
172 F& val, const uint* i) const;
173 virtual void operator() (const Element& elm,
174 const concepts::Array<F>& coeff,
175 F& val, const Real p,
176 const Real t = 0.0) const;
177 virtual void operator() (const Element& elm,
178 const concepts::Array<F>& coeff,
179 F& val, const Real2d& p,
180 const Real t = 0.0) const;
181 virtual void operator() (const Element& elm,
182 const concepts::Array<F>& coeff,
183 F& val, const concepts::Real3d& p,
184 const Real t = 0.0) const;
185 private:
186 virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
187 F& val, const uint i[2]) const = 0;
188 virtual void compute_(const Q& elm, const uint j[3],
189 F& val, const uint i[2]) const = 0;
190 virtual void compute_(const Q& elm, const concepts::Array<F>& coeff,
191 F& val, const Real2d& p, const Real t) const = 0;
192 };
193
194 template<typename F, typename Q>
195 void ElementFunction<1,F,Q>::operator()
196 (const Element& elm, const concepts::Array<F>& coeff,
197 concepts::Array<F>& val, const uint *i) const {
198 val.resize(1);
199 (*this)(elm, coeff, val[0], i);
200 }
201
202 template<typename F, typename Q>
203 void ElementFunction<1,F,Q>::operator()
204 (const Element& elm, const uint* j,
205 concepts::Array<F>& val, const uint *i) const {
206 val.resize(1);
207 (*this)(elm, j, val[0], i);
208 }
209
210 template<typename F, typename Q>
211 void ElementFunction<1,F,Q>::operator()
212 (const Element& elm, const concepts::Array<F>& coeff,
213 concepts::Array<F>& val, const Real p, const Real t) const {
214 const Real2d p2(p);
215 val.resize(1);
216 (*this)(elm, coeff, val[0], p2, t);
217 }
218
219 template<typename F, typename Q>
220 void ElementFunction<1,F,Q>::operator()
221 (const Element& elm, const concepts::Array<F>& coeff,
222 concepts::Array<F>& val, const Real2d& p, const Real t) const {
223 val.resize(1);
224 (*this)(elm, coeff, val[0], p, t);
225 }
226
227 template<typename F, typename Q>
228 void ElementFunction<1,F,Q>::operator()
229 (const Element& elm, const concepts::Array<F>& coeff,
230 concepts::Array<F>& val, const concepts::Real3d& p, const Real t) const {
231 const Real2d p2(p);
232 val.resize(1);
233 (*this)(elm, coeff, val[0], p2, t);
234 }
235
236 // *************
237
238 template<typename F, typename Q>
239 void ElementFunction<1,F,Q>::operator()
240 (const Element& elm, const concepts::Array<F>& coeff,
241 F& val, const uint *i) const {
242 // Quadrilaterial
243 const Q* quad = dynamic_cast<const Q*>(&elm);
244 if (quad)
245 return compute_(*quad, coeff, val, i);
246
247 throw conceptsException(concepts::MissingFeature("element not supported"));
248 }
249
250 template<typename F, typename Q>
251 void ElementFunction<1,F,Q>::operator()
252 (const Element& elm, const uint* j,
253 F& val, const uint *i) const {
254 // Quadrilaterial
255 const Q* quad = dynamic_cast<const Q*>(&elm);
256 if (quad) return compute_(*quad, j, val, i);
257
258 throw conceptsException(concepts::MissingFeature("element not supported"));
259 }
260
261 template<typename F, typename Q>
262 void ElementFunction<1,F,Q>::operator()
263 (const Element& elm, const concepts::Array<F>& coeff,
264 F& val, const Real p, const Real t) const {
265 const Real2d p2(p);
266 (*this)(elm, coeff, val, p2, t);
267 }
268
269 template<typename F, typename Q>
270 void ElementFunction<1,F,Q>::operator()
271 (const Element& elm, const concepts::Array<F>& coeff,
272 F& val, const Real2d& p, const Real t) const {
273 // Quadrilaterial
274 const Q* quad = dynamic_cast<const Q*>(&elm);
275 if (quad) return compute_(*quad, coeff, val, p, t);
276
277 throw conceptsException(concepts::MissingFeature("element not supported"));
278 }
279
280 template<typename F, typename Q>
281 void ElementFunction<1,F,Q>::operator()
282 (const Element& elm, const concepts::Array<F>& coeff,
283 F& val, const concepts::Real3d& p, const Real t) const {
284 const Real2d p2(p);
285 (*this)(elm, coeff, val, p2, t);
286 }
287
288} // namespace hp2D
289
290
291#endif // hpFunctionBase2d_hh
#define conceptsException(exc)
virtual uint n() const
Number of components.
virtual uint n() const
Number of components.
double Real
Definition typedefs.hh:39
GenericElement< KarniadakisMixin< F > > Element
template aliases for backwards compatibility
Definition element.hh:267