Dune Core Modules (2.11.0)

gmsh4reader.impl.hh
1#include <array>
2#include <filesystem>
3#include <sstream>
4#include <fstream>
5#include <iterator>
6#include <string>
7#include <set>
8
10#include <dune/gmsh4/utility/string.hh>
11
12#include <dune/grid/io/file/gmshreader.hh> // For reading gmsh2.2 files
13
14namespace Dune {
15
16template <class G, class C, class S>
17std::map<int, S> Gmsh4Reader<G,C,S>::elementType_ {
18 {1, 2u}, // 2-node line.
19 {2, 3u}, // 3-node triangle.
20 {3, 4u}, // 4-node quadrangle.
21 {4, 4u}, // 4-node tetrahedron.
22 {5, 8u}, // 8-node hexahedron.
23 {6, 6u}, // 6-node prism.
24 {7, 5u}, // 5-node pyramid.
25 {8, 3u}, // 3-node second order line.
26 {9, 6u}, // 6-node second order triangle.
27 {10, 9u}, // 9-node second order quadrangle.
28 {11, 10u}, // 10-node second order tetrahedron.
29 {12, 27u}, // 27-node second order hexahedron.
30 {13, 18u}, // 18-node second order prism.
31 {14, 14u}, // 14-node second order pyramid.
32 {15, 1u}, // 1-node point.
33 {16, 8u}, // 8-node second order quadrangle.
34 {17, 20u}, // 20-node second order hexahedron.
35 {18, 15u}, // 15-node second order prism.
36 {19, 13u}, // 13-node second order pyramid.
37 {20, 9u}, // 9-node third order incomplete triangle.
38 {21, 10u}, // 10-node third order triangle.
39 {22, 12u}, // 12-node fourth order incomplete triangle.
40 {23, 15u}, // 15-node fourth order triangle.
41 {24, 15u}, // 15-node fifth order incomplete triangle.
42 {25, 21u}, // 21-node fifth order complete triangle.
43 {26, 4u}, // 4-node third order line.
44 {27, 5u}, // 5-node fourth order line.
45 {28, 6u}, // 6-node fifth order line.
46 {29, 20u}, // 20-node third order tetrahedron.
47 {30, 35u}, // 35-node fourth order tetrahedron.
48 {31, 56u}, // 56-node fifth order tetrahedron.
49 {32, 22u}, // 22-node tetrahedron.
50 {33, 28u}, // 28-node tetrahedron.
51 //{34, ?}, // polygon.
52 //{35, ?}, // polygon.
53 {36, 16u}, // 16-node quadrangle.
54 {37, 25u}, // 25-node quadrangle.
55 {38, 36u}, // 36-node quadrangle.
56 {39, 12u}, // 12-node quadrangle.
57 {40, 16u}, // 16-node quadrangle (I).
58 {41, 20u}, // 20-node quadrangle.
59 {42, 28u}, // 28-node triangle.
60 {43, 36u}, // 36-node triangle.
61 {44, 45u}, // 45-node triangle.
62 {45, 55u}, // 55-node triangle.
63 {46, 66u}, // 66-node triangle.
64 {47, 49u}, // 49-node quadrangle.
65 {48, 64u}, // 64-node quadrangle.
66 {49, 81u}, // 81-node quadrangle.
67 {50, 100u}, // 100-node quadrangle.
68 {51, 121u}, // 121-node quadrangle.
69 {52, 18u}, // 18-node triangle.
70 {53, 21u}, // 21-node triangle (I).
71 {54, 24u}, // 24-node triangle.
72 {55, 27u}, // 27-node triangle.
73 {56, 30u}, // 30-node triangle.
74 {57, 24u}, // 24-node quadrangle.
75 {58, 28u}, // 28-node quadrangle.
76 {59, 32u}, // 32-node quadrangle.
77 {60, 36u}, // 36-node quadrangle (I).
78 {61, 40u}, // 40-node quadrangle.
79 {62, 7u}, // 7-node line.
80 {63, 8u}, // 8-node line.
81 {64, 9u}, // 9-node line.
82 {65, 10u}, // 10-node line.
83 {66, 11u}, // 11-node line.
84 //{67, ?}, // line.
85 //{68, ?}, // triangle.
86 //{69, ?}, // polygon.
87 //{70, ?}, // line.
88 {71, 84u}, // 84-node tetrahedron.
89 {72, 120u}, // 120-node tetrahedron.
90 {73, 165u}, // 165-node tetrahedron.
91 {74, 220u}, // 220-node tetrahedron.
92 {75, 286u}, // 286-node tetrahedron.
93 {79, 34u}, // 34-node incomplete tetrahedron.
94 {80, 40u}, // 40-node incomplete tetrahedron.
95 {81, 46u}, // 46-node incomplete tetrahedron.
96 {82, 52u}, // 52-node incomplete tetrahedron.
97 {83, 58u}, // 58-node incomplete tetrahedron.
98 {84, 1u}, // 1-node line.
99 {85, 1u}, // 1-node triangle.
100 {86, 1u}, // 1-node quadrangle.
101 {87, 1u}, // 1-node tetrahedron.
102 {88, 1u}, // 1-node hexahedron.
103 {89, 1u}, // 1-node prism.
104 {90, 40u}, // 40-node prism.
105 {91, 75u}, // 75-node prism.
106 {92, 64u}, // 64-node third order hexahedron.
107 {93, 125u}, // 125-node fourth order hexahedron.
108 {94, 216u}, // 216-node hexahedron.
109 {95, 343u}, // 343-node hexahedron.
110 {96, 512u}, // 512-node hexahedron.
111 {97, 729u}, // 729-node hexahedron.
112 {98, 1000u},// 1000-node hexahedron.
113 {99, 32u}, // 32-node incomplete hexahedron.
114 {100, 44u}, // 44-node incomplete hexahedron.
115 {101, 56u}, // 56-node incomplete hexahedron.
116 {102, 68u}, // 68-node incomplete hexahedron.
117 {103, 80u}, // 80-node incomplete hexahedron.
118 {104, 92u}, // 92-node incomplete hexahedron.
119 {105, 104u},// 104-node incomplete hexahedron.
120 {106, 126u},// 126-node prism.
121 {107, 196u},// 196-node prism.
122 {108, 288u},// 288-node prism.
123 {109, 405u},// 405-node prism.
124 {110, 550u},// 550-node prism.
125 {111, 24u}, // 24-node incomplete prism.
126 {112, 33u}, // 33-node incomplete prism.
127 {113, 42u}, // 42-node incomplete prism.
128 {114, 51u}, // 51-node incomplete prism.
129 {115, 60u}, // 60-node incomplete prism.
130 {116, 69u}, // 69-node incomplete prism.
131 {117, 78u}, // 78-node incomplete prism.
132 {118, 30u}, // 30-node pyramid.
133 {119, 55u}, // 55-node pyramid.
134 {120, 91u}, // 91-node pyramid.
135 {121, 140u},// 140-node pyramid.
136 {122, 204u},// 204-node pyramid.
137 {123, 285u},// 285-node pyramid.
138 {124, 385u},// 385-node pyramid.
139 {125, 21u}, // 21-node incomplete pyramid.
140 {126, 29u}, // 29-node incomplete pyramid.
141 {127, 37u}, // 37-node incomplete pyramid.
142 {128, 45u}, // 45-node incomplete pyramid.
143 {129, 53u}, // 53-node incomplete pyramid.
144 {130, 61u}, // 61-node incomplete pyramid.
145 {131, 69u}, // 69-node incomplete pyramid.
146 {132, 1u}, // 1-node pyramid.
147 //{133, ?}, // point.
148 //{134, ?}, // line.
149 //{135, ?}, // triangle.
150 //{136, ?}, // tetrahedron.
151 {137, 16u}, // 16-node tetrahedron.
152 //{138, ?}, // triangle (mini).
153 //{139, ?}, // tetrahedron (mini).
154 {140, 4u}, // 4-node triangle.
155};
156
157template <class G, class C, class S>
158std::map<std::string, typename Gmsh4Reader<G,C,S>::Sections> Gmsh4Reader<G,C,S>::sections_ {
159 {"MeshFormat", Sections::MESH_FORMAT},
160 {"PhysicalNames", Sections::PHYSICAL_NAMES},
161 {"Entities", Sections::ENTITIES},
162 {"PartitionedEntities", Sections::PARTITIONED_ENTITIES},
163 {"Nodes", Sections::NODES},
164 {"Elements", Sections::ELEMENTS},
165 {"Periodic", Sections::PERIODIC},
166 {"GhostElements", Sections::GHOST_ELEMENTS},
167 {"Parametrization", Sections::PARAMETRIZATION},
168 {"NodeData", Sections::NODE_DATA},
169 {"ElementData", Sections::ELEMENT_DATA},
170 {"ElementNodeData", Sections::ELEMENT_NODE_DATA},
171 {"InterpolationScheme", Sections::INTERPOLATION_SCHEME}
172};
173
174template <class G, class C, class S>
175struct Gmsh4Reader<G,C,S>::PhysicalNamesAttributes
176{
177 int dim;
178 int tag;
179 std::string name;
180};
181
182template <class G, class C, class S>
183struct Gmsh4Reader<G,C,S>::PointAttributes
184{
185 int tag;
186 std::array<double,3> xyz;
187 std::vector<int> physicalTags;
188};
189
190template <class G, class C, class S>
191struct Gmsh4Reader<G,C,S>::EntityAttributes
192{
193 int tag;
194 std::array<double,3> min_xyz;
195 std::array<double,3> max_xyz;
196 std::vector<int> physicalTags;
197 std::vector<int> boundingEntities;
198};
199
200template <class G, class C, class S>
201struct Gmsh4Reader<G,C,S>::GhostAttributes
202{
203 int tag;
204 int partition;
205};
206
207template <class G, class C, class S>
208struct Gmsh4Reader<G,C,S>::NodeAttributes
209{
210 struct Node
211 {
212 size_type tag;
213 std::array<double,3> xyz;
214 std::array<double,3> uvw;
215 };
216
217 int entityDim;
218 int entityTag;
219 int parametric;
220 std::vector<Node> nodes;
221};
222
223template <class G, class C, class S>
224struct Gmsh4Reader<G,C,S>::ElementAttributes
225{
226 struct Element
227 {
228 size_type tag;
229 std::vector<size_type> nodes;
230 };
231
232 int entityDim;
233 int entityTag;
234 int elementType;
235 std::vector<Element> elements;
236};
237
238template <class G, class C, class S>
239struct Gmsh4Reader<G,C,S>::PeriodicAttributes
240{
241 struct Association
242 {
243 size_type tag;
244 size_type tagMaster;
245 };
246
247 int entityDim;
248 int entityTag;
249 int entityTagMaster;
250 std::vector<double> affine;
251 std::vector<Association> correspondingNodes;
252};
253
254
255template <class G, class C, class S>
256template <class T>
257void Gmsh4Reader<G,C,S>::readValueBinary(std::ifstream& input, T &v)
258{
259 const std::size_t size = sizeof(T);
260 input.read(reinterpret_cast<char*>(&v), size);
261 if (swap)
262 {
263 char* vBinary = reinterpret_cast<char*>(&v);
264 for (std::size_t i=0; i<size/2; ++i)
265 std::swap(vBinary[i],vBinary[size-1-i]);
266 }
267}
268
269
270template <class G, class C, class S>
271void Gmsh4Reader<G,C,S>::read (std::string const& filename, bool fillCreator)
272{
273 const std::filesystem::path filePath(filename);
274
275 // check whether file exists!
276 if (!std::filesystem::exists(filePath))
277 DUNE_THROW(IOError, "File " << filename << " does not exist!");
278
279 std::ifstream input(filename, std::ios_base::in | std::ios_base::binary);
280 GMSH4_ASSERT(input.is_open());
281
282 const std::string ext = filePath.extension().string();
283 if (ext == ".msh") {
284
285 // Get first line
286 std::string line;
287 std::getline(input, line);
288 Gmsh4::ltrim(line);
289
290 // Read the mesh format section -- it must make up the first two lines
291 GMSH4_ASSERT_MSG((line=="$MeshFormat"), "First line of file is not $MeshFormat!");
292
293 double version = 0.0;
294 int file_type = 0;
295 int data_size = 0;
296 readMeshFormat(input, version, file_type, data_size);
297
298 // Test whether version is supported
299 // 2.2 is not representable as float and leads to problems on i386
300 // Hence we use >= 2.00001.
301 GMSH4_ASSERT_MSG((version >= 4.0 && version < 5.0) || (version >= 2.0 && version <= 2.2),
302 "Can only read gmsh files versions >= 4.0 and < 5.0 and versions >= 2.0 and <= 2.2");
303
304 // Hand over to hold GmshReader for Version-2 files
305 if (version >= 2.0 && version <= 2.2)
306 {
307 std::vector<int> boundarySegmentToPhysicalEntity, elementToPhysicalEntity;
308 GmshReader<G>::read(creator_->factory(),
309 filename,
310 boundarySegmentToPhysicalEntity,
311 elementToPhysicalEntity,
312 /*verbose=*/false,
313 /*insertBoundarySegments=*/true);
314 return;
315 }
316
317 // Further sanity checking
318 GMSH4_ASSERT_MSG(file_type == 0 || file_type == 1,
319 "Invalid file-type: 0 for ASCII mode, 1 for binary mode");
320 GMSH4_ASSERT_MSG(data_size >= 4 && data_size <= 16,
321 "Invalid data-size range: should be in {4, 16}");
322 GMSH4_ASSERT_MSG(file_type != 1 || data_size == sizeof(size_type),
323 "Invalid data-size: must be sizeof(size_t)");
324
325 // Rewind the stream, so readSerialFileFromStream can start from the top again
326 input.clear();
327 input.seekg(0, std::ios::beg);
328
329 readSerialFileFromStream(input, fillCreator);
330 pieces_.push_back(filename);
331 } else if (ext == ".pro") {
332 readParallelFileFromStream(input, comm().rank(), comm().size(), fillCreator);
333 } else {
334 DUNE_THROW(IOError, "File has unknown file-extension '" << ext << "'. Allowed are only '.msh' and '.pro'.");
335 }
336}
337
338
339template <class G, class C, class S>
340void Gmsh4Reader<G,C,S>::readSerialFileFromStream (std::ifstream& input, bool fillCreator)
341{
342 clear();
343
344 // MeshFormat section
345 int file_type = 0;
346 int data_size = 0;
347
348 Sections section = Sections::NO_SECTION;
349 for (std::string line; std::getline(input, line); ) {
350 Gmsh4::ltrim(line);
351
352 // detect current section
353 for (auto const& s : sections_) {
354 if (isSection(line, s.first, section)) {
355 section = s.second;
356 break;
357 } else if (isSection(line, "End" + s.first, section, s.second)) {
358 section = Sections::NO_SECTION;
359 break;
360 }
361 }
362
363 switch (section) {
364 case Sections::MESH_FORMAT: {
365 double version = 0.0;
366 readMeshFormat(input, version, file_type, data_size);
367 break;
368 }
369 case Sections::PHYSICAL_NAMES:
370 readPhysicalNames(input); break;
371 case Sections::ENTITIES:
372 if(file_type == 0) readEntitiesAscii(input);
373 else readEntitiesBinary(input);
374 break;
375 case Sections::PARTITIONED_ENTITIES:
376 if(file_type == 0) readPartitionedEntitiesAscii(input);
377 else readPartitionedEntitiesBinary(input);
378 break;
379 case Sections::NODES:
380 if(file_type == 0) readNodesAscii(input);
381 else readNodesBinary(input);
382 break;
383 case Sections::ELEMENTS:
384 if(file_type == 0) readElementsAscii(input);
385 else readElementsBinary(input);
386 break;
387 case Sections::PERIODIC:
388 readPeriodic(input); break;
389 case Sections::GHOST_ELEMENTS:
390 readGhostElements(input); break;
391 case Sections::PARAMETRIZATION:
392 readParametrization(input); break;
393 case Sections::NODE_DATA:
394 readNodeData(input); break;
395 case Sections::ELEMENT_DATA:
396 readElementData(input); break;
397 case Sections::ELEMENT_NODE_DATA:
398 readElementNodeData(input); break;
399 case Sections::INTERPOLATION_SCHEME:
400 readInterpolationScheme(input); break;
401 default:
402 // do nothing
403 break;
404 }
405 }
406
407 if (fillCreator)
408 fillGridCreator();
409}
410
411
412template <class G, class C, class S>
413void Gmsh4Reader<G,C,S>::readParallelFileFromStream (std::ifstream& input, int commRank, int commSize, bool fillCreator)
414{
415 clear();
416 DUNE_THROW(Dune::NotImplemented, "Reading parallel .pro files not yet implemented.");
417 if (fillCreator)
418 fillGridCreator();
419}
420
421
422template <class G, class C, class S>
423void Gmsh4Reader<G,C,S>::readMeshFormat (std::ifstream& input, double& version, int& file_type, int& data_size)
424{
425 std::string line;
426 std::getline(input, line);
427 std::istringstream stream(line);
428 stream >> version >> file_type >> data_size;
429 if (file_type != 0) {
430 int one;
431 input.read(reinterpret_cast<char*>(&one), sizeof(int));
432 if (one != 1) swap = true;
433 std::getline(input, line);
434 }
435}
436
437
438template <class G, class C, class S>
439void Gmsh4Reader<G,C,S>::readPhysicalNames (std::ifstream& input)
440{
441 int numPhysicalNames = 0;
442 std::string line;
443 std::getline(input, line);
444 {
445 std::istringstream stream(line);
446 stream >> numPhysicalNames;
447 }
448
449 for (int i = 0; i < numPhysicalNames; ++i) {
450 if (!std::getline(input,line))
451 break;
452
453 std::istringstream stream(line);
454 PhysicalNamesAttributes attr;
455 stream >> attr.dim >> attr.tag;
456 readString(stream, attr.name);
457
458 physicalNames_.push_back(attr);
459 }
460}
461
462
463template <class G, class C, class S>
464void Gmsh4Reader<G,C,S>::readEntitiesAscii (std::ifstream& input)
465{
466 size_type numPoints = 0, numCurves = 0, numSurfaces = 0, numVolumes = 0;
467
468 std::string line;
469 std::getline(input, line);
470 {
471 std::istringstream stream(line);
472 stream >> numPoints >> numCurves >> numSurfaces >> numVolumes;
473 }
474
475 // points
476 points_.reserve(numPoints);
477 for (size_type i = 0; i < numPoints; ++i) {
478 if (!std::getline(input,line))
479 break;
480
481 std::istringstream stream(line);
482 PointAttributes attr;
483 stream >> attr.tag >> attr.xyz[0] >> attr.xyz[1] >> attr.xyz[2];
484
485 size_type numPhysicalTags = 0;
486 stream >> numPhysicalTags;
487
488 attr.physicalTags.resize(numPhysicalTags);
489 for (size_type j = 0; j < numPhysicalTags; ++j)
490 stream >> attr.physicalTags[j];
491
492 points_.push_back(attr);
493 }
494 GMSH4_ASSERT(points_.size() == numPoints);
495
496 // curves
497 curves_.reserve(numCurves);
498 for (size_type i = 0; i < numCurves; ++i) {
499 if (!std::getline(input,line))
500 break;
501
502 std::istringstream stream(line);
503 EntityAttributes attr;
504 stream >> attr.tag
505 >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
506 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
507
508 size_type numPhysicalTags = 0;
509 stream >> numPhysicalTags;
510 attr.physicalTags.resize(numPhysicalTags);
511 for (size_type j = 0; j < numPhysicalTags; ++j)
512 stream >> attr.physicalTags[j];
513
514 size_type numBoundingPoints = 0;
515 stream >> numBoundingPoints;
516 attr.boundingEntities.resize(numBoundingPoints);
517 for (size_type j = 0; j < numBoundingPoints; ++j)
518 stream >> attr.boundingEntities[j];
519
520 curves_.push_back(attr);
521 }
522 GMSH4_ASSERT(curves_.size() == numCurves);
523
524 // surfaces
525 surfaces_.reserve(numSurfaces);
526 for (size_type i = 0; i < numSurfaces; ++i) {
527 if (!std::getline(input,line))
528 break;
529
530 std::istringstream stream(line);
531 EntityAttributes attr;
532 stream >> attr.tag
533 >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
534 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
535
536 size_type numPhysicalTags = 0;
537 stream >> numPhysicalTags;
538 attr.physicalTags.resize(numPhysicalTags);
539 for (size_type j = 0; j < numPhysicalTags; ++j)
540 stream >> attr.physicalTags[j];
541
542 size_type numBoundingCurves = 0;
543 stream >> numBoundingCurves;
544 attr.boundingEntities.resize(numBoundingCurves);
545 for (size_type j = 0; j < numBoundingCurves; ++j)
546 stream >> attr.boundingEntities[j];
547
548 surfaces_.push_back(attr);
549 }
550 GMSH4_ASSERT(surfaces_.size() == numSurfaces);
551
552 // volumes
553 volumes_.reserve(numVolumes);
554 for (size_type i = 0; i < numVolumes; ++i) {
555 if (!std::getline(input,line))
556 break;
557
558 std::istringstream stream(line);
559 EntityAttributes attr;
560 stream >> attr.tag
561 >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
562 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
563
564 size_type numPhysicalTags = 0;
565 stream >> numPhysicalTags;
566 attr.physicalTags.resize(numPhysicalTags);
567 for (size_type j = 0; j < numPhysicalTags; ++j)
568 stream >> attr.physicalTags[j];
569
570 size_type numBoundingSurfaces = 0;
571 stream >> numBoundingSurfaces;
572 attr.boundingEntities.resize(numBoundingSurfaces);
573 for (size_type j = 0; j < numBoundingSurfaces; ++j)
574 stream >> attr.boundingEntities[j];
575
576 volumes_.push_back(attr);
577 }
578 GMSH4_ASSERT(volumes_.size() == numVolumes);
579}
580
581
582template <class G, class C, class S>
583void Gmsh4Reader<G,C,S>::readEntitiesBinary (std::ifstream& input)
584{
585 size_type numPoints = 0, numCurves = 0, numSurfaces = 0, numVolumes = 0;
586
587 readValueBinary(input, numPoints);
588 readValueBinary(input, numCurves);
589 readValueBinary(input, numSurfaces);
590 readValueBinary(input, numVolumes);
591
592 // points
593 points_.reserve(numPoints);
594 for (size_type i = 0; i < numPoints; ++i) {
595 PointAttributes attr;
596
597 readValueBinary(input, attr.tag);
598 readValueBinary(input, attr.xyz[0]);
599 readValueBinary(input, attr.xyz[1]);
600 readValueBinary(input, attr.xyz[2]);
601
602 size_type numPhysicalTags = 0;
603 readValueBinary(input, numPhysicalTags);
604 attr.physicalTags.resize(numPhysicalTags);
605 for (size_type j = 0; j < numPhysicalTags; ++j)
606 readValueBinary(input, attr.physicalTags[j]);
607
608 points_.push_back(attr);
609 }
610 GMSH4_ASSERT(points_.size() == numPoints);
611
612 // curves
613 curves_.reserve(numCurves);
614 for (size_type i = 0; i < numCurves; ++i) {
615 EntityAttributes attr;
616
617 readValueBinary(input, attr.tag);
618 readValueBinary(input, attr.min_xyz[0]);
619 readValueBinary(input, attr.min_xyz[1]);
620 readValueBinary(input, attr.min_xyz[2]);
621 readValueBinary(input, attr.max_xyz[0]);
622 readValueBinary(input, attr.max_xyz[1]);
623 readValueBinary(input, attr.max_xyz[2]);
624
625 size_type numPhysicalTags = 0;
626 readValueBinary(input, numPhysicalTags);
627 attr.physicalTags.resize(numPhysicalTags);
628 for (size_type j = 0; j < numPhysicalTags; ++j)
629 readValueBinary(input, attr.physicalTags[j]);
630
631 size_type numBoundingPoints = 0;
632 readValueBinary(input, numBoundingPoints);
633 attr.boundingEntities.resize(numBoundingPoints);
634 for (size_type j = 0; j < numBoundingPoints; ++j)
635 readValueBinary(input, attr.boundingEntities[j]);
636
637 curves_.push_back(attr);
638 }
639 GMSH4_ASSERT(curves_.size() == numCurves);
640
641 // surfaces
642 surfaces_.reserve(numSurfaces);
643 for (size_type i = 0; i < numSurfaces; ++i) {
644 EntityAttributes attr;
645
646 readValueBinary(input, attr.tag);
647 readValueBinary(input, attr.min_xyz[0]);
648 readValueBinary(input, attr.min_xyz[1]);
649 readValueBinary(input, attr.min_xyz[2]);
650 readValueBinary(input, attr.max_xyz[0]);
651 readValueBinary(input, attr.max_xyz[1]);
652 readValueBinary(input, attr.max_xyz[2]);
653
654 size_type numPhysicalTags = 0;
655 readValueBinary(input, numPhysicalTags);
656 attr.physicalTags.resize(numPhysicalTags);
657 for (size_type j = 0; j < numPhysicalTags; ++j)
658 readValueBinary(input, attr.physicalTags[j]);
659
660 size_type numBoundingCurves = 0;
661 readValueBinary(input, numBoundingCurves);
662 attr.boundingEntities.resize(numBoundingCurves);
663 for (size_type j = 0; j < numBoundingCurves; ++j)
664 readValueBinary(input, attr.boundingEntities[j]);
665
666 surfaces_.push_back(attr);
667 }
668 GMSH4_ASSERT(surfaces_.size() == numSurfaces);
669
670 // volumes
671 volumes_.reserve(numVolumes);
672 for (size_type i = 0; i < numVolumes; ++i) {
673 EntityAttributes attr;
674
675 readValueBinary(input, attr.tag);
676 readValueBinary(input, attr.min_xyz[0]);
677 readValueBinary(input, attr.min_xyz[1]);
678 readValueBinary(input, attr.min_xyz[2]);
679 readValueBinary(input, attr.max_xyz[0]);
680 readValueBinary(input, attr.max_xyz[1]);
681 readValueBinary(input, attr.max_xyz[2]);
682
683 size_type numPhysicalTags = 0;
684 readValueBinary(input, numPhysicalTags);
685 attr.physicalTags.resize(numPhysicalTags);
686 for (size_type j = 0; j < numPhysicalTags; ++j)
687 readValueBinary(input, attr.physicalTags[j]);
688
689 size_type numBoundingSurfaces = 0;
690 readValueBinary(input, numBoundingSurfaces);
691 attr.boundingEntities.resize(numBoundingSurfaces);
692 for (size_type j = 0; j < numBoundingSurfaces; ++j)
693 readValueBinary(input, attr.boundingEntities[j]);
694
695 volumes_.push_back(attr);
696 }
697 GMSH4_ASSERT(volumes_.size() == numVolumes);
698 std::string line;
699 std::getline(input, line);
700}
701
702
703template <class G, class C, class S>
704void Gmsh4Reader<G,C,S>::readPartitionedEntitiesAscii (std::ifstream& input)
705{
706 size_type numGhostEntities = 0;
707 size_type numPoints = 0, numCurves = 0, numSurfaces = 0, numVolumes = 0;
708
709 std::string line;
710 std::getline(input, line);
711 {
712 std::istringstream stream(line);
713 stream >> numPartitions_;
714 }
715
716 std::getline(input, line);
717 {
718 std::istringstream stream(line);
719 stream >> numGhostEntities;
720
721 // ghost entities
722 ghostEntities_.reserve(numGhostEntities);
723 for (size_type i = 0; i < numGhostEntities; ++i) {
724 GhostAttributes attr;
725 stream >> attr.tag >> attr.partition;
726
727 ghostEntities_.push_back(attr);
728 }
729 GMSH4_ASSERT(ghostEntities_.size() == numGhostEntities);
730 }
731
732 std::getline(input, line);
733 {
734 std::istringstream stream(line);
735 stream >> numPoints >> numCurves >> numSurfaces >> numVolumes;
736 }
737
738 // points
739 partitionedPoints_.reserve(numPoints);
740 for (size_type i = 0; i < numPoints; ++i) {
741 if (!std::getline(input,line))
742 break;
743
744 std::istringstream stream(line);
745 PartitionedAttributes<PointAttributes> attr;
746 stream >> attr.tag >> attr.parentDim >> attr.parentTag;
747
748 size_type numPartitions = 0;
749 stream >> numPartitions;
750 attr.partitions.resize(numPartitions);
751 for (size_type j = 0; j < numPartitions; ++j)
752 stream >> attr.partitions[j];
753
754 stream >> attr.xyz[0] >> attr.xyz[1] >> attr.xyz[2];
755
756 size_type numPhysicalTags = 0;
757 stream >> numPhysicalTags;
758 attr.physicalTags.resize(numPhysicalTags);
759 for (size_type j = 0; j < numPhysicalTags; ++j)
760 stream >> attr.physicalTags[j];
761
762 partitionedPoints_.push_back(attr);
763 }
764 GMSH4_ASSERT(partitionedPoints_.size() == numPoints);
765
766 // curves
767 partitionedCurves_.reserve(numCurves);
768 for (size_type i = 0; i < numCurves; ++i) {
769 if (!std::getline(input,line))
770 break;
771
772 std::istringstream stream(line);
773 PartitionedAttributes<EntityAttributes> attr;
774 stream >> attr.tag >> attr.parentDim >> attr.parentTag;
775
776 size_type numPartitions = 0;
777 stream >> numPartitions;
778 attr.partitions.resize(numPartitions);
779 for (size_type j = 0; j < numPartitions; ++j)
780 stream >> attr.partitions[j];
781
782 stream >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
783 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
784
785 size_type numPhysicalTags = 0;
786 stream >> numPhysicalTags;
787 attr.physicalTags.resize(numPhysicalTags);
788 for (size_type j = 0; j < numPhysicalTags; ++j)
789 stream >> attr.physicalTags[j];
790
791 size_type numBoundingPoints = 0;
792 stream >> numBoundingPoints;
793 attr.boundingEntities.resize(numBoundingPoints);
794 for (size_type j = 0; j < numBoundingPoints; ++j)
795 stream >> attr.boundingEntities[j];
796
797 partitionedCurves_.push_back(attr);
798 }
799 GMSH4_ASSERT(partitionedCurves_.size() == numCurves);
800
801 // surfaces
802 partitionedSurfaces_.reserve(numSurfaces);
803 for (size_type i = 0; i < numSurfaces; ++i) {
804 if (!std::getline(input,line))
805 break;
806
807 std::istringstream stream(line);
808 PartitionedAttributes<EntityAttributes> attr;
809 stream >> attr.tag >> attr.parentDim >> attr.parentTag;
810
811 size_type numPartitions = 0;
812 stream >> numPartitions;
813 attr.partitions.resize(numPartitions);
814 for (size_type j = 0; j < numPartitions; ++j)
815 stream >> attr.partitions[j];
816
817 stream >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
818 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
819
820 size_type numPhysicalTags = 0;
821 stream >> numPhysicalTags;
822 attr.physicalTags.resize(numPhysicalTags);
823 for (size_type j = 0; j < numPhysicalTags; ++j)
824 stream >> attr.physicalTags[j];
825
826 size_type numBoundingCurves = 0;
827 stream >> numBoundingCurves;
828 attr.boundingEntities.resize(numBoundingCurves);
829 for (size_type j = 0; j < numBoundingCurves; ++j)
830 stream >> attr.boundingEntities[j];
831
832 partitionedSurfaces_.push_back(attr);
833 }
834 GMSH4_ASSERT(partitionedSurfaces_.size() == numSurfaces);
835
836 // volumes
837 partitionedVolumes_.reserve(numVolumes);
838 for (size_type i = 0; i < numVolumes; ++i) {
839 if (!std::getline(input,line))
840 break;
841
842 std::istringstream stream(line);
843 PartitionedAttributes<EntityAttributes> attr;
844 stream >> attr.tag >> attr.parentDim >> attr.parentTag;
845
846 size_type numPartitions = 0;
847 stream >> numPartitions;
848 attr.partitions.resize(numPartitions);
849 for (size_type j = 0; j < numPartitions; ++j)
850 stream >> attr.partitions[j];
851
852 stream >> attr.min_xyz[0] >> attr.min_xyz[1] >> attr.min_xyz[2]
853 >> attr.max_xyz[0] >> attr.max_xyz[1] >> attr.max_xyz[2];
854
855 size_type numPhysicalTags = 0;
856 stream >> numPhysicalTags;
857 attr.physicalTags.resize(numPhysicalTags);
858 for (size_type j = 0; j < numPhysicalTags; ++j)
859 stream >> attr.physicalTags[j];
860
861 size_type numBoundingSurfaces = 0;
862 stream >> numBoundingSurfaces;
863 attr.boundingEntities.resize(numBoundingSurfaces);
864 for (size_type j = 0; j < numBoundingSurfaces; ++j)
865 stream >> attr.boundingEntities[j];
866
867 partitionedVolumes_.push_back(attr);
868 }
869 GMSH4_ASSERT(partitionedVolumes_.size() == numVolumes);
870}
871
872
873template <class G, class C, class S>
874void Gmsh4Reader<G,C,S>::readPartitionedEntitiesBinary (std::ifstream& input)
875{
876 size_type numGhostEntities = 0;
877 size_type numPoints = 0, numCurves = 0, numSurfaces = 0, numVolumes = 0;
878
879 readValueBinary(input, numPartitions_);
880
881 // ghost entities
882 readValueBinary(input, numGhostEntities);
883 ghostEntities_.reserve(numGhostEntities);
884 for (size_type i = 0; i < numGhostEntities; ++i) {
885 GhostAttributes attr;
886 readValueBinary(input, attr.tag);
887 readValueBinary(input, attr.partition);
888 ghostEntities_.push_back(attr);
889 }
890 GMSH4_ASSERT(ghostEntities_.size() == numGhostEntities);
891
892 readValueBinary(input, numPoints);
893 readValueBinary(input, numCurves);
894 readValueBinary(input, numSurfaces);
895 readValueBinary(input, numVolumes);
896
897 // points
898 partitionedPoints_.reserve(numPoints);
899 for (size_type i = 0; i < numPoints; ++i) {
900 PartitionedAttributes<PointAttributes> attr;
901
902 readValueBinary(input, attr.tag);
903 readValueBinary(input, attr.parentDim);
904 readValueBinary(input, attr.parentTag);
905
906 size_type numPartitions = 0;
907 readValueBinary(input, numPartitions);
908 attr.partitions.resize(numPartitions);
909 for (size_type j = 0; j < numPartitions; ++j)
910 readValueBinary(input, attr.partitions[j]);
911
912 readValueBinary(input, attr.xyz[0]);
913 readValueBinary(input, attr.xyz[1]);
914 readValueBinary(input, attr.xyz[2]);
915
916 size_type numPhysicalTags = 0;
917 readValueBinary(input, numPhysicalTags);
918 attr.physicalTags.resize(numPhysicalTags);
919 for (size_type j = 0; j < numPhysicalTags; ++j)
920 readValueBinary(input, attr.physicalTags[j]);
921
922 partitionedPoints_.push_back(attr);
923 }
924 GMSH4_ASSERT(partitionedPoints_.size() == numPoints);
925
926 // curves
927 partitionedCurves_.reserve(numCurves);
928 for (size_type i = 0; i < numCurves; ++i) {
929 PartitionedAttributes<EntityAttributes> attr;
930
931 readValueBinary(input, attr.tag);
932 readValueBinary(input, attr.parentDim);
933 readValueBinary(input, attr.parentTag);
934
935 size_type numPartitions = 0;
936 readValueBinary(input, numPartitions);
937 attr.partitions.resize(numPartitions);
938 for (size_type j = 0; j < numPartitions; ++j)
939 readValueBinary(input, attr.partitions[j]);
940
941 readValueBinary(input, attr.min_xyz[0]);
942 readValueBinary(input, attr.min_xyz[1]);
943 readValueBinary(input, attr.min_xyz[2]);
944 readValueBinary(input, attr.max_xyz[0]);
945 readValueBinary(input, attr.max_xyz[1]);
946 readValueBinary(input, attr.max_xyz[2]);
947
948 size_type numPhysicalTags = 0;
949 readValueBinary(input, numPhysicalTags);
950 attr.physicalTags.resize(numPhysicalTags);
951 for (size_type j = 0; j < numPhysicalTags; ++j)
952 readValueBinary(input, attr.physicalTags[j]);
953
954 size_type numBoundingPoints = 0;
955 readValueBinary(input, numBoundingPoints);
956 attr.boundingEntities.resize(numBoundingPoints);
957 for (size_type j = 0; j < numBoundingPoints; ++j)
958 readValueBinary(input, attr.boundingEntities[j]);
959
960 partitionedCurves_.push_back(attr);
961 }
962 GMSH4_ASSERT(partitionedCurves_.size() == numCurves);
963
964 // surfaces
965 partitionedSurfaces_.reserve(numSurfaces);
966 for (size_type i = 0; i < numSurfaces; ++i) {
967 PartitionedAttributes<EntityAttributes> attr;
968
969 readValueBinary(input, attr.tag);
970 readValueBinary(input, attr.parentDim);
971 readValueBinary(input, attr.parentTag);
972
973 size_type numPartitions = 0;
974 readValueBinary(input, numPartitions);
975 attr.partitions.resize(numPartitions);
976 for (size_type j = 0; j < numPartitions; ++j)
977 readValueBinary(input, attr.partitions[j]);
978
979 readValueBinary(input, attr.min_xyz[0]);
980 readValueBinary(input, attr.min_xyz[1]);
981 readValueBinary(input, attr.min_xyz[2]);
982 readValueBinary(input, attr.max_xyz[0]);
983 readValueBinary(input, attr.max_xyz[1]);
984 readValueBinary(input, attr.max_xyz[2]);
985
986 size_type numPhysicalTags = 0;
987 readValueBinary(input, numPhysicalTags);
988 attr.physicalTags.resize(numPhysicalTags);
989 for (size_type j = 0; j < numPhysicalTags; ++j)
990 readValueBinary(input, attr.physicalTags[j]);
991
992 size_type numBoundingCurves = 0;
993 readValueBinary(input, numBoundingCurves);
994 attr.boundingEntities.resize(numBoundingCurves);
995 for (size_type j = 0; j < numBoundingCurves; ++j)
996 readValueBinary(input, attr.boundingEntities[j]);
997
998 partitionedSurfaces_.push_back(attr);
999 }
1000 GMSH4_ASSERT(partitionedSurfaces_.size() == numSurfaces);
1001
1002 // volumes
1003 partitionedVolumes_.reserve(numVolumes);
1004 for (size_type i = 0; i < numVolumes; ++i) {
1005 PartitionedAttributes<EntityAttributes> attr;
1006
1007 readValueBinary(input, attr.tag);
1008 readValueBinary(input, attr.parentDim);
1009 readValueBinary(input, attr.parentTag);
1010
1011 size_type numPartitions = 0;
1012 readValueBinary(input, numPartitions);
1013 attr.partitions.resize(numPartitions);
1014 for (size_type j = 0; j < numPartitions; ++j)
1015 readValueBinary(input, attr.partitions[j]);
1016
1017 readValueBinary(input, attr.min_xyz[0]);
1018 readValueBinary(input, attr.min_xyz[1]);
1019 readValueBinary(input, attr.min_xyz[2]);
1020 readValueBinary(input, attr.max_xyz[0]);
1021 readValueBinary(input, attr.max_xyz[1]);
1022 readValueBinary(input, attr.max_xyz[2]);
1023
1024 size_type numPhysicalTags = 0;
1025 readValueBinary(input, numPhysicalTags);
1026 attr.physicalTags.resize(numPhysicalTags);
1027 for (size_type j = 0; j < numPhysicalTags; ++j)
1028 readValueBinary(input, attr.physicalTags[j]);
1029
1030 size_type numBoundingSurfaces = 0;
1031 readValueBinary(input, numBoundingSurfaces);
1032 attr.boundingEntities.resize(numBoundingSurfaces);
1033 for (size_type j = 0; j < numBoundingSurfaces; ++j)
1034 readValueBinary(input, attr.boundingEntities[j]);
1035
1036 partitionedVolumes_.push_back(attr);
1037 }
1038 GMSH4_ASSERT(partitionedVolumes_.size() == numVolumes);
1039 std::string line;
1040 std::getline(input, line);
1041}
1042
1043
1044template <class G, class C, class S>
1045void Gmsh4Reader<G,C,S>::readNodesAscii (std::ifstream& input)
1046{
1047 size_type numEntityBlocks = 0;
1048
1049 std::string line;
1050 std::getline(input, line);
1051 {
1052 std::istringstream stream(line);
1053 stream >> numEntityBlocks >> numNodes_ >> minNodeTag_ >> maxNodeTag_;
1054 }
1055
1056 nodes_.resize(numEntityBlocks);
1057 for (size_type i = 0; i < numEntityBlocks; ++i) {
1058 if (!std::getline(input,line))
1059 break;
1060
1061 auto& entityBlock = nodes_[i];
1062 size_type numNodesInBlock = 0;
1063
1064 std::istringstream stream(line);
1065 stream >> entityBlock.entityDim >> entityBlock.entityTag >> entityBlock.parametric >> numNodesInBlock;
1066
1067 entityBlock.nodes.resize(numNodesInBlock);
1068 for (size_type j = 0; j < numNodesInBlock; ++j) {
1069 if (!std::getline(input,line))
1070 break;
1071
1072 char* end;
1073 entityBlock.nodes[j].tag = std::strtoul(line.data(), &end, 10);
1074 }
1075
1076 for (size_type j = 0; j < numNodesInBlock; ++j) {
1077 if (!std::getline(input,line))
1078 break;
1079
1080 auto& node = entityBlock.nodes[j];
1081
1082 std::istringstream stream(line);
1083 stream >> node.xyz[0] >> node.xyz[1] >> node.xyz[2];
1084
1085 if (entityBlock.parametric && entityBlock.entityDim >= 1)
1086 stream >> node.uvw[0];
1087 if (entityBlock.parametric && entityBlock.entityDim >= 2)
1088 stream >> node.uvw[1];
1089 if (entityBlock.parametric && entityBlock.entityDim == 3)
1090 stream >> node.uvw[2];
1091 }
1092 }
1093}
1094
1095
1096template <class G, class C, class S>
1097void Gmsh4Reader<G,C,S>::readNodesBinary (std::ifstream& input)
1098{
1099 size_type numEntityBlocks = 0;
1100 readValueBinary(input, numEntityBlocks);
1101 readValueBinary(input, numNodes_);
1102 readValueBinary(input, minNodeTag_);
1103 readValueBinary(input, maxNodeTag_);
1104
1105 nodes_.resize(numEntityBlocks);
1106 for (size_type i = 0; i < numEntityBlocks; ++i) {
1107 auto& entityBlock = nodes_[i];
1108 size_type numNodesInBlock = 0;
1109
1110 readValueBinary(input, entityBlock.entityDim);
1111 readValueBinary(input, entityBlock.entityTag);
1112 readValueBinary(input, entityBlock.parametric);
1113 readValueBinary(input, numNodesInBlock);
1114
1115 entityBlock.nodes.resize(numNodesInBlock);
1116 for (size_type j = 0; j < numNodesInBlock; ++j)
1117 readValueBinary(input, entityBlock.nodes[j].tag);
1118
1119 for (size_type j = 0; j < numNodesInBlock; ++j) {
1120 auto& node = entityBlock.nodes[j];
1121
1122 readValueBinary(input, node.xyz[0]);
1123 readValueBinary(input, node.xyz[1]);
1124 readValueBinary(input, node.xyz[2]);
1125
1126 if (entityBlock.parametric && entityBlock.entityDim >= 1)
1127 readValueBinary(input, node.uvw[0]);
1128 if (entityBlock.parametric && entityBlock.entityDim >= 2)
1129 readValueBinary(input, node.uvw[1]);
1130 if (entityBlock.parametric && entityBlock.entityDim == 3)
1131 readValueBinary(input, node.uvw[2]);
1132 }
1133 }
1134 std::string line;
1135 std::getline(input, line);
1136}
1137
1138
1139template <class G, class C, class S>
1140void Gmsh4Reader<G,C,S>::readElementsAscii (std::ifstream& input)
1141{
1142 size_type numEntityBlocks = 0;
1143 size_type numElementsInBlock = 0;
1144
1145 std::string line;
1146 std::getline(input, line);
1147 {
1148 std::istringstream stream(line);
1149 stream >> numEntityBlocks >> numElements_ >> minElementTag_ >> maxElementTag_;
1150 }
1151
1152 elements_.resize(numEntityBlocks);
1153 for (size_type i = 0; i < numEntityBlocks; ++i) {
1154 if (!std::getline(input,line))
1155 break;
1156
1157 auto& entityBlock = elements_[i];
1158
1159 std::istringstream stream(line);
1160 stream >> entityBlock.entityDim >> entityBlock.entityTag >> entityBlock.elementType >> numElementsInBlock;
1161
1162 size_type numNodes = elementType_[entityBlock.elementType];
1163
1164 entityBlock.elements.resize(numElementsInBlock);
1165 for (size_type j = 0; j < numElementsInBlock; ++j) {
1166 if (!std::getline(input,line))
1167 break;
1168
1169 auto& element = entityBlock.elements[j];
1170
1171 std::istringstream stream(line);
1172 stream >> element.tag;
1173 element.nodes.resize(numNodes);
1174 for (size_type k = 0; k < numNodes; ++k)
1175 stream >> element.nodes[k];
1176 }
1177 }
1178}
1179
1180
1181template <class G, class C, class S>
1182void Gmsh4Reader<G,C,S>::readElementsBinary (std::ifstream& input)
1183{
1184 size_type numEntityBlocks = 0;
1185 size_type numElementsInBlock = 0;
1186
1187 readValueBinary(input, numEntityBlocks);
1188 readValueBinary(input, numElements_);
1189 readValueBinary(input, minElementTag_);
1190 readValueBinary(input, maxElementTag_);
1191
1192 elements_.resize(numEntityBlocks);
1193 for (size_type i = 0; i < numEntityBlocks; ++i) {
1194 auto& entityBlock = elements_[i];
1195
1196 readValueBinary(input, entityBlock.entityDim);
1197 readValueBinary(input, entityBlock.entityTag);
1198 readValueBinary(input, entityBlock.elementType);
1199 readValueBinary(input, numElementsInBlock);
1200
1201 size_type numNodes = elementType_[entityBlock.elementType];
1202
1203 entityBlock.elements.resize(numElementsInBlock);
1204 for (size_type j = 0; j < numElementsInBlock; ++j) {
1205 auto& element = entityBlock.elements[j];
1206 readValueBinary(input, element.tag);
1207 element.nodes.resize(numNodes);
1208 for (size_type k = 0; k < numNodes; ++k)
1209 readValueBinary(input, element.nodes[k]);
1210 }
1211 }
1212 std::string line;
1213 std::getline(input, line);
1214}
1215
1216
1217template <class G, class C, class S>
1218void Gmsh4Reader<G,C,S>::readPeriodic (std::ifstream& /*input*/)
1219{
1220 std::cout << "WARNING: readPeriodic() is not yet implemented. Section will be ignored." << std::endl;
1221}
1222
1223template <class G, class C, class S>
1224void Gmsh4Reader<G,C,S>::readGhostElements (std::ifstream& /*input*/)
1225{
1226 std::cout << "WARNING: readGhostElements() is not yet implemented. Section will be ignored." << std::endl;
1227}
1228
1229template <class G, class C, class S>
1230void Gmsh4Reader<G,C,S>::readParametrization (std::ifstream& /*input*/)
1231{
1232 std::cout << "WARNING: readParametrization() is not yet implemented. Section will be ignored." << std::endl;
1233}
1234
1235template <class G, class C, class S>
1236void Gmsh4Reader<G,C,S>::readNodeData (std::ifstream& /*input*/)
1237{
1238 std::cout << "WARNING: readNodeData() is not yet implemented. Section will be ignored." << std::endl;
1239}
1240
1241template <class G, class C, class S>
1242void Gmsh4Reader<G,C,S>::readElementData (std::ifstream& /*input*/)
1243{
1244 std::cout << "WARNING: readElementData() is not yet implemented. Section will be ignored." << std::endl;
1245}
1246
1247template <class G, class C, class S>
1248void Gmsh4Reader<G,C,S>::readElementNodeData (std::ifstream& /*input*/)
1249{
1250 std::cout << "WARNING: readElementNodeData() is not yet implemented. Section will be ignored." << std::endl;
1251}
1252
1253template <class G, class C, class S>
1254void Gmsh4Reader<G,C,S>::readInterpolationScheme (std::ifstream& /*input*/)
1255{
1256 std::cout << "WARNING: readInterpolationScheme() is not yet implemented. Section will be ignored." << std::endl;
1257}
1258
1259
1260template <class G, class C, class S>
1262{
1263 if (!nodes_.empty())
1264 creator_->insertVertices(numNodes_, {minNodeTag_, maxNodeTag_}, nodes_);
1265 if (!elements_.empty()) {
1266 std::set<int> boundaryEntities;
1267 creator_->insertElements(numElements_, {minElementTag_, maxElementTag_}, elements_, boundaryEntities);
1268 }
1269 if (insertPieces)
1270 creator_->insertPieces(pieces_);
1271}
1272
1273} // end namespace Dune
File-Reader for GMsh unstructured .msh files.
Definition: gmsh4reader.hh:32
void readSerialFileFromStream(std::ifstream &input, bool fillCreator=true)
Read the grid from an input stream, referring to a .msh file, into the GridCreator.
Definition: gmsh4reader.impl.hh:340
void fillGridCreator(bool insertPieces=true)
Construct a grid using the GridCreator.
Definition: gmsh4reader.impl.hh:1261
void read(std::string const &filename, bool fillCreator=true)
Read the grid from file with filename into the GridFactory stored in the GridCreator.
Definition: gmsh4reader.impl.hh:271
void readParallelFileFromStream(std::ifstream &input, int rank, int size, bool fillCreator=true)
Read the grid from and input stream, referring to a .pro file, into the GridCreator.
Definition: gmsh4reader.impl.hh:413
static std::unique_ptr< Grid > read(const std::string &fileName, bool verbose=true, bool insertBoundarySegments=true)
Definition: gmshreader.hh:203
Default exception class for I/O errors.
Definition: exceptions.hh:325
Default exception for dummy implementations.
Definition: exceptions.hh:357
Macro for wrapping error checks and throwing exceptions.
#define GMSH4_ASSERT(cond)
check if condition cond holds; otherwise, throw a Gmsh4Error.
Definition: errors.hh:34
#define GMSH4_ASSERT_MSG(cond, text)
check if condition cond holds; otherwise, throw a Gmsh4Error with a message.
Definition: errors.hh:24
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:498
auto elements(const SubDomainGridView< HostGridView > &subDomainGridView)
ADL findable access to element range for a SubDomainGridView.
Definition: subdomain.hh:487
Dune namespace
Definition: alignedallocator.hh:13
constexpr std::integral_constant< std::size_t, sizeof...(II)> size(std::integer_sequence< T, II... >)
Return the size of the sequence.
Definition: integersequence.hh:75
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 14, 23:39, 2026)