Skip to content

Commit

Permalink
Add code from the core repo (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkundu1 authored Jun 3, 2022
1 parent 8151dff commit 9efbcdd
Show file tree
Hide file tree
Showing 24 changed files with 3,154 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ exclude = venv, __init__.py, doc/_build, .venv
select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, E501, F401, F403
count = True
max-complexity = 10
max-line-length = 100
max-line-length = 88
statistics = True
13 changes: 11 additions & 2 deletions .github/workflows/ci_cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,21 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}

- name: Install OS packages
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt update
sudo apt install libegl1
- name: Install pyfluent-visualization
run: make install

- name: Test with pytest
run: make unittest

Expand Down Expand Up @@ -96,8 +105,8 @@ jobs:

- name: Retrieve pyfluent-visualization version
run: |
echo "::set-output name=PYFLUENT_VISUALIZATION_VERSION::$(python -c "from ansys.fluent.visualization import __version__; print(__version__)")"
echo "pyfluent-visualization version is: $(python -c "from ansys.fluent.visualization import __version__; print(__version__)")"
echo "::set-output name=PYFLUENT_VISUALIZATION_VERSION::$(python -c "from ansys.fluent.post import __version__; print(__version__)")"
echo "pyfluent-visualization version is: $(python -c "from ansys.fluent.post import __version__; print(__version__)")"
id: version

- name: Cache examples
Expand Down
2 changes: 1 addition & 1 deletion doc/source/api/post/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ environment and data is plotted in MatplotLib.
plots_session1 = Plots(session)
#get xyplot object
plot1 = plots_session1.XYPlots["plot-1"]
plot1=plots_session1.XYPlots["plot-1"]
#set properties
plot1.surfaces_list = ["symmetry"]
Expand Down
18 changes: 10 additions & 8 deletions doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import pyvista
from sphinx_gallery.sorting import FileNameSortKey

from ansys.fluent.visualization import __version__
from ansys.fluent.post import __version__

