Skip to content

Commit 6f656d4

Browse files
authored
Modify CFF tests to be consistent with CFX zone refactoring (#549)
* Modify CFF tests to be consistent with CFX zone refactoring * style check * Update the PR : don't break retro compatibility * Remove unneeded screen display
1 parent d836b3d commit 6f656d4

File tree

2 files changed

+59
-53
lines changed

2 files changed

+59
-53
lines changed

tests/conftest.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,10 @@ def grpc_server():
204204
server.shutdown()
205205

206206

207+
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0 = meets_version(
208+
get_server_version(core._global_server()), "8.0"
209+
)
210+
207211
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_1 = meets_version(
208212
get_server_version(core._global_server()), "7.1"
209213
)

tests/test_streamlines.py

Lines changed: 55 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
from ansys.dpf import post
44
from ansys.dpf.post import examples
5-
6-
# from ansys.dpf.post.helpers import streamlines
7-
from conftest import SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0
5+
from ansys.dpf.post.helpers import streamlines
6+
from conftest import (
7+
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_7_0,
8+
SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0,
9+
)
810

911

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

20-
# def test_plot_streamlines(self, simulation):
21-
# # import pyvista as pv
22-
# #
23-
# # pv.OFF_SCREEN = False
24-
# dataframe = simulation.velocity(times=[0.0], zone_ids=[5])
25-
# sources = [
26-
# {"radius": 0.25, "center": (0.75, 0.0, 0.0), "n_points": 20},
27-
# {
28-
# "radius": 0.25,
29-
# "center": (0.0, 0.75, 0.0),
30-
# "n_points": 5,
31-
# "max_time": 10.0,
32-
# },
33-
# {"radius": 0.25, "center": (-0.75, 0.0, 0.0), "max_time": 2.0},
34-
# {"radius": 0.25, "center": (0.0, -0.75, 0.0)},
35-
# ]
36-
# streamlines.plot_streamlines(
37-
# dataframe=dataframe,
38-
# sources=sources,
39-
# streamline_thickness=0.007,
40-
# plot_mesh=True,
41-
# mesh_opacity=0.2,
42-
# plot_contour=True,
43-
# contour_opacity=0.3,
44-
# title="Streamlines with multiple sources",
45-
# )
46-
# dataframe = simulation.velocity()
47-
# with pytest.raises(ValueError, match="The set_id requested is not available"):
48-
# streamlines.plot_streamlines(
49-
# dataframe=dataframe,
50-
# sources=sources,
51-
# set_id=2,
52-
# streamline_thickness=0.007,
53-
# plot_mesh=True,
54-
# mesh_opacity=0.2,
55-
# plot_contour=True,
56-
# contour_opacity=0.3,
57-
# title="Streamlines with multiple sources",
58-
# )
59-
# streamlines.plot_streamlines(
60-
# dataframe=dataframe,
61-
# sources=sources,
62-
# set_id=1,
63-
# streamline_thickness=0.007,
64-
# plot_mesh=True,
65-
# mesh_opacity=0.2,
66-
# plot_contour=True,
67-
# contour_opacity=0.3,
68-
# title="Streamlines with multiple sources",
69-
# )
22+
def test_plot_streamlines(self, simulation):
23+
if SERVERS_VERSION_GREATER_THAN_OR_EQUAL_TO_8_0:
24+
dataframe = simulation.velocity(times=[0.0], zone_ids=[1])
25+
else:
26+
dataframe = simulation.velocity(times=[0.0], zone_ids=[5])
27+
sources = [
28+
{"radius": 0.25, "center": (0.75, 0.0, 0.0), "n_points": 20},
29+
{
30+
"radius": 0.25,
31+
"center": (0.0, 0.75, 0.0),
32+
"n_points": 5,
33+
"max_time": 10.0,
34+
},
35+
{"radius": 0.25, "center": (-0.75, 0.0, 0.0), "max_time": 2.0},
36+
{"radius": 0.25, "center": (0.0, -0.75, 0.0)},
37+
]
38+
streamlines.plot_streamlines(
39+
dataframe=dataframe,
40+
sources=sources,
41+
streamline_thickness=0.007,
42+
plot_mesh=True,
43+
mesh_opacity=0.2,
44+
plot_contour=True,
45+
contour_opacity=0.3,
46+
title="Streamlines with multiple sources",
47+
)
48+
dataframe = simulation.velocity()
49+
with pytest.raises(ValueError, match="The set_id requested is not available"):
50+
streamlines.plot_streamlines(
51+
dataframe=dataframe,
52+
sources=sources,
53+
set_id=2,
54+
streamline_thickness=0.007,
55+
plot_mesh=True,
56+
mesh_opacity=0.2,
57+
plot_contour=True,
58+
contour_opacity=0.3,
59+
title="Streamlines with multiple sources",
60+
)
61+
streamlines.plot_streamlines(
62+
dataframe=dataframe,
63+
sources=sources,
64+
set_id=1,
65+
streamline_thickness=0.007,
66+
plot_mesh=True,
67+
mesh_opacity=0.2,
68+
plot_contour=True,
69+
contour_opacity=0.3,
70+
title="Streamlines with multiple sources",
71+
)

0 commit comments

Comments
 (0)