7#include <dune/geometry/referenceelement.hh>
8#include <dune/grid/common/partitionset.hh>
10#include <dune/vtk/types.hh>
11#include <dune/vtk/utility/lagrangepoints.hh>
13#include "unstructureddatacollector.hh"
18 template <
class GridView,
int ORDER = -1>
20 :
public UnstructuredDataCollectorInterface<GridView, LagrangeDataCollector<GridView,ORDER>, Partitions::All>
23 using Super = UnstructuredDataCollectorInterface<GridView, Self, Partitions::All>;
25 auto pointSetMapper()
const
30 auto refElem = Dune::referenceElement<double,dim>(
gt);
31 return pointSets_.at(
gt).size() - refElem.size(dim);
42 static_assert(ORDER != 0,
"Order 0 not supported");
44 using Super::partition;
45 using Super::gridView;
52 assert(order > 0 &&
"Order 0 not supported");
53 assert(ORDER < 0 || order == ORDER);
59 auto const& indexSet =
gridView().indexSet();
62 for (
auto gt : indexSet.types(0))
63 pointSets_.emplace(
gt, order_);
65 for (
auto& pointSet : pointSets_)
66 pointSet.second.build(pointSet.first);
68 numPoints_ = pointSetMapper().size();
85 std::vector<T> data(this->
numPoints() * 3);
86 auto const& mapper = pointSetMapper();
89 auto geometry = element.geometry();
90 auto refElem = referenceElement<T,dim>(element.type());
92 auto const& pointSet = pointSets_.at(element.type());
93 unsigned int vertexDOFs = refElem.size(dim);
95 for (std::size_t i = 0; i < pointSet.size(); ++i) {
96 auto const& p = pointSet[i];
98 assert(p.localKey().codim() == dim);
100 auto const& localKey = p.localKey();
101 std::size_t idx = 3 * (localKey.codim() == dim
102 ? mapper.subIndex(element, localKey.subEntity(), dim)
103 : mapper.index(element) + (i - vertexDOFs));
105 auto v = geometry.global(p.point());
106 for (std::size_t j = 0; j < v.size(); ++j)
107 data[idx + j] = T(v[j]);
108 for (std::size_t j = v.size(); j < 3u; ++j)
109 data[idx + j] = T(0);
129 cells.connectivity.reserve(this->
numPoints());
130 cells.offsets.reserve(this->
numCells());
131 cells.types.reserve(this->
numCells());
133 auto const& mapper = pointSetMapper();
135 std::int64_t old_o = 0;
137 auto refElem = referenceElement<double,dim>(element.type());
138 Vtk::CellType cellType(element.type(), Vtk::CellType::LAGRANGE);
140 auto const& pointSet = pointSets_.at(element.type());
141 unsigned int vertexDOFs = refElem.size(dim);
143 for (std::size_t i = 0; i < pointSet.size(); ++i) {
144 auto const& p = pointSet[i];
145 auto const& localKey = p.localKey();
146 std::size_t idx = (localKey.codim() == dim
147 ? mapper.subIndex(element, localKey.subEntity(), dim)
148 : mapper.index(element) + (i - vertexDOFs));
149 cells.connectivity.push_back(std::int64_t(idx));
152 cells.offsets.push_back(old_o += pointSet.size());
153 cells.types.push_back(cellType.
type());
159 template <
class T,
class GlobalFunction>
162 int nComps = fct.numComponents();
163 std::vector<T> data(this->
numPoints() * nComps);
164 auto const& mapper = pointSetMapper();
166 auto localFct = localFunction(fct);
168 localFct.bind(element);
169 auto refElem = referenceElement<T,dim>(element.type());
171 auto const& pointSet = pointSets_.at(element.type());
172 unsigned int vertexDOFs = refElem.size(dim);
174 for (std::size_t i = 0; i < pointSet.size(); ++i) {
175 auto const& p = pointSet[i];
176 auto const& localKey = p.localKey();
177 std::size_t idx = nComps * (localKey.codim() == dim
178 ? mapper.subIndex(element, localKey.subEntity(), dim)
179 : mapper.index(element) + (i - vertexDOFs));
181 for (
int comp = 0; comp < nComps; ++comp)
182 data[idx + comp] = T(localFct.evaluate(comp, p.point()));
191 std::uint64_t numPoints_ = 0;
194 std::map<GeometryType, PointSet> pointSets_;
Unique label for each type of entities that can occur in DUNE grids.
Definition: type.hh:114
Implementation class for a multiple codim and multiple geometry type mapper.
Definition: mcmgmapper.hh:129
std::uint64_t numCells() const
Return the number of cells in (this partition of the) grid.
Definition: datacollectorinterface.hh:57
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
GridView 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 Lagrange cells.
Definition: lagrangedatacollector.hh:21
std::uint64_t numPointsImpl() const
Return number of Lagrange nodes.
Definition: lagrangedatacollector.hh:72
void updateImpl()
Construct the point sets.
Definition: lagrangedatacollector.hh:57
Cells cellsImpl() const
Return cell types, offsets, and connectivity.
Definition: lagrangedatacollector.hh:126
std::vector< T > pointsImpl() const
Return a vector of point coordinates.
Definition: lagrangedatacollector.hh:83
std::vector< T > pointDataImpl(GlobalFunction const &fct) const
Evaluate the fct at element vertices and edge centers in the same order as the point coords.
Definition: lagrangedatacollector.hh:160
std::uint64_t numCellsImpl() const
Return number of grid cells.
Definition: lagrangedatacollector.hh:116
A set of lagrange points compatible with the numbering of VTK and Gmsh.
Definition: lagrangepoints.hh:29
bool gt(const T &first, const T &second, typename EpsilonType< T >::Type epsilon)
test if first greater than second
Definition: float_cmp.cc:158
auto elements(const SubDomainGridView< HostGridView > &subDomainGridView)
ADL findable access to element range for a SubDomainGridView.
Definition: subdomain.hh:487
Mapper for multiple codim and multiple geometry types.
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