Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

geometry/square.hh
Go to the documentation of this file.
00001 /* square made out of one or two hexahedron
00002  */
00003 
00004 #ifndef square_hh
00005 #define square_hh
00006 
00007 #include "basics/typedefs.hh"
00008 #include "mesh.hh"
00009 #include "topology.hh"
00010 #include "cell2D.hh"
00011 
00012 namespace concepts {
00013 
00014   // ****************************************************************** Square **
00015 
00020   class Square : public Mesh2 {
00021     static const uint ncell_ = 1;
00022   public:
00027     Square(const Real sizex = 1.0, const Real sizey = 1.0,
00028            const uint attrib = 0);
00033     Square(const Real x0, const Real y0, const Real x1, const Real y1, 
00034            const Real x2, const Real y2, const Real x3, const Real y3,
00035            const uint attrib = 0);
00041     Square(const Real sizex, const Real sizey,
00042            const Array<uint>& attrib,
00043            const Array<uint>* vattrib = 0);
00048     Square(const Real x0, const Real y0, const Real x1, const Real y1, 
00049            const Real x2, const Real y2, const Real x3, const Real y3,
00050            const Array<uint>& attrib,
00051            const Array<uint>* vattrib = 0);
00052     virtual ~Square();
00053 
00054     inline uint ncell() const { return ncell_; }
00055     inline Scan2* scan() { return new S(cell_); }
00056 
00057     virtual std::ostream& info(std::ostream& os) const;
00058   private:
00059     class S : public Scan<Cell2> {
00060       uint idx_;
00061       Quad2d *(&cell_)[ncell_];
00062     public:
00063       inline S(Quad2d *(&cell)[ncell_]) : idx_(0), cell_(cell) {}
00064       inline S(const S &scan) : idx_(scan.idx_), cell_(scan.cell_) {}
00065 
00066       inline bool eos() const { return idx_ == ncell_; }
00067       inline Cell2& operator++(int) { return *cell_[idx_++]; }
00068 
00069       inline Scan2* clone() const { return new S(*this); }
00070     };
00071     void construct_(const Array<Real2d>& coord,
00072                     const Array<uint>& attrib,
00073                     const Array<uint>* vattrib = 0);
00074 
00075     Vertex* vtx_[4];
00076     Edge* edg_[4];
00077     Quad* quad_[ncell_];
00078 
00079     Quad2d* cell_[ncell_];
00080   };
00081 
00082   // ***************************************************************** Square2 **
00083 
00092   class Square2 : public Mesh2 {
00093     static const uint ncell_ = 2;
00094   public:
00095     Square2();
00098     Square2(Array<uint> attrib);
00099     virtual ~Square2();
00100 
00101     inline uint ncell() const { return ncell_; }
00102     inline Scan2* scan() { return new S(cell_); }
00103 
00104     virtual std::ostream& info(std::ostream& os) const;
00105   private:
00106     class S : public Scan<Cell2> {
00107       uint idx_;
00108       Quad2d *(&cell_)[ncell_];
00109     public:
00110       inline S(Quad2d *(&cell)[ncell_]) : idx_(0), cell_(cell) {}
00111       inline S(const S &scan) : idx_(scan.idx_), cell_(scan.cell_) {}
00112 
00113       inline bool eos() const { return idx_ == ncell_; }
00114       inline Cell2& operator++(int) { return *cell_[idx_++]; }
00115 
00116       inline Scan2* clone() const { return new S(*this); }
00117     };
00118 
00119     void construct_(const Array<uint>& attrib);
00120 
00121 
00122     Vertex* vtx_[6];
00123     Edge* edg_[7];
00124     Quad* quad_[ncell_];
00125 
00126     Quad2d* cell_[ncell_];
00127   };
00128 
00129 } // namespace concepts
00130 
00131 #endif // square_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)