GraphicsWindow#

class ansys.fluent.visualization.GraphicsWindow#

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__()#

__init__ method of GraphicsWindow class.

add_graphics(graphics_obj, position=(0, 0), opacity=1)#

Add graphics-data to a window.

Parameters:
graphics_obj

Object to render in the window.

position: tuple, optional

Position of the sub-plot.

opacity: float, optional

Transparency of the sub-plot.

Return type:

None

add_plot(plot_obj, position=(0, 0), title='')#

Add 2D plot-data to a window.

Parameters:
plot_obj

Object to render in the window.

position: tuple, optional

Position of the sub-plot.

title: str, optional

Title of the sub-plot.

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

real_time_update(events)#

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

Parameters:
eventslist

List of events.

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

property renderer#

Returns the plotter object.

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(renderer=None)#

Render the objects in window and display the same.

Return type:

None