Class documentation of Concepts

Loading...
Searching...
No Matches
meshImport3D.hh
Go to the documentation of this file.
1
8#ifndef meshImport3D_hh
9#define meshImport3D_hh
10
11#include <vector>
12#include <map>
13#include "toolbox/hashMap.hh"
14#include "mesh.hh"
15#include "toolbox/array.hh"
16
17namespace concepts {
23 struct Index {
33 void sort_();
34
35 Index(const uint n0);
36 Index(const uint n0, const uint n1);
38 Index(const uint n0, const uint n1, const uint n2);
40 Index(const uint n0, const uint n1, const uint n2, const uint n3);
42 Index(const Index& i) : n_(i.n_) {}
44 uint size() const { return n_.size(); }
46 uint operator[](const uint i) const { return n_[i]; }
48 uint& operator[](const uint i) { return n_[i]; }
50 bool operator<(const concepts::Index& y) const;
52 bool operator==(const concepts::Index& y) const;
53 };
54}
55
56namespace std {
58 size_t hash_value(const concepts::Index& i);
59
61 template<>
62 struct hash<concepts::Index> {
64 size_t operator()(const concepts::Index& x) const {
65 return hash_value(x); }
66 };
67
69 struct IndexEqual {
70 bool operator()(const concepts::Index& x, const concepts::Index& y) const {
71 return x == y;
72 }
73 };
74} // namespace std
75
76namespace concepts {
77
78 // ********************************************************** Import3dMesh **
79
94 class Import3dMesh : public Mesh3 {
95 public:
136 Import3dMesh(const std::string coord, const std::string elms,
137 const std::string boundary, const uint idxStart = 1,
138 const bool leftHand = false, const uint elmtyp = 0);
139 virtual ~Import3dMesh();
140 virtual uint ncell() const { return cell_.size(); }
141 virtual Scan3* scan() { return new S(cell_); }
142
143 class NodeCell;
144 class NodeTetrahedron;
145 class NodeHexahedron;
146 protected:
147 virtual std::ostream& info(std::ostream& os) const;
148 private:
150 class S : public Scan<Cell3> {
151 public:
152 inline S(std::vector<Cell3*>& cell) :
153 idx_(cell.begin()), cell_(cell) {}
154 inline S(const S& scan) : idx_(scan.idx_), cell_(scan.cell_) {}
155 inline bool eos() const { return idx_ == cell_.end(); }
156 inline Cell3& operator++(int) { return *(*idx_++); }
157 inline Scan3* clone() const { return new S(*this); }
158 private:
159 std::vector<Cell3*>::iterator idx_;
160 std::vector<Cell3*>& cell_;
161 };
163 std::vector<Vertex*> vtx_;
165 std::vector<Edge*> edg_;
167 std::unordered_map<Index, Triangle*, std::hash<Index>,
168 std::IndexEqual> tri_;
170 std::unordered_map<Index, Quad*, std::hash<Index>,
171 std::IndexEqual> quad_;
173 std::vector<Cell3*> cell_;
174
178 uint readInts_(const std::string& i, std::vector<int>& v) const;
179
181 void clear_(std::vector<NodeCell*>& cells) const;
182
193 void createEdge_(uint ix, uint iy,
194 std::map<uint, std::map<uint, Edge*> >& edges,
195 Attribute attr = 0, Edge** e = 0);
203 Triangle* createTriangle_(const Index& I,
204 std::map<uint, std::map<uint, Edge*> >& edges,
205 Attribute attr = 0);
213 Quad* createQuad_(const Index& I,
214 std::map<uint, std::map<uint, Edge*> >& edges,
215 Attribute attr = 0);
216 };
217
222 protected:
225 public:
231 virtual ~NodeCell();
233 uint operator[](const uint i) const { return nodes_[i]; }
235 uint size() const { return nodes_.size(); }
236
238 virtual uint nofaces() const = 0;
240 virtual Index faceIndex(const uint i) = 0;
242 virtual Quad** quad(const uint i) = 0;
244 virtual Triangle** triangle(const uint i) = 0;
246 virtual Cell3* cell(const std::vector<Real3d>& vertices) const = 0;
247 };
248
253 private:
255 Array<Triangle*> faces_;
256 public:
260 NodeTetrahedron(const uint one, const uint two, const uint three,
261 const uint four, const bool leftHand = false);
262 virtual ~NodeTetrahedron();
263 virtual uint nofaces() const { return 4; }
264 virtual Index faceIndex(const uint i);
265 virtual Tetrahedron3d* cell(const std::vector<Real3d>& vertices) const;
266 virtual Quad** quad(const uint i) { return 0; }
267 virtual Triangle** triangle(const uint i) { return &(faces_[i]); }
268 };
269
274 private:
276 Array<Quad*> faces_;
278 uint elmType_;
279 public:
283 NodeHexahedron(const uint one, const uint two, const uint three,
284 const uint four, const uint five, const uint six,
285 const uint seven, const uint eight, const uint elmType = 0);
286 virtual ~NodeHexahedron();
287 virtual uint nofaces() const { return 6; }
288 virtual Index faceIndex(const uint i);
289 virtual Cell3* cell(const std::vector<Real3d>& vertices) const;
290 virtual Quad** quad(const uint i) { return &(faces_[i]); }
291 virtual Triangle** triangle(const uint i) { return 0; }
292 };
293
294} // namespace concepts
295
296#endif // meshImport3D_hh
uint size() const
Returns the requested size of the array.
Definition array.hh:259
Three dimensional cell.
Definition cell.hh:112
Array< uint > nodes_
Node numbers of the cell.
virtual Triangle ** triangle(const uint i)=0
Returns the face with index i.
uint operator[](const uint i) const
Returns the node with index i.
virtual Quad ** quad(const uint i)=0
Returns the face with index i.
virtual uint nofaces() const =0
Returns the number of faces.
uint size() const
Returns the number of nodes.
virtual Index faceIndex(const uint i)=0
Returns the indices of the nodes which define the face i.
virtual Cell3 * cell(const std::vector< Real3d > &vertices) const =0
Creates and returns the cell.
virtual Cell3 * cell(const std::vector< Real3d > &vertices) const
Creates and returns the cell.
virtual uint nofaces() const
Returns the number of faces.
virtual Index faceIndex(const uint i)
Returns the indices of the nodes which define the face i.
virtual Triangle ** triangle(const uint i)
Returns the face with index i.
NodeHexahedron(const uint one, const uint two, const uint three, const uint four, const uint five, const uint six, const uint seven, const uint eight, const uint elmType=0)
virtual Quad ** quad(const uint i)
Returns the face with index i.
NodeTetrahedron(const uint one, const uint two, const uint three, const uint four, const bool leftHand=false)
virtual uint nofaces() const
Returns the number of faces.
virtual Index faceIndex(const uint i)
Returns the indices of the nodes which define the face i.
virtual Quad ** quad(const uint i)
Returns the face with index i.
virtual Tetrahedron3d * cell(const std::vector< Real3d > &vertices) const
Creates and returns the cell.
virtual Triangle ** triangle(const uint i)
Returns the face with index i.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
Import3dMesh(const std::string coord, const std::string elms, const std::string boundary, const uint idxStart=1, const bool leftHand=false, const uint elmtyp=0)
virtual Scan3 * scan()
virtual uint ncell() const
Returns the number of cells in the mesh.
A scanner for a 3D mesh.
Definition mesh.hh:52
size_t hash_value(const concepts::Index &i)
Computes a hash for i.
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
Index(const Index &i)
Copy constructor.
bool operator==(const concepts::Index &y) const
== operator
uint operator[](const uint i) const
Returns the ith entry of n_.
uint & operator[](const uint i)
Returns the ith entry of n_.
Array< uint > n_
Stores the data.
uint size() const
Returns number of entries in n_.
Index(const uint n0, const uint n1, const uint n2)
Constructor for use in a triangle.
Index(const uint n0, const uint n1, const uint n2, const uint n3)
Constructor for use in a quad.
bool operator<(const concepts::Index &y) const
< operator for
Key equal function class.
size_t operator()(const concepts::Index &x) const
Computes the hash function value for x.