Class documentation of Concepts

Loading...
Searching...
No Matches
arrays.hh
Go to the documentation of this file.
1
6#include "toolbox/array.hh"
7#include "cell1D.hh"
8#include "cell2D.hh"
9#include "cell3D.hh"
10
11#ifndef geometryArrays_hh
12#define geometryArrays_hh
13
14namespace concepts {
15
16 // ************************************************************* makeArray **
17
23 template<class F, class G>
24 void makeArray(const F& cell, const Array<Real>& p, G (F::*fun)(Real) const,
25 Array<G>& array) {
26 array.resize(p.size());
27 G* coord = array;
28 const Real* pAcc = p;
29 for (uint i = 0; i < p.size(); ++i)
30 *coord++ = (cell.*fun)(*pAcc++);
31 }
32
42 template<class F, class G>
43 void makeArray(const F& cell, const Array<Real>& pX, const Array<Real>& pY,
44 G (F::*fun)(Real, Real) const, Array<G>& array,
46 {
47 if (istensor) {
48 array.resize(pX.size() * pY.size());
49 G* coord = array;
50 const Real* pxAcc = pX;
51 for (uint i = 0; i < pX.size(); ++i) {
52 const Real* pyAcc = pY;
53 for (uint j = 0; j < pY.size(); ++j)
54 *coord++ = (cell.*fun)(*pxAcc, *pyAcc++);
55 pxAcc++;
56 }
57 } else { // non tensor case, simple one loop over all points
58 conceptsAssert(pX.size() == pY.size(), concepts::Assertion());
59
60 array.resize(pX.size());
61 G* coord = array;
62 const Real* pxAcc = pX;
63 const Real* pyAcc = pY;
64 for (uint i = 0; i < pX.size(); ++i)
65 *coord++ = (cell.*fun)(*pxAcc++, *pyAcc++);
66 } // else
67 }
68
78 template<class F, class G>
79 void makeArray(const F& cell,
80 const Array<Real>& pX,
81 const Array<Real>& pY,
82 const Array<Real>& pZ,
83 G (F::*fun)(Real, Real, Real) const, Array<G>& array,
85 {
86 if (istensor) {
87 array.resize(pX.size() * pY.size() * pZ.size());
88 G* coord = array;
89 const Real* pxAcc = pX;
90 for (uint i = 0; i < pX.size(); ++i) {
91 const Real* pyAcc = pY;
92 for (uint j = 0; j < pY.size(); ++j) {
93 const Real* pzAcc = pZ;
94 for (uint k = 0; k < pZ.size(); ++k)
95 *coord++ = (cell.*fun)(*pxAcc, *pyAcc, *pzAcc++);
96 pyAcc++;
97 }
98 pxAcc++;
99 }
100 } else { // non tensor case, simple one loop over all points
101 conceptsAssert(pX.size() == pY.size(), concepts::Assertion());
102 conceptsAssert(pX.size() == pZ.size(), concepts::Assertion());
103
104 array.resize(pX.size());
105 G* coord = array;
106 const Real* pxAcc = pX;
107 const Real* pyAcc = pY;
108 const Real* pzAcc = pZ;
109 for (uint i = 0; i < pX.size(); ++i)
110 *coord++ = (cell.*fun)(*pxAcc++, *pyAcc++, *pzAcc++);
111 } // else
112 }
113
114 // ************************************************************ ArrayCoord **
115
122 template<uint dim>
124 };
125
126 // ********************************************************* ArrayCoord<1> **
127
132 template<>
133 class ArrayCoord<1> : public Array<Real> {
134 public:
140 ArrayCoord(const Edge1d& edge, const Array<Real>& p);
141 };
142
143 // ********************************************************* ArrayCoord<2> **
144
149 template<>
150 class ArrayCoord<2> : public Array<Real2d> {
151 public:
157 ArrayCoord(const Quad2d& quad,
158 const Array<Real>& qX,
159 const Array<Real>& qY,
160 bool tensor = true);
166 ArrayCoord(const Edge2d& edge, const Array<Real>& p);
167 };
168
169 // ********************************************************* ArrayJacobian **
170
175 template<int gdim, int ldim>
177 };
178
179 // **************************************************** ArrayJacobian<1,1> **
180
185 template<>
186 class ArrayJacobian<1, 1> : public Array<Real> {
187 public:
193 ArrayJacobian(const EdgeNd& edge, const Array<Real>& p);
200 const Array<Real>& qX,
201 const Array<Real>& qY,
202 bool tensor = true);
203 };
204
205 // **************************************************** ArrayJacobian<2,2> **
206
212 template<>
213 class ArrayJacobian<2, 2> : public Array<Mapping<Real, 2> > {
214 public:
224 const Array<Real>& qX,
225 const Array<Real>& qY,
226 bool istensor = true);
227
236 ArrayJacobian(const QuadNd& quad, uint k, const Array<Real>& q);
237 };
238
239 // **************************************************** ArrayJacobian<2,2> **
240
245 template<>
246 class ArrayJacobian<3, 3> : public Array<Mapping<Real, 3> > {
247 public:
257 const Array<Real>& qX,
258 const Array<Real>& qY,
259 const Array<Real>& qZ,
260 bool istensor = true);
261 };
262
263 // ******************************************************** ArrayLocalCoord **
264
269 class ArrayLocalCoord: public Array<Real> {
270 public:
282 ArrayLocalCoord(const QuadNd& quad, uint k, uint dim, const Array<Real>& q);
283 private:
284 inline bool alongEdge(uint k, uint dim) {
285 return (k == 0 && dim == 1) || (k == 3 && dim == 0)
286 || (k == 1 && dim == 0) || (k == 2 && dim == 1);
287 }
288 };
289
290
295 template<int gdim, int ldim>
297 };
298
299 // **************************************************** ArrayHessian<1,1> **
300
306 template<>
307 class ArrayHessian<1, 1> : public Array<Real> {
308 public:
314 ArrayHessian(const EdgeNd& edge, const Array<Real>& p);
315
316 };
317
318
319} // namespace concepts
320
321#endif // geometryArrays_hh
ArrayCoord(const Edge1d &edge, const Array< Real > &p)
ArrayCoord(const Quad2d &quad, const Array< Real > &qX, const Array< Real > &qY, bool tensor=true)
ArrayCoord(const Edge2d &edge, const Array< Real > &p)
ArrayHessian(const EdgeNd &edge, const Array< Real > &p)
ArrayJacobian(const QuadNd &quad, const Array< Real > &qX, const Array< Real > &qY, bool tensor=true)
ArrayJacobian(const EdgeNd &edge, const Array< Real > &p)
ArrayJacobian(const QuadNd &quad, const Array< Real > &qX, const Array< Real > &qY, bool istensor=true)
ArrayJacobian(const QuadNd &quad, uint k, const Array< Real > &q)
ArrayJacobian(const Hexahedron3d &quad, const Array< Real > &qX, const Array< Real > &qY, const Array< Real > &qZ, bool istensor=true)
ArrayLocalCoord(const QuadNd &quad, uint k, uint dim, const Array< Real > &q)
uint size() const
Returns the requested size of the array.
Definition array.hh:259
void resize(const uint sz)
Definition array.hh:281
#define conceptsAssert(cond, exc)
double Real
Definition typedefs.hh:39
void makeArray(const F &cell, const Array< Real > &p, G(F::*fun)(Real) const, Array< G > &array)
Definition arrays.hh:24
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320