20#include <unordered_map>
22#include <Kokkos_Core.hpp>
39static const std::unordered_map<std::string, MeshType> MESH_TYPES = {
50static const std::unordered_map<MeshType, std::string> MESH_NAMES = {
73static const std::unordered_map<std::string, CellType> CELL_TYPES = {
82static const std::unordered_map<CellType, std::string> CELL_NAMES = {
105 std::vector<std::array<std::array<double, 3>, 4>> & tets);
136 void init(
const toml::value & input);
143 static std::vector<PeriodicPair>
periodic_pairs(
const toml::value & input);
232 std::vector<uint32_t> & neighbors)
const;
348 const std::vector<std::vector<uint32_t>> &
cells,
349 const std::vector<BoundaryFace> & boundary_faces,
351 const std::vector<PeriodicPair> & periodic = {});
359 const std::vector<std::vector<uint32_t>> &
cells,
360 const std::vector<BoundaryFace> & boundary_faces,
378 const std::vector<FaceZone> &
h_face_zones()
const {
return m_face_zones; }
397 void init_file(
const std::string &
filename,
const std::vector<PeriodicPair> & periodic = {});
486 Kokkos::View<rtype *[N_DIM]>::host_mirror_type
h_shifts;
507 std::vector<uint32_t> cells_by_global_id()
const;
512 static void orient_cells_3d(
const std::vector<std::array<rtype, N_DIM>> & nodes,
513 const std::vector<std::vector<uint32_t>> &
cells,
514 std::vector<uint32_t> & offsets, std::vector<uint32_t> & cell_nodes);
516 void allocate_and_fill(
const std::vector<std::array<rtype, N_DIM>> & nodes,
518 const std::vector<uint32_t> & cell_nodes,
522 const std::vector<uint32_t> & face_nodes,
523 const std::vector<std::array<int32_t, 2>> &
face_cells,
525 const std::vector<uint32_t> & interior,
526 const std::map<std::string, std::vector<uint32_t>> &
zone_faces);
530 std::vector<uint32_t> & neighbors)
const;
533 std::vector<CellZone> m_cell_zones;
534 std::vector<FaceZone> m_face_zones;
void h_neighbors_of_cell(uint32_t i_cell, uint8_t n_order, std::vector< uint32_t > &neighbors) const
Get neighbors of a cell up to n_order graph distance.
Definition mesh.cpp:226
Kokkos::View< uint8_t * > cells_of_cell_shift
Definition mesh.h:469
uint32_t h_n_nodes_of_cell(uint32_t i_cell) const
Get the number of nodes comprising a cell - host version.
Definition mesh.cpp:171
rtype h_face_offset(uint32_t f, uint32_t c, int i) const
Component i of the translation from face f's frame (that of its cell 0) to cell c's frame: the face s...
Definition mesh.h:388
uint32_t n_reconstructed() const
Definition mesh.h:428
Kokkos::View< rtype * >::host_mirror_type h_cell_measure
Definition mesh.h:443
std::vector< curved::SurfaceFace > high_order_faces
Definition mesh.h:420
Kokkos::View< uint32_t * > offsets_nodes_of_cell
Definition mesh.h:456
uint32_t n_complete_cells
Definition mesh.h:430
Kokkos::View< uint32_t * >::host_mirror_type h_cells_of_cell
Definition mesh.h:484
std::vector< std::array< int8_t, 3 > > h_node_lattice
Definition mesh.h:497
std::vector< FaceZone > * face_zones()
Get the face zones.
Definition mesh.cpp:139
void compute_cell_volumes()
Compute cell volumes.
Definition mesh.cpp:333
Kokkos::View< uint32_t * > offsets_cells_of_cell
Definition mesh.h:463
Mesh()
Construct a new Mesh object.
Definition mesh.cpp:28
std::vector< std::array< int8_t, 3 > > shift_lattice
Definition mesh.h:499
void init_from_connectivity(const std::vector< std::array< rtype, N_DIM > > &nodes, const std::vector< std::vector< uint32_t > > &cells, const std::vector< BoundaryFace > &boundary_faces, const std::string &unlisted_zone="unassigned", const std::vector< PeriodicPair > &periodic={})
Build the mesh from nodes, cells (any orientation) and named boundary faces. Boundary faces without a...
Definition mesh_io.cpp:42
Kokkos::View< int32_t *[2]>::host_mirror_type h_cells_of_face
Definition mesh.h:483
uint32_t n_nodes
Definition mesh.h:418
Kokkos::View< uint8_t * >::host_mirror_type h_face_shift
Definition mesh.h:487
Kokkos::View< rtype *[N_DIM]> cell_coords
Definition mesh.h:450
Kokkos::View< uint32_t * >::host_mirror_type h_offsets_nodes_of_cell
Definition mesh.h:478
Kokkos::View< rtype * > face_area
Definition mesh.h:452
uint8_t shift_index(const std::array< int8_t, 3 > &lattice)
Row of shifts for a lattice offset, added if new.
Definition mesh.cpp:432
void compute_face_normals()
Compute face normals.
Definition mesh.cpp:381
void h_cell_tetrahedra(uint32_t i_cell, std::vector< std::array< std::array< double, 3 >, 4 > > &tets) const
Tetrahedra of a 3D cell (see cell_tetrahedra).
Definition mesh_3d.cpp:95
Kokkos::View< uint8_t * > face_shift
Definition mesh.h:468
std::vector< std::string > periodic_zones
Definition mesh.h:495
uint32_t h_n_faces_of_cell(uint32_t i_cell) const
Get the number of faces comprising a cell - host version.
Definition mesh.cpp:175
uint32_t h_node_of_face(uint32_t i_face, uint32_t i_node_local) const
Get the id of the i-th node of a face - host version.
Definition mesh.cpp:191
MeshType get_type() const
Get the type of mesh.
Definition mesh.cpp:127
void init_cart(uint32_t nx, uint32_t ny, rtype Lx, rtype Ly)
Initialize the mesh as a cartesian grid.
Definition mesh.cpp:634
bool axisymmetric
Definition mesh.h:440
Kokkos::View< uint32_t * > nodes_of_face
Definition mesh.h:459
void init_wedge(uint32_t nx, uint32_t ny, rtype Lx, rtype Ly)
Initialize the supersonic wedge mesh.
Definition mesh.cpp:642
Kokkos::View< rtype * > face_measure
Definition mesh.h:442
uint32_t n_faces
Definition mesh.h:418
Kokkos::View< uint8_t * >::host_mirror_type h_cells_of_cell_shift
Definition mesh.h:488
uint32_t n_complete() const
Definition mesh.h:431
void compute_face_areas()
Compute face areas.
Definition mesh.cpp:370
Kokkos::View< rtype *[N_DIM]> face_normals
Definition mesh.h:453
Kokkos::View< uint32_t * >::host_mirror_type h_offsets_cells_of_cell
Definition mesh.h:485
~Mesh()
Destroy the Mesh object.
Definition mesh.cpp:32
Kokkos::View< uint32_t * > offsets_nodes_of_face
Definition mesh.h:460
Kokkos::View< uint32_t * > cells_of_cell
Definition mesh.h:462
void init(const toml::value &input)
Initialize the mesh.
Definition mesh.cpp:36
Kokkos::View< rtype *[N_DIM]>::host_mirror_type h_face_normals
Definition mesh.h:475
Kokkos::View< rtype *[N_DIM]>::host_mirror_type h_shifts
Definition mesh.h:486
Kokkos::View< uint32_t * > offsets_faces_of_cell
Definition mesh.h:458
uint32_t n_cells
Definition mesh.h:418
Kokkos::View< rtype *[N_DIM]>::host_mirror_type h_face_coords
Definition mesh.h:476
uint32_t h_n_nodes_of_face(uint32_t i_face) const
Get the number of nodes comprising a face - host version.
Definition mesh.cpp:179
void init_cart_3d(uint32_t nx, uint32_t ny, uint32_t nz, rtype Lx, rtype Ly, rtype Lz, MeshType kind, const std::vector< PeriodicPair > &periodic={}, const Stretching &stretching={})
Initialize a 3D box [0, Lx] x [0, Ly] x [0, Lz] of nx x ny x nz blocks, each a hexahedron or split in...
Definition mesh_3d.cpp:190
Kokkos::View< uint32_t * > faces_of_cell
Definition mesh.h:457
void compute_cell_centroids()
Compute cell centroids.
Definition mesh.cpp:235
Kokkos::View< rtype *[3]> cell_covariance
Definition mesh.h:447
void compute_cell_neighbors()
Build the vertex-neighbor (cells sharing a node) adjacency on the device.
Definition mesh.cpp:441
Kokkos::View< rtype * >::host_mirror_type h_face_area
Definition mesh.h:474
static std::vector< PeriodicPair > periodic_pairs(const toml::value &input)
Periodic pairs from [[periodic]] entries, and for generated meshes from [mesh] periodic: left/right f...
Definition mesh.cpp:87
std::vector< uint32_t > h_node_key
Definition mesh.h:496
void set_type(MeshType type)
Set the type of mesh.
Definition mesh.cpp:131
void compute_geometry()
Compute all derived geometry (face areas and normals, cell volumes and centroids, face centroids) and...
Definition mesh_3d.cpp:104
Kokkos::View< rtype * > cell_measure
Definition mesh.h:441
void make_axisymmetric()
Turn the planar 2D geometry into that of the solid of revolution about the x axis (y = r >= 0),...
Definition mesh.cpp:261
Kokkos::View< int32_t *[2]> cells_of_face
Definition mesh.h:461
uint32_t n_reconstructed_cells
Definition mesh.h:427
std::vector< std::array< rtype, N_DIM > > periodic_translations
Definition mesh.h:494
uint32_t h_face_of_cell(uint32_t i_cell, uint32_t i_face_local) const
Get the id of the i-th face of a cell - host version.
Definition mesh.cpp:187
void copy_device_to_host()
Copy mesh data from device to host.
Definition mesh.cpp:566
uint32_t n_owned() const
Definition mesh.h:425
Kokkos::View< rtype * > cell_volume
Definition mesh.h:451
void compute_face_centroids()
Compute the face centroids.
Definition mesh.cpp:415
Kokkos::View< rtype *[N_DIM]>::host_mirror_type h_node_coords
Definition mesh.h:471
std::vector< uint64_t > h_global_node_id
Definition mesh.h:435
uint32_t n_owned_cells
Definition mesh.h:424
Kokkos::View< rtype *[3]>::host_mirror_type h_cell_covariance
Definition mesh.h:448
Kokkos::View< rtype * >::host_mirror_type h_face_measure
Definition mesh.h:444
std::shared_ptr< const curved::Geometry > curved_geometry
Definition mesh.h:422
CellType h_cell_type(uint32_t i_cell) const
Get the type of a cell.
Definition mesh.cpp:152
uint64_t n_global_nodes
Definition mesh.h:436
void init_from_block(const MeshBlock &block, const std::vector< PeriodicPair > &periodic={})
Build the mesh from a block holding the whole mesh.
Definition mesh_io.cpp:589
Kokkos::View< rtype *[N_DIM]> node_coords
Definition mesh.h:449
uint64_t h_global_cell(uint32_t i_cell) const
Global id of local cell i_cell (i_cell itself unless distributed). Connectivity is ordered by global ...
Definition mesh.h:414
uint32_t h_node_of_cell(uint32_t i_cell, uint32_t i_node_local) const
Get the id of the i-th node of a cell - host version.
Definition mesh.cpp:183
uint64_t n_global_cells
Definition mesh.h:434
std::vector< uint64_t > h_global_cell_id
Definition mesh.h:433
uint32_t n_face_zones() const
Get the number of face zones.
Definition mesh.cpp:135
FaceZone * get_face_zone(const std::string &name)
Get face zone by name.
Definition mesh.cpp:143
bool is_periodic() const
Whether some zones were joined periodically.
Definition mesh.h:381
const std::vector< FaceZone > & h_face_zones() const
The face zones (host).
Definition mesh.h:378
Kokkos::View< rtype *[N_DIM]> shifts
Definition mesh.h:467
void copy_host_to_device()
Copy mesh data from host to device.
Definition mesh.cpp:537
Kokkos::View< rtype *[N_DIM]>::host_mirror_type h_cell_coords
Definition mesh.h:472
Kokkos::View< uint32_t * >::host_mirror_type h_nodes_of_face
Definition mesh.h:481
Kokkos::View< uint32_t * >::host_mirror_type h_offsets_nodes_of_face
Definition mesh.h:482
void apply_curved(const curved::Surfaces &surfaces)
Curve the faces on the given surfaces (see curved::Geometry): 3D area vectors of the curved faces,...
Definition curved.cpp:790
Kokkos::View< rtype * >::host_mirror_type h_cell_volume
Definition mesh.h:473
Kokkos::View< uint32_t * > nodes_of_cell
Definition mesh.h:455
void init_file(const std::string &filename, const std::vector< PeriodicPair > &periodic={})
Read a Mallard HDF5 mesh file (.h5, .hdf5), or an ASCII Gmsh mesh (format 2.2 or 4....
Definition mesh_io.cpp:579
void init_cart_tri(uint32_t nx, uint32_t ny, rtype Lx, rtype Ly)
Initialize the mesh as a cartesian grid, with each cell split into two triangles.
Definition mesh.cpp:638
Kokkos::View< uint32_t * >::host_mirror_type h_nodes_of_cell
Definition mesh.h:477
Kokkos::View< rtype *[N_DIM]> face_coords
Definition mesh.h:454
Kokkos::View< uint32_t * >::host_mirror_type h_offsets_faces_of_cell
Definition mesh.h:480
Kokkos::View< uint32_t * >::host_mirror_type h_faces_of_cell
Definition mesh.h:479
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
float rtype
Definition common_typedef.h:39
Curved (high-order) boundary geometry: face maps, face quadrature and cell integration rules (docs/de...
MeshType
Definition mesh.h:28
CellType
Definition mesh.h:64
std::array< rtype, 3 > Stretching
Tanh stretching factor of each direction of a generated mesh, 0 for uniform spacing.
Definition mesh.h:62
const std::vector< std::vector< uint8_t > > & cell_local_faces(uint32_t n_nodes)
Local faces of a positively oriented 3D cell with n_nodes nodes (4 tetrahedron, 5 pyramid,...
Definition mesh_3d.cpp:64
void cell_tetrahedra(const std::vector< std::array< double, 3 > > &nodes, std::vector< std::array< std::array< double, 3 >, 4 > > &tets)
Decompose a 3D cell (node coordinates in Gmsh/VTK order, positively oriented) into tetrahedra: each f...
Definition mesh_3d.cpp:79
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
A boundary face (2 nodes in 2D; 3 or 4 nodes in 3D) and its zone name.
Definition mesh.h:334
std::vector< uint32_t > nodes
Definition mesh.h:335
std::string zone
Definition mesh.h:336
A periodic pair of boundary zones: zone_b is zone_a translated by translation.
Definition mesh.h:127
std::array< rtype, N_DIM > translation
Definition mesh.h:129
std::string zone_b
Definition mesh.h:128
std::string zone_a
Definition mesh.h:128
Periodic classes of the mesh nodes: the translation of each lattice direction, and per node its key (...
Definition periodic.h:28
The curved boundary of a mesh, identical on every rank: the analytic shapes and every curved boundary...
Definition curved.h:65
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810
Kokkos::View< uint32_t *, Space > cells
Definition teno_setup.cpp:682