ansys-fluent-visualization 0.18.dev0__tar.gz → 0.19.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/PKG-INFO +3 -5
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/pyproject.toml +3 -5
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/__init__.py +2 -2
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/_config.py +9 -2
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/graphics_windows.py +93 -6
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py +5 -21
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/pyvista/graphics_defns.py +7 -2
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/AUTHORS +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/LICENSE +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/README.rst +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/containers.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/contour.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/abstract_graphics_defns.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/graphics_objects.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/graphics/pyvista/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/matplotlib/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/abstract_plotter_defns.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/matplotlib/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/matplotlib/plotter_defns.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/plotly/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/plotly/plotter_defns.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/plotter_objects.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/plotter_windows.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/plotter_windows_manager.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/pyvista/__init__.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/plotter/pyvista/plotter_defns.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/post_data_extractor.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/post_windows_manager.py +0 -0
- {ansys_fluent_visualization-0.18.dev0 → ansys_fluent_visualization-0.19.0}/src/ansys/fluent/visualization/pyvista/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: ansys-fluent-visualization
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.19.0
|
|
4
4
|
Summary: A python wrapper for ansys Fluent visualization
|
|
5
5
|
License: MIT
|
|
6
6
|
Author: ANSYS, Inc.
|
|
@@ -16,15 +16,13 @@ Classifier: Programming Language :: Python :: 3.10
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.11
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.12
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
-
Requires-Dist: ansys-fluent-core (
|
|
19
|
+
Requires-Dist: ansys-fluent-core (==0.30.0)
|
|
20
20
|
Requires-Dist: imageio (>=2.36.1)
|
|
21
21
|
Requires-Dist: importlib-metadata (>=4.0,<5.0) ; python_version < "3.9"
|
|
22
22
|
Requires-Dist: matplotlib (>=3.6.0)
|
|
23
|
-
Requires-Dist: plotly (>=5.24.0)
|
|
24
23
|
Requires-Dist: pyside6 (>=6.8.1,<6.9.0)
|
|
25
|
-
Requires-Dist: pyvista
|
|
24
|
+
Requires-Dist: pyvista (>=0.44.0)
|
|
26
25
|
Requires-Dist: pyvistaqt (>=0.11.1,<0.12.0)
|
|
27
|
-
Requires-Dist: vtk (<9.4.0) ; python_version < "3.13"
|
|
28
26
|
Project-URL: Documentation, https://visualization.fluent.docs.pyansys.com/
|
|
29
27
|
Project-URL: Repository, https://github.com/ansys/pyfluent-visualization
|
|
30
28
|
Project-URL: Source, https://github.com/ansys/pyfluent-visualization
|
|
@@ -5,7 +5,7 @@ build-backend = "poetry.core.masonry.api"
|
|
|
5
5
|
[tool.poetry]
|
|
6
6
|
# Check https://python-poetry.org/docs/pyproject/ for all available sections
|
|
7
7
|
name = "ansys-fluent-visualization"
|
|
8
|
-
version = "0.
|
|
8
|
+
version = "0.19.0"
|
|
9
9
|
description = "A python wrapper for ansys Fluent visualization"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = ["ANSYS, Inc. <ansys.support@ansys.com>"]
|
|
@@ -25,13 +25,11 @@ packages = [
|
|
|
25
25
|
[tool.poetry.dependencies]
|
|
26
26
|
python = ">=3.10,<4.0"
|
|
27
27
|
importlib-metadata = {version = "^4.0", python = "<3.9"}
|
|
28
|
-
ansys-fluent-core = "
|
|
29
|
-
pyvista =
|
|
28
|
+
ansys-fluent-core = "==0.30.0"
|
|
29
|
+
pyvista = ">=0.44.0"
|
|
30
30
|
matplotlib = ">=3.6.0"
|
|
31
|
-
vtk = {version = "<9.4.0", python = "<3.13"}
|
|
32
31
|
pyvistaqt = "~=0.11.1"
|
|
33
32
|
pyside6 = "~=6.8.1"
|
|
34
|
-
plotly = ">=5.24.0"
|
|
35
33
|
imageio= ">=2.36.1"
|
|
36
34
|
|
|
37
35
|
[tool.poetry.urls]
|
|
@@ -27,10 +27,10 @@ try:
|
|
|
27
27
|
except ModuleNotFoundError:
|
|
28
28
|
import importlib_metadata
|
|
29
29
|
|
|
30
|
-
_VERSION_INFO = "Build date:
|
|
30
|
+
_VERSION_INFO = "Build date: March 11, 2025 13:48 UTC ShaID: 837c3f6"
|
|
31
31
|
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
|
|
32
32
|
PLOTTER = "matplotlib"
|
|
33
|
-
|
|
33
|
+
SINGLE_WINDOW = False
|
|
34
34
|
|
|
35
35
|
|
|
36
36
|
def version_info() -> str:
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
"""Global configuration state for visualization."""
|
|
24
|
+
import warnings
|
|
24
25
|
|
|
25
26
|
_global_config = {"blocking": False, "set_view_on_display": None}
|
|
26
27
|
|
|
@@ -35,7 +36,8 @@ def get_config() -> dict:
|
|
|
35
36
|
"""
|
|
36
37
|
import ansys.fluent.visualization as pyviz
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
if pyviz.SINGLE_WINDOW:
|
|
40
|
+
_global_config["blocking"] = False
|
|
39
41
|
return _global_config.copy()
|
|
40
42
|
|
|
41
43
|
|
|
@@ -50,13 +52,18 @@ def set_config(blocking: bool = False, set_view_on_display: str = "isometric"):
|
|
|
50
52
|
If specified, then graphics will always be displayed in the specified view.
|
|
51
53
|
Valid values are xy, xz, yx, yz, zx, zy and isometric.
|
|
52
54
|
"""
|
|
55
|
+
import ansys.fluent.visualization as pyviz
|
|
56
|
+
|
|
53
57
|
if set_view_on_display not in set_config.allowed_views:
|
|
54
58
|
raise ValueError(
|
|
55
59
|
f"'{set_view_on_display}' is not an allowed view.\n"
|
|
56
60
|
f"Allowed views are: {set_config.allowed_views}"
|
|
57
61
|
)
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
if pyviz.SINGLE_WINDOW:
|
|
64
|
+
warnings.warn("'blocking' cannot be set from PyConsole.")
|
|
65
|
+
else:
|
|
66
|
+
_global_config["blocking"] = blocking
|
|
60
67
|
_global_config["set_view_on_display"] = set_view_on_display
|
|
61
68
|
|
|
62
69
|
|
|
@@ -21,11 +21,21 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
"""A wrapper to improve the user interface of graphics."""
|
|
24
|
+
from PySide6.QtWidgets import (
|
|
25
|
+
QApplication,
|
|
26
|
+
QMainWindow,
|
|
27
|
+
QTabWidget,
|
|
28
|
+
QVBoxLayout,
|
|
29
|
+
QWidget,
|
|
30
|
+
)
|
|
24
31
|
|
|
32
|
+
import ansys.fluent.visualization as pyviz
|
|
25
33
|
from ansys.fluent.visualization import get_config
|
|
26
34
|
from ansys.fluent.visualization.graphics import graphics_windows_manager
|
|
27
35
|
from ansys.fluent.visualization.plotter.plotter_windows import PlotterWindow
|
|
28
36
|
|
|
37
|
+
_qt_window = None
|
|
38
|
+
|
|
29
39
|
|
|
30
40
|
class GraphicsWindow:
|
|
31
41
|
def __init__(self, grid: tuple = (1, 1)):
|
|
@@ -86,26 +96,64 @@ class GraphicsWindow:
|
|
|
86
96
|
position=self._graphics_objs[i]["position"],
|
|
87
97
|
opacity=self._graphics_objs[i]["opacity"],
|
|
88
98
|
)
|
|
89
|
-
|
|
99
|
+
if pyviz.SINGLE_WINDOW:
|
|
100
|
+
global _qt_window
|
|
101
|
+
if not _qt_window:
|
|
102
|
+
QApplication.instance() or QApplication()
|
|
103
|
+
_qt_window = MainWindow()
|
|
104
|
+
_qt_window.show()
|
|
105
|
+
_qt_window._add_tab(
|
|
106
|
+
self.plotter,
|
|
107
|
+
title=self.window_id.replace(
|
|
108
|
+
self.window_id[-1], str(int(self.window_id[-1]) + 1)
|
|
109
|
+
),
|
|
110
|
+
)
|
|
111
|
+
else:
|
|
112
|
+
graphics_windows_manager.show_graphics(self.window_id)
|
|
90
113
|
|
|
91
114
|
def save_graphic(
|
|
92
115
|
self,
|
|
93
|
-
|
|
116
|
+
filename: str,
|
|
94
117
|
) -> None:
|
|
95
|
-
"""Save a
|
|
118
|
+
"""Save a screenshot of the rendering window as a graphic file.
|
|
96
119
|
|
|
97
120
|
Parameters
|
|
98
121
|
----------
|
|
99
|
-
|
|
100
|
-
|
|
122
|
+
filename : str
|
|
123
|
+
Path to save the graphic file to.
|
|
124
|
+
Supported formats are SVG, EPS, PS, PDF, and TEX.
|
|
101
125
|
|
|
102
126
|
Raises
|
|
103
127
|
------
|
|
104
128
|
ValueError
|
|
105
129
|
If the window does not support the specified format.
|
|
130
|
+
|
|
131
|
+
Examples
|
|
132
|
+
--------
|
|
133
|
+
>>> import ansys.fluent.core as pyfluent
|
|
134
|
+
>>> from ansys.fluent.core import examples
|
|
135
|
+
>>> from ansys.fluent.visualization import GraphicsWindow, Vector
|
|
136
|
+
>>>
|
|
137
|
+
>>> import_case = examples.download_file(
|
|
138
|
+
>>> file_name="exhaust_system.cas.h5", directory="pyfluent/exhaust_system"
|
|
139
|
+
>>> )
|
|
140
|
+
>>> import_data = examples.download_file(
|
|
141
|
+
>>> file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
|
|
142
|
+
>>> )
|
|
143
|
+
>>>
|
|
144
|
+
>>> solver_session = pyfluent.launch_fluent()
|
|
145
|
+
>>> solver_session.settings.file.read_case(file_name=import_case)
|
|
146
|
+
>>> solver_session.settings.file.read_data(file_name=import_data)
|
|
147
|
+
>>>
|
|
148
|
+
>>> velocity_vector = Vector(
|
|
149
|
+
>>> solver=solver_session, field="pressure", surfaces=["solid_up:1:830"]
|
|
150
|
+
>>> )
|
|
151
|
+
>>> graphics_window = GraphicsWindow()
|
|
152
|
+
>>> graphics_window.add_graphics(velocity_vector)
|
|
153
|
+
>>> graphics_window.save_graphic("saved_vector.svg")
|
|
106
154
|
"""
|
|
107
155
|
if self.window_id:
|
|
108
|
-
self._renderer.save_graphic(
|
|
156
|
+
self._renderer.save_graphic(filename)
|
|
109
157
|
|
|
110
158
|
def refresh_windows(
|
|
111
159
|
self,
|
|
@@ -168,3 +216,42 @@ class GraphicsWindow:
|
|
|
168
216
|
graphics_windows_manager.close_windows(
|
|
169
217
|
windows_id=[self.window_id], session_id=session_id
|
|
170
218
|
)
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
# Define the main window
|
|
222
|
+
class MainWindow(QMainWindow):
|
|
223
|
+
def __init__(self):
|
|
224
|
+
super().__init__()
|
|
225
|
+
self.setWindowTitle("PyFluent Visualization Plots")
|
|
226
|
+
screen = QApplication.primaryScreen().availableGeometry()
|
|
227
|
+
width = int(screen.width() * 0.75)
|
|
228
|
+
height = int(screen.height() * 0.75)
|
|
229
|
+
self.setGeometry(
|
|
230
|
+
(screen.width() - width) // 2, # Center X
|
|
231
|
+
(screen.height() - height) // 2, # Center Y
|
|
232
|
+
width,
|
|
233
|
+
height,
|
|
234
|
+
)
|
|
235
|
+
self.tabs = QTabWidget()
|
|
236
|
+
self.setCentralWidget(self.tabs)
|
|
237
|
+
self.tabs.setMovable(True)
|
|
238
|
+
self.plotters = []
|
|
239
|
+
|
|
240
|
+
def _add_tab(self, plotter, title="-"):
|
|
241
|
+
tab = QWidget()
|
|
242
|
+
layout = QVBoxLayout()
|
|
243
|
+
|
|
244
|
+
self.plotters.append(plotter)
|
|
245
|
+
layout.addWidget(plotter.interactor)
|
|
246
|
+
tab.setLayout(layout)
|
|
247
|
+
|
|
248
|
+
# Add tabs with PyVista BackgroundPlotters
|
|
249
|
+
self.tabs.addTab(tab, f"PyViz ({title})")
|
|
250
|
+
|
|
251
|
+
def closeEvent(self, event):
|
|
252
|
+
"""Ensure proper cleanup of plotter instances on window close."""
|
|
253
|
+
for plotter in self.plotters:
|
|
254
|
+
plotter.close() # Properly close each PyVista plotter
|
|
255
|
+
event.accept()
|
|
256
|
+
global _qt_window
|
|
257
|
+
_qt_window = None
|
|
@@ -24,7 +24,6 @@
|
|
|
24
24
|
|
|
25
25
|
from enum import Enum
|
|
26
26
|
import itertools
|
|
27
|
-
import os
|
|
28
27
|
import threading
|
|
29
28
|
from typing import Dict, List, Optional, Union
|
|
30
29
|
|
|
@@ -43,6 +42,7 @@ try:
|
|
|
43
42
|
except ModuleNotFoundError:
|
|
44
43
|
BackgroundPlotter = None
|
|
45
44
|
|
|
45
|
+
import ansys.fluent.visualization as pyviz
|
|
46
46
|
from ansys.fluent.visualization import get_config
|
|
47
47
|
from ansys.fluent.visualization.post_data_extractor import (
|
|
48
48
|
FieldDataExtractor,
|
|
@@ -576,11 +576,7 @@ class GraphicsWindowsManager(PostWindowsManager, metaclass=AbstractSingletonMeta
|
|
|
576
576
|
with self._condition:
|
|
577
577
|
if not window_id:
|
|
578
578
|
window_id = self._get_unique_window_id()
|
|
579
|
-
if (
|
|
580
|
-
in_notebook()
|
|
581
|
-
or get_config()["blocking"]
|
|
582
|
-
or os.getenv("FLUENT_PROD_DIR")
|
|
583
|
-
):
|
|
579
|
+
if in_notebook() or get_config()["blocking"] or pyviz.SINGLE_WINDOW:
|
|
584
580
|
self._open_window_notebook(window_id, grid)
|
|
585
581
|
else:
|
|
586
582
|
self._open_and_plot_console(None, window_id, grid=grid)
|
|
@@ -639,11 +635,7 @@ class GraphicsWindowsManager(PostWindowsManager, metaclass=AbstractSingletonMeta
|
|
|
639
635
|
with self._condition:
|
|
640
636
|
if not window_id:
|
|
641
637
|
window_id = self._get_unique_window_id()
|
|
642
|
-
if (
|
|
643
|
-
in_notebook()
|
|
644
|
-
or get_config()["blocking"]
|
|
645
|
-
or os.getenv("FLUENT_PROD_DIR")
|
|
646
|
-
):
|
|
638
|
+
if in_notebook() or get_config()["blocking"] or pyviz.SINGLE_WINDOW:
|
|
647
639
|
self._plot_notebook(object, window_id, fetch_data, overlay)
|
|
648
640
|
else:
|
|
649
641
|
self._open_and_plot_console(object, window_id, fetch_data, overlay)
|
|
@@ -682,11 +674,7 @@ class GraphicsWindowsManager(PostWindowsManager, metaclass=AbstractSingletonMeta
|
|
|
682
674
|
if not isinstance(object, (GraphicsDefn, PlotDefn)):
|
|
683
675
|
raise RuntimeError("Object type currently not supported.")
|
|
684
676
|
with self._condition:
|
|
685
|
-
if (
|
|
686
|
-
in_notebook()
|
|
687
|
-
or get_config()["blocking"]
|
|
688
|
-
or os.getenv("FLUENT_PROD_DIR")
|
|
689
|
-
):
|
|
677
|
+
if in_notebook() or get_config()["blocking"] or pyviz.SINGLE_WINDOW:
|
|
690
678
|
self._add_graphics_in_notebook(
|
|
691
679
|
object, window_id, fetch_data, overlay, position, opacity
|
|
692
680
|
)
|
|
@@ -698,11 +686,7 @@ class GraphicsWindowsManager(PostWindowsManager, metaclass=AbstractSingletonMeta
|
|
|
698
686
|
def show_graphics(self, window_id: str):
|
|
699
687
|
"""Display the graphics window."""
|
|
700
688
|
with self._condition:
|
|
701
|
-
if (
|
|
702
|
-
in_notebook()
|
|
703
|
-
or get_config()["blocking"]
|
|
704
|
-
or os.getenv("FLUENT_PROD_DIR")
|
|
705
|
-
):
|
|
689
|
+
if in_notebook() or get_config()["blocking"] or pyviz.SINGLE_WINDOW:
|
|
706
690
|
self._show_graphics_in_notebook(window_id)
|
|
707
691
|
|
|
708
692
|
def save_graphic(
|
|
@@ -21,10 +21,11 @@
|
|
|
21
21
|
# SOFTWARE.
|
|
22
22
|
|
|
23
23
|
"""Module for pyVista windows management."""
|
|
24
|
-
|
|
25
24
|
import numpy as np
|
|
26
25
|
import pyvista as pv
|
|
27
26
|
|
|
27
|
+
import ansys.fluent.visualization as pyviz
|
|
28
|
+
|
|
28
29
|
try:
|
|
29
30
|
from pyvistaqt import BackgroundPlotter
|
|
30
31
|
except ModuleNotFoundError:
|
|
@@ -44,7 +45,11 @@ class Renderer(AbstractRenderer):
|
|
|
44
45
|
self.plotter: BackgroundPlotter | pv.Plotter = (
|
|
45
46
|
pv.Plotter(title=f"PyFluent ({win_id})", shape=grid)
|
|
46
47
|
if in_notebook or non_interactive
|
|
47
|
-
else BackgroundPlotter(
|
|
48
|
+
else BackgroundPlotter(
|
|
49
|
+
title=f"PyFluent ({win_id})",
|
|
50
|
+
shape=grid,
|
|
51
|
+
show=False if pyviz.SINGLE_WINDOW else True,
|
|
52
|
+
)
|
|
48
53
|
)
|
|
49
54
|
self._init_properties()
|
|
50
55
|
self._colors = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|