zoomy_core.model.initial_conditions

zoomy_core.model.initial_conditions#

Initial conditions (constant, Riemann problems, radial dam break, user function, 3-D projection, restart) applied to the state array of a Model.

Module Contents#

Classes#

InitialConditions

Abstract base of initial conditions; subclasses implement apply and get_definition.

Constant

Spatially constant initial state given by constants(n_variables).

RP

1-D Riemann problem: high state for x < jump_position_x, low state otherwise.

RP2d

2-D Riemann problem: high state in the quadrant x < jump_position_x and y < jump_position_y, low otherwise.

RP3d

3-D Riemann problem: high state in the octant below all three jump positions, low otherwise.

RadialDambreak

Radial dam break: high state within radius of the mesh centroid, low outside.

UserFunction

Initial state from a user callable function(x) -> state evaluated per cell.

Project3D

Initial condition from a 3-D profile through the model’s own project_from_3d map, sampled at its projection nodes. Covers the horizontal-velocity moments (SME family); the profile is given as height(x), optional bed(x) and velocity(x, zeta).

RestartFromHdf5

Restart from an HDF5 snapshot; a runtime operation handled by the solver, so apply is a no-op.

Functions#

default_constant_func

Default constant state [1, 0, 0, ...].

default_low_state

Default low (right) state [1, 0, ...].

default_high_state

Default high (left) state [2, 0, ...].

default_user_function

Default user function, identically zero.

API#

zoomy_core.model.initial_conditions.default_constant_func(n_variables: int) → zoomy_core.misc.custom_types.FArray#

Default constant state [1, 0, 0, ...].

zoomy_core.model.initial_conditions.default_low_state(n_variables: int) → zoomy_core.misc.custom_types.FArray#

Default low (right) state [1, 0, ...].

zoomy_core.model.initial_conditions.default_high_state(n_variables: int) → zoomy_core.misc.custom_types.FArray#

Default high (left) state [2, 0, ...].

zoomy_core.model.initial_conditions.default_user_function(x: zoomy_core.misc.custom_types.FArray) → zoomy_core.misc.custom_types.FArray#

Default user function, identically zero.

class zoomy_core.model.initial_conditions.InitialConditions(**params)#

Bases: param.Parameterized

Abstract base of initial conditions; subclasses implement apply and get_definition.

Initialization

apply(X, Q)#

Abstract: fill Q from X.

get_definition(X, p, n_variables)#

Symbolic initial state for C++ code generation; the default is a zero state that the solver overwrites at runtime.

class zoomy_core.model.initial_conditions.Constant(constants=None, **params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

Spatially constant initial state given by constants(n_variables).

Initialization

Set constants (callable n_variables -> state) if given.

constants#

‘Callable(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state ZArray of length n_variables for code generation.

class zoomy_core.model.initial_conditions.RP(**params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

1-D Riemann problem: high state for x < jump_position_x, low state otherwise.

Initialization

low#

‘Callable(…)’

high#

‘Callable(…)’

jump_position_x#

‘Number(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state ZArray of length n_variables for code generation.

class zoomy_core.model.initial_conditions.RP2d(**params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

2-D Riemann problem: high state in the quadrant x < jump_position_x and y < jump_position_y, low otherwise.

Initialization

low#

‘Callable(…)’

high#

‘Callable(…)’

jump_position_x#

‘Number(…)’

jump_position_y#

‘Number(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state ZArray of length n_variables for code generation.

class zoomy_core.model.initial_conditions.RP3d(**params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

3-D Riemann problem: high state in the octant below all three jump positions, low otherwise.

Initialization

low#

‘Callable(…)’

high#

‘Callable(…)’

jump_position_x#

‘Number(…)’

jump_position_y#

‘Number(…)’

jump_position_z#

‘Number(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state ZArray of length n_variables for code generation.

class zoomy_core.model.initial_conditions.RadialDambreak(**params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

Radial dam break: high state within radius of the mesh centroid, low outside.

Initialization

low#

‘Callable(…)’

high#

‘Callable(…)’

radius#

‘Number(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state, with the circle centred at the origin (unlike apply, which uses the centroid).

class zoomy_core.model.initial_conditions.UserFunction(function=None, **params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

Initial state from a user callable function(x) -> state evaluated per cell.

Initialization

Set function if given.

function#

‘Callable(…)’

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

get_definition(X, p, n_variables)#

Symbolic initial state obtained by calling function on symbolic X; a zero state if it is not symbolic.

class zoomy_core.model.initial_conditions.Project3D(model, height, velocity, bed=None, **params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

Initial condition from a 3-D profile through the model’s own project_from_3d map, sampled at its projection nodes. Covers the horizontal-velocity moments (SME family); the profile is given as height(x), optional bed(x) and velocity(x, zeta).

Args

  • model: the Model providing project_from_3d.

  • height: callable x -> h.

  • velocity: callable (x, zeta) -> u, the vertical velocity profile.

  • bed: callable x -> b; defaults to a flat bed at zero.

Initialization

Store the model and the profile callables.

apply(X, Q)#

Fill Q (shape (n_variables, n_cells)) in place from the cell coordinates X (shape (dim, n_cells)).

Returns

The filled Q.

class zoomy_core.model.initial_conditions.RestartFromHdf5(**params)#

Bases: zoomy_core.model.initial_conditions.InitialConditions

Restart from an HDF5 snapshot; a runtime operation handled by the solver, so apply is a no-op.

Initialization

path_to_fields#

‘String(…)’

mesh_new#

‘ClassSelector(…)’

mesh_identical#

‘Boolean(…)’

path_to_old_mesh#

‘String(…)’

snapshot#

‘Integer(…)’

map_fields#

‘Dict(…)’

apply(X, Q)#

No-op placeholder; the solver performs the HDF5 load.

get_definition(X, p, n_variables)#

Zero state for the compiled model; the solver overwrites it from the HDF5 file.