Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
 into main
  • Loading branch information
prmukherj committed Nov 5, 2024
2 parents fab2277 + ff419f4 commit 05faa31
Show file tree
Hide file tree
Showing 37 changed files with 748 additions and 322 deletions.
13 changes: 2 additions & 11 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,19 +31,10 @@ jobs:
name: Documentation Style Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Running Vale
uses: errata-ai/vale-action@reviewdog
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
uses: ansys/actions/doc-style@v8
with:
files: doc
reporter: github-pr-check
level: error
filter_mode: nofilter
fail_on_error: true
vale_flags: "--config=doc/.vale.ini"
token: ${{ secrets.GITHUB_TOKEN }}

tests:
name: Tests and coverage
Expand Down
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"])
Loading

0 comments on commit 05faa31

Please sign in to comment.