diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ccfc31f39..a9ccdc9fb 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -145,7 +145,7 @@ jobs: uses: pyansys/pydpf-actions/build_package@v2.3 with: python-version: ${{ matrix.python-version }} - ANSYS_VERSION: ${{env.ANSYS_VERSION}} + ANSYS_VERSION: ${{matrix.ANSYS_VERSION}} PACKAGE_NAME: ${{env.PACKAGE_NAME}} MODULE: ${{env.MODULE}} dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}} @@ -157,6 +157,8 @@ jobs: shell: bash run: | pip install ansys-grpc-dpf==0.4.0 + pip uninstall -y protobuf + pip install "protobuf<4.0" if: matrix.ANSYS_VERSION == '221' - name: "Prepare Testing Environment" diff --git a/.github/workflows/ci_release.yml b/.github/workflows/ci_release.yml index dd6fe217f..31025d3dc 100644 --- a/.github/workflows/ci_release.yml +++ b/.github/workflows/ci_release.yml @@ -141,7 +141,7 @@ jobs: uses: pyansys/pydpf-actions/build_package@v2.3 with: python-version: ${{ matrix.python-version }} - ANSYS_VERSION: ${{env.ANSYS_VERSION}} + ANSYS_VERSION: ${{matrix.ANSYS_VERSION}} PACKAGE_NAME: ${{env.PACKAGE_NAME}} MODULE: ${{env.MODULE}} dpf-standalone-TOKEN: ${{secrets.DPF_PIPELINE}} @@ -153,6 +153,8 @@ jobs: shell: bash run: | pip install ansys-grpc-dpf==0.4.0 + pip uninstall -y protobuf + pip install "protobuf<4.0" if: matrix.ANSYS_VERSION == '221' - name: "Prepare Testing Environment" diff --git a/src/ansys/dpf/post/harmonic_mechanical_simulation.py b/src/ansys/dpf/post/harmonic_mechanical_simulation.py index a71b5eea6..7c05baf76 100644 --- a/src/ansys/dpf/post/harmonic_mechanical_simulation.py +++ b/src/ansys/dpf/post/harmonic_mechanical_simulation.py @@ -264,12 +264,6 @@ def _get_result( wf.add_operator(operator=norm_op) out = norm_op.outputs.fields_container - extract_scoping = self._model.operator(name="extract_scoping") - extract_scoping.connect(0, out) - merge_scopings = self._model.operator(name="merge::scoping") - merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping) - wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping) - # Set the workflow output wf.set_output_name("out", out) # Evaluate the workflow diff --git a/src/ansys/dpf/post/index.py b/src/ansys/dpf/post/index.py index 75de714f2..cbeb6f4d4 100644 --- a/src/ansys/dpf/post/index.py +++ b/src/ansys/dpf/post/index.py @@ -147,10 +147,16 @@ def _evaluate_values(self): # Merge the fields container scoping fc = self._fc() if fc is not None: - scopings = dpf.operators.utility.extract_scoping( - field_or_fields_container=fc - ).outputs.mesh_scoping_as_scopings_container - merge_op = dpf.operators.utility.merge_scopings(scopings=scopings) + merge_op = dpf.operators.utility.merge_scopings(server=fc._server) + if float(fc._server.version) >= 5.0: + scopings = dpf.operators.utility.extract_scoping( + field_or_fields_container=fc, + server=fc._server, + ).outputs.mesh_scoping_as_scopings_container + merge_op.connect(0, scopings) + else: + for i, f in enumerate(fc): + merge_op.connect(i, f.scoping) self._values = merge_op.eval().ids else: raise AttributeError( diff --git a/src/ansys/dpf/post/modal_mechanical_simulation.py b/src/ansys/dpf/post/modal_mechanical_simulation.py index 941b5f849..92d58f365 100644 --- a/src/ansys/dpf/post/modal_mechanical_simulation.py +++ b/src/ansys/dpf/post/modal_mechanical_simulation.py @@ -206,12 +206,6 @@ def _get_result( wf.add_operator(operator=norm_op) out = norm_op.outputs.fields_container - extract_scoping = self._model.operator(name="extract_scoping") - extract_scoping.connect(0, out) - merge_scopings = self._model.operator(name="merge::scoping") - merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping) - wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping) - # Set the workflow output wf.set_output_name("out", out) # Evaluate the workflow diff --git a/src/ansys/dpf/post/transient_mechanical_simulation.py b/src/ansys/dpf/post/transient_mechanical_simulation.py index 4b87cef7b..f8cd0020a 100644 --- a/src/ansys/dpf/post/transient_mechanical_simulation.py +++ b/src/ansys/dpf/post/transient_mechanical_simulation.py @@ -214,12 +214,6 @@ def _get_result( out = norm_op.outputs.fields_container comp = None - extract_scoping = self._model.operator(name="extract_scoping") - extract_scoping.connect(0, out) - merge_scopings = self._model.operator(name="merge::scoping") - merge_scopings.connect(0, extract_scoping.outputs.mesh_scoping_as_scoping) - wf.set_output_name("scoping", merge_scopings.outputs.merged_scoping) - # Set the workflow output wf.set_output_name("out", out) # Evaluate the workflow diff --git a/tests/conftest.py b/tests/conftest.py index 34cf1d44b..ae9e31386 100755 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -161,6 +161,9 @@ def close_servers(): get_server_version(core._global_server()), "6.0" ) +SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 = meets_version( + get_server_version(core._global_server()), "5.0" +) # to call at the end if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_6_0: diff --git a/tests/test_dataframe.py b/tests/test_dataframe.py index d1697e5a8..0ce5e02ef 100644 --- a/tests/test_dataframe.py +++ b/tests/test_dataframe.py @@ -19,6 +19,7 @@ @fixture def df(static_rst): simulation = StaticMechanicalSimulation(static_rst) + print(simulation._model._server.version) return simulation.displacement() diff --git a/tests/test_simulation.py b/tests/test_simulation.py index f955f5f00..131ddecc2 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -1,6 +1,7 @@ import os.path import ansys.dpf.core as core +from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0 import numpy as np import pytest from pytest import fixture @@ -430,6 +431,10 @@ def test_structural_temperature_elemental(self, static_simulation): assert field.data.shape == (12,) assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces(self, allkindofcomplexity): static_simulation = post.load_simulation(data_sources=allkindofcomplexity) element_nodal_forces = static_simulation.element_nodal_forces() @@ -442,6 +447,10 @@ def test_element_nodal_forces(self, allkindofcomplexity): assert field.data.shape == (103766, 3) assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_nodal(self, allkindofcomplexity): static_simulation = post.load_simulation(data_sources=allkindofcomplexity) element_nodal_forces = static_simulation.element_nodal_forces_nodal() @@ -455,6 +464,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity): assert field.data.shape == (14982, 3) assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_elemental(self, allkindofcomplexity): static_simulation = post.load_simulation(data_sources=allkindofcomplexity) element_nodal_forces = static_simulation.element_nodal_forces_elemental() @@ -974,6 +987,10 @@ def test_structural_temperature_elemental(self, transient_simulation): assert field.component_count == 1 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces(self, allkindofcomplexity): transient_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -988,6 +1005,10 @@ def test_element_nodal_forces(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_nodal(self, allkindofcomplexity): transient_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1003,6 +1024,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_elemental(self, allkindofcomplexity): transient_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1126,6 +1151,10 @@ def test_reaction_force(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces(self, allkindofcomplexity): modal_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1140,6 +1169,10 @@ def test_element_nodal_forces(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_nodal(self, allkindofcomplexity): modal_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1155,6 +1188,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_elemental(self, allkindofcomplexity): modal_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1582,6 +1619,10 @@ def test_reaction_force(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces(self, allkindofcomplexity): harmonic_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1596,6 +1637,10 @@ def test_element_nodal_forces(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_nodal(self, allkindofcomplexity): harmonic_simulation = post.load_simulation( data_sources=allkindofcomplexity, @@ -1611,6 +1656,10 @@ def test_element_nodal_forces_nodal(self, allkindofcomplexity): assert field.component_count == 3 assert np.allclose(field.data, field_ref.data) + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_5_0, + reason="Available starting DPF 5.0", + ) def test_element_nodal_forces_elemental(self, allkindofcomplexity): harmonic_simulation = post.load_simulation( data_sources=allkindofcomplexity,