mooserunner.py¶
- class MooseRunner(config)[source]¶
Bases:
SimRunner
Used to run MOOSE models (*.i) from python.
- __init__(config)[source]¶
Constructor for MOOSE runner taking a MooseConfig object that contains the paths to the main MOOSE install, the MOOSE app and the MOOSE app name. Sets default parallelisation options to 1 MPI task and 1 thread. Sets environment variables required for MPI setup.
- Parameters:
config (
MooseConfig
) – moose configuration object containing the required paths and app name to construct the command string.
- set_threads(n_threads)[source]¶
Sets the number of threads asked of MOOSE on the command line.
- Parameters:
n_threads (
int
) – Number of threads.
- set_tasks(n_tasks)[source]¶
Sets the number of MPI tasks asked of MOOSE on the command line.
- Parameters:
n_tasks (
int
) – Number of mpi tasks.
- set_stdout(redirect_flag=True)[source]¶
Sets MOOSE to redirect output (True) to file instead of console (False).
- Parameters:
redirect_flag (
bool
) – True = output to stdout file, False = output to console. Defaults to True.
- set_run_opts(n_tasks=1, n_threads=1, redirect_out=True)[source]¶
Sets all options for MOOSE run parallelisation and output.
- Parameters:
n_tasks (
int
) – Number of mpi tasks for MOOSE run. Defaults to 1.n_threads (
int
) – Number of threads for MOOSE run. Defaults to 1.redirect (
bool
) – Redirect MOOSE output from console to file (True). Defaults to False.
- get_input_file()[source]¶
- Returns:
Path | None
– full path to the input file or None if not specified.
- set_input_file(input_path)[source]¶
Sets the path to the MOOSE input file and checks it exists.
- Parameters:
input_file (
Path
) – full path and name of *.i MOOSE input script.- Raises:
FileNotFoundError – the MOOSE input script doesn’t exist
- get_input_dir()[source]¶
Gets the path to the directory for the specified input file.
- Returns:
Path
– path to input file directory, if no input file is specified returns None.
- get_input_tag()[source]¶
Gets the input file name string without the path or the .i
- Returns:
str
– input file string, if no input file is specified returns an empty string.
- get_output_path()[source]¶
Gets the file and path for the output exodus file based on the specified input file. Includes ‘_out.e’.
- Returns:
Path
– output exodus file name with path, returns an empty None if no input file is specified.
- assemble_arg_list(input_file=None)[source]¶
Assmebles the command line string to run MOOSE based on current options.
- Parameters:
input_file (
str
) – Full path to MOOSE input file, if not empty updates the input file. Defaults to “”.- Returns:
str
– command line string that will be used by the runner when run is called.