Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
5fe273b
build: Bump version to v0.11.dev0
prmukherj Jun 21, 2024
7da40a0
Merge branch 'main' into release/v0.11.dev0
prmukherj Jun 24, 2024
cd34356
Merge branch 'release/v0.11.dev0' of https://github.com/pyansys/pyflu…
prmukherj Jul 2, 2024
d17fb8a
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 8, 2024
fe41ed1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 9, 2024
de52b2e
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 16, 2024
9c7a215
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Jul 24, 2024
616dea1
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 19, 2024
30e5c5c
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 20, 2024
0d91d78
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 21, 2024
2a1d92f
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Aug 28, 2024
03be4f5
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 5, 2024
14c2013
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 12, 2024
1c410d7
Merge branch 'main' of https://github.com/pyansys/pyfluent-visualizat…
prmukherj Sep 18, 2024
b4df79e
feat: Plug in pyvista as an alternate plotter.
prmukherj Sep 22, 2024
5c3ca7f
Update test.
prmukherj Sep 22, 2024
39f22ec
Update docs.
prmukherj Sep 22, 2024
425e6b9
Update docs.
prmukherj Sep 22, 2024
2faf80f
Add abstract class for plotters.
prmukherj Sep 23, 2024
932c9ca
Restructure pyvista -> graphic
prmukherj Sep 23, 2024
9ec22a2
Rename docs.
prmukherj Sep 23, 2024
56020e6
Add docstring.
prmukherj Sep 23, 2024
cfda0f3
Refactor graphics.
prmukherj Sep 23, 2024
413a2fd
Refactor.
prmukherj Sep 23, 2024
fcd8c96
Fix docs.
prmukherj Sep 23, 2024
1a6ecfa
Refactor.
prmukherj Sep 23, 2024
5bca610
Refactor.
prmukherj Sep 24, 2024
e5964cd
Refactor.
prmukherj Sep 24, 2024
3a6e960
Refactor.
prmukherj Sep 24, 2024
ffede36
Bug fix for notebook.
prmukherj Sep 24, 2024
ed48d1d
Merge branch 'main' into feat/plug_in_pyvista_as_plotter
prmukherj Oct 8, 2024
d520b0d
Set a default value for config.
prmukherj Oct 8, 2024
c36573a
Merge branch 'feat/plug_in_pyvista_as_plotter' of https://github.com/…
prmukherj Oct 8, 2024
ffbd5ad
Bug fixing in multi-plotter.
prmukherj Oct 8, 2024
f2708a2
Added exapmple script for additional testing.
prmukherj Oct 8, 2024
96047f2
Update examples.
prmukherj Oct 8, 2024
e3f8dfd
Merge branch 'main' into feat/plug_in_pyvista_as_plotter
prmukherj Oct 14, 2024
2b7b34d
Merge branch 'main' into feat/plug_in_pyvista_as_plotter
prmukherj Oct 16, 2024
ea62f91
Add deprecated modules.
prmukherj Oct 16, 2024
f57e86c
Merge branch 'main' into feat/plug_in_pyvista_as_plotter
prmukherj Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ the PyFluent-Visualization documentation.

.. code:: python

from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization import Graphics
graphics = Graphics(session=session)
temperature_contour = graphics.Contours["contour-temperature"]
temperature_contour.field = "temperature"
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/visualization/contour.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Contour
=======

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Contour
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Contour
4 changes: 2 additions & 2 deletions doc/source/api/visualization/graphics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
Graphics
========

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Graphics
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Graphics

In the following example, a ``Graphics`` object is instantiated with a Fluent
session as its context. The ``Graphics`` object is used to create a mesh,
contour, vector, and surface. The contour is then deleted.

.. code-block:: python

from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization import Graphics
graphics_session = Graphics(session)

#Create object
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
.. _ref_pyvista_windows_manager:
.. _ref_graphics_windows_manager:

