specfem::mesh::mesh¶
-
template<specfem::element::dimension_tag DimensionTag>
struct mesh¶ Struct to store information about the mesh read from the database.
- Template Parameters:
DimensionTag – Dimension type
Dimension-Specific Specializations¶
-
template<>
struct mesh<specfem::element::dimension_tag::dim2>¶ Constructors
-
inline mesh()¶
Default mesh constructor.
-
inline mesh(const int npgeo, const int nspec, const int nproc, const specfem::mesh::control_nodes<dimension> &control_nodes, const specfem::mesh::parameters<dimension> ¶meters, const specfem::mesh::boundaries<dimension> &boundaries, const specfem::mesh::tags<dimension> &tags, const specfem::mesh::elements::tangential_elements<dimension> &tangential_nodes, const specfem::mesh::elements::axial_elements<dimension> &axial_nodes, const specfem::mesh::materials<dimension> &materials)¶
Mesh constructor.
This constructor initializes the mesh struct with the given parameters
// Example of how to use this constructor specfem::mesh::mesh<dimension> mesh( npgeo, nspec, nproc, control_nodes, parameters, coupled_interfaces, boundaries, tags, tangential_nodes, axial_nodes, materials);
- Parameters:
npgeo – Total number of spectral element control nodes
nspec – Total number of spectral elements
nproc – Total number of processors
control_nodes – Struct to store control nodes
parameters – Struct to store simulation launch parameters
coupled_interfaces – Struct to store coupled interfaces
boundaries – Struct to store information at the boundaries
tags – Struct to store tags for every spectral element
tangential_nodes – Struct to store tangential nodes
axial_nodes – Struct to store axial nodes
materials – Struct to store material properties
Public Functions
-
std::string print() const¶
Print mesh information.
This function prints the mesh information
// Example of how to use this function std::string mesh_info = mesh.print();
- Returns:
std::string String containing the mesh information
-
void check_consistency() const¶
Checks the consistency of the mesh data structure.
This function verifies the internal consistency of the mesh, ensuring that all mesh components (such as control nodes, boundaries, materials, etc.) are correctly initialized and compatible with each other. It is intended to catch configuration or initialization errors before running simulations.
- Throws:
std::runtime_error – if any inconsistency is detected within the mesh.
-
void setup_coupled_interfaces(const std::set<std::pair<int, int>> &coupled_interfaces)¶
Setup and check coupled interfaces in the mesh.
This function checks whether the coupled interfaces are correctly defined in the mesh data structure and are contistent with the adjacency graph.
Note
This function should be called after the mesh has been fully initialized and all components (control nodes, materials, boundaries) have been populated from MESHFEM2D database files.
Public Members
-
int npgeo¶
Total number of spectral element control nodes.
-
int nspec¶
Total number of spectral elements.
-
int nproc¶
Total number of processors.
-
specfem::mesh::control_nodes<dimension> control_nodes¶
Defines control nodes
-
specfem::mesh::boundaries<dimension> boundaries¶
Struct to store information at the boundaries
Public Static Attributes
-
static constexpr auto dimension = specfem::element::dimension_tag::dim2¶
Dimension.
-
inline mesh()¶
-
template<>
struct mesh<specfem::element::dimension_tag::dim3>¶ 3D mesh data container for MESHFEM3D-generated spectral element meshes
This template specialization manages 3D mesh data structures generated by MESHFEM3D. The mesh structure serves as the primary data interface between MESHFEM3D database files and the SPECFEM++ computational engine.
This design follows the SPECFEM3D workflow where MESHFEM3D generates binary database files containing pre-computed mesh information, which are then read by the main solver for efficient spectral element computations.
// Example: Reading a MESHFEM3D database std::string param_file = "MESH/parameters.bin"; std::string database_file = "MESH/database.bin"; // Read mesh from MESHFEM3D binary files auto mesh = specfem::io::meshfem3d::read_3d_mesh(param_file, database_file); // Access mesh components int num_nodes = mesh.control_nodes.ngnod; int num_materials = mesh.materials.number_of_materials; int num_absorbing_faces = mesh.absorbing_boundaries.nfaces; // Use in spectral element computation // (mesh data is typically passed to solver initialization)
See also
specfem::io::meshfem3d::read_3d_mesh
See also
See also
See also
- Template Parameters:
specfem::element::dimension_tag::dim3 – Template specialization for 3D spatial dimension
Public Functions
-
void setup_coupled_interfaces()¶
Setup coupled interfaces in the mesh.
Coupled interfaces are essential for multi-domain simulations where different materials or physical models interact at shared boundaries.
Note
This function should be called after the mesh has been fully initialized and all components (control nodes, materials, boundaries) have been populated from MESHFEM3D database files.
-
mesh() = default¶
Default constructor.
Creates an empty mesh structure with default-initialized components. This constructor is typically used internally by IO routines which populate the mesh data by reading from MESHFEM3D database files.
// Internal usage in IO routines specfem::mesh::mesh<specfem::element::dimension_tag::dim3> mesh; mesh.control_nodes = read_control_nodes(stream); mesh.materials = read_materials(stream); mesh.absorbing_boundaries = read_absorbing_boundaries(stream);
-
~mesh() = default¶
Default destructor.
Automatically destroys all mesh components. Memory management is handled by the individual component destructors (ControlNodes, Materials, AbsorbingBoundaries).
Public Members
-
int nspec¶
Number of spectral elements in the mesh.
-
int utm_projection_zone = 0¶
UTM projection zone (positive = Northern hemisphere, negative = Southern). Range: ±1–60. Only meaningful when suppress_utm_projection is false.
-
bool suppress_utm_projection = true¶
When true, mesh coordinates are Cartesian (no lat/lon to UTM conversion needed). When false, source/receiver lat/lon must be converted to UTM using utm_projection_zone.
-
specfem::mesh::control_nodes<dimension_tag> control_nodes¶
Control node geometric data container.
Stores coordinate information and connectivity data for control nodes that define the geometric structure of spectral elements. These nodes are read from MESHFEM3D database files and represent the high-order geometric mapping points used in spectral element discretization.
See also
-
specfem::mesh::materials<dimension_tag> materials¶
Material properties database.
Contains physical material properties (elastic, acoustic, poroelastic) mapped to different regions of the mesh. Materials are organized by medium type and property characteristics, enabling efficient material property lookup during spectral element computations.
See also
-
specfem::mesh::boundaries<dimension_tag> boundaries¶
Absorbing boundary condition specifications.
Stores information about mesh faces designated as absorbing boundaries for implementing Stacey absorbing boundary conditions. These boundaries prevent spurious wave reflections at domain edges by absorbing outgoing seismic waves.
See also
-
specfem::mesh::adjacency_graph<dimension_tag> adjacency_graph¶
Element adjacency graph.
Represents the connectivity relationships between spectral elements in the mesh.
See also
specfem::mesh::adjacency_graph
-
specfem::mesh::tags<dimension_tag> tags¶
Tags associated with each spectral element.
Stores the tags for each spectral element, which specify medium type, property type, and boundary conditions.
Public Static Attributes
-
static constexpr auto dimension_tag = specfem::element::dimension_tag::dim3¶
Dimension tag.