snek5000.util.restart#
Utilities to restart a simulation#
Help message#
usage: snek-restart [-h] [-oc] [-oi] [--modify-params MODIFY_PARAMS]
[--new-dir-results] [-np NB_MPI_PROCS]
[--use-start-from USE_START_FROM]
[--use-checkpoint USE_CHECKPOINT]
[--session-id SESSION_ID] [--skip-verify-contents]
[--add-to-end-time ADD_TO_END_TIME] [--end-time END_TIME]
[--num-steps NUM_STEPS]
path
Restart a fluidsim simulation
positional arguments:
path Path of the directory or file from which to restart
optional arguments:
-h, --help show this help message and exit
-oc, --only-check Only check what should be done
-oi, --only-init Only run initialization phase
--modify-params MODIFY_PARAMS
Code modifying the `params` object.
--new-dir-results Create a new directory for the new simulation
-np NB_MPI_PROCS, --nb-mpi-procs NB_MPI_PROCS
Number of MPI processes
--use-start-from USE_START_FROM
Name (relative to the session path) of the field file
to restart from. Mutually exclusive option with
`use_checkpoint`.
--use-checkpoint USE_CHECKPOINT
Number of the multi-file checkpoint file set to
restart from. Mutually exclusive parameter with
`use_start_from`.
--session-id SESSION_ID
Indicate which session directory should be used to
look for restart files. If not specified it would
default to the `path_session` value last recorded in
the `params_simul.xml` file.
--skip-verify-contents
Do not verify directory contents to avoid runtime
errors.
--add-to-end-time ADD_TO_END_TIME
Time added to params.nek.general.end_time
--end-time END_TIME params.nek.general.end_time
--num-steps NUM_STEPS
params.nek.general.num_steps
Functions
Create the argument parser with default arguments |
|
|
Get status of a simulation run by verifying its contents. |
|
Load params and Simul for a restart. |
|
Classes
Exceptions
- exception snek5000.util.restart.SnekRestartError[source]#
- args#
- with_traceback()#
Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
- class snek5000.util.restart.SimStatus(value)[source]#
Simulation status inspired from HTTP response status codes.
- OK = (200, 'OK: All prerequisities satisfied to restart.')#
- RESET_CONTENT = (205, 'Reset Content: Multi-file restart found. Some field files exist. Restarting in the same session would overwrite files. Ensure current session is archived or restart in a new session or a new directory.')#
- PARTIAL_CONTENT = (206, 'Partial Content: No multi-file restart found. Some field files exist. Ensure current session is archived or restart in a new session or a new directory.')#
- NOT_FOUND = (404, 'Not Found: SIZE and/or nek5000 is missing.')#
- LOCKED = (423, 'Locked: The path is currently locked by snakemake. Execute `snakemake --unlock` function snek5000.make.unlock.')#
- TOO_EARLY = (425, 'Too Early: Seems like snakemake was never executed.')#
- code#
status code
- message#
helpful description
- snek5000.util.restart.get_status(path_dir, session_id=None, verbose=False)[source]#
Get status of a simulation run by verifying its contents. It checks if:
snakemake was ever executed
directory is locked by snakemake (either due to a running simulation or a terminated one)
necessary files for starting a simulation exist
restart files exist
- snek5000.util.restart.load_for_restart(path_dir='.', use_start_from=None, use_checkpoint=None, session_id=None, verify_contents=True, new_dir_results=False, only_check=False)[source]#
Load params and Simul for a restart.
>>> params, Simul = load_for_restart(name_dir)
- Parameters
path_dir (str or path-like (optional)) – The directory of an existing simulation. If nothing is given, we load the data in the current directory. Can be an absolute path, a relative path, or even simply just the name of the directory under $FLUIDSIM_PATH.
use_start_from (str or int) – Name or index of the field file to restart from. Mutually exclusive option with
use_checkpoint
.use_checkpoint (int, {1, 2}) – Number of the multi-file checkpoint file set to restart from. Mutually exclusive parameter with
use_start_from
.session_id (int) – Indicate which session directory should be used to look for restart files. If not specified it would default to the path_session value last recorded in the params_simul.xml file.
verify_contents (bool) – Verify directory contents to avoid runtime errors.
new_dir_results (bool (default False)) – Create a new directory for the new simulation.
Notes
How it works:
If
verify contents
is True, do so usingget_status()
Reads
params_simul.xml
if it exists, and if not falls back to.par
file.Modifies parameters (in memory, but does not write into the filesystem, yet)
start_from
(Nek5000) or checkpoint module (requires KTH framework) with appropriatechkp_fnumber
to restart from.
- class snek5000.util.restart.Restarter[source]#
-
- main()#
Entry point fluidsim-restart
- restart(args=None, **defaults)#
Restart a simulation
- snek5000.util.restart.create_parser()#
Create the argument parser with default arguments