-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
184 additions
and
2 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,181 @@ | ||
""" | ||
operator_id | ||
=========== | ||
Autogenerated DPF operator classes. | ||
""" | ||
|
||
from warnings import warn | ||
from ansys.dpf.core.dpf_operator import Operator | ||
from ansys.dpf.core.inputs import Input, _Inputs | ||
from ansys.dpf.core.outputs import Output, _Outputs | ||
from ansys.dpf.core.operators.specification import PinSpecification, Specification | ||
|
||
|
||
class operator_id(Operator): | ||
"""Return the id of an Operator. | ||
Parameters | ||
---------- | ||
op : Operator | ||
Returns | ||
------- | ||
id : int | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> # Instantiate operator | ||
>>> op = dpf.operators.utility.operator_id() | ||
>>> # Make input connections | ||
>>> my_op = dpf.Operator() | ||
>>> op.inputs.op.connect(my_op) | ||
>>> # Instantiate operator and connect inputs in one line | ||
>>> op = dpf.operators.utility.operator_id( | ||
... op=my_op, | ||
... ) | ||
>>> # Get output data | ||
>>> result_id = op.outputs.id() | ||
""" | ||
|
||
def __init__(self, op=None, config=None, server=None): | ||
super().__init__(name="operator_id", config=config, server=server) | ||
self._inputs = InputsOperatorId(self) | ||
self._outputs = OutputsOperatorId(self) | ||
if op is not None: | ||
self.inputs.op.connect(op) | ||
|
||
@staticmethod | ||
def _spec(): | ||
description = """Return the id of an Operator.""" | ||
spec = Specification( | ||
description=description, | ||
map_input_pin_spec={ | ||
0: PinSpecification( | ||
name="op", | ||
type_names=["operator"], | ||
optional=False, | ||
document="""""", | ||
), | ||
}, | ||
map_output_pin_spec={ | ||
0: PinSpecification( | ||
name="id", | ||
type_names=["int32"], | ||
optional=False, | ||
document="""""", | ||
), | ||
}, | ||
) | ||
return spec | ||
|
||
@staticmethod | ||
def default_config(server=None): | ||
"""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.DPFServer, optional | ||
Server with channel connected to the remote or local instance. When | ||
``None``, attempts to use the global server. | ||
""" | ||
return Operator.default_config(name="operator_id", server=server) | ||
|
||
@property | ||
def inputs(self): | ||
"""Enables to connect inputs to the operator | ||
Returns | ||
-------- | ||
inputs : InputsOperatorId | ||
""" | ||
return super().inputs | ||
|
||
@property | ||
def outputs(self): | ||
"""Enables to get outputs of the operator by evaluating it | ||
Returns | ||
-------- | ||
outputs : OutputsOperatorId | ||
""" | ||
return super().outputs | ||
|
||
|
||
class InputsOperatorId(_Inputs): | ||
"""Intermediate class used to connect user inputs to | ||
operator_id operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.utility.operator_id() | ||
>>> my_op = dpf.Operator() | ||
>>> op.inputs.op.connect(my_op) | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(operator_id._spec().inputs, op) | ||
self._op = Input(operator_id._spec().input_pin(0), 0, op, -1) | ||
self._inputs.append(self._op) | ||
|
||
@property | ||
def op(self): | ||
"""Allows to connect op input to the operator. | ||
Parameters | ||
---------- | ||
my_op : Operator | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.utility.operator_id() | ||
>>> op.inputs.op.connect(my_op) | ||
>>> # or | ||
>>> op.inputs.op(my_op) | ||
""" | ||
return self._op | ||
|
||
|
||
class OutputsOperatorId(_Outputs): | ||
"""Intermediate class used to get outputs from | ||
operator_id operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.utility.operator_id() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_id = op.outputs.id() | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(operator_id._spec().outputs, op) | ||
self._id = Output(operator_id._spec().output_pin(0), 0, op) | ||
self._outputs.append(self._id) | ||
|
||
@property | ||
def id(self): | ||
"""Allows to get id output of the operator | ||
Returns | ||
---------- | ||
my_id : int | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.utility.operator_id() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_id = op.outputs.id() | ||
""" # noqa: E501 | ||
return self._id |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.