Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Convert protobuf Point to python Vector. #3239

Merged
merged 6 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions src/ansys/fluent/core/services/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand All @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down Expand Up @@ -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."""
Expand Down
22 changes: 11 additions & 11 deletions tests/test_reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down Expand Up @@ -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")

Expand All @@ -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")
Expand Down
Loading