6#ifndef DUNE_GMSHREADER_HH
7#define DUNE_GMSHREADER_HH
21#include <dune/common/exceptions.hh>
22#include <dune/common/fvector.hh>
24#include <dune/geometry/type.hh>
51 template<
int dimension,
int dimWorld = dimension >
52 class GmshReaderQuadraticBoundarySegment
56 static void registerFactory() {}
71 template<
int dimWorld >
72 struct GmshReaderQuadraticBoundarySegment< 2,
dimWorld >
75 typedef GmshReaderQuadraticBoundarySegment< 2, dimWorld > ThisType;
77 typedef Dune::FieldVector< double, dimWorld >
GlobalVector;
80 : p0(p0_), p1(p1_), p2(p2_)
85 GmshReaderQuadraticBoundarySegment( ObjectStreamType& in )
88 const int bytes =
sizeof(double)*
dimWorld;
89 in.read( (
char *) &p0[ 0 ], bytes );
90 in.read( (
char *) &p1[ 0 ], bytes );
91 in.read( (
char *) &p2[ 0 ], bytes );
95 static void registerFactory()
103 virtual GlobalVector operator() (
const Dune::FieldVector<double,1> &local )
const
107 y.axpy((local[0]-alpha)*(local[0]-1.0)/alpha,p0);
108 y.axpy(local[0]*(local[0]-1.0)/(alpha*(alpha-1.0)),p1);
109 y.axpy(local[0]*(local[0]-alpha)/(1.0-alpha),p2);
113 void backup( ObjectStreamType& out )
const
116 out.write( (
const char *) &key(),
sizeof(
int ) );
118 const int bytes =
sizeof(double)*
dimWorld;
119 out.write( (
const char*) &p0[ 0 ], bytes );
120 out.write( (
const char*) &p1[ 0 ], bytes );
121 out.write( (
const char*) &p2[ 0 ], bytes );
132 alpha=d1.two_norm()/(d1.two_norm()+d2.two_norm());
133 if (alpha<1E-6 || alpha>1-1E-6)
134 DUNE_THROW(Dune::IOError,
"ration in quadratic boundary segment bad");
172 class GmshReaderQuadraticBoundarySegment< 3, 3 >
175 typedef GmshReaderQuadraticBoundarySegment< 3, 3 > ThisType;
178 GmshReaderQuadraticBoundarySegment (Dune::FieldVector<double,3> p0_, Dune::FieldVector<double,3> p1_,
179 Dune::FieldVector<double,3> p2_, Dune::FieldVector<double,3> p3_,
180 Dune::FieldVector<double,3> p4_, Dune::FieldVector<double,3> p5_)
181 : p0(p0_), p1(p1_), p2(p2_), p3(p3_), p4(p4_), p5(p5_)
186 GmshReaderQuadraticBoundarySegment( ObjectStreamType& in )
188 const int bytes =
sizeof(double)*3;
189 in.read( (
char *) &p0[ 0 ], bytes );
190 in.read( (
char *) &p1[ 0 ], bytes );
191 in.read( (
char *) &p2[ 0 ], bytes );
192 in.read( (
char *) &p3[ 0 ], bytes );
193 in.read( (
char *) &p4[ 0 ], bytes );
194 in.read( (
char *) &p5[ 0 ], bytes );
198 static void registerFactory()
206 virtual Dune::FieldVector<double,3> operator() (
const Dune::FieldVector<double,2>& local)
const
208 Dune::FieldVector<double,3> y;
210 y.axpy(phi0(local),p0);
211 y.axpy(phi1(local),p1);
212 y.axpy(phi2(local),p2);
213 y.axpy(phi3(local),p3);
214 y.axpy(phi4(local),p4);
215 y.axpy(phi5(local),p5);
219 void backup( ObjectStreamType& out )
const
222 out.write( (
const char*) &key(),
sizeof(
int ) );
224 const int bytes =
sizeof(double)*3;
225 out.write( (
const char*) &p0[ 0 ], bytes );
226 out.write( (
const char*) &p1[ 0 ], bytes );
227 out.write( (
const char*) &p2[ 0 ], bytes );
228 out.write( (
const char*) &p3[ 0 ], bytes );
229 out.write( (
const char*) &p4[ 0 ], bytes );
230 out.write( (
const char*) &p5[ 0 ], bytes );
238 Dune::FieldVector<double,3> d1,d2;
242 alpha=d1.two_norm()/(d1.two_norm()+d2.two_norm());
243 if (alpha<1E-6 || alpha>1-1E-6)
244 DUNE_THROW(Dune::IOError,
"alpha in quadratic boundary segment bad");
248 beta=d1.two_norm()/(d1.two_norm()+d2.two_norm());
249 if (beta<1E-6 || beta>1-1E-6)
250 DUNE_THROW(Dune::IOError,
"beta in quadratic boundary segment bad");
254 gamma=sqrt2*(d1.two_norm()/(d1.two_norm()+d2.two_norm()));
255 if (gamma<1E-6 || gamma>1-1E-6)
256 DUNE_THROW(Dune::IOError,
"gamma in quadratic boundary segment bad");
268 double phi0 (
const Dune::FieldVector<double,2>& local)
const
270 return (alpha*beta-beta*local[0]-alpha*local[1])*(1-local[0]-local[1])/(alpha*beta);
272 double phi3 (
const Dune::FieldVector<double,2>& local)
const
274 return local[0]*(1-local[0]-local[1])/(alpha*(1-alpha));
276 double phi1 (
const Dune::FieldVector<double,2>& local)
const
278 return local[0]*(gamma*local[0]-(sqrt2-gamma-sqrt2*alpha)*local[1]-alpha*gamma)/(gamma*(1-alpha));
280 double phi5 (
const Dune::FieldVector<double,2>& local)
const
282 return local[1]*(1-local[0]-local[1])/(beta*(1-beta));
284 double phi4 (
const Dune::FieldVector<double,2>& local)
const
286 return local[0]*local[1]/((1-gamma/sqrt2)*gamma/sqrt2);
288 double phi2 (
const Dune::FieldVector<double,2>& local)
const
290 return local[1]*(beta*(1-gamma/sqrt2)-local[0]*(beta-gamma/sqrt2)-local[1]*(1-gamma/sqrt2))/((1-gamma/sqrt2)*(beta-1));
293 Dune::FieldVector<double,3> p0,p1,p2,p3,p4,p5;
294 double alpha,beta,gamma,sqrt2;
300 template<
typename Gr
idType>
319 static const int dim = GridType::dimension;
320 static const int dimWorld = GridType::dimensionworld;
321 static_assert( (
dimWorld <= 3),
"GmshReader requires dimWorld <= 3." );
330 void readfile(FILE * file,
int cnt,
const char * format,
331 void* t1,
void* t2 = 0,
void* t3 = 0,
void* t4 = 0,
332 void* t5 = 0,
void* t6 = 0,
void* t7 = 0,
void* t8 = 0,
333 void* t9 = 0,
void* t10 = 0)
335 off_t pos = ftello(file);
336 int c = fscanf(file, format, t1, t2, t3, t4, t5, t6, t7, t8, t9, t10);
338 DUNE_THROW(Dune::IOError,
"Error parsing " <<
fileName <<
" "
340 <<
": Expected '" << format <<
"', only read " << c <<
" entries instead of " << cnt <<
".");
348 c = std::fgetc(file);
349 }
while(c !=
'\n' && c != EOF);
367 void read (
const std::string& f)
369 if (
verbose) std::cout <<
"Reading " <<
dim <<
"d Gmsh grid..." << std::endl;
373 FILE* file = fopen(
fileName.c_str(),
"rb");
375 DUNE_THROW(Dune::IOError,
"Could not open " <<
fileName);
387 double version_number;
388 int file_type, data_size;
391 if (strcmp(
buf,
"$MeshFormat")!=0)
392 DUNE_THROW(Dune::IOError,
"expected $MeshFormat in first line");
393 readfile(file,3,
"%lg %d %d\n",&version_number,&file_type,&data_size);
394 if( (version_number < 2.0) || (version_number > 2.2) )
395 DUNE_THROW(Dune::IOError,
"can only read Gmsh version 2 files");
396 if (
verbose) std::cout <<
"version " << version_number <<
" Gmsh file detected" << std::endl;
398 if (strcmp(
buf,
"$EndMeshFormat")!=0)
399 DUNE_THROW(Dune::IOError,
"expected $EndMeshFormat");
405 if (strcmp(
buf,
"$Nodes")!=0)
406 DUNE_THROW(Dune::IOError,
"expected $Nodes");
407 readfile(file,1,
"%d\n",&number_of_nodes);
408 if (
verbose) std::cout <<
"file contains " << number_of_nodes <<
" nodes" << std::endl;
412 std::vector< GlobalVector > nodes( number_of_nodes+1 );
416 for(
int i = 1; i <= number_of_nodes; ++i )
418 readfile(file,4,
"%d %lg %lg %lg\n", &
id, &x[ 0 ], &x[ 1 ], &x[ 2 ] );
420 if (
id > number_of_nodes) {
421 DUNE_THROW(Dune::IOError,
422 "Only dense sequences of node indices are currently supported (node index "
423 <<
id <<
" is invalid).");
428 nodes[
id ][ j ] = x[ j ];
431 if (strcmp(
buf,
"$EndNodes")!=0)
432 DUNE_THROW(Dune::IOError,
"expected $EndNodes");
437 if (strcmp(
buf,
"$Elements")!=0)
438 DUNE_THROW(Dune::IOError,
"expected $Elements");
439 int number_of_elements;
440 readfile(file,1,
"%d\n",&number_of_elements);
441 if (
verbose) std::cout <<
"file contains " << number_of_elements <<
" elements" << std::endl;
448 off_t section_element_offset = ftello(file);
449 std::map<int,unsigned int>
renumber;
450 for (
int i=1; i<=number_of_elements; i++)
452 int id, elm_type, number_of_tags;
453 readfile(file,3,
"%d %d %d ",&
id,&elm_type,&number_of_tags);
454 for (
int k=1; k<=number_of_tags; k++)
472 if (strcmp(
buf,
"$EndElements")!=0)
473 DUNE_THROW(Dune::IOError,
"expected $EndElements");
481 fseeko(file, section_element_offset, SEEK_SET);
484 for (
int i=1; i<=number_of_elements; i++)
486 int id, elm_type, number_of_tags;
487 readfile(file,3,
"%d %d %d ",&
id,&elm_type,&number_of_tags);
488 int physical_entity = -1;
490 for (
int k=1; k<=number_of_tags; k++)
494 if (k==1) physical_entity = blub;
499 if (strcmp(
buf,
"$EndElements")!=0)
500 DUNE_THROW(Dune::IOError,
"expected $EndElements");
511 std::map<int,unsigned int> &
renumber,
512 const std::vector< GlobalVector > & nodes)
515 const int nDofs[16] = {-1, 2, 3, 4, 4, 8, 6, 5, 3, 6, -1, 10, -1, -1, -1, 1};
516 const int nVertices[16] = {-1, 2, 3, 4, 4, 8, 6, 5, 2, 3, -1, 4, -1, -1, -1, 1};
517 const int elementDim[16] = {-1, 1, 2, 2, 3, 3, 3, 3, 1, 2, -1, 3, -1, -1, -1, 0};
520 if ( not (elm_type > 0 && elm_type <= 15
521 && (elementDim[elm_type] ==
dim || elementDim[elm_type] == (
dim-1) ) ) )
528 std::string formatString =
"%d";
529 for (
int i=1; i<nDofs[elm_type]; i++)
530 formatString +=
" %d";
531 formatString +=
"\n";
534 std::vector<int> elementDofs(10);
536 readfile(file,nDofs[elm_type], formatString.c_str(),
537 &(elementDofs[0]),&(elementDofs[1]),&(elementDofs[2]),
538 &(elementDofs[3]),&(elementDofs[4]),&(elementDofs[5]),
539 &(elementDofs[6]),&(elementDofs[7]),&(elementDofs[8]),
543 for (
int i=0; i<nVertices[elm_type]; i++)
547 factory.insertVertex(nodes[elementDofs[i]]);
551 if (elementDim[elm_type] ==
dim)
561 template <
class E,
class V,
class V2>
568 DUNE_THROW(Dune::IOError,
"tried to create a 3D boundary segment in a non-3D Grid");
572 template <
class E,
class V>
574 const std::vector<FieldVector<double, 3> >& nodes,
575 const E& elementDofs,
579 std::array<FieldVector<double,dimWorld>, 6> v;
580 for (
int i=0; i<6; i++)
582 v[i][j] = nodes[elementDofs[i]][j];
588 factory.insertBoundarySegment( vertices,
599 std::map<int,unsigned int> &
renumber,
600 const std::vector< GlobalVector > & nodes,
601 const int physical_entity)
604 const int nDofs[16] = {-1, 2, 3, 4, 4, 8, 6, 5, 3, 6, -1, 10, -1, -1, -1, 1};
605 const int nVertices[16] = {-1, 2, 3, 4, 4, 8, 6, 5, 2, 3, -1, 4, -1, -1, -1, 1};
606 const int elementDim[16] = {-1, 1, 2, 2, 3, 3, 3, 3, 1, 2, -1, 3, -1, -1, -1, 0};
609 if ( not (elm_type > 0 && elm_type <= 15
610 && (elementDim[elm_type] ==
dim || elementDim[elm_type] == (
dim-1) ) ) )
617 std::string formatString =
"%d";
618 for (
int i=1; i<nDofs[elm_type]; i++)
619 formatString +=
" %d";
620 formatString +=
"\n";
623 std::vector<int> elementDofs(10);
625 readfile(file,nDofs[elm_type], formatString.c_str(),
626 &(elementDofs[0]),&(elementDofs[1]),&(elementDofs[2]),
627 &(elementDofs[3]),&(elementDofs[4]),&(elementDofs[5]),
628 &(elementDofs[6]),&(elementDofs[7]),&(elementDofs[8]),
635 std::swap(elementDofs[2],elementDofs[3]);
638 std::swap(elementDofs[2],elementDofs[3]);
639 std::swap(elementDofs[6],elementDofs[7]);
642 std::swap(elementDofs[2],elementDofs[3]);
648 std::vector<unsigned int> vertices(nVertices[elm_type]);
650 for (
int i=0; i<nVertices[elm_type]; i++)
651 vertices[i] =
renumber[elementDofs[i]];
654 if (elementDim[elm_type] ==
dim) {
694 factory.insertBoundarySegment(vertices);
698 factory.insertBoundarySegment(vertices);
702 factory.insertBoundarySegment(vertices);
706 factory.insertBoundarySegment(vertices);
710 std::array<FieldVector<double,dimWorld>, 3> v;
712 v[0][i] = nodes[elementDofs[0]][i];
713 v[1][i] = nodes[elementDofs[2]][i];
714 v[2][i] = nodes[elementDofs[1]][i];
718 factory.insertBoundarySegment(vertices,
727 DUNE_THROW(Dune::IOError,
"GmshReader does not support using element-type " << elm_type <<
" for boundary segments");
737 if (elementDim[elm_type] ==
dim) {
767 static_cast<int>(a) |
static_cast<int>(b)
774 return static_cast<int>(a) &
static_cast<int>(b);
803 template<
typename Gr
idType>
827 const std::string &fileName,
828 std::vector<int>& boundarySegmentToPhysicalEntity,
829 std::vector<int>& elementToPhysicalEntity,
830 bool verbose,
bool insertBoundarySegments)
834 GmshReaderQuadraticBoundarySegment< Grid::dimension, Grid::dimensionworld >::registerFactory();
838 factory.
comm().barrier();
842 if (factory.
comm().rank() == 0)
845 parser.
read(fileName);
847 boundarySegmentToPhysicalEntity = std::move(parser.
boundaryIdMap());
852 boundarySegmentToPhysicalEntity = {};
853 elementToPhysicalEntity = {};
878 static T &discarded(T &&value) {
return value; }
881 std::vector<int> *data_ =
nullptr;
882 DataArg(std::vector<int> &data) : data_(&data) {}
883 DataArg(
const decltype(std::ignore)&) {}
887 struct DataFlagArg : DataArg {
889 using DataArg::DataArg;
890 DataFlagArg(
bool flag) : flag_(flag) {}
902 static std::unique_ptr<Grid>
read (
const std::string& fileName,
bool verbose =
true,
bool insertBoundarySegments=
true)
907 read(factory, fileName, verbose, insertBoundarySegments);
931 static std::unique_ptr<Grid>
read (
const std::string& fileName,
932 std::vector<int>& boundarySegmentToPhysicalEntity,
933 std::vector<int>& elementToPhysicalEntity,
934 bool verbose =
true,
bool insertBoundarySegments=
true)
940 factory, fileName, boundarySegmentToPhysicalEntity,
941 elementToPhysicalEntity, verbose, insertBoundarySegments
949 bool verbose =
true,
bool insertBoundarySegments=
true)
952 factory, fileName, discarded(std::vector<int>{}),
953 discarded(std::vector<int>{}), verbose, insertBoundarySegments
982 const std::string &fileName,
983 DataFlagArg boundarySegmentData,
989 boundarySegmentData.data_
990 ? *boundarySegmentData.data_ : discarded(std::vector<int>{}),
992 ? *
elementData.data_ : discarded(std::vector<int>{}),
994 boundarySegmentData.flag_ || boundarySegmentData.data_
1019 const std::string& fileName,
1020 std::vector<int>& boundarySegmentToPhysicalEntity,
1021 std::vector<int>& elementToPhysicalEntity,
1022 bool verbose,
bool insertBoundarySegments)
1025 factory, fileName, boundarySegmentToPhysicalEntity,
1026 elementToPhysicalEntity, verbose, insertBoundarySegments
1033 [[deprecated(
"Will be removed after 2.8. Either use other constructors or use static methods without constructing an object")]]
1039 Opts::verbose | Opts::insertBoundarySegments | Opts::readElementData | Opts::readBoundaryData;
1068 gridFactory_ = std::make_unique<Dune::GridFactory<Grid>>();
1069 readGridFile(fileName, *gridFactory_, options);
1082 readGridFile(fileName, factory, options);
1089 return elementIndexToGmshPhysicalEntity_;
1095 checkBoundaryData();
1096 return boundarySegmentIndexToGmshPhysicalEntity_;
1104 {
return hasElementData_ && !extractedElementData_; }
1111 {
return hasBoundaryData_ && !extractedBoundaryData_; }
1117 extractedElementData_ =
true;
1118 return std::move(elementIndexToGmshPhysicalEntity_);
1124 checkBoundaryData();
1125 extractedBoundaryData_ =
true;
1126 return std::move(boundarySegmentIndexToGmshPhysicalEntity_);
1133 DUNE_THROW(Dune::InvalidStateException,
1134 "This GmshReader has been constructed with a Dune::GridFactory. "
1135 <<
"This grid factory has been filled with all information to create a grid. "
1136 <<
"Please use this factory to create the grid by calling factory.createGrid(). "
1137 <<
"Alternatively use the constructor without passing the factory in combination with this member function."
1140 return gridFactory_->createGrid();
1146 void checkElementData ()
const
1148 if (!hasElementData_)
1149 DUNE_THROW(Dune::InvalidStateException,
1150 "This GmshReader has been constructed without the option 'readElementData'. "
1151 <<
"Please enable reading element data by passing the option 'Gmsh::ReaderOpts::readElementData' "
1152 <<
"to the constructor of this class."
1155 if (extractedElementData_)
1156 DUNE_THROW(Dune::InvalidStateException,
1157 "The element data has already been extracted from this GmshReader "
1158 <<
"via a function call to reader.extractElementData(). Use the extraced data or "
1159 <<
"read the grid data from file again by constructing a new reader."
1163 void checkBoundaryData ()
const
1165 if (!hasBoundaryData_)
1166 DUNE_THROW(Dune::InvalidStateException,
1167 "This GmshReader has been constructed without the option 'readBoundaryData'. "
1168 <<
"Please enable reading boundary data by passing the option 'Gmsh::ReaderOpts::readBoundaryData' "
1169 <<
"to the constructor of this class."
1172 if (extractedBoundaryData_)
1173 DUNE_THROW(Dune::InvalidStateException,
1174 "The boundary data has already been extracted from this GmshReader "
1175 <<
"via a function call to reader.extractBoundaryData(). Use the extraced data or "
1176 <<
"read the grid data from file again by constructing a new reader."
1180 void readGridFile (
const std::string& fileName, GridFactory<Grid>& factory,
Gmsh::ReaderOptions options)
1188 factory, fileName, boundarySegmentIndexToGmshPhysicalEntity_,
1189 elementIndexToGmshPhysicalEntity_, verbose,
1190 readBoundaryData || insertBoundarySegments
1194 if (!readBoundaryData)
1195 boundarySegmentIndexToGmshPhysicalEntity_ = std::vector<int>{};
1196 if (!readElementData)
1197 elementIndexToGmshPhysicalEntity_ = std::vector<int>{};
1203 std::unique_ptr<Dune::GridFactory<Grid>> gridFactory_;
1205 std::vector<int> elementIndexToGmshPhysicalEntity_;
1206 std::vector<int> boundarySegmentIndexToGmshPhysicalEntity_;
1208 bool hasElementData_;
1209 bool hasBoundaryData_;
1212 bool extractedElementData_ =
false;
1213 bool extractedBoundaryData_ =
false;
Base class for grid boundary segments of arbitrary geometry.
ReaderOptions
Option for the Gmsh mesh file reader.
Definition: gmshreader.hh:756
void swap(Dune::PersistentContainer< G, T > &a, Dune::PersistentContainer< G, T > &b)
Definition: utility/persistentcontainer.hh:83
Include standard header files.
Definition: agrid.hh:60
static const int dimWorld
Definition: misc.hh:46
ALBERTA REAL_D GlobalVector
Definition: misc.hh:50
constexpr bool operator&(ReaderOptions a, ReaderOptions b)
query operator for reader options (is b set in a)
Definition: gmshreader.hh:772
constexpr ReaderOptions operator|(ReaderOptions a, ReaderOptions b)
composition operator for reader options
Definition: gmshreader.hh:764
int renumber(const Dune::GeometryType &t, int i)
renumber VTK <-> Dune
Definition: common.hh:186
@ line
Definition: common.hh:134
@ pyramid
Definition: common.hh:141
@ quadrilateral
Definition: common.hh:137
@ tetrahedron
Definition: common.hh:138
@ prism
Definition: common.hh:140
@ hexahedron
Definition: common.hh:139
@ triangle
Definition: common.hh:135
Base class for classes implementing geometries of boundary segments.
Definition: boundarysegment.hh:94
Communication comm() const
Return the Communication used by the grid factory.
Definition: common/gridfactory.hh:297
Provide a generic factory class for unstructured grids.
Definition: common/gridfactory.hh:314
virtual std::unique_ptr< GridType > createGrid()
Finalize grid creation and hand over the grid.
Definition: common/gridfactory.hh:372
Options for read operation.
Definition: gmshreader.hh:39
GeometryOrder
Definition: gmshreader.hh:40
@ firstOrder
edges are straight lines.
Definition: gmshreader.hh:42
@ secondOrder
quadratic boundary approximation.
Definition: gmshreader.hh:44
dimension independent parts for GmshReaderParser
Definition: gmshreader.hh:302
void pass1HandleElement(FILE *file, const int elm_type, std::map< int, unsigned int > &renumber, const std::vector< GlobalVector > &nodes)
Process one element during the first pass through the list of all elements.
Definition: gmshreader.hh:510
static const int dimWorld
Definition: gmshreader.hh:320
Dune::GridFactory< GridType > & factory
Definition: gmshreader.hh:305
std::vector< int > & boundaryIdMap()
Definition: gmshreader.hh:357
std::vector< int > & elementIndexMap()
Definition: gmshreader.hh:362
unsigned int number_of_real_vertices
Definition: gmshreader.hh:308
void boundarysegment_insert(const std::vector< FieldVector< double, 3 > > &nodes, const E &elementDofs, const V &vertices)
Definition: gmshreader.hh:573
GmshReaderParser(Dune::GridFactory< GridType > &_factory, bool v, bool i)
Definition: gmshreader.hh:354
int element_count
Definition: gmshreader.hh:310
void read(const std::string &f)
Definition: gmshreader.hh:367
void skipline(FILE *file)
Definition: gmshreader.hh:344
void readfile(FILE *file, int cnt, const char *format, void *t1, void *t2=0, void *t3=0, void *t4=0, void *t5=0, void *t6=0, void *t7=0, void *t8=0, void *t9=0, void *t10=0)
Definition: gmshreader.hh:330
std::vector< int > element_index_to_physical_entity
Definition: gmshreader.hh:316
virtual void pass2HandleElement(FILE *file, const int elm_type, std::map< int, unsigned int > &renumber, const std::vector< GlobalVector > &nodes, const int physical_entity)
Process one element during the second pass through the list of all elements.
Definition: gmshreader.hh:598
static const int dim
Definition: gmshreader.hh:319
FieldVector< double, dimWorld > GlobalVector
Definition: gmshreader.hh:324
std::string fileName
Definition: gmshreader.hh:313
int boundary_element_count
Definition: gmshreader.hh:309
void boundarysegment_insert(const V &, const E &, const V2 &)
Definition: gmshreader.hh:562
bool verbose
Definition: gmshreader.hh:306
std::vector< int > boundary_id_to_physical_entity
Definition: gmshreader.hh:315
char buf[512]
Definition: gmshreader.hh:312
bool insert_boundary_segments
Definition: gmshreader.hh:307
Read Gmsh mesh file.
Definition: gmshreader.hh:805
static std::unique_ptr< Grid > read(const std::string &fileName, std::vector< int > &boundarySegmentToPhysicalEntity, std::vector< int > &elementToPhysicalEntity, bool verbose=true, bool insertBoundarySegments=true)
Read Gmsh file, possibly with data.
Definition: gmshreader.hh:931
const std::vector< int > & elementData() const
Access element data (maps element index to Gmsh physical entity)
Definition: gmshreader.hh:1086
static void read(Dune::GridFactory< Grid > &factory, const std::string &fileName, DataFlagArg boundarySegmentData, DataArg elementData, bool verbose=true)
read Gmsh file, possibly with data
Definition: gmshreader.hh:981
static std::unique_ptr< Grid > read(const std::string &fileName, bool verbose=true, bool insertBoundarySegments=true)
Definition: gmshreader.hh:902
static void read(Dune::GridFactory< Grid > &factory, const std::string &fileName, bool verbose=true, bool insertBoundarySegments=true)
Definition: gmshreader.hh:948
GridType Grid
Definition: gmshreader.hh:894
std::unique_ptr< Grid > createGrid()
Create the grid.
Definition: gmshreader.hh:1130
std::vector< int > extractBoundaryData()
Erase boundary data from reader and return the data.
Definition: gmshreader.hh:1122
static void read(Dune::GridFactory< Grid > &factory, const std::string &fileName, std::vector< int > &boundarySegmentToPhysicalEntity, std::vector< int > &elementToPhysicalEntity, bool verbose, bool insertBoundarySegments)
Read Gmsh file, possibly with data.
Definition: gmshreader.hh:1018
bool hasElementData() const
If element data is available.
Definition: gmshreader.hh:1103
bool hasBoundaryData() const
If boundary data is available.
Definition: gmshreader.hh:1110
static constexpr Opts defaultOpts
Definition: gmshreader.hh:1038
GmshReader(const std::string &fileName, GridFactory< Grid > &factory, Gmsh::ReaderOptions options=defaultOpts)
Construct a Gmsh reader object from a file name and a grid factory.
Definition: gmshreader.hh:1079
GmshReader(const std::string &fileName, Gmsh::ReaderOptions options=defaultOpts)
Construct a Gmsh reader object (alternatively use one of the static member functions)
Definition: gmshreader.hh:1065
std::vector< int > extractElementData()
Erase element data from reader and return the data.
Definition: gmshreader.hh:1114
const std::vector< int > & boundaryData() const
Access boundary data (maps boundary segment index to Gmsh physical entity)
Definition: gmshreader.hh:1093
GmshReader()=default
Dynamic Gmsh reader interface.
Provide a generic factory class for unstructured grids.