Skip to content

Commit 6f86246

Browse files
committed
docs: Updates w.r.t. new structure.
1 parent 89c5220 commit 6f86246

File tree

7 files changed

+202
-193
lines changed

7 files changed

+202
-193
lines changed

doc/source/api/visualization/graphics.rst

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,7 @@ Graphics
77

88
In the following example, a ``Graphics`` object is instantiated with a Fluent
99
session as its context. The ``Graphics`` object is used to create a mesh,
10-
contour, vector, and surface. The contour is then deleted.
11-
12-
.. code-block:: python
13-
14-
from ansys.fluent.visualization import Graphics
15-
graphics_session = Graphics(session)
16-
17-
#Create object
18-
mesh1 = graphics_session.Meshes["mesh-1"]
19-
contour1 = graphics_session.Contours["contour-1"]
20-
vector1 = graphics_session.Vectors["vector-1"]
21-
surface1 = graphics_session.Surfaces["surface-1"]
22-
pathlines1 = graphics_session.Pathlines["pathlines-1"]
23-
24-
#Delete object
25-
del graphics_session.Contours["contour-1"]
10+
contour, vector, and surface.
2611

2712
.. toctree::
2813
:maxdepth: 2

doc/source/api/visualization/graphics_windows_manager.rst

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6,40 +6,39 @@ The ``GraphicsWindowsManager`` class provides for managing and directly interact
66
with PyVista windows. By registering these methods with ``EventsManager``, you
77
can update graphics during run time and create animations.
88

9-
The following example updates ``window-1`` during solution initialization and
10-
whenever data is read. During the calculation, it also updates ``window-1`` at
9+
The following example updates ``p_cont`` during solution initialization and
10+
whenever data is read. During the calculation, it also updates ``p_cont`` at
1111
the end of every time step and creates an animation.
1212

1313
.. note::
1414
The animation is saved when the window is closed.
1515

1616
.. code-block:: python
1717
18-
from ansys.fluent.visualization import Graphics
19-
from ansys.fluent.visualization.graphics import graphics_windows_manager
20-
21-
graphics_session = Graphics(session)
18+
from ansys.fluent.visualization import Contour, GraphicsWindow
2219
2320
#Create contour.
24-
contour1 = graphics_session.Contours["contour-1"]
25-
contour1.field = "velocity-magnitude"
26-
contour1.surfaces = ['symmetry']
21+
contour1 = Contour(
22+
solver=session, field="velocity-magnitude", surfaces=["symmetry"]
23+
)
2724
28-
#Display contour on window-1.
29-
contour1.display("window-1")
25+
#Display contour.
26+
p_cont = GraphicsWindow()
27+
p_cont.add_graphics(contour1)
28+
p_cont.show()
3029
31-
#Create callback that refreshes window-1.
32-
def auto_refresh_contour(session_id, event_info):
33-
graphics_windows_manager.refresh_windows(session_id, ["window-1"])
34-
30+
#Create callback that refreshes 'p_cont'.
31+
def auto_refresh_contour(session, event_info):
32+
# 'p_cont' uses 'graphics_windows_manager' in its implementation
33+
p_cont.refresh_windows(session.id)
34+
3535
#Register this callback with server events.
36-
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_contour)
37-
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_contour)
38-
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_contour)
36+
cb_init_id = session.events.register_callback('InitializedEvent', auto_refresh_contour)
37+
cb_data_read_id = session.events.register_callback('DataReadEvent', auto_refresh_contour)
38+
cb_time_step_ended_id = session.events.register_callback('TimestepEndedEvent', auto_refresh_contour)
3939
40-
#Create animation for window-1.
41-
graphics_windows_manager.animate_windows(session.id, ["window-1"])
42-
40+
#Create animation.
41+
p_cont.animate_windows(session.id)
4342
4443
.. autoclass:: ansys.fluent.visualization.graphics.graphics_windows_manager.GraphicsWindowsManager
4544
:members:

doc/source/api/visualization/index.rst

Lines changed: 39 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,41 +6,39 @@ Visualization
66
Postprocessing of Fluent results can be done with either built-in Fluent
77
postprocessing capabilities, PyVista, or Matplotlib integration.
88

