diff --git a/src/ansys/dpf/core/result_info.py b/src/ansys/dpf/core/result_info.py index 0ca10f0ad92..d860fe96273 100644 --- a/src/ansys/dpf/core/result_info.py +++ b/src/ansys/dpf/core/result_info.py @@ -37,6 +37,7 @@ class physics_types(Enum): magnetic = 2 electric = 3 unknown_physics = 4 + fluid = 5 @unique @@ -256,7 +257,7 @@ def solver_version(self): """Version of the solver.""" major = integral_types.MutableInt32() minor = integral_types.MutableInt32() - res = self._api.result_info_get_solver_version(self, major, minor) + _ = self._api.result_info_get_solver_version(self, major, minor) return str(int(major)) + "." + str(int(minor)) @property @@ -388,7 +389,7 @@ def _get_result(self, numres): ) qualifiers.append(label_space) label_space_dict = label_space.__dict__() - for key in label_space_dict: + for key in label_space_dict.keys(): value = label_space_dict[key] label_support = self.qualifier_label_support(key) names_field = label_support.string_field_support_by_property("names") diff --git a/tests/conftest.py b/tests/conftest.py index e6e03a677a1..f4e7cedd4d9 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -232,42 +232,62 @@ def return_ds(server=None): @pytest.fixture() def fluent_mixing_elbow_steady_state(): - """Create a data sources with a cas and a dat file of fluent mixing elbow steady-state case.""" - ds = core.DataSources() - files = examples.download_fluent_mixing_elbow_steady_state() - ds.set_result_file_path(files["cas"][0], "cas") - ds.add_file_path(files["dat"][0], "dat") - return ds + """Return a function which creates a data sources + with a cas and a dat file of fluent mixing elbow steady-state case.""" + + def return_ds(server=None): + ds = core.DataSources(server=server) + files = examples.download_fluent_mixing_elbow_steady_state(server=server) + ds.set_result_file_path(files["cas"][0], "cas") + ds.add_file_path(files["dat"][0], "dat") + return ds + + return return_ds @pytest.fixture() def fluent_mixing_elbow_transient(): - """Create a data sources with a cas and a dat file of fluent mixing elbow transient case.""" - ds = core.DataSources() - files = examples.download_fluent_mixing_elbow_transient() - ds.set_result_file_path(files["cas"][0], "cas") - ds.add_file_path(files["dat"][0], "dat") - return ds + """Return a function which creates a data sources + with a cas and a dat file of fluent mixing elbow transient case.""" + + def return_ds(server=None): + ds = core.DataSources(server=server) + files = examples.download_fluent_mixing_elbow_transient(server=server) + ds.set_result_file_path(files["cas"][0], "cas") + ds.add_file_path(files["dat"][0], "dat") + return ds + + return return_ds @pytest.fixture() def cfx_heating_coil(): - """Create a data sources with a cas and a dat file of CFX heating coil case.""" - ds = core.DataSources() - files = examples.download_cfx_heating_coil() - ds.set_result_file_path(files["cas"], "cas") - ds.add_file_path(files["dat"], "dat") - return ds + """Return a function which creates a data sources + with a cas and a dat file of CFX heating coil case.""" + + def return_ds(server=None): + ds = core.DataSources(server=server) + files = examples.download_cfx_heating_coil(server=server) + ds.set_result_file_path(files["cas"], "cas") + ds.add_file_path(files["dat"], "dat") + return ds + + return return_ds @pytest.fixture() def cfx_mixing_elbow(): - """Create a data sources with a cas and a dat file of CFX mixing elbow case.""" - ds = core.DataSources() - files = examples.download_cfx_mixing_elbow() - ds.set_result_file_path(files["cas"], "cas") - ds.add_file_path(files["dat"], "dat") - return ds + """Return a function which creates a data sources + with a cas and a dat file of CFX mixing elbow case.""" + + def return_ds(server=None): + ds = core.DataSources(server=server) + files = examples.download_cfx_mixing_elbow(server=server) + ds.set_result_file_path(files["cas"], "cas") + ds.add_file_path(files["dat"], "dat") + return ds + + return return_ds SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0 = meets_version( diff --git a/tests/test_cff.py b/tests/test_cff.py index a47820703a8..80cc641fcd2 100644 --- a/tests/test_cff.py +++ b/tests/test_cff.py @@ -7,10 +7,74 @@ not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, reason="CFF source operators where not supported before 7.0,", ) -def test_cff_model_grpc_servers(server_type, fluent_multi_species): +def test_cff_model(server_type, fluent_multi_species): ds = fluent_multi_species(server_type) model = dpf.Model(ds, server=server_type) - print(model) + assert "Fluid" in str(model) assert model is not None - m = model.metadata.meshed_region - print(m) + mesh = model.metadata.meshed_region + assert "faces" in str(mesh) + + +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="CFF source operators where not supported before 7.0,", +) +def test_results_cfx(cfx_heating_coil, server_type): + model = dpf.Model(cfx_heating_coil(server=server_type), server=server_type) + print(model) + result_names = [ + "specific_heat", + "epsilon", + "enthalpy", + "turbulent_kinetic_energy", + "thermal_conductivity", + "dynamic_viscosity", + "turbulent_viscosity", + "static_pressure", + "total_pressure", + "density", + "entropy", + "wall_shear_stress", + "temperature", + "total_temperature", + "velocity", + ] + for result_name in result_names: + result_op = getattr(model.results, result_name)() + result = result_op.eval() + assert isinstance(result, dpf.FieldsContainer) + result_op.connect(1000, {"phase": 2}) + result = result_op.eval() + assert isinstance(result, dpf.FieldsContainer) + + +@pytest.mark.skipif( + not conftest.SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, + reason="CFF source operators where not supported before 7.0,", +) +def test_results_fluent(fluent_mixing_elbow_steady_state, server_type): + model = dpf.Model(fluent_mixing_elbow_steady_state(server=server_type), server=server_type) + print(model) + result_names = [ + "epsilon", + "enthalpy", + "turbulent_kinetic_energy", + "mach_number", + "mass_flow_rate", + "dynamic_viscosity", + "turbulent_viscosity", + "static_pressure", + "surface_heat_rate", + "density", + "temperature", + "velocity", + "y_plus", + ] + for result_name in result_names: + result_op = getattr(model.results, result_name)() + result = result_op.eval() + assert isinstance(result, dpf.FieldsContainer) + result_op.connect(1000, {"phase": 1}) + result = result_op.eval() + assert isinstance(result, dpf.FieldsContainer) diff --git a/tests/test_resultinfo.py b/tests/test_resultinfo.py index 5f428bb6299..acc9b48a982 100644 --- a/tests/test_resultinfo.py +++ b/tests/test_resultinfo.py @@ -87,7 +87,7 @@ def test_repr_available_results_list(model): not SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0, reason="Available with CFF starting 7.0" ) def test_print_available_result_with_qualifiers(cfx_heating_coil): - model = Model(cfx_heating_coil) + model = Model(cfx_heating_coil()) ref = """DPF Result ---------- specific_heat