make_producer_consumer_for_each_iterator#

class ansys.dpf.core.operators.utility.make_producer_consumer_for_each_iterator.make_producer_consumer_for_each_iterator(try_generate_iterable=None, iterable=None, operator_to_iterate=None, pin_index=None, valueA=None, valueB=None, valueC1=None, valueC2=None, producer_op11=None, producer_op12=None, output_pin_of_producer_op11=None, output_pin_of_producer_op12=None, input_pin_of_consumer_op11=None, input_pin_of_consumer_op12=None, consumer_op11=None, consumer_op12=None, config=None, server=None)#

Bases: ansys.dpf.core.dpf_operator.Operator

Generates an iterator that can be consumed by the for_each operator.The chain of Operators are split into a first part : the producers and a second part : the consumers.Asynchronous buffers are indeed to connect the producers and the consumers.

Inputs#

try_generate_iterable: bool, optional

if true, already iterable values connected in pin 3 like vectors, Scoping, TimefreqSupport, Containers and DataSources are split to iterate on it (default is true)

iterable: optional

Iterable object, generated by make_for_each_range oeprator, that can be combined with the one currently generated.

operator_to_iterate: Operator

Operator that must be reconnected with the range values.

pin_index: int valueA: valueB: valueC1: valueC2: producer_op11: Operator producer_op12: Operator output_pin_of_producer_op11: int output_pin_of_producer_op12: int input_pin_of_consumer_op11: int input_pin_of_consumer_op12: int consumer_op11: Operator consumer_op12: Operator

Outputs#

iterator:

to connect to producer_consumer_for_each

Examples

>>> from ansys.dpf import core as dpf
>>> # Instantiate operator
>>> op = dpf.operators.utility.make_producer_consumer_for_each_iterator()
>>> # Make input connections
>>> my_try_generate_iterable = bool()
>>> op.inputs.try_generate_iterable.connect(my_try_generate_iterable)
>>> my_iterable = dpf.()
>>> op.inputs.iterable.connect(my_iterable)
>>> my_operator_to_iterate = dpf.Operator()
>>> op.inputs.operator_to_iterate.connect(my_operator_to_iterate)
>>> my_pin_index = int()
>>> op.inputs.pin_index.connect(my_pin_index)
>>> my_valueA = dpf.()
>>> op.inputs.valueA.connect(my_valueA)
>>> my_valueB = dpf.()
>>> op.inputs.valueB.connect(my_valueB)
>>> my_valueC1 = dpf.()
>>> op.inputs.valueC1.connect(my_valueC1)
>>> my_valueC2 = dpf.()
>>> op.inputs.valueC2.connect(my_valueC2)
>>> my_producer_op11 = dpf.Operator()
>>> op.inputs.producer_op11.connect(my_producer_op11)
>>> my_producer_op12 = dpf.Operator()
>>> op.inputs.producer_op12.connect(my_producer_op12)
>>> my_output_pin_of_producer_op11 = int()
>>> op.inputs.output_pin_of_producer_op11.connect(my_output_pin_of_producer_op11)
>>> my_output_pin_of_producer_op12 = int()
>>> op.inputs.output_pin_of_producer_op12.connect(my_output_pin_of_producer_op12)
>>> my_input_pin_of_consumer_op11 = int()
>>> op.inputs.input_pin_of_consumer_op11.connect(my_input_pin_of_consumer_op11)
>>> my_input_pin_of_consumer_op12 = int()
>>> op.inputs.input_pin_of_consumer_op12.connect(my_input_pin_of_consumer_op12)
>>> my_consumer_op11 = dpf.Operator()
>>> op.inputs.consumer_op11.connect(my_consumer_op11)
>>> my_consumer_op12 = dpf.Operator()
>>> op.inputs.consumer_op12.connect(my_consumer_op12)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.utility.make_producer_consumer_for_each_iterator(
...     try_generate_iterable=my_try_generate_iterable,
...     iterable=my_iterable,
...     operator_to_iterate=my_operator_to_iterate,
...     pin_index=my_pin_index,
...     valueA=my_valueA,
...     valueB=my_valueB,
...     valueC1=my_valueC1,
...     valueC2=my_valueC2,
...     producer_op11=my_producer_op11,
...     producer_op12=my_producer_op12,
...     output_pin_of_producer_op11=my_output_pin_of_producer_op11,
...     output_pin_of_producer_op12=my_output_pin_of_producer_op12,
...     input_pin_of_consumer_op11=my_input_pin_of_consumer_op11,
...     input_pin_of_consumer_op12=my_input_pin_of_consumer_op12,
...     consumer_op11=my_consumer_op11,
...     consumer_op12=my_consumer_op12,
... )
>>> # Get output data
>>> result_iterator = op.outputs.iterator()

