Skip to content

Commit 2b44761

Browse files
update operators (#1024)
Co-authored-by: rlagha <[email protected]>
1 parent 6991cbb commit 2b44761

File tree

10 files changed

+377
-81
lines changed

10 files changed

+377
-81
lines changed

docs/source/_static/dpf_operators.html

Lines changed: 13 additions & 13 deletions
Large diffs are not rendered by default.

src/ansys/dpf/core/operators/geo/elements_volume.py

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class elements_volume(Operator):
1717
Parameters
1818
----------
1919
mesh : MeshedRegion
20+
mesh_scoping : Scoping
2021
2122
2223
Examples
@@ -29,22 +30,27 @@ class elements_volume(Operator):
2930
>>> # Make input connections
3031
>>> my_mesh = dpf.MeshedRegion()
3132
>>> op.inputs.mesh.connect(my_mesh)
33+
>>> my_mesh_scoping = dpf.Scoping()
34+
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
3235
3336
>>> # Instantiate operator and connect inputs in one line
3437
>>> op = dpf.operators.geo.elements_volume(
3538
... mesh=my_mesh,
39+
... mesh_scoping=my_mesh_scoping,
3640
... )
3741
3842
>>> # Get output data
3943
>>> result_field = op.outputs.field()
4044
"""
4145

42-
def __init__(self, mesh=None, config=None, server=None):
46+
def __init__(self, mesh=None, mesh_scoping=None, config=None, server=None):
4347
super().__init__(name="element::volume", config=config, server=server)
4448
self._inputs = InputsElementsVolume(self)
4549
self._outputs = OutputsElementsVolume(self)
4650
if mesh is not None:
4751
self.inputs.mesh.connect(mesh)
52+
if mesh_scoping is not None:
53+
self.inputs.mesh_scoping.connect(mesh_scoping)
4854

4955
@staticmethod
5056
def _spec():
@@ -59,6 +65,12 @@ def _spec():
5965
optional=False,
6066
document="""""",
6167
),
68+
1: PinSpecification(
69+
name="mesh_scoping",
70+
type_names=["scoping"],
71+
optional=False,
72+
document="""""",
73+
),
6274
},
6375
map_output_pin_spec={
6476
0: PinSpecification(
@@ -118,12 +130,16 @@ class InputsElementsVolume(_Inputs):
118130
>>> op = dpf.operators.geo.elements_volume()
119131
>>> my_mesh = dpf.MeshedRegion()
120132
>>> op.inputs.mesh.connect(my_mesh)
133+
>>> my_mesh_scoping = dpf.Scoping()
134+
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
121135
"""
122136

123137
def __init__(self, op: Operator):
124138
super().__init__(elements_volume._spec().inputs, op)
125139
self._mesh = Input(elements_volume._spec().input_pin(0), 0, op, -1)
126140
self._inputs.append(self._mesh)
141+
self._mesh_scoping = Input(elements_volume._spec().input_pin(1), 1, op, -1)
142+
self._inputs.append(self._mesh_scoping)
127143

128144
@property
129145
def mesh(self):
@@ -143,6 +159,24 @@ def mesh(self):
143159
"""
144160
return self._mesh
145161

162+
@property
163+
def mesh_scoping(self):
164+
"""Allows to connect mesh_scoping input to the operator.
165+
166+
Parameters
167+
----------
168+
my_mesh_scoping : Scoping
169+
170+
Examples
171+
--------
172+
>>> from ansys.dpf import core as dpf
173+
>>> op = dpf.operators.geo.elements_volume()
174+
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
175+
>>> # or
176+
>>> op.inputs.mesh_scoping(my_mesh_scoping)
177+
"""
178+
return self._mesh_scoping
179+
146180

147181
class OutputsElementsVolume(_Outputs):
148182
"""Intermediate class used to get outputs from

src/ansys/dpf/core/operators/mesh/from_scoping.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,12 @@ class from_scoping(Operator):
2020
transposed respecting the inclusive
2121
pin
2222
inclusive : int, optional
23-
If inclusive == 1 then all the elements
23+
If inclusive == 1 then all the elements/faces
2424
adjacent to the nodes ids in input
2525
are added, if inclusive == 0, only
26-
the elements which have all their
27-
nodes in the scoping are included
26+
the elements/faces which have all
27+
their nodes in the scoping are
28+
included
2829
nodes_only : bool, optional
2930
Returns mesh with nodes only (without any
3031
elements). default is false.
@@ -101,11 +102,12 @@ def _spec():
101102
name="inclusive",
102103
type_names=["int32"],
103104
optional=True,
104-
document="""If inclusive == 1 then all the elements
105+
document="""If inclusive == 1 then all the elements/faces
105106
adjacent to the nodes ids in input
106107
are added, if inclusive == 0, only
107-
the elements which have all their
108-
nodes in the scoping are included""",
108+
the elements/faces which have all
109+
their nodes in the scoping are
110+
included""",
109111
),
110112
3: PinSpecification(
111113
name="nodes_only",
@@ -224,11 +226,12 @@ def scoping(self):
224226
def inclusive(self):
225227
"""Allows to connect inclusive input to the operator.
226228
227-
If inclusive == 1 then all the elements
229+
If inclusive == 1 then all the elements/faces
228230
adjacent to the nodes ids in input
229231
are added, if inclusive == 0, only
230-
the elements which have all their
231-
nodes in the scoping are included
232+
the elements/faces which have all
233+
their nodes in the scoping are
234+
included
232235
233236
Parameters
234237
----------

src/ansys/dpf/core/operators/mesh/from_scopings.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ class from_scopings(Operator):
2121
transposed respecting the inclusive
2222
pin
2323
inclusive : int, optional
24-
If inclusive == 1 then all the elements
24+
If inclusive == 1 then all the elements/faces
2525
adjacent to the nodes ids in input
2626
are added, if inclusive == 0, only
27-
the elements which have all their
28-
nodes in the scoping are included
27+
the elements/faces which have all
28+
their nodes in the scoping are
29+
included
2930
nodes_only : bool, optional
3031
Returns mesh with nodes only (without any
3132
elements). default is false.
@@ -101,11 +102,12 @@ def _spec():
101102
name="inclusive",
102103
type_names=["int32"],
103104
optional=True,
104-
document="""If inclusive == 1 then all the elements
105+
document="""If inclusive == 1 then all the elements/faces
105106
adjacent to the nodes ids in input
106107
are added, if inclusive == 0, only
107-
the elements which have all their
108-
nodes in the scoping are included""",
108+
the elements/faces which have all
109+
their nodes in the scoping are
110+
included""",
109111
),
110112
3: PinSpecification(
111113
name="nodes_only",
@@ -224,11 +226,12 @@ def scopings_container(self):
224226
def inclusive(self):
225227
"""Allows to connect inclusive input to the operator.
226228
227-
If inclusive == 1 then all the elements
229+
If inclusive == 1 then all the elements/faces
228230
adjacent to the nodes ids in input
229231
are added, if inclusive == 0, only
230-
the elements which have all their
231-
nodes in the scoping are included
232+
the elements/faces which have all
233+
their nodes in the scoping are
234+
included
232235
233236
Parameters
234237
----------

src/ansys/dpf/core/operators/metadata/mesh_info_provider.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class mesh_info_provider(Operator):
5050
... )
5151
5252
>>> # Get output data
53-
>>> result_generic_data_container = op.outputs.generic_data_container()
53+
>>> result_mesh_info = op.outputs.mesh_info()
5454
"""
5555

5656
def __init__(
@@ -102,7 +102,7 @@ def _spec():
102102
},
103103
map_output_pin_spec={
104104
0: PinSpecification(
105-
name="generic_data_container",
105+
name="mesh_info",
106106
type_names=["generic_data_container"],
107107
optional=False,
108108
document="""""",
@@ -246,29 +246,27 @@ class OutputsMeshInfoProvider(_Outputs):
246246
>>> from ansys.dpf import core as dpf
247247
>>> op = dpf.operators.metadata.mesh_info_provider()
248248
>>> # Connect inputs : op.inputs. ...
249-
>>> result_generic_data_container = op.outputs.generic_data_container()
249+
>>> result_mesh_info = op.outputs.mesh_info()
250250
"""
251251

252252
def __init__(self, op: Operator):
253253
super().__init__(mesh_info_provider._spec().outputs, op)
254-
self._generic_data_container = Output(
255-
mesh_info_provider._spec().output_pin(0), 0, op
256-
)
257-
self._outputs.append(self._generic_data_container)
254+
self._mesh_info = Output(mesh_info_provider._spec().output_pin(0), 0, op)
255+
self._outputs.append(self._mesh_info)
258256

259257
@property
260-
def generic_data_container(self):
261-
"""Allows to get generic_data_container output of the operator
258+
def mesh_info(self):
259+
"""Allows to get mesh_info output of the operator
262260
263261
Returns
264262
----------
265-
my_generic_data_container : GenericDataContainer
263+
my_mesh_info : GenericDataContainer
266264
267265
Examples
268266
--------
269267
>>> from ansys.dpf import core as dpf
270268
>>> op = dpf.operators.metadata.mesh_info_provider()
271269
>>> # Connect inputs : op.inputs. ...
272-
>>> result_generic_data_container = op.outputs.generic_data_container()
270+
>>> result_mesh_info = op.outputs.mesh_info()
273271
""" # noqa: E501
274-
return self._generic_data_container
272+
return self._mesh_info

src/ansys/dpf/core/operators/scoping/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from .change_fc import change_fc
2+
from .compute_element_centroids import compute_element_centroids
23
from .connectivity_ids import connectivity_ids
34
from .elemental_from_mesh import elemental_from_mesh
45
from .from_mesh import from_mesh

0 commit comments

Comments
 (0)