gmsh-TingyuanDoc  0.1
An Open-Source Timing-driven Analytical Mixed-size FPGA Placer
GRegion.h
Go to the documentation of this file.
1 // Gmsh - Copyright (C) 1997-2022 C. Geuzaine, J.-F. Remacle
2 //
3 // See the LICENSE.txt file in the Gmsh root directory for license information.
4 // Please report all issues on https://gitlab.onelab.info/gmsh/gmsh/issues.
5 
6 #ifndef GREGION_H
7 #define GREGION_H
8 
9 #include <list>
10 #include <string>
11 #include <vector>
12 #include <stdio.h>
13 #include "GmshDefines.h"
14 #include "GEntity.h"
15 #include "boundaryLayersData.h"
16 
17 class MElement;
18 class MTetrahedron;
19 class MHexahedron;
20 class MPrism;
21 class MPyramid;
22 class MPolyhedron;
23 class MTrihedron;
24 class ExtrudeParams;
26 
27 // A model region.
28 class GRegion : public GEntity {
29 protected:
30  std::vector<GFace *> l_faces;
31  std::vector<GVertex *> embedded_vertices;
32  std::vector<GFace *> embedded_faces;
33  std::vector<GEdge *> embedded_edges;
34  std::vector<int> l_dirs;
36 
37 public:
38  GRegion(GModel *model, int tag);
39  virtual ~GRegion();
40 
41  // delete mesh data
42  virtual void deleteMesh();
43 
44  // get the dimension of the region (3)
45  virtual int dim() const { return 3; }
46 
47  // returns the parent entity for partitioned entities
48  virtual GEntity *getParentEntity() { return nullptr; }
49 
50  // set the visibility flag
51  virtual void setVisibility(char val, bool recursive = false);
52 
53  // set color
54  virtual void setColor(unsigned int val, bool recursive = false);
55 
56  // add embedded vertices/edges/faces
57  void addEmbeddedVertex(GVertex *v) { embedded_vertices.push_back(v); }
58  void addEmbeddedEdge(GEdge *e) { embedded_edges.push_back(e); }
59  void addEmbeddedFace(GFace *f) { embedded_faces.push_back(f); }
60 
61  // get/set faces that bound the region
62  int delFace(GFace *face);
63 
64  virtual std::vector<GFace *> faces() const { return l_faces; }
65 
66  virtual std::vector<int> faceOrientations() const { return l_dirs; }
67  void set(std::vector<GFace *> const &f) { l_faces = f; }
68  void setOrientations(const std::vector<int> &f) { l_dirs = f; }
69  void setFace(GFace *const f, int const orientation)
70  {
71  l_faces.push_back(f);
72  l_dirs.push_back(orientation);
73  }
74  void setBoundFaces(const std::set<int> &tagFaces);
75  void setBoundFaces(const std::vector<int> &tagFaces,
76  const std::vector<int> &signFaces);
77 
78  // direct access to embedded entities
79  std::vector<GVertex *> &embeddedVertices() { return embedded_vertices; }
80  std::vector<GEdge *> &embeddedEdges() { return embedded_edges; }
81  std::vector<GFace *> &embeddedFaces() { return embedded_faces; }
82  std::vector<MVertex *> getEmbeddedMeshVertices() const;
83 
84  // edges that bound the region
85  virtual std::vector<GEdge *> const &edges() const;
86 
87  // vertices that bound the region
88  virtual std::vector<GVertex *> vertices() const;
89 
90  // get the bounding box
91  virtual SBoundingBox3d bounds(bool fast = false);
92 
93  // get the oriented bounding box
94  virtual SOrientedBoundingBox getOBB();
95 
96  // check if the region is connected to another region by an edge
97  bool edgeConnected(GRegion *r) const;
98 
99  // compute volume, moment of intertia and center of gravity
100  double computeSolidProperties(std::vector<double> cg,
101  std::vector<double> inertia);
102 
103  // return a type-specific additional information string
104  virtual std::string getAdditionalInfoString(bool multline = false);
105 
106  // export in GEO format
107  virtual void writeGEO(FILE *fp);
108 
109  // export in Python
110  virtual void writePY(FILE *fp);
111 
112  // types of elements
113  virtual void getElementTypes(std::vector<int> &types) const
114  {
115  types.clear();
116  types.push_back(TYPE_TET);
117  types.push_back(TYPE_PYR);
118  types.push_back(TYPE_PRI);
119  types.push_back(TYPE_HEX);
120  types.push_back(TYPE_TRIH);
121  types.push_back(TYPE_POLYH);
122  };
123 
124  // get total/by-type number of elements in the mesh
125  std::size_t getNumMeshElements() const;
126  std::size_t getNumMeshElementsByType(const int familyType) const;
127  std::size_t getNumMeshParentElements();
128  void getNumMeshElements(unsigned *const c) const;
129 
130  // get the start of the array of a type of element
131  MElement *const *getStartElementType(int type) const;
132 
133  // get the element at the given index
134  MElement *getMeshElement(std::size_t index) const;
135  // get the element at the given index for a given familyType
136  MElement *getMeshElementByType(const int familyType,
137  const std::size_t index) const;
138 
139  // reset the mesh attributes to default values
140  virtual void resetMeshAttributes();
141 
142  struct {
143  // do we recombine the tetrahedra of the mesh into hex?
145  // is this surface meshed using a transfinite interpolation
146  char method;
147  // the extrusion parameters (if any)
149  // corners of the transfinite interpolation
150  std::vector<GVertex *> corners;
151  // structured/unstructured coupling using pyramids
152  int QuadTri;
153  // global mesh size constraint for the volume
154  double meshSize;
156 
157  virtual double getMeshSize() const { return meshAttributes.meshSize; }
158 
159  // a array for accessing the transfinite vertices using a triplet of
160  // indices
161  std::vector<std::vector<std::vector<MVertex *> > > transfinite_vertices;
162 
163  std::vector<MTetrahedron *> tetrahedra;
164  std::vector<MHexahedron *> hexahedra;
165  std::vector<MPrism *> prisms;
166  std::vector<MPyramid *> pyramids;
167  std::vector<MTrihedron *> trihedra;
168  std::vector<MPolyhedron *> polyhedra;
169 
170  void addTetrahedron(MTetrahedron *t) { tetrahedra.push_back(t); }
171  void addHexahedron(MHexahedron *h) { hexahedra.push_back(h); }
172  void addPrism(MPrism *p) { prisms.push_back(p); }
173  void addPyramid(MPyramid *p) { pyramids.push_back(p); }
174  void addPolyhedron(MPolyhedron *p) { polyhedra.push_back(p); }
175  void addTrihedron(MTrihedron *t) { trihedra.push_back(t); }
176  void addElement(int type, MElement *e);
177  void removeElement(int type, MElement *e);
178  void removeElements(int type);
179 
180  // get the boundary layer columns
182 
183  virtual bool reorder(const int elementType,
184  const std::vector<std::size_t> &ordering);
185 
186  // set the reverseMesh constraint in the bounding surfaces so that the
187  // boundary mesh has outward pointing normals, based on the STL triangulation
189 
190  virtual bool isFullyDiscrete();
191 };
192 
193 #endif
GRegion::edgeConnected
bool edgeConnected(GRegion *r) const
Definition: GRegion.cpp:472
GRegion::getElementTypes
virtual void getElementTypes(std::vector< int > &types) const
Definition: GRegion.h:113
GRegion::l_faces
std::vector< GFace * > l_faces
Definition: GRegion.h:30
GRegion::GRegion
GRegion(GModel *model, int tag)
Definition: GRegion.cpp:28
GRegion::addPyramid
void addPyramid(MPyramid *p)
Definition: GRegion.h:173
GRegion::method
char method
Definition: GRegion.h:146
GRegion::getMeshElementByType
MElement * getMeshElementByType(const int familyType, const std::size_t index) const
Definition: GRegion.cpp:151
MTetrahedron
Definition: MTetrahedron.h:34
GFace
Definition: GFace.h:33
GEntity::model
GModel * model() const
Definition: GEntity.h:277
GEntity.h
GRegion::addEmbeddedVertex
void addEmbeddedVertex(GVertex *v)
Definition: GRegion.h:57
c
static double c(int i, int j, fullMatrix< double > &CA, const std::vector< SPoint3 > &P, const std::vector< SPoint3 > &Q)
Definition: discreteFrechetDistance.cpp:15
GRegion::deleteMesh
virtual void deleteMesh()
Definition: GRegion.cpp:39
GRegion::writeGEO
virtual void writeGEO(FILE *fp)
Definition: GRegion.cpp:397
GRegion::recombine3D
int recombine3D
Definition: GRegion.h:144
LegendrePolynomials::f
void f(int n, double u, double *val)
Definition: orthogonalBasis.cpp:77
GRegion::addPolyhedron
void addPolyhedron(MPolyhedron *p)
Definition: GRegion.h:174
GRegion::getOBB
virtual SOrientedBoundingBox getOBB()
Definition: GRegion.cpp:194
GRegion::set
void set(std::vector< GFace * > const &f)
Definition: GRegion.h:67
GRegion::transfinite_vertices
std::vector< std::vector< std::vector< MVertex * > > > transfinite_vertices
Definition: GRegion.h:161
SOrientedBoundingBox
Definition: SOrientedBoundingBox.h:33
GRegion::getNumMeshElements
std::size_t getNumMeshElements() const
Definition: GRegion.cpp:60
GRegion::getColumns
BoundaryLayerColumns * getColumns()
Definition: GRegion.h:181
MPyramid
Definition: MPyramid.h:32
GRegion::getNumMeshElementsByType
std::size_t getNumMeshElementsByType(const int familyType) const
Definition: GRegion.cpp:66
MPrism
Definition: MPrism.h:34
BoundaryLayerColumns
Definition: boundaryLayersData.h:51
GRegion::meshSize
double meshSize
Definition: GRegion.h:154
GRegion::_columns
BoundaryLayerColumns _columns
Definition: GRegion.h:35
GRegion::getNumMeshParentElements
std::size_t getNumMeshParentElements()
Definition: GRegion.cpp:84
GEntity
Definition: GEntity.h:31
GRegion::isFullyDiscrete
virtual bool isFullyDiscrete()
Definition: GRegion.cpp:948
GRegion::corners
std::vector< GVertex * > corners
Definition: GRegion.h:150
TYPE_PRI
#define TYPE_PRI
Definition: GmshDefines.h:70
GRegion::setOrientations
void setOrientations(const std::vector< int > &f)
Definition: GRegion.h:68
GRegion::removeElements
void removeElements(int type)
Definition: GRegion.cpp:665
GRegion::getMeshSize
virtual double getMeshSize() const
Definition: GRegion.h:157
GRegion::addHexahedron
void addHexahedron(MHexahedron *h)
Definition: GRegion.h:171
GRegion::polyhedra
std::vector< MPolyhedron * > polyhedra
Definition: GRegion.h:168
GRegion::faces
virtual std::vector< GFace * > faces() const
Definition: GRegion.h:64
GRegion::hexahedra
std::vector< MHexahedron * > hexahedra
Definition: GRegion.h:164
GRegion::extrude
ExtrudeParams * extrude
Definition: GRegion.h:148
GRegion::setColor
virtual void setColor(unsigned int val, bool recursive=false)
Definition: GRegion.cpp:261
MTrihedron
Definition: MTrihedron.h:31
boundaryLayersData.h
GVertex
Definition: GVertex.h:23
GRegion::writePY
virtual void writePY(FILE *fp)
Definition: GRegion.cpp:439
GRegion::getEmbeddedMeshVertices
std::vector< MVertex * > getEmbeddedMeshVertices() const
Definition: GRegion.cpp:571
GRegion::faceOrientations
virtual std::vector< int > faceOrientations() const
Definition: GRegion.h:66
GModel
Definition: GModel.h:44
GRegion::vertices
virtual std::vector< GVertex * > vertices() const
Definition: GRegion.cpp:603
GmshDefines.h
GRegion::trihedra
std::vector< MTrihedron * > trihedra
Definition: GRegion.h:167
GRegion::l_dirs
std::vector< int > l_dirs
Definition: GRegion.h:34
MHexahedron
Definition: MHexahedron.h:28
GRegion::edges
virtual std::vector< GEdge * > const & edges() const
Definition: GRegion.cpp:459
GRegion::embedded_faces
std::vector< GFace * > embedded_faces
Definition: GRegion.h:32
MElement
Definition: MElement.h:30
GEntity::tag
int tag() const
Definition: GEntity.h:280
MPolyhedron
Definition: MElementCut.h:21
GRegion::dim
virtual int dim() const
Definition: GRegion.h:45
GRegion::getAdditionalInfoString
virtual std::string getAdditionalInfoString(bool multline=false)
Definition: GRegion.cpp:334
GRegion::computeSolidProperties
double computeSolidProperties(std::vector< double > cg, std::vector< double > inertia)
Definition: GRegion.cpp:484
GRegion
Definition: GRegion.h:28
GRegion::addTetrahedron
void addTetrahedron(MTetrahedron *t)
Definition: GRegion.h:170
GRegion::prisms
std::vector< MPrism * > prisms
Definition: GRegion.h:165
GRegion::QuadTri
int QuadTri
Definition: GRegion.h:152
TYPE_PYR
#define TYPE_PYR
Definition: GmshDefines.h:69
GRegion::pyramids
std::vector< MPyramid * > pyramids
Definition: GRegion.h:166
GRegion::addEmbeddedFace
void addEmbeddedFace(GFace *f)
Definition: GRegion.h:59
GRegion::embedded_vertices
std::vector< GVertex * > embedded_vertices
Definition: GRegion.h:31
GRegion::addElement
void addElement(int type, MElement *e)
Definition: GRegion.cpp:613
GRegion::getStartElementType
MElement *const * getStartElementType(int type) const
Definition: GRegion.cpp:102
GRegion::embeddedEdges
std::vector< GEdge * > & embeddedEdges()
Definition: GRegion.h:80
GRegion::~GRegion
virtual ~GRegion()
Definition: GRegion.cpp:33
GRegion::setFace
void setFace(GFace *const f, int const orientation)
Definition: GRegion.h:69
GRegion::setVisibility
virtual void setVisibility(char val, bool recursive=false)
Definition: GRegion.cpp:250
GRegion::embeddedFaces
std::vector< GFace * > & embeddedFaces()
Definition: GRegion.h:81
GRegion::reorder
virtual bool reorder(const int elementType, const std::vector< std::size_t > &ordering)
Definition: GRegion.cpp:679
GRegion::meshAttributes
struct GRegion::@20 meshAttributes
GRegion::delFace
int delFace(GFace *face)
Definition: GRegion.cpp:272
GRegion::resetMeshAttributes
virtual void resetMeshAttributes()
Definition: GRegion.cpp:170
GRegion::getParentEntity
virtual GEntity * getParentEntity()
Definition: GRegion.h:48
GRegion::addEmbeddedEdge
void addEmbeddedEdge(GEdge *e)
Definition: GRegion.h:58
GEdge
Definition: GEdge.h:26
TYPE_HEX
#define TYPE_HEX
Definition: GmshDefines.h:71
TYPE_TET
#define TYPE_TET
Definition: GmshDefines.h:68
TYPE_TRIH
#define TYPE_TRIH
Definition: GmshDefines.h:76
GRegion::addPrism
void addPrism(MPrism *p)
Definition: GRegion.h:172
GRegion::removeElement
void removeElement(int type, MElement *e)
Definition: GRegion.cpp:627
GRegion::embedded_edges
std::vector< GEdge * > embedded_edges
Definition: GRegion.h:33
GRegion::setBoundFaces
void setBoundFaces(const std::set< int > &tagFaces)
Definition: GRegion.cpp:294
ExtrudeParams
Definition: ExtrudeParams.h:26
GRegion::addTrihedron
void addTrihedron(MTrihedron *t)
Definition: GRegion.h:175
TYPE_POLYH
#define TYPE_POLYH
Definition: GmshDefines.h:73
SBoundingBox3d
Definition: SBoundingBox3d.h:21
GRegion::bounds
virtual SBoundingBox3d bounds(bool fast=false)
Definition: GRegion.cpp:179
GRegion::getMeshElement
MElement * getMeshElement(std::size_t index) const
Definition: GRegion.cpp:127
GRegion::tetrahedra
std::vector< MTetrahedron * > tetrahedra
Definition: GRegion.h:163
GRegion::embeddedVertices
std::vector< GVertex * > & embeddedVertices()
Definition: GRegion.h:79
GRegion::setOutwardOrientationMeshConstraint
bool setOutwardOrientationMeshConstraint()
Definition: GRegion.cpp:839