From 2a2081c9cfb255f126277ef1cf3117301f1692c3 Mon Sep 17 00:00:00 2001 From: Federico Negri Date: Thu, 5 Oct 2023 12:11:21 +0200 Subject: [PATCH] Fix results extraction for simulation object with given server (#499) --- .../post/harmonic_mechanical_simulation.py | 4 +++- src/ansys/dpf/post/simulation.py | 5 ++++- tests/test_simulation.py | 22 +++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/ansys/dpf/post/harmonic_mechanical_simulation.py b/src/ansys/dpf/post/harmonic_mechanical_simulation.py index fcdb73709..3106e66e3 100644 --- a/src/ansys/dpf/post/harmonic_mechanical_simulation.py +++ b/src/ansys/dpf/post/harmonic_mechanical_simulation.py @@ -379,7 +379,9 @@ def _get_result( ) for i_field in range(len(fc)): bind_support_op = dpf.operators.utility.bind_support( - fc[i_field], submesh + fc[i_field], + submesh, + server=fc._server, ) fc.add_field(fc.get_label_space(i_field), bind_support_op.eval()) diff --git a/src/ansys/dpf/post/simulation.py b/src/ansys/dpf/post/simulation.py index 5b4ed109c..02536a8e6 100644 --- a/src/ansys/dpf/post/simulation.py +++ b/src/ansys/dpf/post/simulation.py @@ -619,6 +619,7 @@ def _generate_disp_workflow(self, fc, selection) -> Union[dpf.Workflow, None]: merge_op = dpf.operators.utility.merge_fields_by_label( fields_container=shell_layer_op.outputs.fields_container_as_fields_container, label="eltype", + server=fc._server, ) # Expose output @@ -643,7 +644,9 @@ def _create_dataframe( if submesh is not None: for i_field in range(len(fc)): bind_support_op = dpf.operators.utility.bind_support( - fc[i_field], submesh + fc[i_field], + submesh, + server=fc._server, ) fc.add_field(fc.get_label_space(i_field), bind_support_op.eval()) if unit == "": diff --git a/tests/test_simulation.py b/tests/test_simulation.py index 24d2f9463..92690bdec 100644 --- a/tests/test_simulation.py +++ b/tests/test_simulation.py @@ -158,6 +158,16 @@ def test_multi_stage(self, multi_stage_cyclic): assert "base_sector" not in result.columns.names assert "stage" not in result.columns.names + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0, + reason="Available starting DPF 4.0", + ) + def test_with_grpc_server(self, static_rst, grpc_server): + simulation = post.StaticMechanicalSimulation(static_rst, server=grpc_server) + assert simulation._model._server != dpf.SERVER + _ = simulation.displacement() + _ = simulation.displacement(skin=True) + def test_times_argument(self, static_simulation): _ = static_simulation.displacement(times=1) _ = static_simulation.displacement(times=1.0) @@ -2075,6 +2085,18 @@ def test_multi_stage(self, multi_stage_cyclic): assert "base_sector" not in result.columns.names assert "stage" not in result.columns.names + @pytest.mark.skipif( + not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_4_0, + reason="Available starting DPF 4.0", + ) + def test_with_grpc_server(self, complex_model, grpc_server): + simulation = post.HarmonicMechanicalSimulation( + complex_model, server=grpc_server + ) + assert simulation._model._server != dpf.SERVER + _ = simulation.displacement() + _ = simulation.displacement(skin=True) + def test_displacement(self, harmonic_simulation): # print(harmonic_simulation)