GraphicsWindow#

class ansys.fluent.visualization.GraphicsWindow(grid=(1, 1))#

Bases: object

Create a graphics window to perform operations like display, save, animate, etc. on graphics 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(grid=(2, 2))
>>> 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_graphics(xy_plot, position=(1, 1))
>>> graphics_window.show()
__init__(grid=(1, 1))#

__init__ method of GraphicsWindow class.

add_graphics(object, position=(0, 0), opacity=1, title='')#

Add data to a plot.

Parameters:
object: GraphicsDefn

Object to plot as a sub-plot.

position: tuple, optional

Position of the sub-plot.

opacity: float, optional

Transparency of the sub-plot.

title: str, optional

Title of the sub-plot (only for plots).

Return type:

None

animate(session_id='')#

Animate windows.

Parameters:
session_idstr, optional

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.

Raises:
NotImplementedError

If not implemented.

Return type:

None

close(session_id='')#

Close windows.

Parameters:
session_idstr, optional

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

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

Refresh windows.

Parameters:
session_idstr, optional

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.

overlaybool, Optional

Overlay graphics over existing graphics.

Return type:

None

save_graphic(filename)#

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

Parameters:
filenamestr

Path to save the graphic file to. Supported formats are SVG, EPS, PS, PDF, and TEX.

Raises:
ValueError

If the window does not support the specified format.

Return type:

None

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_graphic("saved_vector.svg")
show()#

Render the objects in window and display the same.

Return type:

None