dune-vtk 2.12
Loading...
Searching...
No Matches
discontinuousdatacollector.hh
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
6#include <dune/vtk/types.hh>
7
9
10namespace Dune::Vtk
11{
13 template <class GridView, class Partition = Partitions::InteriorBorder>
15 : public UnstructuredDataCollectorInterface<GridView, DiscontinuousDataCollector<GridView,Partition>, Partition>
16 {
19
20 public:
21 using Super::dim;
22 using Super::partition;
23 using Super::gridView;
24
25 public:
29
31 void updateImpl ()
32 {
33 numPoints_ = 0;
34 numCells_ = 0;
35 for (auto const& c : elements(gridView(), partition)) {
36 numCells_++;
37 numPoints_ += c.subEntities(dim);
38 }
39 }
40
43 {
44 return numPoints_;
45 }
46
48 template <class T>
50 {
51 std::vector<T> data(numPoints_ * 3);
53 for (auto const& element : elements(gridView(), partition)) {
54 Vtk::CellType cellType(element.type());
55 for (unsigned int i = 0; i < element.subEntities(dim); ++i,++pointIdx) {
57 auto v = element.geometry().corner(cellType.permutation(i));
58 for (std::size_t j = 0; j < v.size(); ++j)
59 data[idx + j] = T(v[j]);
60 for (std::size_t j = v.size(); j < 3u; ++j)
61 data[idx + j] = T(0);
62 }
63 }
64 return data;
65 }
66
69 {
70 return numCells_;
71 }
72
75 {
77 cells.connectivity.reserve(numPoints_);
78 cells.offsets.reserve(numCells_);
79 cells.types.reserve(numCells_);
80
83 for (auto const& c : elements(gridView(), partition)) {
84 Vtk::CellType cellType(c.type());
85 for (unsigned int j = 0; j < c.subEntities(dim); ++j,++pointIdx) {
87 }
88 cells.offsets.push_back(old_o += c.subEntities(dim));
90 }
91
92 return cells;
93 }
94
96 template <class T, class GlobalFunction>
97 std::vector<T> pointDataImpl (GlobalFunction const& fct) const
98 {
99 std::vector<T> data(numPoints_ * fct.numComponents());
100 auto localFct = localFunction(fct);
102 for (auto const& e : elements(gridView(), partition)) {
103 localFct.bind(e);
105 auto refElem = referenceElement(e.geometry());
106 for (unsigned int j = 0; j < e.subEntities(dim); ++j,++pointIdx) {
107 std::size_t idx = fct.numComponents() * pointIdx;
108 for (int comp = 0; comp < fct.numComponents(); ++comp)
109 data[idx + comp] = T(localFct.evaluate(comp, refElem.position(cellType.permutation(j),dim)));
110 }
111 localFct.unbind();
112 }
113 return data;
114 }
115
116 private:
117 std::uint64_t numCells_ = 0;
118 std::uint64_t numPoints_ = 0;
120 };
121
122} // end namespace Dune::Vtk
Definition writer.hh:16
unspecified value type referenceElement(T &&... t)
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
Implementation of DataCollector for linear cells, with discontinuous data.
Definition discontinuousdatacollector.hh:16
void updateImpl()
Create an index map the uniquely assigns an index to each pair (element,corner)
Definition discontinuousdatacollector.hh:31
Cells cellsImpl() const
Connect the corners of each cell. The leads to a global discontinuous grid.
Definition discontinuousdatacollector.hh:74
DiscontinuousDataCollector(GridView const &gridView)
Definition discontinuousdatacollector.hh:26
std::uint64_t numPointsImpl() const
The number of points approx. #cell * #corners-per-cell.
Definition discontinuousdatacollector.hh:42
std::vector< T > pointsImpl() const
Return the coordinates of the corners of all cells.
Definition discontinuousdatacollector.hh:49
std::uint64_t numCellsImpl() const
Return number of grid cells.
Definition discontinuousdatacollector.hh:68
std::vector< T > pointDataImpl(GlobalFunction const &fct) const
Evaluate the fct in the corners of each cell.
Definition discontinuousdatacollector.hh:97
Definition unstructureddatacollector.hh:12
std::vector< std::int64_t > offsets
Definition unstructureddatacollector.hh:14
std::vector< std::int64_t > connectivity
Definition unstructureddatacollector.hh:15
std::vector< std::uint8_t > types
Definition unstructureddatacollector.hh:13
Definition unstructureddatacollector.hh:26
@ dim
Definition datacollectorinterface.hh:27
static constexpr auto partition
The partitionset to collect data from.
Definition datacollectorinterface.hh:24
Cells cells() const
Return cell types, offsets, and connectivity.
Definition unstructureddatacollector.hh:45
Mapping of Dune geometry types to VTK cell types.
Definition types.hh:159
std::uint8_t type() const
Return VTK Cell type.
Definition types.hh:211
T push_back(T... args)
T reserve(T... args)