dune-vtk 2.8
Loading...
Searching...
No Matches
lagrangepoints.hh
Go to the documentation of this file.
1#pragma once
2
3#include <cassert>
4#include <array>
5
6#include <dune/common/exceptions.hh>
7#include <dune/common/version.hh>
8#include <dune/geometry/type.hh>
9#include <dune/localfunctions/lagrange/equidistantpoints.hh>
10
11namespace Dune
12{
13 namespace 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 {
32 using Super = EmptyPointSet<K, dim>;
33
34 public:
35 static const unsigned int dimension = dim;
36
37 LagrangePointSet (std::size_t order)
38 : Super(order)
39 {
40 assert(order > 0);
41 }
42
44 void build (GeometryType gt)
45 {
46 assert(gt.dim() == dimension);
47 builder_(gt, order(), points_);
48 }
49
51 template <GeometryType::Id geometryId>
52 bool build ()
53 {
54 build(GeometryType(geometryId));
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 {
85 DUNE_THROW(Dune::NotImplemented,
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 private: // implementation details
137
138 // Construct the point set in a triangle element.
139 // Loop from the outside to the inside
140 template <class Points>
141 void buildTriangle (std::size_t nPoints, int order, Points& points) const;
142
143 // "Barycentric index" is a triplet of integers, each running from 0 to
144 // <Order>. It is the index of a point on the triangle in barycentric
145 // coordinates.
146 static void barycentricIndex (int index, std::array<int,3>& bindex, int order);
147
148 // Construct the point set in the quad element
149 // 1. build equispaced points with index tuple (i,j)
150 // 2. map index tuple to DOF index and LocalKey
151 template <class Points>
152 void buildQuad(std::size_t nPoints, int order, Points& points) const;
153
154 // Obtain the VTK DOF index of the node (i,j) in the quad element
155 // and construct a LocalKey
156 static std::pair<int,Key> calcQuadKey (int i, int j, std::array<int,2> order);
157 };
158
159
160 // Lagrange points on 3d geometries
161 template <class K>
162 class LagrangePointSetBuilder<K,3>
163 {
164 static constexpr int dim = 3;
165 using LP = LagrangePoint<K,dim>;
166 using Vec = typename LP::Vector;
167 using Key = LocalKey;
168
169 public:
170 template <class Points>
171 void operator() (GeometryType gt, unsigned int order, Points& points) const;
172
173 private: // implementation details
174
175 // Construct the point set in the tetrahedron element
176 // 1. construct barycentric (index) coordinates
177 // 2. obtains the DOF index, LocalKey and actual coordinate from barycentric index
178 template <class Points>
179 void buildTetra (std::size_t nPoints, int order, Points& points) const;
180
181 // "Barycentric index" is a set of 4 integers, each running from 0 to
182 // <Order>. It is the index of a point in the tetrahedron in barycentric
183 // coordinates.
184 static void barycentricIndex (int p, std::array<int,4>& bindex, int order);
185
186 // Construct the point set in the heyhedral element
187 // 1. build equispaced points with index tuple (i,j,k)
188 // 2. map index tuple to DOF index and LocalKey
189 template <class Points>
190 void buildHex (std::size_t nPoints, int order, Points& points) const;
191
192 // Obtain the VTK DOF index of the node (i,j,k) in the hexahedral element
193 static std::pair<int,Key> calcHexKey (int i, int j, int k, std::array<int,3> order);
194 };
195
196 } // end namespace Impl
197 } // end namespace Vtk
198} // end namespace Dune
199
Definition: writer.hh:13
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
static bool supports(std::size_t order)
Definition: lagrangepoints.hh:61
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 const unsigned int dimension
Definition: lagrangepoints.hh:35