salvus.mesh.layered_meshing.utils.split_layered_model
Functions for splitting layered models.
Functions
split_layered_model()
split_layered_model()def split_layered_model(
layered_model: salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel,
predicate: Callable[
[salvus.mesh.layered_meshing.layered_model.layer.Layer], bool
],
) -> Tuple[
Union[
salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel,
NoneType,
],
Union[
salvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel,
NoneType,
],
]:
...Split a layered model with a predicate that takes a Layer as input.
The predicate will be applied to the layered model layer-by-layer in
top-down order. The first time a predicate returns True for a given
layer, the layered model is split at that layer’s top interface. To be
clear, splitting the following model:
LayeredModel([
interface.Hyperplane.at(1.0),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.66),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.33),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.0),
])
with the predicate:
`lambda lay: lay.bot.max_elevation == 0.33`
will result in the return value of:
```
(
LayeredModel([
interface.Hyperplane.at(1.0),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.66),
]),
LayeredModel([
interface.Hyperplane.at(0.66),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.33),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.0),
])
)
```
while the predicate:
`lambda lay: lay.top.max_elevation = 0.33`
would instead result in the return value of:
```
(
LayeredModel([
interface.Hyperplane.at(1.0),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.66),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.33),
]),
LayeredModel([
interface.Hyperplane.at(0.33),
material.acoustic.Velocity.from_params(rho=1.0, vp=1.0),
interface.Hyperplane.at(0.0),
])
)
```
It may be that the predicate returns True for the top layer, or that it
returns False for all layers. In the first case, the return value of this
function will be:
`(None, layered_model)`
signifying that all layers are located below the split. Likewise, if the
predicate returns False for all layers, the return value of this function
will be:
`(layered_model, None)`
signifying that all layers are located above the split.
Finally: the caller is responsible for ensuring that their layered model is complete, i.e. that is has bounding interfaces. If this is not the case, an exception will be thrown.
layered_modelsalvus.mesh.layered_meshing.layered_model.layered_model.LayeredModel — The layered model to split.predicateCallable[[salvus.mesh.layered_meshing.layered_model.layer.Layer], bool] — A callable taking a layer as input, and returningTrueto signify that a split should be done at the top of the layer, otherwise returningFalse.
None if a split has not occurred.