specfem::assembly::mesh

template<specfem::dimension::type 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::dimension::type::dim2> : public specfem::assembly::mesh_impl::points<specfem::dimension::type::dim2>, public specfem::assembly::mesh_impl::quadrature<specfem::dimension::type::dim2>, public specfem::assembly::mesh_impl::control_nodes<specfem::dimension::type::dim2>, public specfem::assembly::mesh_impl::mesh_to_compute_mapping<specfem::dimension::type::dim2>, public specfem::assembly::mesh_impl::shape_functions<specfem::dimension::type::dim2>, public specfem::assembly::mesh_impl::adjacency_graph<specfem::dimension::type::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

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()

Assemble quadrature point coordinates.

Computes physical coordinates for all quadrature points using control nodes and shape functions.

inline Graph &graph()

Get mutable reference to the underlying graph.

Provides direct access to the Boost graph structure for modification operations such as adding edges or vertices.

Returns:

Mutable reference to the Boost adjacency_list graph

inline const Graph &graph() const

Get const reference to the underlying graph.

Provides read-only access to the Boost graph structure for query operations such as traversing edges or checking connectivity.

Returns:

Const reference to the Boost adjacency_list graph

void assert_symmetry() const

Assert that the adjacency graph is symmetric.

Verifies that for every directed edge from vertex A to vertex B, there exists a corresponding edge from vertex B to vertex A. This is required for proper mesh connectivity in spectral element methods.

Throws:

std::runtime_error – if the graph is not symmetric

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::HostMirror h_index_mapping

Global element number for every quadrature point

CoordViewType::HostMirror 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::HostMirror h_hprime

Host Lagrange derivative matrix.

ViewType::HostMirror h_xi

Host GLL points.

ViewType::HostMirror 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::HostMirror h_control_node_mapping

Host mirror view of control node index mapping.

ControlNodeCoordinatesView::HostMirror 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

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::HostMirror h_shape2D

Host mirror view of shape function values.

Shape functions

DShapeFunctionViewType::HostMirror h_dshape2D

Host mirror view of shape function derivatives.

Shape function derivatives

template<>
struct mesh<specfem::dimension::type::dim3> : public specfem::assembly::mesh_impl::points<specfem::dimension::type::dim3>, public specfem::assembly::mesh_impl::quadrature<specfem::dimension::type::dim3>, public specfem::assembly::mesh_impl::control_nodes<specfem::dimension::type::dim3>, public specfem::assembly::mesh_impl::shape_functions<specfem::dimension::type::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

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::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

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

IndexMappingViewType index_mapping

Device index mapping.

IndexMappingViewType::HostMirror h_index_mapping

Host index mapping.

CoordViewType coord

Device coordinates.

CoordViewType::HostMirror h_coord

Host coordinates.

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::HostMirror h_hprime

Host Lagrange derivative matrix.

ViewType::HostMirror h_xi

Host GLL points.

ViewType::HostMirror h_weights

Host weights.

ControlNodeCoordinatesView control_node_coordinates

Device coordinates.

ControlNodeCoordinatesView::HostMirror h_control_node_coordinates

Host coordinates.

ControlNodeIndexView control_node_index

Device indices.

ControlNodeIndexView::HostMirror 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::HostMirror h_shape3D

Host shape functions.

DShapeFunctionViewType::HostMirror h_dshape3D

Host derivatives.

Data Access Functions

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)