Mondaic
This API reference is not for the latest stable Salvus version.

salvus.mesh.layered_meshing.utils.blend

Functions related to blending materials.

Functions

blend()

def blend(
    material: salvus.mesh.layered_meshing.material._material.Material,
    blend_with: salvus.mesh.layered_meshing.material._material.Material,
    blend_method_constant: Union[
        typing_extensions.Literal["average"],
        salvus.mesh.layered_meshing.utils.blend._BlendingProtocol,
    ] = "average",
    blend_method_discrete: Union[
        typing_extensions.Literal["linear", "cosine"],
        salvus.mesh.layered_meshing.utils.blend._BlendingProtocol,
    ] = "linear",
) -> salvus.mesh.layered_meshing.material._material.Material:
    ...

Blend a material with another.

“Blending” in this context refers to constructing a material from a combination of itself and another, compatible material. To be compatible, the following conditions must hold as of now:

- Both materials must be of the same type and parameterization.
- The types of each parameter within each material must match. For
  instance, if a parameter `RHO` in one material is a
  `ConstantParameter`, `RHO` in the other must also be a
  `ConstantParameter.
- The material itself must be realized.
- No analytic parameters are present in either material.

If any of these conditions are violated, this function will return an error.

Each parameter within the blended material will be blended according to its blend_method. The details of each method are expanded upon in the args documentation below.

Parameters
  • material salvus.mesh.layered_meshing.material._material.Material — A material. blend_with will be blended into this value.
  • blend_with salvus.mesh.layered_meshing.material._material.Material — A material. Will be blended into material.
  • blend_method_constant Union[typing_extensions.Literal['average'], salvus.mesh.layered_meshing.utils.blend._BlendingProtocol] — The method with which to blend constant parameters. Can be one of: - "average": Return the average of the two parameters. - A callable implementing the _Blender protocol.
  • blend_method_discrete Union[typing_extensions.Literal['linear', 'cosine'], salvus.mesh.layered_meshing.utils.blend._BlendingProtocol] — The method with which to blend discrete parameters. Can be one of: - "linear": Blend materials with a linear gradient over the vertical coordinate. The weight of blend_with will be 1.0 at the top tapering to 0.0 at the bottom, while material exhibits the opposite behavior.. - "cosine": Blend materials using a cosine filter over the vertical coordinate. The weight of blend_with will be 1.0 a the top tapering to 0.0 at the bottom, while material exhibits the opposite behavior. - A callable implementing the _Blender protocol.
Returns salvus.mesh.layered_meshing.material._material.Material — A new, blended material.

validate_discrete_blend()

def validate_discrete_blend(
    blend_f: salvus.mesh.layered_meshing.utils.blend,
) -> salvus.mesh.layered_meshing.utils.blend:
    ...

Validator used to ensure discrete parameters are suitable for blending.

Meant to be used as a decorator.

Parameters
  • blend_f salvus.mesh.layered_meshing.utils.blend — The discrete blending function.
Returns salvus.mesh.layered_meshing.utils.blend — The blending function blend_f wrapped in a validator.