diff --git a/src/ansys/fluent/core/services/reduction.py b/src/ansys/fluent/core/services/reduction.py index 1a4c9a3202a..412a0546567 100644 --- a/src/ansys/fluent/core/services/reduction.py +++ b/src/ansys/fluent/core/services/reduction.py @@ -263,6 +263,8 @@ def _validate_str_location(self, loc: str): raise ValueError(f"Invalid location input: '{loc}'") def _get_location_string(self, locations, ctxt) -> List[str]: + if locations == []: + return [] for loc in locations: if isinstance(loc, str): self._validate_str_location(loc) diff --git a/src/ansys/fluent/core/solver/flobject.py b/src/ansys/fluent/core/solver/flobject.py index b987300dcd8..21633031393 100644 --- a/src/ansys/fluent/core/solver/flobject.py +++ b/src/ansys/fluent/core/solver/flobject.py @@ -470,6 +470,8 @@ def _while_executing_command(self): return nullcontext() def __eq__(self, other): + if not isinstance(other, self.__class__): + return False return self.flproxy == other.flproxy and self.path == other.path diff --git a/src/ansys/fluent/core/solver/function/reduction.py b/src/ansys/fluent/core/solver/function/reduction.py index 8f12d93f241..646d89eca6f 100644 --- a/src/ansys/fluent/core/solver/function/reduction.py +++ b/src/ansys/fluent/core/solver/function/reduction.py @@ -123,6 +123,9 @@ def _validate_locn_list(locn_list, ctxt): def _locns(locns, ctxt): + if locns == []: + # Raising 'RuntimeError' instead of 'ValueError' to address a limitation in the server-side implementation. + raise RuntimeError("No locations specified.") locn_names_and_objs = _locn_names_and_objs(locns) locn_list = [] for name, obj in locn_names_and_objs: diff --git a/tests/test_reduction.py b/tests/test_reduction.py index eea6090217a..405174801ad 100644 --- a/tests/test_reduction.py +++ b/tests/test_reduction.py @@ -452,3 +452,33 @@ def test_fix_for_invalid_location_inputs(static_mixer_case_session: Any): with pytest.raises(ValueError): assert solver.fields.reduction.area(locations=["inlet-1"]) + + +@pytest.mark.fluent_version(">=25.2") +def test_fix_for_empty_location_inputs(static_mixer_case_session: Any): + solver = static_mixer_case_session + solver.solution.initialization.hybrid_initialize() + + assert solver.fields.reduction.area(locations=["inlet1"]) + + with pytest.raises(RuntimeError): + assert reduction.area(locations=[], ctxt=solver) + + with pytest.raises(RuntimeError): + assert reduction.area_average( + expression="AbsolutePressure", locations=[], ctxt=solver + ) + + with pytest.raises(RuntimeError): + assert reduction.centroid(locations=[], ctxt=solver) + + with pytest.raises(RuntimeError): + assert solver.fields.reduction.area(locations=[]) + + with pytest.raises(RuntimeError): + assert solver.fields.reduction.area_average( + expression="AbsolutePressure", locations=[] + ) + + with pytest.raises(RuntimeError): + assert solver.fields.reduction.centroid(locations=[])