PyVista windows manager
=======================
The ``PyVistaWindowsManager`` class provides for managing and directly interacting
Graphics windows manager
========================
The ``GraphicsWindowsManager`` class provides for managing and directly interacting
with PyVista windows. By registering these methods with ``EventsManager``, you
can update graphics during run time and create animations.

Expand All @@ -15,8 +15,8 @@ the end of every time step and creates an animation.

.. code-block:: python

from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization.pyvista import pyvista_windows_manager
from ansys.fluent.visualization import Graphics
from ansys.fluent.visualization.graphics import graphics_windows_manager

graphics_session = Graphics(session)

Expand All @@ -30,16 +30,16 @@ the end of every time step and creates an animation.

#Create callback that refreshes window-1.
def auto_refresh_contour(session_id, event_info):
pyvista_windows_manager.refresh_windows(session_id, ["window-1"])
graphics_windows_manager.refresh_windows(session_id, ["window-1"])

#Register this callback with server events.
cb_init_id = session.events_manager.register_callback('InitializedEvent', auto_refresh_contour)
cb_data_read_id = session.events_manager.register_callback('DataReadEvent', auto_refresh_contour)
cb_time_step_ended_id = session.events_manager.register_callback('TimestepEndedEvent', auto_refresh_contour)

#Create animation for window-1.
pyvista_windows_manager.animate_windows(session.id, ["window-1"])
graphics_windows_manager.animate_windows(session.id, ["window-1"])


.. autoclass:: ansys.fluent.visualization.pyvista.pyvista_windows_manager.PyVistaWindowsManager
.. autoclass:: ansys.fluent.visualization.graphics.graphics_windows_manager.GraphicsWindowsManager
:members:
4 changes: 2 additions & 2 deletions doc/source/api/visualization/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ environment. PyVista is then used to visualize the extracted data.
.. code:: python

# import module
from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization import Graphics

# get the graphics objects for the session

Expand Down Expand Up @@ -90,7 +90,7 @@ environment. Matplotlib is then used to plot data.
.. code:: python

# import module
from ansys.fluent.visualization.matplotlib import Plots
from ansys.fluent.visualization import Plots

# get the plots object for the session
plots_session1 = Plots(solver_session)
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/visualization/mesh.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
Mesh
====

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Mesh
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Mesh


2 changes: 1 addition & 1 deletion doc/source/api/visualization/monitorplot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
MonitorPlot
===========

.. autopostdoc:: ansys.fluent.visualization.matplotlib.matplot_objects.MonitorPlot
.. autopostdoc:: ansys.fluent.visualization.plotter.plotter_objects.MonitorPlot


2 changes: 1 addition & 1 deletion doc/source/api/visualization/pathlines.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Pathlines
=========

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Pathlines
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Pathlines
6 changes: 3 additions & 3 deletions doc/source/api/visualization/plots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Plots
=====
.. autoclass:: ansys.fluent.visualization.matplotlib.matplot_objects.Plots
.. autoclass:: ansys.fluent.visualization.plotter.plotter_objects.Plots


In the following example, a ``Plots`` object is instantiated with a Fluent session
Expand All @@ -11,7 +11,7 @@ a monitor plot.

.. code-block:: python

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

plots_session = Plots(session)
plot1 = plots_session.XYPlots["plot-1"]
Expand All @@ -22,7 +22,7 @@ a monitor plot.

#To plot data on local surface created in PyVista

from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization import Graphics
pyvista_surface_provider = Graphics(session).Surfaces
plots_session = Plots(session, pyvista_surface_provider)
plot2 = plots_session.XYPlots["plot-2"]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
.. _ref_matplot_windows_manager:
.. _ref_plotter_windows_manager:

Matplotlib windows manager
==========================
Plotter windows manager
=======================

The ``MatplotWindowsManager`` class provides for managing and directly interacting
The ``PlotterWindowsManager`` class provides for managing and directly interacting
with Matplotlib windows. By registering these methods with ``EventsManager``, you can
update plots during run time.

