specfem::mesh::materials¶
-
template<specfem::dimension::type Dimension>
struct materials¶ Struct to store materials.
- Template Parameters:
DimensionTag – Dimension type
Dimension-Specific Specializations¶
-
template<>
struct materials<specfem::dimension::type::dim2>¶ Material properties information.
Constructors
< Electromagnetic material propertie TE
-
materials() = default¶
Default constructor.
-
inline materials(const int nspec, const int numat)¶
Constructor used to allocate views.
- Parameters:
nspec – Number of spectral elements
ngnod – Number of control nodes per spectral element
Public Functions
-
template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
inline specfem::medium::material<dimension_tag, MediumTag, PropertyTag> get_material(const int index) const¶ Material material at spectral element index.
- Parameters:
index – Spectral element index
- Returns:
std::variant Material properties
-
template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
inline specfem::mesh::materials<dimension_tag>::material<MediumTag, PropertyTag> &get_container()¶ Get the container object containing properties for a material type.
- Template Parameters:
MediumTag – Medium tag for the material
PropertyTag – Property tag for the material
- Returns:
material<MediumTag, PropertyTag>& material container
-
inline std::tuple<specfem::element::medium_tag, specfem::element::property_tag> get_material_type(const int index) const¶
Get the medium and property types for a given element index.
Returns a tuple containing the medium and property tags associated with the material specification for the specified element index.
// Get material type for element 42 auto [medium, property] = materials.get_material_type(42); // Use in conditional logic if (medium == specfem::element::medium_tag::elastic && property == specfem::element::property_tag::isotropic) { // Handle elastic isotropic case }
- Parameters:
index – Element index to query
- Returns:
Tuple of (medium_tag, property_tag) for the element’s material
Public Members
-
int n_materials¶
Total number of different materials.
-
specfem::kokkos::HostView1d<material_specification> material_index_mapping¶
Mapping of spectral element to material properties
Public Static Attributes
-
template<>
struct material¶
-
template<>
struct material_specification¶ Public Functions
-
material_specification() = default¶
Default constructor.
-
inline material_specification(specfem::element::medium_tag type, specfem::element::property_tag property, int index, int database_index)¶
Constructor used to assign values.
- Parameters:
type – Type of element
property – Property of element
index – Index of material property
Public Members
-
specfem::element::medium_tag type¶
Type of element.
-
specfem::element::property_tag property¶
Property of element.
-
int index¶
Index of material property.
-
int database_index¶
Index of material property in the database.
-
material_specification() = default¶
-
materials() = default¶
-
template<>
struct materials<specfem::dimension::type::dim3>¶ 3D specialization for MESHFEM3D material database management
This specialized implementation manages material properties for 3D spectral element simulations generated by MESHFEM3D. It provides:
Storage for materials read from MESHFEM3D database files
Type-safe material containers organized by medium and property types
Mapping between spectral elements and their material specifications
Template metaprogramming for compile-time material type dispatch
This ensures comprehensive material support while maintaining type safety and enabling compile-time optimizations in the spectral element framework.
// Create materials database for 1000 elements with 5 unique materials spectral::mesh::meshfem3d::materials<specfem::dimension::type::dim3> materials(1000, 5); // Add an isotropic elastic material from MESHFEM3D database specfem::medium::material<specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic> elastic_mat; materials.add_material(elastic_mat, database_index); // Retrieve material for element during simulation auto material = materials.get_material<specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic>(elem_id);
See also
See also
FOR_EACH_IN_PRODUCT
Core Data Members
-
int n_materials¶
Total number of materials across all type containers.
-
int nspec¶
Total number of spectral elements in the mesh.
-
std::vector<material_specification> material_index_mapping¶
Mapping from element index to material specification.
For each spectral element in the mesh, stores the material specification that identifies which material container and index to use for retrieving the element’s material properties. This provides the link between mesh topology and material database entries.
Material Access Interface
-
template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
inline specfem::medium::material<dimension_tag, MediumTag, PropertyTag> get_material(const int index) const¶ Retrieve material object for a specific element with type safety.
Returns the material object associated with the given element index using compile-time template parameters for the specified medium and property types.
// Retrieve elastic isotropic material for element 42 auto elastic_material = materials.get_material< specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic>(42); // Access material properties auto density = elastic_material.get_density(); auto vp = elastic_material.get_p_velocity(); auto vs = elastic_material.get_s_velocity(); // Use in wave equation computations compute_elastic_forces(elastic_material, element_coords);
- Template Parameters:
MediumTag – Medium type (acoustic, elastic)
PropertyTag – Property type (isotropic, anisotropic)
- Parameters:
index – Element index to retrieve material for
- Returns:
Material object with specified medium and property types
-
template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
inline specfem::mesh::materials<dimension_tag>::material<MediumTag, PropertyTag> &get_container()¶ Get reference to material container for specific medium and property types.
Returns a reference to the internal container storing materials of the specified type combination for direct access by material management functions.
// Get container for elastic isotropic materials auto& elastic_container = materials.get_container< specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic>(); // Access container properties int num_elastic_materials = elastic_container.n_materials; auto& material_vector = elastic_container.element_materials; // Direct manipulation (use with caution) elastic_container.element_materials.reserve(expected_count);
- Template Parameters:
MediumTag – Medium type (acoustic, elastic)
PropertyTag – Property type (isotropic, anisotropic)
- Returns:
Reference to the material container for specified types
-
template<specfem::element::medium_tag MediumTag, specfem::element::property_tag PropertyTag>
inline int add_material(const specfem::medium::material<dimension_tag, MediumTag, PropertyTag> &new_material)¶ Add a new material to the database.
Adds a material to the appropriate container based on its type, updates counts, and creates mapping to the original MESHFEM3D database index.
// Add elastic isotropic material from MESHFEM3D database specfem::medium::material<specfem::element::medium_tag::elastic, specfem::element::property_tag::isotropic> mat; const auto index = materials.add_material(mat);
- Template Parameters:
MediumTag – Medium type (acoustic, elastic)
PropertyTag – Property type (isotropic, anisotropic)
- Parameters:
new_material – Material object to add
database_index – Original MESHFEM3D database index
- Returns:
Local index of the added material within its container
-
inline std::tuple<specfem::element::medium_tag, specfem::element::property_tag> get_material_type(const int index) const¶
Get the medium and property types for a given element index.
Returns a tuple containing the medium and property tags associated with the material specification for the specified element index.
// Get material type for element 42 auto [medium, property] = materials.get_material_type(42); // Use in conditional logic if (medium == specfem::element::medium_tag::elastic && property == specfem::element::property_tag::isotropic) { // Handle elastic isotropic case }
- Parameters:
index – Element index to query
- Returns:
Tuple of (medium_tag, property_tag) for the element’s material
Public Static Attributes
-
template<>
struct material¶ Template container for materials of specific type and property.
Stores material objects of a specific medium/property combination with count tracking for efficient memory management. Each container holds materials of exactly one type (e.g., all elastic isotropic materials).
This design enables:
Type-safe material storage and retrieval
Efficient memory layout for materials of the same type
Compile-time optimization based on material properties
Integration with SPECFEM++ template metaprogramming system
- Template Parameters:
type – Medium type (acoustic, elastic)
property – Property type (isotropic, anisotropic)
Public Functions
-
inline material()¶
Default constructor creating empty container.
-
material(const int n_materials, const std::vector<specfem::medium::material<dimension_tag, type, property>> &l_material)¶
Construct container from existing material vector.
- Parameters:
n_materials – Number of materials to store
l_material – Vector of materials to initialize container with
-
template<>
struct material_specification¶ Material specification linking elements to material database entries.
Associates spectral elements with their corresponding material types and database indices from MESHFEM3D material files. This structure provides the mapping between mesh topology and material properties.
Used internally to maintain the association between:
Element indices in the mesh
Material types (medium + property combinations)
Original database indices from MESHFEM3D input files
Local indices within type-specific material containers
Public Functions
-
material_specification() = default¶
Default constructor initializing with default values.
-
inline material_specification(specfem::element::medium_tag type, specfem::element::property_tag property, int index, int database_index)¶
Construct material specification from components.
- Parameters:
type – Physical medium type for wave equation selection
property – Material property type for constitutive relations
index – Local material index within container
database_index – Original MESHFEM3D database index
Public Members
-
specfem::element::medium_tag type¶
Physical medium type (acoustic, elastic, etc.)
-
specfem::element::property_tag property¶
Material property type (isotropic, anisotropic)
-
int index¶
Local index within the type-specific material container.
-
int database_index¶
Original database index from MESHFEM3D material files.
Implementation Details¶
specfem::mesh::materials< specfem::dimension::type::dim2 >::material_specificationspecfem::mesh::materials< specfem::dimension::type::dim2 >::materialspecfem::mesh::materials< specfem::dimension::type::dim3 >::material_specificationspecfem::mesh::materials< specfem::dimension::type::dim3 >::material