GraphicsWindow#

class ansys.fluent.visualization.GraphicsWindow(renderer=None)#

Bases: object

Create a graphics window to perform operations like display, save, animate on graphics and plot objects.

Examples

You can add graphics objects like mesh, surface or plots and then display it.

>>> from ansys.fluent.visualization import GraphicsWindow
>>> graphics_window = GraphicsWindow()
>>> graphics_window.add_graphics(mesh_object)
>>> graphics_window.show()

You can add multiple graphics objects and display as a structured layout.

>>> graphics_window = GraphicsWindow()
>>> graphics_window.add_graphics(mesh_object, position=(0, 0))
>>> graphics_window.add_graphics(temperature_contour_object, position=(0, 1))
>>> graphics_window.add_graphics(velocity_vector_object, position=(1, 0))
>>> graphics_window.add_plot(xy_plot, position=(1, 1))
>>> graphics_window.show()
__init__(renderer=None)#

__init__ method of GraphicsWindow class.

add_graphics(graphics_obj, position=(0, 0), opacity=1, title=None, **kwargs)#

Add graphics-data to a window.

Parameters:
  • graphics_obj (GraphicsObject) – Object to render in the window.

  • position (tuple) – tuple, optional: Position of the sub-plot.

  • opacity (float) – float, optional: Transparency of the sub-plot.

  • title (str | None) – Title of the sub-plot.

Return type:

None

add_plot(plot_obj, position=(0, 0), title=None, **kwargs)#

Add 2D plot-data to a window.

Parameters:
  • plot_obj (GraphicsObject) – Object to render in the window.

  • position (tuple) – tuple, optional: Position of the sub-plot.

  • title (str | None) – str, optional: Title of the sub-plot.

Return type:

None

animate(session_id='')#

Animate windows.

Parameters:

session_id (str | None) – Session ID for animating the windows that belong only to this session. The default is "", in which case the windows in all sessions are animated.

Return type:

None

:raises NotImplementedError: If not implemented.

close(session_id='')#

Close windows.

Parameters:

session_id (str | None) – Session ID for closing the windows that belong only to this session. The default is "", in which case the windows in all sessions are closed.

Return type:

None

real_time_update(events)#

Update the graphics window in real time with respect to the event that is passed as input.

Parameters:

events (list) – List of events.

Return type:

None

refresh(session_id='', overlay=False)#

Refresh windows.

Parameters:
  • session_id (str | None) – Session ID for refreshing the windows that belong only to this session. The default is "", in which case the windows in all sessions are refreshed.

  • overlay (bool | None) – Overlay graphics over existing graphics.

Return type:

None

property renderer#

Returns the plotter object.

save_graphics(filename)#

Save a screenshot of the rendering window as a graphics file.

Parameters:

filename (str) – Path to save the graphic file to. Supported formats are SVG, EPS, PS, PDF, and TEX.

Return type:

None

:raises ValueError: If the window does not support the specified format.

Examples

>>> import ansys.fluent.core as pyfluent
>>> from ansys.fluent.core import examples
>>> from ansys.fluent.visualization import GraphicsWindow, Vector
>>>
>>> import_case = examples.download_file(
>>> file_name="exhaust_system.cas.h5", directory="pyfluent/exhaust_system"
>>> )
>>> import_data = examples.download_file(
>>> file_name="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
>>> )
>>>
>>> solver_session = pyfluent.launch_fluent()
>>> solver_session.settings.file.read_case(file_name=import_case)
>>> solver_session.settings.file.read_data(file_name=import_data)
>>>
>>> velocity_vector = Vector(
>>> solver=solver_session, field="pressure", surfaces=["solid_up:1:830"]
>>> )
>>> graphics_window = GraphicsWindow()
>>> graphics_window.add_graphics(velocity_vector)
>>> graphics_window.save_graphics("saved_vector.svg")
show()#

Render the objects in window and display the same.

Return type:

None