Skip to content

Commit

Permalink
Update the operators for 2023.2.pre0 (#644)
Browse files Browse the repository at this point in the history
* Update code_generation.py

Signed-off-by: paul.profizi <[email protected]>

* Operators generated with dpf_standalone_win_v23.2.pre0 from #DPF - Server - Customer Portal-20221123.1

Signed-off-by: paul.profizi <[email protected]>

* Update the operator generation script to have everything in one step.

Signed-off-by: paul.profizi <[email protected]>

* Regenerated operators

Signed-off-by: paul.profizi <[email protected]>

* Update code_generation.py

Signed-off-by: paul.profizi <[email protected]>

* Add server operators

Signed-off-by: paul.profizi <[email protected]>

* Loosen retry criteria for tests_remote_workflow and test_workflow (due to 221)

Signed-off-by: paul.profizi <[email protected]>

* Revert to manual generation

Signed-off-by: paul.profizi <[email protected]>

* Fix init files for hdf5

Signed-off-by: paul.profizi <[email protected]>

* fix flake8

Signed-off-by: paul.profizi <[email protected]>

* Loosen retries

Signed-off-by: paul.profizi <[email protected]>

Signed-off-by: paul.profizi <[email protected]>
  • Loading branch information
PProfizi authored Nov 25, 2022
1 parent 2c41da3 commit b4bdc2f
Show file tree
Hide file tree
Showing 89 changed files with 18,435 additions and 1,599 deletions.
24 changes: 16 additions & 8 deletions .ci/code_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
import time
import shutil


core.set_default_server_context(core.AvailableServerContexts.premium)

if os.name == "posix":
LIB_TO_GENERATE = [
"libAns.Dpf.Native.so",
Expand All @@ -24,7 +27,6 @@
else:
LIB_TO_GENERATE = [
"Ans.Dpf.Native.dll",
"Ans.Dpf.Mechanical.dll",
"Ans.Dpf.FEMutils.dll",
"meshOperatorsCore.dll",
"mapdlOperatorsCore.dll",
Expand Down Expand Up @@ -62,13 +64,18 @@
code_gen = core.Operator("python_generator")
code_gen.connect(1, TARGET_PATH)
for lib in LIB_TO_GENERATE:
code_gen.connect(0, lib)
if lib != LIB_TO_GENERATE[0]:
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
code_gen.run()
time.sleep(0.1)
try:
code_gen.connect(0, lib)
if lib != LIB_TO_GENERATE[0]:
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
print(f"Generating {lib} operators for server {core.SERVER.version}...")
code_gen.run()
time.sleep(0.1)
except Exception as e:
print(f"Could not generate operators for library {lib}:\n{str(e)}")
raise e

for lib in LIB_OPTIONAL_TO_GENERATE:
try:
Expand All @@ -77,6 +84,7 @@
code_gen.connect(2, False)
else:
code_gen.connect(2, True)
print(f"Generating optional {lib} operators for server {core.SERVER.version}...")
code_gen.run()
time.sleep(0.1)
except Exception as e:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ jobs:
- name: "Test API test_workflow"
uses: nick-fields/retry@v2
with:
timeout_minutes: 2
max_attempts: 2
timeout_minutes: 3
max_attempts: 3
shell: bash
command: |
pytest $DEBUG $COVERAGE --cov-append $RERUNS --junitxml=../tests/junit/test-results8.xml test_workflow/.
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ jobs:
- name: "Test API test_remote_workflow"
uses: nick-fields/retry@v2
with:
timeout_minutes: 3
timeout_minutes: 4
max_attempts: 3
shell: bash
command: |
Expand All @@ -239,8 +239,9 @@ jobs:
- name: "Test API test_workflow"
uses: nick-fields/retry@v2
with:
timeout_minutes: 2
max_attempts: 2
timeout_minutes: 3
max_attempts: 4
retry_wait_seconds: 15
shell: bash
command: |
pytest $DEBUG $COVERAGE --cov-append $RERUNS --junitxml=../tests/junit/test-results8.xml test_workflow/.
Expand Down
8 changes: 4 additions & 4 deletions ansys/dpf/core/operators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
from . import math
from . import result
from . import utility
from . import min_max
from . import result
from . import scoping
from . import filter
from . import logic
from . import metadata
from . import serialization
from . import min_max
from . import mesh
from . import geo
from . import serialization
from . import averaging
from . import geo
from . import invariant
from . import mapping
22 changes: 11 additions & 11 deletions ansys/dpf/core/operators/averaging/__init__.py
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
from .elemental_difference import elemental_difference
from .elemental_nodal_to_nodal import elemental_nodal_to_nodal
from .elemental_nodal_to_nodal_fc import elemental_nodal_to_nodal_fc
from .elemental_to_nodal import elemental_to_nodal
from .elemental_to_nodal_fc import elemental_to_nodal_fc
from .elemental_to_elemental_nodal import elemental_to_elemental_nodal
from .nodal_difference import nodal_difference
from .elemental_to_elemental_nodal_fc import elemental_to_elemental_nodal_fc
from .nodal_difference_fc import nodal_difference_fc
from .elemental_difference_fc import elemental_difference_fc
from .nodal_fraction_fc import nodal_fraction_fc
from .elemental_nodal_to_nodal_elemental_fc import elemental_nodal_to_nodal_elemental_fc
from .elemental_fraction_fc import elemental_fraction_fc
from .to_nodal import to_nodal
from .nodal_difference import nodal_difference
from .elemental_to_elemental_nodal import elemental_to_elemental_nodal
from .to_nodal_fc import to_nodal_fc
from .nodal_extend_to_mid_nodes import nodal_extend_to_mid_nodes
from .nodal_difference_fc import nodal_difference_fc
from .elemental_to_elemental_nodal_fc import elemental_to_elemental_nodal_fc
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
from .nodal_fraction_fc import nodal_fraction_fc
from .elemental_nodal_to_nodal_elemental_fc import elemental_nodal_to_nodal_elemental_fc
from .elemental_mean import elemental_mean
from .elemental_mean_fc import elemental_mean_fc
from .to_elemental_fc import to_elemental_fc
from .gauss_to_node_fc import gauss_to_node_fc
from .nodal_to_elemental import nodal_to_elemental
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 .extend_to_mid_nodes_fc import extend_to_mid_nodes_fc
from .extend_to_mid_nodes import extend_to_mid_nodes
17 changes: 16 additions & 1 deletion ansys/dpf/core/operators/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from ansys.dpf.core.mapping_types import map_types_to_python


dpf.set_default_server_context(dpf.AvailableServerContexts.premium)
dpf.start_local_server(config=dpf.AvailableServerConfigs.LegacyGrpcServer)

def build_docstring(specification):
Expand Down Expand Up @@ -166,17 +167,25 @@ def build_operator(


if __name__ == "__main__":
print(f"Generating operators for server {dpf.SERVER.version}")

this_path = os.path.dirname(os.path.abspath(__file__))

available_operators = available_operator_names()

print(f"{len(available_operators)} operators found to generate.")

succeeded = 0
done = 0
for operator_name in available_operators:
if succeeded == done + 100:
done += 100
print(f"{done} operators done...")
specification = dpf.Operator.operator_specification(operator_name)

category = specification.properties.get("category", "")
if not category:
raise (f"Category not defined for operator {operator_name}.")
raise ValueError(f"Category not defined for operator {operator_name}.")
scripting_name = specification.properties.get("scripting_name", "")

# Make directory for new category
Expand Down Expand Up @@ -221,3 +230,9 @@ def build_operator(

print(f"Generated {succeeded} out of {len(available_operators)}")
dpf.SERVER.shutdown()
if succeeded == len(available_operators):
print("Success")
exit(0)
else:
print("Terminated with errors")
exit(1)
6 changes: 3 additions & 3 deletions ansys/dpf/core/operators/geo/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
from .normals_provider_nl import normals_provider_nl
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 .elements_volumes_over_time import elements_volumes_over_time
from .gauss_to_node import gauss_to_node
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
from .element_nodal_contribution import element_nodal_contribution
from .integrate_over_elements import integrate_over_elements
Expand Down
65 changes: 51 additions & 14 deletions ansys/dpf/core/operators/geo/rotate_in_cylindrical_cs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ class rotate_in_cylindrical_cs(Operator):
3-3 rotation matrix and origin coordinates
must be set here to define a
coordinate system.
mesh : MeshedRegion, optional
Mesh support of the input field
Examples
Expand All @@ -40,25 +42,32 @@ class rotate_in_cylindrical_cs(Operator):
>>> op.inputs.field.connect(my_field)
>>> my_coordinate_system = dpf.Field()
>>> op.inputs.coordinate_system.connect(my_coordinate_system)
>>> my_mesh = dpf.MeshedRegion()
>>> op.inputs.mesh.connect(my_mesh)
>>> # Instantiate operator and connect inputs in one line
>>> op = dpf.operators.geo.rotate_in_cylindrical_cs(
... field=my_field,
... coordinate_system=my_coordinate_system,
... mesh=my_mesh,
... )
>>> # Get output data
>>> result_fields_container = op.outputs.fields_container()
>>> result_field = op.outputs.field()
"""

def __init__(self, field=None, coordinate_system=None, config=None, server=None):
def __init__(
self, field=None, coordinate_system=None, mesh=None, config=None, server=None
):
super().__init__(name="transform_cylindricalCS", config=config, server=server)
self._inputs = InputsRotateInCylindricalCs(self)
self._outputs = OutputsRotateInCylindricalCs(self)
if field is not None:
self.inputs.field.connect(field)
if coordinate_system is not None:
self.inputs.coordinate_system.connect(coordinate_system)
if mesh is not None:
self.inputs.mesh.connect(mesh)

@staticmethod
def _spec():
Expand All @@ -85,11 +94,17 @@ def _spec():
must be set here to define a
coordinate system.""",
),
2: PinSpecification(
name="mesh",
type_names=["abstract_meshed_region"],
optional=True,
document="""Mesh support of the input field""",
),
},
map_output_pin_spec={
0: PinSpecification(
name="fields_container",
type_names=["fields_container"],
name="field",
type_names=["field"],
optional=False,
document="""""",
),
Expand Down Expand Up @@ -146,6 +161,8 @@ class InputsRotateInCylindricalCs(_Inputs):
>>> op.inputs.field.connect(my_field)
>>> my_coordinate_system = dpf.Field()
>>> op.inputs.coordinate_system.connect(my_coordinate_system)
>>> my_mesh = dpf.MeshedRegion()
>>> op.inputs.mesh.connect(my_mesh)
"""

def __init__(self, op: Operator):
Expand All @@ -156,6 +173,8 @@ def __init__(self, op: Operator):
rotate_in_cylindrical_cs._spec().input_pin(1), 1, op, -1
)
self._inputs.append(self._coordinate_system)
self._mesh = Input(rotate_in_cylindrical_cs._spec().input_pin(2), 2, op, -1)
self._inputs.append(self._mesh)

@property
def field(self):
Expand Down Expand Up @@ -200,6 +219,26 @@ def coordinate_system(self):
"""
return self._coordinate_system

@property
def mesh(self):
"""Allows to connect mesh input to the operator.
Mesh support of the input field
Parameters
----------
my_mesh : MeshedRegion
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.geo.rotate_in_cylindrical_cs()
>>> op.inputs.mesh.connect(my_mesh)
>>> # or
>>> op.inputs.mesh(my_mesh)
"""
return self._mesh


class OutputsRotateInCylindricalCs(_Outputs):
"""Intermediate class used to get outputs from
Expand All @@ -210,29 +249,27 @@ class OutputsRotateInCylindricalCs(_Outputs):
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.geo.rotate_in_cylindrical_cs()
>>> # Connect inputs : op.inputs. ...
>>> result_fields_container = op.outputs.fields_container()
>>> result_field = op.outputs.field()
"""

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

@property
def fields_container(self):
"""Allows to get fields_container output of the operator
def field(self):
"""Allows to get field output of the operator
Returns
----------
my_fields_container : FieldsContainer
my_field : Field
Examples
--------
>>> from ansys.dpf import core as dpf
>>> op = dpf.operators.geo.rotate_in_cylindrical_cs()
>>> # Connect inputs : op.inputs. ...
>>> result_fields_container = op.outputs.fields_container()
>>> result_field = op.outputs.field()
""" # noqa: E501
return self._fields_container
return self._field
Loading

0 comments on commit b4bdc2f

Please sign in to comment.