slim4.pre3d

Pre3d

Classes

class slim4.pre3d.VMap

Abstract class for stretching functions. The get method should compute the z-levels for a given number of layers and depth, and store them in z_L_vec (size nz+1, from surface to bottom). This allows users to implement custom stretching functions that can be used in the extrude_hybrid and extrude_z functions.

class slim4.pre3d.VMapSongHaidvogel

Bases: VMap.

Implementation of the Song and Haidvogel (1994) stretching function.

Constructor

__init__(nz, theta_s=2.0, theta_b=0.8, hc=5.0)

Create a VMapSongHaidvogel object

Parameters

nz: int — Number of vertical layers (number of z-levels = nz+1)
theta_s: float — Surface control parameter (0 < theta_s <= 20); larger values increase resolution near the surface
theta_b: float — Bottom control parameter (0 <= theta_b < 1); 0 concentrates resolution at the surface only, 1 also at the bottom
hc: float — Stretching depth [m]
class slim4.pre3d.VMapSiddornFurner

Bases: VMap.

Implementation of the Siddorn and Furner (2013) stretching function. Above Hcrit the grid follows pure sigma coordinates; below, a smooth stretching function concentrates resolution near the surface and bottom.

Constructor

__init__(nz, alpha=3, Dz_b=2.0, Dz_s=1.0, Hcrit=10.0)

Create a VMapSiddornFurner object

Parameters

nz: int — Number of vertical layers (number of z-levels = nz+1)
alpha: float — Stretching parameter (greater than 1 concentrates resolution towards the surface, less than 1 towards the bottom)
Dz_b: float — Bottom cell thickness [m]
Dz_s: float — Surface cell thickness [m]
Hcrit: float — Critical depth [m]; negative means auto-computed as (nz+1)*(Dz_s+Dz_b)/2
class slim4.pre3d.VMapProportional

Bases: VMap.

VMap that places the z-levels at fixed proportions of the local depth. The proportions are given by the weights vector of size nz, which contains the relative weights of the layer thicknesses. The z-levels are then computed as z_k = -depth * sum(weights[0:k]) / sum(weights).

Constructor

__init__(weights)

Create a VMapProportional object

Parameters

weights: List[float] — The weights for the proportional stretching (size nz+1)
class slim4.pre3d.VMapExponential

Bases: VMap.

VMap that distributes vertical levels using an exponential stretching: layer thicknesses follow d_k = d0 * r^k, with k=0..nz-1. The ratio r is computed such that the total depth is matched. If no solution with r >= 1 exists, a linear distribution is used.

Constructor

__init__(nz, d0, start=0.0)

Create a VMapExponential object

Parameters

nz: int — Number of layers
d0: float — Thickness of the first layer
start: float — Depth at which the first layer starts (intendend for use in the hybrid extrude function, to start the exponential stretching at a certain depth instead of the surface)
class slim4.pre3d.VMapZ

Bases: VMap.

VMap that places the z-levels at fixed heights

Constructor

__init__(levels)

Create a VMapZ object

Parameters

levels: List[float] — The levels for the proportional stretching (size nz+1)

Methods

static create_from_vmap(original, bath2d)

Create a VMapZ object. The fixed z levels are obtained by evaluating another vmap at the deepest point of the mesh.

Parameters

original: VMap — The original vmap to evaluate
bath2d: slim.Data — Bathymetry (positive values)

Returns

self: VMapZ — The VMapZ object created
class slim4.pre3d.VMapHybrid

Bases: VMap.

VMap that combines two other vmap objects (type-σ), one for shallow areas and one for deep areas (type-z).

Constructor

__init__(depth_threshold, vmap_shallow, vmap_deep)

Create a VMapHybrid object

Parameters

depth_threshold: float — Depth threshold to switch between the two vmaps
vmap_shallow: VMap — VMap to use in shallow areas
vmap_deep: VMap — VMap to use in deep areas (levels <= -depth_threshold are ignored)

Methods

static create_exponential_deep(depth_threshold, vmap_shallow, deep_n, deep_use_z, bath2d=None)

Convenience method to create a VMapHybrid object with an exponential VMap for deep areas. The height of the first layer of the deep VMap is set to the height of the last layer of the shallow VMap evaluated at the depth threshold, to ensure a smooth transition between the two vmaps.

Parameters

depth_threshold: float — Depth threshold to switch between the two vmaps
vmap_shallow: VMap — VMap to use in shallow areas
deep_n: int — Number of layers in the exponential VMap for deep areas
deep_use_z: bool — If true, wrap the exponential VMap in a VMapZ to use levels at fixed z.
bath2d: slim.Data | None — required if deep_use_z is true.

Returns

self: VMapHybrid — The VMap object created

Functions

slim4.pre3d.extrude(mesh2d, bath2d, vmap, n_moving_max=-1)

Create a 3D mesh by extruding a 2D mesh with pure sigma vertical coordinates. All triangles have the same number of layers; the vertical grid follows the bathymetry.

Parameters

mesh2d: slim2d.Mesh — 2D mesh
bath2d: slim.Data — Bathymetry (positive values)
vmap: VMap — Stretching function to compute the z-levels from the bathymetry
n_moving_max: int — Maximum number of moving layers (-1 = all layers move)

Returns

mesh: slim3d.Mesh — The 3D mesh
z: NDArray[np.float64] — The z coordinate array of shape (1, 6, n_prisms)
bath: slim.Data — The bathymetry as a DG DataStatic (positive values)