flobject#

Module for accessing and modifying the hierarchy of CFX settings.

The only useful method is get_root(), which returns the root object for accessing CFX settings.

Child objects can be generally accessed or modified using attribute access. Named child objects can be accessed or modified using index operators.

Calling an object returns its current value.

Example#

>>> import ansys.cfx.core as pycfx
>>> import flobject
>>> pypre = pycfx.PreProcessing.from_install()
>>> pypre.file.new_case()
>>> analysis_type = pypre.setup.flow['Flow Analysis 1'].analysis_type
>>> r = flobject.get_root(analysis_type.flproxy)
>>> r.setup.flow['Flow Analysis 1'].solver_control.advection_scheme.option = "Upwind"

Classes:

Action([name, parent])

Provides an intermediate base class for the Command and Query classes.

Base([name, parent])

Provides a base class for settings and command objects.

BaseCommand([name, parent])

Provides for executing a command.

Boolean([name, parent])

Provides an object representing a Boolean value setting.

BooleanList([name, parent])

Provides an object representing a Boolean list setting.

Command([name, parent])

Provides for executing a base command.

CommandWithPositionalArgs([name, parent])

Provides for executing a base with keyword arguments.

FileName([name, parent])

Resolves MRO for child classes.

Filename([name, parent])

Provides an object representing a file name.

FilenameList([name, parent])

An object represents a list of file names.

Group([name, parent])

A Group container object.

Integer([name, parent])

Provides an object representing an integer value setting.

IntegerList([name, parent])

An Integer object representing an integer list setting.

ListObject([name, parent])

A ListObject container is a container object, similar to a Python list object.

Map([name, parent])

Provides an object representing key-value settings.

NamedObject([name, parent])

A NamedObject container is a container object similar to a Python dictionary object.

NamedObjectWildcardPath(flproxy, path, ...)

Provides the wild card path at a NamedObject path so it can be looked up by wildcard again.

Numerical([name, parent])

Exposes the attribute accessor on a settings object.

Property([name, parent])

Exposes the attribute accessor on a settings object.

Query([name, parent])

Provides for querying objects.

Real([name, parent])

Provides an object representing a real value setting.

RealList([name, parent])

Provides an object representing a real list setting.

RealNumerical([name, parent])

Provides an object representing a real value setting, including single real values and containers of real values, such as lists.

RealVector([name, parent])

Provides an object representing a 3D vector.

SettingsBase([name, parent])

Provides a base class for settings objects.

String([name, parent])

Provides an object representing a string value setting.

StringList([name, parent])

Provides an object representing a string list setting.

Textual([name, parent])

Exposes the attribute accessor on the settings object.

WildcardPath(flproxy, path, state_cls, ...)

Wraps a wildcard path to perform get_var() and set_var() on flproxy.

Exceptions:

DeprecatedSettingWarning

Provides the deprecated settings warning.

InactiveObjectError(python_path)

Provides the inactive object access warning.

UnstableSettingWarning

Provides the unstable settings warning.

Functions:

assert_type(val, tp)

Provides the assert type warning.

check_type(val, tp)

Check the type of the object.

find_children(obj[, identifier])

Get paths of all child objects matching an identifier.

get_cls(name, info[, parent, version, ...])

Create a class for the object identified by path.

get_root(flproxy[, session_name, version, ...])

Get the root settings object.

reset_globals()

Reset global variables.

to_python_name(cfx_name)

Convert a CFX engine string to a Python variable name.

class ansys.cfx.core.common.flobject.Action(name: str | None = None, parent=None)#

Bases: Base

Provides an intermediate base class for the Command and Query classes.

Methods:

__init__([name, parent])

Initialize an instance of the Action class.

get_completer_info([prefix, excluded])

Get completer information of all arguments.

__init__(name: str | None = None, parent=None)#

Initialize an instance of the Action class.

get_completer_info(prefix='', excluded=None) List[List[str]]#

Get completer information of all arguments.

Returns:
List[List[str]]

Name, type, and docstring of all arguments.

class ansys.cfx.core.common.flobject.Base(name: str | None = None, parent=None)#

Bases: object

Provides a base class for settings and command objects.

Parameters:
namestr

Name of the object if a child of a named object.

parent: Base

Parent of the object.

Attributes:
flproxy

Proxy object.

obj_name

CFX engine/CCL name of the object.

cfx_name

Methods:

__init__([name, parent])

Initialize an instance of the Base class.

after_execute(value)

Execute after command execution.

before_execute(value)

Execute before command execution.

find_object(relative_path)

Find object.

get_attr(attr[, attr_type_or_types])

Get the requested attribute for the object.

get_attrs(attrs[, recursive])

Get the requested attributes for the object.

is_active()

Check if the object is active.

is_read_only()

Check if the object is read-only.

set_flproxy(flproxy)

Set the flproxy object.

Attributes:

cfx_name

file_transfer_service

Remote file handler.

flproxy

Proxy object.

obj_name

CFX engine/CCL name of the object.

parent

Parent (container) object.

path

Path of the object.

python_name

Python name of the object.

python_path

Path of the object.

__init__(name: str | None = None, parent=None)#

Initialize an instance of the Base class.

after_execute(value)#

Execute after command execution.

before_execute(value)#

Execute before command execution.

cfx_name = None#
property file_transfer_service#

Remote file handler.

Supports file upload and download.

find_object(relative_path)#

Find object.

property flproxy#

Proxy object.

The proxy object is set at the root level and accessed using the parent for the child classes.

get_attr(attr: str, attr_type_or_types: type | Tuple[type] | None = None) Any#

Get the requested attribute for the object.

Parameters:
attrstr

Attribute name.

attr_type_or_typestype or tuple of type, default: None

Attribute type.

Returns:
Any

Attribute value.

Raises:
InactiveObjectError

If any attribute other than "active? is queried when the object is not active.

get_attrs(attrs, recursive=False) Any#

Get the requested attributes for the object.

is_active() bool#

Check if the object is active.

is_read_only() bool#

Check if the object is read-only.

property obj_name: str#

CFX engine/CCL name of the object.

By default, this returns the object’s static name. If the object is a child of a named object, the object’s name is returned.

property parent#

Parent (container) object.

property path: str#

Path of the object.

The path is constructed from the obj_name of self and the path of parent.

property python_name: str#

Python name of the object.

By default, this returns the object’s static name. If the object is a child of a named object, the object’s name is returned.

property python_path: str#

Path of the object.

The path is constructed in Python syntax from python_path and the parent’s Python path.

set_flproxy(flproxy)#

Set the flproxy object.

class ansys.cfx.core.common.flobject.BaseCommand(name: str | None = None, parent=None)#

Bases: Action

Provides for executing a command.

Methods:

execute_command(*args, **kwds)

Execute command.

execute_command(*args, **kwds)#

Execute command.

class ansys.cfx.core.common.flobject.Boolean(name: str | None = None, parent=None)#

Bases: SettingsBase[bool], Property

Provides an object representing a Boolean value setting.

class ansys.cfx.core.common.flobject.BooleanList(name: str | None = None, parent=None)#

Bases: SettingsBase[List[bool]], Property

Provides an object representing a Boolean list setting.

class ansys.cfx.core.common.flobject.Command(name: str | None = None, parent=None)#

Bases: BaseCommand

Provides for executing a base command.

class ansys.cfx.core.common.flobject.CommandWithPositionalArgs(name: str | None = None, parent=None)#

Bases: BaseCommand

Provides for executing a base with keyword arguments.

exception ansys.cfx.core.common.flobject.DeprecatedSettingWarning#

Bases: FutureWarning

Provides the deprecated settings warning.

class ansys.cfx.core.common.flobject.FileName(name: str | None = None, parent=None)#

Bases: Base

Resolves MRO for child classes.

class ansys.cfx.core.common.flobject.Filename(name: str | None = None, parent=None)#

Bases: SettingsBase[str], Textual

Provides an object representing a file name.

Methods:

file_purpose()

Determine if CFX uses this file as an input or output.

file_purpose()#

Determine if CFX uses this file as an input or output.

class ansys.cfx.core.common.flobject.FilenameList(name: str | None = None, parent=None)#

Bases: SettingsBase[List[str]], Textual

An object represents a list of file names.

Methods:

file_purpose()

Determine if CFX uses this file as an input or output.

file_purpose()#

Determine if CFX uses this file as an input or output.

class ansys.cfx.core.common.flobject.Group(name: str | None = None, parent=None)#

Bases: SettingsBase[Dict[str, StateType]]

A Group container object.

This container object is similar to a C++ structure object. Child objects can be accessed with attribute access.

Attributes:
child_names: list[str]

Names of the child objects.

command_names: list[str]

Names of the commands.

Methods:

__init__([name, parent])

Initialize an instance of the Group class.

get_active_child_names()

Get the names of currently active children.

get_active_command_names()

Get the names of currently active commands.

get_active_query_names()

Names of queries that are currently active.

get_completer_info([prefix, excluded])

Get completer information of all children.

to_engine_keys(value)

Convert the state in value to have keys with engine names.

to_python_keys(value)

Convert the state in value to have keys with Python names.

Attributes:

__init__(name: str | None = None, parent=None)#

Initialize an instance of the Group class.

child_names = []#
command_names = []#
get_active_child_names()#

Get the names of currently active children.

get_active_command_names()#

Get the names of currently active commands.

get_active_query_names()#

Names of queries that are currently active.

get_completer_info(prefix='', excluded=None) List[List[str]]#

Get completer information of all children.

Returns:
List[List[str]]

Name, type, and docstring of all children.

query_names = []#
classmethod to_engine_keys(value)#

Convert the state in value to have keys with engine names.

Raises:
RuntimeError

If key is invalid.

classmethod to_python_keys(value)#

Convert the state in value to have keys with Python names.

exception ansys.cfx.core.common.flobject.InactiveObjectError(python_path)#

Bases: RuntimeError

Provides the inactive object access warning.

Methods:

__init__(python_path)

__init__(python_path)#
class ansys.cfx.core.common.flobject.Integer(name: str | None = None, parent=None)#

Bases: SettingsBase[int], Numerical

Provides an object representing an integer value setting.

class ansys.cfx.core.common.flobject.IntegerList(name: str | None = None, parent=None)#

Bases: SettingsBase[List[int]], Numerical

An Integer object representing an integer list setting.

class ansys.cfx.core.common.flobject.ListObject(name=None, parent=None)#

Bases: SettingsBase[List[StateType]], Generic[ChildTypeT]

A ListObject container is a container object, similar to a Python list object. Generally, many such objects can be created.

Attributes:
command_names: list[str]

Names of the commands.

Methods

get_size()

Get the size of the list.

Methods:

__init__([name, parent])

Initialize an instance of the ListObject class.

get_size()

Get the number of elements in a list object.

to_engine_keys(value)

Convert the state in value to have keys with engine names.

to_python_keys(value)

Convert the state in value to have keys with Python names.

Attributes:

__init__(name=None, parent=None)#

Initialize an instance of the ListObject class.

command_names = []#
get_size() int#

Get the number of elements in a list object.

Returns:
int
query_names = []#
classmethod to_engine_keys(value)#

Convert the state in value to have keys with engine names.

classmethod to_python_keys(value)#

Convert the state in value to have keys with Python names.

class ansys.cfx.core.common.flobject.Map(name: str | None = None, parent=None)#

Bases: SettingsBase[Dict[str, StateType]]

Provides an object representing key-value settings.

class ansys.cfx.core.common.flobject.NamedObject(name: str | None = None, parent=None)#

Bases: SettingsBase[Dict[str, StateType]], Generic[ChildTypeT]

A NamedObject container is a container object similar to a Python dictionary object. Generally, many such objects can be created with different names.

Attributes:
command_names: list[str]

Names of the commands.

Methods:

__init__([name, parent])

Initialize an instance of the NamedObject class.

get_completer_info([prefix, excluded])

Get completer information of all children.

get_object_names()

Get object names.

items()

Get items.

keys()

Get object names.

to_engine_keys(value)

Convert the state in value to have keys with engine names.

to_python_keys(value)

Convert the state in value to have keys with Python names.

