Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
else:
LIB_TO_GENERATE = [
"Ans.Dpf.Native.dll",
"Ans.Dpf.Mechanical.dll",
"Ans.Dpf.FEMutils.dll",
"meshOperatorsCore.dll",
"mapdlOperatorsCore.dll",
"Ans.Dpf.Math.dll",
"Ans.Dpf.PythonPluginWrapper.dll"
"Ans.Dpf.Hdf5.dll",
"Ans.Dpf.FlowDiagram.dll",
"Ans.Dpf.LSDYNAHGP.dll",
"Ans.Dpf.LivePost.dll",
"Ans.Dpf.PointCloudSearch.dll",
Expand All @@ -38,14 +41,18 @@
for f in files:
if Path(f).stem == "specification":
continue
if Path(f).name == "build.py":
continue
if Path(f).name == "operator.mustache":
continue
try:
if os.path.isdir(f):
shutil.rmtree(f)
else:
os.remove(f)
except:
pass
core.start_local_server()
core.start_local_server(config=core.AvailableServerConfigs.LegacyGrpcServer)
code_gen = core.Operator("python_generator")
code_gen.connect(1, TARGET_PATH)
for lib in LIB_TO_GENERATE:
Expand All @@ -55,6 +62,4 @@
else:
code_gen.connect(2, True)
code_gen.run()
time.sleep(0.1)

core.SERVER.shutdown()
time.sleep(0.1)
15 changes: 4 additions & 11 deletions ansys/dpf/core/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,13 @@
"""
.. _ref_operators_package:

Operators
---------
"""

from . import result
from . import math
from . import result
from . import utility
from . import min_max
from . import scoping
from . import metadata
from . import logic
from . import mesh
from . import filter
from . import logic
from . import metadata
from . import serialization
from . import mesh
from . import geo
from . import averaging
from . import invariant
Expand Down
1 change: 1 addition & 0 deletions ansys/dpf/core/operators/averaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from .elemental_fraction_fc import elemental_fraction_fc
from .to_nodal import to_nodal
from .to_nodal_fc import to_nodal_fc
from .nodal_extend_to_mid_nodes import nodal_extend_to_mid_nodes
from .elemental_nodal_to_nodal_elemental import elemental_nodal_to_nodal_elemental
from .extend_to_mid_nodes import extend_to_mid_nodes
from .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc
Expand Down
72 changes: 72 additions & 0 deletions ansys/dpf/core/operators/averaging/elemental_nodal_to_nodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class elemental_nodal_to_nodal(Operator):
Each nodal value is divided by the number of
elements linked to this node (default
is true for discrete quantities)
extend_to_mid_nodes : bool, optional
Compute mid nodes (when available) by
averaging neighbour primary nodes
mesh : MeshedRegion, optional


Expand All @@ -42,6 +45,8 @@ class elemental_nodal_to_nodal(Operator):
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_should_average = bool()
>>> op.inputs.should_average.connect(my_should_average)
>>> my_extend_to_mid_nodes = bool()
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
>>> my_mesh = dpf.MeshedRegion()
>>> op.inputs.mesh.connect(my_mesh)

Expand All @@ -50,18 +55,21 @@ class elemental_nodal_to_nodal(Operator):
... field=my_field,
... mesh_scoping=my_mesh_scoping,
... should_average=my_should_average,
... extend_to_mid_nodes=my_extend_to_mid_nodes,
... mesh=my_mesh,
... )

>>> # Get output data
>>> result_field = op.outputs.field()
>>> result_weight = op.outputs.weight()
"""

def __init__(
self,
field=None,
mesh_scoping=None,
should_average=None,
extend_to_mid_nodes=None,
mesh=None,
config=None,
server=None,
Expand All @@ -75,6 +83,8 @@ def __init__(
self.inputs.mesh_scoping.connect(mesh_scoping)
if should_average is not None:
self.inputs.should_average.connect(should_average)
if extend_to_mid_nodes is not None:
self.inputs.extend_to_mid_nodes.connect(extend_to_mid_nodes)
if mesh is not None:
self.inputs.mesh.connect(mesh)

Expand Down Expand Up @@ -105,6 +115,13 @@ def _spec():
document="""Each nodal value is divided by the number of
elements linked to this node (default
is true for discrete quantities)""",
),
4: PinSpecification(
name="extend_to_mid_nodes",
type_names=["bool"],
optional=True,
document="""Compute mid nodes (when available) by
averaging neighbour primary nodes""",
),
7: PinSpecification(
name="mesh",
Expand All @@ -120,6 +137,14 @@ def _spec():
optional=False,
document="""""",
),
1: PinSpecification(
name="weight",
type_names=["property_field"],
optional=False,
document="""Gives for each node, the number of times it
was found in the elemental nodal
field. can be used to average later.""",
),
},
)
return spec
Expand Down Expand Up @@ -175,6 +200,8 @@ class InputsElementalNodalToNodal(_Inputs):
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_should_average = bool()
>>> op.inputs.should_average.connect(my_should_average)
>>> my_extend_to_mid_nodes = bool()
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
>>> my_mesh = dpf.MeshedRegion()
>>> op.inputs.mesh.connect(my_mesh)
"""
Expand All @@ -191,6 +218,10 @@ def __init__(self, op: Operator):
elemental_nodal_to_nodal._spec().input_pin(2), 2, op, -1
)
self._inputs.append(self._should_average)
self._extend_to_mid_nodes = Input(
elemental_nodal_to_nodal._spec().input_pin(4), 4, op, -1
)
self._inputs.append(self._extend_to_mid_nodes)
self._mesh = Input(elemental_nodal_to_nodal._spec().input_pin(7), 7, op, -1)
self._inputs.append(self._mesh)

Expand Down Expand Up @@ -257,6 +288,27 @@ def should_average(self):
"""
return self._should_average

@property
def extend_to_mid_nodes(self):
"""Allows to connect extend_to_mid_nodes input to the operator.

Compute mid nodes (when available) by
averaging neighbour primary nodes

Parameters
----------
my_extend_to_mid_nodes : bool

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
>>> op.inputs.extend_to_mid_nodes.connect(my_extend_to_mid_nodes)
>>> # or
>>> op.inputs.extend_to_mid_nodes(my_extend_to_mid_nodes)
"""
return self._extend_to_mid_nodes

@property
def mesh(self):
"""Allows to connect mesh input to the operator.
Expand Down Expand Up @@ -286,12 +338,15 @@ class OutputsElementalNodalToNodal(_Outputs):
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
>>> # Connect inputs : op.inputs. ...
>>> result_field = op.outputs.field()
>>> result_weight = op.outputs.weight()
"""

def __init__(self, op: Operator):
super().__init__(elemental_nodal_to_nodal._spec().outputs, op)
self._field = Output(elemental_nodal_to_nodal._spec().output_pin(0), 0, op)
self._outputs.append(self._field)
self._weight = Output(elemental_nodal_to_nodal._spec().output_pin(1), 1, op)
self._outputs.append(self._weight)

@property
def field(self):
Expand All @@ -309,3 +364,20 @@ def field(self):
>>> result_field = op.outputs.field()
""" # noqa: E501
return self._field

@property
def weight(self):
"""Allows to get weight output of the operator

Returns
----------
my_weight : PropertyField

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.averaging.elemental_nodal_to_nodal()
>>> # Connect inputs : op.inputs. ...
>>> result_weight = op.outputs.weight()
""" # noqa: E501
return self._weight
Loading