-
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.
Co-authored-by: PProfizi <[email protected]>
- Loading branch information
1 parent
da757b4
commit 52c4ce8
Showing
44 changed files
with
1,161 additions
and
149 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
233 changes: 233 additions & 0 deletions
233
src/ansys/dpf/core/operators/math/component_wise_product.py
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,233 @@ | ||
""" | ||
component_wise_product | ||
====================== | ||
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 component_wise_product(Operator): | ||
"""Computes component-wise product between two fields of same | ||
dimensionality. If one field's scoping has an 'overall' location, | ||
then this field's values are applied on the other field entirely. | ||
When using a constant or 'work_by_index', you can use 'inplace' to | ||
reuse one of the fields. | ||
Parameters | ||
---------- | ||
fieldA : Field or FieldsContainer | ||
Field or fields container with only one field | ||
is expected | ||
fieldB : Field or FieldsContainer | ||
Field or fields container with only one field | ||
is expected | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> # Instantiate operator | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> # Make input connections | ||
>>> my_fieldA = dpf.Field() | ||
>>> op.inputs.fieldA.connect(my_fieldA) | ||
>>> my_fieldB = dpf.Field() | ||
>>> op.inputs.fieldB.connect(my_fieldB) | ||
>>> # Instantiate operator and connect inputs in one line | ||
>>> op = dpf.operators.math.component_wise_product( | ||
... fieldA=my_fieldA, | ||
... fieldB=my_fieldB, | ||
... ) | ||
>>> # Get output data | ||
>>> result_field = op.outputs.field() | ||
""" | ||
|
||
def __init__(self, fieldA=None, fieldB=None, config=None, server=None): | ||
super().__init__(name="component_wise_product", config=config, server=server) | ||
self._inputs = InputsComponentWiseProduct(self) | ||
self._outputs = OutputsComponentWiseProduct(self) | ||
if fieldA is not None: | ||
self.inputs.fieldA.connect(fieldA) | ||
if fieldB is not None: | ||
self.inputs.fieldB.connect(fieldB) | ||
|
||
@staticmethod | ||
def _spec(): | ||
description = """Computes component-wise product between two fields of same | ||
dimensionality. If one field's scoping has an 'overall' | ||
location, then this field's values are applied on the | ||
other field entirely. When using a constant or | ||
'work_by_index', you can use 'inplace' to reuse one of the | ||
fields.""" | ||
spec = Specification( | ||
description=description, | ||
map_input_pin_spec={ | ||
0: PinSpecification( | ||
name="fieldA", | ||
type_names=["field", "fields_container"], | ||
optional=False, | ||
document="""Field or fields container with only one field | ||
is expected""", | ||
), | ||
1: PinSpecification( | ||
name="fieldB", | ||
type_names=["field", "fields_container"], | ||
optional=False, | ||
document="""Field or fields container with only one field | ||
is expected""", | ||
), | ||
}, | ||
map_output_pin_spec={ | ||
0: PinSpecification( | ||
name="field", | ||
type_names=["field"], | ||
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="component_wise_product", server=server) | ||
|
||
@property | ||
def inputs(self): | ||
"""Enables to connect inputs to the operator | ||
Returns | ||
-------- | ||
inputs : InputsComponentWiseProduct | ||
""" | ||
return super().inputs | ||
|
||
@property | ||
def outputs(self): | ||
"""Enables to get outputs of the operator by evaluating it | ||
Returns | ||
-------- | ||
outputs : OutputsComponentWiseProduct | ||
""" | ||
return super().outputs | ||
|
||
|
||
class InputsComponentWiseProduct(_Inputs): | ||
"""Intermediate class used to connect user inputs to | ||
component_wise_product operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> my_fieldA = dpf.Field() | ||
>>> op.inputs.fieldA.connect(my_fieldA) | ||
>>> my_fieldB = dpf.Field() | ||
>>> op.inputs.fieldB.connect(my_fieldB) | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(component_wise_product._spec().inputs, op) | ||
self._fieldA = Input(component_wise_product._spec().input_pin(0), 0, op, -1) | ||
self._inputs.append(self._fieldA) | ||
self._fieldB = Input(component_wise_product._spec().input_pin(1), 1, op, -1) | ||
self._inputs.append(self._fieldB) | ||
|
||
@property | ||
def fieldA(self): | ||
"""Allows to connect fieldA input to the operator. | ||
Field or fields container with only one field | ||
is expected | ||
Parameters | ||
---------- | ||
my_fieldA : Field or FieldsContainer | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> op.inputs.fieldA.connect(my_fieldA) | ||
>>> # or | ||
>>> op.inputs.fieldA(my_fieldA) | ||
""" | ||
return self._fieldA | ||
|
||
@property | ||
def fieldB(self): | ||
"""Allows to connect fieldB input to the operator. | ||
Field or fields container with only one field | ||
is expected | ||
Parameters | ||
---------- | ||
my_fieldB : Field or FieldsContainer | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> op.inputs.fieldB.connect(my_fieldB) | ||
>>> # or | ||
>>> op.inputs.fieldB(my_fieldB) | ||
""" | ||
return self._fieldB | ||
|
||
|
||
class OutputsComponentWiseProduct(_Outputs): | ||
"""Intermediate class used to get outputs from | ||
component_wise_product operator. | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_field = op.outputs.field() | ||
""" | ||
|
||
def __init__(self, op: Operator): | ||
super().__init__(component_wise_product._spec().outputs, op) | ||
self._field = Output(component_wise_product._spec().output_pin(0), 0, op) | ||
self._outputs.append(self._field) | ||
|
||
@property | ||
def field(self): | ||
"""Allows to get field output of the operator | ||
Returns | ||
---------- | ||
my_field : Field | ||
Examples | ||
-------- | ||
>>> from ansys.dpf import core as dpf | ||
>>> op = dpf.operators.math.component_wise_product() | ||
>>> # Connect inputs : op.inputs. ... | ||
>>> result_field = op.outputs.field() | ||
""" # noqa: E501 | ||
return self._field |
Oops, something went wrong.