user_creatable()

Check if the object is user-creatable.

values()

Get object values.

Attributes:

__init__(name: str | None = None, parent=None)#

Initialize an instance of the NamedObject class.

command_names = []#
get_completer_info(prefix='', excluded=None) List[List[str]]#

Get completer information of all children.

Returns:
List[List[str]]

Name, type, and docstring of all children.

get_object_names()#

Get object names.

items()#

Get items.

keys()#

Get object names.

query_names = []#
classmethod to_engine_keys(value)#

Convert the state in value to have keys with engine names.

classmethod to_python_keys(value)#

Convert the state in value to have keys with Python names.

user_creatable() bool#

Check if the object is user-creatable.

values()#

Get object values.

class ansys.cfx.core.common.flobject.NamedObjectWildcardPath(flproxy, path: str, state_cls, settings_cls, parent)#

Bases: WildcardPath

Provides the wild card path at a NamedObject path so it can be looked up by wildcard again.

class ansys.cfx.core.common.flobject.Numerical(name: str | None = None, parent=None)#

Bases: Property

Exposes the attribute accessor on a settings object. This class is specific to numerical objects.

Methods:

max()

Get the maximum value of the object.

min()

Get the minimum value of the object.

max()#

Get the maximum value of the object.

min()#

Get the minimum value of the object.

class ansys.cfx.core.common.flobject.Property(name: str | None = None, parent=None)#

Bases: Base

Exposes the attribute accessor on a settings object.

Methods:

default_value()

Get the default value of the object.

default_value()#

Get the default value of the object.

class ansys.cfx.core.common.flobject.Query(name: str | None = None, parent=None)#

Bases: Action

Provides for querying objects.

class ansys.cfx.core.common.flobject.Real(name: str | None = None, parent=None)#

Bases: SettingsBase[real], RealNumerical

Provides an object representing a real value setting.

Some Real objects also accept string arguments representing expression values.

Methods:

base_set_state([state])

Set the state of the object.

set_state([state])

Set the state of the object.

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

Set the state of the object.

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

Set the state of the object.

Parameters:
statefloat | str | ansys.units.Quantity

The parameter value to set. If a string is provided, it may contain either an expression or a value with units.

kwargsAny

Keyword arguments.

Raises:
NotImplementedError

If the state cannot be handled for the given path.

class ansys.cfx.core.common.flobject.RealList(name: str | None = None, parent=None)#

Bases: SettingsBase[List[real]], RealNumerical

Provides an object representing a real list setting.

Methods:

base_set_state([state])

Set the state of the object.

set_state([state])

Set the state of the object.

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

Set the state of the object.

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

Set the state of the object.

Parameters:
statefloat | str | ansys.units.Quantity

The parameter value to set. If a string is provided, it may contain either an expression or a value with units.

kwargsAny

Keyword arguments.

Raises:
NotImplementedError

If the state cannot be handled for the given path.

class ansys.cfx.core.common.flobject.RealNumerical(name: str | None = None, parent=None)#

Bases: Numerical

Provides an object representing a real value setting, including single real values and containers of real values, such as lists.

Methods

as_quantity()

Get the current state of the object as an ansys.units.Quantity.

set_state(state)

Set the state of the object.

units()

Get the units string.

Methods:

as_quantity()

Get the state of the object as an ansys.units.Quantity.

set_state([state])

Set the state of the object.

units()

Get the physical units of the object as a string.

as_quantity() Quantity | None#

Get the state of the object as an ansys.units.Quantity.

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

Set the state of the object.

Parameters:
statefloat | str | ansys.units.Quantity

The parameter value to set. If a string is provided, it may contain either an expression or a value with units.

kwargsAny

Keyword arguments.

Raises:
NotImplementedError

If the state cannot be handled for the given path.

units() str | None#

Get the physical units of the object as a string.

class ansys.cfx.core.common.flobject.RealVector(name: str | None = None, parent=None)#

Bases: SettingsBase[Tuple[real, real, real]], Numerical

Provides an object representing a 3D vector.

A RealVector object consists of three real values.

class ansys.cfx.core.common.flobject.SettingsBase(name: str | None = None, parent=None)#

