Skip to content
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
5 changes: 3 additions & 2 deletions src/ansys/dpf/core/result_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class physics_types(Enum):
magnetic = 2
electric = 3
unknown_physics = 4
fluid = 5


@unique
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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")
Expand Down
68 changes: 44 additions & 24 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
72 changes: 68 additions & 4 deletions tests/test_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion tests/test_resultinfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down