dune-vtk 2.12
Loading...
Searching...
No Matches
continuousgridcreator.hh
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4#include <cstdint>
5#include <limits>
6#include <vector>
7
10#include <dune/grid/common/gridfactory.hh>
11
12#include <dune/vtk/types.hh>
15
16namespace Dune::Vtk
17{
18 // Create a grid where the input points and connectivity is already
19 // connected correctly.
20 template <class Grid>
22 : public GridCreatorInterface<Grid, ContinuousGridCreator<Grid>>
23 {
27
28 using Super::Super;
29 using Super::factory;
30
32 std::vector<std::uint64_t> const& /*point_ids*/)
33 {
34 for (auto const& p : points)
36 }
37
39 std::vector<std::int64_t> const& offsets,
40 std::vector<std::int64_t> const& connectivity)
41 {
42 std::size_t idx = 0;
43 for (std::size_t i = 0; i < types.size(); ++i) {
44 auto type = Vtk::to_geometry(types[i]);
45 Vtk::CellType cellType{type};
46 [[maybe_unused]] auto refElem = referenceElement<double,Grid::dimension>(type);
47
48 int nNodes = offsets[i] - (i == 0 ? 0 : offsets[i-1]);
49 assert(nNodes == refElem.size(Grid::dimension));
50 std::vector<unsigned int> vtk_cell; vtk_cell.reserve(nNodes);
51 for (int j = 0; j < nNodes; ++j)
52 vtk_cell.push_back( connectivity[idx++] );
53
54 if (cellType.noPermutation())
55 factory().insertElement(type,vtk_cell);
56 else {
57 // apply index permutation
58 std::vector<unsigned int> cell(nNodes);
59 for (int j = 0; j < nNodes; ++j)
60 cell[j] = vtk_cell[cellType.permutation(j)];
61
62 factory().insertElement(type,cell);
63 }
64 }
65 }
66 };
67
68 // deduction guides
69 template <class Grid>
72
73 template <class GridType, class Range, class Context>
78
79} // end namespace Dune::Vtk
Definition writer.hh:16
GeometryType to_geometry(std::uint8_t cell)
Definition types.cc:145
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Base class for grid creators in a CRTP style.
Definition gridcreatorinterface.hh:23
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:75
typename Grid::template Codim< 0 >::Entity::Geometry::GlobalCoordinate GlobalCoordinate
Definition gridcreatorinterface.hh:26
Definition continuousgridcreator.hh:23
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:75
void insertElementsImpl(std::vector< std::uint8_t > const &types, std::vector< std::int64_t > const &offsets, std::vector< std::int64_t > const &connectivity)
Definition continuousgridcreator.hh:38
typename Super::GlobalCoordinate GlobalCoordinate
Definition continuousgridcreator.hh:26
void insertVerticesImpl(std::vector< GlobalCoordinate > const &points, std::vector< std::uint64_t > const &)
Definition continuousgridcreator.hh:31
Type-Traits to associate a GridFunction to a GridCreator.
Definition gridfunctions/common.hh:28
A GridFunction representing data stored on the grid vertices in a continuous manner.
Definition continuousgridfunction.hh:16
Mapping of Dune geometry types to VTK cell types.
Definition types.hh:159
T push_back(T... args)
T reserve(T... args)
T size(T... args)