Skip to content

Commit fb17938

Browse files
authored
Fix retro-compatibility with 222 and 221 (#339)
* Fix ANSYS_VERSION in retro tests in ci.yml and ci_release.yml * Properly remove all scoping_merge workflows from _get_result * Add retro-compatible code for MeshIndex._evaluate_values() * Add retro-compatible code for MeshIndex._evaluate_values() - reduce required server version to 5 * Add retro-compatible code for MeshIndex._evaluate_values() - make server coherent * Skip ENF result tests if DPF<5.0 * Force protobuf<4.0 for 221 * Force protobuf<4.0 for 221
1 parent 5c5d79a commit fb17938

File tree

9 files changed

+69
-24
lines changed

9 files changed

+69
-24
lines changed

.github/workflows/ci.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ jobs:
145145
uses: pyansys/pydpf-actions/[email protected]
146146
with:
147147
python-version: ${{ matrix.python-version }}
148-
ANSYS_VERSION: ${{env.ANSYS_VERSION}}
148+
ANSYS_VERSION: ${{matrix.ANSYS_VERSION}}
149149
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
150150
MODULE: ${{env.MODULE}}
151151
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
@@ -157,6 +157,8 @@ jobs:
157157
shell: bash
158158
run: |
159159
pip install ansys-grpc-dpf==0.4.0
160+
pip uninstall -y protobuf
161+
pip install "protobuf<4.0"
160162
if: matrix.ANSYS_VERSION == '221'
161163

162164
- name: "Prepare Testing Environment"

.github/workflows/ci_release.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ jobs:
141141
uses: pyansys/pydpf-actions/[email protected]
142142
with:
143143
python-version: ${{ matrix.python-version }}
144-
ANSYS_VERSION: ${{env.ANSYS_VERSION}}
144+
ANSYS_VERSION: ${{matrix.ANSYS_VERSION}}
145145
PACKAGE_NAME: ${{env.PACKAGE_NAME}}
146146
MODULE: ${{env.MODULE}}
147147
dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}}
@@ -153,6 +153,8 @@ jobs:
153153
shell: bash
154154
run: |
155155
pip install ansys-grpc-dpf==0.4.0
156+
pip uninstall -y protobuf
157+
pip install "protobuf<4.0"
156158
if: matrix.ANSYS_VERSION == '221'
157159

158160
- name: "Prepare Testing Environment"

src/ansys/dpf/post/harmonic_mechanical_simulation.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -264,12 +264,6 @@ def _get_result(
264264
wf.add_operator(operator=norm_op)
265265
out = norm_op.outputs.fields_container
266266

267-
extract_scoping = self._model.operator(name="extract_scoping")
268-
extract_scoping.connect(0, out)
269-
merge_scopings = self._model.operator(name="merge::scoping")
270-
merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping)
271-
wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping)
272-
273267
# Set the workflow output
274268
wf.set_output_name("out", out)
275269
# Evaluate the workflow

src/ansys/dpf/post/index.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,16 @@ def _evaluate_values(self):
147147
# Merge the fields container scoping
148148
fc = self._fc()
149149
if fc is not None:
150-
scopings = dpf.operators.utility.extract_scoping(
151-
field_or_fields_container=fc
152-
).outputs.mesh_scoping_as_scopings_container
153-
merge_op = dpf.operators.utility.merge_scopings(scopings=scopings)
150+
merge_op = dpf.operators.utility.merge_scopings(server=fc._server)
151+
if float(fc._server.version) >= 5.0:
152+
scopings = dpf.operators.utility.extract_scoping(
153+
field_or_fields_container=fc,
154+
server=fc._server,
155+
).outputs.mesh_scoping_as_scopings_container
156+
merge_op.connect(0, scopings)
157+
else:
158+
for i, f in enumerate(fc):
159+
merge_op.connect(i, f.scoping)
154160
self._values = merge_op.eval().ids
155161
else:
156162
raise AttributeError(

src/ansys/dpf/post/modal_mechanical_simulation.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,6 @@ def _get_result(
206206
wf.add_operator(operator=norm_op)
207207
out = norm_op.outputs.fields_container
208208

209-
extract_scoping = self._model.operator(name="extract_scoping")
210-
extract_scoping.connect(0, out)
211-
merge_scopings = self._model.operator(name="merge::scoping")
212-
merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping)
213-
wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping)
214-
215209
# Set the workflow output
216210
wf.set_output_name("out", out)
217211
# Evaluate the workflow

