Class documentation of Concepts

Loading...
Searching...
No Matches
mesh.hh
Go to the documentation of this file.
1
7#ifndef mesh_hh
8#define mesh_hh
9
10#include <iostream>
11#include <vector>
12#include <map>
13#include <string>
15#include "basics/exceptions.hh"
17#include "toolbox/sequence.hh"
18#include "cell.hh"
19#include "cell1D.hh"
20#include "cell3D.hh"
21
22namespace concepts {
23
24 // forward declaration
25 class Vertex;
26 class Edge;
27 class Triangle;
28 class Tetrahedron;
29 template<class T>
30 class DynArray;
31
32 // ***************************************************************** ScanX **
33
35 template <>
36 class Scan<Cell1> : public Scan<Cell> {
37 public:
39 Cell1& operator++(int) = 0;
40 };
41
43 template <>
44 class Scan<Cell2> : public Scan<Cell> {
45 public:
47 Cell2& operator++(int) = 0;
48 };
49
51 template <>
52 class Scan<Cell3> : public Scan<Cell> {
53 public:
55 Cell3& operator++(int) = 0;
56 };
57
60
63
66
67 // ****************************************************************** Mesh **
68
76 class Mesh : public OutputOperator {
77 public:
79 virtual uint ncell() const = 0;
80
85 virtual Scan<Cell>* scan() = 0;
86 protected:
87 virtual std::ostream& info(std::ostream& os) const;
88 };
89
90 // ***************************************************************** Mesh1 **
91
94 class Mesh1 : public Mesh {
95 public:
96 virtual Scan1* scan() = 0;
97 };
98
99 // ***************************************************************** Mesh2 **
100
103 class Mesh2 : public Mesh {
104 public:
105 virtual Scan2* scan() = 0;
106 };
107
108 // ***************************************************************** Mesh3 **
109
112 class Mesh3 : public Mesh {
113 public:
114 virtual Scan3* scan() = 0;
115 };
116
117 // **************************************************** InnerOuterBoundary2d **
118
125 public:
126 virtual ~InnerOuterBoundary2d();
127
128 inline const Sequence<Edge2d*>& outerBoundary() const {
129 return outerBoundary_;
130 }
131 inline const Sequence<Sequence<Edge2d*> >& innerBoundary() const {
132 return innerBoundary_;
133 }
134
136 void addInnerBoundary(const Sequence<Edge2d*>& innerBoundary);
137 protected:
142 };
143
144 // ******************************************************* Mesh2withBoundary **
145
153 public:
154 virtual ~Mesh2withBoundary();
155 };
156
157 // ******************************************************* Import3DTetMesh **
158
169 class Import3DTetMesh : public Mesh3 {
170 public:
186 Import3DTetMesh(const std::string coord, const std::string elms,
187 const std::string dirichlet, const bool leftHand = false);
188 virtual ~Import3DTetMesh();
189 virtual uint ncell() const { return cell_.size(); }
190 virtual Scan3* scan() { return new S(cell_); }
191 protected:
192 virtual std::ostream& info(std::ostream& os) const;
193 private:
194 class S : public Scan<Cell3> {
195 public:
196 inline S(std::vector<Tetrahedron3d*>& cell) :
197 idx_(cell.begin()), cell_(cell) {}
198 inline S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
199 inline bool eos() const { return idx_ == cell_.end(); }
200 inline Tetrahedron3d& operator++(int) {
201 return *(*idx_++);
202 }
203 inline Scan3* clone() const { return new S(*this); }
204 private:
205 std::vector<Tetrahedron3d*>::iterator idx_;
206 std::vector<Tetrahedron3d*>& cell_;
207 };
208 class Tet {
209 private:
210 uint nodes_[4];
211 public:
212 Tet(const uint one, const uint two, const uint three, const uint four) {
213 nodes_[0] = one; nodes_[1] = two;
214 nodes_[2] = three; nodes_[3] = four;
215 }
216 uint operator[](const uint i) const {
217 conceptsAssert(i < 4, Assertion()); return nodes_[i];
218 }
219 };
220
221 unsigned long long int twoIndex_(const uint j, const uint k) const;
222
223 unsigned long long int threeIndex_(const uint x, const uint y,
224 const uint z) const;
225
226 Triangle* createTriangle_(const uint x, const uint y, const uint z,
227 const std::map<unsigned long long int, Edge*>&
228 edges,
229 const uint bc = 0) const;
230
231 std::vector<Vertex*> vtx_;
232 std::vector<Edge*> edg_;
233 std::vector<Triangle*> tri_;
234 std::vector<Tetrahedron*> tet_;
235 std::vector<Tetrahedron3d*> cell_;
236 };
237
238} // namespace concepts
239
240#endif // mesh_hh
One dimensional cell.
Definition cell.hh:75
Two dimensional cell.
Definition cell.hh:89
Three dimensional cell.
Definition cell.hh:112
virtual Scan3 * scan()
Definition mesh.hh:190
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Import3DTetMesh(const std::string coord, const std::string elms, const std::string dirichlet, const bool leftHand=false)
virtual uint ncell() const
Returns the number of cells in the mesh.
Definition mesh.hh:189
Sequence< Edge2d * > outerBoundary_
Outer boundary given by edges in 2D.
Definition mesh.hh:139
Sequence< Sequence< Edge2d * > > innerBoundary_
Several internal boundaries given by edges in 2D.
Definition mesh.hh:141
void addInnerBoundary(const Sequence< Edge2d * > &innerBoundary)
Adds clones of the edges in innerBoundary as new inner boundary.
virtual Scan1 * scan()=0
virtual Scan2 * scan()=0
virtual Scan3 * scan()=0
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual uint ncell() const =0
Returns the number of cells in the mesh.
virtual Scan< Cell > * scan()=0
A scanner for a 1D mesh.
Definition mesh.hh:36
Cell1 & operator++(int)=0
Returns the next cell.
A scanner for a 2D mesh.
Definition mesh.hh:44
Cell2 & operator++(int)=0
Returns the next cell.
A scanner for a 3D mesh.
Definition mesh.hh:52
Cell3 & operator++(int)=0
Returns the next cell.
#define conceptsAssert(cond, exc)
Scan< Cell2 > Scan2
A scanner for a 2D mesh.
Definition mesh.hh:62
Scan< Cell1 > Scan1
A scanner for a 1D mesh.
Definition mesh.hh:59
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320
Scan< Cell3 > Scan3
A scanner for a 3D mesh.
Definition mesh.hh:65