Skip to content

Hotstart and MPI

Starting from the state of a previous run, and domain decomposition for parallel runs.

rompy_xbeach.components.hotstart

XBeach hotstart configuration.

This module contains the Hotstart component for initializing XBeach simulations from a previous simulation state.

Hotstart pydantic-model

Hotstart(**data: Any)

Bases: XBeachBaseModel

Hotstart configuration for initializing from previous simulation state.

XBeach can read hotstart files from a previous simulation to initialize a new simulation, avoiding spin-up time. Hotstart files follow the naming convention: hotstart_{varname}{fileno:06d}.dat

The minimum required files are: zs, zb, uu, vv (always written/read). Additional files may be present depending on the simulation options (groundwater, wave energy, sediment, etc.).

Usage in Config: hotstart: false # No hotstart (default) hotstart: true # Enable hotstart, files must exist in run directory hotstart: # Full hotstart configuration hotstartfileno: 3 previous_run: source: /path/to/previous/run

See https://xbeach.readthedocs.io/en/latest/xbeach_manual.html#hotstart-beta for more information.

Fields:

hotstart pydantic-field

hotstart: Literal[True] = True

Initialize simulation with hotstart files (XBeach default: 0)

hotstartfileno pydantic-field

hotstartfileno: int = 0

Hotstart file number to use for initialization. Selects which set of hotstart files to read when multiple snapshots exist (0-999).

previous_run pydantic-field

previous_run: Optional[XBeachDirectoryBlob] = None

Directory containing hotstart files from a previous XBeach simulation. If not specified, hotstart files must already exist in the run directory.

params property

params: dict

Return the XBeach parameters as a flat dictionary.

get

get(destdir: str | Path) -> dict

Fetch hotstart files if previous_run is specified, and return the params dict.

Parameters:

Name Type Description Default
destdir str | Path

Destination directory for fetching files.

required

Returns:

Type Description
dict

Parameters dictionary with hotstart settings.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

rompy_xbeach.components.mpi

XBeach MPI parallelisation parameter configurations.

This module contains models for MPI (Message Passing Interface) parallelisation settings that control domain decomposition for parallel execution.

Mpi pydantic-model

Mpi(**data: Any)

Bases: XBeachBaseModel

MPI parallelisation parameters (XBeach Table 45).

Controls how the model domain is subdivided into sub-models for parallel execution on multiple cores. Each sub-model is computed on a separate core, which increases computational speed. Sub-models only exchange information over their boundaries when necessary.

The domain subdivision strategy is controlled by mpiboundary: - auto: Subdivides domain to minimise internal boundary length - x: Subdivides in cross-shore direction (full alongshore extent per domain) - y: Subdivides in alongshore direction (full cross-shore extent per domain) - man: Manual subdivision using mmpi and nmpi values

Note

The number of sub-models is determined by the MPI wrapper (e.g., MPICH2 or OpenMPI), not by XBeach itself.

References

XBeach manual: MPI section for parallelisation details.

Fields:

Validators:

mmpi pydantic-field

mmpi: Optional[int] = None

Number of domains in cross-shore direction when manually specifying MPI domains (XBeach default: 2)

mpiboundary pydantic-field

mpiboundary: Optional[Literal["auto", "x", "y", "man"]] = (
    None
)

Strategy for MPI domain boundaries: auto (shortest boundary), x (cross-shore subdivision), y (alongshore subdivision), or man (manual using mmpi/nmpi) (XBeach default: auto)

nmpi pydantic-field

nmpi: Optional[int] = None

Number of domains in alongshore direction when manually specifying MPI domains (XBeach default: 4)

params property

params: dict

Return the XBeach parameters as a flat dictionary.

validate_manual_mode pydantic-validator

validate_manual_mode() -> Mpi

Validate that mmpi and nmpi are specified when using manual mode.

check_for_typos classmethod

check_for_typos(data: Any) -> Any

Suggest the closest field name for an unknown input key.

A field can be given by its name or, like in pydantic, by its alias.

dump_inputs_dict

dump_inputs_dict() -> dict

Return the original inputs as a dictionary.

dump_inputs_json

dump_inputs_json() -> str

Return the original inputs as a JSON string.

get

get(destdir: str | Path) -> dict

Return the params dict with file fetching for nested components.

This method handles two types of nested components: 1. Components with explicit parameter fields: Need special handling to extract the field value and merge remaining params 2. Discriminated union components: Already flattened by the serializer

The default implementation: - For components with explicit fields: includes that field in return dict - For discriminated unions or leaf components: returns standard params - For parent components: processes XBeachBaseModel children recursively

XBeachDataBlob fields are fetched into destdir and written as the file name under the field name. Override this method only for other file handling, such as fetching several files from a directory.

Parameters:

Name Type Description Default
destdir str | Path

Directory path for file operations.

required

Returns:

Type Description
Flat dictionary of XBeach parameters.