dune-vtk 2.12
Loading...
Searching...
No Matches
gridcreatorinterface.hh
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright © DUNE Project contributors, see file AUTHORS.md
2// SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception OR LGPL-3.0-or-later
3#pragma once
4
5#include <cstdint>
6#include <string>
7#include <vector>
8
11#include <dune/grid/common/gridfactory.hh>
12
13namespace Dune::Vtk
14{
16
23 template <class GridType, class DerivedType>
25 {
26 public:
27 using Grid = GridType;
29 using Derived = DerivedType;
30
31 public:
36
41
43 template <class... Args,
46 : factory_(std::make_shared<GridFactory<Grid>>(std::forward<Args>(args)...))
47 {}
48
52 {
53 asDerived().insertVerticesImpl(points, point_ids);
54 }
55
58 std::vector<std::int64_t> const& offsets,
59 std::vector<std::int64_t> const& connectivity)
60 {
61 asDerived().insertElementsImpl(types, offsets, connectivity);
62 }
63
66 {
67 asDerived().insertPiecesImpl(pieces);
68 }
69
72 {
73 return std::unique_ptr<Grid>(factory_->createGrid());
74 }
75
78 {
79 return *factory_;
80 }
81
83 GridFactory<Grid> const& factory () const
84 {
85 return *factory_;
86 }
87
89 auto comm () const
90 {
92 }
93
94 protected: // cast to derived type
95
97 {
98 return static_cast<Derived&>(*this);
99 }
100
101 const Derived& asDerived () const
102 {
103 return static_cast<const Derived&>(*this);
104 }
105
106 public: // default implementations
107
110 {
111 /* do nothing */
112 }
113
117 {
118 /* do nothing */
119 }
120
122 {
123 /* do nothing */;
124 }
125
126 protected:
128 };
129
130} // end namespace Dune::Vtk
STL namespace.
Definition datacollector.hh:19
std::shared_ptr< T > stackobject_to_shared_ptr(T &t)
static Communication< MPICommunicator > getCommunication()
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
Base class for grid creators in a CRTP style.
Definition gridcreatorinterface.hh:25
void insertElementsImpl(std::vector< std::uint8_t > const &, std::vector< std::int64_t > const &, std::vector< std::int64_t > const &)
Definition gridcreatorinterface.hh:114
GridCreatorInterface(Args &&... args)
Constructor. Construct a new GridFactory from the passed arguments.
Definition gridcreatorinterface.hh:45
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:77
typename Grid::template Codim< 0 >::Entity::Geometry::GlobalCoordinate GlobalCoordinate
Definition gridcreatorinterface.hh:28
Derived & asDerived()
Definition gridcreatorinterface.hh:96
std::unique_ptr< Grid > createGrid() const
Construct the actual grid using the GridFactory.
Definition gridcreatorinterface.hh:71
void insertPiecesImpl(std::vector< std::string > const &)
Definition gridcreatorinterface.hh:121
const Derived & asDerived() const
Definition gridcreatorinterface.hh:101
std::shared_ptr< GridFactory< Grid > > factory_
Definition gridcreatorinterface.hh:127
DerivedType Derived
Definition gridcreatorinterface.hh:29
auto comm() const
Return the mpi collective communicator.
Definition gridcreatorinterface.hh:89
void insertPieces(std::vector< std::string > const &pieces)
Insert part of a grid stored in file into factory.
Definition gridcreatorinterface.hh:65
GridType Grid
Definition gridcreatorinterface.hh:27
GridCreatorInterface(std::shared_ptr< GridFactory< Grid > > factory)
Constructor. Store the shared_ptr to the GridFactory.
Definition gridcreatorinterface.hh:38
GridCreatorInterface(GridFactory< Grid > &factory)
Constructor. Stores a reference to the passed GridFactory.
Definition gridcreatorinterface.hh:33
GridFactory< Grid > const & factory() const
Return the associated (const) GridFactory.
Definition gridcreatorinterface.hh:83
void insertVerticesImpl(std::vector< GlobalCoordinate > const &, std::vector< std::uint64_t > const &)
Definition gridcreatorinterface.hh:108
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:50
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:57