9-
Fluent TUI command example
10-
--------------------------
9+
Fluent command example
10+
----------------------
1111

1212
Here visualization objects are constructed within Fluent. You can use
1313
standard Fluent commands to write graphics to a file.
1414

1515
.. code:: python
1616
17-
solver_session.tui.display.objects.contour['contour-1'] = {'boundary_values': True, 'color_map': {'color': 'field-velocity', 'font_automatic': True, 'font_name': 'Helvetica', 'font_size': 0.032, 'format': '%0.2e', 'length': 0.54, 'log_scale': False, 'position': 1, 'show_all': True, 'size': 100, 'user_skip': 9, 'visible': True, 'width': 6.0}, 'coloring': {'smooth': False}, 'contour_lines': False, 'display_state_name': 'None', 'draw_mesh': False, 'field': 'pressure', 'filled': True, 'mesh_object': '', 'node_values': True, 'range_option': {'auto_range_on': {'global_range': True}}, 'surfaces': [2, 5]}
18-
solver_session.tui.display.objects.contour['contour-1']()
19-
solver_session.tui.display.objects.contour['contour-1'].field.set_state('velocity-magnitude')
20-
solver_session.tui.display.objects.contour['contour-1'].field()
21-
solver_session.tui.display.objects.contour['contour-1'].color_map.size.set_state(80.0)
22-
solver_session.tui.display.objects.contour['contour-1'].color_map.size()
23-
solver_session.tui.display.objects.contour['contour-1'].rename('my-contour')
24-
del solver_session.tui.display.objects.contour['my-contour']
17+
solver_session.settings.results.graphics.contour['contour-1'] = {'boundary_values': True, 'color_map': {'color': 'field-velocity', 'font_automatic': True, 'font_name': 'Helvetica', 'font_size': 0.032, 'format': '%0.2e', 'length': 0.54, 'log_scale': False, 'position': 1, 'show_all': True, 'size': 100, 'user_skip': 9, 'visible': True, 'width': 6.0}, 'coloring': {'smooth': False}, 'contour_lines': False, 'display_state_name': 'None', 'draw_mesh': False, 'field': 'pressure', 'filled': True, 'mesh_object': '', 'node_values': True, 'range_option': {'auto_range_on': {'global_range': True}}, 'surfaces': [2, 5]}
18+
solver_session.settings.results.graphics.contour['contour-1']()
19+
solver_session.settings.results.graphics.contour['contour-1'].field = 'velocity-magnitude'
20+
solver_session.settings.results.graphics.contour['contour-1'].field()
21+
solver_session.settings.results.graphics.contour['contour-1'].color_map.size.set_state(80.0)
22+
solver_session.settings.results.graphics.contour['contour-1'].color_map.size()
23+
solver_session.settings.results.graphics.contour['contour-1'].rename('my-contour')
24+
del solver_session.settings.results.graphics.contour['contour-1']['my-contour']
2525
26-
PyVista example (graphics)
27-
--------------------------
26+
Visualization example (graphics)
27+
--------------------------------
2828

2929
Here field data is extracted from the Fluent session into the Python
30-
environment. PyVista is then used to visualize the extracted data.
30+
environment. Visualization is then used to visualize the extracted data.
3131

