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
session_idstr, optional

Session id to animate. If specified, animation will be created for windows which belong to specified session. Otherwise animation will be created for all windows.

windows_idList[str], optional

Windows id to animate. If not specified, animation will be created for all windows.

Raises
NotImplementedError

If not implemented.

Return type

None

close_windows(session_id='', windows_id=[])#

Close windows.

Parameters
session_idstr, optional

Session id to close. If specified, windows which belong to specified session will be closed. Otherwise windows for all sessions will be closed.

windows_idList[str], optional

Windows id to close. If not specified, all windows will be closed.

Return type

None

get_plotter(window_id)#

Get PyVista Plotter.

Parameters
window_idstr

Window Id for plotter.

Returns
Union[BackgroundPlotter, pv.Plotter]

PyVista Plotter.

Return type

Union[BackgroundPlotter, Plotter]

open_window(window_id=None)#

Open new window.

Parameters
window_idstr, optional

Id for new window. If not specified unique id is used.

Returns
str

Window id.

Return type

str

plot(object, window_id=None)#

Draw plot.

Parameters
object: GraphicsDefn

Object to plot.

window_idstr, optional

Window id for plot. If not specified unique id is used.

Raises
RuntimeError

If window does not support object.

Return type

None

refresh_windows(session_id='', windows_id=[])#

Refresh windows.

Parameters
session_idstr, optional

Session id to refresh. If specified, all windows which belong to specified session will be refreshed. Otherwise windows for all sessions will be refreshed.

windows_idList[str], optional

Windows id to refresh. If not specified, all windows will be refreshed.

Return type

None

save_graphic(window_id, format)#

Save graphics.

Parameters
window_idstr

Window id for which graphic should be saved.

formatstr

Graphic format. Supported formats are svg, eps, ps, pdf and tex.

Raises
ValueError

If window does not support specified format.

Return type

None

set_object_for_window(object, window_id)#

Associate visualization object with running window instance.

Parameters
objectGraphicsDefn

Post object to associate with window.

window_idstr

Window id to associate.

Raises
RuntimeError

If window does not support object.

Return type

None