Overview#

connect

Connect an input on the operator using a pin number.

connect_operator_as_input

Connect an operator as an input on a pin.

get_output

Retrieve the output of the operator on the pin number.

run

Evaluate this operator.

eval

Evaluate this operator.

inputs

Enables to connect inputs to the operator

outputs

Enables to get outputs of the operator by evaluating it

progress_bar

Enable or disable progress bar display when requesting the operator’s output.

config

Copy of the operator’s current configuration.

id

Retrieve the unique identifier of the operator.

specification

Returns the Specification (or documentation) of this Operator.

changelog

Return the changelog of this operator.

version

Return the current version of the operator.

default_config

Returns the default config of the operator.

operator_specification

Documents an Operator with its description (what the Operator does),its inputs and outputs and some properties.

__del__

Delete this instance.

__str__

Describe the entity.

__add__

Add two fields or two fields containers.

__sub__

Subtract two fields or two fields containers.

__pow__

Raise each element of a field or a fields container to power 2.

__mul__

Multiply two fields or two fields containers.

__truediv__

Perform division with another operator or a scalar.

Import detail#

from ansys.dpf.core.operators.utility.make_producer_consumer_for_each_iterator import make_producer_consumer_for_each_iterator

Property detail#

property make_producer_consumer_for_each_iterator.inputs: InputsMakeProducerConsumerForEachIterator#

Enables to connect inputs to the operator

Returns:

An instance of InputsMakeProducerConsumerForEachIterator.

Return type:

inputs

property make_producer_consumer_for_each_iterator.outputs: OutputsMakeProducerConsumerForEachIterator#

Enables to get outputs of the operator by evaluating it

Returns:

An instance of OutputsMakeProducerConsumerForEachIterator.

Return type:

outputs

property make_producer_consumer_for_each_iterator.progress_bar: bool#

Enable or disable progress bar display when requesting the operator’s output.

With this property, the user can choose to print a progress bar when the operator’s output is requested, default is False

property make_producer_consumer_for_each_iterator.config#

Copy of the operator’s current configuration.

You can modify the copy of the configuration and then use operator.config = new_config or instantiate an operator with the new configuration as a parameter.

For information on an operator’s options, see the documentation for that operator.

Returns:

Copy of the operator’s current configuration.

Return type:

ansys.dpf.core.config.Config

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_work_by_index_option(True)
>>> op.config = config_add
property make_producer_consumer_for_each_iterator.id: int#

Retrieve the unique identifier of the operator.

This property returns the unique ID associated with the operator. This property is lazily initialized.

Returns:

The unique identifier of the operator.

Return type:

int

Notes

Property available with server’s version starting at 10.0.

property make_producer_consumer_for_each_iterator.specification#

Returns the Specification (or documentation) of this Operator.

Return type:

Specification

property make_producer_consumer_for_each_iterator.changelog: ansys.dpf.core.changelog.Changelog#

Return the changelog of this operator.

Requires DPF 11.0 (2026 R1) or above.

Returns:

Changelog of the operator.

Return type:

changelog

property make_producer_consumer_for_each_iterator.version: packaging.version.Version#

Return the current version of the operator.

Requires DPF 11.0 (2026 R1) or above.

Attribute detail#

make_producer_consumer_for_each_iterator.name = None#

Method detail#

static make_producer_consumer_for_each_iterator.default_config(server: ansys.dpf.core.server_types.AnyServerType = None) → ansys.dpf.core.config.Config#

Returns the default config of the operator.

This config can then be changed to the user needs and be used to instantiate the operator. The Configuration allows to customize how the operation will be processed by the operator.

Parameters:

server – Server with channel connected to the remote or local instance. When None, attempts to use the global server.

Returns:

A new Config instance equivalent to the default config for this operator.

Return type:

config

make_producer_consumer_for_each_iterator.connect(pin, inpt, pin_out=0)#

Connect an input on the operator using a pin number.

Parameters:
  • pin (int) – Number of the input pin.

  • inpt (str, int, double, bool, list[int], list[float], Field, FieldsContainer, Scoping,)

  • ScopingsContainer – Operator, os.PathLike Object to connect to.

  • MeshedRegion – Operator, os.PathLike Object to connect to.

  • MeshesContainer – Operator, os.PathLike Object to connect to.

  • DataSources – Operator, os.PathLike Object to connect to.

  • CyclicSupport – Operator, os.PathLike Object to connect to.

  • dict – Operator, os.PathLike Object to connect to.

  • Outputs – Operator, os.PathLike Object to connect to.

  • pin_out (int, optional) – If the input is an operator, the output pin of the input operator. The default is 0.

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.find_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
DPFArray([[0.59428386, 0.00201751, 0.0006032 ]]...
make_producer_consumer_for_each_iterator.connect_operator_as_input(pin, op)#

Connect an operator as an input on a pin.

Parameters:
make_producer_consumer_for_each_iterator.get_output(pin=0, output_type=None)#

Retrieve the output of the operator on the pin number.

To activate the progress bar for server version higher or equal to 3.0, use my_op.progress_bar=True

Parameters:
  • pin (int, optional) – Number of the output pin. The default is 0.

  • output_type (ansys.dpf.core.common.types, type, optional) – Requested type of the output. The default is None.

Returns:

Output of the operator.

Return type:

type

make_producer_consumer_for_each_iterator.__del__()#

Delete this instance.

make_producer_consumer_for_each_iterator.__str__()#

Describe the entity.

Returns:

Description of the entity.

Return type:

str

make_producer_consumer_for_each_iterator.run()#

Evaluate this operator.

make_producer_consumer_for_each_iterator.eval(pin=None)#

Evaluate this operator.

Parameters:

pin (int) – Number of the output pin. The default is None.

Returns:

output – Returns the first output of the operator by default and the output of a given pin when specified. Or, it only evaluates the operator without output.

Return type:

FieldsContainer, Field, MeshedRegion, Scoping

Examples

Use the eval method.

>>> from ansys.dpf import core as dpf
>>> import ansys.dpf.core.operators.math as math
>>> from ansys.dpf.core import examples
>>> data_src = dpf.DataSources(examples.find_multishells_rst())
>>> disp_op = dpf.operators.result.displacement()
>>> disp_op.inputs.data_sources(data_src)
>>> normfc = math.norm_fc(disp_op).eval()
make_producer_consumer_for_each_iterator.__add__(fields_b)#

Add two fields or two fields containers.

Returns:

add

Return type:

operators.math.add_fc

make_producer_consumer_for_each_iterator.__sub__(fields_b)#

Subtract two fields or two fields containers.

Returns:

minus

Return type:

operators.math.minus_fc

make_producer_consumer_for_each_iterator.__pow__(value)#

Raise each element of a field or a fields container to power 2.

make_producer_consumer_for_each_iterator.__mul__(value)#

Multiply two fields or two fields containers.

Returns:

mul

Return type:

operators.math.generalized_inner_product_fc

static make_producer_consumer_for_each_iterator.operator_specification(op_name, server=None)#

Documents an Operator with its description (what the Operator does),its inputs and outputs and some properties.

make_producer_consumer_for_each_iterator.__truediv__(inpt)#

Perform division with another operator or a scalar.

This method allows the use of the division operator (/) between an Operator instance and either another Operator or a scalar value (float).