Expand All @@ -13,8 +13,8 @@ of every time step.

.. code-block:: python

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

plots_session = Plots(session)

Expand All @@ -37,13 +37,13 @@ of every time step.

# Create callback that 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"])
plotter_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)


.. autoclass:: ansys.fluent.visualization.matplotlib.matplot_windows_manager.MatplotWindowsManager
.. autoclass:: ansys.fluent.visualization.plotter.plotter_windows_manager.PlotterWindowsManager
:members:
4 changes: 2 additions & 2 deletions doc/source/api/visualization/post_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@

graphics
plots
pyvista_windows_manager
matplot_windows_manager
graphics_windows_manager
plotter_windows_manager



Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/visualization/surface.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
Surface
=======

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Surface
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Surface


2 changes: 1 addition & 1 deletion doc/source/api/visualization/vector.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Vector
======

.. autopostdoc:: ansys.fluent.visualization.pyvista.pyvista_objects.Vector
.. autopostdoc:: ansys.fluent.visualization.graphics.graphics_objects.Vector
2 changes: 1 addition & 1 deletion doc/source/api/visualization/xyplot.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
XY plot
=======

.. autopostdoc:: ansys.fluent.visualization.matplotlib.matplot_objects.XYPlot
.. autopostdoc:: ansys.fluent.visualization.plotter.plotter_objects.XYPlot



Expand Down
3 changes: 2 additions & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,8 @@ def _stop_fluent_container(gallery_conf, fname):
"gallery_dirs": ["examples"],
# Pattern to search for example files
"filename_pattern": r"\.py",
# Disabled example scripts
"ignore_pattern": r"script_manifold\.py|flycheck*",
# Remove the "Download all examples" button from the top level gallery
"download_all_examples": False,
# Sort gallery example by file name instead of number of lines (default)
Expand All @@ -171,7 +173,6 @@ def _stop_fluent_container(gallery_conf, fname):
# Modules for which function level galleries are created. In
"doc_module": "ansys-fluent-core",
"image_scrapers": ("pyvista", "matplotlib"),
"ignore_pattern": "flycheck*",
"thumbnail_size": (350, 350),
"reset_modules_order": "after",
"reset_modules": (_stop_fluent_container),
Expand Down
4 changes: 2 additions & 2 deletions doc/source/users_guide/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ This example shows how you can display a mesh:
import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples
from ansys.fluent.visualization import set_config
from ansys.fluent.visualization.matplotlib import Plots
from ansys.fluent.visualization.pyvista import Graphics
from ansys.fluent.visualization import Plots
from ansys.fluent.visualization import Graphics
from ansys.fluent.visualization.contour import Contour

set_config(blocking=True, set_view_on_display="isometric")
Expand Down
124 changes: 124 additions & 0 deletions examples/00-postprocessing/script_manifold.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
""".. _ref_script_manifold:
Triggering callbacks and Animation
----------------------------------
This example uses PyVista and Matplotlib to demonstrate the use
of callback mechanisms. The 3D model in this example
is an exhaust manifold.
"""

###############################################################################
# Run the following in command prompt to execute this file:
# exec(open("script_manifold.py").read())

import ansys.fluent.core as pyfluent

session = pyfluent.connect_to_fluent(ip="10.18.44.105", port=62599, password="hzk1dhbc")

from ansys.fluent.visualization import set_config

set_config(blocking=False)


from ansys.fluent.visualization import Graphics, Plots
from ansys.fluent.visualization.graphics import graphics_windows_manager
from ansys.fluent.visualization.plotter import plotter_windows_manager

# get the graphics objects for the session
graphics_session1 = Graphics(session)
graphics_session1_1 = Graphics(session)

# mesh
mesh1 = graphics_session1.Meshes["mesh-1"]
mesh1.show_edges = True
mesh1.surfaces_list = ["solid_up:1:830"]

