cell3D.hh

Go to the documentation of this file.
1 
8 #ifndef cell3D_hh
9 #define cell3D_hh
10 
11 #include <iostream>
12 #include "basics/typedefs.hh"
14 #include "basics/level.hh"
15 #include "topology3D.hh"
16 #include "cell.hh"
17 #include "elementMaps3D.hh"
18 
19 
20 namespace concepts {
21 
22  // ****************************************************** NegativeJacobian **
23 
29  public:
34  NegativeJacobian(const std::string& errMsg) throw();
35  protected:
36  virtual std::ostream& info(std::ostream& os) const throw();
37  };
38 
39  // ********************************************************* Tetrahedron3d **
40 
47  class Tetrahedron3d : public Cell3 {
48  public:
49 
50  /* Type for indices in the hierarchical definition of the cells
51 
52  Use a type with a larger range depending on the number of cell
53  refinements.
54  */
55  typedef uint index_type;
56 
57  // Maximal number of levels in the cell refinement
58 
59  static uint MAX_LEVEL;
60 
62  struct Index {
65 
71 
77 
83 
84  inline Index() : l_(0), i_(0), j_(0), k_(0) {}
86  l_(l), i_(i), j_(j), k_(k) {}
87  inline std::ostream& info(std::ostream& os) const;
88  };
89 
96  virtual ~Tetrahedron3d();
97 
98  virtual Tetrahedron3d* child(uint i);
99  virtual const Tetrahedron3d* child(uint i) const;
100  Tetrahedron& connector() const { return cntr_; }
101 
110  Real3d chi(Real xi, Real eta, Real zeta) const;
111  Real3d center() const {return chi(0.5, 0.5, 0.5);};
112 
113  Real3d vertex(uint i) const;
114  protected:
115  virtual std::ostream& info(std::ostream& os) const;
116  private:
119 
122 
125 
130 
133 
136  const Index& idx);
137  };
138 
139  inline std::ostream& Tetrahedron3d::Index::info(std::ostream& os) const {
140  return os << '(' << (uint)l_ << ", "
141  << i_ << ", " << j_ << ", " << k_ << ')';
142  }
143 
144  // ****************************************************** Hex3dSubdivision **
145 
146  class Hexahedron3d;
147 
160  public:
163  virtual void createChildren(Hexahedron3d& h) const = 0;
166  virtual void removeChildren(Hexahedron3d& h) const;
169  virtual const HexSubdivision* topologicalStrategy() const = 0;
170  };
171 
172  // ********************************************************** Hex3dSubdiv8 **
173 
178  public:
179  virtual void createChildren(Hexahedron3d& h) const;
180  virtual const HexSubdiv8* topologicalStrategy() const;
181  static const Hex3dSubdiv8* instance();
182  virtual ~Hex3dSubdiv8();
183  protected:
184  virtual std::ostream& info(std::ostream& os) const;
185  private:
186  static std::unique_ptr<Hex3dSubdiv8> instance_;
187  };
188 
189  // ********************************************************* Hex3dSubdiv2x **
190 
196  public:
197  virtual void createChildren(Hexahedron3d& h) const;
198  virtual const HexSubdiv2x* topologicalStrategy() const;
199  static const Hex3dSubdiv2x* instance();
200  virtual ~Hex3dSubdiv2x();
201  protected:
202  virtual std::ostream& info(std::ostream& os) const;
203  private:
204  static std::unique_ptr<Hex3dSubdiv2x> instance_;
205  };
206 
207  // ********************************************************* Hex3dSubdiv2y **
208 
214  public:
215  virtual void createChildren(Hexahedron3d& h) const;
216  virtual const HexSubdiv2y* topologicalStrategy() const;
217  static const Hex3dSubdiv2y* instance();
218  virtual ~Hex3dSubdiv2y();
219  protected:
220  virtual std::ostream& info(std::ostream& os) const;
221  private:
222  static std::unique_ptr<Hex3dSubdiv2y> instance_;
223  };
224 
225  // ********************************************************* Hex3dSubdiv2z **
226 
232  public:
233  virtual void createChildren(Hexahedron3d& h) const;
234  virtual const HexSubdiv2z* topologicalStrategy() const;
235  static const Hex3dSubdiv2z* instance();
236  virtual ~Hex3dSubdiv2z();
237  protected:
238  virtual std::ostream& info(std::ostream& os) const;
239  private:
240  static std::unique_ptr<Hex3dSubdiv2z> instance_;
241  };
242 
243  // ********************************************************* Hex3dSubdiv4x **
244 
249  public:
250  virtual void createChildren(Hexahedron3d& h) const;
251  virtual const HexSubdiv4x* topologicalStrategy() const;
252  static const Hex3dSubdiv4x* instance();
253  virtual ~Hex3dSubdiv4x();
254  protected:
255  virtual std::ostream& info(std::ostream& os) const;
256  private:
257  static std::unique_ptr<Hex3dSubdiv4x> instance_;
258  };
259 
260  // ********************************************************* Hex3dSubdiv4y **
261 
266  public:
267  virtual void createChildren(Hexahedron3d& h) const;
268  virtual const HexSubdiv4y* topologicalStrategy() const;
269  static const Hex3dSubdiv4y* instance();
270  virtual ~Hex3dSubdiv4y();
271  protected:
272  virtual std::ostream& info(std::ostream& os) const;
273  private:
274  static std::unique_ptr<Hex3dSubdiv4y> instance_;
275  };
276 
277  // ********************************************************* Hex3dSubdiv4z **
278 
283  public:
284  virtual void createChildren(Hexahedron3d& h) const;
285  virtual const HexSubdiv4z* topologicalStrategy() const;
286  static const Hex3dSubdiv4z* instance();
287  virtual ~Hex3dSubdiv4z();
288  protected:
289  virtual std::ostream& info(std::ostream& os) const;
290  private:
291  static std::unique_ptr<Hex3dSubdiv4z> instance_;
292  };
293 
294  // ********************************************************** Hexahedron3d **
295 
296  // forward declaration
297  class MappingQuad3d;
298 
317  class Hexahedron3d : public Cell3 {
318  friend class Hex3dSubdivision;
319  friend class Hex3dSubdiv8;
320  friend class Hex3dSubdiv2x;
321  friend class Hex3dSubdiv2y;
322  friend class Hex3dSubdiv2z;
323  friend class Hex3dSubdiv4x;
324  friend class Hex3dSubdiv4y;
325  friend class Hex3dSubdiv4z;
326  public:
327 
328  /* Type for indices in the hierarchical definition of the cells
329 
330  Use a type with a larger range depending on the number of cell
331  refinements.
332  */
333  typedef uint index_type;
334 
335  // Maximal number of levels in the cell refinement
336 
337  static uint MAX_LEVEL;
338 
340  struct Index {
343 
349 
355 
361 
362  inline Index() : level_(0), i_(0), j_(0), k_(0) {}
363  inline Index(uchar l, uchar m, uchar n, index_type i, index_type j, index_type k) :
364  level_(l), i_(i), j_(j), k_(k) { level_.l_[1] = m; level_.l_[2] = n; }
365  inline Index(const Index& i) : level_(i.level_), i_(i.i_), j_(i.j_),
366  k_(i.k_) {}
367  };
368 
369  friend std::ostream& operator<<(std::ostream& os,
370  const Hexahedron3d::Index& i);
371 
378  virtual ~Hexahedron3d();
379 
380  virtual Hexahedron3d* child(uint i);
381  virtual const Hexahedron3d* child(uint i) const;
382  inline Hexahedron& connector() const { return cntr_; }
383 
392  Real3d chi(Real xi, Real eta, Real zeta) const;
393 
394  Real3d elemMap(const Real3d& coord_local) const
395  {
396  return chi(coord_local[0], coord_local[1], coord_local[2]);
397  }
398 
424  MapReal3d jacobian(const Real xi, const Real eta, const Real zeta) const;
425 
427 
428  /*
429  * Hessian of the mapping
430  */
431 
432  MapReal3d hessian(const uint i,const Real xi, const Real eta, const Real zeta) const;
433 
434  MapReal3d hessian(const uint i,const concepts::Real3d& p) const;
435 
439  MapReal3d jacobianInverse(const Real xi, const Real eta,
440  const Real zeta) const {
441  return jacobian(xi, eta, zeta).inverse();
442  }
443 
447  Real jacobianDeterminant(const Real xi, const Real eta,
448  const Real zeta) const {
449  return jacobian(xi, eta, zeta).determinant();
450  }
451 
453  const Level<3>& level() const { return idx_.level_; }
454 
455  Real3d vertex(uint i) const;
456  Real3d center() const {return chi(0.5, 0.5, 0.5);};
457 
459  inline const MappingHexahedron3d* map() const {return map_;};
460 
464  MappingQuad3d* faceMap(uint face) const;
465 
478  void setStrategy(const Hex3dSubdivision* strategy = 0)
479  throw(StrategyChange);
480 
486  const Hex3dSubdivision* getStrategy() const { return subdivStrategy_; }
487  protected:
488  virtual std::ostream& info(std::ostream& os) const;
489  private:
492 
495 
498 
503 
506 
509 
512  const Index& idx);
513  };
514 
515  // ****************************************************** Parallelepiped3d **
516 
524  class Parallelepiped3d : public Cell3 {
525  public:
526 
527  /* Type for indices in the hierarchical definition of the cells
528 
529  Use a type with a larger range depending on the number of cell
530  refinements.
531  */
532  typedef uint index_type;
533 
534  // Maximal number of levels in the cell refinement
535 
536  static uint MAX_LEVEL;
537 
539  struct Index {
542 
548 
554 
560 
561  inline Index() : l_(0), i_(0), j_(0), k_(0) {}
563  l_(l), i_(i), j_(j), k_(k) {}
564  inline std::ostream& info(std::ostream& os) const;
565  };
566 
573  virtual ~Parallelepiped3d();
574 
575  virtual Parallelepiped3d* child(uint c);
576  virtual const Parallelepiped3d* child(uint c) const;
577  Hexahedron& connector() const { return cntr_; }
578 
587  Real3d chi(Real xi, Real eta, Real zeta) const;
588  Real3d center() const {return chi(0.5, 0.5, 0.5);};
589 
590  Real3d vertex(uint i) const;
591  protected:
592  virtual std::ostream& info(std::ostream& os) const;
593  private:
596 
599 
602 
607 
610 
613  const Index& idx);
614  };
615 
616  inline std::ostream& Parallelepiped3d::Index::info(std::ostream& os) const {
617  return os << '(' << (uint)l_ << ", "
618  << i_ << ", " << j_ << ", " << k_ << ')';
619  }
620 
621 } // namespace concepts
622 
623 #endif // cell3D_hh
MappingHexahedron3d * map_
Pointer to the element map.
Definition: cell3D.hh:505
virtual Tetrahedron3d * child(uint i)
Returns a pointer to the ith child.
virtual void removeChildren(Hexahedron3d &h) const
If there are chilren, they are removed.
index_type j_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:354
Parallelepiped3d(Hexahedron &cntr, MapParallelepiped3d *map, const Index &idx)
Private constructor.
Mapping< F, DimX, DimY > inverse() const
Returns the inverse of the matrix.
Hexahedron & cntr_
Reference to the hexahedron connector (topology)
Definition: cell3D.hh:494
MappingQuad3d * faceMap(uint face) const
Returns the mapping of a face.
Subdivision strategy for hexahedrons which generates 2 children perpendicular the y direction.
Definition: hexsubdiv.hh:211
Real3d chi(Real xi, Real eta, Real zeta) const
The element map.
Hexahedron & connector() const
Returns the connector.
Definition: cell3D.hh:577
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Real3d center() const
Returns the center of the cell.
Definition: cell3D.hh:111
Subdivision strategy for hexahedrons which generates 2 children.
Definition: cell3D.hh:195
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
static const Hex3dSubdiv2z * instance()
Subclass of Tetrahedron3d representing its index.
Definition: cell3D.hh:62
Hexahedron3d * chld_
Pointer to the first child.
Definition: cell3D.hh:502
static std::unique_ptr< Hex3dSubdiv8 > instance_
Definition: cell3D.hh:186
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Interface for topological subdivision strategies for hexahedrons.
Definition: hexsubdiv.hh:40
NegativeJacobian(const std::string &errMsg)
Constructor.
uchar l_
Level of this element.
Definition: cell3D.hh:64
Real jacobianDeterminant(const Real xi, const Real eta, const Real zeta) const
Returns the determinant of the Jacobian for xi, eta, zeta .
Definition: cell3D.hh:447
Tetrahedron3d(Tetrahedron &cntr, const MapTetrahedron3d &map)
Constructor.
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
Subdivision strategy for hexahedrons which generates 4 children.
Definition: cell3D.hh:248
const MappingHexahedron3d * map() const
Returns the element map.
Definition: cell3D.hh:459
virtual Parallelepiped3d * child(uint c)
Returns a pointer to the ith child.
A 3D cell: hexahedron.
Definition: cell3D.hh:317
Tetrahedron & connector() const
Returns the connector.
Definition: cell3D.hh:100
Tetrahedron & cntr_
Reference to the tetrahedron connector (topology)
Definition: cell3D.hh:121
Real3d chi(Real xi, Real eta, Real zeta) const
The element map.
static uint MAX_LEVEL
Definition: cell3D.hh:337
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
Hexahedron3d(Hexahedron &cntr, const MappingHexahedron3d &map)
Constructor.
Index idx_
Index of this element.
Definition: cell3D.hh:491
index_type k_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:82
MapReal3d jacobian(const concepts::Real3d &p) const
Three dimensional cell.
Definition: cell.hh:112
static const Hex3dSubdiv2y * instance()
virtual const Parallelepiped3d * child(uint c) const
Returns a pointer to the ith child.
static std::unique_ptr< Hex3dSubdiv2y > instance_
Definition: cell3D.hh:222
Subclass of Hexahedron3d representing its index.
Definition: cell3D.hh:340
unsigned char uchar
Abbreviation for unsigned char.
Definition: typedefs.hh:45
Real3d elemMap(const Real3d &coord_local) const
Element map from point local coordinates in 3D.
Definition: cell3D.hh:394
Tetrahedron3d * chld_
Pointer to the first child.
Definition: cell3D.hh:129
Hexahedron & cntr_
Reference to the tetrahedron connector (topology)
Definition: cell3D.hh:598
Subdivision strategy for hexahedrons which generates 4 children along the x direction.
Definition: hexsubdiv.hh:255
Tetrahedron3d * lnk_
Pointer to a sibling.
Definition: cell3D.hh:124
Exception indicating that changing the subdivision strategy is not allowed (but was tried anyway).
Index(uchar l, index_type i, index_type j, index_type k)
Definition: cell3D.hh:562
Interface for the element map of a hexahedron embedded in R^3 (analogous to the design of MappingQuad...
virtual const Hexahedron3d * child(uint i) const
Returns a pointer to the ith child.
static std::unique_ptr< Hex3dSubdiv4y > instance_
Definition: cell3D.hh:274
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Subdivision strategy for hexahedrons which generates 2 children perpendicular to the x direction.
Definition: hexsubdiv.hh:189
MapParallelepiped3d * map_
Pointer to the element map.
Definition: cell3D.hh:609
index_type k_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:360
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Parallelepiped3d * chld_
Pointer to the first child.
Definition: cell3D.hh:606
Parallelepiped3d(Hexahedron &cntr, const MapParallelepiped3d &map)
Constructor.
virtual const HexSubdivision * topologicalStrategy() const =0
Returns the respective topological subdivision strategy.
static const Hex3dSubdiv4z * instance()
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
Real3d chi(Real xi, Real eta, Real zeta) const
The element map.
A hexahedron in the topology.
Definition: topology3D.hh:134
static uint MAX_LEVEL
Definition: cell3D.hh:59
Subdivision strategy for hexahedrons which generates 2 children.
Definition: cell3D.hh:231
Subdivision strategy for hexahedrons which generates 8 children.
Definition: hexsubdiv.hh:167
static std::unique_ptr< Hex3dSubdiv4z > instance_
Definition: cell3D.hh:291
A tetrahedron in the topology.
Definition: topology3D.hh:35
MapReal3d hessian(const uint i, const concepts::Real3d &p) const
A 3D element map for a Parallelepiped.
uchar l_
Level of this element.
Definition: cell3D.hh:541
MapReal3d jacobianInverse(const Real xi, const Real eta, const Real zeta) const
Returns the inverse of the Jacobian for xi, eta, zeta .
Definition: cell3D.hh:439
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
A 3D cell: parallelepiped.
Definition: cell3D.hh:524
index_type i_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:348
Level< 3 > level_
Level of this element.
Definition: cell3D.hh:342
MapReal3d jacobian(const Real xi, const Real eta, const Real zeta) const
Computes the Jacobian for xi, eta, zeta .
virtual const HexSubdiv2x * topologicalStrategy() const
Returns the respective topological subdivision strategy.
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
const Hex3dSubdivision * subdivStrategy_
Subdivision strategy for the hexahedron.
Definition: cell3D.hh:508
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
MapReal3d hessian(const uint i, const Real xi, const Real eta, const Real zeta) const
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
Subdivision strategy for hexahedrons which generates 4 children.
Definition: cell3D.hh:282
index_type j_
Index of this element on the local level with respect to the element and the y axis.
Definition: cell3D.hh:553
Real3d vertex(uint i) const
Returns the coordinates of the ith vertex.
MapTetrahedron3d * map_
Pointer to the element map.
Definition: cell3D.hh:132
Subdivision strategy for hexahedrons which generates 8 children.
Definition: cell3D.hh:177
virtual const HexSubdiv2y * topologicalStrategy() const
Returns the respective topological subdivision strategy.
A 3D cell: tetrahedron.
Definition: cell3D.hh:47
static const Hex3dSubdiv4y * instance()
static const Hex3dSubdiv4x * instance()
index_type i_
Index of this element on the local level with respect to the element and the x axis.
Definition: cell3D.hh:547
virtual const HexSubdiv4y * topologicalStrategy() const
Returns the respective topological subdivision strategy.
virtual const Tetrahedron3d * child(uint i) const
Returns a pointer to the ith child.
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Parallelepiped3d * lnk_
Pointer to a sibling.
Definition: cell3D.hh:601
Index(const Index &i)
Definition: cell3D.hh:365
Subdivision strategy for hexahedrons which generates 2 children.
Definition: cell3D.hh:213
Subdivision strategy for hexahedrons which generates 4 children along the z direction.
Definition: hexsubdiv.hh:299
Index(uchar l, index_type i, index_type j, index_type k)
Definition: cell3D.hh:85
virtual const HexSubdiv4x * topologicalStrategy() const
Returns the respective topological subdivision strategy.
index_type i_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:70
virtual Hexahedron3d * child(uint i)
Returns a pointer to the ith child.
const Level< 3 > & level() const
Returns the level of the cell.
Definition: cell3D.hh:453
Tetrahedron3d(Tetrahedron &cntr, MapTetrahedron3d *map, const Index &idx)
Private constructor.
virtual const HexSubdiv2z * topologicalStrategy() const
Returns the respective topological subdivision strategy.
Index idx_
Index of this element.
Definition: cell3D.hh:118
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Exception class to express a missing feature.
Definition: exceptions.hh:206
virtual const HexSubdiv4z * topologicalStrategy() const
Returns the respective topological subdivision strategy.
Index(uchar l, uchar m, uchar n, index_type i, index_type j, index_type k)
Definition: cell3D.hh:363
Real3d center() const
Returns the center of the cell.
Definition: cell3D.hh:456
short l_[dim]
Level.
Definition: level.hh:24
index_type j_
Index of this element on the local level with respect to the element in the original mesh.
Definition: cell3D.hh:76
Index idx_
Index of this element.
Definition: cell3D.hh:595
Hexahedron & connector() const
Returns the connector.
Definition: cell3D.hh:382
Hexahedron3d * lnk_
Pointer to a sibling.
Definition: cell3D.hh:497
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
static std::unique_ptr< Hex3dSubdiv2x > instance_
Definition: cell3D.hh:204
Subdivision strategy for hexahedrons which generates 4 children.
Definition: cell3D.hh:265
virtual void createChildren(Hexahedron3d &h) const =0
If no children of h exist, they are created.
Subdivision strategy for hexahedrons which generates 2 children perpendicular to the z direction.
Definition: hexsubdiv.hh:233
Hexahedron3d(Hexahedron &cntr, MappingHexahedron3d *map, const Index &idx)
Private constructor.
friend std::ostream & operator<<(std::ostream &os, const Hexahedron3d::Index &i)
Exception which indicates that a negative Jacobian was found.
Definition: cell3D.hh:28
Subclass of Tetrahedron3d representing its index.
Definition: cell3D.hh:539
static const Hex3dSubdiv2x * instance()
static const Hex3dSubdiv8 * instance()
Class providing an output operator.
virtual const HexSubdiv8 * topologicalStrategy() const
Returns the respective topological subdivision strategy.
static std::unique_ptr< Hex3dSubdiv4x > instance_
Definition: cell3D.hh:257
std::ostream & info(std::ostream &os) const
Definition: cell3D.hh:139
static std::unique_ptr< Hex3dSubdiv2z > instance_
Definition: cell3D.hh:240
Subdivision strategy for hexahedrons which generates 4 children along the y direction.
Definition: hexsubdiv.hh:277
Real3d center() const
Returns the center of the cell.
Definition: cell3D.hh:588
Interface for geometrical subdivision strategies for hexahedrons.
Definition: cell3D.hh:159
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
void setStrategy(const Hex3dSubdivision *strategy=0)
Sets the subdivision strategy of this hexahedron.
index_type k_
Index of this element on the local level with respect to the element and the z axis.
Definition: cell3D.hh:559
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
A 3D element map for a tetrahedron.
virtual void createChildren(Hexahedron3d &h) const
If no children of h exist, they are created.
std::ostream & info(std::ostream &os) const
Definition: cell3D.hh:616
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich