Skip to content

Commit 59fec46

Browse files
committed
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualization into main
2 parents 4b62bf5 + 22b3187 commit 59fec46

File tree

18 files changed

+474
-111
lines changed

18 files changed

+474
-111
lines changed

.github/workflows/ci_cd.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
strategy:
4343
matrix:
4444
os: [windows-latest, ubuntu-latest]
45-
python-version: ['3.10', '3.11', '3.12']
45+
python-version: ['3.10', '3.11', '3.12', '3.13']
4646
fail-fast: false
4747

4848
steps:

.github/workflows/nightly-test-run.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
strategy:
1313
matrix:
1414
os: [windows-latest, ubuntu-latest]
15-
python-version: ['3.10', '3.11', '3.12']
15+
python-version: ['3.10', '3.11', '3.12', '3.13']
1616
fail-fast: false
1717

1818
steps:

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ the project support team, email `[email protected] <[email protected]>
5151
Installation
5252
------------
5353
The ``ansys-fluent-visualization`` package supports Python 3.10 through Python
54-
3.12 on Windows and Linux.
54+
3.13 on Windows and Linux.
5555

5656
If you are using Python 3.10, download and install the wheel file for the ``vtk`` package from
5757
`here for Windows <https://github.com/pyvista/pyvista-wheels/raw/main/vtk-9.1.0.dev0-cp310-cp310-win_amd64.whl>`_

doc/source/getting_started/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ page on the Ansys website.
1414
Install package
1515
***************
1616
The ``ansys-fluent-visualization`` package supports Python 3.10 through
17-
Python 3.12 on Windows and Linux.
17+
Python 3.13 on Windows and Linux.
1818

1919
Install the latest release from `PyPi
2020
<https://pypi.org/project/ansys-fluent-visualization/>`_ with:

examples/00-postprocessing/updated_exhaust_manifold_example.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
Mesh,
4141
Monitor,
4242
Pathline,
43-
PlotterWindow,
4443
Surface,
4544
Vector,
4645
XYPlot,
@@ -252,8 +251,8 @@
252251
surfaces=["outlet"],
253252
y_axis_function="temperature",
254253
)
255-
p7 = PlotterWindow(grid=(2, 2))
256-
p7.add_plots(xy_plot, position=(0, 0))
254+
p7 = GraphicsWindow(grid=(2, 2))
255+
p7.add_graphics(xy_plot, position=(0, 0))
257256

258257
###############################################################################
259258
# Create residual plot
@@ -262,7 +261,7 @@
262261

263262
residual = Monitor(solver=solver_session)
264263
residual.monitor_set_name = "residual"
265-
p7.add_plots(residual, position=(0, 1))
264+
p7.add_graphics(residual, position=(0, 1))
266265

267266
###############################################################################
268267
# Solve and plot solution monitors
@@ -274,10 +273,10 @@
274273

275274
mass_bal_rplot = Monitor(solver=solver_session)
276275
mass_bal_rplot.monitor_set_name = "mass-bal-rplot"
277-
p7.add_plots(mass_bal_rplot, position=(1, 0))
276+
p7.add_graphics(mass_bal_rplot, position=(1, 0))
278277

279278
point_vel_rplot = Monitor(solver=solver_session, monitor_set_name="point-vel-rplot")
280-
p7.add_plots(point_vel_rplot, position=(1, 1))
279+
p7.add_graphics(point_vel_rplot, position=(1, 1))
281280
p7.show()
282281

283282
###############################################################################

examples/00-postprocessing/updated_script_manifold_example.py

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
Mesh,
4444
Monitor,
4545
Pathline,
46-
PlotterWindow,
4746
Surface,
4847
Vector,
4948
XYPlot,
@@ -78,27 +77,27 @@
7877

7978
p1 = XYPlot(solver=session, surfaces=["solid_up:1:830"])
8079
p1.y_axis_function = "temperature"
81-
p_xy = PlotterWindow()
82-
p_xy.add_plots(p1)
80+
p_xy = GraphicsWindow()
81+
p_xy.add_graphics(p1)
8382
p_xy.show()
8483

8584
session.monitors.get_monitor_set_names()
8685
residual = Monitor(solver=session)
8786
residual.monitor_set_name = "residual"
88-
p_res = PlotterWindow()
89-
p_res.add_plots(residual)
87+
p_res = GraphicsWindow()
88+
p_res.add_graphics(residual)
9089
p_res.show()
9190

9291
mtr = Monitor(solver=session)
9392
mtr.monitor_set_name = "mass-tot-rplot"
94-
p_mtr = PlotterWindow()
95-
p_mtr.add_plots(mtr)
93+
p_mtr = GraphicsWindow()
94+
p_mtr.add_graphics(mtr)
9695
p_mtr.show()
9796

9897
mbr = Monitor(solver=session)
9998
mbr.monitor_set_name = "mass-bal-rplot"
100-
p_mbr = PlotterWindow()
101-
p_mbr.add_plots(mbr)
99+
p_mbr = GraphicsWindow()
100+
p_mbr.add_graphics(mbr)
102101
p_mbr.show()
103102

104103
p_mesh = GraphicsWindow()
@@ -121,21 +120,20 @@
121120
p_surf.show()
122121

123122

124-
def auto_refersh_call_back_iteration(session_id, event_info):
125-
if event_info.index % 1 == 0:
126-
p_cont.refresh_windows(session_id)
127-
p_res.refresh_windows(session_id)
128-
p_mtr.refresh_windows(session_id)
129-
p_mbr.refresh_windows(session_id)
123+
def auto_refersh_call_back_iteration(session, event_info):
124+
p_cont.refresh_windows(session.id)
125+
p_res.refresh_windows(session.id)
126+
p_mtr.refresh_windows(session.id)
127+
p_mbr.refresh_windows(session.id)
130128

