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_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.
meshUnstructuredMesh — The mesh to attach the material to.materialsmaterial.Material | list[material.Material] — A single material or a list of materials to attach.index_fieldstr | 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_valuefloat — The value to fill in for parameters that are not present in a material.clear_elemental_nodal_fieldsbool — 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.
split_acoustic_elastic_material_dicts()
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.
material_dictdict[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).
to_material()
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.
meshUnstructuredMesh — The mesh.ignore_fieldstyping.Sequence[str] | None — A list of fields to ignore when creating the material.
to_materials()
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.
meshUnstructuredMesh — The mesh.ignore_fieldstyping.Sequence[str] | None — A list of fields to ignore when creating the material.
transform_material()
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.
meshUnstructuredMesh — The mesh.mtype[material.Material] — The desired material.reduction_methodtyping.Literal['remove-components', 'force'] | None — Method to move between incompatible symmetry classes. None will only move to symmetries that are equal or more permissive, whileremove-componentswill 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.