dune-vtk 2.12
Loading...
Searching...
No Matches
gridcreatorinterface.hh
Go to the documentation of this file.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
9#include <dune/grid/common/gridfactory.hh>
10
11namespace Dune::Vtk
12{
14
21 template <class GridType, class DerivedType>
23 {
24 public:
25 using Grid = GridType;
27 using Derived = DerivedType;
28
29 public:
34
39
41 template <class... Args,
43 GridCreatorInterface (Args&&... args)
44 : factory_(std::make_shared<GridFactory<Grid>>(std::forward<Args>(args)...))
45 {}
46
49 std::vector<std::uint64_t> const& point_ids)
50 {
51 asDerived().insertVerticesImpl(points, point_ids);
52 }
53
56 std::vector<std::int64_t> const& offsets,
57 std::vector<std::int64_t> const& connectivity)
58 {
59 asDerived().insertElementsImpl(types, offsets, connectivity);
60 }
61
64 {
65 asDerived().insertPiecesImpl(pieces);
66 }
67
70 {
71 return std::unique_ptr<Grid>(factory_->createGrid());
72 }
73
76 {
77 return *factory_;
78 }
79
81 GridFactory<Grid> const& factory () const
82 {
83 return *factory_;
84 }
85
87 auto comm () const
88 {
90 }
91
92 protected: // cast to derived type
93
95 {
96 return static_cast<Derived&>(*this);
97 }
98
99 const Derived& asDerived () const
100 {
101 return static_cast<const Derived&>(*this);
102 }
103
104 public: // default implementations
105
108 {
109 /* do nothing */
110 }
111
115 {
116 /* do nothing */
117 }
118
120 {
121 /* do nothing */;
122 }
123
124 protected:
126 };
127
128} // end namespace Dune::Vtk
STL namespace.
Definition writer.hh:16
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
static Communication< MPICommunicator > getCommunication()
Base class for grid creators in a CRTP style.
Definition gridcreatorinterface.hh:23
void insertElementsImpl(std::vector< std::uint8_t > const &, std::vector< std::int64_t > const &, std::vector< std::int64_t > const &)
Definition gridcreatorinterface.hh:112
GridCreatorInterface(Args &&... args)
Constructor. Construct a new GridFactory from the passed arguments.
Definition gridcreatorinterface.hh:43
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:75
typename Grid::template Codim< 0 >::Entity::Geometry::GlobalCoordinate GlobalCoordinate
Definition gridcreatorinterface.hh:26
Derived & asDerived()
Definition gridcreatorinterface.hh:94
std::unique_ptr< Grid > createGrid() const
Construct the actual grid using the GridFactory.
Definition gridcreatorinterface.hh:69
void insertPiecesImpl(std::vector< std::string > const &)
Definition gridcreatorinterface.hh:119
const Derived & asDerived() const
Definition gridcreatorinterface.hh:99
std::shared_ptr< GridFactory< Grid > > factory_
Definition gridcreatorinterface.hh:125
DerivedType Derived
Definition gridcreatorinterface.hh:27
auto comm() const
Return the mpi collective communicator.
Definition gridcreatorinterface.hh:87
void insertPieces(std::vector< std::string > const &pieces)
Insert part of a grid stored in file into factory.
Definition gridcreatorinterface.hh:63
GridType Grid
Definition gridcreatorinterface.hh:25
GridCreatorInterface(std::shared_ptr< GridFactory< Grid > > factory)
Constructor. Store the shared_ptr to the GridFactory.
Definition gridcreatorinterface.hh:36
GridCreatorInterface(GridFactory< Grid > &factory)
Constructor. Stores a reference to the passed GridFactory.
Definition gridcreatorinterface.hh:31
GridFactory< Grid > const & factory() const
Return the associated (const) GridFactory.
Definition gridcreatorinterface.hh:81
void insertVerticesImpl(std::vector< GlobalCoordinate > const &, std::vector< std::uint64_t > const &)
Definition gridcreatorinterface.hh:106
void insertVertices(std::vector< GlobalCoordinate > const &points, std::vector< std::uint64_t > const &point_ids)
Insert all points as vertices into the factory.
Definition gridcreatorinterface.hh:48
void insertElements(std::vector< std::uint8_t > const &types, std::vector< std::int64_t > const &offsets, std::vector< std::int64_t > const &connectivity)
Create elements based on type and connectivity description.
Definition gridcreatorinterface.hh:55