Operator

Interface to underlying gRPC Operator

class ansys.dpf.core.dpf_operator.Operator(name, config=None, server=None)

A class used to represent an Operator which is an elementary operation.The Operator is the only object used to create and transform the data. When the operator is evaluated, it will process the input information to compute its output with respect to its description.

A list of existing operators can be asked through the “html_doc” operator.

Parameters
  • name (str) – Name of the operator. For example ‘U’.

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the the global server.

Examples

Create an operator from the library of operators

>>> from ansys.dpf import core as dpf
>>> disp_oper = dpf.operators.result.displacement()

Create an operator from a model

>>> from ansys.dpf.core import Model
>>> from ansys.dpf.core import examples
>>> model = Model(examples.static_rst)
>>> disp_oper = model.results.displacement()
connect(pin, inpt, pin_out=0)

Connect an input on the operator using a pin number.

Parameters

Examples

Compute the minimum of displacement by chaining the 'U' and 'min_max_fc' operators.

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> data_src = dpf.DataSources(examples.multishells_rst)
>>> disp_op = dpf.operators.result.displacement()
>>> disp_op.inputs.data_sources(data_src)
>>> max_fc_op = dpf.operators.min_max.min_max_fc()
>>> max_fc_op.inputs.connect(disp_op.outputs)
>>> max_field = max_fc_op.outputs.field_max()
>>> max_field.data
array([[0.59428386, 0.00201751, 0.0006032 ]])
get_output(pin=0, output_type=None)

Returns the output of the operator on the pin number.

Parameters
  • pin (int, optional) – Number of the output pin.

  • output_type (core.type enum, optional) – The requested type of the output.

property config

Returns a copy of the current config of the operator. To use the config that you modify, please use operator.config = new_config or create an operator with the new config as a parameter.

Returns

config

Return type

Config

property inputs

Enables to connect inputs to the operator

Returns

inputs

Return type

Inputs

Examples

Use the displacement operator

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> data_src = dpf.DataSources(examples.multishells_rst)
>>> disp_op = dpf.operators.result.displacement()
>>> disp_op.inputs.data_sources(data_src)
property outputs

Enables to get outputs of the operator by evaluationg it

Returns

outputs

Return type

Output

Examples

CUse the displacement operator

>>> from ansys.dpf import core as dpf
>>> from ansys.dpf.core import examples
>>> data_src = dpf.DataSources(examples.multishells_rst)
>>> disp_op = dpf.operators.result.displacement()
>>> disp_op.inputs.data_sources(data_src)
>>> disp_fc = disp_op.outputs.fields_container()
static default_config(name, server=None)

Returns the default config for a given operator. This config can then be changed to the user needs and be used to instantiate the given operator

Parameters
  • name (str) – Name of the operator. For example ‘U’.

  • server (server.DPFServer, optional) – Server with channel connected to the remote or local instance. When None, attempts to use the the global server.

run()

Evaluate this operator