Dune Core Modules (2.11.0)

datacollectorinterface.hh
1#pragma once
2
3#include <cstdint>
4#include <vector>
5
6#include <dune/grid/common/partitionset.hh>
7
8namespace Dune::Vtk
9{
11
16 template <class GV, class Derived, class Partition = Partitions::InteriorBorder>
18 {
19 public:
21 using GridView = GV;
22
24 static constexpr auto partition = Partition{};
25
27 enum { dim = GridView::dimension };
28
30 enum { dow = GridView::dimensionworld };
31
32 public:
35 : gridView_(gridView)
36 {}
37
39 GridView const& gridView () const
40 {
41 return gridView_;
42 }
43
45 void update ()
46 {
47 asDerived().updateImpl();
48 }
49
51 int ghostLevel () const
52 {
53 return asDerived().ghostLevelImpl();
54 }
55
57 std::uint64_t numCells () const
58 {
59 return asDerived().numCellsImpl();
60 }
61
63 std::uint64_t numPoints () const
64 {
65 return asDerived().numPointsImpl();
66 }
67
69
75 template <class T>
76 std::vector<T> points () const
77 {
78 return asDerived().template pointsImpl<T>();
79 }
80
82
90 template <class T, class VtkFunction>
91 std::vector<T> pointData (VtkFunction const& fct) const
92 {
93 return asDerived().template pointDataImpl<T>(fct);
94 }
95
97
103 template <class T, class VtkFunction>
104 std::vector<T> cellData (VtkFunction const& fct) const
105 {
106 return asDerived().template cellDataImpl<T>(fct);
107 }
108
109 // Return the collective communication object from the grid.
110 auto comm () const
111 {
112 return gridView_.comm();
113 }
114
115 protected: // cast to derived type
116
117 Derived& asDerived ()
118 {
119 return static_cast<Derived&>(*this);
120 }
121
122 const Derived& asDerived () const
123 {
124 return static_cast<const Derived&>(*this);
125 }
126
127 public: // default implementations
128
129 void updateImpl ()
130 {
131 /* do nothing */
132 }
133
134 int ghostLevelImpl () const
135 {
136 return gridView_.overlapSize(0);
137 }
138
139 // Evaluate `fct` in center of cell.
140 template <class T, class VtkFunction>
141 std::vector<T> cellDataImpl (VtkFunction const& fct) const;
142
143 private:
144 GridView gridView_;
145 };
146
147} // end namespace Dune::Vtk
148
149#include "datacollectorinterface.impl.hh"
Base class for data collectors in a CRTP style.
Definition: datacollectorinterface.hh:18
void update()
Update the DataCollector on the current GridView.
Definition: datacollectorinterface.hh:45
std::uint64_t numCells() const
Return the number of cells in (this partition of the) grid.
Definition: datacollectorinterface.hh:57
std::vector< T > pointData(VtkFunction const &fct) const
Return a flat vector of function values evaluated at the points.
Definition: datacollectorinterface.hh:91
std::vector< T > cellData(VtkFunction const &fct) const
Return a flat vector of function values evaluated at the cells in the order of traversal.
Definition: datacollectorinterface.hh:104
int ghostLevel() const
Return the number of ghost elements.
Definition: datacollectorinterface.hh:51
std::vector< T > points() const
Return a flat vector of point coordinates.
Definition: datacollectorinterface.hh:76
std::uint64_t numPoints() const
Return the number of points in (this partition of the) grid.
Definition: datacollectorinterface.hh:63
static constexpr auto partition
The partitionset to collect data from.
Definition: datacollectorinterface.hh:24
GV GridView
Type of the bound grid view.
Definition: datacollectorinterface.hh:21
GridView const & gridView() const
Return the bound grid view.
Definition: datacollectorinterface.hh:39
DataCollectorInterface(GridView const &gridView)
Store a copy of the GridView.
Definition: datacollectorinterface.hh:34
static constexpr int dimension
The dimension of the grid.
Definition: gridview.hh:134
static constexpr int dimensionworld
The dimension of the world the grid lives in.
Definition: gridview.hh:137
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden & Uni Heidelberg  |  generated with Hugo v0.111.3 (Feb 14, 23:39, 2026)