Mondaic

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

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

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.

Parameters
  • mesh UnstructuredMesh — The mesh to attach the material to.
  • materials material.Material | list[material.Material] — A single material or a list of materials to attach.
  • index_field str | None — 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.
  • fill_value float — The value to fill in for parameters that are not present in a material.
  • clear_elemental_nodal_fields bool — 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 None — The mesh with the material attached.

split_acoustic_elastic_material_dicts()

def split_acoustic_elastic_material_dicts(
    material_dict: dict[str, npt.NDArray],
) -> tuple[dict[str, npt.NDArray], dict[str, npt.NDArray], npt.NDArray]: ...

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.

Parameters
  • material_dict dict[str, npt.NDArray] — 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 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()

def to_material(
    mesh: UnstructuredMesh, ignore_fields: typing.Sequence[str] | None = None
) -> material.Material: ...

Create a material from the mesh, without encoding geometrical information.

Parameters
  • mesh UnstructuredMesh — The mesh.
  • ignore_fields typing.Sequence[str] | None — A list of fields to ignore when creating the material.
Returns material.Material — The material, with all parameters of type array.Parameter.

to_materials()

def to_materials(
    mesh: UnstructuredMesh, ignore_fields: typing.Sequence[str] | None = None
) -> tuple[
    material.Material | None, material.Material | None, npt.NDArray
]: ...

Create an acoustic and elastic material from the mesh, without encoding geometrical information.

Parameters
  • mesh UnstructuredMesh — The mesh.
  • ignore_fields typing.Sequence[str] | None — A list of fields to ignore when creating the material.
Returns 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()

def transform_material(
    mesh: UnstructuredMesh,
    m: type[material.Material],
    reduction_method: (
        typing.Literal["remove-components", "force"] | None
    ) = None,
) -> UnstructuredMesh: ...

Transform the material of a mesh to another compatible material.

Parameters
  • mesh UnstructuredMesh — The mesh.
  • m type[material.Material] — The desired material.
  • reduction_method typing.Literal['remove-components', 'force'] | None — 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 UnstructuredMesh — A mesh with replaced elemental nodal fields for the material properties.

Used in tutorials