4#ifndef DUNE_GRID_IO_FILE_GMSH_GRIDCREATORS_CONTINUOUSGRIDCREATOR_HH
5#define DUNE_GRID_IO_FILE_GMSH_GRIDCREATORS_CONTINUOUSGRIDCREATOR_HH
13#include <dune/common/hybridutilities.hh>
16#include <dune/grid/io/file/gmsh/types.hh>
17#include <dune/grid/io/file/gmsh/gridcreatorinterface.hh>
20namespace Dune::Impl::Gmsh
25 struct ContinuousGridCreator
26 :
public GridCreatorInterface<Grid, ContinuousGridCreator<Grid> >
28 using Super = GridCreatorInterface<Grid, ContinuousGridCreator<Grid> >;
29 using GlobalCoordinate =
typename Super::GlobalCoordinate;
30 using Nodes = std::vector<GlobalCoordinate>;
37 template <
class NodeAttributes>
38 void insertVerticesImpl (std::size_t numNodes,
39 std::pair<std::size_t,std::size_t> nodeTagRange,
40 std::vector<NodeAttributes>
const& entityBlocks)
42 vertexMap_.resize(nodeTagRange.second - nodeTagRange.first + 1);
43 vertexShift_ = nodeTagRange.first;
44 nodes_.resize(numNodes);
46 size_t vertexIndex = 0;
48 for (
auto const& entityBlock : entityBlocks) {
49 for (
auto const& node : entityBlock.nodes) {
50 for (std::size_t j = 0; j < p.size(); ++j)
52 nodes_[vertexIndex] = p;
53 vertexMap_[node.tag - vertexShift_] = vertexIndex++;
58 template <
class ElementAttributes,
class BoundaryEntities>
59 void insertElementsImpl (std::size_t ,
60 std::pair<std::size_t,std::size_t> ,
61 std::vector<ElementAttributes>
const& entityBlocks,
62 BoundaryEntities
const& )
64 std::vector<unsigned int> connectivity;
65 std::size_t cornerIndex = 0;
66 std::vector<std::int64_t> cornerVertices(nodes_.size(), -1);
68 for (
auto const& entityBlock : entityBlocks) {
72 auto type = gmshNumberToGeometryType(entityBlock.elementType);
76 auto refElem = referenceElement<double,Grid::dimension>(cell.type());
79 for (
auto const& element : entityBlock.elements) {
80 GMSH4_ASSERT(element.nodes.size() >= connectivity.size());
81 for (std::size_t j = 0; j < connectivity.size(); ++j) {
82 auto index = vertexMap_[element.nodes[j] - vertexShift_];
83 auto&
vertex = cornerVertices.at(index);
85 factory().insertVertex(nodes_.at(index));
88 connectivity[cell.gmshVertexToDuneVertex(j)] =
vertex;
91 factory().insertElement(cell.type(), connectivity);
102 std::vector<std::size_t> vertexMap_;
103 std::size_t vertexShift_ = 0;
107 template <
class Gr
id>
108 ContinuousGridCreator(GridFactory<Grid>&)
109 -> ContinuousGridCreator<Grid>;
static constexpr int dimension
The dimension of the grid.
Definition: grid.hh:387
Provide a generic factory class for unstructured grids.
A few common exception classes.
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
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:492