Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Post processing with pyVista #21

Merged
merged 31 commits into from
Feb 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
646b0e1
Post processing with pyVista
ajain-work Jan 24, 2022
5075c14
pyVista post processing
ajain-work Jan 25, 2022
91eb370
pyVista post processing
ajain-work Jan 25, 2022
9dfc579
pyVista post processing
ajain-work Jan 25, 2022
378179f
pyVista post processing
ajain-work Jan 25, 2022
1f34fe3
pyVista Post processing
ajain-work Jan 27, 2022
b7c9bb6
pyVista post processing
ajain-work Jan 27, 2022
929aa45
pyVista post processing
ajain-work Jan 27, 2022
81a4afe
pyVista Post processing
ajain-work Jan 28, 2022
14416e7
pyVista Post processing
ajain-work Jan 28, 2022
f8354cc
pyVista Post processing
ajain-work Jan 28, 2022
02f3e26
pyVista Post processing
ajain-work Jan 28, 2022
4d6e060
Install pyvista for python-3.10 (#25)
mkundu1 Jan 28, 2022
ba9f6fc
Corrected Iso surface range
ajain-work Jan 28, 2022
1cf424a
Merge branch 'feat/pyvista_postprocessing' of https://github.com/pyan…
ajain-work Jan 31, 2022
76da8ec
Container to store collection
ajain-work Jan 31, 2022
87dae43
Container to store collection
ajain-work Jan 31, 2022
72f128d
Merge pull request #27 from pyansys/feat/postprocessing_container
ajain-work Jan 31, 2022
de79260
Corrected readme
ajain-work Jan 31, 2022
c3494cb
Specify pyvista whl in setup.py (#35)
mkundu1 Feb 1, 2022
7b22b39
PyVista Post processing
ajain-work Feb 1, 2022
1a36a81
Merge branch 'feat/pyvista_postprocessing' of https://github.com/pyan…
ajain-work Feb 4, 2022
debc849
pyVista post processing
ajain-work Feb 4, 2022
e613239
pyVista post processing
ajain-work Feb 4, 2022
9ab895d
PyVista Postprocessing
ajain-work Feb 4, 2022
ca6698a
Multi plotters support
ajain-work Feb 4, 2022
1bd2af4
Multiple plotters
ajain-work Feb 4, 2022
200da3e
Multiple plotters
ajain-work Feb 4, 2022
9a4cc8a
Multiple plotters
ajain-work Feb 4, 2022
c124109
Multiple plotters
ajain-work Feb 4, 2022
78991b9
Merge pull request #48 from pyansys/feat/multi_plotters_support
ajain-work Feb 4, 2022
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: 2 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
[flake8]
exclude = venv, tui.py, ansys/api/fluent
per-file-ignores =
Copy link
Collaborator

@dnwillia-work dnwillia-work Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, what was causing the error. The naming looks ok. @ajain-ansys

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class names should use CapWords convention

Copy link
Collaborator

@dnwillia-work dnwillia-work Feb 4, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes and I'm not seeing why you need to ignore that error? It looks like you are using CapWords already. @ajain-ansys

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I did not stare at it hard enough. It's because the member classes not following that naming convention.

Is there a reason the members are not following that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Member classes represent, object properties. We are not following CapWords convention for properties, because that is how we are accessing them. For example field for a contour object is accessed as: contour1.field.

Copy link
Collaborator

@dnwillia-work dnwillia-work Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, ok, but I still don't understand. Is there any reason it can't be contour1.Field? For instance, is there is an external requirement driving this design choice? @ajain-ansys

OK, sorry if I'm being dense, but Is it just that the other commands are all using lower case with underscores?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is correct. Other commands are all using lower case. For example, all commands in auto generated file tui.py are lower case.

Copy link
Collaborator

@dnwillia-work dnwillia-work Feb 7, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, very sorry, now I got it.

ansys/fluent/postprocessing/pyvista/graphics.py:N801
select = W191, W291, W293, W391, E115, E117, E122, E124, E125, E225, E231, E301, E303, E501, F401, F403, N801, N802, N803, N804, N805, N806
count = True
max-complexity = 10
Expand Down
56 changes: 46 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: |
make flake8

testimport:
test-import:
name: Smoke Tests
runs-on: ${{ matrix.os }}
strategy:
Expand Down Expand Up @@ -67,16 +67,54 @@ jobs:
Python-${{ runner.os }}-${{ matrix.python-version }}

- name: Install pyfluent
run: |
make install
run: make install

- name: Test import
run: |
make test-import
run: make test-import

test-post-import:
name: Post Import
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
python-version: ['3.7', '3.8', '3.9', '3.10']

steps:
- uses: actions/checkout@v2

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

- name: Linux pip cache
uses: actions/cache@v2
if: ${{ runner.os == 'Linux' }}
with:
path: ~/.cache/pip
key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }}
restore-keys: |
Python-${{ runner.os }}-${{ matrix.python-version }}

- name: Window pip cache
uses: actions/cache@v2
if: ${{ runner.os == 'Windows' }}
with:
path: ~\AppData\Local\pip\Cache
key: Python-${{ runner.os }}-${{ matrix.python-version }}-${{ hashFiles('setup.py') }}-${{ hashFiles('requirements_*.txt') }}
restore-keys: |
Python-${{ runner.os }}-${{ matrix.python-version }}

- name: Install pyfluent
run: make install

- name: Test post import
run: make test-post-import

build_test:
name: Build and Unit Testing
needs: testimport
needs: test-import
runs-on: ubuntu-latest

