71 std::cout <<
"TPZGmshReader:: Lastest version supported 4.1 " << std::endl;
72 std::cout <<
"TPZGmshReader:: This reader supports only the lastest version " << std::endl;
73 std::cout <<
"TPZGmshReader:: Reader no available for the msh file version = " <<
m_format_version << std::endl;
81 out <<
"TPZGmshReader geometrical partition summary " << std::endl;
83 out <<
"Geometry dimension = " <<
m_dimension << std::endl;
84 out <<
"Number of volumes = " <<
m_n_volumes << std::endl;
85 out <<
"Number of surfaces = " <<
m_n_surfaces << std::endl;
86 out <<
"Number of curves = " <<
m_n_curves << std::endl;
87 out <<
"Number of points = " <<
m_n_points << std::endl;
92 out <<
"Number of elements by type : " << std::endl;
103 out <<
"Number of elements by dimension : " << std::endl;
104 out <<
"3D elements : " << n_vols_els << std::endl;
105 out <<
"2D elements : " << n_surf_els << std::endl;
166 std::ifstream
read (file_name.c_str());
169 std::cout <<
"Couldn't open the file " << file_name << std::endl;
174 std::cout <<
"Gmsh Reader: the mesh file path is wrong " << std::endl;
181 read.getline(buf, 1024);
182 std::string str(buf);
184 if(str ==
"$MeshFormat" || str ==
"$MeshFormat\r")
186 read.getline(buf, 1024);
187 std::string str(buf);
188 std::cout <<
"Reading mesh format = " << str << std::endl;
192 if(str ==
"$PhysicalNames" || str ==
"$PhysicalNames\r" )
195 int64_t n_physical_names;
196 read >> n_physical_names;
197 int max_dimension = 0;
201 std::pair<int, std::string> chunk;
203 for (int64_t i_name = 0; i_name < n_physical_names; i_name++) {
205 read.getline(buf, 1024);
210 name.erase(name.end()-1,name.end());
215 std::cout <<
"Automatically associating " << name <<
" with material id " <<
id << std::endl;
221 std::cout <<
"Associating " << name <<
" with material id " <<
id <<
222 " with pz material id " << pzmatid << std::endl;
227 if (max_dimension < dimension) {
235 read.getline(buf_end, 1024);
236 read.getline(buf_end, 1024);
237 std::string str_end(buf_end);
238 if(str_end ==
"$EndPhysicalNames" || str_end ==
"$EndPhysicalNames\r")
240 std::cout <<
"Read mesh physical entities = " << n_physical_names << std::endl;
245 if(str ==
"$Entities" || str ==
"$Entities\r")
254 std::pair<int, std::vector<int> > chunk;
256 REAL x_min, y_min, z_min;
257 REAL x_max, y_max, z_max;
259 std::vector<int> n_entities_with_physical_tag = {0,0,0,0};
263 for (int64_t i_entity = 0; i_entity < n_entities[
i_dim]; i_entity++) {
265 read.getline(buf, 1024);
276 read >> n_physical_tag;
277 chunk.second.resize(n_physical_tag);
278 for (
int i_data = 0; i_data < n_physical_tag; i_data++) {
279 read >> chunk.second[i_data];
283 size_t n_bounding_points;
284 read >> n_bounding_points;
285 for (
int i_data = 0; i_data < n_bounding_points; i_data++) {
290 n_entities_with_physical_tag[
i_dim] += n_physical_tag;
301 read.getline(buf_end, 1024);
302 read.getline(buf_end, 1024);
303 std::string str_end(buf_end);
304 if(str_end ==
"$EndEntities" || str_end ==
"$EndEntities\r")
306 std::cout <<
"Read mesh entities = " << m_n_points + m_n_curves + m_n_surfaces + m_n_volumes << std::endl;
312 if(str ==
"$Nodes" || str ==
"$Nodes\r")
315 int64_t n_entity_blocks, n_nodes, min_node_tag, max_node_tag;
316 read >> n_entity_blocks;
318 read >> min_node_tag;
319 read >> max_node_tag;
322 double nodecoordX , nodecoordY , nodecoordZ ;
323 gmesh -> NodeVec().Resize(max_node_tag);
326 const int64_t Tnodes = max_node_tag;
329 int entity_tag, entity_dim, entity_parametric, entity_nodes;
330 for (int64_t i_block = 0; i_block < n_entity_blocks; i_block++)
332 read.getline(buf, 1024);
335 read >> entity_parametric;
336 read >> entity_nodes;
338 if (entity_parametric != 0) {
339 std::cout <<
"TPZGmshReader:: Characteristic not implemented." << std::endl;
344 for (int64_t inode = 0; inode < entity_nodes; inode++) {
345 read >> nodeids[inode];
347 for (int64_t inode = 0; inode < entity_nodes; inode++) {
352 Node[nodeids[inode]-1].SetNodeId(nodeids[inode]-1);
356 gmesh->
NodeVec()[nodeids[inode]-1] = Node[nodeids[inode]-1];
362 read.getline(buf_end, 1024);
363 read.getline(buf_end, 1024);
364 std::string str_end(buf_end);
365 if(str_end ==
"$EndNodes" || str_end ==
"$EndNodes\r")
367 std::cout <<
"Read mesh nodes = " << gmesh->
NNodes() << std::endl;
372 if(str ==
"$Elements" || str ==
"$Elements\r")
375 int64_t n_entity_blocks, n_elements, min_element_tag, max_element_tag;
376 read >> n_entity_blocks;
378 read >> min_element_tag;
379 read >> max_element_tag;
382 int entity_tag, entity_dim, entity_el_type, entity_elements;
383 for (int64_t i_block = 0; i_block < n_entity_blocks; i_block++)
385 read.getline(buf, 1024);
388 read >> entity_el_type;
389 read >> entity_elements;
391 if(entity_elements == 0){
392 std::cout <<
"The entity with tag " << entity_tag <<
" does not have elements to insert" << std::endl;
395 for (int64_t iel = 0; iel < entity_elements; iel++) {
396 int physical_identifier;
397 int n_physical_identifier = 0;
402 bool physical_identifier_Q = n_physical_identifier != 0;
403 if(physical_identifier_Q)
407 if(n_physical_identifier !=1){
408 std::cout <<
"The entity with tag " << entity_tag << std::endl;
409 std::cout <<
"Has associated the following physical tags : " << std::endl;
410 for (
int i_data = 0; i_data < n_physical_identifier; i_data++) {
414 std::cout <<
"Automatically, the assgined pz physical tag = " << physical_identifier <<
" is used. The other ones are dropped out." << std::endl;
418 read.getline(buf, 1024);
419 int el_identifier, n_el_nodes;
421 read >> el_identifier;
422 std::vector<int> node_identifiers(n_el_nodes);
423 for (
int i_node = 0; i_node < n_el_nodes; i_node++) {
424 read >> node_identifiers[i_node];
427 InsertElement(gmesh, physical_identifier, entity_el_type, el_identifier, node_identifiers);
430 read.getline(buf, 1024);
431 int el_identifier, n_el_nodes;
433 read >> el_identifier;
434 std::vector<int> node_identifiers(n_el_nodes);
435 for (
int i_node = 0; i_node < n_el_nodes; i_node++) {
436 read >> node_identifiers[i_node];
438 std::cout <<
"The entity with tag " << entity_tag <<
" does not have a physical tag, element " << el_identifier <<
" skipped " << std::endl;
445 read.getline(buf_end, 1024);
446 read.getline(buf_end, 1024);
447 std::string str_end(buf_end);
448 if(str_end ==
"$EndElements" || str_end ==
"$EndElements\r")
450 std::cout <<
"Read mesh elements = " << gmesh->
NElements() << std::endl;
459 std::cout <<
"Read General Mesh Data -> done!" << std::endl;
460 std::cout <<
"Number of elements " << gmesh->
NElements() << std::endl;
462 std::cout <<
"Geometric Mesh Connectivity -> done!" << std::endl;
470 int n_nodes = node_identifiers.
size();
471 Topology.
Resize(n_nodes, 0);
472 for (
int k_node = 0; k_node<n_nodes; k_node++) {
473 Topology[k_node] = node_identifiers[k_node]-1;
546 for (
int k_node = 0; k_node < n_nodes-1; k_node++) {
547 Topology_c[k_node] = Topology[k_node];
584 std::cout <<
"Element not impelemented." << std::endl;
681 std::cout <<
"Element not impelemented." << std::endl;
703 std::ifstream
read (file_name.c_str());
706 std::cout <<
"Couldn't open the file " << file_name << std::endl;
711 std::cout <<
"Gmsh Reader: the mesh file path is wrong " << std::endl;
718 read.getline(buf, 1024);
719 std::string str(buf);
721 if(str ==
"$MeshFormat" || str ==
"$MeshFormat\r")
723 read.getline(buf, 1024);
724 std::string str(buf);
725 std::cout <<
"Reading mesh format = " << str << std::endl;
729 if(str ==
"$PhysicalNames" || str ==
"$PhysicalNames\r" )
734 int max_dimension = 0;
738 std::pair<int, std::string> chunk;
740 for (int64_t inode = 0; inode < n_entities; inode++) {
742 read.getline(buf, 1024);
747 name.erase(name.end()-1,name.end());
752 std::cout <<
"Automatically associating " << name <<
" with material id " <<
id << std::endl;
758 std::cout <<
"Associating " << name <<
" with material id " <<
id <<
759 " with pz material id " << pzmatid << std::endl;
764 if (max_dimension < dimension) {
771 read.getline(buf_end, 1024);
772 read.getline(buf_end, 1024);
773 std::string str_end(buf_end);
774 if(str_end ==
"$EndPhysicalNames" || str_end ==
"$EndPhysicalNames\r")
776 std::cout <<
"Read mesh physical entities = " << n_entities << std::endl;
781 if(str ==
"$Nodes" || str ==
"$Nodes\r")
788 double nodecoordX , nodecoordY , nodecoordZ ;
789 gmesh -> NodeVec().Resize(n_nodes);
793 const int64_t Tnodes = n_nodes;
796 for (int64_t inode = 0; inode < n_nodes; inode++) {
798 read.getline(buf, 1024);
804 Node[node_id-1].SetNodeId(node_id-1);
808 gmesh->
NodeVec()[node_id-1] = Node[node_id-1];
814 read.getline(buf_end, 1024);
815 read.getline(buf_end, 1024);
816 std::string str_end(buf_end);
817 if(str_end ==
"$EndNodes" || str_end ==
"$EndNodes\r")
819 std::cout <<
"Read mesh nodes = " << gmesh->
NNodes() << std::endl;
824 if(str ==
"$Elements" || str ==
"$Elements\r")
831 for (int64_t iel = 0; iel < n_elements; iel++) {
836 read.getline(buf_end, 1024);
837 read.getline(buf_end, 1024);
838 std::string str_end(buf_end);
839 if(str_end ==
"$EndElements" || str_end ==
"$EndElements\r")
841 std::cout <<
"Read mesh elements = " << gmesh->
NElements() << std::endl;
850 std::cout <<
"Read General Mesh Data -> done!" << std::endl;
851 std::cout <<
"Number of elements " << gmesh->
NElements() << std::endl;
853 std::cout <<
"Geometric Mesh Connectivity -> done!" << std::endl;
890 int64_t element_id, type_id, div_id, physical_id, elementary_id;
892 int dimensions[] = {-1 , 1 , 2 , 2 , 3 , 3 , 3 , 3 , 1 , 2 , 2 , 3 , 3 , 3 , 3 , 0};
896 line.getline(buf, 1024);
902 line >> elementary_id;
904 if (div_id != 2 || type_id > 15) {
905 std::cout <<
"div_id " << div_id <<
" type_id " << type_id << std::endl;
911 std::cout << __PRETTY_FUNCTION__ <<
"physical_id " << physical_id <<
" not found bailing out\n";
922 line >> TopolLine[0];
923 line >> TopolLine[1];
938 line >> TopolTriangle[0];
939 line >> TopolTriangle[1];
940 line >> TopolTriangle[2];
956 line >> TopolQuad[0];
957 line >> TopolQuad[1];
958 line >> TopolQuad[2];
959 line >> TopolQuad[3];
1000 line >> TopolHex[4];
1001 line >> TopolHex[5];
1002 line >> TopolHex[6];
1003 line >> TopolHex[7];
1013 if (dimension < 3) {
1023 line >> TopolPrism[0];
1024 line >> TopolPrism[1];
1025 line >> TopolPrism[2];
1026 line >> TopolPrism[3];
1027 line >> TopolPrism[4];
1028 line >> TopolPrism[5];
1036 if (dimension < 3) {
1047 line >> TopolPyr[0];
1048 line >> TopolPyr[1];
1049 line >> TopolPyr[2];
1050 line >> TopolPyr[3];
1051 line >> TopolPyr[4];
1058 if (dimension < 3) {
1068 line >> TopolLineQ[0];
1069 line >> TopolLineQ[1];
1070 line >> TopolLineQ[2];
1075 if (dimension < 1) {
1085 line >> TopolTriangleQ[0];
1086 line >> TopolTriangleQ[1];
1087 line >> TopolTriangleQ[2];
1088 line >> TopolTriangleQ[3];
1089 line >> TopolTriangleQ[4];
1090 line >> TopolTriangleQ[5];
1092 TopolTriangleQ[0]--;
1093 TopolTriangleQ[1]--;
1094 TopolTriangleQ[2]--;
1095 TopolTriangleQ[3]--;
1096 TopolTriangleQ[4]--;
1097 TopolTriangleQ[5]--;
1098 if (dimension < 2) {
1108 line >> TopolQuadQ[0];
1109 line >> TopolQuadQ[1];
1110 line >> TopolQuadQ[2];
1111 line >> TopolQuadQ[3];
1112 line >> TopolQuadQ[4];
1113 line >> TopolQuadQ[5];
1114 line >> TopolQuadQ[6];
1115 line >> TopolQuadQ[7];
1125 if (dimension < 2) {
1135 line >> TopolTetQ[0];
1136 line >> TopolTetQ[1];
1137 line >> TopolTetQ[2];
1138 line >> TopolTetQ[3];
1140 line >> TopolTetQ[4];
1141 line >> TopolTetQ[5];
1142 line >> TopolTetQ[6];
1143 line >> TopolTetQ[7];
1144 line >> TopolTetQ[9];
1145 line >> TopolTetQ[8];
1159 if (dimension < 3) {
1170 line >> TopolHexQ[0];
1171 line >> TopolHexQ[1];
1172 line >> TopolHexQ[2];
1173 line >> TopolHexQ[3];
1174 line >> TopolHexQ[4];
1175 line >> TopolHexQ[5];
1176 line >> TopolHexQ[6];
1177 line >> TopolHexQ[7];
1179 line >> TopolHexQ[8];
1180 line >> TopolHexQ[11];
1181 line >> TopolHexQ[12];
1182 line >> TopolHexQ[9];
1183 line >> TopolHexQ[13];
1184 line >> TopolHexQ[10];
1185 line >> TopolHexQ[14];
1186 line >> TopolHexQ[15];
1187 line >> TopolHexQ[16];
1188 line >> TopolHexQ[19];
1189 line >> TopolHexQ[17];
1190 line >> TopolHexQ[18];
1214 if (dimension < 3) {
1224 line >> TopolPrismQ[0];
1225 line >> TopolPrismQ[1];
1226 line >> TopolPrismQ[2];
1227 line >> TopolPrismQ[3];
1228 line >> TopolPrismQ[4];
1229 line >> TopolPrismQ[5];
1231 line >> TopolPrismQ[6];
1232 line >> TopolPrismQ[8];
1233 line >> TopolPrismQ[9];
1234 line >> TopolPrismQ[7];
1235 line >> TopolPrismQ[10];
1236 line >> TopolPrismQ[11];
1237 line >> TopolPrismQ[12];
1238 line >> TopolPrismQ[14];
1239 line >> TopolPrismQ[13];
1258 if (dimension < 3) {
1268 line >> TopolPoint[0];
1276 std::cout <<
"Element not impelemented." << std::endl;
TPZGeoMesh * GeometricGmshMesh4(std::string file_name, TPZGeoMesh *gmesh=NULL)
Convert a Gmsh *.msh file with format 4 to a TPZGeoMesh object.
int m_n_physical_curves
Number of curves with physical tag.
int m_n_prism_els
Number of prisms.
Contains the TPZQuadraticPrism class which defines a prism geometric element with quadratic map...
void SetMaxElementId(int64_t id)
Used in patch meshes.
void InsertElement(TPZGeoMesh *gmesh, int &physical_identifier, int &el_type, int &el_identifier, std::vector< int > &node_identifiers)
int m_n_quadrilateral_els
Number of quadrilaterals.
TPZManVector< std::map< int, std::vector< int > >, 4 > m_dim_entity_tag_and_physical_tag
Data structure of both: physical entities and names indexed by dimension.
TPZGeoMesh * GeometricGmshMesh(std::string file_name, TPZGeoMesh *gmesh=NULL)
Convert Gmsh msh files in a TPZGeoMesh object.
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
Implements a vector class which allows to use external storage provided by the user. Utility.
int m_n_triangle_els
Number of triangles.
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
TPZGeoMesh * GeometricGmshMesh3(std::string file_name, TPZGeoMesh *gmesh=NULL)
Convert a Gmsh *.msh file with format 3 to a TPZGeoMesh object.
int m_n_curves
Number of curves.
Implements a generic geometric element with a uniform refinement pattern. Geometry.
Contains the TPZQuadraticQuad class which defines a quadrilateral geometric element with quadratic ma...
TPZManVector< std::map< int, std::string >, 4 > m_dim_physical_tag_and_name
Structure of both: physical entities and names indexed by dimension.
Contains the TPZPoint class which defines the topology of a point.
TPZVec< int64_t > m_entity_index
Entity index to which the element belongs.
int m_n_volumes
Number of volumes.
int64_t NElements() const
Number of elements of the mesh.
int m_n_physical_points
Number of points with physical tag.
This class implements a simple vector storage scheme for a templated class T. Utility.
TPZManVector< std::map< std::string, int >, 4 > m_dim_name_and_physical_tag
Structure of both: names and physical id indexed by dimension.
void SetDimension(int dim)
Set Dimension.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
int m_n_line_els
Number of triangles.
int m_n_tetrahedron_els
Number of tetrahedra.
int64_t size() const
Returns the number of elements of the vector.
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
void SetFormatVersion(std::string format_version)
Set the format version.
void PrintPartitionSummary(std::ostream &out)
Print the partition summary after the reading process.
int64_t i_dim(int64_t value_1, int64_t value_2)
void SetMaxNodeId(int64_t id)
Used in patch meshes.
Implements a generic geometric element which is refined according to a generic refinement pattern...
int m_dimension
Geometry dimension.
Contains the TPZGeoBlend class which implements a blending map from curved boundaries to the interior...
const TPZGmshReader & operator=(const TPZGmshReader &other)
Assignement constructor.
Contains the TPZGeoTetrahedra class which implements the geometry of a tetrahedral element...
#define DebugStop()
Returns a message to user put a breakpoint in.
int64_t NNodes() const
Number of nodes of the mesh.
int GetNumberofNodes(int &el_type)
TPZGmshReader()
Default constructor.
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
int m_n_physical_surfaces
Number of surfaces with physical tag.
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
int m_n_surfaces
Number of surfaces.
Contains the TPZQuadraticLine class which defines a linear geometric element with quadratic map...
Contains the TPZQuadraticCube class which defines a cube geometric element with quadratic map...
Contains the TPZRefPattern class which defines the topology of the current refinement pattern to a me...
std::string m_format_version
gmsh file format version (supported versions = {3,4})
REAL m_characteristic_lentgh
Characteristic length to apply a Scale affine transformation.
Contains the TPZGeoCube class which implements the geometry of hexahedra element. ...
Contains the TPZQuadraticTrig class which defines a triangular geometric element with quadratic map...
Implement the interface between TPZGeoMesh and the files produced by Gmsh (version 3...
Contains the TPZGeoPoint class which implements the geometry of a point element or 0-D element...
void SetCharacteristiclength(REAL length)
Set the Characteristic length.
int m_n_points
Number of points.
void BuildConnectivity()
Build the connectivity of the grid.
~TPZGmshReader()
Default destructor.
Contains the TPZArc3D class which implements three dimensional arc.
This class implements a geometric mesh for the pz environment. Geometry.
int m_n_hexahedron_els
Number of hexahedra.
TPZManVector< std::map< int, int >, 4 > m_dim_physical_tag_and_physical_tag
Structure of both: physical id and user defined physical tag indexed by dimension.
int m_n_pyramid_els
Number of pyramids.
Contains the TPZGeoPyramid class which implements the geometry of pyramid element.
int m_n_point_els
Number of points.
Contains the TPZCube class which defines the topology of the hexahedron element.
Contains declaration of TPZGeoElement class which implements a generic geometric element with a unifo...
Contains the TPZQuadraticTetra class which defines a tetrahedral geometric element with quadratic map...
int m_n_physical_volumes
Number of volumes with physical tag.
T * end() const
Returns a pointer to the last+1 element.
Contains the TPZRefPoint class which implements the uniform refinement of a geometric point element...