# Manage errors
pyvista.set_error_output_file("errors.txt")
Expand Down Expand Up @@ -124,7 +124,9 @@ def _stop_fluent_container(gallery_conf, fname):
try:
is_linux = platform.system() == "Linux"
container_names = (
subprocess.check_output("docker container ls --format {{.Names}}", shell=is_linux)
subprocess.check_output(
"docker container ls --format {{.Names}}", shell=is_linux
)
.decode("utf-8")
.strip()
.split()
Expand Down Expand Up @@ -190,7 +192,7 @@ def _stop_fluent_container(gallery_conf, fname):
(
master_doc,
f"pyfluent-visualization-Documentation-{__version__}.tex",
"ansys.fluent.visualization Documentation",
"ansys.fluent.post Documentation",
author,
"manual",
),
Expand All @@ -204,8 +206,8 @@ def _stop_fluent_container(gallery_conf, fname):
man_pages = [
(
master_doc,
"ansys.fluent.visualization",
"ansys.fluent.visualization Documentation",
"ansys.fluent.post",
"ansys.fluent.post Documentation",
[author],
1,
)
Expand All @@ -220,10 +222,10 @@ def _stop_fluent_container(gallery_conf, fname):
texinfo_documents = [
(
master_doc,
"ansys.fluent.visualization",
"ansys.fluent.visualization Documentation",
"ansys.fluent.post",
"ansys.fluent.post Documentation",
author,
"ansys.fluent.visualization",
"ansys.fluent.post",
"Pythonic interface for Fluent using gRPC",
"Engineering Software",
),
Expand Down
107 changes: 98 additions & 9 deletions doc/source/users_guide/index.rst
Original file line number Diff line number Diff line change
@@ -1,12 +1,101 @@
.. _ref_user_guide:

.. _user_guide:

************
User's Guide
************
This guide contains pertinent information regarding using Ansys pyfluent-visualization and its
==========
User Guide
==========
This guide provides information regarding using Ansys PyFluent and its
constituent modules and components.

================================================
Understanding the pyfluent-visualization Modules
================================================

..
This toctreemust be a top level index to get it to show up in
pydata_sphinx_theme
.. toctree::
:maxdepth: 1
:hidden:

postprocessing


PyFluent Basic Overview
=======================
Session objects are the main entry point when using the PyFluent library, where
one or more Fluent server sessions can be launched simultaneously from the
client. For example:

.. code:: python
solver_session = pyfluent.launch_fluent()
or

.. code:: python
meshing_session = pyfluent.launch_fluent(meshing_mode=True)
Each session object provides access to multiple services, such as boundary
contitions, meshing workflows, field data properties, and so forth.

PyFluent contains several basic service modules that provide access to core
Fluent capabilities.

- General command and query services are encompassed in three modules:

+ The 'tui' modules are a collection of Python wrappers around the
Fluent's traditional Text User Interface (TUI) command-based
infrastructure.

.. code::
solver_session.tui.define.models.unsteady_2nd_order('yes’)​
+ The 'settings' module is a Pythonic interface to access Fluent's setup
and solution objects, where you can, for instance, enable a
physics-based model for your simulation.

.. code::
session.solver.root.setup.models.energy.enabled = True
+ The 'datamodel' module is a Python interface to access the
datamodel-driven aspects of Fluent, such as the meshing workflows.

.. code::
import_geometry.arguments.update_dict({'AppendMesh':True})
- Surface field and mesh data services are available using the 'field_data'
module, such as obtaining surface data for a specified surface.

.. code::
surface_data = field_data.get_surfaces(surface_ids)​
- There are general modules available, such as 'health_check', 'transcript',
and 'events' that provide access to generic features that are useful to
running your simulation. For instance,

.. code::
health_check_service.check_health()​​
or

.. code::
transcript_service.begin_streaming()​​
or

.. code::
events_service.begin_streaming()
- Finally, there is a 'scheme_eval' module that provides access to Scheme
function evaluation. For instance,

.. code::
scheme_eval.string_eval("(rp-unsteady?)")​
107 changes: 107 additions & 0 deletions doc/source/users_guide/postprocessing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Analyzing Your Results
======================
PyFluent postprocessing supports graphics and plotting.

Rendering Graphics Objects
--------------------------
The post package library is used for rendering graphics objects.
The following graphics operations are supported.

Displaying Mesh Objects
~~~~~~~~~~~~~~~~~~~~~~~
The following example demonstrates how you can display the mesh object:

.. code:: python
import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples
from ansys.fluent.post import set_config
from ansys.fluent.post.matplotlib import Plots
from ansys.fluent.post.pyvista import Graphics
set_config(blocking=True, set_view_on_display="isometric")
import_case = examples.download_file(
filename="exhaust_system.cas.h5", directory="pyfluent/exhaust_system"
)
import_data = examples.download_file(
filename="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
)
session = pyfluent.launch_fluent(precision="double", processor_count=2)
session.solver.tui.file.read_case(case_file_name=import_case)
session.solver.tui.file.read_data(case_file_name=import_data)
graphics = Graphics(session=session)
mesh1 = graphics.Meshes["mesh-1"]
mesh1.show_edges = True
mesh1.surfaces_list = [
"in1",
"in2",
"in3",
"out1",
"solid_up:1",
"solid_up:1:830",
"solid_up:1:830-shadow",
]
mesh1.display("window-1")
Displaying Iso-Surfaces
~~~~~~~~~~~~~~~~~~~~~~~
The following example demonstrates how you can display the iso-surface:

.. code:: python
surf_outlet_plane = graphics.Surfaces["outlet-plane"]
surf_outlet_plane.surface.type = "iso-surface"
iso_surf1 = surf_outlet_plane.surface.iso_surface
iso_surf1.field = "y-coordinate"
iso_surf1.iso_value = -0.125017
surf_outlet_plane.display("window-2")
Displaying Contours
~~~~~~~~~~~~~~~~~~~
The following example demonstrates how you can display the contour object:

.. code:: python
temperature_contour_manifold = graphics.Contours["contour-temperature-manifold"]
temperature_contour_manifold.field = "temperature"
temperature_contour_manifold.surfaces_list = [
"in1",
"in2",
"in3",
"out1",
"solid_up:1",
"solid_up:1:830",
]
temperature_contour_manifold.display("window-3")
Displaying Vectors
~~~~~~~~~~~~~~~~~~
The following example demonstrates how you can display the vector object:

.. code:: python
velocity_vector = graphics.Vectors["velocity-vector"]
velocity_vector.surfaces_list = ["outlet-plane"]
velocity_vector.scale = 1
velocity_vector.display("window-4")
Plotting Your Data
------------------
The following plotting operations are supported.

Displaying XY Plots
~~~~~~~~~~~~~~~~~~~
The following example demonstrates how you can display the xy plot:

.. code:: python
plots_session_1 = Plots(session)
plot_1 = plots_session_1.XYPlots["plot-1"]
plot_1.surfaces_list = ["outlet"]
plot_1.y_axis_function = "temperature"
plot_1.plot("window-5")
4 changes: 2 additions & 2 deletions examples/00-postprocessing/README.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Post Processing Examples
Postprocessing Examples
========================
These examples demonstrate how to the PyVista package to post process Fluent
These examples demonstrate how to use the PyVista package to postprocess Fluent
results.
20 changes: 14 additions & 6 deletions examples/00-postprocessing/post_processing_exhaust_manifold.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
""".. _ref_post_processing_exhaust_manifold:
Post Processing using PyVista and Matplotlib: Exhaust Manifold
--------------------------------------------------------------
Postprocessing using PyVista and Matplotlib
---------------------------------------------
This example demonstrates the postprocessing capabilities of PyFluent
(using PyVista and Matplotlib) using a 3D model
of an exhaust manifold with high temperature flows passing through.
The flow through the manifold is turbulent and
involves conjugate heat transfer.
This example demonstrates how to do the following:
This example demonstrates postprocessing using pyvista
- Create surfaces for the display of 3D data.
- Display filled contours of temperature on several surfaces.
- Display velocity vectors.
- Plot quantitative results using Matplotlib
"""
# sphinx_gallery_thumbnail_number = -3

###############################################################################
import ansys.fluent.core as pyfluent
from ansys.fluent.core import examples

from ansys.fluent.post import set_config
from ansys.fluent.post.matplotlib import Plots
from ansys.fluent.post.pyvista import Graphics
Expand All @@ -36,7 +39,7 @@
filename="exhaust_system.dat.h5", directory="pyfluent/exhaust_system"
)

session = pyfluent.launch_fluent(precision="double", processor_count=4)
session = pyfluent.launch_fluent(precision="double", processor_count=2)

session.solver.tui.file.read_case(case_file_name=import_case)
session.solver.tui.file.read_data(case_file_name=import_data)
Expand Down Expand Up @@ -125,8 +128,8 @@
# Currently using outlet-plane since mid-plane is affected by Issue # 276

velocity_vector = graphics.Vectors["velocity-vector"]
velocity_vector.surfaces_list = ["outlet-plane"]
velocity_vector.scale = 1
velocity_vector.surfaces_list = ["solid_up:1:830"]
velocity_vector.scale = 2
velocity_vector.display("window-6")

###############################################################################
Expand All @@ -146,3 +149,8 @@
###############################################################################
# Plot the created XY-Plot
plot_1.plot("window-7")

#########################################################################
# Close Fluent

session.exit()
Loading

0 comments on commit 9efbcdd

Please sign in to comment.