# pathlines
pathlines1 = graphics_session1.Pathlines["pathlines-1"]
pathlines1.field = "velocity-magnitude"
pathlines1.surfaces_list = ["inlet"]

# contour
contour1 = graphics_session1.Contours["contour-1"]
contour1.field = "velocity-magnitude"
contour1.surfaces_list = ["solid_up:1:830"]


graphics_session1.Contours["contour-2"]
graphics_session1_1.Contours["contour-3"]

# vector
vector1 = graphics_session1_1.Vectors["vector-1"]
vector1.surfaces_list = ["solid_up:1:830"]
vector1.scale = 4.0
vector1.skip = 0
vector1.field = "temperature"
vector1.display()

# iso surface
surface1 = graphics_session1_1.Surfaces["surface-1"]
surface1.definition.type = "iso-surface"
surface1.definition.iso_surface.field = "velocity-magnitude"
surface1.definition.iso_surface.rendering = "contour"
surface1.definition.iso_surface.iso_value = 0.0


local_surfaces_provider = Graphics(session).Surfaces
matplotlib_plots1 = Plots(session, local_surfaces_provider=local_surfaces_provider)


p1 = matplotlib_plots1.XYPlots["p1"]
p1.surfaces_list = ["solid_up:1:830", "surface-1"]
p1.surfaces_list = ["solid_up:1:830"]
p1.y_axis_function = "temperature"
p1.plot("p1")

session.monitors.get_monitor_set_names()
residual = matplotlib_plots1.Monitors["residual"]
residual.monitor_set_name = "residual"
residual.plot("residual")

mtr = matplotlib_plots1.Monitors["mass-tot-rplot"]
mtr.monitor_set_name = "mass-tot-rplot"
mtr.plot("mass-tot-rplot")

mbr = matplotlib_plots1.Monitors["mass-bal-rplot"]
mbr.monitor_set_name = "mass-bal-rplot"
mbr.plot("mass-bal-rplot")

mesh1.display("mesh-1")
vector1.display("vector-1")
contour1.display("contour-1")
pathlines1.display("pthlines-1")
plotter = graphics_windows_manager.get_plotter("contour-1")
plotter.view_isometric()
surface1.display("surface-1")


def auto_refersh_call_back_iteration(session_id, event_info):
if event_info.index % 1 == 0:
graphics_windows_manager.refresh_windows(session_id, ["contour-1"])
plotter_windows_manager.refresh_windows(
session_id, ["residual", "mass-tot-rplot", "mass-bal-rplot"]
)


def auto_refersh_call_back_time_step(session_id, event_info):
graphics_windows_manager.refresh_windows(session_id)
plotter_windows_manager.refresh_windows("", ["residual"])


def initialize_call_back(session_id, event_info):
graphics_windows_manager.refresh_windows(session_id)
plotter_windows_manager.refresh_windows("", ["residual", "mass-tot-rplot"])


cb_init_id = session.events.register_callback("InitializedEvent", initialize_call_back)
cb_data_read_id = session.events.register_callback(
"DataReadEvent", initialize_call_back
)
cb_itr_id = session.events.register_callback(
"IterationEndedEvent", auto_refersh_call_back_iteration
)

graphics_windows_manager.animate_windows(session.id, ["contour-1"])
5 changes: 3 additions & 2 deletions src/ansys/fluent/visualization/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

_VERSION_INFO = None
__version__ = importlib_metadata.version(__name__.replace(".", "-"))
PLOTTER = "matplotlib"


def version_info() -> str:
Expand All @@ -23,5 +24,5 @@ def version_info() -> str:


from ansys.fluent.visualization._config import get_config, set_config # noqa: F401
from ansys.fluent.visualization.matplotlib import Plots # noqa: F401
from ansys.fluent.visualization.pyvista import Graphics # noqa: F401
from ansys.fluent.visualization.graphics import Graphics # noqa: F401
from ansys.fluent.visualization.plotter import Plots # noqa: F401
Loading