PyVista Windows Manager#
This class manages PyVista windows and provides methods to directly interact with them. By registering these methods to EventsManager, graphics can be updated during run time and animations can be created.
The following example will update window-1 during solution initialization and whenever data is read. Also during calculation it will update window-1 at end of every time step and will create animation.
Important:Animation will be saved whenever window is closed.
from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization.pyvista import pyvista_windows_manager
graphics_session = Graphics(session)
#Create contour.
contour1 = graphics_session.Contours["contour-1"]
contour1.field = "velocity-magnitude"
contour1.surfaces_list = ['symmetry']
#Display contour on window-1.
contour1.display("window-1")
#Create callback which refreshes window-1.
def auto_refresh_contour(session_id, event_info):
pyvista_windows_manager.refresh_windows(session_id, ["window-1"])
#Register this callback with server events.
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_contour)
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_contour)
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_contour)
#Create animation for window-1
pyvista_windows_manager.animate_windows(session.id, ["window-1"])
- class ansys.fluent.visualization.pyvista.pyvista_windows_manager.PyVistaWindowsManager(*args, **kwargs)#
Class for PyVista windows manager.
- animate_windows(session_id='', windows_id=[])#
Animate windows.
- Parameters
- Raises
NotImplementedErrorIf not implemented.
- Return type
- close_windows(session_id='', windows_id=[])#
Close windows.
- Parameters
- Return type
- get_plotter(window_id)#
Get PyVista Plotter.
- Parameters
- window_id
str Window Id for plotter.
- window_id
- Returns
Union[BackgroundPlotter,pv.Plotter]PyVista Plotter.
- open_window(window_id=None)#
Open new window.
- Parameters
- window_id
str,optional Id for new window. If not specified unique id is used.
- window_id
- Returns
strWindow id.
- Return type
- plot(object, window_id=None)#
Draw plot.
- Parameters
- object: GraphicsDefn
Object to plot.
- window_id
str,optional Window id for plot. If not specified unique id is used.
- Raises
RuntimeErrorIf window does not support object.
- Return type
- refresh_windows(session_id='', windows_id=[])#
Refresh windows.
- Parameters
- Return type
- save_graphic(window_id, format)#
Save graphics.
- Parameters
- Raises
ValueErrorIf window does not support specified format.
- Return type
- set_object_for_window(object, window_id)#
Associate visualization object with running window instance.
- Parameters
- object
GraphicsDefn Post object to associate with window.
- window_id
str Window id to associate.
- object
- Raises
RuntimeErrorIf window does not support object.
- Return type