3232
.. code:: python
3333
3434
# import module
35-
from ansys.fluent.visualization import Graphics
35+
from ansys.fluent.visualization import GraphicsWindow, Mesh, Contour, Surface
3636
3737
# get the graphics objects for the session
38-
39-
graphics_session1 = Graphics(solver_session)
40-
mesh1 = graphics_session1.Meshes["mesh-1"]
41-
contour1 = graphics_session1.Contours["contour-1"]
42-
contour2 = graphics_session1.Contours["contour-2"]
43-
surface1 = graphics_session1.Surfaces["surface-1"]
38+
mesh1 = Mesh(solver=solver_session)
39+
contour1 = Contour(solver=solver_session)
40+
contour2 = Contour(solver=solver_session)
41+
surface1 = Surface(solver=solver_session)
4442
4543
# set graphics objects properties
4644
@@ -55,55 +53,41 @@ environment. PyVista is then used to visualize the extracted data.
5553
contour2.field = "temperature"
5654
contour2.surfaces = ['symmetry', 'wall']
5755
58-
# copy
59-
graphics_session1.Contours["contour-3"] = contour2()
60-
61-
# update
62-
contour3 = graphics_session1.Contours["contour-3"]
63-
contour3.update(contour1())
64-
65-
# delete
66-
del graphics_session1.Contours["contour-3"]
67-
68-
# loop
69-
for name, _ in graphics_session1.Contours.items():
70-
print(name)
71-
7256
# iso surface
73-
surface1.surface.iso_surface.field= "velocity-magnitude"
74-
surface1.surface.iso_surface.rendering= "contour"
75-
76-
# display
77-
contour1.display()
78-
mesh1.display()
79-
surface1.display()
57+
surface1.definition.type = "iso-surface"
58+
surface1.definition.iso_surface.field= "velocity-magnitude"
59+
surface1.definition.iso_surface.rendering= "contour"
60+
61+
# display
62+
plotter = GraphicsWindow(grid=(2, 2))
63+
plotter.add_graphics(mesh1, position=(0, 0))
64+
plotter.add_graphics(contour1, position=(0, 1))
65+
plotter.add_graphics(contour2, position=(1, 0))
66+
plotter.add_graphics(surface1, position=(1, 1))
67+
plotter.show()
8068
81-
# To display in specific window e.g. window-2
82-
contour1.display("window-2")
83-
84-
Matplotlib example (XY plots)
85-
-----------------------------
69+
Visualization example (XY plots)
70+
--------------------------------
8671

8772
Here plot data is extracted from the Fluent session into the Python
88-
environment. Matplotlib is then used to plot data.
73+
environment. Visualization is then used to plot data.
8974

9075
.. code:: python
9176
9277
# import module
93-
from ansys.fluent.visualization import Plots
78+
from ansys.fluent.visualization import XYPlot
9479
9580
# get the plots object for the session
96-
plots_session1 = Plots(solver_session)
97-
98-
#get xyplot object
99-
plot1=plots_session1.XYPlots["plot-1"]
81+
plots_session1 = XYPlot(solver=solver_session)
10082
10183
#set properties
102-
plot1.surfaces = ["symmetry"]
103-
plot1.y_axis_function = "temperature"
84+
plots_session1.surfaces = ["symmetry"]
85+
plots_session1.y_axis_function = "temperature"
10486
10587
#Draw plot
106-
plot1.plot("window-1")
88+
plotter = GraphicsWindow()
89+
plotter.add_graphics(plots_session1)
90+
plotter.show()
10791
10892
solver_session.exit()
10993

doc/source/api/visualization/plots.rst

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,26 @@ a monitor plot.
1111

1212
.. code-block:: python
1313
14-
from ansys.fluent.visualization import Plots
14+
from ansys.fluent.visualization import GraphicsWindow, XYPlot, Monitor
1515
16-
plots_session = Plots(session)
17-
plot1 = plots_session.XYPlots["plot-1"]
16+
plot1 = XYPlot(solver=session)
1817
plot1.surfaces = ['symmetry', 'wall']
1918
plot1.y_axis_function = "temperature"
20-
plot1.plot("window-0")
21-
22-
23-
#To plot data on local surface created in PyVista
24-
25-
from ansys.fluent.visualization import Graphics
26-
pyvista_surface_provider = Graphics(session).Surfaces
27-
plots_session = Plots(session, pyvista_surface_provider)
28-
plot2 = plots_session.XYPlots["plot-2"]
29-
plot2.surfaces = ['iso-surface-1']
30-
plot2.y_axis_function = "temperature"
31-
plot2.plot("window-0")
32-
19+
plot1.plot("window-0")
20+
21+
plotter = GraphicsWindow()
22+
plotter.add_graphics(plot1)
23+
plotter.show()
3324
3425
#To plot monitors
3526
36-
monitor1=plots_session.Monitors["monitor-1"]
27+
monitor1 = Monitor(solver=session)
3728
monitor1.monitor_set_name = "residual"
38-
monitor1.plot("window-0")
39-
29+
30+
plotter = GraphicsWindow()
31+
plotter.add_graphics(monitor1)
32+
plotter.show()
33+
4034
.. toctree::
4135
:maxdepth: 2
4236
:hidden:

