dune-vtk 2.12
Loading...
Searching...
No Matches
datacollectorinterface.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 <vector>
7
9
10namespace Dune::Vtk
11{
13
18 template <class GV, class Derived, class Partition = Partitions::InteriorBorder>
20 {
21 public:
23 using GridView = GV;
24
26 static constexpr auto partition = Partition{};
27
29 enum { dim = GridView::dimension };
30
32 enum { dow = GridView::dimensionworld };
34 public:
37 : gridView_(gridView)
38 {}
39
41 GridView const& gridView () const
42 {
43 return gridView_;
44 }
45
47 void update ()
48 {
50 }
51
53 int ghostLevel () const
54 {
55 return asDerived().ghostLevelImpl();
56 }
57
60 {
61 return asDerived().numCellsImpl();
62 }
63
66 {
67 return asDerived().numPointsImpl();
68 }
69
71
77 template <class T>
79 {
80 return asDerived().template pointsImpl<T>();
81 }
82
84
92 template <class T, class VtkFunction>
93 std::vector<T> pointData (VtkFunction const& fct) const
94 {
95 return asDerived().template pointDataImpl<T>(fct);
96 }
97
99
105 template <class T, class VtkFunction>
106 std::vector<T> cellData (VtkFunction const& fct) const
107 {
108 return asDerived().template cellDataImpl<T>(fct);
109 }
110
111 // Return the collective communication object from the grid.
112 auto comm () const
113 {
114 return gridView_.comm();
115 }
116
117 protected: // cast to derived type
118
119 Derived& asDerived ()
120 {
121 return static_cast<Derived&>(*this);
122 }
123
124 const Derived& asDerived () const
125 {
126 return static_cast<const Derived&>(*this);
127 }
128
129 public: // default implementations
130
132 {
133 /* do nothing */
134 }
135
136 int ghostLevelImpl () const
137 {
138 return gridView_.overlapSize(0);
139 }
140
141 // Evaluate `fct` in center of cell.
142 template <class T, class VtkFunction>
143 std::vector<T> cellDataImpl (VtkFunction const& fct) const;
144
145 private:
146 GridView gridView_;
147 };
148
149} // end namespace Dune::Vtk
150
Definition datacollector.hh:19
Base class for data collectors in a CRTP style.
Definition datacollectorinterface.hh:20
@ dow
Definition datacollectorinterface.hh:32
void update()
Update the DataCollector on the current GridView.
Definition datacollectorinterface.hh:47
std::uint64_t numCells() const
Return the number of cells in (this partition of the) grid.
Definition datacollectorinterface.hh:59
auto comm() const
Definition datacollectorinterface.hh:112
std::vector< T > pointData(VtkFunction const &fct) const
Return a flat vector of function values evaluated at the points.
Definition datacollectorinterface.hh:93
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:106
int ghostLevel() const
Return the number of ghost elements.
Definition datacollectorinterface.hh:53
const Derived & asDerived() const
Definition datacollectorinterface.hh:124
std::vector< T > points() const
Return a flat vector of point coordinates.
Definition datacollectorinterface.hh:78
std::uint64_t numPoints() const
Return the number of points in (this partition of the) grid.
Definition datacollectorinterface.hh:65
@ dim
Definition datacollectorinterface.hh:29
std::vector< T > cellDataImpl(VtkFunction const &fct) const
Definition datacollectorinterface.impl.hh:12
static constexpr auto partition
The partitionset to collect data from.
Definition datacollectorinterface.hh:26
GV GridView
Type of the bound grid view.
Definition datacollectorinterface.hh:23
Derived & asDerived()
Definition datacollectorinterface.hh:119
GridView const & gridView() const
Return the bound grid view.
Definition datacollectorinterface.hh:41
int ghostLevelImpl() const
Definition datacollectorinterface.hh:136
void updateImpl()
Definition datacollectorinterface.hh:131
DataCollectorInterface(GridView const &gridView)
Store a copy of the GridView.
Definition datacollectorinterface.hh:36
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
void updateImpl()
Update the mapper.
Definition celltypedatacollector.hh:49