Dune Core Modules (2.11.0)

gridcreatorinterface.hh
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <tuple>
6#include <vector>
7
9
10namespace Dune
11{
12 namespace Gmsh4
13 {
15
21 template <class G, class Derived>
23 {
24 public:
25 using Grid = G;
26 using GlobalCoordinate = typename Grid::template Codim<0>::Entity::Geometry::GlobalCoordinate;
27
28 public:
31 : factory_(&factory)
32 {}
33
35 template <class NodeAttributes>
36 void insertVertices (std::size_t numNodes,
37 std::pair<std::size_t,std::size_t> nodeTagRange,
38 std::vector<NodeAttributes> const& entityBlocks)
39 {
40 asDerived().insertVerticesImpl(numNodes, nodeTagRange, entityBlocks);
41 }
42
44 template <class ElementAttributes, class BoundaryEntities>
45 void insertElements (std::size_t numElements,
46 std::pair<std::size_t,std::size_t> elementTagRange,
47 std::vector<ElementAttributes> const& entityBlocks,
48 BoundaryEntities const& boundaryEntities)
49 {
50 asDerived().insertElementsImpl(numElements, elementTagRange, entityBlocks, boundaryEntities);
51 }
52
54 void insertPieces (std::vector<std::string> const& pieces)
55 {
56 asDerived().insertPiecesImpl(pieces);
57 }
58
61 {
62 return *factory_;
63 }
64
66 GridFactory<Grid> const& factory () const
67 {
68 return *factory_;
69 }
70
72 auto comm () const
73 {
74 return MPIHelper::getCommunication();
75 }
76
77 protected: // cast to derived type
78
79 Derived& asDerived ()
80 {
81 return static_cast<Derived&>(*this);
82 }
83
84 const Derived& asDerived () const
85 {
86 return static_cast<const Derived&>(*this);
87 }
88
89 public: // default implementations
90
91 template <class NodeAttributes>
92 void insertVerticesImpl (std::size_t numNodes,
93 std::pair<std::size_t,std::size_t> nodeTagRange,
94 std::vector<NodeAttributes> const& entityBlocks)
95 {
96 /* do nothing */
97 }
98
99 template <class ElementAttributes, class BoundaryEntities>
100 void insertElementsImpl (std::size_t numElements,
101 std::pair<std::size_t,std::size_t> elementTagRange,
102 std::vector<ElementAttributes> const& entityBlocks,
103 BoundaryEntities const& boundaryEntities)
104 {
105 /* do nothing */
106 }
107
108 void insertPiecesImpl (std::vector<std::string> const&)
109 {
110 /* do nothing */;
111 }
112
113 protected:
114 GridFactory<Grid>* factory_;
115 };
116
117 } // end namespace Gmsh4
118} // end namespace Dune
Base class for grid creators in a CRTP style.
Definition: gridcreatorinterface.hh:23
GridFactory< Grid > const & factory() const
Return the associated (const) GridFactory.
Definition: gridcreatorinterface.hh:66
void insertElements(std::size_t numElements, std::pair< std::size_t, std::size_t > elementTagRange, std::vector< ElementAttributes > const &entityBlocks, BoundaryEntities const &boundaryEntities)
Create elements based on type and connectivity description.
Definition: gridcreatorinterface.hh:45
auto comm() const
Return the mpi collective communicator.
Definition: gridcreatorinterface.hh:72
GridCreatorInterface(GridFactory< Grid > &factory)
Constructor. Stores a reference to the passed GridFactory.
Definition: gridcreatorinterface.hh:30
void insertVertices(std::size_t numNodes, std::pair< std::size_t, std::size_t > nodeTagRange, std::vector< NodeAttributes > const &entityBlocks)
Insert all points as vertices into the factory.
Definition: gridcreatorinterface.hh:36
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition: gridcreatorinterface.hh:60
void insertPieces(std::vector< std::string > const &pieces)
Insert part of a grid stored in file into factory.
Definition: gridcreatorinterface.hh:54
Provide a generic factory class for unstructured grids.
Dune namespace
Definition: alignedallocator.hh:13
Static tag representing a codimension.
Definition: dimension.hh:24
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 14, 23:39, 2026)