From b720a5c996ea1bb1d5c6454af593925bfeb57195 Mon Sep 17 00:00:00 2001 From: Prithwish Mukherjee <109645853+prmukherj@users.noreply.github.com> Date: Mon, 2 Sep 2024 15:31:04 +0530 Subject: [PATCH] fix: Convert protobuf Point to python Vector. (#3239) * fix: Convert protobuf Point to python Vector. * Return tuple from Point. * Mark test as nightly. --- src/ansys/fluent/core/services/reduction.py | 10 +++++----- tests/test_reduction.py | 22 ++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/ansys/fluent/core/services/reduction.py b/src/ansys/fluent/core/services/reduction.py index a725d0f30fe..5b9a88b6fa0 100644 --- a/src/ansys/fluent/core/services/reduction.py +++ b/src/ansys/fluent/core/services/reduction.py @@ -300,7 +300,7 @@ def centroid(self, locations, ctxt=None) -> Any: request = ReductionProtoModule.CentroidRequest() request.locations.extend(self._get_location_string(locations, ctxt)) response = self.service.centroid(request) - return response.value + return (response.value.x, response.value.y, response.value.z) def count(self, locations, ctxt=None) -> Any: """Get count.""" @@ -322,7 +322,7 @@ def force(self, locations, ctxt=None) -> Any: request = ReductionProtoModule.ForceRequest() request.locations.extend(self._get_location_string(locations, ctxt)) response = self.service.force(request) - return response.value + return (response.value.x, response.value.y, response.value.z) def mass_average(self, expression, locations, ctxt=None) -> Any: """Get mass average.""" @@ -385,14 +385,14 @@ def pressure_force(self, locations, ctxt=None) -> Any: request = ReductionProtoModule.PressureForceRequest() request.locations.extend(self._get_location_string(locations, ctxt)) response = self.service.pressure_force(request) - return response.value + return (response.value.x, response.value.y, response.value.z) def viscous_force(self, locations, ctxt=None) -> Any: """Get viscous force.""" request = ReductionProtoModule.ViscousForceRequest() request.locations.extend(self._get_location_string(locations, ctxt)) response = self.service.viscous_force(request) - return response.value + return (response.value.x, response.value.y, response.value.z) def volume(self, locations, ctxt=None) -> Any: """Get volume.""" @@ -423,7 +423,7 @@ def moment(self, expression, locations, ctxt=None) -> Any: request.expression = expression request.locations.extend(self._get_location_string(locations, ctxt)) response = self.service.moment(request) - return response.value + return (response.value.x, response.value.y, response.value.z) def sum(self, expression, locations, weight, ctxt=None) -> Any: """Get sum.""" diff --git a/tests/test_reduction.py b/tests/test_reduction.py index 17980815ea2..cf0ed8d29cf 100644 --- a/tests/test_reduction.py +++ b/tests/test_reduction.py @@ -163,9 +163,9 @@ def _test_centroid(solver): red_val_1 = solver.fields.reduction.centroid(locations=[velocity_inlet["inlet1"]]) red_val_2 = solver.fields.reduction.centroid(locations=[velocity_inlet["inlet2"]]) red_val_3 = solver.fields.reduction.centroid(locations=[velocity_inlet]) - assert [red_val_1.x, red_val_1.y, red_val_1.z] == expr_val_1 - assert [red_val_2.x, red_val_2.y, red_val_2.z] == expr_val_2 - assert [red_val_3.x, red_val_3.y, red_val_3.z] == expr_val_3 + assert [red_val_1[0], red_val_1[1], red_val_1[2]] == expr_val_1 + assert [red_val_2[0], red_val_2[1], red_val_2[2]] == expr_val_2 + assert [red_val_3[0], red_val_3[1], red_val_3[2]] == expr_val_3 solver_named_expressions.pop(key="test_expr_1") @@ -284,13 +284,13 @@ def _test_force(solver): locations=[solver.setup.boundary_conditions.wall] ) - assert [red_total_force.x, red_total_force.y, red_total_force.z] == expr_val_1 + assert [red_total_force[0], red_total_force[1], red_total_force[2]] == expr_val_1 - assert red_pressure_force.x + red_viscous_force.x == red_total_force.x + assert red_pressure_force[0] + red_viscous_force[0] == red_total_force[0] - assert red_pressure_force.y + red_viscous_force.y == red_total_force.y + assert red_pressure_force[1] + red_viscous_force[1] == red_total_force[1] - assert red_pressure_force.z + red_viscous_force.z == red_total_force.z + assert red_pressure_force[2] + red_viscous_force[2] == red_total_force[2] solver_named_expressions.pop(key="test_expr_1") @@ -316,11 +316,11 @@ def _test_moment(solver): expression="['inlet1']", locations=[location] ) - assert [red_moment_force.x, red_moment_force.y, red_moment_force.z] == expr_val_1 + assert [red_moment_force[0], red_moment_force[1], red_moment_force[2]] == expr_val_1 assert [ - red_moment_location.x, - red_moment_location.y, - red_moment_location.z, + red_moment_location[0], + red_moment_location[1], + red_moment_location[2], ] == expr_val_2 solver_named_expressions.pop(key="test_expr_1")