src/ansys/dpf/post/transient_mechanical_simulation.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,6 @@ def _get_result(
214214
out = norm_op.outputs.fields_container
215215
comp = None
216216

217-
extract_scoping = self._model.operator(name="extract_scoping")
218-
extract_scoping.connect(0, out)
219-
merge_scopings = self._model.operator(name="merge::scoping")
220-
merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping)
221-
wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping)
222-
223217
# Set the workflow output
224218
wf.set_output_name("out", out)
225219
# Evaluate the workflow

tests/conftest.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,9 @@ def close_servers():
161161
get_server_version(core._global_server()), "6.0"
162162
)
163163

164+
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 = meets_version(
165+
get_server_version(core._global_server()), "5.0"
166+
)
164167

165168
# to call at the end
166169
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_0:

tests/test_dataframe.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
@fixture
2020
def df(static_rst):
2121
simulation = StaticMechanicalSimulation(static_rst)
22+
print(simulation._model._server.version)
2223
return simulation.displacement()
2324

2425

tests/test_simulation.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import os.path
22

33
import ansys.dpf.core as core
4+
from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0
45
import numpy as np
56
import pytest
67
from pytest import fixture
@@ -430,6 +431,10 @@ def test_structural_temperature_elemental(self, static_simulation):
430431
assert field.data.shape == (12,)
431432
assert np.allclose(field.data, field_ref.data)
432433

434+
@pytest.mark.skipif(
435+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
436+
reason="Available starting DPF 5.0",
437+
)
433438
def test_element_nodal_forces(self, allkindofcomplexity):
434439
static_simulation = post.load_simulation(data_sources=allkindofcomplexity)
435440
element_nodal_forces = static_simulation.element_nodal_forces()
@@ -442,6 +447,10 @@ def test_element_nodal_forces(self, allkindofcomplexity):
442447
assert field.data.shape == (103766, 3)
443448
assert np.allclose(field.data, field_ref.data)
444449

450+
@pytest.mark.skipif(
451+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
452+
reason="Available starting DPF 5.0",
453+
)
445454
def test_element_nodal_forces_nodal(self, allkindofcomplexity):
446455
static_simulation = post.load_simulation(data_sources=allkindofcomplexity)
447456
element_nodal_forces = static_simulation.element_nodal_forces_nodal()
@@ -455,6 +464,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity):
455464
assert field.data.shape == (14982, 3)
456465
assert np.allclose(field.data, field_ref.data)
457466

467+
@pytest.mark.skipif(
468+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
469+
reason="Available starting DPF 5.0",
470+
)
458471
def test_element_nodal_forces_elemental(self, allkindofcomplexity):
459472
static_simulation = post.load_simulation(data_sources=allkindofcomplexity)
460473
element_nodal_forces = static_simulation.element_nodal_forces_elemental()
@@ -974,6 +987,10 @@ def test_structural_temperature_elemental(self, transient_simulation):
974987
assert field.component_count == 1
975988
assert np.allclose(field.data, field_ref.data)
976989

