4 * Created on: 22 janv. 2012
12 * Mesh class is defined by
13 * - case 1: file name of mesh med file (general unstructured)
14 * - case 2: 1D cartesian, xmin and xmax and number of cells
15 * - case 3: 2D cartesian, xmin, xmax, ymin and ymax and numbers of cells in x direction and y direction
16 * - case 4: 3D cartesian, xmin, xmax, ymin, ymax, zmin and zmax and numbers of cells in x direction, y direction and z direction
17 * - case 5: 2D regular triangular mesh
18 * - case 6: 3D regular hexahedral mesh
19 * - case 7: 1D unstructured
25 class MEDCouplingMesh;
26 class MEDCouplingIMesh;
27 class MEDCouplingUMesh;
35 #include "NormalizedGeometricTypes"
55 public: //----------------------------------------------------------------
57 * \brief default constructor
62 * \brief constructor with data to load a general unstructured mesh
63 * @param filename name of mesh file
64 * @param meshLevel : relative mesh dimension : 0->cells, 1->Faces etc
66 Mesh ( const std::string filename, int meshLevel=0 ) ;
69 * \brief constructor with data for a regular 1D grid
70 * @param xmin : minimum x
71 * @param xmax : maximum x
72 * @param nx : Number of cells in x direction
74 Mesh( double xmin, double xmax, int nx, std::string meshName="MESH1D_Regular_Grid" ) ;
77 * \brief constructor with data for an unstructured 1D mesh
78 * @param points : abscissas of the mesh nodes
80 Mesh( std::vector<double> points, std::string meshName="MESH1D_unstructured" ) ;
83 * \brief constructor with data for a regular 2D grid
84 * @param xmin : minimum x
85 * @param xmax : maximum x
86 * @param ymin : minimum y
87 * @param ymax : maximum y
88 * @param nx : Number of cells in x direction
89 * @param ny : Number of cells in y direction
90 * @param split_to_triangles_policy : each rectangle will be split into 2 triangles with orientation of the cut depending if value is 0 or 1
92 Mesh( double xmin, double xmax, int nx, double ymin, double ymax, int ny, int split_to_triangles_policy=-1, std::string meshName="MESH2D_Regular_Rectangle_Grid") ;
95 * \brief constructor with data for a regular 3D grid
96 * @param xmin : minimum x
97 * @param xmax : maximum x
98 * @param ymin : minimum y
99 * @param ymax : maximum y
100 * @param zmin : minimum z
101 * @param zmax : maximum z
102 * @param nx : Number of cells in x direction
103 * @param ny : Number of cells in y direction
104 * @param nz : Number of cells in z direction
105 * @param split_to_tetrahedra_policy : each cuboid will be split into 5 tetrahedra if value is INTERP_KERNEL::PLANAR_FACE_5 or 6 tetrahedra if the value is INTERP_KERNEL::PLANAR_FACE_6
107 Mesh( double xmin, double xmax, int nx, double ymin, double ymax, int ny, double zmin, double zmax, int nz, int split_to_tetrahedra_policy=-1, std::string meshName="MESH3D_Regular_Cuboid_Grid") ;
109 Mesh( const MEDCoupling::MEDCouplingIMesh* mesh ) ;
110 Mesh( const MEDCoupling::MEDCouplingUMesh* mesh ) ;
113 * \brief constructor with data
114 * @param filename : file name of mesh med file
115 * @param meshLevel : relative mesh dimension : 0->cells, 1->Faces etc
117 void readMeshMed( const std::string filename, int meshLevel=0 ) ;
120 * \brief constructor by copy
121 * @param mesh : The Mesh object to be copied
123 Mesh ( const Mesh & mesh ) ;
131 * \brief return mesh name
134 std::string getName( void ) const ;
137 * \brief return Space dimension
140 int getSpaceDimension( void ) const ;
143 * \brief Mesh dimension
146 int getMeshDimension( void ) const ;
149 * \brief return The nodes in this mesh
152 Node* getNodes ( void ) const ;
155 * \brief return The cells in this mesh
158 Cell* getCells ( void ) const ;
161 * \brief return the faces in this mesh
164 Face* getFaces ( void ) const ;
167 * \brief return the number of nodes in this mesh
168 * @return _numberOfNodes
170 int getNumberOfNodes ( void ) const ;
173 * \brief return the number of faces in this mesh
174 * @return _numberOfFaces
176 int getNumberOfFaces ( void ) const ;
179 * \brief return the number of cells in this mesh
180 * @return _numberOfCells
182 int getNumberOfCells ( void ) const ;
185 * \brief return the number of edges in this mesh
186 * @return _numberOfEdges
188 int getNumberOfEdges ( void ) const ;
191 * \brief return the cell i in this mesh
194 Cell& getCell ( int i ) const ;
197 * return The face i in this mesh
200 Face& getFace ( int i ) const ;
203 * \brief return The node i in this mesh
206 Node& getNode ( int i ) const ;
209 * \brief return number of cell in x direction (structured mesh)
212 int getNx( void ) const ;
215 * \brief return number of cell in y direction (structured mesh)
218 int getNy( void ) const ;
221 * \brief return number of cell in z direction (structured mesh)
224 int getNz( void ) const ;
226 double getXMin( void ) const ;
228 double getXMax( void ) const ;
230 double getYMin( void ) const ;
232 double getYMax( void ) const ;
234 double getZMin( void ) const ;
236 double getZMax( void ) const ;
238 std::vector<double> getDXYZ() const ;// for structured meshes
240 std::vector<int> getCellGridStructure() const;// for structured meshes
243 * \brief surcharge operator =
244 * @param mesh : The Mesh object to be copied
246 const Mesh& operator= ( const Mesh& mesh ) ;
249 * \brief return the mesh MEDCoupling
252 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingMesh> getMEDCouplingMesh ( void ) const ;
255 * \brief computes the skin surrounding the mesh
257 Mesh getBoundaryMesh ( void ) const ;
260 * \brief return the list of face group names
261 * return _faceGroupNames
263 std::vector<std::string> getNameOfFaceGroups( void ) const ;
266 * \brief return the list of node group names
267 * return _nodeGroupNames
269 std::vector<std::string> getNameOfNodeGroups( void ) const ;
272 * \brief return the list of face groups
273 * @return _faceGroups
275 std::vector<MEDCoupling::MEDCouplingUMesh *> getFaceGroups( void ) const ;
278 * \brief return the list of node groups
279 * @return _nodeGroups
281 std::vector<MEDCoupling::DataArrayInt32 *> getNodeGroups( void ) const ;
284 * Functions to extract boundary nodes and faces Ids
287 * \brief return the list of boundary faces Ids
288 * @return _boundaryFaceIds
290 std::vector< int > getBoundaryFaceIds() const;
292 * \brief list of boundary nodes Ids
293 * @return _boundaryNodeIds
295 std::vector< int > getBoundaryNodeIds() const;
297 * Functions to extract group nodes and faces ids
300 * @return list of face group Ids
302 std::vector< int > getGroupFaceIds(std::string groupName) const;
304 * @return list of node group Ids
306 std::vector< int > getGroupNodeIds(std::string groupName) const;
309 * \brief write mesh in the VTK format
311 void writeVTK ( const std::string fileName ) const ;
314 * \brief write mesh in the MED format
316 void writeMED ( const std::string fileName ) const ;
318 void setGroupAtPlan(double value, int direction, double eps, std::string groupName) ;
320 void setGroupAtFaceByCoords(double x, double y, double z, double eps, std::string groupName) ;
322 void setFaceGroupByIds(std::vector< int > faceIds, std::string groupName) ;
324 void setNodeGroupByIds(std::vector< int > nodeIds, std::string groupName) ;
327 * Functions to manage periodic boundary condition in square/cubic geometries
329 void setPeriodicFaces(bool check_groups= false, bool use_central_inversion=false) ;
330 int getIndexFacePeriodic(int indexFace, bool check_groups= false, bool use_central_inversion=false);
331 void setBoundaryNodesFromFaces();
332 std::map<int,int> getIndexFacePeriodic( void ) const;
333 bool isIndexFacePeriodicSet() const ;
335 bool isBorderNode(int nodeid) const ;
336 bool isBorderFace(int faceid) const ;
338 bool isTriangular() const ;
339 bool isTetrahedral() const ;
340 bool isQuadrangular() const ;
341 bool isHexahedral() const ;
342 bool isStructured() const ;
343 std::vector< std::string > getElementTypesNames() const ;
345 * \brief Compute the minimum value over all cells of the ratio cell perimeter/cell vaolume
347 double minRatioVolSurf();
350 * \brief Compute the maximum number of neighbours around an element (cells around a cell or nodes around a node)
352 int getMaxNbNeighbours(EntityType type) const;
354 private: //----------------------------------------------------------------
356 MEDCoupling::MEDCouplingUMesh* setMesh( void ) ;
358 void setGroups( const MEDCoupling::MEDFileUMesh* medmesh, MEDCoupling::MEDCouplingUMesh* mu) ;
363 * \brief Space dimension
368 * \brief Mesh dimension
373 * Structured mesh parameters
390 std::vector<int> _nxyz;
392 std::vector<double> _dxyz;
394 * The nodes in this mesh.
399 * The number of nodes in this mesh.
404 * The faces in this mesh.
409 * The numbers of faces in this mesh.
414 * The cells in this mesh.
419 * The number of cells in this mesh.
424 * The number of edges in this mesh.
426 int _numberOfEdges;//Useful to deduce the number of non zero coefficients in the finite element matrix
429 * The names of face groups.
431 std::vector<std::string> _faceGroupNames;
434 * The names of node groups.
436 std::vector<std::string> _nodeGroupNames;
439 * The list of face groups.
441 std::vector<MEDCoupling::MEDCouplingUMesh *> _faceGroups;
443 * The list of node groups.
445 std::vector<MEDCoupling::DataArrayInt32 *> _nodeGroups;
447 * The mesh MEDCoupling
449 MEDCoupling::MCAuto<MEDCoupling::MEDCouplingMesh> _mesh;
451 std::vector< INTERP_KERNEL::NormalizedCellType > _eltsTypes;//List of cell types contained in the mesh
452 std::vector< std::string > _eltsTypesNames;//List of cell types contained in the mesh
453 std::vector< INTERP_KERNEL::NormalizedCellType > getElementTypes() const;
456 * Tools to manage periodic boundary conditions in square/cube geometries
458 bool _indexFacePeriodicSet;
459 std::map<int,int> _indexFacePeriodicMap;
461 /* List of boundary faces*/
462 std::vector< int > _boundaryFaceIds;
463 /* List of boundary nodes*/
464 std::vector< int > _boundaryNodeIds;
466 const MEDCoupling::MEDCouplingUMesh * _boundaryMesh;
469 #endif /* MESH_HXX_ */