Kudos to PyFluent Team for supporting exporting 3D visualization as HTML with ansys-fluent-visualization module under PyAnsys earlier it available as rendered with Jupyter Notebook.
Key benefits of 3D visualization in the browser are the ability to export the model/simulation data as HTML, allowing it to be easily shared and embedded in web pages and applications.
This is definitely going to be useful with Ansys SAF Based Solution & Web App Development with PyFluent in general.
Just sharing simple example code snippet for reference, please feel free to reach out to me if you need more details.
Code Snippet
# Class to launch Fluent session and read the file and also create a methods for reading and exporting html output
class FluentSession:
def __init__(self, file_name):
self.file_name = file_name
self.session = None
self.graphics = None
self.mesh1 = None
self.plotter = None
self.active_window = None
def launch_fluent(self):
set_config(blocking=True, set_view_on_display="isometric")
self.session = pyfluent.launch_fluent(show_gui=True)
self.session.file.read(file_type="case-data", file_name=self.file_name)
def create_graphics(self):
self.graphics = Graphics(session=self.session)
self.contour1 = self.graphics.Contours['contour-1']
self.contour1.field = "temperature"
def create_plotter(self):
self.contour1.surfaces_list = ["symmetry", ]
self.contour1.show_edges = False
pyvista_windows_manager.open_window("test_viz")
self.active_window = pyvista_windows_manager.get_window("test_viz")
self.active_window.show_window = False
self.active_window.post_object = self.contour1
self.active_window.plot()
self.plotter = pyvista_windows_manager.get_plotter("test_viz")
def export_html(self, file_name):
self.plotter.window_size = [1920, 1080]
self.plotter.export_html(file_name, backend="panel")
def close_fluent(self):
self.session.exit()
# This path needs to updated with the path of the case file
fluent_session = FluentSession(file_name=r"D:\Ansys_Fluent_Visualization_Test\elbow1.cas.h5")
fluent_session.launch_fluent()
fluent_session.create_graphics()
fluent_session.create_plotter()
fluent_session.export_html('test_viz.html')
fluent_session.close_fluent()
Note: PyFluent-Visualization provides postprocessing and visualization capabilities or PyFluent using PyVista and Matplotlib.