Version:

salvus.mesh.layered_meshing.layered_model.layer

salvus.mesh.layered_meshing.layered_model.layer salvus mesh layered_meshing layered_model layer
A single layer.

Classes

Layer

A layer consists of a model bounded by two interface.
SIGNATURE
class Layer(salvus.utils.dataclass_utils.MappableDataclass):
    def __init__(
        self,
        bot: interface.Interface,
        mod: material.PhysicalMaterial,
        top: interface.Interface,
        linear_solids: (
            LinearSolids
            | typing.Literal["skip_validation_linear_solids"]
            | None
        ) = None,
        _index: int | None = None,
    ) -> None: ...
ARGUMENTS
Required
bot
Type:interface.Interface
Description:
The bottom layer (smaller vertical coordinate).
Required
mod
Type:material.PhysicalMaterial
Description:
The bounded model.
Required
top
Type:interface.Interface
Description:
The top layer (larger vertical coordinate).
Optional
linear_solids
Type:LinearSolids | typing.Literal['skip_validation_linear_solids'] | None
Default value:None
Description:
Any linear solids associated with the layer.
Optional
_index
Type:int | None
Default value:None
Description:
An optional index specifying the position of this layer with respect to its neighbors. Required for some reduction algorithms.

Properties

  • bot_realized(ConcreteInterface)-Return the bottom interface as a curve or a surface.
  • bounds(LayerBounds)-Get this layer's bounding interfaces.
  • index(int | None)-Get the optional index of this layer.
  • interfaces(tuple[interface.Interface, interface.Interface])-Get a tuple of the (bottom, top) interface.
  • model(material.PhysicalMaterial)-Get the model.
  • strata(list[interface.Interface | material.PhysicalMaterial])-Get this layer's ordered strata.
  • top_realized(ConcreteInterface)-Return the top interface as a curve or a surface.
  • v_ref(tuple[float, float])-Get the reference elevations of the (bottom, top) layers.

Methods

Layer.bounds_da()
Get the bounds of this layer as a DataArray.
SIGNATURE
def bounds_da(self, d: DomainBounds) -> xr.DataArray: ...
ARGUMENTS
Required
d
Type:DomainBounds
Description:
The domain bounds.
Layer.map()
Generic map for dataclass instances.
f should be a function taking two parameters: the name of the dataclass member and its value, and it should return a tuple containing the same quantities. If a member is not to be transformed, f should just return a tuple of the input member name and value, unchanged. Both names and values can be transformed, with the semantics following those of dataclasses.replace.
In Salvus we primarily treat dataclasses as containers offering semantics similar to typed dictionaries. Deriving from this protocol allows any relevant dataclass to additionally be treated functorially. This allows for the generic un- and re-wrapping of value held in dataclasses, and essentially replaces the following imperative code:
@dataclass
class A:
    member: int

# Before
my_a = A(member=1)
my_a_new = dataclasses.replace(my_a, member=2 * my_a.member)

# After
my_a_new = A(val=1).map(lambda key, val: (key, 2 * val))
As with many functional patterns, the perceived benefits for simple demonstrative purposes is minimal. The scalability of this pattern becomes apparent, however, when parsing deeply nested abstractions, as the transformation logic can be factored out into independent functions. This is used extensively, for example, in the realization logic of the layered mesher, where generic materials can have generic parameters, etc.
SIGNATURE
def map(
    self, f: typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
) -> typing.Self: ...
ARGUMENTS
Required
f
Type:typing.Callable[[str, typing.Any], tuple[str, typing.Any]]
Description:
The function to map over the dataclass.
Layer.replace_bounds()
Optionally replace each boundary of this layer.
SIGNATURE
def replace_bounds(
    self,
    new_top: interface.Interface | None = None,
    new_bot: interface.Interface | None = None,
) -> Layer: ...
ARGUMENTS
Optional
new_top
Type:interface.Interface | None
Default value:None
Description:
The new top interface, or None to keep the current interface.
Optional
new_bot
Type:interface.Interface | None
Default value:None
Description:
The new bottom interface, or None to keep the current interface.

LayerBounds

The bounding interfaces of a layer.
SIGNATURE
class LayerBounds(builtins.object):
    def __init__(
        self, top: interface.Interface, bot: interface.Interface
    ) -> None: ...
ARGUMENTS
Required
top
Type:interface.Interface
Description:
The top interface.
Required
bot
Type:interface.Interface
Description:
The bottom interface.

Class Methods

LayerBounds.from_coords()
Construct the layer bounds from coordinate values.
Removes the burden of wrapping the input coordinates with Hyperplanes.
SIGNATURE
def from_coords(
    top: float | interface.Height | interface.Depth,
    bot: float | interface.Height | interface.Depth,
) -> LayerBounds: ...
ARGUMENTS
Required
top
Type:float | interface.Height | interface.Depth
Description:
The top interface.
Required
bot
Type:float | interface.Height | interface.Depth
Description:
The bottom interface.

Methods

LayerBounds.interp_like()
Interpolate bounding interfaces onto another DataArray's coordinates.
Will call the interface's extend method to ensure that it spans the coordinates spanned by other with the desired expansion behavior.
SIGNATURE
def interp_like(self, like: xr.DataArray) -> typing.Self: ...
ARGUMENTS
Required
like
Type:xr.DataArray
Description:
The DataArray on which to interpolate this interface.
LayerBounds.replace_bounds()
Replace one or both bounds.
SIGNATURE
def replace_bounds(
    self,
    top: interface.Interface | None = None,
    bot: interface.Interface | None = None,
) -> typing.Self: ...
ARGUMENTS
Optional
top
Type:interface.Interface | None
Default value:None
Description:
The new top bound, or None if the current bound is to be kept.
Optional
bot
Type:interface.Interface | None
Default value:None
Description:
The new bottom bound, or None if the current bound is to be kept.
PAGE CONTENTS