10#include <dune/gmsh4/filereader.hh>
11#include <dune/gmsh4/gridcreators/continuousgridcreator.hh>
29 template <
class Gr
id,
class Gr
idCreator = Gmsh4::ContinuousGr
idCreator<Gr
id>,
class SizeType = std::
size_t>
31 :
public Gmsh4::FileReader<Grid, Gmsh4Reader<Grid, GridCreator>>
35 NO_SECTION = 0, MESH_FORMAT, PHYSICAL_NAMES, ENTITIES, PARTITIONED_ENTITIES, NODES, ELEMENTS, PERIODIC,
36 GHOST_ELEMENTS, PARAMETRIZATION, NODE_DATA, ELEMENT_DATA, ELEMENT_NODE_DATA, INTERPOLATION_SCHEME
40 using GlobalCoordinate =
typename Entity::Geometry::GlobalCoordinate;
43 using size_type = SizeType;
46 template <
class... Args,
47 std::enable_if_t<std::is_constructible<GridCreator, Args...>::value,
int> = 0>
49 : creator_(
std::make_shared<GridCreator>(
std::forward<Args>(args)...))
59 : creator_(
std::move(creator))
68 void read (std::string
const& filename,
bool fillCreator =
true);
96 std::vector<std::string>
const&
pieces ()
const
103 static void fillFactoryImpl (
GridFactory<Grid>& factory, std::string
const& filename)
106 reader.read(filename);
112 void readValueBinary(std::ifstream& input, T &v);
113 void readMeshFormat (std::ifstream& input,
114 double& version,
int& file_type,
int& data_size);
116 void readPhysicalNames (std::ifstream& input);
117 void readEntitiesAscii (std::ifstream& input);
118 void readEntitiesBinary (std::ifstream& input);
119 void readPartitionedEntitiesAscii (std::ifstream& input);
120 void readPartitionedEntitiesBinary (std::ifstream& input);
121 void readNodesAscii (std::ifstream& input);
122 void readNodesBinary (std::ifstream& input);
123 void readElementsAscii (std::ifstream& input);
124 void readElementsBinary (std::ifstream& input);
125 void readPeriodic (std::ifstream& input);
126 void readGhostElements (std::ifstream& input);
127 void readParametrization (std::ifstream& input);
128 void readNodeData (std::ifstream& input);
129 void readElementData (std::ifstream& input);
130 void readElementNodeData (std::ifstream& input);
131 void readInterpolationScheme (std::ifstream& input);
134 bool isSection (std::string
line,
137 Sections parent = Sections::NO_SECTION)
const
139 bool result =
line.substr(1, key.length()) == key;
140 if (result && current != parent)
145 void readString(std::istream& , std::string& name)
156 physicalNames_.clear();
164 ghostEntities_.clear();
165 partitionedPoints_.clear();
166 partitionedCurves_.clear();
167 partitionedSurfaces_.clear();
168 partitionedVolumes_.clear();
181 ghostElements_.clear();
182 parametrization_.clear();
184 elementData_.clear();
185 elementNodeData_.clear();
186 interpolationScheme_.clear();
191 return MPIHelper::getCommunication();
196 struct PhysicalNamesAttributes;
197 struct PointAttributes;
198 struct EntityAttributes;
200 template <
class Attr>
201 struct PartitionedAttributes :
public Attr
205 std::vector<int> partitions;
208 struct GhostAttributes;
209 struct NodeAttributes;
210 struct ElementAttributes;
211 struct PeriodicAttributes;
213 struct GhostElementAttributes {};
214 struct ParametrizationAttributes {};
215 struct NodeDataAttributes {};
216 struct ElementDataAttributes {};
217 struct ElementNodeDataAttributes {};
218 struct InterpolationSchemeAttributes {};
221 std::shared_ptr<GridCreator> creator_ =
nullptr;
226 std::vector<std::string> pieces_;
229 std::vector<PhysicalNamesAttributes> physicalNames_;
232 std::vector<PointAttributes> points_;
233 std::vector<EntityAttributes> curves_;
234 std::vector<EntityAttributes> surfaces_;
235 std::vector<EntityAttributes> volumes_;
238 size_type numPartitions_ = 0;
239 std::vector<GhostAttributes> ghostEntities_;
240 std::vector<PartitionedAttributes<PointAttributes>> partitionedPoints_;
241 std::vector<PartitionedAttributes<EntityAttributes>> partitionedCurves_;
242 std::vector<PartitionedAttributes<EntityAttributes>> partitionedSurfaces_;
243 std::vector<PartitionedAttributes<EntityAttributes>> partitionedVolumes_;
245 size_type numNodes_ = 0;
246 size_type minNodeTag_ = 0;
247 size_type maxNodeTag_ = 0;
248 std::vector<NodeAttributes> nodes_;
250 size_type numElements_ = 0;
251 size_type minElementTag_ = 0;
252 size_type maxElementTag_ = 0;
253 std::vector<ElementAttributes> elements_;
254 std::vector<PeriodicAttributes> periodic_;
255 std::vector<GhostElementAttributes> ghostElements_;
256 std::vector<ParametrizationAttributes> parametrization_;
257 std::vector<NodeDataAttributes> nodeData_;
258 std::vector<ElementDataAttributes> elementData_;
259 std::vector<ElementNodeDataAttributes> elementNodeData_;
260 std::vector<InterpolationSchemeAttributes> interpolationScheme_;
263 static std::map<int, size_type> elementType_;
266 static std::map<std::string, Sections> sections_;
270 template <
class Gr
id>
271 Gmsh4Reader (GridFactory<Grid>&)
272 -> Gmsh4Reader<Grid, Gmsh4::ContinuousGridCreator<Grid>>;
274 template <
class GridCreator,
275 class = std::void_t<typename GridCreator::Grid>>
276 Gmsh4Reader (GridCreator&)
277 -> Gmsh4Reader<typename GridCreator::Grid, GridCreator>;
279 template <
class GridCreator,
280 class = std::void_t<typename GridCreator::Grid>>
281 Gmsh4Reader (std::shared_ptr<GridCreator>)
282 -> Gmsh4Reader<typename GridCreator::Grid, GridCreator>;
286#include "gmsh4reader.impl.hh"
Base class for Dune-Exceptions.
Definition: exceptions.hh:98
File-Reader for GMsh unstructured .msh files.
Definition: gmsh4reader.hh:32
std::vector< std::string > const & pieces() const
Return the filenames of parallel pieces.
Definition: gmsh4reader.hh:96
Gmsh4Reader(Args &&... args)
Constructor. Creates a new GridCreator with the passed factory.
Definition: gmsh4reader.hh:48
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
Gmsh4Reader(std::shared_ptr< GridCreator > creator)
Constructor. Stores the shared_ptr.
Definition: gmsh4reader.hh:58
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
Gmsh4Reader(GridCreator &creator)
Constructor. Stores the references in a non-destroying shared_ptr.
Definition: gmsh4reader.hh:53
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
Default exception for dummy implementations.
Definition: exceptions.hh:357
#define DUNE_THROW(E,...)
Definition: exceptions.hh:314
constexpr GeometryType line
GeometryType representing a line.
Definition: type.hh:498
Dune namespace
Definition: alignedallocator.hh:13
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
Create a shared_ptr for a stack-allocated object.
Definition: shared_ptr.hh:72
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
This file implements several utilities related to std::shared_ptr.
Static tag representing a codimension.
Definition: dimension.hh:24