Loading...
Searching...
No Matches
element_reference.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_ELEMENT_REFERENCE_HPP__
26#define __BITPIT_ELEMENT_REFERENCE_HPP__
27
28#include <assert.h>
29#include <vector>
30
31#include "bitpit_common.hpp"
32
33#include "element_type.hpp"
34
35namespace bitpit {
36
38
39public:
40 BITPIT_PUBLIC_API static const int MAX_ELEM_VERTICES = 8;
41 BITPIT_PUBLIC_API static const int MAX_ELEM_FACES = 6;
42 BITPIT_PUBLIC_API static const int MAX_ELEM_EDGES = 12;
43
44 static bool hasInfo(ElementType type);
45 BITPIT_PUBLIC_API static const ReferenceElementInfo & getInfo(ElementType type);
46
47 int dimension;
48 ElementType type;
49
50 int nVertices;
51 int nFaces;
52 int nEdges;
53
54 std::array<ElementType, MAX_ELEM_FACES> faceTypeStorage;
55 std::array<std::array<int, MAX_ELEM_VERTICES>, MAX_ELEM_FACES> faceConnectStorage;
56 std::array<std::array<int, MAX_ELEM_FACES>, MAX_ELEM_FACES> faceEdgeStorage;
57
58 std::array<ElementType, MAX_ELEM_EDGES> edgeTypeStorage;
59 std::array<std::array<int, MAX_ELEM_VERTICES>, MAX_ELEM_EDGES> edgeConnectStorage;
60
61 virtual ~ReferenceElementInfo() = default;
62
63 virtual double evalSize(const std::array<double, 3> *vertexCoords) const = 0;
64
65 virtual void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const = 0;
66 virtual double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const = 0;
67
68protected:
69 ReferenceElementInfo(int _dimension, ElementType _type, int _nVertices, int _nFaces, int _nEdges);
70
72 ReferenceElementInfo & operator=(ReferenceElementInfo const &) = delete;
73
74 void initializeFaceEdges(const std::vector<const ReferenceElementInfo *> &facesInfo, const std::vector<const ReferenceElementInfo *> &edgesInfo);
75
76};
77
79
80public:
81 double evalSize(const std::array<double, 3> *vertexCoords) const override;
82
83 virtual double evalVolume(const std::array<double, 3> *vertexCoords) const = 0;
84 double evalSurfaceArea(const std::array<double, 3> *vertexCoords) const;
85 double evalEdgePerimeter(const std::array<double, 3> *vertexCoords) const;
86
87 double evalFaceArea(int face, const std::array<double, 3> *vertexCoords) const;
88 double evalEdgeLength(int edge, const std::array<double, 3> *vertexCoords) const;
89
90 void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const override;
91 double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const override;
92
93protected:
94 Reference3DElementInfo(ElementType type, int nVertices, int nFaces);
95
96};
97
99
100friend class ReferenceElementInfo;
101
102public:
103 double evalSize(const std::array<double, 3> *vertexCoords) const override;
104
105 double evalVolume(const std::array<double, 3> *vertexCoords) const override;
106
107 BITPIT_PUBLIC_API static const ReferenceTetraInfo info;
108
109protected:
111
112 ReferenceTetraInfo(ReferenceTetraInfo const &) = delete;
113 ReferenceTetraInfo & operator=(ReferenceTetraInfo const &) = delete;
114
115};
116
118
119friend class ReferenceElementInfo;
120
121public:
122 double evalSize(const std::array<double, 3> *vertexCoords) const override;
123
124 double evalVolume(const std::array<double, 3> *vertexCoords) const override;
125
126 BITPIT_PUBLIC_API static const ReferenceVoxelInfo info;
127
128protected:
130
131 ReferenceVoxelInfo(ReferenceVoxelInfo const &) = delete;
132 ReferenceVoxelInfo & operator=(ReferenceVoxelInfo const &) = delete;
133
134};
135
137
138friend class ReferenceElementInfo;
139
140public:
141 double evalVolume(const std::array<double, 3> *vertexCoords) const override;
142
143 BITPIT_PUBLIC_API static const ReferenceHexahedronInfo info;
144
145protected:
147
149 ReferenceHexahedronInfo & operator=(ReferenceHexahedronInfo const &) = delete;
150
151};
152
154
155friend class ReferenceElementInfo;
156
157public:
158 double evalVolume(const std::array<double, 3> *vertexCoords) const override;
159
160 BITPIT_PUBLIC_API static const ReferencePyramidInfo info;
161
162protected:
164
166 ReferencePyramidInfo & operator=(ReferencePyramidInfo const &) = delete;
167
168};
169
171
172friend class ReferenceElementInfo;
173
174public:
175 double evalVolume(const std::array<double, 3> *vertexCoords) const override;
176
177 BITPIT_PUBLIC_API static const ReferenceWedgeInfo info;
178
179protected:
181
182 ReferenceWedgeInfo(ReferenceWedgeInfo const &) = delete;
183 ReferenceWedgeInfo & operator=(ReferenceWedgeInfo const &) = delete;
184
185};
186
188
189public:
190 double evalSize(const std::array<double, 3> *vertexCoords) const override;
191
192 virtual double evalArea(const std::array<double, 3> *vertexCoords) const = 0;
193 double evalPerimeter(const std::array<double, 3> *vertexCoords) const;
194
195 double evalFaceLength(int face, const std::array<double, 3> *vertexCoords) const;
196
197 virtual std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const = 0;
198
199 void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const override;
200 double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const override;
201
202 virtual bool areVerticesCCWOrdered() const;
203 virtual int getCCWOrderedVertex(int n) const;
204
205 virtual bool areFacesCCWOrdered() const;
206 virtual int getCCWOrderedFace(int n) const;
207
208protected:
209 Reference2DElementInfo(ElementType type, int nVertices);
210
211 void getCCWVertexCoords(const std::array<double, 3> *vertexCoords, const std::array<double, 3> **ccwVertexCoords, std::array<double, 3> *ccwVertexCoordsStorage) const;
212
213};
214
216
217friend class ReferenceElementInfo;
218friend class ReferenceTetraInfo;
219friend class ReferencePyramidInfo;
220friend class ReferenceWedgeInfo;
221
222public:
223 double evalSize(const std::array<double, 3> *vertexCoords) const override;
224
225 double evalArea(const std::array<double, 3> *vertexCoords) const override;
226
227 std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const override;
228
229 void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const override;
230 double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const override;
231
232 BITPIT_PUBLIC_API static const ReferenceTriangleInfo info;
233
234protected:
236
238 ReferenceTriangleInfo & operator=(ReferenceTriangleInfo const &) = delete;
239
240};
241
243
244friend class ReferenceElementInfo;
245friend class ReferenceVoxelInfo;
246
247public:
248 double evalSize(const std::array<double, 3> *vertexCoords) const override;
249
250 double evalArea(const std::array<double, 3> *vertexCoords) const override;
251
252 std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const override;
253
254 bool areVerticesCCWOrdered() const override;
255 int getCCWOrderedVertex(int n) const override;
256
257 bool areFacesCCWOrdered() const override;
258 int getCCWOrderedFace(int n) const override;
259
260 BITPIT_PUBLIC_API static const ReferencePixelInfo info;
261
262protected:
264
265 ReferencePixelInfo(ReferencePixelInfo const &) = delete;
266 ReferencePixelInfo & operator=(ReferencePixelInfo const &) = delete;
267
268};
269
271
272friend class ReferenceElementInfo;
273friend class ReferenceHexahedronInfo;
274friend class ReferencePyramidInfo;
275friend class ReferenceWedgeInfo;
276
277public:
278 double evalArea(const std::array<double, 3> *vertexCoords) const override;
279
280 std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const override;
281
282 BITPIT_PUBLIC_API static const ReferenceQuadInfo info;
283
284protected:
286
287 ReferenceQuadInfo(ReferenceQuadInfo const &) = delete;
288 ReferenceQuadInfo & operator=(ReferenceQuadInfo const &) = delete;
289
290};
291
293
294public:
295 virtual double evalLength(const std::array<double, 3> *vertexCoords) const = 0;
296
297 virtual std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &orientation = {{0., 0., 1.}}, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const = 0;
298
299protected:
301
302};
303
305
306friend class ReferenceElementInfo;
307friend class ReferenceTriangleInfo;
308friend class ReferencePixelInfo;
309friend class ReferenceQuadInfo;
310friend class ReferenceTetraInfo;
311friend class ReferenceVoxelInfo;
312friend class ReferenceHexahedronInfo;
313friend class ReferencePyramidInfo;
314friend class ReferenceWedgeInfo;
315
316public:
317 double evalSize(const std::array<double, 3> *vertexCoords) const override;
318
319 double evalLength(const std::array<double, 3> *vertexCoords) const override;
320
321 std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &orientation = {{0., 0., 1.}}, const std::array<double, 3> &point = {{0.5, 0.5, 0.5}}) const override;
322
323 void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const override;
324 double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const override;
325
326 BITPIT_PUBLIC_API static const ReferenceLineInfo info;
327
328protected:
330
331 ReferenceLineInfo(ReferenceLineInfo const &) = delete;
332 ReferenceLineInfo & operator=(ReferenceLineInfo const &) = delete;
333
334};
335
337
338public:
339 virtual std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &orientation = {{1., 0., 0.}}) const = 0;
340
341protected:
343
344};
345
347
348friend class ReferenceElementInfo;
349friend class ReferenceLineInfo;
350friend class ReferenceTriangleInfo;
351friend class ReferencePixelInfo;
352friend class ReferenceQuadInfo;
353
354public:
355 double evalSize(const std::array<double, 3> *vertexCoords) const override;
356
357 std::array<double, 3> evalNormal(const std::array<double, 3> *vertexCoords, const std::array<double, 3> &orientation = {{1., 0., 0.}}) const override;
358
359 void evalPointProjection(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords, std::array<double, 3> *projection, double *distance) const override;
360 double evalPointDistance(const std::array<double, 3> &point, const std::array<double, 3> *vertexCoords) const override;
361
362 BITPIT_PUBLIC_API static const ReferenceVertexInfo info;
363
364protected:
366
368 ReferenceVertexInfo & operator=(ReferenceVertexInfo const &) = delete;
369
370};
371
372}
373
374#endif
The Reference0DElementInfo class allows to define information about reference zero-dimensional elemen...
The Reference1DElementInfo class allows to define information about reference one-dimensional element...
The Reference2DElementInfo class allows to define information about reference two-dimensional element...
virtual int getCCWOrderedVertex(int n) const
virtual int getCCWOrderedFace(int n) const
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords) const override
double evalFaceLength(int face, const std::array< double, 3 > *vertexCoords) const
double evalSize(const std::array< double, 3 > *vertexCoords) const override
Reference2DElementInfo(ElementType type, int nVertices)
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords, std::array< double, 3 > *projection, double *distance) const override
double evalPerimeter(const std::array< double, 3 > *vertexCoords) const
void getCCWVertexCoords(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > **ccwVertexCoords, std::array< double, 3 > *ccwVertexCoordsStorage) const
virtual bool areVerticesCCWOrdered() const
The Reference3DElementInfo class allows to define information about reference three-dimensional eleme...
double evalSurfaceArea(const std::array< double, 3 > *vertexCoords) const
double evalSize(const std::array< double, 3 > *vertexCoords) const override
double evalEdgePerimeter(const std::array< double, 3 > *vertexCoords) const
double evalFaceArea(int face, const std::array< double, 3 > *vertexCoords) const
Reference3DElementInfo(ElementType type, int nVertices, int nFaces)
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords) const override
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords, std::array< double, 3 > *projection, double *distance) const override
double evalEdgeLength(int edge, const std::array< double, 3 > *vertexCoords) const
The ReferenceElementInfo class allows to define information about reference elements.
ReferenceElementInfo(int _dimension, ElementType _type, int _nVertices, int _nFaces, int _nEdges)
static bool hasInfo(ElementType type)
static BITPIT_PUBLIC_API const ReferenceElementInfo & getInfo(ElementType type)
void initializeFaceEdges(const std::vector< const ReferenceElementInfo * > &facesInfo, const std::vector< const ReferenceElementInfo * > &edgesInfo)
The ReferenceHexahedronInfo class defines the information about the reference hexahedron.
double evalVolume(const std::array< double, 3 > *vertexCoords) const override
The ReferenceLineInfo class defines the information about the reference line.
std::array< double, 3 > evalNormal(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > &orientation={{0., 0., 1.}}, const std::array< double, 3 > &point={{0.5, 0.5, 0.5}}) const override
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords, std::array< double, 3 > *projection, double *distance) const override
double evalLength(const std::array< double, 3 > *vertexCoords) const override
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords) const override
double evalSize(const std::array< double, 3 > *vertexCoords) const override
The ReferencePixelInfo class defines the information about the reference pixel.
bool areVerticesCCWOrdered() const override
double evalSize(const std::array< double, 3 > *vertexCoords) const override
int getCCWOrderedVertex(int n) const override
std::array< double, 3 > evalNormal(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > &point={{0.5, 0.5, 0.5}}) const override
bool areFacesCCWOrdered() const override
int getCCWOrderedFace(int n) const override
double evalArea(const std::array< double, 3 > *vertexCoords) const override
The ReferencePyramidInfo class defines the information about the reference pyramid.
double evalVolume(const std::array< double, 3 > *vertexCoords) const override
The ReferenceQuadInfo class defines the information about the reference quadrangle.
double evalArea(const std::array< double, 3 > *vertexCoords) const override
std::array< double, 3 > evalNormal(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > &point={{0.5, 0.5, 0.5}}) const override
The ReferenceTetraInfo class defines the information about the reference tetrahedron.
double evalSize(const std::array< double, 3 > *vertexCoords) const override
double evalVolume(const std::array< double, 3 > *vertexCoords) const override
The ReferenceTriangleInfo class defines the information about the reference triangle.
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords) const override
double evalArea(const std::array< double, 3 > *vertexCoords) const override
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords, std::array< double, 3 > *projection, double *distance) const override
double evalSize(const std::array< double, 3 > *vertexCoords) const override
std::array< double, 3 > evalNormal(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > &point={{0.5, 0.5, 0.5}}) const override
The ReferenceVertexInfo class defines the information about the reference vertex.
std::array< double, 3 > evalNormal(const std::array< double, 3 > *vertexCoords, const std::array< double, 3 > &orientation={{1., 0., 0.}}) const override
double evalPointDistance(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords) const override
double evalSize(const std::array< double, 3 > *vertexCoords) const override
void evalPointProjection(const std::array< double, 3 > &point, const std::array< double, 3 > *vertexCoords, std::array< double, 3 > *projection, double *distance) const override
The ReferenceVoxelInfo class defines the information about the reference voxel.
double evalSize(const std::array< double, 3 > *vertexCoords) const override
double evalVolume(const std::array< double, 3 > *vertexCoords) const override
The ReferenceWedgeInfo class defines the information about the reference wedge.
double evalVolume(const std::array< double, 3 > *vertexCoords) const override
--- layout: doxygen_footer ---