|
Mallard 0.8.0
Unstructured, GPU accelerated, high-order finite volume CFD solver
Mallard website |
#include <mesh.h>
Classes | |
| struct | BoundaryFace |
| A boundary face (2 nodes in 2D; 3 or 4 nodes in 3D) and its zone name. More... | |
| struct | PeriodicPair |
| A periodic pair of boundary zones: zone_b is zone_a translated by translation. More... | |
Public Member Functions | |
| Mesh () | |
| Construct a new Mesh object. | |
| ~Mesh () | |
| Destroy the Mesh object. | |
| void | init (const toml::value &input) |
| Initialize the mesh. | |
| MeshType | get_type () const |
| Get the type of mesh. | |
| void | set_type (MeshType type) |
| Set the type of mesh. | |
| uint32_t | n_face_zones () const |
| Get the number of face zones. | |
| std::vector< FaceZone > * | face_zones () |
| Get the face zones. | |
| FaceZone * | get_face_zone (const std::string &name) |
| Get face zone by name. | |
| uint32_t | h_n_nodes_of_cell (uint32_t i_cell) const |
| Get the number of nodes comprising a cell - host version. | |
| uint32_t | h_n_faces_of_cell (uint32_t i_cell) const |
| Get the number of faces comprising a cell - host version. | |
| uint32_t | h_n_nodes_of_face (uint32_t i_face) const |
| Get the number of nodes comprising a face - host version. | |
| 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. | |
| 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. | |
| 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. | |
| CellType | h_cell_type (uint32_t i_cell) const |
| Get the type of a cell. | |
| 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. | |
| void | compute_cell_centroids () |
| Compute cell centroids. | |
| void | compute_cell_volumes () |
| Compute cell volumes. | |
| void | compute_face_areas () |
| Compute face areas. | |
| void | compute_face_normals () |
| Compute face normals. | |
| void | compute_face_centroids () |
| Compute the face centroids. | |
| void | compute_geometry () |
| Compute all derived geometry (face areas and normals, cell volumes and centroids, face centroids) and the vertex-neighbor adjacency from the node coordinates and connectivity. | |
| void | make_axisymmetric () |
| Turn the planar 2D geometry into that of the solid of revolution about the x axis (y = r >= 0), per radian: cell_measure = int r dA, face_measure = r L (exact for straight edges), and cell_coords become the r-weighted centroids, where linear functions equal their r-weighted averages. Planar areas, lengths and normals are kept. | |
| 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). | |
| void | compute_cell_neighbors () |
| Build the vertex-neighbor (cells sharing a node) adjacency on the device. | |
| void | copy_host_to_device () |
| Copy mesh data from host to device. | |
| void | copy_device_to_host () |
| Copy mesh data from device to host. | |
| void | init_cart (uint32_t nx, uint32_t ny, rtype Lx, rtype Ly) |
| Initialize the mesh as a cartesian grid. | |
| 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. | |
| 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 into tetrahedra (6, Kuhn), prisms (2) or pyramids (6, apex at the block center). The mixed type uses hexahedra, pyramids and prisms in thirds of x. Boundary zones: left/right (x), bottom/top (y), back/front (z). Nodes are uniform, or clustered toward both ends of each direction with a nonzero stretching factor (see stretched_coordinate). | |
| 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 named face go to the zone unlisted_zone. Cells are triangles and quadrilaterals in 2D; tetrahedra, pyramids, prisms and hexahedra (Gmsh/VTK node order) in 3D. The zones of each periodic pair are joined into interior faces (see docs/design/periodic.md). | |
| 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, const PeriodicNodes &classes) |
| Build the mesh with periodic node classes found beforehand (e.g. across ranks); boundary faces of classes.zones, if given, are dropped. | |
| void | init_from_block (const MeshBlock &block, const std::vector< PeriodicPair > &periodic={}) |
| Build the mesh from a block holding the whole mesh. | |
| void | apply_curved (const curved::Surfaces &surfaces) |
| Curve the faces on the given surfaces (see curved::Geometry): 3D area vectors of the curved faces, and the volumes and centroids of the cells touching them, on the host. Nothing changes for empty surfaces. Collective (checks the analytic shapes against the zones' nodes on every rank). | |
| const std::vector< FaceZone > & | h_face_zones () const |
| The face zones (host). | |
| bool | is_periodic () const |
| Whether some zones were joined periodically. | |
| 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 seen from c is at h_face_coords(f) - h_face_offset(f, c, i). | |
| 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.1) whose named physical curves (surfaces in 3D) become boundary zones. | |
| void | init_wedge (uint32_t nx, uint32_t ny, rtype Lx, rtype Ly) |
| Initialize the supersonic wedge mesh. | |
| 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 ids, so that every rank count builds bitwise identical faces and stencils. | |
| uint32_t | n_owned () const |
| uint32_t | n_reconstructed () const |
| uint32_t | n_complete () const |
| uint8_t | shift_index (const std::array< int8_t, 3 > &lattice) |
| Row of shifts for a lattice offset, added if new. | |
Static Public Member Functions | |
| static std::vector< PeriodicPair > | periodic_pairs (const toml::value &input) |
| Periodic pairs from [[periodic]] entries, and for generated meshes from [mesh] periodic: left/right for x, bottom/top for y, back/front for z. | |
| Mesh::Mesh | ( | ) |
Construct a new Mesh object.
| Mesh::~Mesh | ( | ) |
Destroy the Mesh object.
| void Mesh::apply_curved | ( | const curved::Surfaces & | surfaces | ) |
Curve the faces on the given surfaces (see curved::Geometry): 3D area vectors of the curved faces, and the volumes and centroids of the cells touching them, on the host. Nothing changes for empty surfaces. Collective (checks the analytic shapes against the zones' nodes on every rank).
| void Mesh::compute_cell_centroids | ( | ) |
Compute cell centroids.
| void Mesh::compute_cell_neighbors | ( | ) |
Build the vertex-neighbor (cells sharing a node) adjacency on the device.
| void Mesh::compute_cell_volumes | ( | ) |
Compute cell volumes.
| void Mesh::compute_face_areas | ( | ) |
Compute face areas.
| void Mesh::compute_face_centroids | ( | ) |
Compute the face centroids.
| void Mesh::compute_face_normals | ( | ) |
Compute face normals.
| void Mesh::compute_geometry | ( | ) |
Compute all derived geometry (face areas and normals, cell volumes and centroids, face centroids) and the vertex-neighbor adjacency from the node coordinates and connectivity.
| void Mesh::copy_device_to_host | ( | ) |
Copy mesh data from device to host.
| void Mesh::copy_host_to_device | ( | ) |
Copy mesh data from host to device.
| std::vector< FaceZone > * Mesh::face_zones | ( | ) |
Get the face zones.
Get face zone by name.
| MeshType Mesh::get_type | ( | ) | const |
Get the type of mesh.
| void Mesh::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).
Get the type of a cell.
| i_cell | Index of the cell. |
Get the id of the i-th face of a cell - host version.
| i_cell | Index of the cell. |
| i_face_local | Index of the face. |
Component i of the translation from face f's frame (that of its cell 0) to cell c's frame: the face seen from c is at h_face_coords(f) - h_face_offset(f, c, i).
Global id of local cell i_cell (i_cell itself unless distributed). Connectivity is ordered by global ids, so that every rank count builds bitwise identical faces and stencils.
Get the number of faces comprising a cell - host version.
| i_cell | Index of the cell. |
Get the number of nodes comprising a cell - host version.
| i_cell | Index of the cell. |
Get the number of nodes comprising a face - host version.
| i_face | Index of the face. |
| void Mesh::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.
| i_cell | Index of the cell. |
| n_order | Maximum graph distance. |
| neighbors | Vector to store the neighbors. |
Get the id of the i-th node of a cell - host version.
| i_cell | Index of the cell. |
| i_node_local | Index of the node. |
Get the id of the i-th node of a face - host version.
| i_face | Index of the face. |
| i_node_local | Index of the node. |
Initialize the mesh as a cartesian grid.
| nx | Number of cells in the x-direction. |
| ny | Number of cells in the y-direction. |
| Lx | Length of the domain in the x-direction. |
| Ly | Length of the domain in the y-direction. |
| void Mesh::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 into tetrahedra (6, Kuhn), prisms (2) or pyramids (6, apex at the block center). The mixed type uses hexahedra, pyramids and prisms in thirds of x. Boundary zones: left/right (x), bottom/top (y), back/front (z). Nodes are uniform, or clustered toward both ends of each direction with a nonzero stretching factor (see stretched_coordinate).
Initialize the mesh as a cartesian grid, with each cell split into two triangles.
| nx | Number of cells in the x-direction. |
| ny | Number of cells in the y-direction. |
| Lx | Length of the domain in the x-direction. |
| Ly | Length of the domain in the y-direction. |
| void Mesh::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.1) whose named physical curves (surfaces in 3D) become boundary zones.
| void Mesh::init_from_block | ( | const MeshBlock & | block, |
| const std::vector< PeriodicPair > & | periodic = {} |
||
| ) |
Build the mesh from a block holding the whole mesh.
| void Mesh::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, | ||
| const PeriodicNodes & | classes | ||
| ) |
Build the mesh with periodic node classes found beforehand (e.g. across ranks); boundary faces of classes.zones, if given, are dropped.
| void Mesh::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 named face go to the zone unlisted_zone. Cells are triangles and quadrilaterals in 2D; tetrahedra, pyramids, prisms and hexahedra (Gmsh/VTK node order) in 3D. The zones of each periodic pair are joined into interior faces (see docs/design/periodic.md).
Initialize the supersonic wedge mesh.
| nx | Number of cells in the x-direction. |
| ny | Number of cells in the y-direction. |
| Lx | Length of the domain in the x-direction. |
| Ly | Length of the domain in the y-direction. |
|
inline |
Whether some zones were joined periodically.
| void Mesh::make_axisymmetric | ( | ) |
Turn the planar 2D geometry into that of the solid of revolution about the x axis (y = r >= 0), per radian: cell_measure = int r dA, face_measure = r L (exact for straight edges), and cell_coords become the r-weighted centroids, where linear functions equal their r-weighted averages. Planar areas, lengths and normals are kept.
|
inline |
| uint32_t Mesh::n_face_zones | ( | ) | const |
Get the number of face zones.
|
inline |
|
inline |
|
static |
Periodic pairs from [[periodic]] entries, and for generated meshes from [mesh] periodic: left/right for x, bottom/top for y, back/front for z.
Row of shifts for a lattice offset, added if new.
| Kokkos::View<rtype *[3]> Mesh::cell_covariance |
| Kokkos::View<rtype *> Mesh::cell_measure |
| Kokkos::View<rtype *> Mesh::cell_volume |
| Kokkos::View<uint32_t *> Mesh::cells_of_cell |
| Kokkos::View<uint8_t *> Mesh::cells_of_cell_shift |
| Kokkos::View<int32_t *[2]> Mesh::cells_of_face |
| std::shared_ptr<const curved::Geometry> Mesh::curved_geometry |
| Kokkos::View<rtype *> Mesh::face_area |
| Kokkos::View<rtype *> Mesh::face_measure |
| Kokkos::View<uint8_t *> Mesh::face_shift |
| Kokkos::View<uint32_t *> Mesh::faces_of_cell |
| Kokkos::View<rtype*[N_DIM]>::host_mirror_type Mesh::h_cell_coords |
| Kokkos::View<rtype*[3]>::host_mirror_type Mesh::h_cell_covariance |
| Kokkos::View<rtype*>::host_mirror_type Mesh::h_cell_measure |
| Kokkos::View<rtype*>::host_mirror_type Mesh::h_cell_volume |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_cells_of_cell |
| Kokkos::View<uint8_t*>::host_mirror_type Mesh::h_cells_of_cell_shift |
| Kokkos::View<int32_t*[2]>::host_mirror_type Mesh::h_cells_of_face |
| Kokkos::View<rtype*>::host_mirror_type Mesh::h_face_area |
| Kokkos::View<rtype*[N_DIM]>::host_mirror_type Mesh::h_face_coords |
| Kokkos::View<rtype*>::host_mirror_type Mesh::h_face_measure |
| Kokkos::View<rtype*[N_DIM]>::host_mirror_type Mesh::h_face_normals |
| Kokkos::View<uint8_t*>::host_mirror_type Mesh::h_face_shift |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_faces_of_cell |
| std::vector<uint64_t> Mesh::h_global_cell_id |
| std::vector<uint64_t> Mesh::h_global_node_id |
| Kokkos::View<rtype*[N_DIM]>::host_mirror_type Mesh::h_node_coords |
| std::vector<uint32_t> Mesh::h_node_key |
| std::vector<std::array<int8_t, 3> > Mesh::h_node_lattice |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_nodes_of_cell |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_nodes_of_face |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_offsets_cells_of_cell |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_offsets_faces_of_cell |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_offsets_nodes_of_cell |
| Kokkos::View<uint32_t*>::host_mirror_type Mesh::h_offsets_nodes_of_face |
| Kokkos::View<rtype*[N_DIM]>::host_mirror_type Mesh::h_shifts |
| std::vector<curved::SurfaceFace> Mesh::high_order_faces |
| uint32_t Mesh::n_cells |
| uint32_t Mesh::n_complete_cells = 0 |
| uint32_t Mesh::n_faces |
| uint64_t Mesh::n_global_cells = 0 |
| uint64_t Mesh::n_global_nodes = 0 |
| uint32_t Mesh::n_nodes |
| uint32_t Mesh::n_owned_cells = 0 |
| uint32_t Mesh::n_reconstructed_cells = 0 |
| Kokkos::View<uint32_t *> Mesh::nodes_of_cell |
| Kokkos::View<uint32_t *> Mesh::nodes_of_face |
| Kokkos::View<uint32_t *> Mesh::offsets_cells_of_cell |
| Kokkos::View<uint32_t *> Mesh::offsets_faces_of_cell |
| Kokkos::View<uint32_t *> Mesh::offsets_nodes_of_cell |
| Kokkos::View<uint32_t *> Mesh::offsets_nodes_of_face |
| std::vector<std::string> Mesh::periodic_zones |
| std::vector<std::array<int8_t, 3> > Mesh::shift_lattice |