Skip to content

Commit 354f953

Browse files
authored
Operators generation (#443)
1 parent 819771d commit 354f953

File tree

135 files changed

+7804
-5219
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+7804
-5219
lines changed

.ci/code_generation.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,14 @@
2121
else:
2222
LIB_TO_GENERATE = [
2323
"Ans.Dpf.Native.dll",
24+
"Ans.Dpf.Mechanical.dll",
2425
"Ans.Dpf.FEMutils.dll",
2526
"meshOperatorsCore.dll",
2627
"mapdlOperatorsCore.dll",
2728
"Ans.Dpf.Math.dll",
29+
"Ans.Dpf.PythonPluginWrapper.dll"
2830
"Ans.Dpf.Hdf5.dll",
31+
"Ans.Dpf.FlowDiagram.dll",
2932
"Ans.Dpf.LSDYNAHGP.dll",
3033
"Ans.Dpf.LivePost.dll",
3134
"Ans.Dpf.PointCloudSearch.dll",
@@ -38,14 +41,18 @@
3841
for f in files:
3942
if Path(f).stem == "specification":
4043
continue
44+
if Path(f).name == "build.py":
45+
continue
46+
if Path(f).name == "operator.mustache":
47+
continue
4148
try:
4249
if os.path.isdir(f):
4350
shutil.rmtree(f)
4451
else:
4552
os.remove(f)
4653
except:
4754
pass
48-
core.start_local_server()
55+
core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer)
4956
code_gen = core.Operator("python_generator")
5057
code_gen.connect(1, TARGET_PATH)
5158
for lib in LIB_TO_GENERATE:
@@ -55,6 +62,4 @@
5562
else:
5663
code_gen.connect(2, True)
5764
code_gen.run()
58-
time.sleep(0.1)
59-
60-
core.SERVER.shutdown()
65+
time.sleep(0.1)

ansys/dpf/core/operators/__init__.py

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
1-
"""
2-
.. _ref_operators_package:
3-
4-
Operators
5-
---------
6-
"""
7-
8-
from . import result
91
from . import math
2+
from . import result
103
from . import utility
114
from . import min_max
125
from . import scoping
13-
from . import metadata
14-
from . import logic
15-
from . import mesh
166
from . import filter
7+
from . import logic
8+
from . import metadata
179
from . import serialization
10+
from . import mesh
1811
from . import geo
1912
from . import averaging
2013
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

0 commit comments

Comments
 (0)