Version:

salvus.mesh.algorithms.unstructured_mesh.material_operations

salvus.mesh.algorithms.unstructured_mesh.material_operations salvus mesh algorithms unstructured_mesh material_operations
Mesh operations that involve materials.

Functions

attach_material_to_mesh()

Attach a material to the mesh.
This function creates fields in the mesh for each parameter of the material(s) provided. If multiple materials are provided, an index field must be specified that maps the materials to the mesh elements.
Note that as materials passed can have different parameters, this function will create a field for each unique parameter across all materials. If a parameter is not present in a material, it will be filled with the fill_value specified.
SIGNATURE
def attach_material_to_mesh(
    mesh: UnstructuredMesh,
    materials: material.Material | list[material.Material],
    index_field: str | None = None,
    fill_value: float = 0.0,
    clear_elemental_nodal_fields: bool = False,
) -> None: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh to attach the material to.
Required
materials
Type:material.Material | list[material.Material]
Description:
A single material or a list of materials to attach.
Optional
index_field
Type:str | None
Default value:None
Description:
The name of the field that maps the materials to the mesh elements. This should be an unsigned integer field that indicates which material each element should use. If None, it is assumed that there is only one material and all elements use it.
Optional
fill_value
Type:float
Default value:0.0
Description:
The value to fill in for parameters that are not present in a material.
Optional
clear_elemental_nodal_fields
Type:bool
Default value:False
Description:
If True, all existing elemental nodal fields in the mesh will be cleared before attaching the material. This might be useful to keep mesh size down, and to allow material extraction for mesh qc.
RETURNS
Return type: None
The mesh with the material attached.

split_acoustic_elastic_material_dicts()

Split a material dictionary into acoustic and elastic materials.
This function assumes that the material dictionary contains a 'fluid' field that indicates whether the material for an element of the other arrays (along the first index) is acoustic (fluid) or elastic (solid). The 'fluid' field should be a boolean or uint8 array, where 1 indicates fluid (acoustic) and 0 indicates solid (elastic). The other fields are allowed to be of higher dimensionality, but the first dimension must always be element id.
SIGNATURE
def split_acoustic_elastic_material_dicts(
    material_dict: dict[str, npt.NDArray],
) -> tuple[dict[str, npt.NDArray], dict[str, npt.NDArray], npt.NDArray]: ...
ARGUMENTS
Required
material_dict
Type:dict[str, npt.NDArray]
Description:
A dictionary containing material properties, where the keys are the names of the material properties and the values are numpy arrays. The dictionary must contain a 'fluid' field that indicates whether the material is acoustic (fluid) or elastic (solid).
RETURNS
Return type: tuple[dict[str, npt.NDArray], dict[str, npt.NDArray], npt.NDArray]
A tuple containing two dictionaries: the first for acoustic materials and the second for elastic materials. Each dictionary contains the material properties as numpy arrays, with the first dimension being the element id. Additionally, the fluid mask is returned.

to_material()

Create a material from the mesh, without encoding geometrical information.
SIGNATURE
def to_material(
    mesh: UnstructuredMesh, ignore_fields: typing.Sequence[str] | None = None
) -> material.Material: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
ignore_fields
Type:typing.Sequence[str] | None
Default value:None
Description:
A list of fields to ignore when creating the material.
RETURNS
Return type: material.Material
The material, with all parameters of type array.Parameter.

to_materials()

Create an acoustic and elastic material from the mesh, without encoding geometrical information.
SIGNATURE
def to_materials(
    mesh: UnstructuredMesh, ignore_fields: typing.Sequence[str] | None = None
) -> tuple[
    material.Material | None, material.Material | None, npt.NDArray
]: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Optional
ignore_fields
Type:typing.Sequence[str] | None
Default value:None
Description:
A list of fields to ignore when creating the material.
RETURNS
Return type: tuple[material.Material | None, material.Material | None, npt.NDArray]
A tuple containing the acoustic material, elastic material, and a mask indicating which elements are fluid (acoustic) materials.

transform_material()

Transform the material of a mesh to another compatible material.
SIGNATURE
def transform_material(
    mesh: UnstructuredMesh,
    m: type[material.Material],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> UnstructuredMesh: ...
ARGUMENTS
Required
mesh
Type:UnstructuredMesh
Description:
The mesh.
Required
m
Type:type[material.Material]
Description:
The desired material.
Optional
reduction_method
Type:typing.Literal['remove-components', 'force'] | None
Default value:None
Description:
Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, while remove-components will drop components that are found to match the new material's constraints as necessary, and thus leading to loss of free parameters but not of information. The option "force" will take all information necessary to construct the new parameter set without verification, leading to loss of information.
RETURNS
Return type: UnstructuredMesh
A mesh with replaced elemental nodal fields for the material properties.

Used in tutorials

Functionality from this module is used in the following tutorials.
PAGE CONTENTS