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