Operator Configuration#

class ansys.dpf.core.config.Config(operator_name=None, config=None, server=None, spec=None)#

Represents an operator’s configuration.

You can use configurations to choose how an operator will run. This is an advanced feature for deep customization. The different options can change the way loops are done. They can also change whether the operator needs to perform checks on the input.

Parameters:
  • operator_name (str, optional) – Name of the operator. The default is None.

  • config (str, optional) – Name of the configuration. The default is None.

  • server (str, optional) – Server with the channel connected to the remote or local instance. The default is None, in which case an attempt is made to use the global server.

Examples

Create an operator configuration, instantiate the operator and run it with the configuration.

>>> from ansys.dpf import core as dpf
>>> config_add = dpf.Config("add")
>>> config_add.set_work_by_index_option(True)
>>> op = dpf.operators.math.add(config=config_add)

Modify the copy of an operator’s configuration and set it as current config of the operator.

>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.math.add()
>>> config_add = op.config
>>> config_add.set_work_by_index_option(True)
>>> op.config = config_add
property options#

Retrieve a list of configuration options and their values.

Returns:

List of configuration options and their values.

Return type:

list

set_config_option(config_name, config_value)#

Change the value of a configuration option.

Parameters:
  • config_value (bool, int, float) – Value to give to a configuration option.

  • config_name (str) – Name of the configuration option.

Examples

Modify the copy of an operator’s configuration and set it as current config of the operator.

>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.math.add()
>>> config_add = op.config
>>> config_add.set_config_option(config_name="work_by_index", config_value=True)
>>> op.config = config_add
config_option_value(config_name)#

Retrieve the value for a configuration option.

Parameters:

config_name (str) – Name of the configuration option.

Returns:

Value for the configuration option.

Return type:

str

config_option_documentation(config_name)#

Retrieve the documentation for a configuration option.

Parameters:

config_name (str) – Name of the configuration option.

Returns:

Documentation for the configuration option.

Return type:

str

config_option_accepted_types(config_name)#

Retrieve accepted types for a configuration option.

Parameters:

config_name (str) – Name of the configuration option.

Returns:

One or more accepted types for the configuration option.

Return type:

list, str

config_option_default_value(config_name)#

Retrieve the default value for a configuration option.

Parameters:

config_name (str) – Name of the configuration option.

Returns:

Default value for the configuration option.

Return type:

str

property available_config_options#

Available configuration options for the operator.

Returns:

One or more available configuration options for the operator.

Return type:

list, str