Go to the documentation of this file.00001
00002
00003
00004
00005 #ifndef mesh_hh
00006 #define mesh_hh
00007
00008 #include <iostream>
00009 #include <vector>
00010 #include <map>
00011 #include <string>
00012 #include "basics/outputOperator.hh"
00013 #include "basics/exceptions.hh"
00014 #include "toolbox/scannerConnectors.hh"
00015 #include "toolbox/sequence.hh"
00016 #include "cell.hh"
00017 #include "cell1D.hh"
00018 #include "cell3D.hh"
00019
00020 namespace concepts {
00021
00022
00023 class Vertex;
00024 class Edge;
00025 class Triangle;
00026 class Tetrahedron;
00027 template<class T>
00028 class DynArray;
00029
00030
00031
00033 template <>
00034 class Scan<Cell1> : public Scan<Cell> {
00035 public:
00037 Cell1& operator++(int) = 0;
00038 };
00039
00041 template <>
00042 class Scan<Cell2> : public Scan<Cell> {
00043 public:
00045 Cell2& operator++(int) = 0;
00046 };
00047
00049 template <>
00050 class Scan<Cell3> : public Scan<Cell> {
00051 public:
00053 Cell3& operator++(int) = 0;
00054 };
00055
00057 typedef Scan<Cell1> Scan1;
00058
00060 typedef Scan<Cell2> Scan2;
00061
00063 typedef Scan<Cell3> Scan3;
00064
00065
00066
00074 class Mesh : public OutputOperator {
00075 public:
00077 virtual uint ncell() const = 0;
00078
00083 virtual Scan<Cell>* scan() = 0;
00084 protected:
00085 virtual std::ostream& info(std::ostream& os) const;
00086 };
00087
00088
00089
00092 class Mesh1 : public Mesh {
00093 public:
00094 virtual Scan1* scan() = 0;
00095 };
00096
00097
00098
00101 class Mesh2 : public Mesh {
00102 public:
00103 virtual Scan2* scan() = 0;
00104 };
00105
00106
00107
00110 class Mesh3 : public Mesh {
00111 public:
00112 virtual Scan3* scan() = 0;
00113 };
00114
00115
00116
00122 class InnerOuterBoundary2d {
00123 public:
00124 virtual ~InnerOuterBoundary2d();
00125
00126 inline const Sequence<Edge2d*>& outerBoundary() const {
00127 return outerBoundary_;
00128 }
00129 inline const Sequence<Sequence<Edge2d*> >& innerBoundary() const {
00130 return innerBoundary_;
00131 }
00132
00134 void addInnerBoundary(const Sequence<Edge2d*>& innerBoundary);
00135 protected:
00137 Sequence<Edge2d*> outerBoundary_;
00139 Sequence<Sequence<Edge2d*> > innerBoundary_;
00140 };
00141
00142
00143
00150 class Mesh2withBoundary : public Mesh2, public InnerOuterBoundary2d {
00151 public:
00152 virtual ~Mesh2withBoundary();
00153 };
00154
00155
00156
00167 class Import3DTetMesh : public Mesh3 {
00168 public:
00184 Import3DTetMesh(const std::string coord, const std::string elms,
00185 const std::string dirichlet, const bool leftHand = false);
00186 virtual ~Import3DTetMesh();
00187 virtual uint ncell() const { return cell_.size(); }
00188 virtual Scan3* scan() { return new S(cell_); }
00189 protected:
00190 virtual std::ostream& info(std::ostream& os) const;
00191 private:
00192 class S : public Scan<Cell3> {
00193 public:
00194 inline S(std::vector<Tetrahedron3d*>& cell) :
00195 idx_(cell.begin()), cell_(cell) {}
00196 inline S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
00197 inline bool eos() const { return idx_ == cell_.end(); }
00198 inline Tetrahedron3d& operator++(int) {
00199 return *(*idx_++);
00200 }
00201 inline Scan3* clone() const { return new S(*this); }
00202 private:
00203 std::vector<Tetrahedron3d*>::iterator idx_;
00204 std::vector<Tetrahedron3d*>& cell_;
00205 };
00206 class Tet {
00207 private:
00208 uint nodes_[4];
00209 public:
00210 Tet(const uint one, const uint two, const uint three, const uint four) {
00211 nodes_[0] = one; nodes_[1] = two;
00212 nodes_[2] = three; nodes_[3] = four;
00213 }
00214 uint operator[](const uint i) const {
00215 conceptsAssert(i < 4, Assertion()); return nodes_[i];
00216 }
00217 };
00218
00219 unsigned long long int twoIndex_(const uint j, const uint k) const;
00220
00221 unsigned long long int threeIndex_(const uint x, const uint y,
00222 const uint z) const;
00223
00224 Triangle* createTriangle_(const uint x, const uint y, const uint z,
00225 const std::map<unsigned long long int, Edge*>&
00226 edges,
00227 const uint bc = 0) const;
00228
00229 std::vector<Vertex*> vtx_;
00230 std::vector<Edge*> edg_;
00231 std::vector<Triangle*> tri_;
00232 std::vector<Tetrahedron*> tet_;
00233 std::vector<Tetrahedron3d*> cell_;
00234 };
00235
00236 }
00237
00238 #endif // mesh_hh