990+
@pytest.mark.skipif(
991+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
992+
reason="Available starting DPF 5.0",
993+
)
977994
def test_element_nodal_forces(self, allkindofcomplexity):
978995
transient_simulation = post.load_simulation(
979996
data_sources=allkindofcomplexity,
@@ -988,6 +1005,10 @@ def test_element_nodal_forces(self, allkindofcomplexity):
9881005
assert field.component_count == 3
9891006
assert np.allclose(field.data, field_ref.data)
9901007

1008+
@pytest.mark.skipif(
1009+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1010+
reason="Available starting DPF 5.0",
1011+
)
9911012
def test_element_nodal_forces_nodal(self, allkindofcomplexity):
9921013
transient_simulation = post.load_simulation(
9931014
data_sources=allkindofcomplexity,
@@ -1003,6 +1024,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity):
10031024
assert field.component_count == 3
10041025
assert np.allclose(field.data, field_ref.data)
10051026

1027+
@pytest.mark.skipif(
1028+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1029+
reason="Available starting DPF 5.0",
1030+
)
10061031
def test_element_nodal_forces_elemental(self, allkindofcomplexity):
10071032
transient_simulation = post.load_simulation(
10081033
data_sources=allkindofcomplexity,
@@ -1126,6 +1151,10 @@ def test_reaction_force(self, allkindofcomplexity):
11261151
assert field.component_count == 3
11271152
assert np.allclose(field.data, field_ref.data)
11281153

1154+
@pytest.mark.skipif(
1155+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1156+
reason="Available starting DPF 5.0",
1157+
)
11291158
def test_element_nodal_forces(self, allkindofcomplexity):
11301159
modal_simulation = post.load_simulation(
11311160
data_sources=allkindofcomplexity,
@@ -1140,6 +1169,10 @@ def test_element_nodal_forces(self, allkindofcomplexity):
11401169
assert field.component_count == 3
11411170
assert np.allclose(field.data, field_ref.data)
11421171

1172+
@pytest.mark.skipif(
1173+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1174+
reason="Available starting DPF 5.0",
1175+
)
11431176
def test_element_nodal_forces_nodal(self, allkindofcomplexity):
11441177
modal_simulation = post.load_simulation(
11451178
data_sources=allkindofcomplexity,
@@ -1155,6 +1188,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity):
11551188
assert field.component_count == 3
11561189
assert np.allclose(field.data, field_ref.data)
11571190

1191+
@pytest.mark.skipif(
1192+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1193+
reason="Available starting DPF 5.0",
1194+
)
11581195
def test_element_nodal_forces_elemental(self, allkindofcomplexity):
11591196
modal_simulation = post.load_simulation(
11601197
data_sources=allkindofcomplexity,
@@ -1582,6 +1619,10 @@ def test_reaction_force(self, allkindofcomplexity):
15821619
assert field.component_count == 3
15831620
assert np.allclose(field.data, field_ref.data)
15841621

1622+
@pytest.mark.skipif(
1623+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1624+
reason="Available starting DPF 5.0",
1625+
)
15851626
def test_element_nodal_forces(self, allkindofcomplexity):
15861627
harmonic_simulation = post.load_simulation(
15871628
data_sources=allkindofcomplexity,
@@ -1596,6 +1637,10 @@ def test_element_nodal_forces(self, allkindofcomplexity):
15961637
assert field.component_count == 3
15971638
assert np.allclose(field.data, field_ref.data)
15981639

1640+
@pytest.mark.skipif(
1641+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1642+
reason="Available starting DPF 5.0",
1643+
)
15991644
def test_element_nodal_forces_nodal(self, allkindofcomplexity):
16001645
harmonic_simulation = post.load_simulation(
16011646
data_sources=allkindofcomplexity,
@@ -1611,6 +1656,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity):
16111656
assert field.component_count == 3
16121657
assert np.allclose(field.data, field_ref.data)
16131658

1659+
@pytest.mark.skipif(
1660+
not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0,
1661+
reason="Available starting DPF 5.0",
1662+
)
16141663
def test_element_nodal_forces_elemental(self, allkindofcomplexity):
16151664
harmonic_simulation = post.load_simulation(
16161665
data_sources=allkindofcomplexity,

0 commit comments

Comments
 (0)