GCC Code Coverage Report


Directory: ./
File: InputOutput/medit.cpp
Date: 2024-04-14 07:32:34
Exec Total Coverage
Lines: 409 579 70.6%
Branches: 407 1031 39.5%

Line Branch Exec Source
1 // ______ ______ _ _ _____ ______
2 // | ____| ____| | (_)/ ____| | ____|
3 // | |__ | |__ | | _| (___ ___| |__
4 // | __| | __| | | | |\___ \ / __| __|
5 // | | | |____| |____| |____) | (__| |____
6 // |_| |______|______|_|_____/ \___|______|
7 // Finite Elements for Life Sciences and Engineering
8 //
9 // License: LGL2.1 License
10 // FELiScE default license: LICENSE in root folder
11 //
12 // Main authors: J.Castelneau & J.Foulon
13 //
14
15 // System includes
16
17 // External includes
18
19 // Project includes
20 #include "Core/felisceParam.hpp"
21 #include "InputOutput/medit.hpp"
22
23 namespace felisce
24 {
25
26 Medit::StringToMeditPair_type Medit::m_eltFelNameToMeditPair;
27
28 Medit::Medit(const std::string& inputMesh,const std::string& outputMesh,const std::string& meshDir,const std::string& resultDir):
29 m_inputMesh(inputMesh),
30 m_outputMesh(outputMesh),
31 m_meshDir(meshDir),
32 m_resultDir(resultDir),
33 m_meshVersion(0) {
34 initMap();
35 }
36
37 /***********************************************************************************/
38 /***********************************************************************************/
39
40 1055 void Medit::initialize(const std::string& inputMesh,const std::string& outputMesh,const std::string& meshDir,const std::string& resultDir) {
41 1055 m_inputMesh=inputMesh;
42 1055 m_outputMesh=outputMesh;
43 1055 m_meshDir=meshDir;
44 1055 m_resultDir=resultDir;
45 1055 m_meshVersion=0;
46 1055 initMap();
47 1055 }
48
49 /***********************************************************************************/
50 /***********************************************************************************/
51
52 1055 void Medit::initMap() {
53 //! std::unordered_map for medit mesh
54 //! felisce type name -> < enum, medit keyword >
55
2/2
✓ Branch 1 taken 106 times.
✓ Branch 2 taken 949 times.
1055 if (FelisceParam::instance().readNodesReferences) {
56
3/6
✓ Branch 1 taken 106 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 106 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 106 times.
✗ Branch 9 not taken.
106 m_eltFelNameToMeditPair["Vertices"] = std::make_pair( GeometricMeshRegion::Nod, GmfVertices );
57 }
58
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Segments2"] = std::make_pair( GeometricMeshRegion::Seg2, GmfEdges );
59
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Segments3"] = std::make_pair( GeometricMeshRegion::Seg3, GmfEdgesP2 );
60
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Triangles3"] = std::make_pair( GeometricMeshRegion::Tria3, GmfTriangles );
61
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Triangles6"] = std::make_pair( GeometricMeshRegion::Tria6, GmfTrianglesP2 );
62
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Quadrangles4"] = std::make_pair( GeometricMeshRegion::Quad4, GmfQuadrilaterals );
63
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Quadrangles6"] = std::make_pair( GeometricMeshRegion::Quad6, GmfQuadrilaterals6 );
64
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Quadrangles9"] = std::make_pair( GeometricMeshRegion::Quad9, GmfQuadrilateralsQ2 );
65
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Tetrahedra4"] = std::make_pair( GeometricMeshRegion::Tetra4, GmfTetrahedra );
66
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Tetrahedra10"] = std::make_pair( GeometricMeshRegion::Tetra10,GmfTetrahedraP2 );
67
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Prisms6"] = std::make_pair( GeometricMeshRegion::Prism6, GmfPrisms );
68
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Prisms9"] = std::make_pair( GeometricMeshRegion::Prism9, GmfPrisms9 );
69
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Hexahedra8"] = std::make_pair( GeometricMeshRegion::Hexa8, GmfHexahedra );
70 // m_eltFelNameToMeditPair["Hexahedra12"] = std::make_pair( GeometricMeshRegion::Hexa12, GmfHexahedra12 );
71
3/6
✓ Branch 1 taken 1055 times.
✗ Branch 2 not taken.
✓ Branch 5 taken 1055 times.
✗ Branch 6 not taken.
✓ Branch 8 taken 1055 times.
✗ Branch 9 not taken.
1055 m_eltFelNameToMeditPair["Hexahedra27"] = std::make_pair( GeometricMeshRegion::Hexa27, GmfHexahedraQ2 );
72 1055 }
73
74 /***********************************************************************************/
75 /***********************************************************************************/
76
77 namespace { // anonymous
78 // This function writes on \a stream a warning when mesh version is not supported by architecture
79 // Compilation error when \a SizeOfLongT is neither 4 (32 bits) nor 8 (64 bits)
80 template<int SizeOfLongT>
81 void warnInvalidArchitecture(std::ostream& stream) {
82 switch(SizeOfLongT) {
83 case 4:
84 stream << " You are trying to use MeshVersion = 3 with a 32 bit version of Arch.";
85 break;
86 case 8:
87 // Do nothing
88 break;
89 default:
90 felisce_error("Unexpected size of long!", __FILE__, __LINE__);
91 }
92 }
93
94 } // namespace anonymous
95
96
97 /***********************************************************************************/
98 /***********************************************************************************/
99
100 template<class TType, bool TReadRefNodes>
101 1008 void Medit::ReadVertices(
102 GeometricMeshRegion& rMesh,
103 const double spaceUnit,
104 int64_t& InpMsh,
105 RefToElements_type* RefToElementsMaps
106 )
107 {
108 // Dimension
109 1008 const auto dimension = rMesh.numCoor();
110
111 // Node reference
112 int node_ref;
113
114 // Coordinates
115 1008 TType xcoor, ycoor, zcoor = 0.0;
116
117 // Reading coordinates
118
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
1008 GmfGotoKwd(InpMsh, GmfVertices);
119
120 // Retrive the correct dimension point
121 1008 const std::function<void(int64_t&, TType&, TType&, TType&, int& )> retrieve_3d_vertex =
122 532038 [](int64_t& InpMsh, TType& xcoor, TType& ycoor, TType& zcoor, int& node_ref) {GmfGetLin(InpMsh, GmfVertices, &xcoor, &ycoor, &zcoor, &node_ref );};
123 1008 const std::function<void(int64_t&, TType&, TType&, TType&, int& )> retrieve_2d_vertex =
124 161308 [](int64_t& InpMsh, TType& xcoor, TType& ycoor, TType& zcoor, int& node_ref) {
125 IGNORE_UNUSED_ARGUMENT(zcoor);
126 80654 GmfGetLin(InpMsh, GmfVertices, &xcoor, &ycoor, &node_ref );
127 };
128
129
2/2
✓ Branch 0 taken 395 times.
✓ Branch 1 taken 109 times.
1008 const auto* p_retrieve_vertex = dimension == 3 ? &retrieve_3d_vertex : &retrieve_2d_vertex;
130
131 // Retrieve coordinates
132 1008 GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = rMesh.intRefToEnum();
133
1/2
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
1008 std::vector<felInt> elem(1);
134
2/2
✓ Branch 1 taken 612692 times.
✓ Branch 2 taken 504 times.
1226392 for(felInt iv=0; iv< rMesh.numPoints(); iv++) {
135 1225384 auto& r_point = rMesh.listPoint(iv);
136
1/2
✓ Branch 1 taken 612692 times.
✗ Branch 2 not taken.
1225384 (*p_retrieve_vertex)(InpMsh, xcoor, ycoor, zcoor, node_ref);
137 1225384 r_point.x() = xcoor*spaceUnit;
138 1225384 r_point.y() = ycoor*spaceUnit;
139 1225384 r_point.z() = zcoor*spaceUnit;
140
141 // We add the node to the mesh
142 if constexpr(TReadRefNodes) {
143 1266 elem[0] = iv + 1;
144
1/2
✓ Branch 1 taken 633 times.
✗ Branch 2 not taken.
1266 rMesh.setOneElement(GeometricMeshRegion::Nod, iv, elem, true);
145
2/4
✓ Branch 1 taken 633 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 633 times.
✗ Branch 5 not taken.
1266 RefToElementsMaps[ GeometricMeshRegion::Nod ][ node_ref ].push_back( iv );
146
2/4
✓ Branch 1 taken 633 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 633 times.
✗ Branch 5 not taken.
1266 intRefToEnum[ node_ref ].insert( GeometricMeshRegion::Nod );
147 }
148 }
149 }
150
151 /***********************************************************************************/
152 /***********************************************************************************/
153
154 // Explicit instantation
155 template void Medit::ReadVertices<float, true >(GeometricMeshRegion& rMesh, const double spaceUnit, int64_t& InpMsh, RefToElements_type* RefToElementsMaps);
156 template void Medit::ReadVertices<double, true >(GeometricMeshRegion& rMesh, const double spaceUnit, int64_t& InpMsh, RefToElements_type* RefToElementsMaps);
157 template void Medit::ReadVertices<float, false>(GeometricMeshRegion& rMesh, const double spaceUnit, int64_t& InpMsh, RefToElements_type* RefToElementsMaps);
158 template void Medit::ReadVertices<double, false>(GeometricMeshRegion& rMesh, const double spaceUnit, int64_t& InpMsh, RefToElements_type* RefToElementsMaps);
159
160 /***********************************************************************************/
161 /***********************************************************************************/
162
163 // It Reads INRIA MESH file using Loic Marechal's libmesh5
164 //! \todo manage verbose and errors
165 504 void Medit::readerMedit(GeometricMeshRegion& mesh, double spaceUnit, const std::size_t verbose)
166 {
167 504 std::string fileNameMedit, fileNameRoot, fileName;
168
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 fileNameMedit = m_inputMesh;
169
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 fileNameRoot = m_meshDir;
170
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 fileName = fileNameRoot + fileNameMedit;
171
172 504 int64_t InpMsh = -1;
173 504 int the_ref = 0;
174
175
1/8
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
504 if (verbose>0) std::cout << "Reading from file "<< fileName << std::endl;
176
177 // one needs to convert the std::string into char* (not const char*)
178
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 char *filenameChar = c_string( fileName );
179
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 504 times.
504 if( !( InpMsh = GmfOpenMesh(filenameChar, GmfRead, &m_meshVersion, &mesh.numCoor()) ) ) {
180 std::ostringstream msg;
181 msg << "Error in reading mesh: File " << fileName << " not found or locked.";
182
183 // Display something only if invalid architecture
184 if( m_meshVersion == 3)
185 warnInvalidArchitecture<sizeof(void*)>(msg);
186
187 msg << std::endl;
188 delete [] filenameChar;
189 FEL_ERROR(msg.str());
190 }
191
192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if (verbose>1) {
193 std::cout << "LIBMESH5: Reading mesh file" << std::endl;
194 std::cout << "InputMesh : idx = " << InpMsh << ", version = " << m_meshVersion <<", numCoor = " << mesh.numCoor() << "." << std::endl;
195 }
196
197
4/6
✓ Branch 1 taken 395 times.
✓ Branch 2 taken 109 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 395 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 504 times.
504 if (mesh.numCoor() != 2 && mesh.numCoor() != 3) {
198 std::ostringstream msg;
199 msg << "Error in reading mesh: File " << fileName << ". "
200 << "Expecting mesh with 2 or 3 coordinates (it is " << mesh.numCoor() << ")."
201 << std::endl;
202 delete [] filenameChar;
203 FEL_ERROR(msg.str());
204 }
205
206 //------------------------
207 // read the sizes for memory allocation
208
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 const felInt number_of_nodes = GmfStatKwd(InpMsh, GmfVertices);
209 if ( GmfVertices > 10000000 ) {
210 FEL_ERROR(" implicite conversion, GmfVertice is stocked with int type in felisce, whereas libmesh use int64_t type " );
211 }
212
213 // Prepare mesh
214
1/2
✓ Branch 3 taken 504 times.
✗ Branch 4 not taken.
504 mesh.listPoints().resize( number_of_nodes, Point( 0. ) );
215
2/2
✓ Branch 4 taken 6605 times.
✓ Branch 5 taken 504 times.
7109 for ( auto it_eltype = m_eltFelNameToMeditPair.begin(); it_eltype != m_eltFelNameToMeditPair.end(); ++it_eltype) {
216
217 6605 ElementType eltType = it_eltype->second.first;
218 6605 GmfKwdCod keyWord = it_eltype->second.second;
219
1/2
✓ Branch 1 taken 6605 times.
✗ Branch 2 not taken.
6605 mesh.numElements(eltType) = GmfStatKwd(InpMsh, keyWord);
220
221 // Allocate memory
222
2/2
✓ Branch 1 taken 1066 times.
✓ Branch 2 taken 5539 times.
6605 if ( mesh.numElements(eltType) != 0 ) {
223
1/2
✓ Branch 1 taken 1066 times.
✗ Branch 2 not taken.
1066 mesh.allocateElements(eltType);
224 }
225 }
226
227
2/2
✓ Branch 1 taken 12600 times.
✓ Branch 2 taken 504 times.
26208 RefToElements_type RefToElementsMaps[ GeometricMeshRegion::m_numTypesOfElement ];
228
229 //------------------------
230 // Read the vertices
231
3/4
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 53 times.
✓ Branch 4 taken 451 times.
504 if (FelisceParam::instance().readNodesReferences) {
232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 53 times.
53 if ( m_meshVersion == 1 ) {
233 ReadVertices<float, true>(mesh, spaceUnit, InpMsh, RefToElementsMaps);
234 } else {
235
1/2
✓ Branch 1 taken 53 times.
✗ Branch 2 not taken.
53 ReadVertices<double, true>(mesh, spaceUnit, InpMsh, RefToElementsMaps);
236 }
237 } else {
238
2/2
✓ Branch 0 taken 146 times.
✓ Branch 1 taken 305 times.
451 if ( m_meshVersion == 1 ) {
239
1/2
✓ Branch 1 taken 146 times.
✗ Branch 2 not taken.
146 ReadVertices<float, false>(mesh, spaceUnit, InpMsh, RefToElementsMaps);
240 } else {
241
1/2
✓ Branch 1 taken 305 times.
✗ Branch 2 not taken.
305 ReadVertices<double, false>(mesh, spaceUnit, InpMsh, RefToElementsMaps);
242 }
243 }
244
245 //------------------------
246 // read the elements:
247 // do it separately for each type as the nb of arguments changes.
248 // we put the reference right after the element. thus a triangle needs 3+1 int.
249 ElementType eltType;
250 GmfKwdCod keyWord;
251 felInt numElems;
252 int nVpEl;
253 504 std::vector<felInt> elem;
254 504 const bool decr_vert_id = true;
255
256 504 GeometricMeshRegion::IntRefToElementType_type& intRefToEnum = mesh.intRefToEnum();
257
258 //------------
259 // Hexahedra27:
260
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Hexahedra27"].first;
261
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Hexahedra27"].second;
262 504 numElems = mesh.numElements(eltType);
263 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
264
265
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if ( numElems != 0 ) {
266 // read the Hexahedra27 (27 points)
267 GmfGotoKwd(InpMsh, keyWord);
268 elem.resize(nVpEl, 0);
269
270 for(felInt iel = 0; iel < numElems; iel++) {
271 GmfGetLin(InpMsh, keyWord,
272 &elem[0], &elem[1], &elem[2], &elem[3],
273 &elem[4], &elem[5], &elem[6], &elem[7],
274 &elem[8], &elem[9], &elem[10], &elem[11],
275 &elem[12], &elem[13], &elem[14], &elem[15],
276 &elem[16], &elem[17], &elem[18], &elem[19],
277 &elem[20], &elem[21], &elem[22], &elem[23],
278 &elem[24], &elem[25], &elem[26],
279 &the_ref);
280 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
281 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
282 intRefToEnum[ the_ref ].insert( eltType );
283 }
284 }
285
286 //------------
287 // Hexahedra8:
288
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Hexahedra8"].first;
289
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Hexahedra8"].second;
290 504 numElems = mesh.numElements(eltType);
291 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
292
293
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 503 times.
504 if ( numElems != 0 ) {
294 // read the Hexahedra8 (8 points)
295
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 GmfGotoKwd(InpMsh, keyWord);
296
1/2
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
1 elem.resize(nVpEl, 0);
297
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 1 times.
9 for(felInt iel = 0; iel < numElems; iel++) {
298
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 GmfGetLin(InpMsh, keyWord,
299 8 &elem[0], &elem[1], &elem[2], &elem[3],
300 8 &elem[4], &elem[5], &elem[6], &elem[7],
301 &the_ref);
302
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
303
2/4
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
304
2/4
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 8 times.
✗ Branch 5 not taken.
8 intRefToEnum[ the_ref ].insert( eltType );
305 }
306 }
307
308 //------------
309 // Prisms9:
310
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Prisms9"].first;
311
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Prisms9"].second;
312 504 numElems = mesh.numElements(eltType);
313 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
314
315
2/2
✓ Branch 0 taken 68 times.
✓ Branch 1 taken 436 times.
504 if ( numElems != 0 ) {
316 // read the Prisms9 (9 points)
317
1/2
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
68 GmfGotoKwd(InpMsh, keyWord);
318
1/2
✓ Branch 1 taken 68 times.
✗ Branch 2 not taken.
68 elem.resize(nVpEl, 0);
319
2/2
✓ Branch 0 taken 21146 times.
✓ Branch 1 taken 68 times.
21214 for(felInt iel = 0; iel < numElems; iel++) {
320
1/2
✓ Branch 1 taken 21146 times.
✗ Branch 2 not taken.
21146 GmfGetLin(InpMsh, keyWord,
321 21146 &elem[0], &elem[1], &elem[2], &elem[3],
322 21146 &elem[4], &elem[5], &elem[6], &elem[7],
323 21146 &elem[8],
324 &the_ref);
325
1/2
✓ Branch 1 taken 21146 times.
✗ Branch 2 not taken.
21146 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
326
2/4
✓ Branch 1 taken 21146 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21146 times.
✗ Branch 5 not taken.
21146 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
327
2/4
✓ Branch 1 taken 21146 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 21146 times.
✗ Branch 5 not taken.
21146 intRefToEnum[ the_ref ].insert( eltType );
328 }
329 }
330
331 //------------
332 // Prisms6:
333
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Prisms6"].first;
334
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Prisms6"].second;
335 504 numElems = mesh.numElements(eltType);
336 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
337
338
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 473 times.
504 if ( numElems != 0 ) {
339 // read the Prisms6 (6 points)
340
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 GmfGotoKwd(InpMsh, keyWord);
341
1/2
✓ Branch 1 taken 31 times.
✗ Branch 2 not taken.
31 elem.resize(nVpEl, 0);
342
2/2
✓ Branch 0 taken 4483 times.
✓ Branch 1 taken 31 times.
4514 for(felInt iel = 0; iel < numElems; iel++) {
343
1/2
✓ Branch 1 taken 4483 times.
✗ Branch 2 not taken.
4483 GmfGetLin(InpMsh, keyWord,
344 4483 &elem[0], &elem[1], &elem[2], &elem[3],
345 4483 &elem[4], &elem[5],
346 &the_ref);
347
1/2
✓ Branch 1 taken 4483 times.
✗ Branch 2 not taken.
4483 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
348
2/4
✓ Branch 1 taken 4483 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4483 times.
✗ Branch 5 not taken.
4483 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
349
2/4
✓ Branch 1 taken 4483 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 4483 times.
✗ Branch 5 not taken.
4483 intRefToEnum[ the_ref ].insert( eltType );
350 }
351 }
352
353 //------------
354 // Tetrahedra10:
355
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Tetrahedra10"].first;
356
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Tetrahedra10"].second;
357 504 numElems = mesh.numElements(eltType);
358 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
359
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if ( numElems != 0 ) {
360 // read the Tetrahedra10 (10 points)
361 GmfGotoKwd(InpMsh, keyWord);
362 elem.resize(nVpEl, 0);
363 for(felInt iel = 0; iel < numElems; iel++) {
364 GmfGetLin(InpMsh, keyWord,
365 &elem[0], &elem[1], &elem[2], &elem[3],
366 &elem[4], &elem[5], &elem[6], &elem[7],
367 &elem[8], &elem[9],
368 &the_ref);
369 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
370 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
371 intRefToEnum[ the_ref ].insert( eltType );
372 }
373 }
374
375 //------------
376 // Tetrahedra4:
377
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Tetrahedra4"].first;
378
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Tetrahedra4"].second;
379 504 numElems = mesh.numElements(eltType);
380 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
381
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 422 times.
504 if ( numElems != 0 ) {
382 // read the Tetrahedra4 (4 points)
383
1/2
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
82 GmfGotoKwd(InpMsh, keyWord);
384
1/2
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
82 elem.resize(nVpEl, 0);
385
2/2
✓ Branch 0 taken 1529099 times.
✓ Branch 1 taken 82 times.
1529181 for(felInt iel = 0; iel < numElems; iel++) {
386
1/2
✓ Branch 1 taken 1529099 times.
✗ Branch 2 not taken.
1529099 GmfGetLin(InpMsh, keyWord,
387 1529099 &elem[0], &elem[1], &elem[2], &elem[3],
388 &the_ref);
389
1/2
✓ Branch 1 taken 1529099 times.
✗ Branch 2 not taken.
1529099 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
390
2/4
✓ Branch 1 taken 1529099 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1529099 times.
✗ Branch 5 not taken.
1529099 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
391
2/4
✓ Branch 1 taken 1529099 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1529099 times.
✗ Branch 5 not taken.
1529099 intRefToEnum[ the_ref ].insert( eltType );
392 }
393 }
394
395
396 //------------
397 // Quadrangles9:
398
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Quadrangles9"].first;
399
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Quadrangles9"].second;
400 504 numElems = mesh.numElements(eltType);
401 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
402
403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if ( numElems != 0 ) {
404 // read the Quadrangles9 (9 points)
405 GmfGotoKwd(InpMsh, keyWord);
406 elem.resize(nVpEl, 0);
407 for(felInt iel = 0; iel < numElems; iel++) {
408 GmfGetLin(InpMsh, keyWord,
409 &elem[0], &elem[1], &elem[2], &elem[3],
410 &elem[4], &elem[5], &elem[6], &elem[7],
411 &elem[8],
412 &the_ref);
413 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
414 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
415 intRefToEnum[ the_ref ].insert( eltType );
416 }
417 }
418
419 //------------
420 // Quadrangles6:
421
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Quadrangles6"].first;
422
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Quadrangles6"].second;
423 504 numElems = mesh.numElements(eltType);
424 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
425
426
2/2
✓ Branch 0 taken 50 times.
✓ Branch 1 taken 454 times.
504 if ( numElems != 0 ) {
427 // read the Quadrangles6 (6 points)
428
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
50 GmfGotoKwd(InpMsh, keyWord);
429
1/2
✓ Branch 1 taken 50 times.
✗ Branch 2 not taken.
50 elem.resize(nVpEl, 0);
430
2/2
✓ Branch 0 taken 1337 times.
✓ Branch 1 taken 50 times.
1387 for(felInt iel = 0; iel < numElems; iel++) {
431
1/2
✓ Branch 1 taken 1337 times.
✗ Branch 2 not taken.
1337 GmfGetLin(InpMsh, keyWord,
432 1337 &elem[0], &elem[1], &elem[2], &elem[3],
433 1337 &elem[4], &elem[5],
434 &the_ref);
435
1/2
✓ Branch 1 taken 1337 times.
✗ Branch 2 not taken.
1337 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
436
2/4
✓ Branch 1 taken 1337 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1337 times.
✗ Branch 5 not taken.
1337 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
437
2/4
✓ Branch 1 taken 1337 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1337 times.
✗ Branch 5 not taken.
1337 intRefToEnum[ the_ref ].insert( eltType );
438 }
439 }
440
441 //------------
442 // Quadrangles4:
443
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Quadrangles4"].first;
444
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Quadrangles4"].second;
445 504 numElems = mesh.numElements(eltType);
446 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
447
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 458 times.
504 if ( numElems != 0 ) {
448 // read the Quadrangles4 (4 points)
449
1/2
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
46 GmfGotoKwd(InpMsh, keyWord);
450
1/2
✓ Branch 1 taken 46 times.
✗ Branch 2 not taken.
46 elem.resize(nVpEl, 0);
451
2/2
✓ Branch 0 taken 1487 times.
✓ Branch 1 taken 46 times.
1533 for(felInt iel = 0; iel < numElems; iel++) {
452
1/2
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
1487 GmfGetLin(InpMsh, keyWord,
453 1487 &elem[0], &elem[1], &elem[2], &elem[3],
454 &the_ref);
455
1/2
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
1487 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
456
2/4
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1487 times.
✗ Branch 5 not taken.
1487 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
457
2/4
✓ Branch 1 taken 1487 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 1487 times.
✗ Branch 5 not taken.
1487 intRefToEnum[ the_ref ].insert( eltType );
458 }
459 }
460
461 //------------
462 // Triangles6:
463
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Triangles6"].first;
464
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Triangles6"].second;
465 504 numElems = mesh.numElements(eltType);
466 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if ( numElems != 0 ) {
468 // read the Triangles6 (6 points)
469 GmfGotoKwd(InpMsh, keyWord);
470 elem.resize(nVpEl, 0);
471 for(felInt iel = 0; iel < numElems; iel++) {
472 GmfGetLin(InpMsh, keyWord,
473 &elem[0], &elem[1], &elem[2], &elem[3],
474 &elem[4], &elem[5],
475 &the_ref);
476 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
477 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
478 intRefToEnum[ the_ref ].insert( eltType );
479 }
480 }
481
482 //------------
483 // Triangles3:
484
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Triangles3"].first;
485
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Triangles3"].second;
486 504 numElems = mesh.numElements(eltType);
487 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
488
2/2
✓ Branch 0 taken 382 times.
✓ Branch 1 taken 122 times.
504 if ( numElems != 0 ) {
489 // read the Triangles3 (3 points)
490
1/2
✓ Branch 1 taken 382 times.
✗ Branch 2 not taken.
382 GmfGotoKwd(InpMsh, keyWord);
491
1/2
✓ Branch 1 taken 382 times.
✗ Branch 2 not taken.
382 elem.resize(nVpEl, 0);
492
2/2
✓ Branch 0 taken 744914 times.
✓ Branch 1 taken 382 times.
745296 for(felInt iel = 0; iel < numElems; iel++) {
493
1/2
✓ Branch 1 taken 744914 times.
✗ Branch 2 not taken.
744914 GmfGetLin(InpMsh, keyWord,
494 744914 &elem[0], &elem[1], &elem[2],
495 &the_ref);
496
1/2
✓ Branch 1 taken 744914 times.
✗ Branch 2 not taken.
744914 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
497
2/4
✓ Branch 1 taken 744914 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 744914 times.
✗ Branch 5 not taken.
744914 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
498
2/4
✓ Branch 1 taken 744914 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 744914 times.
✗ Branch 5 not taken.
744914 intRefToEnum[ the_ref ].insert( eltType );
499 }
500 }
501
502 //------------
503 // Segments3:
504
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Segments3"].first;
505
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Segments3"].second;
506 504 numElems = mesh.numElements(eltType);
507 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
508
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 504 times.
504 if ( numElems != 0 ) {
509 // read the Segments3 (3 points)
510 GmfGotoKwd(InpMsh, keyWord);
511 elem.resize(nVpEl, 0);
512 for(felInt iel = 0; iel < numElems; iel++) {
513 GmfGetLin(InpMsh, keyWord,
514 &elem[0], &elem[1], &elem[2],
515 &the_ref);
516 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
517 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
518 intRefToEnum[ the_ref ].insert( eltType );
519 }
520 }
521 //------------
522 // Segments2:
523
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 eltType = m_eltFelNameToMeditPair["Segments2"].first;
524
2/4
✓ Branch 2 taken 504 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 504 times.
✗ Branch 6 not taken.
504 keyWord = m_eltFelNameToMeditPair["Segments2"].second;
525 504 numElems = mesh.numElements(eltType);
526 504 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
527
2/2
✓ Branch 0 taken 353 times.
✓ Branch 1 taken 151 times.
504 if ( numElems != 0 ) {
528 // read the Segments2 (2 points)
529
1/2
✓ Branch 1 taken 353 times.
✗ Branch 2 not taken.
353 GmfGotoKwd(InpMsh, keyWord);
530
1/2
✓ Branch 1 taken 353 times.
✗ Branch 2 not taken.
353 elem.resize(nVpEl, 0);
531
2/2
✓ Branch 0 taken 29265 times.
✓ Branch 1 taken 353 times.
29618 for(felInt iel = 0; iel < numElems; iel++) {
532
1/2
✓ Branch 1 taken 29265 times.
✗ Branch 2 not taken.
29265 GmfGetLin(InpMsh, keyWord,
533 29265 &elem[0], &elem[1],
534 &the_ref);
535
1/2
✓ Branch 1 taken 29265 times.
✗ Branch 2 not taken.
29265 mesh.setOneElement(eltType, iel, elem, decr_vert_id);
536
2/4
✓ Branch 1 taken 29265 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 29265 times.
✗ Branch 5 not taken.
29265 RefToElementsMaps[ eltType ][ the_ref ].push_back( iel );
537
2/4
✓ Branch 1 taken 29265 times.
✗ Branch 2 not taken.
✓ Branch 4 taken 29265 times.
✗ Branch 5 not taken.
29265 intRefToEnum[ the_ref ].insert( eltType );
538 }
539 }
540
541 //-------------------------------
542 // Close the mesh
543
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 GmfCloseMesh(InpMsh);
544
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 delete [] filenameChar;
545
2/2
✓ Branch 0 taken 12600 times.
✓ Branch 1 taken 504 times.
13104 for (int ityp=0; ityp<GeometricMeshRegion::m_numTypesOfElement; ityp++ ) {
546 12600 eltType = static_cast<ElementType>(ityp);
547
1/2
✓ Branch 1 taken 12600 times.
✗ Branch 2 not taken.
12600 mesh.reorderListElePerRef(RefToElementsMaps[eltType], eltType);
548 }
549 504 mesh.flagFormatMesh() = GeometricMeshRegion::FormatMedit;
550
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 mesh.setDomainDim();
551
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 mesh.setBagElementTypeDomain();
552
1/2
✓ Branch 1 taken 504 times.
✗ Branch 2 not taken.
504 mesh.setBagElementTypeDomainBoundary();
553
2/4
✓ Branch 1 taken 12600 times.
✓ Branch 2 taken 504 times.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
14112 }
554
555 /***********************************************************************************/
556 /***********************************************************************************/
557
558 namespace { // anonymous
559
560 enum { arch32 = 4, arch64 = 8 };
561
562 template<int SizePointerT>
563 29 void checkArchitectureVersion(int mesh_version) {
564 switch(SizePointerT) {
565 case arch32:
566 if (mesh_version == 3)
567 felisce_error("Error: You are trying to use MeshVersionFormatted = 3 with a 32 bit version of Arch!", __FILE__,__LINE__);
568 break;
569 case arch64:
570 // Do nothing: all Medit versions are supported by 64 bits architecture.
571 29 break;
572 default:
573 felisce_error("Error: architecture should be 32 or 64 bits!",__FILE__,__LINE__);
574 }
575 29 }
576
577 //! Check whether the Medit version is supported by present architecture.
578 29 void checkMeditVersionSupportedByArchitecture(int mesh_version) {
579 29 checkArchitectureVersion<sizeof(void*)>(mesh_version);
580 29 }
581
582 } // namespace anonymous
583
584 /***********************************************************************************/
585 /***********************************************************************************/
586
587 // It writes INRIA MESH file using Loic Marechal's libmesh5
588 //! \todo manage verbose and errors
589 29 void Medit::writerMedit(GeometricMeshRegion& mesh)
590 {
591 29 std::string fileNameMesh, fileNameRoot, fileName;
592
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 fileNameMesh = m_outputMesh;
593
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 fileNameRoot = m_resultDir;
594
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 fileName = fileNameRoot + fileNameMesh;
595 29 int64_t OutMsh = -1;
596 29 short verbose = 0;
597 29 m_meshVersion = 2; //! \todo switch to meshVersion when read Geo File
598 //< Why is mesh version hardcoded here? The tests just below are threfore all irrelevant; and it would be
599 // nice anyway to let the user choose its Medit version.
600
601
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 checkMeditVersionSupportedByArchitecture(m_meshVersion);
602
603
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if( m_meshVersion == 1 ) {
604 felisce_error("Error: we do not write meshes in MeshVersionFormatted 1 (no floats)!",__FILE__,__LINE__);
605 }
606 // one needs to convert the std::string into char* (not const char*)
607
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 char *fileNameMeshChar = c_string( fileName );
608 FILE* pFile;
609
1/2
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 pFile = fopen (fileName.c_str(),"w");
610
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (pFile==nullptr) {
611 std::string command = "mkdir -p " + m_resultDir;
612 int ierr = system(command.c_str());
613 if (ierr>0) {
614 FEL_ERROR("Impossible to write "+fileName+" medit mesh");
615 }
616 fclose(pFile);
617 }
618
619 29 const auto dimension = mesh.numCoor();
620
2/4
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 29 times.
29 if( !( OutMsh = GmfOpenMesh(fileNameMeshChar, GmfWrite, m_meshVersion, dimension) ) ) {
621 std::string error="Error: mesh file "+fileNameMesh+" cannot be opened. Several reasons are possible... (See libmesh5!)";
622 felisce_error(error.c_str(),__FILE__,__LINE__);
623 }
624
1/2
✓ Branch 0 taken 29 times.
✗ Branch 1 not taken.
29 delete [] fileNameMeshChar;
625
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (verbose>1) {
626 std::cout << "LIBMESH5: Reading mesh file" << std::endl;
627 std::cout << "OutputMesh : idx = " << OutMsh << ", version = " << m_meshVersion
628 <<", numCoor = " << dimension << "." << std::endl;
629 }
630
631 // Dimension check
632
3/4
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 22 times.
29 if (dimension != 2 && dimension != 3) {
633 std::string error = "Error in writing mesh: File " + fileNameMesh + "Expecting mesh with 2 or 3 coordinates (it is "+std::to_string(dimension)+").";
634 felisce_error(error.c_str(),__FILE__,__LINE__);
635 }
636
637 //------------------------
638 ElementType eltType;
639 GmfKwdCod keyWord;
640 29 std::vector<felInt> elem;
641 29 felInt numElems = 0;
642 29 int nVpEl = 0;
643 29 felInt startindex = 0, numElemsPerRef = 0;
644 29 int the_ref = 0;
645 29 bool incr_vert_id = true;
646 //------------------------
647
648 //------------------------
649 // Write the vertices
650 const std::function<void(int64_t&, Point&, const int)> write_3d_vertex =
651 27552 [](int64_t& OutMsh, Point& point, const int node_ref) {GmfSetLin(OutMsh, GmfVertices, point.x(), point.y(), point.z(), node_ref);};
652 const std::function<void(int64_t&, Point&, const int)> write_2d_vertex =
653 118 [](int64_t& OutMsh, Point& point, const int node_ref) {GmfSetLin(OutMsh, GmfVertices, point.x(), point.y(), node_ref);};
654
655
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 7 times.
29 const auto* p_write_vertex = dimension == 3 ? &write_3d_vertex : &write_2d_vertex;
656
1/2
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
29 GmfSetKwd(OutMsh, GmfVertices, mesh.numPoints() );
657
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 elem.resize(1, 0);
658 29 eltType = GeometricMeshRegion::Nod;
659 29 std::size_t counter = 0;
660
1/2
✗ Branch 5 not taken.
✓ Branch 6 taken 29 times.
29 for ( auto& r_ref : mesh.intRefToBegEndMaps[eltType]) counter += r_ref.first + 1;
661
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if (counter > 0) {
662 for ( auto it_ref = mesh.intRefToBegEndMaps[eltType].begin();it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
663 the_ref = it_ref->first;
664 startindex = it_ref->second.first;
665 numElemsPerRef = it_ref->second.second;
666 for(felInt iv = 0; iv < numElemsPerRef; iv++) {
667 mesh.getOneElement(eltType, iv, elem, startindex, incr_vert_id);
668 (*p_write_vertex)(OutMsh, mesh.listPoint(elem[0] - 1), the_ref);
669 }
670 }
671 } else {
672
2/2
✓ Branch 1 taken 27612 times.
✓ Branch 2 taken 29 times.
27641 for(felInt iv = 0; iv < mesh.numPoints(); iv++) {
673
1/2
✓ Branch 2 taken 27612 times.
✗ Branch 3 not taken.
27612 (*p_write_vertex)(OutMsh, mesh.listPoint(iv), the_ref);
674 }
675 }
676
677 //------------------------
678 // write the elements:
679 // do it separately for each type as the nb of arguments changes.
680 // we put the reference right after the element. thus a triangle needs 3+1 int.
681
682 //------------
683 // Hexahedra27:
684
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Hexahedra27"].first;
685
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Hexahedra27"].second;
686 29 numElems = mesh.numElements(eltType);
687 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
688
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if ( numElems != 0 ) {
689 // write the Hexahedra27 (27 points)
690 GmfSetKwd(OutMsh, keyWord, numElems );
691 elem.resize(nVpEl, 0);
692 for ( auto it_ref = mesh.intRefToBegEndMaps[eltType].begin();it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
693 the_ref = it_ref->first;
694 startindex = it_ref->second.first;
695 numElemsPerRef = it_ref->second.second;
696 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
697 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
698 GmfSetLin(OutMsh, keyWord,
699 elem[0], elem[1], elem[2], elem[3],
700 elem[4], elem[5], elem[6], elem[7],
701 elem[8], elem[9], elem[10], elem[11],
702 elem[12], elem[13], elem[14], elem[15],
703 elem[16], elem[17], elem[18], elem[19],
704 elem[20], elem[21], elem[22], elem[23],
705 elem[24], elem[25], elem[26],
706 the_ref);
707 }
708 }
709 }
710
711 //------------
712 // Hexahedra8:
713
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Hexahedra8"].first;
714
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Hexahedra8"].second;
715 29 numElems = mesh.numElements(eltType);
716 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
717
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 26 times.
29 if ( numElems != 0 ) {
718 // write the Hexahedra8 (8 points)
719
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 GmfSetKwd(OutMsh, keyWord, numElems );
720
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 elem.resize(nVpEl, 0);
721
2/2
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
6 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
722
723 3 the_ref = it_ref->first;
724 3 startindex = it_ref->second.first;
725 3 numElemsPerRef = it_ref->second.second;
726
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 3 times.
13 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
727
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
728
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 GmfSetLin(OutMsh, keyWord,
729 10 elem[0], elem[1], elem[2], elem[3],
730 10 elem[4], elem[5], elem[6], elem[7],
731 the_ref);
732 }
733 }
734 }
735
736 //------------
737 // Prisms9:
738
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Prisms9"].first;
739
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Prisms9"].second;
740 29 numElems = mesh.numElements(eltType);
741 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
742
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 19 times.
29 if ( numElems != 0 ) {
743 // write the Prisms9 (9 points)
744
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 GmfSetKwd(OutMsh, keyWord, numElems );
745
1/2
✓ Branch 1 taken 10 times.
✗ Branch 2 not taken.
10 elem.resize(nVpEl, 0);
746
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 10 times.
22 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
747 12 the_ref = it_ref->first;
748 12 startindex = it_ref->second.first;
749 12 numElemsPerRef = it_ref->second.second;
750
2/2
✓ Branch 0 taken 17413 times.
✓ Branch 1 taken 12 times.
17425 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
751
1/2
✓ Branch 1 taken 17413 times.
✗ Branch 2 not taken.
17413 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
752
1/2
✓ Branch 1 taken 17413 times.
✗ Branch 2 not taken.
17413 GmfSetLin(OutMsh, keyWord,
753 17413 elem[0], elem[1], elem[2], elem[3],
754 17413 elem[4], elem[5], elem[6], elem[7],
755 17413 elem[8],
756 the_ref);
757 }
758 }
759 }
760
761 //------------
762 // Prisms6:
763
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Prisms6"].first;
764
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Prisms6"].second;
765 29 numElems = mesh.numElements(eltType);
766 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
767
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 26 times.
29 if ( numElems != 0 ) {
768 // write the Prisms6 (6 points)
769
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 GmfSetKwd(OutMsh, keyWord, numElems );
770
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 elem.resize(nVpEl, 0);
771
2/2
✓ Branch 4 taken 3 times.
✓ Branch 5 taken 3 times.
6 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
772 3 the_ref = it_ref->first;
773 3 startindex = it_ref->second.first;
774 3 numElemsPerRef = it_ref->second.second;
775
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 3 times.
6 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
776
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
777
1/2
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
3 GmfSetLin(OutMsh, keyWord,
778 3 elem[0], elem[1], elem[2], elem[3],
779 3 elem[4], elem[5],
780 the_ref);
781 }
782 }
783 }
784
785 //------------
786 // Tetrahedra10:
787
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Tetrahedra10"].first;
788
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Tetrahedra10"].second;
789 29 numElems = mesh.numElements(eltType);
790 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
791
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if ( numElems != 0 ) {
792 // write the Tetrahedra10 (10 points)
793 GmfSetKwd(OutMsh, keyWord, numElems );
794 elem.resize(nVpEl, 0);
795 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
796 the_ref = it_ref->first;
797 startindex = it_ref->second.first;
798 numElemsPerRef = it_ref->second.second;
799 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
800 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
801 GmfSetLin(OutMsh, keyWord,
802 elem[0], elem[1], elem[2], elem[3],
803 elem[4], elem[5], elem[6], elem[7],
804 elem[8], elem[9],
805 the_ref);
806 }
807 }
808 }
809
810 //------------
811 // Tetrahedra4:
812
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Tetrahedra4"].first;
813
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Tetrahedra4"].second;
814 29 numElems = mesh.numElements(eltType);
815 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
816
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 25 times.
29 if ( numElems != 0 ) {
817 // write the Tetrahedra4 (4 points)
818
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 GmfSetKwd(OutMsh, keyWord, numElems );
819
1/2
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
4 elem.resize(nVpEl, 0);
820
2/2
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 4 times.
8 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
821 4 the_ref = it_ref->first;
822 4 startindex = it_ref->second.first;
823 4 numElemsPerRef = it_ref->second.second;
824
2/2
✓ Branch 0 taken 344 times.
✓ Branch 1 taken 4 times.
348 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
825
1/2
✓ Branch 1 taken 344 times.
✗ Branch 2 not taken.
344 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
826
1/2
✓ Branch 1 taken 344 times.
✗ Branch 2 not taken.
344 GmfSetLin(OutMsh, keyWord,
827 344 elem[0], elem[1], elem[2], elem[3],
828 the_ref);
829 }
830 }
831 }
832
833 //------------
834 // Quadrangles9:
835
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Quadrangles9"].first;
836
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Quadrangles9"].second;
837 29 numElems = mesh.numElements(eltType);
838 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
839
840
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if ( numElems != 0 ) {
841 // write the Quadrangles9 (9 points)
842 GmfSetKwd(OutMsh, keyWord, numElems );
843 elem.resize(nVpEl, 0);
844 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
845 the_ref = it_ref->first;
846 startindex = it_ref->second.first;
847 numElemsPerRef = it_ref->second.second;
848 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
849 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
850 GmfSetLin(OutMsh, keyWord,
851 elem[0], elem[1], elem[2], elem[3],
852 elem[4], elem[5], elem[6], elem[7],
853 elem[8],
854 the_ref);
855 }
856 }
857 }
858
859 //------------
860 // Quadrangles6:
861
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Quadrangles6"].first;
862
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Quadrangles6"].second;
863 29 numElems = mesh.numElements(eltType);
864 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
865
866
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 21 times.
29 if ( numElems != 0 ) {
867 // write the Quadrangles6 (6 points)
868
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 GmfSetKwd(OutMsh, keyWord, numElems );
869
1/2
✓ Branch 1 taken 8 times.
✗ Branch 2 not taken.
8 elem.resize(nVpEl, 0);
870
2/2
✓ Branch 4 taken 25 times.
✓ Branch 5 taken 8 times.
33 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
871 25 the_ref = it_ref->first;
872 25 startindex = it_ref->second.first;
873 25 numElemsPerRef = it_ref->second.second;
874
2/2
✓ Branch 0 taken 668 times.
✓ Branch 1 taken 25 times.
693 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
875
1/2
✓ Branch 1 taken 668 times.
✗ Branch 2 not taken.
668 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
876
1/2
✓ Branch 1 taken 668 times.
✗ Branch 2 not taken.
668 GmfSetLin(OutMsh, keyWord,
877 668 elem[0], elem[1], elem[2], elem[3],
878 668 elem[4], elem[5],
879 the_ref);
880 }
881 }
882 }
883
884 //------------
885 // Quadrangles4:
886
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Quadrangles4"].first;
887
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Quadrangles4"].second;
888 29 numElems = mesh.numElements(eltType);
889 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
890
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 22 times.
29 if ( numElems != 0 ) {
891 // write the Quadrangles4 (4 points)
892
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 GmfSetKwd(OutMsh, keyWord, numElems );
893
1/2
✓ Branch 1 taken 7 times.
✗ Branch 2 not taken.
7 elem.resize(nVpEl, 0);
894
2/2
✓ Branch 4 taken 13 times.
✓ Branch 5 taken 7 times.
20 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
895 13 the_ref = it_ref->first;
896 13 startindex = it_ref->second.first;
897 13 numElemsPerRef = it_ref->second.second;
898
2/2
✓ Branch 0 taken 42 times.
✓ Branch 1 taken 13 times.
55 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
899
1/2
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
42 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
900
1/2
✓ Branch 1 taken 42 times.
✗ Branch 2 not taken.
42 GmfSetLin(OutMsh, keyWord,
901 42 elem[0], elem[1], elem[2], elem[3],
902 the_ref);
903 }
904 }
905 }
906
907 //------------
908 // Triangles6:
909
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Triangles6"].first;
910
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Triangles6"].second;
911 29 numElems = mesh.numElements(eltType);
912 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
913
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29 times.
29 if ( numElems != 0 ) {
914 // write the Triangles6 (6 points)
915 GmfSetKwd(OutMsh, keyWord, numElems );
916 elem.resize(nVpEl, 0);
917 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
918 the_ref = it_ref->first;
919 startindex = it_ref->second.first;
920 numElemsPerRef = it_ref->second.second;
921 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
922 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
923 GmfSetLin(OutMsh, keyWord,
924 elem[0], elem[1], elem[2], elem[3],
925 elem[4], elem[5],
926 the_ref);
927 }
928 }
929 }
930
931 //------------
932 // Triangles3:
933
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Triangles3"].first;
934
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Triangles3"].second;
935 29 numElems = mesh.numElements(eltType);
936 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
937
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 9 times.
29 if ( numElems != 0 ) {
938 // write the Triangles3 (3 points)
939
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 GmfSetKwd(OutMsh, keyWord, numElems );
940
1/2
✓ Branch 1 taken 20 times.
✗ Branch 2 not taken.
20 elem.resize(nVpEl, 0);
941
2/2
✓ Branch 4 taken 44 times.
✓ Branch 5 taken 20 times.
64 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
942 44 the_ref = it_ref->first;
943 44 startindex = it_ref->second.first;
944 44 numElemsPerRef = it_ref->second.second;
945
2/2
✓ Branch 0 taken 35426 times.
✓ Branch 1 taken 44 times.
35470 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
946
1/2
✓ Branch 1 taken 35426 times.
✗ Branch 2 not taken.
35426 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
947
1/2
✓ Branch 1 taken 35426 times.
✗ Branch 2 not taken.
35426 GmfSetLin(OutMsh, keyWord,
948 35426 elem[0], elem[1], elem[2],
949 the_ref);
950 }
951 }
952 }
953
954 //------------
955 // Segments2:
956
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 eltType = m_eltFelNameToMeditPair["Segments2"].first;
957
2/4
✓ Branch 2 taken 29 times.
✗ Branch 3 not taken.
✓ Branch 5 taken 29 times.
✗ Branch 6 not taken.
29 keyWord = m_eltFelNameToMeditPair["Segments2"].second;
958 29 numElems = mesh.numElements(eltType);
959 29 nVpEl = GeometricMeshRegion::m_numPointsPerElt[eltType];
960
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 24 times.
29 if ( numElems != 0 ) {
961 // write the Segments2 (2 points)
962
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 GmfSetKwd(OutMsh, keyWord, numElems );
963
1/2
✓ Branch 1 taken 5 times.
✗ Branch 2 not taken.
5 elem.resize(nVpEl, 0);
964
2/2
✓ Branch 4 taken 12 times.
✓ Branch 5 taken 5 times.
17 for(auto it_ref = mesh.intRefToBegEndMaps[eltType].begin(); it_ref != mesh.intRefToBegEndMaps[eltType].end(); ++it_ref ) {
965 12 the_ref = it_ref->first;
966 12 startindex = it_ref->second.first;
967 12 numElemsPerRef = it_ref->second.second;
968
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 12 times.
96 for(felInt iel = 0; iel < numElemsPerRef; iel++) {
969
1/2
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
84 mesh.getOneElement(eltType, iel, elem, startindex, incr_vert_id);
970
1/2
✓ Branch 1 taken 84 times.
✗ Branch 2 not taken.
84 GmfSetLin(OutMsh, keyWord,
971 84 elem[0], elem[1],
972 the_ref);
973 }
974 }
975 }
976
977 //-------------------------------
978 // Close the mesh
979
1/2
✓ Branch 1 taken 29 times.
✗ Branch 2 not taken.
29 GmfCloseMesh(OutMsh);
980
981 29 }
982
983 /***********************************************************************************/
984 /***********************************************************************************/
985
986 void Medit::writeSolution(double& time,int iteration, const int & typeVariable, const std::string nameVariable, const double* solution,
987 felInt size, int dimension) {
988
989 std::string fileName = m_resultDir + "/" + nameVariable + "." + std::to_string(iteration) + ".sol";
990
991 FILE* pFile;
992 pFile = fopen( fileName.c_str(),"w" );
993 fprintf(pFile,"MeshVersionFormatted \n 2 \n");
994 fprintf(pFile,"Dimension \n %d \n", dimension);
995 fprintf(pFile,"SolAtVertices \n %d \n", size);
996 switch (typeVariable) {
997 case 0:
998 fprintf(pFile,"1 1\n");
999 for ( int i = 0; i < size; i++)
1000 fprintf(pFile, "%le \n", solution[i]);
1001 break;
1002 case 1:
1003 fprintf(pFile,"1 2\n");
1004 for ( int i = 0; i < size; i++) {
1005 for (int j = 0; j < dimension; j++)
1006 fprintf(pFile, "%le ", solution[i*3+j]);
1007 fprintf(pFile, "\n");
1008 }
1009 break;
1010 default:
1011 break;
1012 }
1013 fprintf(pFile,"Iterations \n %d \n Time \n %lf \n", iteration, time);
1014 fprintf(pFile,"End");
1015 fclose(pFile);
1016 }
1017 }
1018