session#

Module containing class encapsulating CFX connection and the Base Session.

Classes:

BaseSession(cfx_connection[, ...])

Instantiates a CFX connection.

class ansys.cfx.core.session.BaseSession(cfx_connection: CFXConnection, file_transfer_service: Any | None = None)#

Bases: object

Instantiates a CFX connection.

Attributes:
engine_eval: EngineEval

Instance of EngineEval to execute CFX’s CCL code on.

Methods:

__init__(cfx_connection[, file_transfer_service])

Instantiates an instance of the BaseSession class.

build_from_cfx_connection(cfx_connection[, ...])

Build a BaseSession object from a cfx_connection object.

download(file_name[, local_directory])

Download a file from the server.

execute_ccl(command[, wait])

Execute a CCL command.

exit(**kwargs)

Exit the session.

force_exit()

Terminate the CFX session immediately, losing unsaved progress and data.

get_cfx_version()

Get the CFX version.

get_name()

Get the session name.

get_state()

Get the state of the object.

has_remote_server()

Check if the session can connect to a remote server.

is_server_healthy()

Check if the current session is healthy.

set_state([state])

Set the state of the object.

upload(file_name)

Upload a file to the server.

Attributes:

id

Session ID.

settings

Root settings object.

__init__(cfx_connection: CFXConnection, file_transfer_service: Any | None = None)#

Instantiates an instance of the BaseSession class.

Args:

cfx_connection (cfx_connection): Encapsulates a CFX connection. file_transfer_service: Supports file upload and download.

build_from_cfx_connection(cfx_connection: CFXConnection, file_transfer_service: Any | None = None)#

Build a BaseSession object from a cfx_connection object.

download(file_name: str, local_directory: str | None = '.')#

Download a file from the server.

Parameters:
file_namestr

Name of the file to download from the server.

local_directorystr, optional

Local destination directory. The default is the current working directory.

execute_ccl(command: str, wait: bool = True) None#

Execute a CCL command.

exit(**kwargs) None#

Exit the session.

force_exit() None#

Terminate the CFX session immediately, losing unsaved progress and data.

get_cfx_version() CFXVersion#

Get the CFX version.

classmethod get_name() str | None#

Get the session name.

get_state() StateT#

Get the state of the object.

classmethod has_remote_server() bool#

Check if the session can connect to a remote server.

property id: str#

Session ID.

is_server_healthy() bool#

Check if the current session is healthy.

set_state(state: StateT | None = None, **kwargs)#

Set the state of the object.

property settings#

Root settings object.

upload(file_name: str)#

Upload a file to the server.

Parameters:
file_namestr

Name of the local file to upload to the server.