Skip to content

Commit

Permalink
Modify CFF tests to be consistent with CFX zone refactoring (#549)
Browse files Browse the repository at this point in the history
* Modify CFF tests to be consistent with CFX zone refactoring

* style check

* Update the PR : don't break retro compatibility

* Remove unneeded screen display
  • Loading branch information
MichaelNale authored Nov 23, 2023
1 parent d836b3d commit 6f656d4
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 53 deletions.
4 changes: 4 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def grpc_server():
server.shutdown()


SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0 = meets_version(
get_server_version(core._global_server()), "8.0"
)

SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1 = meets_version(
get_server_version(core._global_server()), "7.1"
)
Expand Down
108 changes: 55 additions & 53 deletions tests/test_streamlines.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

from ansys.dpf import post
from ansys.dpf.post import examples

# from ansys.dpf.post.helpers import streamlines
from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0
from ansys.dpf.post.helpers import streamlines
from conftest import (
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0,
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0,
)


@pytest.mark.skipif(
Expand All @@ -17,53 +19,53 @@ def simulation(self) -> post.FluidSimulation:
files_cfx = examples.download_cfx_heating_coil()
return post.FluidSimulation(cas=files_cfx["cas"], dat=files_cfx["dat"]) # noqa

# def test_plot_streamlines(self, simulation):
# # import pyvista as pv
# #
# # pv.OFF_SCREEN = False
# dataframe = simulation.velocity(times=[0.0], zone_ids=[5])
# sources = [
# {"radius": 0.25, "center": (0.75, 0.0, 0.0), "n_points": 20},
# {
# "radius": 0.25,
# "center": (0.0, 0.75, 0.0),
# "n_points": 5,
# "max_time": 10.0,
# },
# {"radius": 0.25, "center": (-0.75, 0.0, 0.0), "max_time": 2.0},
# {"radius": 0.25, "center": (0.0, -0.75, 0.0)},
# ]
# streamlines.plot_streamlines(
# dataframe=dataframe,
# sources=sources,
# streamline_thickness=0.007,
# plot_mesh=True,
# mesh_opacity=0.2,
# plot_contour=True,
# contour_opacity=0.3,
# title="Streamlines with multiple sources",
# )
# dataframe = simulation.velocity()
# with pytest.raises(ValueError, match="The set_id requested is not available"):
# streamlines.plot_streamlines(
# dataframe=dataframe,
# sources=sources,
# set_id=2,
# streamline_thickness=0.007,
# plot_mesh=True,
# mesh_opacity=0.2,
# plot_contour=True,
# contour_opacity=0.3,
# title="Streamlines with multiple sources",
# )
# streamlines.plot_streamlines(
# dataframe=dataframe,
# sources=sources,
# set_id=1,
# streamline_thickness=0.007,
# plot_mesh=True,
# mesh_opacity=0.2,
# plot_contour=True,
# contour_opacity=0.3,
# title="Streamlines with multiple sources",
# )
def test_plot_streamlines(self, simulation):
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0:
dataframe = simulation.velocity(times=[0.0], zone_ids=[1])
else:
dataframe = simulation.velocity(times=[0.0], zone_ids=[5])
sources = [
{"radius": 0.25, "center": (0.75, 0.0, 0.0), "n_points": 20},
{
"radius": 0.25,
"center": (0.0, 0.75, 0.0),
"n_points": 5,
"max_time": 10.0,
},
{"radius": 0.25, "center": (-0.75, 0.0, 0.0), "max_time": 2.0},
{"radius": 0.25, "center": (0.0, -0.75, 0.0)},
]
streamlines.plot_streamlines(
dataframe=dataframe,
sources=sources,
streamline_thickness=0.007,
plot_mesh=True,
mesh_opacity=0.2,
plot_contour=True,
contour_opacity=0.3,
title="Streamlines with multiple sources",
)
dataframe = simulation.velocity()
with pytest.raises(ValueError, match="The set_id requested is not available"):
streamlines.plot_streamlines(
dataframe=dataframe,
sources=sources,
set_id=2,
streamline_thickness=0.007,
plot_mesh=True,
mesh_opacity=0.2,
plot_contour=True,
contour_opacity=0.3,
title="Streamlines with multiple sources",
)
streamlines.plot_streamlines(
dataframe=dataframe,
sources=sources,
set_id=1,
streamline_thickness=0.007,
plot_mesh=True,
mesh_opacity=0.2,
plot_contour=True,
contour_opacity=0.3,
title="Streamlines with multiple sources",
)

0 comments on commit 6f656d4

Please sign in to comment.