131129

132-
def auto_refersh_call_back_time_step(session_id, event_info):
133-
p_res.refresh_windows(session_id)
130+
def auto_refersh_call_back_time_step(session, event_info):
131+
p_res.refresh_windows(session.id)
134132

135133

136-
def initialize_call_back(session_id, event_info):
137-
p_res.refresh_windows(session_id)
138-
p_mtr.refresh_windows(session_id)
134+
def initialize_call_back(session, event_info):
135+
p_res.refresh_windows(session.id)
136+
p_mtr.refresh_windows(session.id)
139137

140138

141139
cb_init_id = session.events.register_callback("InitializedEvent", initialize_call_back)

pyproject.toml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,14 @@ packages = [
2525
[tool.poetry.dependencies]
2626
python = ">=3.10,<4.0"
2727
importlib-metadata = {version = "^4.0", python = "<3.9"}
28-
ansys-fluent-core = "~=0.28.dev0"
29-
pyvista = "~=0.44.1"
28+
ansys-fluent-core = "~=0.29.dev0"
29+
pyvista = { version = ">=0.44.0", extras = ["jupyter"]}
30+
matplotlib = ">=3.6.0"
31+
vtk = {version = "<9.4.0", python = "<3.13"}
3032
pyvistaqt = "~=0.11.1"
31-
pyside6 = "~=6.7.2"
32-
matplotlib = ">=3.9.0"
33+
pyside6 = "~=6.8.1"
34+
plotly = ">=5.24.0"
35+
imageio= ">=2.36.1"
3336

3437
[tool.poetry.urls]
3538
"Documentation" = "https://visualization.fluent.docs.pyansys.com/"

src/ansys/fluent/visualization/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
_VERSION_INFO = None
99
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
1010
PLOTTER = "matplotlib"
11+
INTERACTIVE = False
1112

1213

1314
def version_info() -> str:

src/ansys/fluent/visualization/_config.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@ def get_config() -> dict:
1111
config : dict
1212
Keys are parameter names that can be passed to :func:`set_config`.
1313
"""
14+
import ansys.fluent.visualization as pyviz
15+
16+
_global_config["blocking"] = not pyviz.INTERACTIVE
1417
return _global_config.copy()
1518

1619

17-
def set_config(blocking: bool = True, set_view_on_display: str = "isometric"):
20+
def set_config(blocking: bool = False, set_view_on_display: str = "isometric"):
1821
"""Set visualization configuration.
1922
2023
Parameters

src/ansys/fluent/visualization/graphics/graphics_windows.py

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"""A wrapper to improve the user interface of graphics."""
22

3+
from ansys.fluent.visualization import get_config
34
from ansys.fluent.visualization.graphics import graphics_windows_manager
5+
from ansys.fluent.visualization.plotter.plotter_windows import PlotterWindow
46

57

68
class GraphicsWindow:
@@ -14,6 +16,7 @@ def add_graphics(
1416
object,
1517
position: tuple = (0, 0),
1618
opacity: float = 1,
19+
title: str = "",
1720
) -> None:
1821
"""Add data to a plot.
1922
@@ -25,27 +28,43 @@ def add_graphics(
2528
Position of the sub-plot.
2629
opacity: float, optional
2730
Transparency of the sub-plot.
31+
title: str, optional
32+
Title of the sub-plot (only for plots).
2833
"""
2934
self._graphics_objs.append({**locals()})
3035

36+
def _all_plt_objs(self):
37+
from ansys.fluent.core.post_objects.post_object_definitions import PlotDefn
38+
39+
for obj in self._graphics_objs:
40+
if not isinstance(obj["object"].obj, PlotDefn):
41+
return False
42+
return True
43+
3144
def show(self) -> None:
3245
"""Render the objects in window and display the same."""
3346
self.window_id = graphics_windows_manager.open_window(grid=self._grid)
34-
self.graphics_window = graphics_windows_manager._post_windows.get(
35-
self.window_id
36-
)
37-
self._renderer = self.graphics_window.renderer
38-
self.plotter = self.graphics_window.renderer.plotter
39-
for i in range(len(self._graphics_objs)):
40-
graphics_windows_manager.add_graphics(
41-
object=self._graphics_objs[i]["object"].obj,
42-
window_id=self.window_id,
43-
fetch_data=True,
44-
overlay=True,
45-
position=self._graphics_objs[i]["position"],
46-
opacity=self._graphics_objs[i]["opacity"],
47+
if self._all_plt_objs() and get_config()["blocking"]:
48+
p = PlotterWindow(grid=self._grid)
49+
for obj in self._graphics_objs:
50+
p.add_plots(obj["object"], position=obj["position"], title=obj["title"])
51+
p.show(self.window_id)
52+
else:
53+
self.graphics_window = graphics_windows_manager._post_windows.get(
54+
self.window_id
4755
)
48-
graphics_windows_manager.show_graphics(self.window_id)
56+
self._renderer = self.graphics_window.renderer
57+
self.plotter = self.graphics_window.renderer.plotter
58+
for i in range(len(self._graphics_objs)):
59+
graphics_windows_manager.add_graphics(
60+
object=self._graphics_objs[i]["object"].obj,
61+
window_id=self.window_id,
62+
fetch_data=True,
63+
overlay=True,
64+
position=self._graphics_objs[i]["position"],
65+
opacity=self._graphics_objs[i]["opacity"],
66+
)
67+
graphics_windows_manager.show_graphics(self.window_id)
4968

5069
def save_graphic(
5170
self,

0 commit comments

Comments
 (0)