Skip to content

Commit

Permalink
Update Operators for DPF 232 (#769)
Browse files Browse the repository at this point in the history
* add example and MechanicaResults to code_generation

* fix example style issues

* fix operator call in example

* remove trailing whitespaces from example

* fix typos

* fix example and cherry pick auto update of ops

* add disclaimer related to stress_eqv_as_mechanical

* fix example with suggested changes

* update operators

* merge_meshes moved back

* Fix 01-average_across_bodies.py

Co-authored-by: vsousacosta <vinicius.costa@ansys.com>
Co-authored-by: vsousacosta <109511965+vsousacosta@users.noreply.github.com>
Co-authored-by: cbellot <camille.bellot@ansys.com>
Co-authored-by: cbellot000 <cbellot000@users.noreply.github.com>
Co-authored-by: paul.profizi <paul.profizi@ansys.com>
  • Loading branch information
6 people authored Jan 27, 2023
1 parent dddf378 commit 97d7841
Show file tree
Hide file tree
Showing 200 changed files with 8,424 additions and 2,529 deletions.
2 changes: 2 additions & 0 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"libAns.Dpf.LivePost.so",
"libans.dpf.pointcloudsearch.so",
"libAns.Dpf.Vtk.so",
"libAns.Dpf.MechanicalResults.so",
]
LIB_OPTIONAL_TO_GENERATE = [
"libAns.Dpf.SystemCouplingMapping.so",
Expand All @@ -41,6 +42,7 @@
"Ans.Dpf.LivePost.dll",
"Ans.Dpf.PointCloudSearch.dll",
"Ans.Dpf.Vtk.dll",
"Ans.Dpf.MechanicalResults.dll",
]
LIB_OPTIONAL_TO_GENERATE = [
"Ans.Dpf.SystemCouplingMapping.dll",
Expand Down
4 changes: 3 additions & 1 deletion docs/source/_static/dpf_entry.html

Large diffs are not rendered by default.

56 changes: 29 additions & 27 deletions docs/source/_static/dpf_premium.html

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@
# the modal response, and expand the modal response with the modal basis.

merge_fields = ops.utility.merge_fields_containers()
merge_mesh = ops.mesh.merge_meshes()
merge_mesh = ops.utility.merge_meshes()

ds = dpf.DataSources(base_path + r"/file_load_1.rfrq")
response = ops.result.displacement(data_sources=ds)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@
# the modal response, and expand the modal response with the modal basis.

merge_fields = ops.utility.merge_fields_containers()
merge_mesh = ops.mesh.merge_meshes()
merge_mesh = ops.utility.merge_meshes()

ds = dpf.DataSources(os.path.join(base_path, "file_load_1.rfrq"))
response = ops.result.displacement(data_sources=ds)
Expand Down
346 changes: 179 additions & 167 deletions examples/08-averaging/01-average_across_bodies.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/ansys/dpf/core/operators/averaging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from .nodal_to_elemental_fc import nodal_to_elemental_fc
from .to_elemental_nodal_fc import to_elemental_nodal_fc
from .elemental_fraction_fc import elemental_fraction_fc
from .elemental_difference import elemental_difference
from .elemental_difference_fc import elemental_difference_fc
from .elemental_difference import elemental_difference
from .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc
from .extend_to_mid_nodes import extend_to_mid_nodes
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class elemental_nodal_to_nodal(Operator):
Compute mid nodes (when available) by
averaging neighbour primary nodes
extend_weights_to_mid_nodes : bool, optional
Assigns weights = 2 to mid nodes (when
Extends weights to mid nodes (when
available). default is false
mesh : MeshedRegion, optional
Expand Down Expand Up @@ -136,7 +136,7 @@ def _spec():
name="extend_weights_to_mid_nodes",
type_names=["bool"],
optional=True,
document="""Assigns weights = 2 to mid nodes (when
document="""Extends weights to mid nodes (when
available). default is false""",
),
7: PinSpecification(
Expand Down Expand Up @@ -335,7 +335,7 @@ def extend_to_mid_nodes(self):
def extend_weights_to_mid_nodes(self):
"""Allows to connect extend_weights_to_mid_nodes input to the operator.
Assigns weights = 2 to mid nodes (when
Extends weights to mid nodes (when
available). default is false
Parameters
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/operators/geo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from .rotate_in_cylindrical_cs_fc import rotate_in_cylindrical_cs_fc
from .elements_volumes_over_time import elements_volumes_over_time
from .normals_provider_nl import normals_provider_nl
from .rotate_in_cylindrical_cs import rotate_in_cylindrical_cs
from .rotate import rotate
from .rotate_fc import rotate_fc
from .to_polar_coordinates import to_polar_coordinates
from .normals_provider_nl import normals_provider_nl
from .elements_volumes_over_time import elements_volumes_over_time
from .elements_facets_surfaces_over_time import elements_facets_surfaces_over_time
from .gauss_to_node import gauss_to_node
from .elements_volume import elements_volume
Expand Down
2 changes: 1 addition & 1 deletion src/ansys/dpf/core/operators/mapping/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .solid_to_skin import solid_to_skin
from .scoping_on_coordinates import scoping_on_coordinates
from .find_reduced_coordinates import find_reduced_coordinates
from .on_reduced_coordinates import on_reduced_coordinates
from .on_coordinates import on_coordinates
from .solid_to_skin import solid_to_skin
from .prepare_mapping_workflow import prepare_mapping_workflow
61 changes: 61 additions & 0 deletions src/ansys/dpf/core/operators/math/time_freq_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ class time_freq_interpolation(Operator):
should be its scoping.
interpolation_type : int, optional
1 is ramped, 2 is stepped, default is 0.
force_new_time_freq_support : bool, optional
If set to true, the output fields container
will always have a new time freq
support rescoped to the output
time_freq_values (default is false).
if set to false, the time freq
support is only recreated when time
or frequency values are between
existing ones.
time_freq_support : TimeFreqSupport, optional
Expand All @@ -50,6 +59,8 @@ class time_freq_interpolation(Operator):
>>> op.inputs.step.connect(my_step)
>>> my_interpolation_type = int()
>>> op.inputs.interpolation_type.connect(my_interpolation_type)
>>> my_force_new_time_freq_support = bool()
>>> op.inputs.force_new_time_freq_support.connect(my_force_new_time_freq_support)
>>> my_time_freq_support = dpf.TimeFreqSupport()
>>> op.inputs.time_freq_support.connect(my_time_freq_support)
Expand All @@ -59,6 +70,7 @@ class time_freq_interpolation(Operator):
... time_freq_values=my_time_freq_values,
... step=my_step,
... interpolation_type=my_interpolation_type,
... force_new_time_freq_support=my_force_new_time_freq_support,
... time_freq_support=my_time_freq_support,
... )
Expand All @@ -72,6 +84,7 @@ def __init__(
time_freq_values=None,
step=None,
interpolation_type=None,
force_new_time_freq_support=None,
time_freq_support=None,
config=None,
server=None,
Expand All @@ -87,6 +100,8 @@ def __init__(
self.inputs.step.connect(step)
if interpolation_type is not None:
self.inputs.interpolation_type.connect(interpolation_type)
if force_new_time_freq_support is not None:
self.inputs.force_new_time_freq_support.connect(force_new_time_freq_support)
if time_freq_support is not None:
self.inputs.time_freq_support.connect(time_freq_support)

Expand Down Expand Up @@ -130,6 +145,19 @@ def _spec():
optional=True,
document="""1 is ramped, 2 is stepped, default is 0.""",
),
4: PinSpecification(
name="force_new_time_freq_support",
type_names=["bool"],
optional=True,
document="""If set to true, the output fields container
will always have a new time freq
support rescoped to the output
time_freq_values (default is false).
if set to false, the time freq
support is only recreated when time
or frequency values are between
existing ones.""",
),
8: PinSpecification(
name="time_freq_support",
type_names=["time_freq_support"],
Expand Down Expand Up @@ -201,6 +229,8 @@ class InputsTimeFreqInterpolation(_Inputs):
>>> op.inputs.step.connect(my_step)
>>> my_interpolation_type = int()
>>> op.inputs.interpolation_type.connect(my_interpolation_type)
>>> my_force_new_time_freq_support = bool()
>>> op.inputs.force_new_time_freq_support.connect(my_force_new_time_freq_support)
>>> my_time_freq_support = dpf.TimeFreqSupport()
>>> op.inputs.time_freq_support.connect(my_time_freq_support)
"""
Expand All @@ -221,6 +251,10 @@ def __init__(self, op: Operator):
time_freq_interpolation._spec().input_pin(3), 3, op, -1
)
self._inputs.append(self._interpolation_type)
self._force_new_time_freq_support = Input(
time_freq_interpolation._spec().input_pin(4), 4, op, -1
)
self._inputs.append(self._force_new_time_freq_support)
self._time_freq_support = Input(
time_freq_interpolation._spec().input_pin(8), 8, op, -1
)
Expand Down Expand Up @@ -308,6 +342,33 @@ def interpolation_type(self):
"""
return self._interpolation_type

@property
def force_new_time_freq_support(self):
"""Allows to connect force_new_time_freq_support input to the operator.
If set to true, the output fields container
will always have a new time freq
support rescoped to the output
time_freq_values (default is false).
if set to false, the time freq
support is only recreated when time
or frequency values are between
existing ones.
Parameters
----------
my_force_new_time_freq_support : bool
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.math.time_freq_interpolation()
>>> op.inputs.force_new_time_freq_support.connect(my_force_new_time_freq_support)
>>> # or
>>> op.inputs.force_new_time_freq_support(my_force_new_time_freq_support)
"""
return self._force_new_time_freq_support

@property
def time_freq_support(self):
"""Allows to connect time_freq_support input to the operator.
Expand Down
4 changes: 2 additions & 2 deletions src/ansys/dpf/core/operators/mesh/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
from .mesh_provider import mesh_provider
from .meshes_provider import meshes_provider
from .beam_properties import beam_properties
from .merge_meshes import merge_meshes
from .get_attribute import get_attribute
from .points_from_coordinates import points_from_coordinates
from .change_cs import change_cs
from .from_scoping import from_scoping
from .split_fields import split_fields
from .split_mesh import split_mesh
from .points_from_coordinates import points_from_coordinates
from .mesh_clip import mesh_clip
from .make_sphere_levelset import make_sphere_levelset
from .tri_mesh_skin import tri_mesh_skin
Expand Down
36 changes: 35 additions & 1 deletion src/ansys/dpf/core/operators/mesh/acmo_mesh_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class acmo_mesh_provider(Operator):
Parameters
----------
assembly_mesh : AnsDispatchHolder or Struct Iansdispatch
unit : str, optional
Examples
Expand All @@ -28,22 +29,27 @@ class acmo_mesh_provider(Operator):
>>> # Make input connections
>>> my_assembly_mesh = dpf.AnsDispatchHolder()
>>> op.inputs.assembly_mesh.connect(my_assembly_mesh)
>>> my_unit = str()
>>> op.inputs.unit.connect(my_unit)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.mesh.acmo_mesh_provider(
... assembly_mesh=my_assembly_mesh,
... unit=my_unit,
... )
>>> # Get output data
>>> result_meshes_container = op.outputs.meshes_container()
"""

def __init__(self, assembly_mesh=None, config=None, server=None):
def __init__(self, assembly_mesh=None, unit=None, config=None, server=None):
super().__init__(name="acmo_mesh_provider", config=config, server=server)
self._inputs = InputsAcmoMeshProvider(self)
self._outputs = OutputsAcmoMeshProvider(self)
if assembly_mesh is not None:
self.inputs.assembly_mesh.connect(assembly_mesh)
if unit is not None:
self.inputs.unit.connect(unit)

@staticmethod
def _spec():
Expand All @@ -57,6 +63,12 @@ def _spec():
optional=False,
document="""""",
),
1: PinSpecification(
name="unit",
type_names=["string"],
optional=True,
document="""""",
),
},
map_output_pin_spec={
0: PinSpecification(
Expand Down Expand Up @@ -116,12 +128,16 @@ class InputsAcmoMeshProvider(_Inputs):
>>> op = dpf.operators.mesh.acmo_mesh_provider()
>>> my_assembly_mesh = dpf.AnsDispatchHolder()
>>> op.inputs.assembly_mesh.connect(my_assembly_mesh)
>>> my_unit = str()
>>> op.inputs.unit.connect(my_unit)
"""

def __init__(self, op: Operator):
super().__init__(acmo_mesh_provider._spec().inputs, op)
self._assembly_mesh = Input(acmo_mesh_provider._spec().input_pin(0), 0, op, -1)
self._inputs.append(self._assembly_mesh)
self._unit = Input(acmo_mesh_provider._spec().input_pin(1), 1, op, -1)
self._inputs.append(self._unit)

@property
def assembly_mesh(self):
Expand All @@ -141,6 +157,24 @@ def assembly_mesh(self):
"""
return self._assembly_mesh

@property
def unit(self):
"""Allows to connect unit input to the operator.
Parameters
----------
my_unit : str
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.mesh.acmo_mesh_provider()
>>> op.inputs.unit.connect(my_unit)
>>> # or
>>> op.inputs.unit(my_unit)
"""
return self._unit


class OutputsAcmoMeshProvider(_Outputs):
"""Intermediate class used to get outputs from
Expand Down
Loading

0 comments on commit 97d7841

Please sign in to comment.