Fluent 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_fluent([ip, port, ...])

Connect to an existing Fluent server instance.

create_launcher([fluent_launch_mode])

Factory function to create launcher for supported launch modes.

launch_fluent([product_version, version, ...])

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:
ipstr, 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 variable PYFLUENT_FLUENT_IP=<ip> to set this parameter. The explicit value of ip takes precedence over PYFLUENT_FLUENT_IP=<ip>.

portint, 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 of port takes precedence over PYFLUENT_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 is False.

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() and transcript.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.

passwordstr, 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.

Returns:
Union [Meshing, PureMeshing, Solver, SolverIcing]

Session object.

ansys.fluent.core.launcher.launcher.create_launcher(fluent_launch_mode=None, **kwargs)#

Factory function to create 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".

kwargsAny

Keyword arguments.

Returns
——-
launcher: Union[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, version=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, show_gui=None, case_file_name=None, case_data_file_name=None, lightweight_mode=None, mode=None, py=None, gpu=None, cwd=None, topy=None, start_watchdog=None, scheduler_options=None, file_transfer_service=None, **kwargs)#

Launch Fluent locally in server mode or connect to a running Fluent server instance.

Parameters:
product_versionstr, optional

Version of Ansys Fluent to launch. The string must be in a format like "23.2.0" (for 2023 R2), matching the documented version format in the FluentVersion class. The default is None, in which case the newest installed version is used.

versionstr, optional

Geometric dimensionality of the Fluent simulation. The default is None, in which case "3d" is used. Options are "3d" and "2d".

precisionstr, optional

Floating point precision. The default is None, in which case "double" is used. Options are "double" and "single".

processor_countint, optional

Number of processors. The default is None, in which case 1 processor is used. In job scheduler environments the total number of allocated cores is clamped to value of processor_count.

journal_file_namesstr or list 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_timeoutint, 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_argumentsstr, optional

Additional arguments to send to Fluent as a string in the same format they are normally passed to Fluent on the command line.

envdict[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_dictdict, 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 also fluent_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 configured container_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 is True.

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() and transcript.stop() on the session object.

ui_modeUIMode or str, 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 is UIMode.HIDDEN_GUI in Windows and UIMode.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_driverFluentWindowsGraphicsDriver or FluentLinuxGraphicsDriver or str, 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 the FluentLinuxGraphicsDriver enum or any of

"null", "x11", "opengl2", "opengl" or "auto". The default is FluentWindowsGraphicsDriver.AUTO in Windows and FluentLinuxGraphicsDriver.AUTO in Linux.

show_guibool, optional

Whether to display the Fluent GUI. The default is None, which does not cause the GUI to be shown. If a value of False is not explicitly provided, the GUI will also be shown if the environment variable PYFLUENT_SHOW_SERVER_GUI is set to 1.

case_file_namestr, optional

If provided, the case file at case_file_name is read into the Fluent session.

case_data_file_namestr, 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 is False.

modestr, 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.

cwdstr, Optional

Working directory for the Fluent client.

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_optionsdict, 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 keys scheduler_headnode, scheduler_queue and scheduler_account are optional and should be specified in a similar manner to Fluent’s scheduler options.

file_transfer_serviceoptional

File transfer service. Uploads/downloads files to/from the server.

kwargsAny

Keyword arguments.

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.

DockerContainerLaunchNotSupported

If a Fluent Docker container launch is not supported.

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.