elementMaps3D.hh

Go to the documentation of this file.
1 
7 #ifndef elementMaps3D_hh
8 #define elementMaps3D_hh
9 
10 #include "basics/outputOperator.hh"
11 #include "basics/typedefs.hh"
13 #include "basics/debug.hh"
14 #include "elementMaps.hh"
15 
16 // debugging
17 #define geoMapTetrahedron3dAppl_D 0
18 
19 namespace concepts {
20 
21  // ***************************************************************** Map3d **
22 
26  class Map3d : public OutputOperator {
27  public:
28  std::ostream& info(std::ostream& os) const {return os << "Map3d()";};
29  };
30 
31 
32  // ****************************************************** MapTetrahedron3d **
33 
66  class MapTetrahedron3d : public Map3d {
67  public:
79  MapTetrahedron3d(char* map, Real scX, Real scY, Real scZ);
80 
87  MapTetrahedron3d(Real3d vtx0, Real3d vtx1, Real3d vtx2, Real3d vtx3);
88 
91  ~MapTetrahedron3d() { delete[] map_; }
92 
109  Real3d operator()(Real x, Real y, Real z) const {
110  if (map_)
111  return Real3d(map_, scx_ * x, scy_ * y, scz_ * z);
112  else {
113  Real3d xi(x*(1.0-y)*(1.0-z), y*(1.0-z), z);
114  Real3d res(B_ * xi);
115  res += b_;
116  DEBUGL(geoMapTetrahedron3dAppl_D, '(' << x << ", " << y
117  << ", " << z << ") -> " << xi << " -> " << res);
118  return res;
119  }
120  }
121 
123  Real jacobian() const {
124  if (map_)
125  throw conceptsException(MissingFeature("jacobian not supported"));
126  return B_.determinant(); }
127 
129  inline MapTetrahedron3d* clone() const {
130  return new MapTetrahedron3d(*this);
131  };
132 
133 private:
136 
138  uint sz_;
139 
142 
145 
148 
151 
154 
157  };
158 
159 
160  // ********************************************************** MappingHexahedron3d **
161 
162  //forward declaration
163  class MappingQuad3d;
164 
171  class MappingHexahedron3d : public Map3d {
172  public:
173 
174  virtual ~MappingHexahedron3d() {}
179  virtual Real3d operator()(Real x, Real y, Real z) const = 0;
180 
185  virtual MapReal3d jacobian(const Real x, const Real y, const Real z) const = 0;
186 
190  virtual MapReal3d hessian(uint i,const Real x, const Real y, const Real z) const = 0;
191 
196  virtual MapReal3d jacobianInverse(const Real x, const Real y, const Real z) const {
197  return jacobian(x,y,z).inverse(); }
198 
200  virtual Real jacobianDeterminant(const Real x, const Real y, const Real z) const {
201  return jacobian(x,y,z).determinant(); }
202 
204  virtual MappingQuad3d* face(const uint face) const = 0;
205 
207  virtual MappingHexahedron3d* clone() const = 0;
208 
210  virtual MappingHexahedron3d* part(const Real3d xi0, const Real3d xi1) const = 0;
211 
212  protected:
213  virtual std::ostream& info(std::ostream& os) const = 0;
214  };
215 
216  // ********************************************************* BlendingHexahedron3d **
217 
218  //forward declaration
219  class MappingQuad3d;
220  class MappingEdge3d;
221  class Hexahedron;
222 
243  public:
244 
271  BlendingHexahedron3d(const MappingQuad3d* quadmap0, const MappingQuad3d* quadmap1,
272  const MappingQuad3d* quadmap2, const MappingQuad3d* quadmap3,
273  const MappingQuad3d* quadmap4, const MappingQuad3d* quadmap5,
274  const Hexahedron& hex);
276  BlendingHexahedron3d* clone() const override { return new BlendingHexahedron3d(*this); }
278  Real3d operator()(Real x, Real y, Real z) const override;
279  MapReal3d jacobian(const Real x, const Real y, const Real z) const override;
280  MapReal3d hessian(uint i,const Real x, const Real y, const Real z) const override;
281  MappingQuad3d* face(const uint face) const override;
282  MappingEdge3d* edge(const uint edge) const;
284  MappingHexahedron3d* part(const Real3d xi0, const Real3d xi1) const override;
285  protected:
286  std::ostream& info(std::ostream& os) const override;
287  private:
288  // Maps of the faces
289  std::array<std::unique_ptr<MappingQuad3d>,6> quadmap_;
290  // Maps of the edges
291  std::array<std::unique_ptr<MappingEdge3d>,12> edgemap_;
292  // Coordinates of the vertices
293  std::array<Real3d,8> vtx_;
294 
295  // Find all geometric boundary quads, edges and vertices
296  // This function should actually be a member of a MappingHex class, which should independent of the
297  // dimension of the ambient space
298  void construct_(const std::array<const MappingQuad3d*,6>& quadmap, const Hexahedron& hex);
299  };
300 
301  // ***************************************************** PartMappingHexahedron3d **
302 
314  public:
321  const Real3d x0, const Real3d x1);
324  PartMappingHexahedron3d* clone() const override;
325  Real3d operator()(Real x, Real y, Real z) const override;
326  MapReal3d jacobian(const Real x, const Real y, const Real z) const override;
327  MapReal3d hessian(uint i,const Real x, const Real y, const Real z) const override;
328  MappingQuad3d* face(const uint face) const override;
329  PartMappingHexahedron3d* part(const Real3d x0, const Real3d x1) const override;
330  protected:
331  std::ostream& info(std::ostream& os) const override;
332  private:
334  std::unique_ptr<MappingHexahedron3d> map_;
336  const Real3d x0_;
338  const Real3d d_;
339 
341  inline const Real3d xi_(const Real x, const Real y, const Real z) const {
342  return x0_ + Real3d(x * d_[0], y * d_[1], z * d_[2]);
343  }
344  };
345 
346 
347  // ******************************************************* MapHexahedron3d **
348 
367 
370 
372  uint sz_;
373 
376 
379 
382 
385 
387  void operator=(const MapHexahedron3d &);
388 
389  public:
401  MapHexahedron3d(char* map, Real scX, Real scY, Real scZ);
402 
409  MapHexahedron3d(const Real3d& vtx0, const Real3d& vtx1,
410  const Real3d& vtx2, const Real3d& vtx3,
411  const Real3d& vtx4, const Real3d& vtx5,
412  const Real3d& vtx6, const Real3d& vtx7);
413 
416  ~MapHexahedron3d() { delete[] map_; delete[] comp_; }
417 
426  inline Real3d operator()(Real x, Real y, Real z) const {
427  conceptsAssert(x >= 0.0, Assertion());
428  conceptsAssert(x <= 1.0, Assertion());
429  conceptsAssert(y >= 0.0, Assertion());
430  conceptsAssert(y <= 1.0, Assertion());
431  conceptsAssert(z >= 0.0, Assertion());
432  conceptsAssert(z <= 1.0, Assertion());
433  if (map_)
434  return Real3d(map_, scx_ * x, scy_ * y, scz_* z);
435  else {
436  Real3d res(comp_[0]*(x*y*z));
437  res += comp_[1]*(x*y);
438  res += comp_[2]*(x*z);
439  res += comp_[3]*(y*z);
440  res += comp_[4]*x;
441  res += comp_[5]*y;
442  res += comp_[6]*z;
443  res += comp_[7];
444  return res;
445  }
446  }
447 
452  MapReal3d jacobian(const Real x, const Real y, const Real z) const;
453 
456  MapReal3d hessian(uint i,const Real x, const Real y, const Real z) const;
457 
462  MapReal3d jacobianInverse(const Real x, const Real y, const Real z) const {
463  return jacobian(x, y, z).inverse();
464  }
465 
467  Real jacobianDeterminant(const Real x, const Real y, const Real z) const {
468  return jacobian(x, y, z).determinant();
469  }
470 
472  MapHexahedron3d* clone() const { return new MapHexahedron3d(*this); }
473 
475  MappingQuad3d* face(uint face) const;
476 
478  MapHexahedron3d* part(const Real3d x0, const Real3d z0) const;
479 
480  protected:
481  virtual std::ostream& info(std::ostream& os) const;
482  };
483 
484 
485  // *************************************************** MapParallelepiped3d **
486 
495  class MapParallelepiped3d : public Map3d {
496  public:
503  MapParallelepiped3d(Real3d vtx0, Real3d vtx1, Real3d vtx2, Real3d vtx3);
504 
507 
516  Real3d operator()(Real x, Real y, Real z) const {
517  Real3d res(B1_*x + B2_*y + B3_*z);
518  res += b_;
519  return res;
520  }
521 
523  Real jacobian() const {
524  return (B1_ ^ B2_) * B3_;
525  }
526 
528  inline MapParallelepiped3d* clone() const {
529  return new MapParallelepiped3d(*this);
530  };
531 
532  private:
537 
540  };
541 
542 } // namespace concepts
543 
544 #endif // elementMaps3D_hh
MappingQuad3d * face(uint face) const
Returns the mapping of the given face.
std::array< Real3d, 8 > vtx_
Mapping< F, DimX, DimY > inverse() const
Returns the inverse of the matrix.
std::ostream & info(std::ostream &os) const override
Returns information in an output stream.
virtual MapReal3d jacobian(const Real x, const Real y, const Real z) const =0
Returns the jacobian of the element map.
virtual MappingHexahedron3d * part(const Real3d xi0, const Real3d xi1) const =0
Returns a part of the mapping.
MapTetrahedron3d(const MapTetrahedron3d &map)
Copy constructor.
F determinant() const
Returns the determinant of the matrix (only valid for square matrices)
BlendingHexahedron3d * clone() const override
Returns a copy of the map.
MapHexahedron3d(const MapHexahedron3d &map)
Copy constructor.
PartMappingHexahedron3d * clone() const override
Returns a copy of the map.
#define conceptsException(exc)
Prepares an exception for throwing.
Definition: exceptions.hh:344
MappingHexahedron3d * part(const Real3d xi0, const Real3d xi1) const override
uchar * map_
Parsed formula for the map.
Real3d b_
Computed map, vector part.
Real scx_
Right border of the x parameter domain.
An abstract class for a 3d map.
PartMappingHexahedron3d(const MappingHexahedron3d &map, const Real3d x0, const Real3d x1)
Constructor.
MapReal3d jacobian(const Real x, const Real y, const Real z) const
Returns the jacobian of the element map.
Base class for an edge element map .
MapHexahedron3d * part(const Real3d x0, const Real3d z0) const
Returns a part of the mapping.
MapHexahedron3d(char *map, Real scX, Real scY, Real scZ)
Constructor.
unsigned char uchar
Abbreviation for unsigned char.
Definition: typedefs.hh:45
virtual std::ostream & info(std::ostream &os) const =0
Returns information in an output stream.
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
MappingQuad3d * face(const uint face) const override
Returns the mapping of the given face.
Real3d operator()(Real x, Real y, Real z) const override
Returns a point in 3D mapped from the unit cube [0,1]3 onto the element in physical 3d space.
#define geoMapTetrahedron3dAppl_D
Real3d operator()(Real x, Real y, Real z) const
Returns a point in 3D mapped from the unit cube onto the element in the original mesh.
Point< Real, 3 > Real3d
Real3d operator()(Real x, Real y, Real z) const
Returns a point in 3D mapped from the unit cube [0,1]3 onto the element in the original mesh.
Real scz_
Right border of the z parameter domain.
Interface for the element map of a hexahedron embedded in R^3 (analogous to the design of MappingQuad...
std::unique_ptr< MappingHexahedron3d > map_
Parent hexahedron map.
#define DEBUGL(doit, msg)
PartMappingHexahedron3d(const PartMappingHexahedron3d &other)
Real jacobianDeterminant(const Real x, const Real y, const Real z) const
Returns the determinant of the Jacobian.
MapParallelepiped3d(Real3d vtx0, Real3d vtx1, Real3d vtx2, Real3d vtx3)
Constructor.
A 3D hexahedral element map for interpolation between arbitrary curved boundary quadrilateral element...
Real jacobian() const
Returns the jacobian.
virtual Real jacobianDeterminant(const Real x, const Real y, const Real z) const
Returns the determinant of the Jacobian.
Real scz_
Right border of the z parameter domain.
MapTetrahedron3d(char *map, Real scX, Real scY, Real scZ)
Constructor.
std::array< std::unique_ptr< MappingEdge3d >, 12 > edgemap_
Exception class for assertions.
Definition: exceptions.hh:258
A 3D element map for a hexahedron.
Real3d operator()(Real x, Real y, Real z) const
Returns a point in 3D mapped from the unit cube [0,1]3 onto the element in the original mesh.
A hexahedron in the topology.
Definition: topology3D.hh:134
const Real3d x0_
Coordinate of the lower left front vertex in the reference domain of the parent map.
MapReal3d jacobian(const Real x, const Real y, const Real z) const override
Returns the jacobian of the element map.
uint sz_
Length of the parsed formula.
void construct_(const std::array< const MappingQuad3d *, 6 > &quadmap, const Hexahedron &hex)
A 3D element map for a Parallelepiped.
MapReal3d B_
Computed map, matrix part.
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
const Real3d xi_(const Real x, const Real y, const Real z) const
Embedding of local coordinates to parent hexahedron reference domain.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual MapReal3d jacobianInverse(const Real x, const Real y, const Real z) const
Computes the inverse of the jacobian:
MapParallelepiped3d(const MapParallelepiped3d &map)
Copy constructor.
uchar * map_
Parsed formula for the map.
MapReal3d hessian(uint i, const Real x, const Real y, const Real z) const override
Returns the Hessian, the integer indicates which 3x3 submap of the 3x3xi (i=1..3) tensor is required.
MapHexahedron3d(const Real3d &vtx0, const Real3d &vtx1, const Real3d &vtx2, const Real3d &vtx3, const Real3d &vtx4, const Real3d &vtx5, const Real3d &vtx6, const Real3d &vtx7)
Constructor.
const Real3d d_
Widths of the restricted hexahedron in coordinates of the parent map.
Real scy_
Right border of the y parameter domain.
virtual MappingHexahedron3d * clone() const =0
Returns a copy of the map.
BlendingHexahedron3d(const BlendingHexahedron3d &v)
uint sz_
Length of the parsed formula.
Real scx_
Right border of the x parameter domain.
MapReal3d hessian(uint i, const Real x, const Real y, const Real z) const
Returns the hessian of the element map.
MapReal3d jacobianInverse(const Real x, const Real y, const Real z) const
Computes the inverse of the jacobian:
std::array< std::unique_ptr< MappingQuad3d >, 6 > quadmap_
std::ostream & info(std::ostream &os) const
Returns information in an output stream.
MapTetrahedron3d(Real3d vtx0, Real3d vtx1, Real3d vtx2, Real3d vtx3)
Constructor.
Real scy_
Right border of the y parameter domain.
Real3d operator()(Real x, Real y, Real z) const override
Returns a point in 3D mapped from the unit cube [0,1]3 onto the element in physical 3d space.
MappingEdge3d * edge(const uint edge) const
Exception class to express a missing feature.
Definition: exceptions.hh:206
MapParallelepiped3d * clone() const
Returns a copy of the map.
A 3D element map for a restriction of a given hexahedron element mapping.
MapTetrahedron3d * clone() const
Returns a copy of the map.
MapHexahedron3d * clone() const
Returns a copy of the map.
MapReal3d hessian(uint i, const Real x, const Real y, const Real z) const override
Returns the Hessian, the integer indicates which 3x3 submap of the 3x3xi (i=1..3) tensor is required.
BlendingHexahedron3d(const MappingQuad3d *quadmap0, const MappingQuad3d *quadmap1, const MappingQuad3d *quadmap2, const MappingQuad3d *quadmap3, const MappingQuad3d *quadmap4, const MappingQuad3d *quadmap5, const Hexahedron &hex)
void operator=(const MapParallelepiped3d &)
Private assignement operator.
PartMappingHexahedron3d * part(const Real3d x0, const Real3d x1) const override
Returns a part of the mapping.
MapReal3d jacobian(const Real x, const Real y, const Real z) const override
Returns the jacobian of the element map.
MappingQuad3d * face(const uint face) const override
Returns the mapping of the given face.
void operator=(const MapTetrahedron3d &)
Private assignement operator.
Class providing an output operator.
void operator=(const MapHexahedron3d &)
Private assignement operator.
virtual MappingQuad3d * face(const uint face) const =0
Returns the mapping of the given face.
virtual MapReal3d hessian(uint i, const Real x, const Real y, const Real z) const =0
Returns the Hessian, the integer indicates which 3x3 submap of the 3x3xi (i=1..3) tensor is required.
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Real3d * comp_
Computed map.
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
virtual Real3d operator()(Real x, Real y, Real z) const =0
Returns a point in 3D mapped from the unit cube [0,1]3 onto the element in physical 3d space.
A 3D element map for a tetrahedron.
std::ostream & info(std::ostream &os) const override
Returns information in an output stream.
BlendingHexahedron3d(const Sequence< const MappingQuad3d * > quadmap, const Hexahedron &hex)
Constructor.
Real jacobian() const
Returns the jacobian.
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich