Skip to content

Commit ab3b437

Browse files
committed
1 parent ad91fa2 commit ab3b437

32 files changed

+3197
-1407
lines changed

ansys/dpf/core/operators/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
from . import utility
44
from . import min_max
55
from . import scoping
6-
from . import metadata
76
from . import logic
7+
from . import metadata
8+
from . import serialization
89
from . import mesh
910
from . import filter
10-
from . import serialization
1111
from . import geo
1212
from . import averaging
1313
from . import invariant

ansys/dpf/core/operators/averaging/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
from .elemental_fraction_fc import elemental_fraction_fc
1414
from .to_nodal import to_nodal
1515
from .to_nodal_fc import to_nodal_fc
16+
from .nodal_extend_to_mid_nodes import nodal_extend_to_mid_nodes
1617
from .elemental_nodal_to_nodal_elemental import elemental_nodal_to_nodal_elemental
1718
from .extend_to_mid_nodes import extend_to_mid_nodes
1819
from .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc

ansys/dpf/core/operators/averaging/elemental_nodal_to_nodal.py

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ class elemental_nodal_to_nodal(Operator):
2525
Each nodal value is divided by the number of
2626
elements linked to this node (default
2727
is true for discrete quantities)
28+
extend_to_mid_nodes : bool, optional
29+
Compute mid nodes (when available) by
30+
averaging neighbour primary nodes
2831
mesh : MeshedRegion, optional
2932
3033
@@ -42,6 +45,8 @@ class elemental_nodal_to_nodal(Operator):
4245
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
4346
>>> my_should_average = bool()
4447
>>> op.inputs.should_average.connect(my_should_average)
48+
>>> my_extend_to_mid_nodes = bool()
49+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
4550
>>> my_mesh = dpf.MeshedRegion()
4651
>>> op.inputs.mesh.connect(my_mesh)
4752
@@ -50,18 +55,21 @@ class elemental_nodal_to_nodal(Operator):
5055
... field=my_field,
5156
... mesh_scoping=my_mesh_scoping,
5257
... should_average=my_should_average,
58+
... extend_to_mid_nodes=my_extend_to_mid_nodes,
5359
... mesh=my_mesh,
5460
... )
5561
5662
>>> # Get output data
5763
>>> result_field = op.outputs.field()
64+
>>> result_weight = op.outputs.weight()
5865
"""
5966

6067
def __init__(
6168
self,
6269
field=None,
6370
mesh_scoping=None,
6471
should_average=None,
72+
extend_to_mid_nodes=None,
6573
mesh=None,
6674
config=None,
6775
server=None,
@@ -75,6 +83,8 @@ def __init__(
7583
self.inputs.mesh_scoping.connect(mesh_scoping)
7684
if should_average is not None:
7785
self.inputs.should_average.connect(should_average)
86+
if extend_to_mid_nodes is not None:
87+
self.inputs.extend_to_mid_nodes.connect(extend_to_mid_nodes)
7888
if mesh is not None:
7989
self.inputs.mesh.connect(mesh)
8090

@@ -105,6 +115,13 @@ def _spec():
105115
document="""Each nodal value is divided by the number of
106116
elements linked to this node (default
107117
is true for discrete quantities)""",
118+
),
119+
4: PinSpecification(
120+
name="extend_to_mid_nodes",
121+
type_names=["bool"],
122+
optional=True,
123+
document="""Compute mid nodes (when available) by
124+
averaging neighbour primary nodes""",
108125
),
109126
7: PinSpecification(
110127
name="mesh",
@@ -120,6 +137,14 @@ def _spec():
120137
optional=False,
121138
document="""""",
122139
),
140+
1: PinSpecification(
141+
name="weight",
142+
type_names=["property_field"],
143+
optional=False,
144+
document="""Gives for each node, the number of times it
145+
was found in the elemental nodal
146+
field. can be used to average later.""",
147+
),
123148
},
124149
)
125150
return spec
@@ -175,6 +200,8 @@ class InputsElementalNodalToNodal(_Inputs):
175200
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
176201
>>> my_should_average = bool()
177202
>>> op.inputs.should_average.connect(my_should_average)
203+
>>> my_extend_to_mid_nodes = bool()
204+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
178205
>>> my_mesh = dpf.MeshedRegion()
179206
>>> op.inputs.mesh.connect(my_mesh)
180207
"""
@@ -191,6 +218,10 @@ def __init__(self, op: Operator):
191218
elemental_nodal_to_nodal._spec().input_pin(2), 2, op, -1
192219
)
193220
self._inputs.append(self._should_average)
221+
self._extend_to_mid_nodes = Input(
222+
elemental_nodal_to_nodal._spec().input_pin(4), 4, op, -1
223+
)
224+
self._inputs.append(self._extend_to_mid_nodes)
194225
self._mesh = Input(elemental_nodal_to_nodal._spec().input_pin(7), 7, op, -1)
195226
self._inputs.append(self._mesh)
196227

@@ -257,6 +288,27 @@ def should_average(self):
257288
"""
258289
return self._should_average
259290

291+
@property
292+
def extend_to_mid_nodes(self):
293+
"""Allows to connect extend_to_mid_nodes input to the operator.
294+
295+
Compute mid nodes (when available) by
296+
averaging neighbour primary nodes
297+
298+
Parameters
299+
----------
300+
my_extend_to_mid_nodes : bool
301+
302+
Examples
303+
--------
304+
>>> from ansys.dpf import core as dpf
305+
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
306+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
307+
>>> # or
308+
>>> op.inputs.extend_to_mid_nodes(my_extend_to_mid_nodes)
309+
"""
310+
return self._extend_to_mid_nodes
311+
260312
@property
261313
def mesh(self):
262314
"""Allows to connect mesh input to the operator.
@@ -286,12 +338,15 @@ class OutputsElementalNodalToNodal(_Outputs):
286338
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
287339
>>> # Connect inputs : op.inputs. ...
288340
>>> result_field = op.outputs.field()
341+
>>> result_weight = op.outputs.weight()
289342
"""
290343

291344
def __init__(self, op: Operator):
292345
super().__init__(elemental_nodal_to_nodal._spec().outputs, op)
293346
self._field = Output(elemental_nodal_to_nodal._spec().output_pin(0), 0, op)
294347
self._outputs.append(self._field)
348+
self._weight = Output(elemental_nodal_to_nodal._spec().output_pin(1), 1, op)
349+
self._outputs.append(self._weight)
295350

296351
@property
297352
def field(self):
@@ -309,3 +364,20 @@ def field(self):
309364
>>> result_field = op.outputs.field()
310365
""" # noqa: E501
311366
return self._field
367+
368+
@property
369+
def weight(self):
370+
"""Allows to get weight output of the operator
371+
372+
Returns
373+
----------
374+
my_weight : PropertyField
375+
376+
Examples
377+
--------
378+
>>> from ansys.dpf import core as dpf
379+
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
380+
>>> # Connect inputs : op.inputs. ...
381+
>>> result_weight = op.outputs.weight()
382+
""" # noqa: E501
383+
return self._weight

ansys/dpf/core/operators/averaging/elemental_nodal_to_nodal_fc.py

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ class elemental_nodal_to_nodal_fc(Operator):
3131
Average only on these nodes, if it is scoping
3232
container, the label must correspond
3333
to the one of the fields container
34+
extend_to_mid_nodes : bool, optional
35+
Compute mid nodes (when available) by
36+
averaging neighbour primary nodes
3437
3538
3639
Examples
@@ -49,17 +52,21 @@ class elemental_nodal_to_nodal_fc(Operator):
4952
>>> op.inputs.should_average.connect(my_should_average)
5053
>>> my_scoping = dpf.Scoping()
5154
>>> op.inputs.scoping.connect(my_scoping)
55+
>>> my_extend_to_mid_nodes = bool()
56+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
5257
5358
>>> # Instantiate operator and connect inputs in one line
5459
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal_fc(
5560
... fields_container=my_fields_container,
5661
... mesh=my_mesh,
5762
... should_average=my_should_average,
5863
... scoping=my_scoping,
64+
... extend_to_mid_nodes=my_extend_to_mid_nodes,
5965
... )
6066
6167
>>> # Get output data
6268
>>> result_fields_container = op.outputs.fields_container()
69+
>>> result_weights = op.outputs.weights()
6370
"""
6471

6572
def __init__(
@@ -68,6 +75,7 @@ def __init__(
6875
mesh=None,
6976
should_average=None,
7077
scoping=None,
78+
extend_to_mid_nodes=None,
7179
config=None,
7280
server=None,
7381
):
@@ -84,6 +92,8 @@ def __init__(
8492
self.inputs.should_average.connect(should_average)
8593
if scoping is not None:
8694
self.inputs.scoping.connect(scoping)
95+
if extend_to_mid_nodes is not None:
96+
self.inputs.extend_to_mid_nodes.connect(extend_to_mid_nodes)
8797

8898
@staticmethod
8999
def _spec():
@@ -125,6 +135,13 @@ def _spec():
125135
container, the label must correspond
126136
to the one of the fields container""",
127137
),
138+
4: PinSpecification(
139+
name="extend_to_mid_nodes",
140+
type_names=["bool"],
141+
optional=True,
142+
document="""Compute mid nodes (when available) by
143+
averaging neighbour primary nodes""",
144+
),
128145
},
129146
map_output_pin_spec={
130147
0: PinSpecification(
@@ -133,6 +150,16 @@ def _spec():
133150
optional=False,
134151
document="""""",
135152
),
153+
1: PinSpecification(
154+
name="weights",
155+
type_names=[
156+
"class dataProcessing::DpfTypeCollection<class dataProcessing::CPropertyField>"
157+
],
158+
optional=False,
159+
document="""Gives for each node, the number of times it
160+
was found in the elemental nodal
161+
field. can be used to average later.""",
162+
),
136163
},
137164
)
138165
return spec
@@ -192,6 +219,8 @@ class InputsElementalNodalToNodalFc(_Inputs):
192219
>>> op.inputs.should_average.connect(my_should_average)
193220
>>> my_scoping = dpf.Scoping()
194221
>>> op.inputs.scoping.connect(my_scoping)
222+
>>> my_extend_to_mid_nodes = bool()
223+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
195224
"""
196225

197226
def __init__(self, op: Operator):
@@ -210,6 +239,10 @@ def __init__(self, op: Operator):
210239
elemental_nodal_to_nodal_fc._spec().input_pin(3), 3, op, -1
211240
)
212241
self._inputs.append(self._scoping)
242+
self._extend_to_mid_nodes = Input(
243+
elemental_nodal_to_nodal_fc._spec().input_pin(4), 4, op, -1
244+
)
245+
self._inputs.append(self._extend_to_mid_nodes)
213246

214247
@property
215248
def fields_container(self):
@@ -295,6 +328,27 @@ def scoping(self):
295328
"""
296329
return self._scoping
297330

331+
@property
332+
def extend_to_mid_nodes(self):
333+
"""Allows to connect extend_to_mid_nodes input to the operator.
334+
335+
Compute mid nodes (when available) by
336+
averaging neighbour primary nodes
337+
338+
Parameters
339+
----------
340+
my_extend_to_mid_nodes : bool
341+
342+
Examples
343+
--------
344+
>>> from ansys.dpf import core as dpf
345+
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal_fc()
346+
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
347+
>>> # or
348+
>>> op.inputs.extend_to_mid_nodes(my_extend_to_mid_nodes)
349+
"""
350+
return self._extend_to_mid_nodes
351+
298352

299353
class OutputsElementalNodalToNodalFc(_Outputs):
300354
"""Intermediate class used to get outputs from
@@ -306,6 +360,7 @@ class OutputsElementalNodalToNodalFc(_Outputs):
306360
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal_fc()
307361
>>> # Connect inputs : op.inputs. ...
308362
>>> result_fields_container = op.outputs.fields_container()
363+
>>> result_weights = op.outputs.weights()
309364
"""
310365

311366
def __init__(self, op: Operator):
@@ -314,6 +369,8 @@ def __init__(self, op: Operator):
314369
elemental_nodal_to_nodal_fc._spec().output_pin(0), 0, op
315370
)
316371
self._outputs.append(self._fields_container)
372+
self._weights = Output(elemental_nodal_to_nodal_fc._spec().output_pin(1), 1, op)
373+
self._outputs.append(self._weights)
317374

318375
@property
319376
def fields_container(self):
@@ -331,3 +388,21 @@ def fields_container(self):
331388
>>> result_fields_container = op.outputs.fields_container()
332389
""" # noqa: E501
333390
return self._fields_container
391+
392+
@property
393+
def weights(self):
394+
"""Allows to get weights output of the operator
395+
396+
Returns
397+
----------
398+
my_weights : Class Dataprocessing::Dpftypecollection&lt;Class
399+
Dataprocessing::Cpropertyfield&gt;
400+
401+
Examples
402+
--------
403+
>>> from ansys.dpf import core as dpf
404+
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal_fc()
405+
>>> # Connect inputs : op.inputs. ...
406+
>>> result_weights = op.outputs.weights()
407+
""" # noqa: E501
408+
return self._weights

ansys/dpf/core/operators/averaging/extend_to_mid_nodes.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111

1212

1313
class extend_to_mid_nodes(Operator):
14-
"""Extends ElementalNodal field defined on corner nodes to a
15-
ElementalNodal field defined also on the mid nodes.
14+
"""Extends an ElementalNodal or Nodal field defined on corner nodes to a
15+
field defined also on the mid nodes.
1616
1717
Parameters
1818
----------
@@ -56,8 +56,8 @@ def __init__(self, field=None, mesh=None, config=None, server=None):
5656

5757
@staticmethod
5858
def _spec():
59-
description = """Extends ElementalNodal field defined on corner nodes to a
60-
ElementalNodal field defined also on the mid nodes."""
59+
description = """Extends an ElementalNodal or Nodal field defined on corner nodes to a
60+
field defined also on the mid nodes."""
6161
spec = Specification(
6262
description=description,
6363
map_input_pin_spec={

ansys/dpf/core/operators/averaging/extend_to_mid_nodes_fc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
class extend_to_mid_nodes_fc(Operator):
14-
"""Extends ElementalNodal fields defined on corner nodes to
14+
"""Extends ElementalNodal or Nodal fields defined on corner nodes to
1515
ElementalNodal fields defined also on the mid nodes.
1616
1717
Parameters
@@ -57,7 +57,7 @@ def __init__(self, fields_container=None, mesh=None, config=None, server=None):
5757

5858
@staticmethod
5959
def _spec():
60-
description = """Extends ElementalNodal fields defined on corner nodes to
60+
description = """Extends ElementalNodal or Nodal fields defined on corner nodes to
6161
ElementalNodal fields defined also on the mid nodes."""
6262
spec = Specification(
6363
description=description,

0 commit comments

Comments
 (0)