dune-vtk 2.12
Loading...
Searching...
No Matches
lagrangepoints.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 <array>
7
10#include <dune/geometry/type.hh>
12
13namespace Dune::Vtk
14{
15 namespace Impl
16 {
17 // forward declaration
18 template <class K, unsigned int dim>
19 class LagrangePointSetBuilder;
20 }
21
22
24
28 template <class K, unsigned int dim>
30 : public EmptyPointSet<K, dim>
31 {
33
34 public:
35 static const unsigned int dimension = dim;
36
42
45 {
46 assert(gt.dim() == dimension);
47 builder_(gt, order(), points_);
48 }
49
51 template <GeometryType::Id geometryId>
52 bool build ()
53 {
55 return true;
56 }
57
60 template <GeometryType::Id geometryId>
61 static bool supports (std::size_t /*order*/)
62 {
63 return true;
64 }
65
66 using Super::order;
67
68 private:
69 using Super::points_;
70 Impl::LagrangePointSetBuilder<K,dim> builder_;
71 };
72
73
74 namespace Impl
75 {
76 // Build for lagrange point sets in different dimensions
77 // Specialized for dim=1,2,3
78 template <class K, unsigned int dim>
79 class LagrangePointSetBuilder
80 {
81 public:
82 template <class Points>
83 void operator()(GeometryType, unsigned int, Points& points) const
84 {
86 "Lagrange points not yet implemented for this GeometryType.");
87 }
88 };
89
90
91 // Lagrange points on point geometries
92 template <class K>
93 class LagrangePointSetBuilder<K,0>
94 {
95 static constexpr int dim = 0;
96 using LP = LagrangePoint<K,dim>;
97 using Vec = typename LP::Vector;
98 using Key = LocalKey;
99
100 public:
101 template <class Points>
102 void operator()(GeometryType gt, int /*order*/, Points& points) const;
103 };
104
105
106 // Lagrange points on line geometries
107 template <class K>
108 class LagrangePointSetBuilder<K,1>
109 {
110 static constexpr int dim = 1;
111 using LP = LagrangePoint<K,dim>;
112 using Vec = typename LP::Vector;
113 using Key = LocalKey;
114
115 public:
116 template <class Points>
117 void operator()(GeometryType gt, int order, Points& points) const;
118 };
119
120
121 // Lagrange points on 2d geometries
122 template <class K>
123 class LagrangePointSetBuilder<K,2>
124 {
125 static constexpr int dim = 2;
126 using LP = LagrangePoint<K,dim>;
127 using Vec = typename LP::Vector;
128 using Key = LocalKey;
129
130 friend class LagrangePointSetBuilder<K,3>;
131
132 public:
133 template <class Points>
134 void operator()(GeometryType gt, int order, Points& points) const;
135
136 // implementation details
137 // ----------------------
138
139 // Construct the point set in a triangle element.
140 // Loop from the outside to the inside
141 template <class Points>
142 void buildTriangle (int order, Points& points) const;
143
144 // "Barycentric index" is a triplet of integers, each running from 0 to
145 // <Order>. It is the index of a point on the triangle in barycentric
146 // coordinates.
147 static void barycentricIndex (int index, std::array<int,3>& bindex, int order);
148
149 // Construct the point set in the quad element
150 // 1. build equispaced points with index tuple (i,j)
151 // 2. map index tuple to DOF index and LocalKey
152 template <class Points>
153 void buildQuad(int orderx, int ordery, Points& points) const;
154
155 // Obtain the VTK DOF index of the node (i,j) in the quad element
156 // and construct a LocalKey
157 static std::pair<int,Key> calcQuadKey (int i, int j, std::array<int,2> order);
158 };
159
160
161 // Lagrange points on 3d geometries
162 template <class K>
163 class LagrangePointSetBuilder<K,3>
164 {
165 static constexpr int dim = 3;
166 using LP = LagrangePoint<K,dim>;
167 using Vec = typename LP::Vector;
168 using Key = LocalKey;
169
170 public:
171 template <class Points>
172 void operator() (GeometryType gt, unsigned int order, Points& points) const;
173
174 // implementation details
175 // ----------------------
176
177 // Construct the point set in the tetrahedron element
178 // 1. construct barycentric (index) coordinates
179 // 2. obtains the DOF index, LocalKey and actual coordinate from barycentric index
180 template <class Points>
181 void buildTetra (int order, Points& points) const;
182
183 // "Barycentric index" is a set of 4 integers, each running from 0 to
184 // <Order>. It is the index of a point in the tetrahedron in barycentric
185 // coordinates.
186 static void barycentricIndex (int p, std::array<int,4>& bindex, int order);
187
188 // Construct the point set in the heyhedral element
189 // 1. build equispaced points with index tuple (i,j,k)
190 // 2. map index tuple to DOF index and LocalKey
191 template <class Points>
192 void buildHex (int order, Points& points) const;
193
194 // Obtain the VTK DOF index of the node (i,j,k) in the hexahedral element
195 static std::pair<int,Key> calcHexKey (int i, int j, int k, std::array<int,3> order);
196
197 // Construct the point set in the prism element
198 // with polynomial order `order_tri` in the triangular faces and along the
199 // z-direction with `order_quad` polynomial order.
200 template <class Points>
201 void buildWedge (int order_tri, int order_quad, Points& points) const;
202 };
203
204 template <class K, unsigned int dim>
205 class LexicographicPointSetBuilder
206 {
207 public:
208 // equidistant points along the line with `a+1` points.
209 template <class Points>
210 static void buildLine(int a, Points& points);
211
212 // equidistant points in the quad with `a+1` points along the x-axis and
213 // `b+1` points along the y-axis, lexicographically ordered.
214 template <class Points>
215 static void buildQuad(int a, int b, Points& points);
216
217 // equidistant points in the hexahedron with `a+1` points along the x-axis,
218 // `b+1` points along the y-axis, and `c+1` points along the z-axis,
219 // lexicographically ordered.
220 template <class Points>
221 static void buildHex(int a, int b, int c, Points& points);
222 };
223
224 } // end namespace Impl
225} // end namespace Dune::Vtk
226
Definition datacollector.hh:19
size_type dim() const
std::ptrdiff_t index() const
virtual void operator()()=0
#define DUNE_THROW(E,...)
std::size_t order() const
std::vector< LagrangePoint > points_
Implementation of DataCollector for cells, with continuous data.
Definition celltypedatacollector.hh:20
A set of lagrange points compatible with the numbering of VTK and Gmsh.
Definition lagrangepoints.hh:31
bool build()
Fill the lagrange points for the given topology type Topology
Definition lagrangepoints.hh:52
LagrangePointSet(std::size_t order)
Definition lagrangepoints.hh:37
void build(GeometryType gt)
Fill the lagrange points for the given geometry type.
Definition lagrangepoints.hh:44
static bool supports(std::size_t)
Definition lagrangepoints.hh:61
static const unsigned int dimension
Definition lagrangepoints.hh:35