dune-vtk 2.12
Loading...
Searching...
No Matches
continuousgridcreator.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 <cassert>
6#include <cstdint>
7#include <limits>
8#include <vector>
9
12#include <dune/grid/common/gridfactory.hh>
13
14#include <dune/vtk/types.hh>
17
18namespace Dune::Vtk
19{
20 // Create a grid where the input points and connectivity is already
21 // connected correctly.
22 template <class Grid>
24 : public GridCreatorInterface<Grid, ContinuousGridCreator<Grid>>
25 {
29
30 using Super::Super;
31 using Super::factory;
32
34 std::vector<std::uint64_t> const& /*point_ids*/)
35 {
36 for (auto const& p : points)
38 }
39
41 std::vector<std::int64_t> const& offsets,
42 std::vector<std::int64_t> const& connectivity)
43 {
44 std::size_t idx = 0;
45 for (std::size_t i = 0; i < types.size(); ++i) {
46 auto type = Vtk::to_geometry(types[i]);
49
50 int nNodes = offsets[i] - (i == 0 ? 0 : offsets[i-1]);
51 assert(nNodes == refElem.size(Grid::dimension));
53 for (int j = 0; j < nNodes; ++j)
54 vtk_cell.push_back( connectivity[idx++] );
55
56 if (cellType.noPermutation())
58 else {
59 // apply index permutation
61 for (int j = 0; j < nNodes; ++j)
62 cell[j] = vtk_cell[cellType.permutation(j)];
63
64 factory().insertElement(type,cell);
65 }
66 }
67 }
68 };
69
70 // deduction guides
71 template <class Grid>
74
75 template <class GridType, class Range, class Context>
80
81} // end namespace Dune::Vtk
Definition datacollector.hh:19
GeometryType to_geometry(std::uint8_t cell)
Definition types.cc:147
virtual void insertElement(const GeometryType &type, const std::vector< unsigned int > &vertices)
virtual void insertVertex(const FieldVector< ctype, dimworld > &pos)
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
Base class for grid creators in a CRTP style.
Definition gridcreatorinterface.hh:25
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:77
typename Grid::template Codim< 0 >::Entity::Geometry::GlobalCoordinate GlobalCoordinate
Definition gridcreatorinterface.hh:28
Definition continuousgridcreator.hh:25
GridFactory< Grid > & factory()
Return the associated GridFactory.
Definition gridcreatorinterface.hh:77
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:40
typename Super::GlobalCoordinate GlobalCoordinate
Definition continuousgridcreator.hh:28
void insertVerticesImpl(std::vector< GlobalCoordinate > const &points, std::vector< std::uint64_t > const &)
Definition continuousgridcreator.hh:33
Type-Traits to associate a GridFunction to a GridCreator.
Definition gridfunctions/common.hh:32
Mapping of Dune geometry types to VTK cell types.
Definition types.hh:161
T size(T... args)