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 
14 namespace 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,
45  bool istensor = true)
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
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,
84  bool istensor = true)
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>
123  class ArrayCoord {
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);
199  ArrayJacobian(const QuadNd& quad,
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:
223  ArrayJacobian(const QuadNd& quad,
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>
296  class ArrayHessian {
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
uint size() const
Returns the requested size of the array.
Definition: array.hh:259
ArrayCoord(const Quad2d &quad, const Array< Real > &qX, const Array< Real > &qY, bool tensor=true)
Constructor for a Quad2d.
A 2D cell: quadrilateral.
Definition: cell2D.hh:378
Array of local coordinates, e.g., inside a quad, but only along an edge.
Definition: arrays.hh:269
ArrayJacobian(const QuadNd &quad, const Array< Real > &qX, const Array< Real > &qY, bool tensor=true)
Constructor for a QuadNd.
ArrayHessian(const EdgeNd &edge, const Array< Real > &p)
Constructor for a EdgeNd.
bool alongEdge(uint k, uint dim)
Definition: arrays.hh:284
A 3D cell: hexahedron.
Definition: cell3D.hh:317
A 1D cell: edge.
Definition: cell1D.hh:83
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
A 1D cell: edge in 2D.
Definition: cell1D.hh:189
ArrayLocalCoord(const QuadNd &quad, uint k, uint dim, const Array< Real > &q)
Constructor for a QuadNd, where local coordinates are evaluated on the edge.
Array of jacobian matrices on quadrature points.
Definition: arrays.hh:176
Array of hessian matrices on quadrature points.
Definition: arrays.hh:296
ArrayJacobian(const QuadNd &quad, uint k, const Array< Real > &q)
Constructor for a QuadNd, evaluated on an edge.
Exception class for assertions.
Definition: exceptions.hh:258
Base class for a quadrilateral in any dimension.
Definition: cell2D.hh:187
ArrayJacobian(const Hexahedron3d &quad, const Array< Real > &qX, const Array< Real > &qY, const Array< Real > &qZ, bool istensor=true)
Constructor for a Hexahedron.
ArrayJacobian(const EdgeNd &edge, const Array< Real > &p)
Constructor for a EdgeNd.
void makeArray(const F &cell, const Array< Real > &p, G(F::*fun)(Real) const, Array< G > &array)
Creates an array array by applying an function fun of a cell cell for each value p.
Definition: arrays.hh:24
ArrayJacobian(const QuadNd &quad, const Array< Real > &qX, const Array< Real > &qY, bool istensor=true)
Constructor for a QuadNd.
A 1D cell in any dimension: edge.
Definition: cell1D.hh:32
void resize(const uint sz)
Resizes the array.
Definition: array.hh:281
Array with coordinates of a cell.
Definition: arrays.hh:123
ArrayCoord(const Edge2d &edge, const Array< Real > &p)
Constructor for a Edge2d.
ArrayCoord(const Edge1d &edge, const Array< Real > &p)
Constructor for a Edge1d.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich