specfem::mesh::boundaries¶
-
template<specfem::dimension::type DimensionTag>
struct boundaries¶ Struct to store boundaries.
- Template Parameters:
DimensionTag – Dimension type
Dimension-Specific Specializations¶
-
template<>
struct boundaries<specfem::dimension::type::dim2>¶ Boundary information.
- Template Parameters:
DimensionTag – Dimension type for the mesh
Constructors
-
boundaries() = default¶
Default constructor.
-
inline boundaries(const specfem::mesh::absorbing_boundary<dimension_tag> &absorbing_boundary, const specfem::mesh::acoustic_free_surface<dimension_tag> &acoustic_free_surface, const specfem::mesh::forcing_boundary<dimension_tag> &forcing_boundary)¶
Construct a new boundaries object.
- Parameters:
absorbing_boundary – absorbing boundary
acoustic_free_surface – acoustic free surface
forcing_boundary – forcing boundary
Public Members
-
specfem::mesh::absorbing_boundary<dimension_tag> absorbing_boundary¶
Absorbing boundary.
-
specfem::mesh::acoustic_free_surface<dimension_tag> acoustic_free_surface¶
Acoustic free surface
-
specfem::mesh::forcing_boundary<dimension_tag> forcing_boundary¶
Forcing boundary (never used)
-
template<>
struct boundaries<specfem::dimension::type::dim3>¶ Domain boundary manager for 3D spectral element meshes.
This template specialization manages all boundary face information for 3D spectral element simulations, including but not limited to absorbing boundaries. The class stores comprehensive boundary data read from MESHFEM3D database files, encompassing:
Absorbing boundaries: Stacey conditions to prevent spurious reflections
Free surface boundaries: Traction-free conditions at domain surfaces
Interface boundaries: Coupling conditions between different media
Other domain boundaries: Any faces at the mesh exterior
This unified boundary representation allows for efficient processing of all boundary conditions in the spectral element simulation workflow.
// Example usage with MESHFEM3D database file std::ifstream database_stream("MESH/boundaries.bin", std::ios::binary); auto control_nodes = read_control_nodes(database_stream); // Read all domain boundaries from database auto boundaries = specfem::io::mesh_impl::fortran::dim3::meshfem3d::read_boundaries( database_stream, control_nodes); // Process all boundary faces for (int iface = 0; iface < boundaries.nfaces; ++iface) { int element_index = boundaries.index_mapping(iface); auto face_type = boundaries.face_type(iface); // Apply appropriate boundary condition based on face type switch (face_type) { case specfem::mesh_entity::dim3::type::bottom: // Process bottom boundary break; case specfem::mesh_entity::dim3::type::top: // Process top boundary (e.g., free surface) break; // ... handle other face types } }
Public Types
-
using FaceDirection = face_direction¶
Enumeration type alias for face directions.
Public Functions
-
boundaries() = default¶
Default constructor.
Creates an empty boundaries object with zero faces and elements. Use this constructor when boundaries are not required or will be populated later through IO operations or explicit assignment.
-
inline boundaries(const int nfaces, const int nspec)¶
Parameterized constructor for domain boundaries.
Constructs a boundaries object with the specified number of boundary faces and total spectral elements. Allocates Kokkos host memory views for storing element indices and face types read from MESHFEM3D database files. This constructor handles all types of domain boundaries, not just absorbing boundaries.
// Create boundaries container for 120 faces in a mesh with 1000 elements specfem::mesh::boundaries<specfem::dimension::type::dim3> boundaries(120, 1000); // Views are now allocated and ready for data from MESHFEM3D assert(boundaries.nfaces == 120); assert(boundaries.nspec == 1000); assert(boundaries.index_mapping.extent(0) == 120); assert(boundaries.face_type.extent(0) == 120);
Note
The constructor initializes Kokkos views with labeled memory for debugging and profiling purposes. The nspec parameter provides mesh context for boundary processing algorithms.
- Parameters:
nfaces – Number of boundary faces to allocate storage for
nspec – Total number of spectral elements in the mesh
-
inline std::tuple<IndexViewType, FaceViewType> filter(enum face_direction dir)¶
Filter boundary faces by specified direction.
Returns Kokkos views containing the element indices and face types for all boundary faces that match the given direction (X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX). This allows for efficient processing of boundary conditions applied to specific domain boundaries.
// Example: Get all faces on the X_MIN boundary auto [indices, faces] = boundaries.filter( specfem::mesh::boundaries<specfem::dimension::type::dim3>::face_direction::X_MIN); // Process each face on the X_MIN boundary for (size_t i = 0; i < indices.extent(0); ++i) { int element_index = indices(i); auto face_type = faces(i); // Apply X_MIN boundary condition based on face_type }
- Parameters:
dir – The face direction to filter by (X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX)
- Returns:
A tuple of Kokkos views:
First: View of element indices for matching boundary faces
Second: View of face types for matching boundary faces
Public Members
-
int nfaces¶
Total number of domain boundary faces.
-
int nspec¶
Total number of spectral elements in the mesh.
-
IndexViewType index_mapping¶
Mapping from boundary face index to spectral element index.
This Kokkos host view stores the spectral element indices that contain boundary faces. Each entry corresponds to the element that owns the boundary face at the same index position.
-
FaceViewType face_type¶
Type identifier for each domain boundary face.
This Kokkos host view stores the geometric face type (bottom, top, front, back, left, right) for each boundary face.
See also
specfem::mesh_entity::dim3::type for complete face enumeration
-
FaceDirectionViewType face_direction
Direction identifier for each domain boundary face.
This Kokkos host view stores the directional classification (X_MIN, X_MAX, Y_MIN, Y_MAX, Z_MIN, Z_MAX) for each boundary face.
This Kokkos host view is essential for applying boundary conditions in the correct direction during spectral element computations.
Public Static Attributes
Private Types
-
enum class face_direction : int¶
Enumeration of face directions for 3D boundaries.
Values:
-
enumerator X_MIN¶
-
enumerator X_MAX¶
-
enumerator Y_MIN¶
-
enumerator Y_MAX¶
-
enumerator Z_MIN¶
-
enumerator Z_MAX¶
-
enumerator X_MIN¶
-
using IndexViewType = Kokkos::View<int*, Kokkos::HostSpace>¶
Kokkos view type for storing element indices on host memory.
-
using FaceViewType = Kokkos::View<specfem::mesh_entity::dim3::type*, Kokkos::HostSpace>¶
Kokkos view type for storing face types on host memory.
-
using FaceDirectionViewType = Kokkos::View<face_direction*, Kokkos::HostSpace>¶
Kokkos view type for storing face directions on host memory.