fluent_connection#

Classes:

ErrorState([name, details])

Object to indicate the error state of the connected Fluent client.

FluentConnection([start_timeout, ip, port, ...])

Encapsulates a Fluent connection.

FluentConnectionProperties([ip, port, ...])

Stores Fluent connection properties, including connection IP, port and password; Fluent Cortex working directory, process ID and hostname; and whether Fluent was launched in a docker container.

MonitorThread()

A class used for monitoring a Fluent session.

Functions:

get_container(container_id_or_name)

Get the Docker container object.

class ansys.fluent.core.fluent_connection.ErrorState(name='', details='')#

Bases: object

Object to indicate the error state of the connected Fluent client.

Examples

>>> import ansys.fluent.core as pyfluent
>>> session = pyfluent.launch_fluent()
>>> session.fluent_connection.error_state.set("test", "test details")
>>> session.fluent_connection.error_state.name
'test'
>>> session.fluent_connection.error_state.details
'test details'
>>> session.fluent_connection.error_state.clear()
>>> session.fluent_connection.error_state.name
''

Methods:

clear()

Method to clear the current error state, emptying the error name and details properties.

set(name, details)

Method to set the error state name and details to new values.

Attributes:

details

name

clear()#

Method to clear the current error state, emptying the error name and details properties.

property details#
property name#
set(name, details)#

Method to set the error state name and details to new values.

class ansys.fluent.core.fluent_connection.FluentConnection(start_timeout=60, ip=None, port=None, password=None, channel=None, cleanup_on_exit=True, start_transcript=True, remote_instance=None, launcher_args=None, inside_container=None)#

Bases: object

Encapsulates a Fluent connection.

Methods

check_health()

Check health of Fluent connection.

exit()

Close the Fluent connection and exit Fluent.

Methods:

check_health()

Check health of Fluent connection.

create_service(service, *args)

Create a gRPC service.

exit([timeout, timeout_force])

Close the Fluent connection and exit Fluent.

force_exit()

Immediately terminates the Fluent client, losing unsaved progress and data.

force_exit_container()

Immediately terminates the Fluent client running inside a container, losing unsaved progress and data.

register_finalizer_cb(cb)

Register a callback to run with the finalizer.

check_health()#

Check health of Fluent connection.

create_service(service, *args)#

Create a gRPC service.

Parameters:
serviceAny

service class

argsAny, optional

additional arguments, by default empty

Returns:
Any

service object

exit(timeout=None, timeout_force=True)#

Close the Fluent connection and exit Fluent.

Parameters:
timeoutfloat, optional

Time in seconds before considering that the exit request has timed out. If omitted or specified as None, then request will not time out and will lock up the interpreter while waiting for a response.

timeout_forcebool, optional

If not specified, defaults to True. If True, attempts to terminate the Fluent process if exit request reached timeout. Executes force_exit() or force_exit_container(), depending on how Fluent was launched.

Notes

Can also set the PYFLUENT_TIMEOUT_FORCE_EXIT environment variable to specify the number of seconds and alter the default timeout value. Setting this env var to a non-number value, such as OFF, will return this function to default behavior. Note that the environment variable will be ignored if timeout is specified when calling this function.

Examples

>>> import ansys.fluent.core as pyfluent
>>> session = pyfluent.launch_fluent()
>>> session.exit()
force_exit()#

Immediately terminates the Fluent client, losing unsaved progress and data.

Notes

If the Fluent session is responsive, prefer using exit() instead.

Examples

>>> import ansys.fluent.core as pyfluent
>>> session = pyfluent.launch_fluent()
>>> session.force_exit()
force_exit_container()#

Immediately terminates the Fluent client running inside a container, losing unsaved progress and data.

Notes

By default, Fluent does not run in a container, in that case use force_exit(). If the Fluent session is responsive, prefer using exit() instead.

register_finalizer_cb(cb)#

Register a callback to run with the finalizer.

class ansys.fluent.core.fluent_connection.FluentConnectionProperties(ip=None, port=None, password=None, cortex_pwd=None, cortex_pid=None, cortex_host=None, fluent_host_pid=None, inside_container=None)#

Bases: object

Stores Fluent connection properties, including connection IP, port and password; Fluent Cortex working directory, process ID and hostname; and whether Fluent was launched in a docker container.

Examples

These properties are also available through the session object and can be accessed as:

>>> import ansys.fluent.core as pyfluent
>>> session = pyfluent.launch_fluent()
>>> session.connection_properties.list_names()
['ip', 'port', 'password', 'cortex_pwd', 'cortex_pid', 'cortex_host', 'inside_container']
>>> session.connection_properties.ip
'127.0.0.1'

Attributes:

cortex_host

cortex_pid

cortex_pwd

fluent_host_pid

inside_container

ip

password

port

Methods:

list_names()

Returns list with all property names.

list_values()

Returns dictionary with all property names and values.

cortex_host: str = None#
cortex_pid: int = None#
cortex_pwd: str = None#
fluent_host_pid: int = None#
inside_container: Union[bool, Container, None] = None#
ip: str = None#
list_names()#

Returns list with all property names.

list_values()#

Returns dictionary with all property names and values.

password: str = None#
port: int = None#
class ansys.fluent.core.fluent_connection.MonitorThread#

Bases: Thread

A class used for monitoring a Fluent session.

Daemon thread which will ensure cleanup of session objects, shutdown of non-deamon threads etc.

Attributes:
cbsList[Callable]

Cleanup/shutdown functions

Methods:

run()

Run monitor thread.

run()#

Run monitor thread.

ansys.fluent.core.fluent_connection.get_container(container_id_or_name)#

Get the Docker container object.

Returns:
Union[bool, Container, None]

If the system is not correctly set up to run Docker containers, returns None. If the container was not found, returns False. If the container is found, returns the associated Docker container object.

Notes

See Docker container for more information.