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:
|
Provides an intermediate base class for the |
|
Provides a base class for settings and command objects. |
|
Provides for executing a command. |
|
Provides an object representing a Boolean value setting. |
|
Provides an object representing a Boolean list setting. |
|
Provides for executing a base command. |
|
Provides for executing a base with keyword arguments. |
|
Resolves MRO for child classes. |
|
Provides an object representing a file name. |
|
An object represents a list of file names. |
|
A |
|
Provides an object representing an integer value setting. |
|
An |
|
A |
|
Provides an object representing key-value settings. |
|
A |
|
Provides the wild card path at a |
|
Exposes the attribute accessor on a settings object. |
|
Exposes the attribute accessor on a settings object. |
|
Provides for querying objects. |
|
Provides an object representing a real value setting. |
|
Provides an object representing a real list setting. |
|
Provides an object representing a real value setting, including single real values and containers of real values, such as lists. |
|
Provides an object representing a 3D vector. |
|
Provides a base class for settings objects. |
|
Provides an object representing a string value setting. |
|
Provides an object representing a string list setting. |
|
Exposes the attribute accessor on the settings object. |
|
Wraps a wildcard path to perform |
Exceptions:
Provides the deprecated settings warning. |
|
|
Provides the inactive object access warning. |
Provides the unstable settings warning. |
Functions:
|
Provides the assert type warning. |
|
Check the type of the object. |
|
Get paths of all child objects matching an identifier. |
|
Create a class for the object identified by |
|
Get the root settings object. |
Reset global variables. |
|
|
Convert a CFX engine string to a Python variable name. |
- class ansys.cfx.core.common.flobject.Action(name: str | None = None, parent=None)#
Bases:
BaseProvides an intermediate base class for the
CommandandQueryclasses.Methods:
__init__([name, parent])Initialize an instance of the
Actionclass.get_completer_info([prefix, excluded])Get completer information of all arguments.
- class ansys.cfx.core.common.flobject.Base(name: str | None = None, parent=None)#
Bases:
objectProvides a base class for settings and command objects.
- Parameters:
- name
str Name of the object if a child of a named object.
- parent: Base
Parent of the object.
- name
- Attributes:
Methods:
__init__([name, parent])Initialize an instance of the
Baseclass.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.
Check if the object is active.
Check if the object is read-only.
set_flproxy(flproxy)Set the
flproxyobject.Attributes:
Remote file handler.
Proxy object.
CFX engine/CCL name of the object.
Parent (container) object.
Path of the object.
Python name of the object.
Path of the object.
- 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.
- 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_nameof 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_pathand the parent’s Python path.
- set_flproxy(flproxy)#
Set the
flproxyobject.
- class ansys.cfx.core.common.flobject.BaseCommand(name: str | None = None, parent=None)#
Bases:
ActionProvides 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],PropertyProvides an object representing a Boolean value setting.
- class ansys.cfx.core.common.flobject.BooleanList(name: str | None = None, parent=None)#
Bases:
SettingsBase[List[bool]],PropertyProvides an object representing a Boolean list setting.
- class ansys.cfx.core.common.flobject.Command(name: str | None = None, parent=None)#
Bases:
BaseCommandProvides for executing a base command.
- class ansys.cfx.core.common.flobject.CommandWithPositionalArgs(name: str | None = None, parent=None)#
Bases:
BaseCommandProvides for executing a base with keyword arguments.
- exception ansys.cfx.core.common.flobject.DeprecatedSettingWarning#
Bases:
FutureWarningProvides the deprecated settings warning.
- class ansys.cfx.core.common.flobject.FileName(name: str | None = None, parent=None)#
Bases:
BaseResolves MRO for child classes.
- class ansys.cfx.core.common.flobject.Filename(name: str | None = None, parent=None)#
Bases:
SettingsBase[str],TextualProvides an object representing a file name.
Methods:
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]],TextualAn object represents a list of file names.
Methods:
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
Groupcontainer 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
Groupclass.Get the names of currently active children.
Get the names of currently active commands.
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
valueto have keys with engine names.to_python_keys(value)Convert the state in
valueto have keys with Python names.Attributes:
- 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
valueto have keys with engine names.- Raises:
RuntimeErrorIf key is invalid.
- classmethod to_python_keys(value)#
Convert the state in
valueto have keys with Python names.
- exception ansys.cfx.core.common.flobject.InactiveObjectError(python_path)#
Bases:
RuntimeErrorProvides 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],NumericalProvides an object representing an integer value setting.
- class ansys.cfx.core.common.flobject.IntegerList(name: str | None = None, parent=None)#
Bases:
SettingsBase[List[int]],NumericalAn
Integerobject representing an integer list setting.
- class ansys.cfx.core.common.flobject.ListObject(name=None, parent=None)#
Bases:
SettingsBase[List[StateType]],Generic[ChildTypeT]A
ListObjectcontainer 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
ListObjectclass.get_size()Get the number of elements in a list object.
to_engine_keys(value)Convert the state in
valueto have keys with engine names.to_python_keys(value)Convert the state in
valueto have keys with Python names.Attributes:
- __init__(name=None, parent=None)#
Initialize an instance of the
ListObjectclass.
- command_names = []#
- query_names = []#
- classmethod to_engine_keys(value)#
Convert the state in
valueto have keys with engine names.
- classmethod to_python_keys(value)#
Convert the state in
valueto 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
NamedObjectcontainer 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
NamedObjectclass.get_completer_info([prefix, excluded])Get completer information of all children.
Get object names.
items()Get items.
keys()Get object names.
to_engine_keys(value)Convert the state in
valueto have keys with engine names.to_python_keys(value)Convert the state in
valueto have keys with Python names.Check if the object is user-creatable.
values()Get object values.
Attributes:
- 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
valueto have keys with engine names.
- classmethod to_python_keys(value)#
Convert the state in
valueto have keys with Python names.
- values()#
Get object values.
- class ansys.cfx.core.common.flobject.NamedObjectWildcardPath(flproxy, path: str, state_cls, settings_cls, parent)#
Bases:
WildcardPathProvides the wild card path at a
NamedObjectpath so it can be looked up by wildcard again.
- class ansys.cfx.core.common.flobject.Numerical(name: str | None = None, parent=None)#
Bases:
PropertyExposes 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.
- class ansys.cfx.core.common.flobject.Property(name: str | None = None, parent=None)#
Bases:
BaseExposes the attribute accessor on a settings object.
Methods:
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:
ActionProvides for querying objects.
- class ansys.cfx.core.common.flobject.Real(name: str | None = None, parent=None)#
Bases:
SettingsBase[real],RealNumericalProvides an object representing a real value setting.
Some
Realobjects 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.
- set_state(state: StateT | None = None, **kwargs)#
Set the state of the object.
- Parameters:
- Raises:
NotImplementedErrorIf 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]],RealNumericalProvides 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.
- set_state(state: StateT | None = None, **kwargs)#
Set the state of the object.
- Parameters:
- Raises:
NotImplementedErrorIf the state cannot be handled for the given path.
- class ansys.cfx.core.common.flobject.RealNumerical(name: str | None = None, parent=None)#
Bases:
NumericalProvides 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:
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.
- set_state(state: StateT | None = None, **kwargs)#
Set the state of the object.
- Parameters:
- Raises:
NotImplementedErrorIf the state cannot be handled for the given path.
- class ansys.cfx.core.common.flobject.RealVector(name: str | None = None, parent=None)#
Bases:
SettingsBase[Tuple[real,real,real]],NumericalProvides an object representing a 3D vector.
A
RealVectorobject consists of three real values.
- class ansys.cfx.core.common.flobject.SettingsBase(name: str | None = None, parent=None)#
-
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 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.
Get the state of the object with units where available.
to_engine_keys(value)Convert the state in
valueto have keys with engine names.to_python_keys(value)Convert the state in
valueto 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.
- 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
valueto have keys with engine names.This is overridden in the
Group,NamedObject, andListObjectclasses.
- classmethod to_python_keys(value: StateT) StateT#
Convert the state in
valueto have keys with Python names.This is overridden in the
Group,NamedObject, andListObjectclasses.
- class ansys.cfx.core.common.flobject.String(name: str | None = None, parent=None)#
Bases:
SettingsBase[str],TextualProvides an object representing a string value setting.
- class ansys.cfx.core.common.flobject.StringList(name: str | None = None, parent=None)#
Bases:
SettingsBase[List[str]],TextualProvides an object representing a string list setting.
- class ansys.cfx.core.common.flobject.Textual(name: str | None = None, parent=None)#
Bases:
PropertyExposes the attribute accessor on the settings object. This class is specific to string objects.
- exception ansys.cfx.core.common.flobject.UnstableSettingWarning#
Bases:
UserWarningProvides the unstable settings warning.
- class ansys.cfx.core.common.flobject.WildcardPath(flproxy, path: str, state_cls, settings_cls, parent)#
Bases:
GroupWraps a wildcard path to perform
get_var()andset_var()on flproxy.Methods:
__init__(flproxy, path, state_cls, ...)Initialize an instance of the
WildcardPathclass.items()Get items.
to_engine_keys(value)Convert the state in
valueto have keys with engine names.to_python_keys(value)Convert the state in
valueto have keys with Python names.Attributes:
- __init__(flproxy, path: str, state_cls, settings_cls, parent)#
Initialize an instance of the
WildcardPathclass.
- property flproxy#
Proxy object.
- items()#
Get items.
- property path#
Path with wildcards.
- to_engine_keys(value)#
Convert the state in
valueto have keys with engine names.
- to_python_keys(value)#
Convert the state in
valueto have keys with Python names.
- ansys.cfx.core.common.flobject.assert_type(val, tp)#
Provides the assert type warning.
- Raises:
TypeErrorIf 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, orpost-processing.- flproxy: Proxy
Object that interfaces with the CFX backend.
- file_transfer_service
optional File transfer service. Uploads or downloads files to and from the server.
- info_query
Any gRPC service to execute Engine/CCL code.
- version
str CFX version.
- Returns:
Rootobject.
- Raises:
RuntimeErrorIf hash values are inconsistent.
- ansys.cfx.core.common.flobject.reset_globals()#
Reset global variables.