40 #define MESHWRITER_H 1
42 #include <lifev/core/LifeV.hpp> 43 #include <lifev/core/mesh/ElementShapes.hpp> 59 template <
typename Mesh>
62 std::ofstream ofile ( fname.c_str() );
64 ASSERT ( ofile,
"Error: Output file cannot be open" );
66 ofile <<
"MeshVersionFormatted 1\n";
67 ofile <<
"Dimension 3\n";
69 ofile <<
"Vertices\n";
71 UInt nVertices = mesh.numVertices();
72 ofile << nVertices <<
"\n";
74 for (
UInt i = 0; i < nVertices; ++i )
76 ofile << mesh.pointList ( i ).x() <<
" " 77 << mesh.pointList ( i ).y() <<
" " 78 << mesh.pointList ( i ).z() <<
" " 79 << mesh.pointList ( i ).markerID() <<
"\n";
83 typedef typename Mesh::faceShape_Type faceShape_Type;
85 switch ( faceShape_Type::S_shape )
88 ofile <<
"Quadrilaterals\n";
91 ofile <<
"Triangles\n";
94 ERROR_MSG (
"BdShape not implement in MEDIT writer" );
97 UInt nBdF = mesh. numBFaces();
98 ofile << nBdF <<
"\n";
100 UInt nVerticesPerFace = faceShape_Type::S_numVertices;
103 for (
UInt k = 0; k < nBdF; ++k )
105 for (
UInt i = 0; i < nVerticesPerFace; ++i )
107 ofile << mesh.boundaryFace ( k ).point ( i ).id() + 1
110 ofile << mesh.boundaryFace ( k ).markerID() <<
"\n";
114 typedef typename Mesh::volumeShape_Type volumeShape_Type;
116 switch ( volumeShape_Type::S_shape )
119 ofile <<
"Hexaedra\n";
122 ofile <<
"Tetrahedra\n";
125 ERROR_MSG (
"Shape not implement in MEDIT writer" );
128 UInt nElements = mesh.numVolumes();
129 ofile << nElements <<
"\n";
131 UInt nVerticesPerElement = volumeShape_Type::S_numVertices;
135 for (
UInt k = 0; k < nElements; ++k )
137 for (
UInt i = 0; i < nVerticesPerElement; ++i )
139 ielem = mesh.volume ( k ).point ( i ).localId();
144 ofile << mesh.volume ( k ).markerID() <<
"\n";
void writeMeshMedit(std::string fname, Mesh &mesh)
MeshWriter - Short description of the class.
uint32_type UInt
generic unsigned integer (used mainly for addressing)