doc/source/api/visualization/plotter_windows_manager.rst

Lines changed: 20 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,47 @@ The ``PlotterWindowsManager`` class provides for managing and directly interacti
77
with Matplotlib windows. By registering these methods with ``EventsManager``, you can
88
update plots during run time.
99

10-
The following example updates ``window-1`` and ``window-2`` during solution initialization
10+
The following example updates ``p_xy`` and ``p_res`` during solution initialization
1111
and whenever data is read. During the calculation, it also updates both windows at the end
1212
of every time step.
1313

1414
.. code-block:: python
1515
16-
from ansys.fluent.visualization import Plots
17-
from ansys.fluent.visualization.plotter import plotter_windows_manager
16+
from ansys.fluent.visualization import XYPlot, Monitor, GraphicsWindow
1817
1918
plots_session = Plots(session)
2019
2120
#Create xy plot.
22-
plot1 = plots_session.XYPlots["plot-1"]
21+
plot1 = XYPlot(solver=session)
2322
plot1.surfaces = ['symmetry']
2423
plot1.y_axis_function = "temperature"
2524
2625
27-
# Plot XY plot on window-1.
28-
plot1.plot("window-1")
26+
# Plot XY plot.
27+
p_xy = GraphicsWindow()
28+
p_xy.add_graphics(plot1)
29+
p_xy.show()
2930
3031
#Create monitor plot.
31-
monitor1 = plots_session.Monitors["monitor-1"]
32+
monitor1 = Monitor(solver=session)
3233
monitor1.monitor_set_name = "residual"
3334
3435
35-
#Plot monitor on window-2.
36-
monitor1.plot("window-2")
36+
#Plot monitor.
37+
p_res = GraphicsWindow()
38+
p_res.add_graphics(monitor1)
39+
p_res.show()
3740
38-
# Create callback that refreshes window-1 and window-2.
39-
def auto_refresh_plot(session_id, event_info):
40-
plotter_windows_manager.refresh_windows(session_id, ["window-1", "window-2"])
41+
# Create callback that refreshes 'p_xy' and 'p_res'.
42+
def auto_refresh_plot(session_id, event_info):
43+
# 'p_xy' and 'p_res' uses 'plotter_windows_manager' in its implementation
44+
p_xy.refresh_windows(session.id)
45+
p_res.refresh_windows(session.id)
4146
4247
#Register this callback with server events.
43-
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_plot)
44-
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_plot)
45-
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_plot)
46-
48+
cb_init_id = session.events.register_callback('InitializedEvent', auto_refresh_plot)
49+
cb_data_read_id = session.events.register_callback('DataReadEvent', auto_refresh_plot)
50+
cb_time_step_ended_id = session.events.register_callback('TimestepEndedEvent', auto_refresh_plot)
4751
4852
.. autoclass:: ansys.fluent.visualization.plotter.plotter_windows_manager.PlotterWindowsManager
4953
:members:

doc/source/getting_started/index.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,10 @@ You can launch Fluent from PyFluent using the ``launch_fluent`` function:
5656
session.check_health()
5757
session.start_transcript() # Streaming the transcript locally
5858
59-
PyFluent-Visualization provides integrations with both
59+
PyFluent-Visualization seamlessly integrates with both
6060
`PyVista <https://www.pyvista.org/>`_ and `Matplotlib <https://matplotlib.org/>`_.
61-
62-
If you want to interact with the Fluent graphical user interface, set the
63-
following environment variable:
64-
65-
.. code::
66-
67-
set PYFLUENT_SHOW_SERVER_GUI=1 # Windows
68-
export PYFLUENT_SHOW_SERVER_GUI=1 # Linux (bash)
61+
Additionally, it offers flexibility to incorporate other open-source data visualization tools,
62+
such as `Plotly <https://plotly.com/python/>`_.
6963

7064
If you want to print the debug information for development, set the following
7165
environment variable:

0 commit comments

Comments
 (0)