solver_controller#

Module to control a CFX-Solver instance.

Classes:

SolverController(**kwargs)

Provides basic operations for a local CFX-Solver session.

class ansys.cfx.core.solver_controller.SolverController(**kwargs)#

Bases: object

Provides basic operations for a local CFX-Solver session.

Classes:

RunState(*values)

Enumerates over CFX-Solver run states.

Methods:

__init__(**kwargs)

Set up a CFX-Solver session.

get_results_file_name([use_engine_path])

Get the name of the results file associated with the current session.

get_run_state()

Get the CFX-Solver run state.

is_running()

Check if a CFX-Solver run is in progress.

start_run()

Start a CFX-Solver run.

stop_run([wait_for_run])

Stop the CFX-Solver run currently in progress.

wait_for_run([interval, timeout])

Wait for a CFX-Solver run in progress to complete.

class RunState(*values)#

Bases: Enum

Enumerates over CFX-Solver run states.

Attributes:

DEFINED = 1#
ERROR = 4#
FINISHED = 3#
IN_PROGRESS = 2#
NONE = 0#
__init__(**kwargs)#

Set up a CFX-Solver session.

Parameters:
processed_argsdict

Contains arguments initially passed to a Solver.from_install() function.

Raises:
RuntimeError

If the provided arguments in process_args are not consistent or any necessary files do not exist.

get_results_file_name(use_engine_path: bool = False) str | None#

Get the name of the results file associated with the current session.

Returns:
str | None

Current results file name or None if no results file is associated with the current session.

get_run_state() RunState#

Get the CFX-Solver run state.

Returns:
RunState

Current CFX-Solver run state.

is_running() bool#

Check if a CFX-Solver run is in progress.

Returns:
bool

True if a CFX-Solver run is in progress.

start_run() None#

Start a CFX-Solver run.

This command can also be used to restart from an existing results file if the Solver session has previously completed a successful run or if the Solver session was started with a ‘results_file_name` argument.

Execution control is read from the CFX-Solver input file.

Raises:
RuntimeError

If the run cannot be successfully started.

stop_run(wait_for_run=True) None#

Stop the CFX-Solver run currently in progress.

If a run is not currently in progress, the command does nothing.

Parameters:
wait_for_runbool, default: True

Whether to wait for the run to complete before returning from the command, Depending on the problem setup, this could take a long time as the CFX-Solver must complete the iteration or timestep that is in progress and then write a results file.

wait_for_run(interval=10, timeout=86400) None#

Wait for a CFX-Solver run in progress to complete.

Note that run completion is indicated by the removal of the working directory and/or the presence of the results file or results error file. Some CFX-Solver failures may not trigger the “run complete” condition. In this case, the wait_for_run() function raises an exception after the specified timeout.

Parameters:
intervalint, default: 10

Time interval in seconds between each check of the CFX-Solver status.

timeoutint, default: 86400

Maximum number of seconds to wait for the run to finish. If the run has not finished within this time limit, an exception is raised.

Raises:
RuntimeError

If the run has not stopped within the specified timeout.