00001
00002
00003
00004
00005
00006 #ifndef cell3D_hh
00007 #define cell3D_hh
00008
00009 #include <iostream>
00010 #include "basics/typedefs.hh"
00011 #include "basics/vectorsMatrices.hh"
00012 #include "basics/level.hh"
00013 #include "topology3D.hh"
00014 #include "cell.hh"
00015 #include "elementMaps3D.hh"
00016
00017 namespace concepts {
00018
00019
00020
00025 class NegativeJacobian : public MissingFeature {
00026 public:
00031 NegativeJacobian(const std::string& errMsg) throw();
00032 protected:
00033 virtual std::ostream& info(std::ostream& os) const throw();
00034 };
00035
00036
00037
00044 class Tetrahedron3d : public Cell3 {
00045 public:
00047 struct Index {
00049 uchar l_;
00050
00055 ushort i_;
00056
00061 ushort j_;
00062
00067 ushort k_;
00068
00069 inline Index() : l_(0), i_(0), j_(0), k_(0) {}
00070 inline Index(uchar l, ushort i, ushort j, ushort k) :
00071 l_(l), i_(i), j_(j), k_(k) {}
00072 inline std::ostream& info(std::ostream& os) const;
00073 };
00074
00080 Tetrahedron3d(Tetrahedron& cntr, const MapTetrahedron3d& map);
00081 virtual ~Tetrahedron3d();
00082
00083 virtual Tetrahedron3d* child(uint i);
00084 virtual const Tetrahedron3d* child(uint i) const;
00085 Tetrahedron& connector() const { return cntr_; }
00086
00095 Real3d chi(Real xi, Real eta, Real zeta) const;
00096 Real3d center() const {return chi(0.5, 0.5, 0.5);};
00097
00098 Real3d vertex(uint i) const;
00099 protected:
00100 virtual std::ostream& info(std::ostream& os) const;
00101 private:
00103 Index idx_;
00104
00106 Tetrahedron& cntr_;
00107
00109 Tetrahedron3d* lnk_;
00110
00114 Tetrahedron3d* chld_;
00115
00117 MapTetrahedron3d* map_;
00118
00120 Tetrahedron3d(Tetrahedron& cntr, MapTetrahedron3d* map,
00121 const Index& idx);
00122 };
00123
00124 inline std::ostream& Tetrahedron3d::Index::info(std::ostream& os) const {
00125 return os << '(' << (uint)l_ << ", "
00126 << i_ << ", " << j_ << ", " << k_ << ')';
00127 }
00128
00129
00130
00131 class Hexahedron3d;
00132
00144 class Hex3dSubdivision : public OutputOperator {
00145 public:
00148 virtual void createChildren(Hexahedron3d& h) const = 0;
00151 virtual void removeChildren(Hexahedron3d& h) const;
00154 virtual const HexSubdivision* topologicalStrategy() const = 0;
00155 };
00156
00157
00158
00162 class Hex3dSubdiv8 : public Hex3dSubdivision {
00163 public:
00164 virtual void createChildren(Hexahedron3d& h) const;
00165 virtual const HexSubdiv8* topologicalStrategy() const;
00166 static const Hex3dSubdiv8* instance();
00167 virtual ~Hex3dSubdiv8();
00168 protected:
00169 virtual std::ostream& info(std::ostream& os) const;
00170 private:
00171 static std::auto_ptr<Hex3dSubdiv8> instance_;
00172 };
00173
00174
00175
00180 class Hex3dSubdiv2x : public Hex3dSubdivision {
00181 public:
00182 virtual void createChildren(Hexahedron3d& h) const;
00183 virtual const HexSubdiv2x* topologicalStrategy() const;
00184 static const Hex3dSubdiv2x* instance();
00185 virtual ~Hex3dSubdiv2x();
00186 protected:
00187 virtual std::ostream& info(std::ostream& os) const;
00188 private:
00189 static std::auto_ptr<Hex3dSubdiv2x> instance_;
00190 };
00191
00192
00193
00198 class Hex3dSubdiv2y : public Hex3dSubdivision {
00199 public:
00200 virtual void createChildren(Hexahedron3d& h) const;
00201 virtual const HexSubdiv2y* topologicalStrategy() const;
00202 static const Hex3dSubdiv2y* instance();
00203 virtual ~Hex3dSubdiv2y();
00204 protected:
00205 virtual std::ostream& info(std::ostream& os) const;
00206 private:
00207 static std::auto_ptr<Hex3dSubdiv2y> instance_;
00208 };
00209
00210
00211
00216 class Hex3dSubdiv2z : public Hex3dSubdivision {
00217 public:
00218 virtual void createChildren(Hexahedron3d& h) const;
00219 virtual const HexSubdiv2z* topologicalStrategy() const;
00220 static const Hex3dSubdiv2z* instance();
00221 virtual ~Hex3dSubdiv2z();
00222 protected:
00223 virtual std::ostream& info(std::ostream& os) const;
00224 private:
00225 static std::auto_ptr<Hex3dSubdiv2z> instance_;
00226 };
00227
00228
00229
00233 class Hex3dSubdiv4x : public Hex3dSubdivision {
00234 public:
00235 virtual void createChildren(Hexahedron3d& h) const;
00236 virtual const HexSubdiv4x* topologicalStrategy() const;
00237 static const Hex3dSubdiv4x* instance();
00238 virtual ~Hex3dSubdiv4x();
00239 protected:
00240 virtual std::ostream& info(std::ostream& os) const;
00241 private:
00242 static std::auto_ptr<Hex3dSubdiv4x> instance_;
00243 };
00244
00245
00246
00250 class Hex3dSubdiv4y : public Hex3dSubdivision {
00251 public:
00252 virtual void createChildren(Hexahedron3d& h) const;
00253 virtual const HexSubdiv4y* topologicalStrategy() const;
00254 static const Hex3dSubdiv4y* instance();
00255 virtual ~Hex3dSubdiv4y();
00256 protected:
00257 virtual std::ostream& info(std::ostream& os) const;
00258 private:
00259 static std::auto_ptr<Hex3dSubdiv4y> instance_;
00260 };
00261
00262
00263
00267 class Hex3dSubdiv4z : public Hex3dSubdivision {
00268 public:
00269 virtual void createChildren(Hexahedron3d& h) const;
00270 virtual const HexSubdiv4z* topologicalStrategy() const;
00271 static const Hex3dSubdiv4z* instance();
00272 virtual ~Hex3dSubdiv4z();
00273 protected:
00274 virtual std::ostream& info(std::ostream& os) const;
00275 private:
00276 static std::auto_ptr<Hex3dSubdiv4z> instance_;
00277 };
00278
00279
00280
00299 class Hexahedron3d : public Cell3 {
00300 friend class Hex3dSubdivision;
00301 friend class Hex3dSubdiv8;
00302 friend class Hex3dSubdiv2x;
00303 friend class Hex3dSubdiv2y;
00304 friend class Hex3dSubdiv2z;
00305 friend class Hex3dSubdiv4x;
00306 friend class Hex3dSubdiv4y;
00307 friend class Hex3dSubdiv4z;
00308 public:
00310 struct Index {
00312 Level<3> level_;
00313
00318 ushort i_;
00319
00324 ushort j_;
00325
00330 ushort k_;
00331
00332 inline Index() : level_(0), i_(0), j_(0), k_(0) {}
00333 inline Index(uchar l, uchar m, uchar n, ushort i, ushort j, ushort k) :
00334 level_(l), i_(i), j_(j), k_(k) { level_.l_[1] = m; level_.l_[2] = n; }
00335 inline Index(const Index& i) : level_(i.level_), i_(i.i_), j_(i.j_),
00336 k_(i.k_) {}
00337 };
00338
00339 friend std::ostream& operator<<(std::ostream& os,
00340 const Hexahedron3d::Index& i);
00341
00347 Hexahedron3d(Hexahedron& cntr, const MapHexahedron3d& map);
00348 virtual ~Hexahedron3d();
00349
00350 virtual Hexahedron3d* child(uint i);
00351 virtual const Hexahedron3d* child(uint i) const;
00352 inline Hexahedron& connector() const { return cntr_; }
00353
00362 Real3d chi(Real xi, Real eta, Real zeta) const;
00363
00364 Real3d elemMap(const Real3d& coord_local) const
00365 {
00366 return chi(coord_local[0], coord_local[1], coord_local[2]);
00367 }
00368
00394 MapReal3d jacobian(const Real xi, const Real eta, const Real zeta) const;
00395
00399 MapReal3d jacobianInverse(const Real xi, const Real eta,
00400 const Real zeta) const {
00401 return jacobian(xi, eta, zeta).inverse();
00402 }
00403
00407 Real jacobianDeterminant(const Real xi, const Real eta,
00408 const Real zeta) const {
00409 return jacobian(xi, eta, zeta).determinant();
00410 }
00411
00413 const Level<3>& level() const { return idx_.level_; }
00414
00415 Real3d vertex(uint i) const;
00416 Real3d center() const {return chi(0.5, 0.5, 0.5);};
00418 inline const MapHexahedron3d* map() const {return map_;};
00419
00432 void setStrategy(const Hex3dSubdivision* strategy = 0)
00433 throw(StrategyChange);
00434
00440 const Hex3dSubdivision* getStrategy() const { return subdivStrategy_; }
00441 protected:
00442 virtual std::ostream& info(std::ostream& os) const;
00443 private:
00445 Index idx_;
00446
00448 Hexahedron& cntr_;
00449
00451 Hexahedron3d* lnk_;
00452
00456 Hexahedron3d* chld_;
00457
00459 MapHexahedron3d* map_;
00460
00462 const Hex3dSubdivision* subdivStrategy_;
00463
00465 Hexahedron3d(Hexahedron& cntr, MapHexahedron3d* map,
00466 const Index& idx);
00467 };
00468
00469
00470
00478 class Parallelepiped3d : public Cell3 {
00479 public:
00481 struct Index {
00483 uchar l_;
00484
00489 ushort i_;
00490
00495 ushort j_;
00496
00501 ushort k_;
00502
00503 inline Index() : l_(0), i_(0), j_(0), k_(0) {}
00504 inline Index(uchar l, ushort i, ushort j, ushort k) :
00505 l_(l), i_(i), j_(j), k_(k) {}
00506 inline std::ostream& info(std::ostream& os) const;
00507 };
00508
00514 Parallelepiped3d(Hexahedron& cntr, const MapParallelepiped3d& map);
00515 virtual ~Parallelepiped3d();
00516
00517 virtual Parallelepiped3d* child(uint c);
00518 virtual const Parallelepiped3d* child(uint c) const;
00519 Hexahedron& connector() const { return cntr_; }
00520
00529 Real3d chi(Real xi, Real eta, Real zeta) const;
00530 Real3d center() const {return chi(0.5, 0.5, 0.5);};
00531
00532 Real3d vertex(uint i) const;
00533 protected:
00534 virtual std::ostream& info(std::ostream& os) const;
00535 private:
00537 Index idx_;
00538
00540 Hexahedron& cntr_;
00541
00543 Parallelepiped3d* lnk_;
00544
00548 Parallelepiped3d* chld_;
00549
00551 MapParallelepiped3d* map_;
00552
00554 Parallelepiped3d(Hexahedron& cntr, MapParallelepiped3d* map,
00555 const Index& idx);
00556 };
00557
00558 inline std::ostream& Parallelepiped3d::Index::info(std::ostream& os) const {
00559 return os << '(' << (uint)l_ << ", "
00560 << i_ << ", " << j_ << ", " << k_ << ')';
00561 }
00562
00563 }
00564
00565 #endif // cell3D_hh