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: 11 additions & 2 deletions docs/source/_static/dpf_operators.html

Large diffs are not rendered by default.

73 changes: 69 additions & 4 deletions src/ansys/dpf/core/operators/averaging/elemental_to_nodal.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@


class elemental_to_nodal(Operator):
"""Transforms an Elemental Nodal field to a Nodal field. The result is
computed on a given node's scoping.
"""Transforms an Elemental field to a Nodal field. The result is computed
on a given node's scoping. 1. For a finite element mesh, the
value on a node is the average of the values of the neighbour
elements. 2. For a volume finite volume mesh, the agorithm is :
- For each node, compute interpolation weights for the cells
connected to it based on the Frink's Laplacian method. -
If the determinant of the I matrix is zero, switch to an inverse
distance weighted average. - If not, compute the Frink
weights and apply the Holmes' weight clip. - If the
clipping produces a large overshoot, inverse volume weighted
average is used.. 3. For a face finite volume mesh inverse
distance weighted average is used.

Parameters
----------
Expand All @@ -24,6 +34,10 @@ class elemental_to_nodal(Operator):
Averaging on nodes is used if this pin is set
to 1 (default is 1 for integrated
results and 0 for discrete ones).
algorithm : int, optional
Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).


Examples
Expand All @@ -40,12 +54,15 @@ class elemental_to_nodal(Operator):
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_force_averaging = int()
>>> op.inputs.force_averaging.connect(my_force_averaging)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.averaging.elemental_to_nodal(
... field=my_field,
... mesh_scoping=my_mesh_scoping,
... force_averaging=my_force_averaging,
... algorithm=my_algorithm,
... )

>>> # Get output data
Expand All @@ -57,6 +74,7 @@ def __init__(
field=None,
mesh_scoping=None,
force_averaging=None,
algorithm=None,
config=None,
server=None,
):
Expand All @@ -69,11 +87,24 @@ def __init__(
self.inputs.mesh_scoping.connect(mesh_scoping)
if force_averaging is not None:
self.inputs.force_averaging.connect(force_averaging)
if algorithm is not None:
self.inputs.algorithm.connect(algorithm)

@staticmethod
def _spec():
description = """Transforms an Elemental Nodal field to a Nodal field. The result is
computed on a given node's scoping."""
description = """Transforms an Elemental field to a Nodal field. The result is computed
on a given node's scoping. 1. For a finite element mesh,
the value on a node is the average of the values of the
neighbour elements. 2. For a volume finite volume mesh,
the agorithm is : - For each node, compute
interpolation weights for the cells connected to it based
on the Frink's Laplacian method. - If the
determinant of the I matrix is zero, switch to an inverse
distance weighted average. - If not, compute the
Frink weights and apply the Holmes' weight clip. -
If the clipping produces a large overshoot, inverse volume
weighted average is used.. 3. For a face finite volume
mesh inverse distance weighted average is used."""
spec = Specification(
description=description,
map_input_pin_spec={
Expand All @@ -98,6 +129,14 @@ def _spec():
to 1 (default is 1 for integrated
results and 0 for discrete ones).""",
),
200: PinSpecification(
name="algorithm",
type_names=["int32"],
optional=True,
document="""Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -161,6 +200,8 @@ class InputsElementalToNodal(_Inputs):
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_force_averaging = int()
>>> op.inputs.force_averaging.connect(my_force_averaging)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)
"""

def __init__(self, op: Operator):
Expand All @@ -173,6 +214,8 @@ def __init__(self, op: Operator):
elemental_to_nodal._spec().input_pin(2), 2, op, -1
)
self._inputs.append(self._force_averaging)
self._algorithm = Input(elemental_to_nodal._spec().input_pin(200), 200, op, -1)
self._inputs.append(self._algorithm)

@property
def field(self):
Expand Down Expand Up @@ -235,6 +278,28 @@ def force_averaging(self):
"""
return self._force_averaging

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

Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).

Parameters
----------
my_algorithm : int

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.averaging.elemental_to_nodal()
>>> op.inputs.algorithm.connect(my_algorithm)
>>> # or
>>> op.inputs.algorithm(my_algorithm)
"""
return self._algorithm


class OutputsElementalToNodal(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
71 changes: 69 additions & 2 deletions src/ansys/dpf/core/operators/averaging/elemental_to_nodal_fc.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,17 @@

class elemental_to_nodal_fc(Operator):
"""Transforms Elemental Nodal fields to Nodal fields. The result is
computed on a given node's scoping.
computed on a given node's scoping.1. For a finite element mesh,
the value on a node is the average of the values of the neighbour
elements. 2. For a finite volume mesh, the agorithm is : - For
each node, compute interpolation weights for the cells connected
to it based on the Frink's Laplacian method. - If the
determinant of the I matrix is zero, switch to an inverse distance
weighted average. - If not, compute the Frink weights and
apply the Holmes' weight clip. - If the clipping produces
a large overshoot, inverse volume weighted average is used.. 3.
For a face finite volume mesh inverse distance weighted average is
used.

Parameters
----------
Expand All @@ -23,6 +33,10 @@ class elemental_to_nodal_fc(Operator):
to 1 (default is 1 for integrated
results and 0 for discrete ones).
mesh_scoping : Scoping or ScopingsContainer, optional
algorithm : int, optional
Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).


