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>
14 #include "basics/outputOperator.hh"
15 #include "basics/exceptions.hh"
17 #include "toolbox/sequence.hh"
18 #include "cell.hh"
19 #include "cell1D.hh"
20 #include "cell3D.hh"
21 
22 namespace 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 
59  typedef Scan<Cell1> Scan1;
60 
62  typedef Scan<Cell2> Scan2;
63 
65  typedef Scan<Cell3> Scan3;
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:
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 
137  protected:
142  };
143 
144  // ******************************************************* Mesh2withBoundary **
145 
153  public:
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
virtual uint ncell() const
Returns the number of cells in the mesh.
Definition: mesh.hh:189
Scan< Cell2 > Scan2
A scanner for a 2D mesh.
Definition: mesh.hh:62
void addInnerBoundary(const Sequence< Edge2d * > &innerBoundary)
Adds clones of the edges in innerBoundary as new inner boundary.
std::vector< Tetrahedron3d * >::iterator idx_
Definition: mesh.hh:205
Scan< Cell1 > Scan1
A scanner for a 1D mesh.
Definition: mesh.hh:59
const Sequence< Edge2d * > & outerBoundary() const
Definition: mesh.hh:128
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
A scanner for a 3D mesh.
Definition: mesh.hh:52
std::vector< Tetrahedron3d * > & cell_
Definition: mesh.hh:206
Container class: a dynamic array.
Definition: mesh.hh:30
An abstract class for 3D meshes.
Definition: mesh.hh:112
S(std::vector< Tetrahedron3d * > &cell)
Definition: mesh.hh:196
A scanner for a 2D mesh.
Definition: mesh.hh:44
Three dimensional cell.
Definition: cell.hh:112
Sequence< Edge2d * > outerBoundary_
Outer boundary given by edges in 2D.
Definition: mesh.hh:139
std::vector< Triangle * > tri_
Definition: mesh.hh:233
#define conceptsAssert(cond, exc)
Assert that a certain condition is fulfilled.
Definition: exceptions.hh:394
Base class for mesh classes in 2D which defines its outer boundary and inner boundaries.
Definition: mesh.hh:152
Sequence< Sequence< Edge2d * > > innerBoundary_
Several internal boundaries given by edges in 2D.
Definition: mesh.hh:141
Importer for tetrahedral meshes in notation which was used in [1].
Definition: mesh.hh:169
virtual Scan1 * scan()=0
Returns a scanner over the cells of the mesh.
Tet(const uint one, const uint two, const uint three, const uint four)
Definition: mesh.hh:212
S(const S &scan)
Definition: mesh.hh:198
Scan3 * clone() const
Definition: mesh.hh:203
An abstract class for 1D meshes.
Definition: mesh.hh:94
virtual Scan3 * scan()
Returns a scanner over the cells of the mesh.
Definition: mesh.hh:190
One dimensional cell.
Definition: cell.hh:75
unsigned long long int threeIndex_(const uint x, const uint y, const uint z) const
Cell3 & operator++(int)=0
Returns the next cell.
Cell2 & operator++(int)=0
Returns the next cell.
Exception class for assertions.
Definition: exceptions.hh:258
virtual uint ncell() const =0
Returns the number of cells in the mesh.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Cell1 & operator++(int)=0
Returns the next cell.
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
Import3DTetMesh(const std::string coord, const std::string elms, const std::string dirichlet, const bool leftHand=false)
Constructor.
std::vector< Vertex * > vtx_
Definition: mesh.hh:231
An abstract class for 2D meshes.
Definition: mesh.hh:103
virtual Scan3 * scan()=0
Returns a scanner over the cells of the mesh.
Sequence with operations, output operator, and method of the particular element types.
Definition: sequence.hh:39
Two dimensional cell.
Definition: cell.hh:89
Tetrahedron3d & operator++(int)
Returns the next cell.
Definition: mesh.hh:200
const Sequence< Sequence< Edge2d * > > & innerBoundary() const
Definition: mesh.hh:131
std::vector< Edge * > edg_
Definition: mesh.hh:232
virtual Scan2 * scan()=0
Returns a scanner over the cells of the mesh.
A 3D cell: tetrahedron.
Definition: cell3D.hh:47
uint operator[](const uint i) const
Definition: mesh.hh:216
unsigned long long int twoIndex_(const uint j, const uint k) const
std::vector< Tetrahedron * > tet_
Definition: mesh.hh:234
virtual Scan< Cell > * scan()=0
Returns a scanner over the cells of the mesh.
std::vector< Tetrahedron3d * > cell_
Definition: mesh.hh:235
An abstract class for meshes.
Definition: mesh.hh:76
Scan< Cell3 > Scan3
A scanner for a 3D mesh.
Definition: mesh.hh:65
A scanner for a 1D mesh.
Definition: mesh.hh:36
A triangle in the topology.
Definition: topology.hh:193
Class providing an output operator.
Base class for mesh classes in 2D which defines its outer boundary and inner boundaries.
Definition: mesh.hh:124
Triangle * createTriangle_(const uint x, const uint y, const uint z, const std::map< unsigned long long int, Edge * > &edges, const uint bc=0) const
Basic namespace for Concepts-2.
Definition: pml_formula.h:16
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich