launcher#
Provides a module for launching Fluent.
This module supports both starting Fluent locally and connecting to a remote instance with gRPC.
Functions:
|
Connect to an existing Fluent server instance. |
|
Use the factory function to create a launcher for supported launch modes. |
|
Launch Fluent locally in server mode or connect to a running Fluent server instance. |
- ansys.fluent.core.launcher.launcher.connect_to_fluent(ip=None, port=None, cleanup_on_exit=False, start_transcript=True, server_info_file_name=None, password=None, start_watchdog=None)#
Connect to an existing Fluent server instance.
- Parameters:
- ip
str
,optional
IP address for connecting to an existing Fluent instance. The IP address defaults to
"127.0.0.1"
. You can also use the environment variablePYFLUENT_FLUENT_IP=<ip>
to set this parameter. The explicit value ofip
takes precedence overPYFLUENT_FLUENT_IP=<ip>
.- port
int
,optional
Port to listen on for an existing Fluent instance. You can use the environment variable
PYFLUENT_FLUENT_PORT=<port>
to set a default value. The explicit value ofport
takes precedence overPYFLUENT_FLUENT_PORT=<port>
.- cleanup_on_exitbool,
optional
Whether to shut down the connected Fluent session when PyFluent is exited, or the
exit()
method is called on the session instance, or if the session instance becomes unreferenced. The default isFalse
.- start_transcriptbool,
optional
Whether to start streaming the Fluent transcript in the client. The default is
True
. You can stop and start the streaming of the Fluent transcript subsequently via the method calls,transcript.start()
andtranscript.stop()
on the session object.- server_info_file_name: str
Path to server-info file written out by Fluent server. The default is
None
. PyFluent uses the connection information in the file to connect to a running Fluent session.- password
str
,optional
Password to connect to existing Fluent instance.
- start_watchdog: bool, optional
When
cleanup_on_exit
is True,start_watchdog
defaults to True, which means an independent watchdog process is run to ensure that any local Fluent connections are properly closed (or terminated if frozen) when Python process ends.
- ip
- Returns:
Union
[Meshing
,PureMeshing
,Solver
,SolverIcing
]Session object.
- ansys.fluent.core.launcher.launcher.create_launcher(fluent_launch_mode=None, **kwargs)#
Use the factory function to create a launcher for supported launch modes.
- Parameters:
- fluent_launch_mode: LaunchMode
Supported Fluent launch modes. Options are
"LaunchMode.CONTAINER"
,"LaunchMode.PIM"
,"LaunchMode.SLURM"
, and"LaunchMode.STANDALONE"
.- kwargs
Any
Keyword arguments.
- Returns
- ——-
- launcher: DockerLauncher | PimLauncher | StandaloneLauncher
Session launcher.
- Raises
- ——
- DisallowedValuesError
If an unknown Fluent launch mode is passed.
- ansys.fluent.core.launcher.launcher.launch_fluent(product_version=None, dimension=None, precision=None, processor_count=None, journal_file_names=None, start_timeout=None, additional_arguments='', env=None, start_container=None, container_dict=None, dry_run=False, cleanup_on_exit=True, start_transcript=True, ui_mode=None, graphics_driver=None, case_file_name=None, case_data_file_name=None, lightweight_mode=None, mode=None, py=None, gpu=None, cwd=None, fluent_path=None, topy=None, start_watchdog=None, scheduler_options=None, file_transfer_service=None)#
Launch Fluent locally in server mode or connect to a running Fluent server instance.
- Parameters:
- product_version
FluentVersion
orstr
orfloat
orint
,optional
Version of Ansys Fluent to launch. To use Fluent version 2024 R2, pass any of
FluentVersion.v242
,"24.2.0"
,"24.2"
,24.2``or ``242
. The default isNone
, in which case the newest installed version is used.- dimension
Dimension
orint
,optional
Geometric dimensionality of the Fluent simulation. The default is
None
, in which caseDimension.THREE
is used. Options are either the values of theDimension
enum (Dimension.TWO
orDimension.THREE
) or any of2
and3
.- precision
Precision
orstr
,optional
Floating point precision. The default is
None
, in which casePrecision.DOUBLE
is used. Options are either the values of thePrecision
enum (Precision.SINGLE
orPrecision.DOUBLE
) or any of"double"
and"single"
.- processor_count
int
,optional
Number of processors. The default is
None
, in which case1
processor is used. In job scheduler environments the total number of allocated cores is clamped to value ofprocessor_count
.- journal_file_names
str
orlist
of
str
,optional
The string path to a Fluent journal file, or a list of such paths. Fluent will execute the journal(s). The default is
None
.- start_timeout
int
,optional
Maximum allowable time in seconds for connecting to the Fluent server. The default is
60
if Fluent is launched outside a Slurm environment, no timeout if Fluent is launched within a Slurm environment.- additional_arguments
str
,optional
Additional arguments to send to Fluent as a string in the same format they are normally passed to Fluent on the command line.
- env
dict
[str
,str
],optional
Mapping to modify environment variables in Fluent. The default is
None
.- start_containerbool,
optional
Specifies whether to launch a Fluent Docker container image. For more details about containers, see
fluent_container
.- container_dict
dict
,optional
Dictionary for Fluent Docker container configuration. If specified, setting
start_container = True
as well is redundant. Will launch Fluent inside a Docker container using the configuration changes specified. See alsofluent_container
.- dry_runbool,
optional
Defaults to False. If True, will not launch Fluent, and will instead print configuration information that would be used as if Fluent was being launched. If dry running a container start,
launch_fluent()
will return the configuredcontainer_dict
.- cleanup_on_exitbool,
optional
Whether to shut down the connected Fluent session when PyFluent is exited, or the
exit()
method is called on the session instance, or if the session instance becomes unreferenced. The default isTrue
.- start_transcriptbool,
optional
Whether to start streaming the Fluent transcript in the client. The default is
True
. You can stop and start the streaming of the Fluent transcript subsequently via the method calls,transcript.start()
andtranscript.stop()
on the session object.- ui_mode
UIMode
orstr
,optional
Fluent user interface mode. Options are either the values of the
UIMode
enum or any of"no_gui_or_graphics"
,"no_gui"
,"hidden_gui"
,"no_graphics"
or"gui"
. The default isUIMode.HIDDEN_GUI
in Windows andUIMode.NO_GUI
in Linux."no_gui_or_graphics"
and"no_gui"
user interface modes are supported in Windows starting from Fluent version 2024 R1.- graphics_driver
FluentWindowsGraphicsDriver
orFluentLinuxGraphicsDriver
orstr
,optional
Graphics driver of Fluent. In Windows, options are either the values of the
FluentWindowsGraphicsDriver
enum or any of"null"
,"msw"
,"dx11"
,"opengl2"
,"opengl"
or"auto"
. In Linux, options are either the values of theFluentLinuxGraphicsDriver
enum or any of"null"
,"x11"
,"opengl2"
,"opengl"
or"auto"
. The default isFluentWindowsGraphicsDriver.AUTO
in Windows andFluentLinuxGraphicsDriver.AUTO
in Linux.- case_file_name
str
,optional
If provided, the case file at
case_file_name
is read into the Fluent session.- case_data_file_name
str
,optional
If provided, the case and data files at
case_data_file_name
are read into the Fluent session.- lightweight_modebool,
optional
Whether to run in lightweight mode. In lightweight mode, the lightweight settings are read into the current Fluent solver session. The mesh is read into a background Fluent solver session which will replace the current Fluent solver session once the mesh read is complete and the lightweight settings made by the user in the current Fluent solver session have been applied in the background Fluent solver session. This is all orchestrated by PyFluent and requires no special usage. This parameter is used only when
case_file_name
is provided. The default isFalse
.- mode
str
,optional
Launch mode of Fluent to point to a specific session type. The default value is
None
. Options are"meshing"
,"pure-meshing"
and"solver"
.- pybool,
optional
If True, Fluent will run in Python mode. Default is None.
- gpubool or
list
,optional
This option will start Fluent with the GPU Solver. A list of GPU IDs can be passed to use specific GPUs. If True is passed, the number of GPUs used will be clamped to the value of
processor_count
. Please refer to Starting the Fluent GPU Solver section in Fluent’s User Guide for more information like how to determine the GPU IDs.- cwd
str
,Optional
Working directory for the Fluent client.
- fluent_path: str, Optional
User provided Fluent installation path.
- topybool or
str
,optional
A boolean flag to write the equivalent Python journal(s) from the journal(s) passed. Can optionally take the file name of the new python journal file.
- start_watchdogbool,
optional
When
cleanup_on_exit
is True,start_watchdog
defaults to True, which means an independent watchdog process is run to ensure that any local GUI-less Fluent sessions started by PyFluent are properly closed (or killed if frozen) when the current Python process ends.- scheduler_options
dict
,optional
Dictionary containing scheduler options. Default is None.
Currently only the Slurm scheduler is supported. The
scheduler_options
dictionary must be of the form{"scheduler": "slurm", "scheduler_headnode": "<headnode>", "scheduler_queue": "<queue>", "scheduler_account": "<account>"}
. The keysscheduler_headnode
,scheduler_queue
andscheduler_account
are optional and should be specified in a similar manner to Fluent’s scheduler options.- file_transfer_service
optional
File transfer service. Uploads/downloads files to/from the server.
- product_version
- Returns:
Union
[Meshing
,PureMeshing
,Solver
,SolverIcing
,dict
]Session object or configuration dictionary if
dry_run = True
.
- Raises:
UnexpectedKeywordArgument
If an unexpected keyword argument is provided.
Notes
Job scheduler environments such as SLURM, LSF, PBS, etc. allocates resources / compute nodes. The allocated machines and core counts are queried from the scheduler environment and passed to Fluent.