Examples
Expand All @@ -41,13 +55,16 @@ class elemental_to_nodal_fc(Operator):
>>> op.inputs.force_averaging.connect(my_force_averaging)
>>> my_mesh_scoping = dpf.Scoping()
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)

>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.averaging.elemental_to_nodal_fc(
... fields_container=my_fields_container,
... mesh=my_mesh,
... force_averaging=my_force_averaging,
... mesh_scoping=my_mesh_scoping,
... algorithm=my_algorithm,
... )

>>> # Get output data
Expand All @@ -60,6 +77,7 @@ def __init__(
mesh=None,
force_averaging=None,
mesh_scoping=None,
algorithm=None,
config=None,
server=None,
):
Expand All @@ -74,11 +92,24 @@ def __init__(
self.inputs.force_averaging.connect(force_averaging)
if mesh_scoping is not None:
self.inputs.mesh_scoping.connect(mesh_scoping)
if algorithm is not None:
self.inputs.algorithm.connect(algorithm)

@staticmethod
def _spec():
description = """Transforms Elemental Nodal fields to Nodal fields. The result is
computed on a given node's scoping."""
computed on a given node's scoping.1. For a finite element
mesh, the value on a node is the average of the values of
the neighbour elements. 2. For a finite volume mesh, the
agorithm is : - For each node, compute interpolation
weights for the cells connected to it based on the
Frink's Laplacian method. - If the determinant of
the I matrix is zero, switch to an inverse distance
weighted average. - If not, compute the Frink
weights and apply the Holmes' weight clip. - If
the clipping produces a large overshoot, inverse volume
weighted average is used.. 3. For a face finite volume
mesh inverse distance weighted average is used."""
spec = Specification(
description=description,
map_input_pin_spec={
Expand Down Expand Up @@ -108,6 +139,14 @@ def _spec():
optional=True,
document="""""",
),
200: PinSpecification(
name="algorithm",
type_names=["int32"],
optional=True,
document="""Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -173,6 +212,8 @@ class InputsElementalToNodalFc(_Inputs):
>>> op.inputs.force_averaging.connect(my_force_averaging)
>>> my_mesh_scoping = dpf.Scoping()
>>> op.inputs.mesh_scoping.connect(my_mesh_scoping)
>>> my_algorithm = int()
>>> op.inputs.algorithm.connect(my_algorithm)
"""

def __init__(self, op: Operator):
Expand All @@ -191,6 +232,10 @@ def __init__(self, op: Operator):
elemental_to_nodal_fc._spec().input_pin(3), 3, op, -1
)
self._inputs.append(self._mesh_scoping)
self._algorithm = Input(
elemental_to_nodal_fc._spec().input_pin(200), 200, op, -1
)
self._inputs.append(self._algorithm)

@property
def fields_container(self):
Expand Down Expand Up @@ -268,6 +313,28 @@ def mesh_scoping(self):
"""
return self._mesh_scoping

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

Forces the usage of algorithm 1, 2 or 3
(default is chosen based on the type
of mesh).

Parameters
----------
my_algorithm : int

Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.averaging.elemental_to_nodal_fc()
>>> op.inputs.algorithm.connect(my_algorithm)
>>> # or
>>> op.inputs.algorithm(my_algorithm)
"""
return self._algorithm


class OutputsElementalToNodalFc(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/operators/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def build_pin_data(pins, output=False):
pin_name = pin_name.replace(">", "_")

main_type = docstring_types[0] if len(docstring_types) >= 1 else ""
built_in_types = ("int", "double", "string", "bool", "float", "str")
built_in_types = ("int", "double", "string", "bool", "float", "str", "dict")

# Case where output pin has multiple types.
multiple_types = len(type_names) >= 2
Expand Down
1 change: 1 addition & 0 deletions src/ansys/dpf/core/operators/geo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
from .spherical_to_cartesian import spherical_to_cartesian
from .spherical_to_cartesian_fc import spherical_to_cartesian_fc
from .to_polar_coordinates import to_polar_coordinates
from .transform_invariant_terms_rbd import transform_invariant_terms_rbd
Loading