ansys-fluent-visualization 0.15.dev0__tar.gz → 0.16.dev0__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.16.dev0/AUTHORS +12 -0
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/PKG-INFO +5 -4
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/README.rst +2 -2
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/pyproject.toml +2 -2
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/src/ansys/fluent/visualization/__init__.py +17 -3
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/src/ansys/fluent/visualization/_config.py +1 -1
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/containers.py +67 -0
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/src/ansys/fluent/visualization/contour.py +2 -2
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/__init__.py +6 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/abstract_graphics_defns.py +44 -0
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/pyvista/pyvista_objects.py → ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/graphics_objects.py +16 -16
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/graphics_windows.py +129 -0
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/pyvista/pyvista_windows_manager.py → ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/graphics_windows_manager.py +275 -228
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/pyvista/__init__.py +0 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/pyvista/graphics_defns.py +116 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/matplotlib/__init__.py +17 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/__init__.py +6 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/abstract_plotter_defns.py +51 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/matplotlib/__init__.py +0 -0
- {ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization → ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter}/matplotlib/plotter_defns.py +17 -6
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/matplotlib/matplot_objects.py → ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/plotter_objects.py +9 -9
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/plotter_windows.py +125 -0
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/matplotlib/matplot_windows_manager.py → ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/plotter_windows_manager.py +42 -21
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/pyvista/__init__.py +0 -0
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/plotter/pyvista/plotter_defns.py +167 -0
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/src/ansys/fluent/visualization/post_data_extractor.py +14 -14
- ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/pyvista/__init__.py +17 -0
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/matplotlib/__init__.py +0 -6
- ansys_fluent_visualization-0.15.dev0/src/ansys/fluent/visualization/pyvista/__init__.py +0 -6
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/LICENSE +0 -0
- {ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/src/ansys/fluent/visualization/post_windows_manager.py +0 -0
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# This is the list of PyFluent Visualization's significant contributors.
|
|
2
|
+
#
|
|
3
|
+
# This file does not necessarily list everyone who has contributed code.
|
|
4
|
+
#
|
|
5
|
+
# For contributions made under a Corporate CLA, the organization is
|
|
6
|
+
# added to this file.
|
|
7
|
+
#
|
|
8
|
+
# If you have contributed to the repository and want to be added to this file,
|
|
9
|
+
# submit a request.
|
|
10
|
+
#
|
|
11
|
+
#
|
|
12
|
+
ANSYS, Inc.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: ansys-fluent-visualization
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.16.dev0
|
|
4
4
|
Summary: A python wrapper for ansys Fluent visualization
|
|
5
5
|
Home-page: https://github.com/ansys/pyfluent-visualization
|
|
6
6
|
License: MIT
|
|
@@ -16,7 +16,8 @@ Classifier: Programming Language :: Python :: 3
|
|
|
16
16
|
Classifier: Programming Language :: Python :: 3.10
|
|
17
17
|
Classifier: Programming Language :: Python :: 3.11
|
|
18
18
|
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
-
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Requires-Dist: ansys-fluent-core (>=0.28.dev0,<1.0)
|
|
20
21
|
Requires-Dist: importlib-metadata (>=4.0,<5.0) ; python_version < "3.9"
|
|
21
22
|
Requires-Dist: matplotlib (>=3.9.0)
|
|
22
23
|
Requires-Dist: pyside6 (>=6.7.2,<6.8.0)
|
|
@@ -131,11 +132,11 @@ the PyFluent-Visualization documentation.
|
|
|
131
132
|
|
|
132
133
|
.. code:: python
|
|
133
134
|
|
|
134
|
-
from ansys.fluent.visualization
|
|
135
|
+
from ansys.fluent.visualization import Graphics
|
|
135
136
|
graphics = Graphics(session=session)
|
|
136
137
|
temperature_contour = graphics.Contours["contour-temperature"]
|
|
137
138
|
temperature_contour.field = "temperature"
|
|
138
|
-
temperature_contour.
|
|
139
|
+
temperature_contour.surfaces = ["in1", "in2", "out1"]
|
|
139
140
|
temperature_contour.display("window-1")
|
|
140
141
|
|
|
141
142
|
Usage in a JupyterLab environment
|
|
@@ -101,11 +101,11 @@ the PyFluent-Visualization documentation.
|
|
|
101
101
|
|
|
102
102
|
.. code:: python
|
|
103
103
|
|
|
104
|
-
from ansys.fluent.visualization
|
|
104
|
+
from ansys.fluent.visualization import Graphics
|
|
105
105
|
graphics = Graphics(session=session)
|
|
106
106
|
temperature_contour = graphics.Contours["contour-temperature"]
|
|
107
107
|
temperature_contour.field = "temperature"
|
|
108
|
-
temperature_contour.
|
|
108
|
+
temperature_contour.surfaces = ["in1", "in2", "out1"]
|
|
109
109
|
temperature_contour.display("window-1")
|
|
110
110
|
|
|
111
111
|
Usage in a JupyterLab environment
|
{ansys_fluent_visualization-0.15.dev0 → ansys_fluent_visualization-0.16.dev0}/pyproject.toml
RENAMED
|
@@ -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.16.dev0"
|
|
9
9
|
description = "A python wrapper for ansys Fluent visualization"
|
|
10
10
|
license = "MIT"
|
|
11
11
|
authors = ["ANSYS, Inc. <ansys.support@ansys.com>"]
|
|
@@ -25,7 +25,7 @@ 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 = "~=0.
|
|
28
|
+
ansys-fluent-core = "~=0.28.dev0"
|
|
29
29
|
pyvista = "~=0.44.1"
|
|
30
30
|
pyvistaqt = "~=0.11.1"
|
|
31
31
|
pyside6 = "~=6.7.2"
|
|
@@ -5,8 +5,9 @@ try:
|
|
|
5
5
|
except ModuleNotFoundError:
|
|
6
6
|
import importlib_metadata
|
|
7
7
|
|
|
8
|
-
_VERSION_INFO = "Build date:
|
|
8
|
+
_VERSION_INFO = "Build date: November 28, 2024 14:47 UTC ShaID: 463438b"
|
|
9
9
|
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
|
|
10
|
+
PLOTTER = "matplotlib"
|
|
10
11
|
|
|
11
12
|
|
|
12
13
|
def version_info() -> str:
|
|
@@ -23,5 +24,18 @@ def version_info() -> str:
|
|
|
23
24
|
|
|
24
25
|
|
|
25
26
|
from ansys.fluent.visualization._config import get_config, set_config # noqa: F401
|
|
26
|
-
from ansys.fluent.visualization.
|
|
27
|
-
|
|
27
|
+
from ansys.fluent.visualization.containers import ( # noqa: F401
|
|
28
|
+
Contour,
|
|
29
|
+
Mesh,
|
|
30
|
+
Monitor,
|
|
31
|
+
Pathline,
|
|
32
|
+
Surface,
|
|
33
|
+
Vector,
|
|
34
|
+
XYPlot,
|
|
35
|
+
)
|
|
36
|
+
from ansys.fluent.visualization.graphics import Graphics # noqa: F401
|
|
37
|
+
from ansys.fluent.visualization.graphics.graphics_windows import ( # noqa: F401
|
|
38
|
+
GraphicsWindow,
|
|
39
|
+
)
|
|
40
|
+
from ansys.fluent.visualization.plotter import Plots # noqa: F401
|
|
41
|
+
from ansys.fluent.visualization.plotter.plotter_windows import PlotterWindow
|
|
@@ -14,7 +14,7 @@ def get_config() -> dict:
|
|
|
14
14
|
return _global_config.copy()
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
def set_config(blocking: bool = True, set_view_on_display: str =
|
|
17
|
+
def set_config(blocking: bool = True, set_view_on_display: str = "isometric"):
|
|
18
18
|
"""Set visualization configuration.
|
|
19
19
|
|
|
20
20
|
Parameters
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""Containers for graphics."""
|
|
2
|
+
|
|
3
|
+
from ansys.fluent.visualization.graphics import Graphics
|
|
4
|
+
from ansys.fluent.visualization.plotter import Plots
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
class GraphicsContainer:
|
|
8
|
+
"""Base class for graphics containers."""
|
|
9
|
+
|
|
10
|
+
def __getattr__(self, attr):
|
|
11
|
+
return getattr(self.obj, attr)
|
|
12
|
+
|
|
13
|
+
def __setattr__(self, attr, value):
|
|
14
|
+
setattr(self.obj, attr, value)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Mesh(GraphicsContainer):
|
|
18
|
+
"""Mesh."""
|
|
19
|
+
|
|
20
|
+
def __init__(self, solver, **kwargs):
|
|
21
|
+
self.__dict__["obj"] = Graphics(session=solver).Meshes.create(**kwargs)
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
class Surface(GraphicsContainer):
|
|
25
|
+
"""Surface."""
|
|
26
|
+
|
|
27
|
+
def __init__(self, solver, **kwargs):
|
|
28
|
+
self.__dict__["obj"] = Graphics(session=solver).Surfaces.create(**kwargs)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class Contour(GraphicsContainer):
|
|
32
|
+
"""Contour."""
|
|
33
|
+
|
|
34
|
+
def __init__(self, solver, **kwargs):
|
|
35
|
+
self.__dict__["obj"] = Graphics(session=solver).Contours.create(**kwargs)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
class Vector(GraphicsContainer):
|
|
39
|
+
"""Vector."""
|
|
40
|
+
|
|
41
|
+
def __init__(self, solver, **kwargs):
|
|
42
|
+
self.__dict__["obj"] = Graphics(session=solver).Vectors.create(**kwargs)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
class Pathline(GraphicsContainer):
|
|
46
|
+
"""Pathline."""
|
|
47
|
+
|
|
48
|
+
def __init__(self, solver, **kwargs):
|
|
49
|
+
self.__dict__["obj"] = Graphics(session=solver).Pathlines.create(**kwargs)
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class XYPlot(GraphicsContainer):
|
|
53
|
+
"""XYPlot."""
|
|
54
|
+
|
|
55
|
+
def __init__(self, solver, local_surfaces_provider=None, **kwargs):
|
|
56
|
+
self.__dict__["obj"] = Plots(
|
|
57
|
+
session=solver, local_surfaces_provider=Graphics(solver).Surfaces
|
|
58
|
+
).XYPlots.create(**kwargs)
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Monitor(GraphicsContainer):
|
|
62
|
+
"""Monitor."""
|
|
63
|
+
|
|
64
|
+
def __init__(self, solver, local_surfaces_provider=None, **kwargs):
|
|
65
|
+
self.__dict__["obj"] = Plots(
|
|
66
|
+
session=solver, local_surfaces_provider=Graphics(solver).Surfaces
|
|
67
|
+
).Monitors.create(**kwargs)
|
|
@@ -85,13 +85,13 @@ class Contour:
|
|
|
85
85
|
if graphics_mode.__class__.__name__ == "Graphics":
|
|
86
86
|
contour = graphics_mode.Contours[contour_name]
|
|
87
87
|
contour.field = self.field
|
|
88
|
-
contour.
|
|
88
|
+
contour.surfaces = self.surfaces
|
|
89
89
|
contour.display()
|
|
90
90
|
return contour
|
|
91
91
|
elif graphics_mode.__class__.__name__ == "Solver":
|
|
92
92
|
solver.results.graphics.contour[contour_name] = {
|
|
93
93
|
"field": self.field,
|
|
94
|
-
"
|
|
94
|
+
"surfaces": self.surfaces,
|
|
95
95
|
}
|
|
96
96
|
solver.results.graphics.contour.display(object_name=contour_name)
|
|
97
97
|
return solver.results.graphics.contour[contour_name]
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"""A package that provides interfacing Fluent with graphics renderer (PyVista)."""
|
|
2
|
+
|
|
3
|
+
from ansys.fluent.visualization.graphics.graphics_objects import Graphics # noqa: F401
|
|
4
|
+
from ansys.fluent.visualization.graphics.graphics_windows_manager import ( # noqa: F401
|
|
5
|
+
graphics_windows_manager,
|
|
6
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"""Abstract module providing graphics functionality."""
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class AbstractRenderer(ABC):
|
|
7
|
+
"""Abstract class for renderer."""
|
|
8
|
+
|
|
9
|
+
@abstractmethod
|
|
10
|
+
def show(self):
|
|
11
|
+
"""Show graphics."""
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
@abstractmethod
|
|
15
|
+
def render(self, mesh, **kwargs):
|
|
16
|
+
"""Render graphics in window."""
|
|
17
|
+
pass
|
|
18
|
+
|
|
19
|
+
@abstractmethod
|
|
20
|
+
def save_graphic(self, file_name: str):
|
|
21
|
+
"""Save graphics to the specified file.
|
|
22
|
+
|
|
23
|
+
Parameters
|
|
24
|
+
----------
|
|
25
|
+
file_name : str
|
|
26
|
+
File name to save graphic.
|
|
27
|
+
"""
|
|
28
|
+
pass
|
|
29
|
+
|
|
30
|
+
@abstractmethod
|
|
31
|
+
def get_animation(self, win_id: str):
|
|
32
|
+
"""Animate windows.
|
|
33
|
+
|
|
34
|
+
Parameters
|
|
35
|
+
----------
|
|
36
|
+
win_id : str
|
|
37
|
+
ID for the window to animate.
|
|
38
|
+
"""
|
|
39
|
+
pass
|
|
40
|
+
|
|
41
|
+
@abstractmethod
|
|
42
|
+
def close(self):
|
|
43
|
+
"""Close graphics window."""
|
|
44
|
+
pass
|
|
@@ -16,8 +16,8 @@ from ansys.fluent.core.post_objects.post_objects_container import (
|
|
|
16
16
|
Graphics as GraphicsContainer,
|
|
17
17
|
)
|
|
18
18
|
|
|
19
|
-
from ansys.fluent.visualization.
|
|
20
|
-
|
|
19
|
+
from ansys.fluent.visualization.graphics.graphics_windows_manager import (
|
|
20
|
+
graphics_windows_manager,
|
|
21
21
|
)
|
|
22
22
|
|
|
23
23
|
|
|
@@ -49,12 +49,12 @@ class Mesh(MeshDefn):
|
|
|
49
49
|
|
|
50
50
|
.. code-block:: python
|
|
51
51
|
|
|
52
|
-
from ansys.fluent.visualization
|
|
52
|
+
from ansys.fluent.visualization import Graphics
|
|
53
53
|
|
|
54
54
|
graphics_session = Graphics(session)
|
|
55
55
|
mesh1 = graphics_session.Meshes["mesh-1"]
|
|
56
56
|
mesh1.show_edges = True
|
|
57
|
-
mesh1.
|
|
57
|
+
mesh1.surfaces = ['wall']
|
|
58
58
|
mesh1.display("window-0")
|
|
59
59
|
"""
|
|
60
60
|
|
|
@@ -71,7 +71,7 @@ class Mesh(MeshDefn):
|
|
|
71
71
|
Whether to overlay graphics over existing graphics.
|
|
72
72
|
The default is ``False``.
|
|
73
73
|
"""
|
|
74
|
-
|
|
74
|
+
graphics_windows_manager.plot(
|
|
75
75
|
self, window_id=window_id, overlay=overlay, fetch_data=True
|
|
76
76
|
)
|
|
77
77
|
|
|
@@ -81,12 +81,12 @@ class Pathlines(PathlinesDefn):
|
|
|
81
81
|
|
|
82
82
|
.. code-block:: python
|
|
83
83
|
|
|
84
|
-
from ansys.fluent.visualization
|
|
84
|
+
from ansys.fluent.visualization import Graphics
|
|
85
85
|
|
|
86
86
|
graphics_session = Graphics(session)
|
|
87
87
|
pathlines1 = graphics_session.Pathlines["pathlines-1"]
|
|
88
88
|
pathlines1.field = "velocity-magnitude"
|
|
89
|
-
pathlines1.
|
|
89
|
+
pathlines1.surfaces = ['inlet']
|
|
90
90
|
pathlines1.display("window-0")
|
|
91
91
|
"""
|
|
92
92
|
|
|
@@ -103,7 +103,7 @@ class Pathlines(PathlinesDefn):
|
|
|
103
103
|
Whether to overlay graphics over existing graphics.
|
|
104
104
|
The default is ``False``.
|
|
105
105
|
"""
|
|
106
|
-
|
|
106
|
+
graphics_windows_manager.plot(
|
|
107
107
|
self, window_id=window_id, overlay=overlay, fetch_data=True
|
|
108
108
|
)
|
|
109
109
|
|
|
@@ -122,7 +122,7 @@ class Surface(SurfaceDefn):
|
|
|
122
122
|
|
|
123
123
|
.. code-block:: python
|
|
124
124
|
|
|
125
|
-
from ansys.fluent.visualization
|
|
125
|
+
from ansys.fluent.visualization import Graphics
|
|
126
126
|
|
|
127
127
|
graphics_session = Graphics(session)
|
|
128
128
|
surface1 = graphics_session.Surfaces["surface-1"]
|
|
@@ -146,7 +146,7 @@ class Surface(SurfaceDefn):
|
|
|
146
146
|
Whether to overlay graphics over existing graphics.
|
|
147
147
|
The default is ``False``.
|
|
148
148
|
"""
|
|
149
|
-
|
|
149
|
+
graphics_windows_manager.plot(
|
|
150
150
|
self, window_id=window_id, overlay=overlay, fetch_data=True
|
|
151
151
|
)
|
|
152
152
|
|
|
@@ -165,12 +165,12 @@ class Contour(ContourDefn):
|
|
|
165
165
|
|
|
166
166
|
.. code-block:: python
|
|
167
167
|
|
|
168
|
-
from ansys.fluent.visualization
|
|
168
|
+
from ansys.fluent.visualization import Graphics
|
|
169
169
|
|
|
170
170
|
graphics_session = Graphics(session)
|
|
171
171
|
contour1 = graphics_session.Contours["contour-1"]
|
|
172
172
|
contour1.field = "velocity-magnitude"
|
|
173
|
-
contour1.
|
|
173
|
+
contour1.surfaces = ['wall']
|
|
174
174
|
contour1.display("window-0")
|
|
175
175
|
"""
|
|
176
176
|
|
|
@@ -187,7 +187,7 @@ class Contour(ContourDefn):
|
|
|
187
187
|
Whether to overlay graphics over existing graphics.
|
|
188
188
|
The default is ``False``.
|
|
189
189
|
"""
|
|
190
|
-
|
|
190
|
+
graphics_windows_manager.plot(
|
|
191
191
|
self, window_id=window_id, overlay=overlay, fetch_data=True
|
|
192
192
|
)
|
|
193
193
|
|
|
@@ -206,11 +206,11 @@ class Vector(VectorDefn):
|
|
|
206
206
|
|
|
207
207
|
.. code-block:: python
|
|
208
208
|
|
|
209
|
-
from ansys.fluent.visualization
|
|
209
|
+
from ansys.fluent.visualization import Graphics
|
|
210
210
|
|
|
211
211
|
graphics_session = Graphics(session)
|
|
212
212
|
vector1 = graphics_session.Vectors["vector-1"]
|
|
213
|
-
vector1.
|
|
213
|
+
vector1.surfaces = ['symmetry']
|
|
214
214
|
vector1.scale = 4.0
|
|
215
215
|
vector1.skip = 4
|
|
216
216
|
vector1.display("window-0")
|
|
@@ -229,6 +229,6 @@ class Vector(VectorDefn):
|
|
|
229
229
|
Whether to overlay graphics over existing graphics.
|
|
230
230
|
The default is ``False``.
|
|
231
231
|
"""
|
|
232
|
-
|
|
232
|
+
graphics_windows_manager.plot(
|
|
233
233
|
self, window_id=window_id, overlay=overlay, fetch_data=True
|
|
234
234
|
)
|
ansys_fluent_visualization-0.16.dev0/src/ansys/fluent/visualization/graphics/graphics_windows.py
ADDED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
"""A wrapper to improve the user interface of graphics."""
|
|
2
|
+
|
|
3
|
+
from ansys.fluent.visualization.graphics import graphics_windows_manager
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class GraphicsWindow:
|
|
7
|
+
def __init__(self, grid: tuple = (1, 1)):
|
|
8
|
+
self._grid = grid
|
|
9
|
+
self._graphics_objs = []
|
|
10
|
+
self.window_id = None
|
|
11
|
+
|
|
12
|
+
def add_graphics(
|
|
13
|
+
self,
|
|
14
|
+
object,
|
|
15
|
+
position: tuple = (0, 0),
|
|
16
|
+
opacity: float = 1,
|
|
17
|
+
) -> None:
|
|
18
|
+
"""Add data to a plot.
|
|
19
|
+
|
|
20
|
+
Parameters
|
|
21
|
+
----------
|
|
22
|
+
object: GraphicsDefn
|
|
23
|
+
Object to plot as a sub-plot.
|
|
24
|
+
position: tuple, optional
|
|
25
|
+
Position of the sub-plot.
|
|
26
|
+
opacity: float, optional
|
|
27
|
+
Transparency of the sub-plot.
|
|
28
|
+
"""
|
|
29
|
+
self._graphics_objs.append({**locals()})
|
|
30
|
+
|
|
31
|
+
def show(self) -> None:
|
|
32
|
+
"""Render the objects in window and display the same."""
|
|
33
|
+
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
|
+
)
|
|
48
|
+
graphics_windows_manager.show_graphics(self.window_id)
|
|
49
|
+
|
|
50
|
+
def save_graphic(
|
|
51
|
+
self,
|
|
52
|
+
format: str,
|
|
53
|
+
) -> None:
|
|
54
|
+
"""Save a graphics.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
format : str
|
|
59
|
+
Graphic file format. Supported formats are SVG, EPS, PS, PDF, and TEX.
|
|
60
|
+
|
|
61
|
+
Raises
|
|
62
|
+
------
|
|
63
|
+
ValueError
|
|
64
|
+
If the window does not support the specified format.
|
|
65
|
+
"""
|
|
66
|
+
if self.window_id:
|
|
67
|
+
self._renderer.save_graphic(f"{self.window_id}.{format}")
|
|
68
|
+
|
|
69
|
+
def refresh_windows(
|
|
70
|
+
self,
|
|
71
|
+
session_id: str | None = "",
|
|
72
|
+
overlay: bool | None = False,
|
|
73
|
+
) -> None:
|
|
74
|
+
"""Refresh windows.
|
|
75
|
+
|
|
76
|
+
Parameters
|
|
77
|
+
----------
|
|
78
|
+
session_id : str, optional
|
|
79
|
+
Session ID for refreshing the windows that belong only to this
|
|
80
|
+
session. The default is ``""``, in which case the windows in all
|
|
81
|
+
sessions are refreshed.
|
|
82
|
+
overlay : bool, Optional
|
|
83
|
+
Overlay graphics over existing graphics.
|
|
84
|
+
"""
|
|
85
|
+
if self.window_id:
|
|
86
|
+
graphics_windows_manager.refresh_windows(
|
|
87
|
+
windows_id=[self.window_id], session_id=session_id, overlay=overlay
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def animate_windows(
|
|
91
|
+
self,
|
|
92
|
+
session_id: str | None = "",
|
|
93
|
+
) -> None:
|
|
94
|
+
"""Animate windows.
|
|
95
|
+
|
|
96
|
+
Parameters
|
|
97
|
+
----------
|
|
98
|
+
session_id : str, optional
|
|
99
|
+
Session ID for animating the windows that belong only to this
|
|
100
|
+
session. The default is ``""``, in which case the windows in all
|
|
101
|
+
sessions are animated.
|
|
102
|
+
|
|
103
|
+
Raises
|
|
104
|
+
------
|
|
105
|
+
NotImplementedError
|
|
106
|
+
If not implemented.
|
|
107
|
+
"""
|
|
108
|
+
if self.window_id:
|
|
109
|
+
graphics_windows_manager.animate_windows(
|
|
110
|
+
windows_id=[self.window_id], session_id=session_id
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
def close_windows(
|
|
114
|
+
self,
|
|
115
|
+
session_id: str | None = "",
|
|
116
|
+
) -> None:
|
|
117
|
+
"""Close windows.
|
|
118
|
+
|
|
119
|
+
Parameters
|
|
120
|
+
----------
|
|
121
|
+
session_id : str, optional
|
|
122
|
+
Session ID for closing the windows that belong only to this session.
|
|
123
|
+
The default is ``""``, in which case the windows in all sessions
|
|
124
|
+
are closed.
|
|
125
|
+
"""
|
|
126
|
+
if self.window_id:
|
|
127
|
+
graphics_windows_manager.close_windows(
|
|
128
|
+
windows_id=[self.window_id], session_id=session_id
|
|
129
|
+
)
|