Bases: Base, Generic[StateT]

Provides a base class for settings objects.

Methods

get_state()

Get the current state of the object.

set_state(state)

Set the state of the object.

Methods:

get_state()

Get the state of the object.

print_state([out, indent_factor])

Print the state of the object.

set_state([state])

Set the state of the object.

state_with_units()

Get the state of the object with units where available.

to_engine_keys(value)

Convert the state in value to have keys with engine names.

to_python_keys(value)

Convert the state in value to have keys with Python names.

get_state() StateT#

Get the state of the object.

print_state(out=None, indent_factor=2)#

Print the state of the object.

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

Set the state of the object.

state_with_units() StateT#

Get the state of the object with units where available.

classmethod to_engine_keys(value: StateT) StateT#

Convert the state in value to have keys with engine names.

This is overridden in the Group, NamedObject, and ListObject classes.

classmethod to_python_keys(value: StateT) StateT#

Convert the state in value to have keys with Python names.

This is overridden in the Group, NamedObject, and ListObject classes.

class ansys.cfx.core.common.flobject.String(name: str | None = None, parent=None)#

Bases: SettingsBase[str], Textual

Provides an object representing a string value setting.

class ansys.cfx.core.common.flobject.StringList(name: str | None = None, parent=None)#

Bases: SettingsBase[List[str]], Textual

Provides an object representing a string list setting.

class ansys.cfx.core.common.flobject.Textual(name: str | None = None, parent=None)#

Bases: Property

Exposes the attribute accessor on the settings object. This class is specific to string objects.

exception ansys.cfx.core.common.flobject.UnstableSettingWarning#

Bases: UserWarning

Provides the unstable settings warning.

class ansys.cfx.core.common.flobject.WildcardPath(flproxy, path: str, state_cls, settings_cls, parent)#

Bases: Group

Wraps a wildcard path to perform get_var() and set_var() on flproxy.

Methods:

__init__(flproxy, path, state_cls, ...)

Initialize an instance of the WildcardPath class.

items()

Get items.

to_engine_keys(value)

Convert the state in value to have keys with engine names.

to_python_keys(value)

Convert the state in value to have keys with Python names.

Attributes:

flproxy

Proxy object.

path

Path with wildcards.

__init__(flproxy, path: str, state_cls, settings_cls, parent)#

Initialize an instance of the WildcardPath class.

property flproxy#

Proxy object.

items()#

Get items.

property path#

Path with wildcards.

to_engine_keys(value)#

Convert the state in value to have keys with engine names.

to_python_keys(value)#

Convert the state in value to have keys with Python names.

ansys.cfx.core.common.flobject.assert_type(val, tp)#

Provides the assert type warning.

Raises:
TypeError

If the given value is not of the given type.

ansys.cfx.core.common.flobject.check_type(val, tp)#

Check the type of the object.

ansys.cfx.core.common.flobject.find_children(obj, identifier='*')#

Get paths of all child objects matching an identifier.

Parameters:
obj: Object

Object whose children are to be queried.

identifier: str

Identifier for finding specific children.

Returns:
List
ansys.cfx.core.common.flobject.get_cls(name, info, parent=None, version=None, is_postprocessing=False)#

Create a class for the object identified by path.

ansys.cfx.core.common.flobject.get_root(flproxy, session_name: str = '', version: str = '', file_transfer_service: Any | None = None, info_query=None) Group#

Get the root settings object.

Parameters:
session_name: str

Name of a specific CFX session, such as pre-processing, solver, or post-processing.

flproxy: Proxy

Object that interfaces with the CFX backend.

file_transfer_serviceoptional

File transfer service. Uploads or downloads files to and from the server.

info_queryAny

gRPC service to execute Engine/CCL code.

versionstr

CFX version.

Returns:
Root object.
Raises:
RuntimeError

If hash values are inconsistent.

ansys.cfx.core.common.flobject.reset_globals()#

Reset global variables.

ansys.cfx.core.common.flobject.to_python_name(cfx_name: str) str#

Convert a CFX engine string to a Python variable name.

This function replaces symbols with _. Any ? symbols are ignored.