steps:
Expand All @@ -96,12 +134,10 @@ jobs:
Python-${{ runner.os }}-${{ matrix.python-version }}

- name: Install pyfluent
run: |
make install
run: make install

- name: Unit Testing
run: |
make unittest
run: make unittest

- name: Check package
run: |
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ install:
test-import:
@python -c "import ansys.fluent.solver as pyfluent"

test-post-import:
@python -c "import ansys.fluent.postprocessing.pyvista as pv"

unittest:
@echo "Running unittest"
@pip install -r requirements_test.txt
Expand Down
86 changes: 76 additions & 10 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,8 @@ Usage
session.check_health()
session.tui.solver.file.read_case(case_file_name='elbow.cas.gz')
session.tui.solver.define.models.unsteady_2nd_order("yes")
session.tui.solver.solve.initialize.initialize_flow()
session.tui.solver.solve.initialize.initialize_flow()
session.tui.solver.solve.dual_time_iterate(number_of_time_steps=2, maximum_number_of_iterations_per_time_step=3)
session.tui.solver.display.objects.contour['contour-1'] = {'boundary_values': True, 'color_map': {'color': 'field-velocity', 'font_automatic': True, 'font_name': 'Helvetica', 'font_size': 0.032, 'format': '%0.2e', 'length': 0.54, 'log_scale': False, 'position': 1, 'show_all': True, 'size': 100, 'user_skip': 9, 'visible': True, 'width': 6.0}, 'coloring': {'smooth': False}, 'contour_lines': False, 'display_state_name': 'None', 'draw_mesh': False, 'field': 'pressure', 'filled': True, 'mesh_object': '', 'node_values': True, 'range_option': {'auto_range_on': {'global_range': True}}, 'surfaces_list': [2, 5]}
session.tui.solver.display.objects.contour['contour-1']()
session.tui.solver.display.objects.contour['contour-1'].field.set_state('velocity-magnitude')
session.tui.solver.display.objects.contour['contour-1'].field()
session.tui.solver.display.objects.contour['contour-1'].color_map.size.set_state(80.0)
session.tui.solver.display.objects.contour['contour-1'].color_map.size()
session.tui.solver.display.objects.contour['contour-1'].rename('my-contour')
del session.tui.solver.display.objects.contour['my-contour']


Settings objects
****************
Expand All @@ -56,3 +47,78 @@ Settings objects provide a more natural way to access and modify Fluent settings
Meshing TUI and workflow
************************
TUI and meshing workflows from Fluent meshing are exposed. Please check `meshing.rst <https://github.com/pyansys/pyfluent/blob/main/doc/meshing.rst>`_ for example usage.


Post Processing
***************

In Fluent (server)
^^^^^^^^^^^^^^^^^^

.. code:: python

session.tui.solver.display.objects.contour['contour-1'] = {'boundary_values': True, 'color_map': {'color': 'field-velocity', 'font_automatic': True, 'font_name': 'Helvetica', 'font_size': 0.032, 'format': '%0.2e', 'length': 0.54, 'log_scale': False, 'position': 1, 'show_all': True, 'size': 100, 'user_skip': 9, 'visible': True, 'width': 6.0}, 'coloring': {'smooth': False}, 'contour_lines': False, 'display_state_name': 'None', 'draw_mesh': False, 'field': 'pressure', 'filled': True, 'mesh_object': '', 'node_values': True, 'range_option': {'auto_range_on': {'global_range': True}}, 'surfaces_list': [2, 5]}
session.tui.solver.display.objects.contour['contour-1']()
session.tui.solver.display.objects.contour['contour-1'].field.set_state('velocity-magnitude')
session.tui.solver.display.objects.contour['contour-1'].field()
session.tui.solver.display.objects.contour['contour-1'].color_map.size.set_state(80.0)
session.tui.solver.display.objects.contour['contour-1'].color_map.size()
session.tui.solver.display.objects.contour['contour-1'].rename('my-contour')
del session.tui.solver.display.objects.contour['my-contour']

PyVista (client)
^^^^^^^^^^^^^^^^

.. code:: python

#import module
import ansys.fluent.postprocessing.pyvista as pv

#get the graphics objects for the session

graphics_session1 = pv.Graphics(session)
mesh1 = graphics_session1.Meshes["mesh-1"]
contour1 = graphics_session1.Contours["contour-1"]
contour2 = graphics_session1.Contours["contour-2"]
surface1 = graphics_session1.Surfaces["surface-1"]

#set graphics objects properties

#mesh
mesh1.show_edges = True
mesh1.surfaces_list = ['symmetry']

#contour
contour1.field = "velocity-magnitude"
contour1.surfaces_list = ['symmetry']

contour2.field = "temperature"
contour2.surfaces_list = ['symmetry', 'wall']

#copy
graphics_session1.Contours["contour-3"] = contour2()

#update
contour3 = graphics_session1.Contours["contour-3"]
contour3.update(contour1())

#delete
del graphics_session1.Contours["contour-3"]

#loop
for name, _ in graphics_session1.Contours.items():
print(name)

#iso surface
surface1.surface_type.iso_surface.field= "velocity-magnitude"
surface1.surface_type.iso_surface.rendering= "contour"

#display in default plotter
contour1.display()
mesh1.display()
surface1.display()

#display in seprate plotter e.g. plotter-2
contour1.display("plotter-2")

session.exit()
2 changes: 2 additions & 0 deletions ansys/fluent/postprocessing/pyvista/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from ansys.fluent.postprocessing.pyvista.plotter import plotter # noqa: F401
from ansys.fluent.postprocessing.pyvista.graphics import Graphics # noqa: F401
Loading