meshImport2D.hh

Go to the documentation of this file.
1 
8 #ifndef meshImport2D_hh
9 #define meshImport2D_hh
10 
11 #include <vector>
12 #include <map>
13 #include "mesh.hh"
14 #include "meshImport.hh"
15 #include "toolbox/array.hh"
16 #include "toolbox/multiArray.hh"
17 
18 namespace concepts {
19 
20  // ****************************************************** Import2dMeshBase **
21 
32  class Import2dMeshBase : public Mesh2, public ImportMesh {
33  public:
34  Import2dMeshBase(const std::string coord, const std::string elms,
35  const uint idxStart = 1);
36  virtual ~Import2dMeshBase();
37  virtual uint ncell() const { return cell_.size(); }
38  virtual Scan2* scan();
39  protected:
40  virtual std::ostream& info(std::ostream& os) const;
41 
43  class S;
44 
46  std::vector<Cell2*> cell_;
47 
49  const std::string coord_, elms_;
50 
52  std::vector<Real3d> vertices_;
53  uint dim_;
54 
56  std::vector<Connector2*> cntr2_;
60 
62  virtual void createEntity_(const MultiIndex<1>& idx)
64  virtual void createEntity_(const MultiIndex<2>& idx)
66  virtual void createEntity_(const MultiIndex<3>& idx)
68  virtual void createEntity_(const MultiIndex<4>& idx)
70 
72  virtual void createCell_(const MultiIndex<3>& idx)
74  virtual void createCell_(const MultiIndex<4>& idx)
76 
78  virtual void readVertices_();
79  uint readVertexLine_(const std::string& i, uint* idx, Real3d* coord) const;
80 
82  void attributes_(const std::string boundary);
84  void import_();
85  };
86 
88  class Import2dMeshBase::S : public Scan<Cell2> {
89  public:
90  inline S(std::vector<Cell2*>& cell) :
91  idx_(cell.begin()), cell_(cell) {}
92  inline S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
93  inline bool eos() const { return idx_ == cell_.end(); }
94  inline Cell2& operator++(int) { return *(*idx_++); }
95  inline Scan2* clone() const { return new S(*this); }
96  private:
97  std::vector<Cell2*>::iterator idx_;
98  std::vector<Cell2*>& cell_;
99  };
100 
101  // ********************************************************** Import2dMesh **
102 
104  public:
137  Import2dMesh(const std::string coord, const std::string elms,
138  const std::string boundary, const uint idxStart = 1);
139 
167  Import2dMesh(const std::string coord, const std::string elms,
168  const uint idxStart = 1);
169  virtual ~Import2dMesh() {}
170  protected:
171  virtual std::ostream& info(std::ostream& os) const;
172  };
173 
174 } // namespace concepts
175 
176 #endif // meshImport2D_hh
MultiArray< 3, Triangle * > Tri_
Array of the entities.
Definition: meshImport2D.hh:58
const std::string elms_
Definition: meshImport2D.hh:49
virtual void createEntity_(const MultiIndex< 3 > &idx)
Creation of topological entities.
virtual void createEntity_(const MultiIndex< 2 > &idx)
Definition: meshImport2D.hh:64
S(std::vector< Cell2 * > &cell)
Definition: meshImport2D.hh:90
Basic class for a Point or a vector.
virtual void readVertices_()
reads the coordinates of the vertices
std::vector< Connector2 * > cntr2_
List of entities.
Definition: meshImport2D.hh:56
void attributes_(const std::string boundary)
Reads attributes from file boundary.
std::vector< Cell2 * >::iterator idx_
Definition: meshImport2D.hh:97
A scanner for a 2D mesh.
Definition: mesh.hh:44
uint readVertexLine_(const std::string &i, uint *idx, Real3d *coord) const
virtual Scan2 * scan()
Returns a scanner over the cells of the mesh.
Import2dMesh(const std::string coord, const std::string elms, const std::string boundary, const uint idxStart=1)
Constructor.
MultiArray< 4, Quad * > Quad_
Definition: meshImport2D.hh:59
virtual void createCell_(const MultiIndex< 4 > &idx)
Cell2 & operator++(int)
Returns the next cell.
Definition: meshImport2D.hh:94
Import2dMesh(const std::string coord, const std::string elms, const uint idxStart=1)
Constructor.
virtual uint ncell() const
Returns the number of cells in the mesh.
Definition: meshImport2D.hh:37
void import_()
Reads and builds the mesh.
Base class for reading a mesh from a file.
Definition: meshImport.hh:32
Container typename for multidimensional Array which is based on std::map.
Definition: multiArray.hh:33
An abstract class for scanning a mesh (a set of cells) or a space (a set of elements).
Import2dMeshBase(const std::string coord, const std::string elms, const uint idxStart=1)
An abstract class for 2D meshes.
Definition: mesh.hh:103
std::vector< Cell2 * > cell_
List of cells.
Definition: meshImport2D.hh:43
Two dimensional cell.
Definition: cell.hh:89
std::vector< Cell2 * > & cell_
Definition: meshImport2D.hh:98
Scanner class for Import2dMesh.
Definition: meshImport2D.hh:88
Exception class to express a missing feature.
Definition: exceptions.hh:206
virtual void createEntity_(const MultiIndex< 1 > &idx)
Creation of topological entities.
Definition: meshImport2D.hh:62
Imports 2D mesh with triangles and quadrilaterals (possibly mixed).
Definition: meshImport2D.hh:32
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
virtual void createCell_(const MultiIndex< 3 > &idx)
Creation of geometrical cells with element mapping.
virtual void createEntity_(const MultiIndex< 4 > &idx)
const std::string coord_
File names of coordinates and cell files.
Definition: meshImport2D.hh:49
std::vector< Real3d > vertices_
Coordinates of the vertices.
Definition: meshImport2D.hh:52
virtual void createEntity_(const MultiIndex< 1 > &idx)
Creation of topological entities Vertex and Edge.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
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