specfem::assembly::mesh¶
-
template<specfem::element::dimension_tag Dimension>
struct mesh¶ Assembled 3D mesh representation for spectral element analysis.
- Template Parameters:
Dimension – The spatial dimension (e.g., dim2 or dim3).
Dimension-Specific Implementation¶
-
template<>
struct mesh<specfem::element::dimension_tag::dim2> : public specfem::assembly::mesh_impl::points<specfem::element::dimension_tag::dim2>, public specfem::assembly::mesh_impl::quadrature<specfem::element::dimension_tag::dim2>, public specfem::assembly::mesh_impl::control_nodes<specfem::element::dimension_tag::dim2>, public specfem::assembly::mesh_impl::mesh_to_compute_mapping<specfem::element::dimension_tag::dim2>, public specfem::assembly::mesh_impl::shape_functions<specfem::element::dimension_tag::dim2>, public specfem::assembly::mesh_impl::adjacency_graph<specfem::element::dimension_tag::dim2> 2D assembly-optimized mesh for spectral element computations.
Combines all mesh components (points, control nodes, shape functions, etc.) with compute-optimized ordering for efficient assembly operations.
Inherits functionality from:
points: Quadrature point coordinates and indexing
quadrature: GLL quadrature points and weights
control_nodes: Element control node data
mesh_to_compute_mapping: Element reordering for performance
shape_functions: Shape function values and derivatives
adjacency_graph: Element connectivity information
See also
Public Types
-
using IndexMappingViewType = Kokkos::View<int***, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Kokkos view for storing global element number for every quadrature point.
-
using CoordViewType = Kokkos::View<type_real****, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
Kokkos view for storing coordinates of every distinct quadrature point.
-
using ControlNodeIndexView = Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Kokkos view type for integer index mappings.
-
using ControlNodeCoordinatesView = Kokkos::View<type_real***, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Kokkos view type for real-valued coordinate data.
-
using ShapeFunctionViewType = Kokkos::View<type_real***, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
Kokkos view type for shape function storage.
3D view with dimensions [ngllz, ngllx, ngnod] using right layout for optimal memory access when iterating over control nodes.
-
using DShapeFunctionViewType = Kokkos::View<type_real****, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
Kokkos view type for shape function derivative storage.
4D view with dimensions [ngllz, ngllx, ndim, ngnod] where ndim=2, storing derivatives with respect to both \(\xi\) and \(\zeta\) directions.
Public Functions
-
mesh() = default
Default constructor.
-
mesh(const specfem::mesh::tags<dimension_tag> &tags, const specfem::mesh::control_nodes<dimension_tag> &control_nodes, const specfem::quadrature::quadratures &quadratures, const specfem::mesh::adjacency_graph<dimension_tag> &adjacency_graph)
Constructor from mesh components.
Builds assembly mesh from source mesh data with compute optimization.
- Parameters:
tags – Element tags for reordering
control_nodes – Element control node data
quadratures – GLL quadrature information
adjacency_graph – Element connectivity
-
void assemble(const Kokkos::View<specfem::element::medium_tag*, Kokkos::HostSpace> medium_tags)
Assemble quadrature point coordinates.
Computes physical coordinates for all quadrature points using control nodes and shape functions.
-
inline auto &graph()
Get mutable reference to the local Boost graph.
The assembly adjacency graph only contains intra-partition edges (copied from the mesh graph by
build_assembly_adjacency_graph), so graph() delegates directly to local_connections().
-
inline const auto &graph() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
-
local_connections_return_type local_connections() = delete
Deleted — assembly graph contains only local edges; use graph() instead.
-
mpi_connections_return_type mpi_connections() = delete
Deleted — assembly graph has no cross-partition edges; not applicable.
-
void assert_symmetry() const
Assert that the adjacency graph is symmetric.
Verifies that for every intra-partition directed edge from vertex A to vertex B, there exists a corresponding edge from vertex B to vertex A. Cross-partition edges are skipped because their reverse edge resides in the remote partition’s graph.
- Throws:
std::runtime_error – if a local edge has no symmetric reverse
Public Members
-
int nspec
Number of spectral elements.
-
int ngnod
Number of control nodes per element.
-
specfem::mesh_entity::element_grid<dimension_tag> element_grid
GLL grid info
-
int ngllz
Number of quadrature points in z dimension.
-
int ngllx
Number of quadrature points in x dimension.
-
int nglob
Number of global quadrature points.
-
IndexMappingViewType index_mapping
Global index number for every quadrature point
-
CoordViewType coord
(x, z) for every distinct quadrature point
-
IndexMappingViewType::host_mirror_type h_index_mapping
Global element number for every quadrature point
-
CoordViewType::host_mirror_type h_coord
(x, z) for every distinct quadrature point
-
type_real zmax
Min and max values of x and z coordinates
-
int N
Number of GLL points.
-
ViewType xi
Device GLL points on [-1,1].
-
ViewType weights
Device integration weights.
-
DViewType hprime
Device Lagrange derivative matrix.
-
DViewType::host_mirror_type h_hprime
Host Lagrange derivative matrix.
-
ViewType::host_mirror_type h_xi
Host GLL points.
-
ViewType::host_mirror_type h_weights
Host weights.
-
ControlNodeIndexView control_node_mapping
Device view containing control node indices in compute ordering.
Dimensions: [nspec, ngnod]. Maps from compute-ordered spectral elements to global control node indices.
-
ControlNodeCoordinatesView control_node_coord
Device view containing control node coordinates.
Dimensions: [ndim, nspec, ngnod] where ndim=2 for 2D problems. Stores (x, z) coordinates for each control node of each spectral element.
-
ControlNodeIndexView::host_mirror_type h_control_node_mapping
Host mirror view of control node index mapping.
-
ControlNodeCoordinatesView::host_mirror_type h_control_node_coord
Host mirror view of control node coordinates.
-
ViewType compute_to_mesh
Mapping from compute ordering to mesh ordering
-
ViewType mesh_to_compute
Mapping from mesh ordering to compute ordering
-
ViewType::host_mirror_type h_compute_to_mesh
Host access for compute_to_mesh
-
ViewType::host_mirror_type h_mesh_to_compute
Host access for mesh_to_compute
-
int ngllz
Number of quadrature points in z dimension.
-
int ngllx
Number of quadrature points in x dimension.
-
ShapeFunctionViewType shape2D
Device view containing shape function values.
Shape functions
-
DShapeFunctionViewType dshape2D
Device view containing shape function derivatives.
Shape function derivatives
-
ShapeFunctionViewType::host_mirror_type h_shape2D
Host mirror view of shape function values.
Shape functions
-
DShapeFunctionViewType::host_mirror_type h_dshape2D
Host mirror view of shape function derivatives.
Shape function derivatives
Public Static Attributes
-
static constexpr auto data_class = specfem::data_access::DataClassType::global_coordinates
Data class.
-
template<>
struct mesh<specfem::element::dimension_tag::dim3> : public specfem::assembly::mesh_impl::mesh_to_compute_mapping<specfem::element::dimension_tag::dim3>, public specfem::assembly::mesh_impl::points<specfem::element::dimension_tag::dim3>, public specfem::assembly::mesh_impl::quadrature<specfem::element::dimension_tag::dim3>, public specfem::assembly::mesh_impl::control_nodes<specfem::element::dimension_tag::dim3>, public specfem::assembly::mesh_impl::shape_functions<specfem::element::dimension_tag::dim3>, public specfem::assembly::mesh_impl::adjacency_graph<specfem::element::dimension_tag::dim3> 3D assembly mesh for spectral element computations.
Combines mesh components (points, control nodes, shape functions, quadrature) for efficient 3D hexahedral spectral element assembly operations.
Inherits functionality from:
points: Quadrature point coordinates and indexing
quadrature: GLL quadrature points and weights
control_nodes: Element control node data
shape_functions: Shape function values and derivatives
See also
Public Types
-
using IndexMappingViewType = Kokkos::View<int****, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Index mapping view type.
Dimensions: [nspec, ngllz, nglly, ngllx] for local-to-global mapping.
-
using CoordViewType = Kokkos::View<type_real*****, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Coordinate view type.
Dimensions: [ndim, nspec, ngllz, nglly, ngllx] for (x, y, z) coordinates.
-
using ControlNodeCoordinatesView = Kokkos::View<type_real***, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Kokkos view type for 3D coordinate storage.
Dimensions: [nspec, ngnod, 3] for (x, y, z) coordinates.
-
using ControlNodeIndexView = Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::DefaultExecutionSpace>
Kokkos view type for node index mapping.
Dimensions: [nspec, ngnod] for element-to-node mapping.
-
using ShapeFunctionViewType = Kokkos::View<type_real****, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
Shape function view type.
Dimensions: [ngllz, nglly, ngllx, ngnod].
-
using DShapeFunctionViewType = Kokkos::View<type_real*****, Kokkos::LayoutRight, Kokkos::DefaultExecutionSpace>
Shape function derivative view type.
Dimensions: [ngllz, nglly, ngllx, ndim, ngnod].
Public Functions
-
mesh() = default
Default constructor.
-
mesh(const int nspec, const int ngnod, const int ngllz, const int nglly, const int ngllx, const specfem::mesh::tags<dimension_tag> &tags, const specfem::mesh::adjacency_graph<dimension_tag> &adjacency_graph, const specfem::mesh::control_nodes<dimension_tag> &control_nodes, const specfem::quadrature::quadratures &quadrature)
Constructor from mesh components.
Builds 3D assembly mesh from source mesh data.
- Parameters:
nspec – Number of spectral elements
ngnod – Number of control nodes per element
ngllz – Number of GLL points in z direction
nglly – Number of GLL points in y direction
ngllx – Number of GLL points in x direction
adjacency_graph – Element connectivity
control_nodes – Element control node data
quadrature – GLL quadrature information
-
void assert_symmetry() const
Verify graph symmetry for undirected adjacency relationships.
Validates that the adjacency graph correctly represents undirected element connections by ensuring that for every edge (u,v) there exists a corresponding edge (v,u) with compatible properties. This is essential for spectral element methods where interface coupling is symmetric.
// Validate graph consistency after construction try { adj_graph.assert_symmetry(); std::cout << "Graph adjacency is symmetric" << std::endl; } catch (const std::runtime_error& e) { std::cerr << "Adjacency error: " << e.what() << std::endl; }
- Throws:
std::runtime_error – if asymmetric adjacency is detected
Public Members
-
int nspec
Number of spectral elements.
-
int ngnod
Number of control nodes per element.
-
specfem::mesh_entity::element<dimension_tag> element_grid
3D GLL grid info
-
ViewType compute_to_mesh
Mapping from compute ordering to mesh ordering
-
ViewType mesh_to_compute
Mapping from mesh ordering to compute ordering
-
ViewType::host_mirror_type h_compute_to_mesh
Host mirror for compute_to_mesh
-
ViewType::host_mirror_type h_mesh_to_compute
Host mirror for mesh_to_compute
-
IndexMappingViewType index_mapping
Device index mapping.
-
IndexMappingViewType::host_mirror_type h_index_mapping
Host index mapping
-
CoordViewType coord
Device coordinates.
-
CoordViewType::host_mirror_type h_coord
Host coordinates.
-
type_real xmin
Minimum x coordinate (for tolerance calculations)
-
type_real xmax
Maximum x coordinate (for tolerance calculations)
-
type_real ymin
Minimum y coordinate (for tolerance calculations)
-
type_real ymax
Maximum y coordinate (for tolerance calculations)
-
type_real zmin
Minimum z coordinate (for tolerance calculations)
-
type_real zmax
Maximum z coordinate (for tolerance calculations)
-
int ngllz
Number of GLL points in z dimension.
-
int nglly
Number of GLL points in y dimension.
-
int ngllx
Number of GLL points in x dimension.
-
int nglob
Total number of global points.
-
int N
Number of GLL points.
-
ViewType xi
Device GLL points on [-1,1].
-
ViewType weights
Device integration weights.
-
DViewType hprime
Device Lagrange derivative matrix.
-
DViewType::host_mirror_type h_hprime
Host Lagrange derivative matrix.
-
ViewType::host_mirror_type h_xi
Host GLL points.
-
ViewType::host_mirror_type h_weights
Host weights.
-
ControlNodeCoordinatesView control_node_coordinates
Device coordinates.
-
ControlNodeCoordinatesView::host_mirror_type h_control_node_coordinates
Host coordinates.
-
ControlNodeIndexView control_node_index
Device indices.
-
ControlNodeIndexView::host_mirror_type h_control_node_index
Host indices.
-
int ngllz
Number of GLL points in z direction.
-
int nglly
Number of GLL points in y direction.
-
int ngllx
Number of GLL points in x direction.
-
ShapeFunctionViewType shape3D
Device shape functions.
-
DShapeFunctionViewType dshape3D
Device derivatives.
-
ShapeFunctionViewType::host_mirror_type h_shape3D
Host shape functions.
-
DShapeFunctionViewType::host_mirror_type h_dshape3D
Host derivatives.
Public Static Attributes
-
static constexpr auto data_class = specfem::data_access::DataClassType::global_coordinates
Data class.
Data Access Functions¶
-
template<bool on_device, typename IndexType, typename ContainerType, typename PointType, typename std::enable_if_t<specfem::data_access::is_index_type<IndexType>::value && IndexType::dimension_tag == specfem::element::dimension_tag::dim2 && IndexType::using_simd && PointType::simd::using_simd && specfem::data_access::is_jacobian_matrix<ContainerType>::value, int> = 0>
void impl_load(const IndexType &index, const ContainerType &container, PointType &point)¶ Load global coordinates for a 2D GLL point (implementation)
Load global coordinates for a 3D GLL point (implementation)
- Template Parameters:
on_device – Whether to load from device or host memory
IndexType – Index type. Must be a point index type
ContainerType – Container type. Must have global_coordinates data_class
PointType – Point type. Must be global_coordinates
- Parameters:
index – GLL point index
container – Points container with coordinate data
point – Global coordinates point structure (output)
-
template<bool on_device, typename MemberType, typename ViewType>
void impl_load(const MemberType &team, const specfem::assembly::mesh_impl::quadrature<ViewType::dimension_tag> &quadrature, ViewType &lagrange_derivative)¶ Load quadrature data for a spectral element on host or device.
- Template Parameters:
MemberType – Member type. Needs to be a Kokkos::TeamPolicy member type
ViewType – View type. Needs to be of specfem::quadrature::lagrange_derivative
- Parameters:
team – Team member
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)
-
template<typename MemberType, typename ViewType, typename std::enable_if_t<(ViewType::data_class_type == specfem::data_access::DataClassType::lagrange_derivative), int> = 0>
void load_on_device(const MemberType &team, const specfem::assembly::mesh_impl::quadrature<ViewType::dimension_tag> &quadrature, ViewType &lagrange_derivative)¶ Load quadrature data for a spectral element on the device.
- Template Parameters:
MemberType – Member type. Needs to be a Kokkos::TeamPolicy member type
ViewType – View type. Needs to be of specfem::quadrature::lagrange_derivative
- Parameters:
team – Team member
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)
-
template<typename MemberType, typename ViewType, typename std::enable_if_t<(ViewType::data_class_type == specfem::data_access::DataClassType::lagrange_derivative), int> = 0>
void load_on_host(const MemberType &team, const specfem::assembly::mesh_impl::quadrature<ViewType::dimension_tag> &quadrature, ViewType &lagrange_derivative)¶ Load quadrature data for a spectral element on the host.
- Template Parameters:
MemberType – Member type. Needs to be a Kokkos::TeamPolicy member type
ViewType – View type. Needs to be of specfem::quadrature::lagrange_derivative
- Parameters:
team – Team member
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)
-
template<bool on_device, typename IndexType, typename ViewType>
void impl_load(const IndexType &index, const ViewType &weights, specfem::point::weights<IndexType::dimension_tag> &point_weights)¶ Load weights for a GLL point on host or device.
- Template Parameters:
IndexType – Index type. Needs to be a point index type
ViewType – View type for mesh.weights.
- Parameters:
index – GLL point index
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)
-
template<typename IndexType, typename ViewType, typename std::enable_if_t<(specfem::data_access::is_index_type<IndexType>::value && specfem::data_access::is_point<IndexType>::value), int> = 0>
void load_on_device(const IndexType &index, const ViewType &weights, specfem::point::weights<IndexType::dimension_tag> &point_weights)¶ Load weights for a GLL point on device.
- Template Parameters:
IndexType – Index type. Needs to be a point index type
ViewType – View type for mesh.weights.
- Parameters:
index – GLL point index
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)
-
template<typename IndexType, typename ViewType, typename std::enable_if_t<(specfem::data_access::is_index_type<IndexType>::value && specfem::data_access::is_point<IndexType>::value), int> = 0>
void load_on_host(const IndexType &index, const ViewType &weights, specfem::point::weights<IndexType::dimension_tag> &point_weights)¶ Load weights for a GLL point on the host.
- Template Parameters:
IndexType – Index type. Needs to be a point index type
ViewType – View type for mesh.weights.
- Parameters:
index – GLL point index
mesh – Mesh data
lagrange_derivative – Quadrature data for the element (output)