Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website
Loading...
Searching...
No Matches
curved.h
Go to the documentation of this file.
1
13#ifndef CURVED_H
14#define CURVED_H
15
16#include <array>
17#include <cstdint>
18#include <map>
19#include <string>
20#include <utility>
21#include <vector>
22
23#include <toml.hpp>
24
25#include "common_typedef.h"
26
27class Mesh;
28struct MeshBlock;
29
30namespace curved {
31
32using Vec3 = std::array<double, 3>;
33
38struct Shape {
39 enum class Kind : uint8_t { CIRCLE, SPHERE, CYLINDER };
41 std::string zone;
42 Vec3 center = {0.0, 0.0, 0.0};
43 Vec3 axis = {0.0, 0.0, 1.0}; // cylinder: unit vector
44 double radius = 1.0;
45
47 void project(const Vec3 & x, Vec3 & p, double * J) const;
48};
49
56 std::vector<uint64_t> corners;
58 std::vector<Vec3> nodes;
59};
60
65struct Surfaces {
66 std::vector<Shape> shapes;
67 std::vector<SurfaceFace> faces;
68
69 bool empty() const { return faces.empty(); }
70};
71
73std::vector<Shape> read_shapes(const toml::value & input);
74
76bool enabled(const toml::value & input);
77
83uint32_t element_order(uint32_t n_corners, uint32_t n_nodes);
84
90Surfaces surfaces_of_mesh(const Mesh & mesh, const toml::value & input);
91
96Surfaces surfaces_of_block(const MeshBlock & block, const toml::value & input);
97
106class Geometry {
107 public:
108 Geometry(const Mesh & mesh, const Surfaces & surfaces);
109
110 bool face_is_curved(uint32_t f) const { return face_index[f] >= 0; }
111 bool cell_is_curved(uint32_t c) const { return curved_cell[c] != 0; }
112 uint32_t n_curved_faces() const { return uint32_t(faces.size()); }
113
118 double max_shape_offset() const;
119
125 void eval(uint32_t f, const double * xi, Vec3 & x, Vec3 * dx) const;
126
128 Vec3 area_vector(uint32_t f) const;
129
137 void face_rule(uint32_t f, const std::vector<std::array<double, 2>> & ref, const std::vector<double> & ref_w,
138 std::vector<Vec3> & x, std::vector<Vec3> & n, std::vector<double> & w) const;
139
145 void cell_rule(uint32_t c, int degree, std::vector<Vec3> & x, std::vector<double> & w) const;
146
147 private:
148 struct Edge {
149 int32_t shape = -1;
150 std::vector<Vec3> nodes; // Lagrange nodes, equispaced from the lower global node id to the higher
151 };
152 struct Face {
153 int32_t shape = -1; // analytic surface face: its own projection
154 std::array<int32_t, 4> edge = {-1, -1, -1, -1}; // local edge k (node k to k + 1), or -1 if straight
155 std::array<uint8_t, 4> flip = {0, 0, 0, 0}; // edge k runs from its higher global node id
156 std::vector<Vec3> bubble; // interior corrections of high-order elements
157 };
158
159 void edge_eval(const Face & face, size_t k, const Vec3 & a, const Vec3 & b, double t, Vec3 & x, Vec3 & dx) const;
160 void face_eval(const Face & face, const std::vector<Vec3> & v, const double * xi, Vec3 & x, Vec3 * dx) const;
161 std::vector<Vec3> face_nodes(uint32_t f) const;
162
163 const Mesh & mesh;
164 std::vector<Shape> shapes;
165 std::vector<Edge> edges;
166 std::vector<Face> faces;
167 std::vector<int32_t> face_index; // per local face: index into faces, or -1
168 std::vector<uint8_t> curved_cell;
169};
170
171} // namespace curved
172
173#endif // CURVED_H
Definition mesh.h:111
Curved geometry of one rank's mesh. Faces are curved where they lie on a curved surface,...
Definition curved.h:106
void face_rule(uint32_t f, const std::vector< std::array< double, 2 > > &ref, const std::vector< double > &ref_w, std::vector< Vec3 > &x, std::vector< Vec3 > &n, std::vector< double > &w) const
Quadrature of face f from a rule on its flat reference element (weights summing to the reference meas...
Definition curved.cpp:678
Vec3 area_vector(uint32_t f) const
The area vector int n dS of face f (out of its cell 0), exact for its edges.
Definition curved.cpp:655
void cell_rule(uint32_t c, int degree, std::vector< Vec3 > &x, std::vector< double > &w) const
Points and signed weights integrating polynomials of the given degree over cell c (curved or not),...
Definition curved.cpp:703
void eval(uint32_t f, const double *xi, Vec3 &x, Vec3 *dx) const
Point x of face f at reference coordinates xi, and its derivatives dx[k] = dx / dxi_k (k < N_DIM - 1)...
Definition curved.cpp:650
double max_shape_offset() const
Largest distance of a node of a projected edge from its analytic shape, relative to the edge's length...
Definition curved.cpp:765
uint32_t n_curved_faces() const
Definition curved.h:112
bool face_is_curved(uint32_t f) const
Definition curved.h:110
bool cell_is_curved(uint32_t c) const
Definition curved.h:111
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
Typedefs for common types.
Definition curved.cpp:25
std::array< double, 3 > Vec3
Definition curved.h:32
Surfaces surfaces_of_block(const MeshBlock &block, const toml::value &input)
The curved surfaces of a mesh spread over the ranks as blocks (collective): every rank gets the faces...
Definition curved.cpp:301
Surfaces surfaces_of_mesh(const Mesh &mesh, const toml::value &input)
The curved surfaces of a whole mesh held by this rank: the high-order faces it was read with (Mesh::h...
Definition curved.cpp:274
bool enabled(const toml::value &input)
[mesh] curved: whether curved geometry is used at all (default true).
Definition curved.cpp:233
std::vector< Shape > read_shapes(const toml::value &input)
Analytic shapes of the [[mesh.curved]] entries (none if [mesh] curved = false).
Definition curved.cpp:238
uint32_t element_order(uint32_t n_corners, uint32_t n_nodes)
Order of a Gmsh boundary element with n_corners corners and n_nodes nodes (1 linear,...
Definition curved.cpp:220
Contiguous ranges of a mesh's cells and nodes and a set of its boundary faces. Global ids are positio...
Definition mesh_block.h:35
An analytic surface onto which the faces of a boundary zone are projected: a circle (2D) or a sphere ...
Definition curved.h:38
std::string zone
Definition curved.h:41
Kind
Definition curved.h:39
double radius
Definition curved.h:44
Kind kind
Definition curved.h:40
Vec3 center
Definition curved.h:42
Vec3 axis
Definition curved.h:43
void project(const Vec3 &x, Vec3 &p, double *J) const
Radial projection p of x onto the shape, and dp/dx (row-major 3 x 3).
Definition curved.cpp:190
A curved boundary face of the whole mesh: its corners (global node ids, in the element's order) and e...
Definition curved.h:55
std::vector< Vec3 > nodes
Definition curved.h:58
int32_t shape
Definition curved.h:57
std::vector< uint64_t > corners
Definition curved.h:56
The curved boundary of a mesh, identical on every rank: the analytic shapes and every curved boundary...
Definition curved.h:65
std::vector< Shape > shapes
Definition curved.h:66
std::vector< SurfaceFace > faces
Definition curved.h:67
bool empty() const
Definition curved.h:69
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810