Matplot Windows Manager#

This class manages MatplotLib windows and provides methods to directly interact with them. By registering these methods to EventsManager, plots can be updated during run time.

The following example will update window-1 and window-2 during solution initialization and whenever data is read. Also during calculation it will update both windows at end of every time step.

from ansys.fluent.visualization.matplotlib import Plots
from ansys.fluent.visualization.matplotlib import matplot_windows_manager

plots_session = Plots(session)

#Create xy plot.
plot1 = plots_session.XYPlots["plot-1"]
plot1.surfaces_list = ['symmetry']
plot1.y_axis_function = "temperature"


#Plot xy plot on window-1.
plot1.plot("window-1")

#Create monitor plot.
monitor1 = plots_session.Monitors["monitor-1"]
monitor1.monitor_set_name = "residual"


#Plot monitor on window-2.
monitor1.plot("window-2")

#Create callback which refreshes window-1 and window-2.
def auto_refresh_plot(session_id, event_info):
    matplot_windows_manager.refresh_windows(session_id, ["window-1", "window-2"])

#Register this callback with server events.
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_plot)
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_plot)
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_plot)
class ansys.fluent.visualization.matplotlib.matplot_windows_manager.MatplotWindowsManager(*args, **kwargs)#

Class for matplot 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

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: PlotDefn

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 eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif and tiff.

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
objectPlotDefn

Post object to associate with window.

window_idstr

Window id to associate.

Raises
RuntimeError

If window does not support object.

Return type

None