ansys-turbogrid-core 0.3.dev0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ansys_turbogrid_core-0.3.dev0/LICENSE +21 -0
- ansys_turbogrid_core-0.3.dev0/PKG-INFO +197 -0
- ansys_turbogrid_core-0.3.dev0/README.rst +150 -0
- ansys_turbogrid_core-0.3.dev0/pyproject.toml +105 -0
- ansys_turbogrid_core-0.3.dev0/src/ansys/turbogrid/core/__init__.py +13 -0
- ansys_turbogrid_core-0.3.dev0/src/ansys/turbogrid/core/launcher/launcher.py +168 -0
- ansys_turbogrid_core-0.3.dev0/src/ansys/turbogrid/core/mesh_statistics/__init__.py +0 -0
- ansys_turbogrid_core-0.3.dev0/src/ansys/turbogrid/core/mesh_statistics/mesh_statistics.py +280 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 ANSYS, Inc. All rights reserved.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: ansys-turbogrid-core
|
|
3
|
+
Version: 0.3.dev0
|
|
4
|
+
Summary: A python wrapper for Ansys TurboGrid
|
|
5
|
+
Author-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
6
|
+
Maintainer-email: "ANSYS, Inc." <pyansys.core@ansys.com>
|
|
7
|
+
Requires-Python: >=3.8,<4
|
|
8
|
+
Description-Content-Type: text/x-rst
|
|
9
|
+
Classifier: Development Status :: 4 - Beta
|
|
10
|
+
Classifier: Intended Audience :: Science/Research
|
|
11
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
12
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
13
|
+
Classifier: Operating System :: OS Independent
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Requires-Dist: ansys-turbogrid-api>=0.3.dev0
|
|
20
|
+
Requires-Dist: matplotlib>=3.5.1
|
|
21
|
+
Requires-Dist: importlib-metadata>=4.0
|
|
22
|
+
Requires-Dist: ansys-sphinx-theme==0.9.9 ; extra == "doc"
|
|
23
|
+
Requires-Dist: autodocsumm==0.2.11 ; extra == "doc"
|
|
24
|
+
Requires-Dist: ipyvtklink==0.2.3 ; extra == "doc"
|
|
25
|
+
Requires-Dist: jupyter_sphinx==0.4.0 ; extra == "doc"
|
|
26
|
+
Requires-Dist: jupytext==1.14.6 ; extra == "doc"
|
|
27
|
+
Requires-Dist: nbconvert==7.6.0 ; extra == "doc"
|
|
28
|
+
Requires-Dist: nbsphinx==0.9.2 ; extra == "doc"
|
|
29
|
+
Requires-Dist: notebook==6.5.4 ; extra == "doc"
|
|
30
|
+
Requires-Dist: numpydoc==1.5.0 ; extra == "doc"
|
|
31
|
+
Requires-Dist: panel==1.1.1 ; extra == "doc"
|
|
32
|
+
Requires-Dist: Sphinx==7.0.1 ; extra == "doc"
|
|
33
|
+
Requires-Dist: sphinx-autoapi==2.1.1 ; extra == "doc"
|
|
34
|
+
Requires-Dist: sphinx-autodoc-typehints==1.23.2 ; extra == "doc"
|
|
35
|
+
Requires-Dist: sphinx-copybutton==0.5.2 ; extra == "doc"
|
|
36
|
+
Requires-Dist: sphinx-gallery==0.13.0 ; extra == "doc"
|
|
37
|
+
Requires-Dist: matplotlib>=3.5.1 ; extra == "tests"
|
|
38
|
+
Requires-Dist: pytest==7.2.2 ; extra == "tests"
|
|
39
|
+
Requires-Dist: pytest-cov==4.1.0 ; extra == "tests"
|
|
40
|
+
Project-URL: Documentation, https://turbogrid.docs.pyansys.com/version/stable/
|
|
41
|
+
Project-URL: Homepage, https://turbogrid.docs.pyansys.com
|
|
42
|
+
Project-URL: Source, https://github.com/ansys/pyturbogrid
|
|
43
|
+
Project-URL: Tracker, https://github.com/ansys/pyturbogrid/issues
|
|
44
|
+
Provides-Extra: doc
|
|
45
|
+
Provides-Extra: tests
|
|
46
|
+
|
|
47
|
+
PyTurboGrid
|
|
48
|
+
================
|
|
49
|
+
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black|
|
|
50
|
+
|
|
51
|
+
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
|
|
52
|
+
:target: https://docs.pyansys.com/
|
|
53
|
+
:alt: PyAnsys
|
|
54
|
+
|
|
55
|
+
.. |python| image:: https://img.shields.io/pypi/pyversions/pyturbogrid?logo=pypi
|
|
56
|
+
:target: https://pypi.org/project/pyturbogrid/
|
|
57
|
+
:alt: Python
|
|
58
|
+
|
|
59
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/pyturbogrid.svg?logo=python&logoColor=white
|
|
60
|
+
:target: https://pypi.org/project/pyturbogrid
|
|
61
|
+
:alt: PyPI
|
|
62
|
+
|
|
63
|
+
.. |codecov| image:: https://codecov.io/gh/ansys/pyturbogrid/branch/main/graph/badge.svg
|
|
64
|
+
:target: https://codecov.io/gh/ansys/pyturbogrid
|
|
65
|
+
:alt: Codecov
|
|
66
|
+
|
|
67
|
+
.. |GH-CI| image:: https://github.com/ansys/pyturbogrid/actions/workflows/ci.yml/badge.svg
|
|
68
|
+
:target: https://github.com/ansys/pyturbogrid/actions/workflows/ci.yml
|
|
69
|
+
:alt: GH-CI
|
|
70
|
+
|
|
71
|
+
.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
72
|
+
:target: https://opensource.org/licenses/MIT
|
|
73
|
+
:alt: MIT
|
|
74
|
+
|
|
75
|
+
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
|
|
76
|
+
:target: https://github.com/psf/black
|
|
77
|
+
:alt: Black
|
|
78
|
+
|
|
79
|
+
.. |intro| image:: https://github.com/ansys/pyturbogrid/raw/main/doc/source/_static/turbine_blade_squealer_tip_conformal_white_rounded.png
|
|
80
|
+
:alt: TurboGrid
|
|
81
|
+
:width: 600
|
|
82
|
+
|
|
83
|
+
PyTurboGrid is a Python wrapper for `Ansys TurboGrid`_, a high-quality turbomachinery
|
|
84
|
+
meshing software app. To run PyTurboGrid, you must have access to a licensed local copy
|
|
85
|
+
of TurboGrid. PyTurboGrid supports Ansys TurboGrid 2023 R2 and later.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|intro|
|
|
89
|
+
|
|
90
|
+
.. inclusion-marker-do-not-remove
|
|
91
|
+
|
|
92
|
+
Installation
|
|
93
|
+
------------
|
|
94
|
+
The ``ansys-turbogrid-core`` package supports Python 3.10 on Windows and Linux. Two modes
|
|
95
|
+
of installation are available:
|
|
96
|
+
|
|
97
|
+
- User installation
|
|
98
|
+
- Developer installation
|
|
99
|
+
|
|
100
|
+
User installation
|
|
101
|
+
~~~~~~~~~~~~~~~~~
|
|
102
|
+
To use PyTurboGrid, you must install the ``ansys-turbogrid-core`` package from `PyPI`_.
|
|
103
|
+
|
|
104
|
+
#. To ensure that you have the latest version of `pip`_, run this command:
|
|
105
|
+
|
|
106
|
+
.. code:: bash
|
|
107
|
+
|
|
108
|
+
python -m pip install -U pip
|
|
109
|
+
|
|
110
|
+
#. To install PyTurboGrid, run this command:
|
|
111
|
+
|
|
112
|
+
.. code:: bash
|
|
113
|
+
|
|
114
|
+
python -m pip install ansys-turbogrid-core
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
Developer installation
|
|
118
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
119
|
+
A developer installation consists of cloning the ``pyturbogrid`` repository
|
|
120
|
+
and installing the project in editable mode. When you install PyTurboGrid from
|
|
121
|
+
source code, you can modify and enhance the code.
|
|
122
|
+
|
|
123
|
+
Overall guidance on contributing to a PyAnsys library appears in the
|
|
124
|
+
`Contributing <https://dev.docs.pyansys.com/how-to/contributing.html>`_ topic
|
|
125
|
+
in the *PyAnsys Developer's Guide*. Ensure that you are thoroughly familiar
|
|
126
|
+
with this `guide <https://dev.docs.pyansys.com/>_` before attempting to
|
|
127
|
+
contribute to PyTurboGrid.
|
|
128
|
+
|
|
129
|
+
#. Clone the ``pyturbogrid`` repository:
|
|
130
|
+
|
|
131
|
+
.. code:: bash
|
|
132
|
+
|
|
133
|
+
git clone https://github.com/ansys/pyturbogrid.git
|
|
134
|
+
|
|
135
|
+
|
|
136
|
+
#. To avoid incompatibilites in requirements when working in multiple
|
|
137
|
+
Python projects, create and activate a virtual environment. For
|
|
138
|
+
more information, see `Virtual environments`_ in the *PyAnsys
|
|
139
|
+
Developer's Guide*.
|
|
140
|
+
|
|
141
|
+
#. To ensure that you have the latest version of `pip`_, run this command:
|
|
142
|
+
|
|
143
|
+
.. code:: bash
|
|
144
|
+
|
|
145
|
+
python -m pip install -U pip
|
|
146
|
+
|
|
147
|
+
#. Assuming that your current working directory is the top-level directory
|
|
148
|
+
of your locally cloned ``pyturbogrid`` repository, install PyTurboGrid
|
|
149
|
+
from this local repository in editable mode by running this command:
|
|
150
|
+
|
|
151
|
+
.. code:: bash
|
|
152
|
+
|
|
153
|
+
python -m pip install -e .
|
|
154
|
+
|
|
155
|
+
Requirements
|
|
156
|
+
------------
|
|
157
|
+
You must have a licensed local installation of Ansys TurboGrid 2023 R2 or later.
|
|
158
|
+
|
|
159
|
+
The ``AWP_ROOTxxx`` environment variable, where ``xxx`` is the three-digit
|
|
160
|
+
Ansys version, allows PyTurboGrid to find your local TurboGrid installation.
|
|
161
|
+
|
|
162
|
+
A Windows installation automatically sets this root environment variable.
|
|
163
|
+
For example, if you install Ansys 2023 R2 in the default directory,
|
|
164
|
+
the installer sets the ``AWP_ROOT232`` environment variable to
|
|
165
|
+
``C:\Program Files\ANSYS Inc\v232``.
|
|
166
|
+
|
|
167
|
+
A Linux installation does not automatically set this root environment
|
|
168
|
+
variable. For example, if you install Ansys 2023 R2 in the default
|
|
169
|
+
directory, you must manually set the ``AWP_ROOT232`` environment
|
|
170
|
+
variable to ``/usr/ansys_inc/v232``.
|
|
171
|
+
|
|
172
|
+
License and acknowledgments
|
|
173
|
+
---------------------------
|
|
174
|
+
|
|
175
|
+
PyTurboGrid is licensed under the MIT license.
|
|
176
|
+
|
|
177
|
+
PyTurboGrid makes no commercial claim over Ansys whatsoever. This library extends the
|
|
178
|
+
functionality of Ansys TurboGrid by adding a Python interface to TurboGrid without
|
|
179
|
+
changing the core behavior or license of the original software. The use of the
|
|
180
|
+
interactive control of PyTurboGrid requires a legally licensed local copy of TurboGrid.
|
|
181
|
+
|
|
182
|
+
For more information on TurboGrid, see the `Ansys TurboGrid`_ page on the Ansys website.
|
|
183
|
+
|
|
184
|
+
.. LINKS AND REFERENCES
|
|
185
|
+
.. _Ansys TurboGrid: https://www.ansys.com/products/fluids/ansys-turbogrid
|
|
186
|
+
.. _black: https://github.com/psf/black
|
|
187
|
+
.. _flake8: https://flake8.pycqa.org/en/latest/
|
|
188
|
+
.. _isort: https://github.com/PyCQA/isort
|
|
189
|
+
.. _pip: https://pypi.org/project/pip/
|
|
190
|
+
.. _pre-commit: https://pre-commit.com/
|
|
191
|
+
.. _PyAnsys Developer's Guide: https://dev.docs.pyansys.com/
|
|
192
|
+
.. _pytest: https://docs.pytest.org/en/stable/
|
|
193
|
+
.. _PyPI: https://pypi.org/
|
|
194
|
+
.. _Sphinx: https://www.sphinx-doc.org/en/master/
|
|
195
|
+
.. _tox: https://tox.wiki/
|
|
196
|
+
.. _Virtual environments: https://dev.docs.pyansys.com/how-to/setting-up.html#virtual-environments
|
|
197
|
+
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
PyTurboGrid
|
|
2
|
+
================
|
|
3
|
+
|pyansys| |python| |pypi| |GH-CI| |codecov| |MIT| |black|
|
|
4
|
+
|
|
5
|
+
.. |pyansys| image:: https://img.shields.io/badge/Py-Ansys-ffc107.svg?logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAIAAACQkWg2AAABDklEQVQ4jWNgoDfg5mD8vE7q/3bpVyskbW0sMRUwofHD7Dh5OBkZGBgW7/3W2tZpa2tLQEOyOzeEsfumlK2tbVpaGj4N6jIs1lpsDAwMJ278sveMY2BgCA0NFRISwqkhyQ1q/Nyd3zg4OBgYGNjZ2ePi4rB5loGBhZnhxTLJ/9ulv26Q4uVk1NXV/f///////69du4Zdg78lx//t0v+3S88rFISInD59GqIH2esIJ8G9O2/XVwhjzpw5EAam1xkkBJn/bJX+v1365hxxuCAfH9+3b9/+////48cPuNehNsS7cDEzMTAwMMzb+Q2u4dOnT2vWrMHu9ZtzxP9vl/69RVpCkBlZ3N7enoDXBwEAAA+YYitOilMVAAAAAElFTkSuQmCC
|
|
6
|
+
:target: https://docs.pyansys.com/
|
|
7
|
+
:alt: PyAnsys
|
|
8
|
+
|
|
9
|
+
.. |python| image:: https://img.shields.io/pypi/pyversions/pyturbogrid?logo=pypi
|
|
10
|
+
:target: https://pypi.org/project/pyturbogrid/
|
|
11
|
+
:alt: Python
|
|
12
|
+
|
|
13
|
+
.. |pypi| image:: https://img.shields.io/pypi/v/pyturbogrid.svg?logo=python&logoColor=white
|
|
14
|
+
:target: https://pypi.org/project/pyturbogrid
|
|
15
|
+
:alt: PyPI
|
|
16
|
+
|
|
17
|
+
.. |codecov| image:: https://codecov.io/gh/ansys/pyturbogrid/branch/main/graph/badge.svg
|
|
18
|
+
:target: https://codecov.io/gh/ansys/pyturbogrid
|
|
19
|
+
:alt: Codecov
|
|
20
|
+
|
|
21
|
+
.. |GH-CI| image:: https://github.com/ansys/pyturbogrid/actions/workflows/ci.yml/badge.svg
|
|
22
|
+
:target: https://github.com/ansys/pyturbogrid/actions/workflows/ci.yml
|
|
23
|
+
:alt: GH-CI
|
|
24
|
+
|
|
25
|
+
.. |MIT| image:: https://img.shields.io/badge/License-MIT-yellow.svg
|
|
26
|
+
:target: https://opensource.org/licenses/MIT
|
|
27
|
+
:alt: MIT
|
|
28
|
+
|
|
29
|
+
.. |black| image:: https://img.shields.io/badge/code%20style-black-000000.svg?style=flat
|
|
30
|
+
:target: https://github.com/psf/black
|
|
31
|
+
:alt: Black
|
|
32
|
+
|
|
33
|
+
.. |intro| image:: https://github.com/ansys/pyturbogrid/raw/main/doc/source/_static/turbine_blade_squealer_tip_conformal_white_rounded.png
|
|
34
|
+
:alt: TurboGrid
|
|
35
|
+
:width: 600
|
|
36
|
+
|
|
37
|
+
PyTurboGrid is a Python wrapper for `Ansys TurboGrid`_, a high-quality turbomachinery
|
|
38
|
+
meshing software app. To run PyTurboGrid, you must have access to a licensed local copy
|
|
39
|
+
of TurboGrid. PyTurboGrid supports Ansys TurboGrid 2023 R2 and later.
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|intro|
|
|
43
|
+
|
|
44
|
+
.. inclusion-marker-do-not-remove
|
|
45
|
+
|
|
46
|
+
Installation
|
|
47
|
+
------------
|
|
48
|
+
The ``ansys-turbogrid-core`` package supports Python 3.10 on Windows and Linux. Two modes
|
|
49
|
+
of installation are available:
|
|
50
|
+
|
|
51
|
+
- User installation
|
|
52
|
+
- Developer installation
|
|
53
|
+
|
|
54
|
+
User installation
|
|
55
|
+
~~~~~~~~~~~~~~~~~
|
|
56
|
+
To use PyTurboGrid, you must install the ``ansys-turbogrid-core`` package from `PyPI`_.
|
|
57
|
+
|
|
58
|
+
#. To ensure that you have the latest version of `pip`_, run this command:
|
|
59
|
+
|
|
60
|
+
.. code:: bash
|
|
61
|
+
|
|
62
|
+
python -m pip install -U pip
|
|
63
|
+
|
|
64
|
+
#. To install PyTurboGrid, run this command:
|
|
65
|
+
|
|
66
|
+
.. code:: bash
|
|
67
|
+
|
|
68
|
+
python -m pip install ansys-turbogrid-core
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
Developer installation
|
|
72
|
+
~~~~~~~~~~~~~~~~~~~~~~
|
|
73
|
+
A developer installation consists of cloning the ``pyturbogrid`` repository
|
|
74
|
+
and installing the project in editable mode. When you install PyTurboGrid from
|
|
75
|
+
source code, you can modify and enhance the code.
|
|
76
|
+
|
|
77
|
+
Overall guidance on contributing to a PyAnsys library appears in the
|
|
78
|
+
`Contributing <https://dev.docs.pyansys.com/how-to/contributing.html>`_ topic
|
|
79
|
+
in the *PyAnsys Developer's Guide*. Ensure that you are thoroughly familiar
|
|
80
|
+
with this `guide <https://dev.docs.pyansys.com/>_` before attempting to
|
|
81
|
+
contribute to PyTurboGrid.
|
|
82
|
+
|
|
83
|
+
#. Clone the ``pyturbogrid`` repository:
|
|
84
|
+
|
|
85
|
+
.. code:: bash
|
|
86
|
+
|
|
87
|
+
git clone https://github.com/ansys/pyturbogrid.git
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
#. To avoid incompatibilites in requirements when working in multiple
|
|
91
|
+
Python projects, create and activate a virtual environment. For
|
|
92
|
+
more information, see `Virtual environments`_ in the *PyAnsys
|
|
93
|
+
Developer's Guide*.
|
|
94
|
+
|
|
95
|
+
#. To ensure that you have the latest version of `pip`_, run this command:
|
|
96
|
+
|
|
97
|
+
.. code:: bash
|
|
98
|
+
|
|
99
|
+
python -m pip install -U pip
|
|
100
|
+
|
|
101
|
+
#. Assuming that your current working directory is the top-level directory
|
|
102
|
+
of your locally cloned ``pyturbogrid`` repository, install PyTurboGrid
|
|
103
|
+
from this local repository in editable mode by running this command:
|
|
104
|
+
|
|
105
|
+
.. code:: bash
|
|
106
|
+
|
|
107
|
+
python -m pip install -e .
|
|
108
|
+
|
|
109
|
+
Requirements
|
|
110
|
+
------------
|
|
111
|
+
You must have a licensed local installation of Ansys TurboGrid 2023 R2 or later.
|
|
112
|
+
|
|
113
|
+
The ``AWP_ROOTxxx`` environment variable, where ``xxx`` is the three-digit
|
|
114
|
+
Ansys version, allows PyTurboGrid to find your local TurboGrid installation.
|
|
115
|
+
|
|
116
|
+
A Windows installation automatically sets this root environment variable.
|
|
117
|
+
For example, if you install Ansys 2023 R2 in the default directory,
|
|
118
|
+
the installer sets the ``AWP_ROOT232`` environment variable to
|
|
119
|
+
``C:\Program Files\ANSYS Inc\v232``.
|
|
120
|
+
|
|
121
|
+
A Linux installation does not automatically set this root environment
|
|
122
|
+
variable. For example, if you install Ansys 2023 R2 in the default
|
|
123
|
+
directory, you must manually set the ``AWP_ROOT232`` environment
|
|
124
|
+
variable to ``/usr/ansys_inc/v232``.
|
|
125
|
+
|
|
126
|
+
License and acknowledgments
|
|
127
|
+
---------------------------
|
|
128
|
+
|
|
129
|
+
PyTurboGrid is licensed under the MIT license.
|
|
130
|
+
|
|
131
|
+
PyTurboGrid makes no commercial claim over Ansys whatsoever. This library extends the
|
|
132
|
+
functionality of Ansys TurboGrid by adding a Python interface to TurboGrid without
|
|
133
|
+
changing the core behavior or license of the original software. The use of the
|
|
134
|
+
interactive control of PyTurboGrid requires a legally licensed local copy of TurboGrid.
|
|
135
|
+
|
|
136
|
+
For more information on TurboGrid, see the `Ansys TurboGrid`_ page on the Ansys website.
|
|
137
|
+
|
|
138
|
+
.. LINKS AND REFERENCES
|
|
139
|
+
.. _Ansys TurboGrid: https://www.ansys.com/products/fluids/ansys-turbogrid
|
|
140
|
+
.. _black: https://github.com/psf/black
|
|
141
|
+
.. _flake8: https://flake8.pycqa.org/en/latest/
|
|
142
|
+
.. _isort: https://github.com/PyCQA/isort
|
|
143
|
+
.. _pip: https://pypi.org/project/pip/
|
|
144
|
+
.. _pre-commit: https://pre-commit.com/
|
|
145
|
+
.. _PyAnsys Developer's Guide: https://dev.docs.pyansys.com/
|
|
146
|
+
.. _pytest: https://docs.pytest.org/en/stable/
|
|
147
|
+
.. _PyPI: https://pypi.org/
|
|
148
|
+
.. _Sphinx: https://www.sphinx-doc.org/en/master/
|
|
149
|
+
.. _tox: https://tox.wiki/
|
|
150
|
+
.. _Virtual environments: https://dev.docs.pyansys.com/how-to/setting-up.html#virtual-environments
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["flit_core >=3.2,<4"]
|
|
3
|
+
build-backend = "flit_core.buildapi"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
# Check https://flit.readthedocs.io/en/latest/pyproject_toml.html for all available sections
|
|
7
|
+
name = "ansys-turbogrid-core"
|
|
8
|
+
version = "0.3.dev0"
|
|
9
|
+
description = "A python wrapper for Ansys TurboGrid"
|
|
10
|
+
readme = "README.rst"
|
|
11
|
+
requires-python = ">=3.8,<4"
|
|
12
|
+
license = {file = "LICENSE"}
|
|
13
|
+
|
|
14
|
+
authors = [
|
|
15
|
+
{name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"},
|
|
16
|
+
]
|
|
17
|
+
maintainers = [
|
|
18
|
+
{name = "ANSYS, Inc.", email = "pyansys.core@ansys.com"},
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
classifiers = [
|
|
22
|
+
"Development Status :: 4 - Beta",
|
|
23
|
+
"Intended Audience :: Science/Research",
|
|
24
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
25
|
+
"License :: OSI Approved :: MIT License",
|
|
26
|
+
"Operating System :: OS Independent",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.8",
|
|
29
|
+
"Programming Language :: Python :: 3.9",
|
|
30
|
+
"Programming Language :: Python :: 3.10",
|
|
31
|
+
"Programming Language :: Python :: 3.11",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
dependencies = [
|
|
35
|
+
"ansys-turbogrid-api>=0.3.dev0",
|
|
36
|
+
"matplotlib>=3.5.1",
|
|
37
|
+
"importlib-metadata>=4.0",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
tests = [
|
|
42
|
+
"matplotlib>=3.5.1",
|
|
43
|
+
"pytest==7.2.2",
|
|
44
|
+
"pytest-cov==4.1.0",
|
|
45
|
+
]
|
|
46
|
+
doc = [
|
|
47
|
+
"ansys-sphinx-theme==0.9.9",
|
|
48
|
+
"autodocsumm==0.2.11",
|
|
49
|
+
"ipyvtklink==0.2.3",
|
|
50
|
+
"jupyter_sphinx==0.4.0",
|
|
51
|
+
"jupytext==1.14.6",
|
|
52
|
+
"nbconvert==7.6.0",
|
|
53
|
+
"nbsphinx==0.9.2",
|
|
54
|
+
"notebook==6.5.4",
|
|
55
|
+
"numpydoc==1.5.0",
|
|
56
|
+
"panel==1.1.1",
|
|
57
|
+
"Sphinx==7.0.1",
|
|
58
|
+
"sphinx-autoapi==2.1.1",
|
|
59
|
+
"sphinx-autodoc-typehints==1.23.2",
|
|
60
|
+
"sphinx-copybutton==0.5.2",
|
|
61
|
+
"sphinx-gallery==0.13.0",
|
|
62
|
+
]
|
|
63
|
+
|
|
64
|
+
[project.urls]
|
|
65
|
+
Source = "https://github.com/ansys/pyturbogrid"
|
|
66
|
+
Homepage = "https://turbogrid.docs.pyansys.com"
|
|
67
|
+
Documentation = "https://turbogrid.docs.pyansys.com/version/stable/"
|
|
68
|
+
Tracker = "https://github.com/ansys/pyturbogrid/issues"
|
|
69
|
+
|
|
70
|
+
[tool.flit.module]
|
|
71
|
+
name = "ansys.turbogrid.core"
|
|
72
|
+
|
|
73
|
+
[tool.black]
|
|
74
|
+
line-length = 100
|
|
75
|
+
|
|
76
|
+
[tool.isort]
|
|
77
|
+
profile = "black"
|
|
78
|
+
force_sort_within_sections = true
|
|
79
|
+
line_length = 120
|
|
80
|
+
default_section = "THIRDPARTY"
|
|
81
|
+
src_paths = ["doc", "src", "tests"]
|
|
82
|
+
|
|
83
|
+
[[tool.poetry.source]]
|
|
84
|
+
name = "privatepypi"
|
|
85
|
+
url = "https://pkgs.dev.azure.com/pyansys/_packaging/pyansys/pypi/simple/"
|
|
86
|
+
default = false
|
|
87
|
+
secondary = true
|
|
88
|
+
|
|
89
|
+
[tool.poetry.dependencies]
|
|
90
|
+
python = ">=3.7,<4.0"
|
|
91
|
+
ansys-turbogrid-api = {source = "privatepypi"}
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
[tool.coverage.run]
|
|
95
|
+
source = ["ansys.turbogrid.core"]
|
|
96
|
+
|
|
97
|
+
[tool.coverage.report]
|
|
98
|
+
show_missing = true
|
|
99
|
+
|
|
100
|
+
[tool.pytest.ini_options]
|
|
101
|
+
minversion = "7.1"
|
|
102
|
+
addopts = "-ra --cov=ansys.turbogrid.core --cov-report html:.cov/html --cov-report xml:.cov/xml --cov-report term -vv"
|
|
103
|
+
testpaths = [
|
|
104
|
+
"tests",
|
|
105
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Copyright (c) 2023 ANSYS, Inc. All rights reserved
|
|
2
|
+
"""PyTurboGrid is a Python wrapper for Ansys TurboGrid."""
|
|
3
|
+
|
|
4
|
+
from ansys.turbogrid.core.launcher.launcher import launch_turbogrid
|
|
5
|
+
|
|
6
|
+
try:
|
|
7
|
+
import importlib.metadata as importlib_metadata
|
|
8
|
+
except ModuleNotFoundError: # pragma: no cover
|
|
9
|
+
import importlib_metadata
|
|
10
|
+
|
|
11
|
+
# Read from the pyproject.toml
|
|
12
|
+
# major, minor, patch
|
|
13
|
+
__version__ = importlib_metadata.version("ansys-turbogrid-core")
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
# Copyright (c) 2023 ANSYS, Inc. All rights reserved
|
|
2
|
+
"""Module for launching a local instance of Ansys TurboGrid."""
|
|
3
|
+
|
|
4
|
+
from enum import Enum
|
|
5
|
+
import os
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
import platform
|
|
8
|
+
from typing import Optional
|
|
9
|
+
|
|
10
|
+
from ansys.turbogrid.api import pyturbogrid_core
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def _is_windows():
|
|
14
|
+
"""Check if Windows is the current operating system."""
|
|
15
|
+
return platform.system() == "Windows"
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class TurboGridVersion(Enum):
|
|
19
|
+
"""Provide an enumeration over supported TurboGrid versions."""
|
|
20
|
+
|
|
21
|
+
# Versions must be listed here with the most recent first
|
|
22
|
+
version_23R2 = "23.2.0"
|
|
23
|
+
|
|
24
|
+
@classmethod
|
|
25
|
+
def _missing_(cls, version):
|
|
26
|
+
if isinstance(version, (float, str)):
|
|
27
|
+
version = str(version) + ".0"
|
|
28
|
+
for v in TurboGridVersion:
|
|
29
|
+
if version == v.value:
|
|
30
|
+
return TurboGridVersion(version)
|
|
31
|
+
else:
|
|
32
|
+
raise RuntimeError(
|
|
33
|
+
f"The passed version '{version[:-2]}' does not exist. "
|
|
34
|
+
f"Available version strings are: "
|
|
35
|
+
f"{[ver.value for ver in TurboGridVersion]} "
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
def __str__(self):
|
|
39
|
+
return str(self.value)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def get_latest_ansys_version() -> str:
|
|
43
|
+
"""Get the latest installed Ansys version from ``AWP_ROOTxxx`` environment variables.
|
|
44
|
+
|
|
45
|
+
.. note::
|
|
46
|
+
The ``xxx`` is the three-digit Ansys version. For example, the ``AWP_ROOT232``
|
|
47
|
+
environment variable specifies the path to the directory where Ansys 2023 R2
|
|
48
|
+
is installed. If Ansys 2023 R2 is installed in the default directory on Windows,
|
|
49
|
+
the value for this environment variable is ``C:\\Program Files\\ANSYS Inc\\v232``.
|
|
50
|
+
|
|
51
|
+
Returns
|
|
52
|
+
-------
|
|
53
|
+
str
|
|
54
|
+
Latest installed Ansys version in this format: ``"23.2.0"``.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
for v in TurboGridVersion:
|
|
58
|
+
if "AWP_ROOT" + "".join(str(v).split("."))[:-1] in os.environ:
|
|
59
|
+
return str(v)
|
|
60
|
+
|
|
61
|
+
raise RuntimeError("No Ansys version can be found.")
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def get_turbogrid_exe_path(**launch_argvals) -> Path:
|
|
65
|
+
"""Get the path to a local installation of TurboGrid.
|
|
66
|
+
|
|
67
|
+
The path is obtained by searching in this order:
|
|
68
|
+
|
|
69
|
+
1. The path specified by the ``turbogrid_path`` parameter from ``launch_argvals``.
|
|
70
|
+
2. The path specified by the ``PYTURBOGRID_TURBOGRID_ROOT`` environment variable.
|
|
71
|
+
3. The path of the TurboGrid installation specified by the ``product_version`` parameter
|
|
72
|
+
from ``launch_argvals``, using the corresponding ``AWP_ROOTxxx`` environment variable.
|
|
73
|
+
4. The path of the TurboGrid installation from the ``AWP_ROOTxxx`` environment variable for
|
|
74
|
+
the latest installed Ansys version.
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
Returns
|
|
78
|
+
-------
|
|
79
|
+
Path
|
|
80
|
+
Path of a local TurboGrid installation.
|
|
81
|
+
"""
|
|
82
|
+
|
|
83
|
+
def get_turbogrid_root(version: TurboGridVersion) -> Path:
|
|
84
|
+
awp_root = os.environ["AWP_ROOT" + "".join(str(version).split("."))[:-1]]
|
|
85
|
+
return Path(awp_root) / "TurboGrid"
|
|
86
|
+
|
|
87
|
+
def get_exe_path(turbogrid_root: Path) -> Path:
|
|
88
|
+
if _is_windows():
|
|
89
|
+
return (
|
|
90
|
+
turbogrid_root / "bin" / "cfxtg.exe"
|
|
91
|
+
) # pragma no cover (operating system dependent)
|
|
92
|
+
else:
|
|
93
|
+
return turbogrid_root / "bin" / "cfxtg" # pragma no cover (operating system dependent)
|
|
94
|
+
|
|
95
|
+
# Look for TurboGrid exe path in the following order:
|
|
96
|
+
# 1. turbogrid_path parameter passed with launch_turbogrid
|
|
97
|
+
turbogrid_path = launch_argvals.get("turbogrid_path")
|
|
98
|
+
if turbogrid_path:
|
|
99
|
+
return Path(turbogrid_path)
|
|
100
|
+
|
|
101
|
+
# 2. "PYTURBOGRID_TURBOGRID_ROOT" environment variable
|
|
102
|
+
turbogrid_root = os.getenv("PYTURBOGRID_TURBOGRID_ROOT")
|
|
103
|
+
if turbogrid_root:
|
|
104
|
+
return get_exe_path(Path(turbogrid_root))
|
|
105
|
+
|
|
106
|
+
# 3. product_version parameter passed with launch_turbogrid
|
|
107
|
+
product_version = launch_argvals.get("product_version")
|
|
108
|
+
if product_version:
|
|
109
|
+
return get_exe_path(get_turbogrid_root(TurboGridVersion(product_version)))
|
|
110
|
+
|
|
111
|
+
# 4. the latest Ansys version from AWP_ROOT environment variables
|
|
112
|
+
ansys_version = get_latest_ansys_version()
|
|
113
|
+
return get_exe_path(get_turbogrid_root(TurboGridVersion(ansys_version)))
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
def launch_turbogrid(
|
|
117
|
+
product_version: str = None,
|
|
118
|
+
turbogrid_path: str = None,
|
|
119
|
+
log_level: pyturbogrid_core.PyTurboGrid.TurboGridLogLevel = pyturbogrid_core.PyTurboGrid.TurboGridLogLevel.INFO,
|
|
120
|
+
additional_args_str: str = None,
|
|
121
|
+
additional_kw_args: dict = None,
|
|
122
|
+
port: Optional[int] = None,
|
|
123
|
+
**kwargs,
|
|
124
|
+
) -> pyturbogrid_core.PyTurboGrid:
|
|
125
|
+
"""Launch TurboGrid locally in server mode.
|
|
126
|
+
|
|
127
|
+
Parameters
|
|
128
|
+
----------
|
|
129
|
+
product_version : str, default: ``None``
|
|
130
|
+
Version of TurboGrid to use in the numeric format. For example, ``"23.2.0"``
|
|
131
|
+
for 2023 R2. The default is ``None``, in which case the latest installed
|
|
132
|
+
version is used.
|
|
133
|
+
turbogrid_path : str, default: ``None``
|
|
134
|
+
Path to the ``cfxtg`` command for starting TurboGrid. The default is ``None``,
|
|
135
|
+
in which case the value for the ``product_version`` parameter is used.
|
|
136
|
+
log_level : pyturbogrid_core.PyTurboGrid.TurboGridLogLevel, default: ``INFO``
|
|
137
|
+
Level of logging information written to the terminal. The default is ``INFO``.
|
|
138
|
+
Options are ``INFO``, ``WARNING``, ``ERROR``, ``CRITICAL``, and ``DEBUG``.
|
|
139
|
+
This setting does not affect the level of output that is written to the log files.
|
|
140
|
+
additional_args_str : str, default: ``None``
|
|
141
|
+
Additional arguments to send to TurboGrid.
|
|
142
|
+
additional_kw_args : dict, default: ``None``
|
|
143
|
+
Additional arguments to send to TurboGrid.
|
|
144
|
+
port : int, default: ``None``
|
|
145
|
+
Port for TurboGrid communications. The default is ``None``, in which case
|
|
146
|
+
an available port is automatically selected.
|
|
147
|
+
|
|
148
|
+
Returns
|
|
149
|
+
-------
|
|
150
|
+
pyturbogrid_core.PyTurboGrid
|
|
151
|
+
TurboGrid session.
|
|
152
|
+
"""
|
|
153
|
+
if kwargs:
|
|
154
|
+
raise TypeError(
|
|
155
|
+
f"launch_turbogrid() got an unexpected keyword argument {next(iter(kwargs))}"
|
|
156
|
+
)
|
|
157
|
+
|
|
158
|
+
argVals = locals()
|
|
159
|
+
pathToCFXTG = get_turbogrid_exe_path(**argVals)
|
|
160
|
+
|
|
161
|
+
return pyturbogrid_core.PyTurboGrid(
|
|
162
|
+
socket_port=port,
|
|
163
|
+
turbogrid_location_type=pyturbogrid_core.PyTurboGrid.TurboGridLocationType.TURBOGRID_INSTALL,
|
|
164
|
+
cfxtg_location=pathToCFXTG,
|
|
165
|
+
log_level=log_level,
|
|
166
|
+
additional_args_str=additional_args_str,
|
|
167
|
+
additional_kw_args=additional_kw_args,
|
|
168
|
+
)
|
|
File without changes
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
# Copyright (c) 2023 ANSYS, Inc. All rights reserved
|
|
2
|
+
"""Module for facilitating analysis of mesh statistics."""
|
|
3
|
+
import ansys.turbogrid.api as pytg
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
class MeshStatistics:
|
|
7
|
+
"""
|
|
8
|
+
Facilitates analysis of mesh statistics for the current mesh in a running session of
|
|
9
|
+
TurboGrid.
|
|
10
|
+
"""
|
|
11
|
+
|
|
12
|
+
#: Interface to a running session of TurboGrid.
|
|
13
|
+
interface: pytg.pyturbogrid_core.PyTurboGrid = 0
|
|
14
|
+
|
|
15
|
+
#: Cache of the basic mesh statistics obtained by the last call to the
|
|
16
|
+
#: :func:`update_mesh_statistics` method or from the initialization of
|
|
17
|
+
#: the object if this method has not been called. The name of the domain
|
|
18
|
+
#: these statistics relate to is stored as the :attr:`current_domain`
|
|
19
|
+
#: attribute.
|
|
20
|
+
mesh_vars: dict = dict()
|
|
21
|
+
|
|
22
|
+
#: Domain that was used for the last update of the mesh statistics. See the :attr:`mesh_vars`
|
|
23
|
+
#: attribute.
|
|
24
|
+
current_domain: str = ""
|
|
25
|
+
|
|
26
|
+
def __init__(self, turbogrid_instance: pytg.pyturbogrid_core.PyTurboGrid, domain: str = "ALL"):
|
|
27
|
+
"""
|
|
28
|
+
Initialize the class using a connection to a running session of TurboGrid.
|
|
29
|
+
|
|
30
|
+
Parameters
|
|
31
|
+
----------
|
|
32
|
+
turbogrid_instance : pytg.pyturbogrid_core.PyTurboGrid
|
|
33
|
+
Running session of TurboGrid.
|
|
34
|
+
domain : str, default: ``"ALL"``
|
|
35
|
+
Name of the domain to get the initial statistics from. The default is ``"ALL"``,
|
|
36
|
+
in which case statistics are read for all domains.
|
|
37
|
+
"""
|
|
38
|
+
self.interface = turbogrid_instance
|
|
39
|
+
self.mesh_vars = dict()
|
|
40
|
+
self.current_domain = str()
|
|
41
|
+
self._read_mesh_statistics(domain)
|
|
42
|
+
|
|
43
|
+
def _read_mesh_statistics(self, domain: str = "ALL") -> None:
|
|
44
|
+
self.mesh_vars.clear()
|
|
45
|
+
if "query_mesh_statistics" not in dir(self.interface):
|
|
46
|
+
raise self.interface.InvalidQuery(
|
|
47
|
+
"query_mesh_statistics"
|
|
48
|
+
) # pragma no cover (won't occur with current TurboGrid data)
|
|
49
|
+
self.mesh_vars = self.interface.query_mesh_statistics(domain)
|
|
50
|
+
self.current_domain = domain
|
|
51
|
+
|
|
52
|
+
def get_mesh_statistics(self, variable: str = "ALL") -> dict:
|
|
53
|
+
"""Get the basic mesh statistics from the cached mesh statistics.
|
|
54
|
+
|
|
55
|
+
Parameters
|
|
56
|
+
----------
|
|
57
|
+
variable : str, default: ``"ALL"``
|
|
58
|
+
Mesh statistics variable to get statistics for. The default is
|
|
59
|
+
``"ALL"``, in which case a dictionary of all variables is returned.
|
|
60
|
+
|
|
61
|
+
Returns
|
|
62
|
+
-------
|
|
63
|
+
dict
|
|
64
|
+
If a single variable is specified for the ``variable`` parameter, a
|
|
65
|
+
dictionary of the current mesh statistics values for the selected variable
|
|
66
|
+
is returned. Otherwise, if the default value of ``"ALL"`` is used for the
|
|
67
|
+
``variable`` parameter, a dictionary of dictionaries (one per variable) is
|
|
68
|
+
returned.
|
|
69
|
+
"""
|
|
70
|
+
if variable == "ALL":
|
|
71
|
+
return self.mesh_vars
|
|
72
|
+
else:
|
|
73
|
+
return self.mesh_vars[variable]
|
|
74
|
+
|
|
75
|
+
def update_mesh_statistics(self, domain: str = "ALL") -> None:
|
|
76
|
+
"""Re-read the mesh statistics from TurboGrid.
|
|
77
|
+
|
|
78
|
+
This method can be used either to update the cached mesh statistics after TurboGrid
|
|
79
|
+
has remeshed or update the cached mesh statistics to use a different domain or domains.
|
|
80
|
+
|
|
81
|
+
Parameters
|
|
82
|
+
----------
|
|
83
|
+
domain : str, default: ``"ALL"``
|
|
84
|
+
Name of the domain to get the statistics from. The default is ``"ALL"``, in which
|
|
85
|
+
case statistics are read for all domains.
|
|
86
|
+
"""
|
|
87
|
+
self._read_mesh_statistics(domain)
|
|
88
|
+
|
|
89
|
+
def get_domain_label(self, domain: str) -> str:
|
|
90
|
+
"""Get suitable label text for a domain.
|
|
91
|
+
|
|
92
|
+
Parameters
|
|
93
|
+
----------
|
|
94
|
+
domain : str
|
|
95
|
+
Name of the domain to generate the label from.
|
|
96
|
+
|
|
97
|
+
Returns
|
|
98
|
+
-------
|
|
99
|
+
str
|
|
100
|
+
``"All Domains"`` is returned if ``"ALL"`` is the value
|
|
101
|
+
specified for the ``domain`` parameter or ``"Domain: <name>"``
|
|
102
|
+
is returned if the name of a single domain is specified.
|
|
103
|
+
|
|
104
|
+
"""
|
|
105
|
+
if domain == "ALL":
|
|
106
|
+
domain_label = "All Domains"
|
|
107
|
+
else:
|
|
108
|
+
domain_label = "Domain: " + domain
|
|
109
|
+
return domain_label
|
|
110
|
+
|
|
111
|
+
def _draw_histogram(
|
|
112
|
+
self,
|
|
113
|
+
variable: str,
|
|
114
|
+
bin_limits: list,
|
|
115
|
+
bin_values: list,
|
|
116
|
+
xlabel: str,
|
|
117
|
+
ylabel: str,
|
|
118
|
+
domain_label: str,
|
|
119
|
+
image_file: str,
|
|
120
|
+
show: bool,
|
|
121
|
+
) -> None:
|
|
122
|
+
import matplotlib.pyplot as plt
|
|
123
|
+
|
|
124
|
+
fig, axs = plt.subplots(1, 1, num="PyTurboGrid Mesh Statistics")
|
|
125
|
+
axs.stairs(bin_values, bin_limits, fill=True)
|
|
126
|
+
axs.set_title(variable + "\n" + domain_label)
|
|
127
|
+
axs.set_xlabel(xlabel)
|
|
128
|
+
axs.set_ylabel(ylabel)
|
|
129
|
+
plt.grid(linestyle="--")
|
|
130
|
+
if image_file:
|
|
131
|
+
plt.savefig(image_file)
|
|
132
|
+
if show:
|
|
133
|
+
plt.show() # pragma no cover (can't open a separate window in unit_tests)
|
|
134
|
+
else:
|
|
135
|
+
plt.close(fig)
|
|
136
|
+
|
|
137
|
+
def create_histogram(
|
|
138
|
+
self,
|
|
139
|
+
variable: str,
|
|
140
|
+
domain: str = "ALL",
|
|
141
|
+
use_percentages: bool = True,
|
|
142
|
+
bin_units: str = "",
|
|
143
|
+
image_file: str = "",
|
|
144
|
+
show: bool = True,
|
|
145
|
+
) -> None:
|
|
146
|
+
"""Create a histogram of mesh statistics using `Matplotlib <https://matplotlib.org/>`_.
|
|
147
|
+
|
|
148
|
+
Parameters
|
|
149
|
+
----------
|
|
150
|
+
variable : str
|
|
151
|
+
Mesh statistics variable to use for the histogram.
|
|
152
|
+
domain : str, default: ``"ALL"``
|
|
153
|
+
Domain name to get statistics for. The default is ``"ALL"``, in which
|
|
154
|
+
case statistics for all domains are read. If a specific domain name
|
|
155
|
+
is supplied, statistics are read for only this domain. Cached mesh
|
|
156
|
+
statistics are not used or affected.
|
|
157
|
+
use_percentages : bool, default: ``False``
|
|
158
|
+
Whether to display the percentage values of the bin counts for
|
|
159
|
+
the histogram. The default is ``False``, in which case the actual bin
|
|
160
|
+
counts are shown.
|
|
161
|
+
bin_units : str, default: ``""``
|
|
162
|
+
Units for the mesh statistics values (x-axis labels). The default is
|
|
163
|
+
``""``, in which case the current TurboGrid units are used.
|
|
164
|
+
image_file : str, default: ``""``
|
|
165
|
+
Name and extension for the image file to write the histogram to. The
|
|
166
|
+
default is ``""``, in which case no image file is written. The format
|
|
167
|
+
is determined by the file extension (such as ``.png``) given in the
|
|
168
|
+
file name. Available formats are those supported by Matplotlib,
|
|
169
|
+
including ``".png"``, ``".pdf"``, and ``".svg"``.
|
|
170
|
+
show : bool, default: True
|
|
171
|
+
Whether to display the image on the screen. If ``False``, the image is not
|
|
172
|
+
displayed on the screen, which is only useful if the image is
|
|
173
|
+
being written to a file.
|
|
174
|
+
"""
|
|
175
|
+
if "query_mesh_statistics_histogram_data" not in dir(self.interface):
|
|
176
|
+
raise self.interface.InvalidQuery(
|
|
177
|
+
"query_mesh_statistics_histogram_data"
|
|
178
|
+
) # pragma no cover (won't occur with current TurboGrid data)
|
|
179
|
+
|
|
180
|
+
histogram_stats = self.interface.query_mesh_statistics_histogram_data(
|
|
181
|
+
domain=domain, variable=variable, bin_units=bin_units
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
if use_percentages:
|
|
185
|
+
bin_values = histogram_stats["Bin Percentages"]
|
|
186
|
+
ylabel = "Percentage"
|
|
187
|
+
else:
|
|
188
|
+
bin_values = histogram_stats["Bin Totals"]
|
|
189
|
+
ylabel = "Count"
|
|
190
|
+
|
|
191
|
+
if histogram_stats["Bin Limits Units"]:
|
|
192
|
+
xlabel = variable + r" [" + histogram_stats["Bin Limits Units"] + r"]"
|
|
193
|
+
else:
|
|
194
|
+
xlabel = variable # pragma no cover (won't occur with current TurboGrid data)
|
|
195
|
+
|
|
196
|
+
self._draw_histogram(
|
|
197
|
+
variable=variable,
|
|
198
|
+
bin_limits=histogram_stats["Bin Limits"],
|
|
199
|
+
bin_values=bin_values,
|
|
200
|
+
xlabel=xlabel,
|
|
201
|
+
ylabel=ylabel,
|
|
202
|
+
domain_label=self.get_domain_label(domain),
|
|
203
|
+
image_file=image_file,
|
|
204
|
+
show=show,
|
|
205
|
+
)
|
|
206
|
+
|
|
207
|
+
def get_table_rows(self) -> list:
|
|
208
|
+
"""
|
|
209
|
+
Get the mesh statistics table data from the cached mesh statistics.
|
|
210
|
+
|
|
211
|
+
Returns
|
|
212
|
+
-------
|
|
213
|
+
list
|
|
214
|
+
List of row data. Each list item represents one table row. The list
|
|
215
|
+
item contains a list of the cell contents for each cell in the row.
|
|
216
|
+
"""
|
|
217
|
+
row_data = list()
|
|
218
|
+
row_data.append(["Mesh Measure", "Value", "% Bad", "% ok", "%OK"])
|
|
219
|
+
for var_name, var_data in self.mesh_vars.items():
|
|
220
|
+
# Exclude variables which only have 'Count' set (e.g. 'Elements')
|
|
221
|
+
if "Maximum" in var_data:
|
|
222
|
+
data = list()
|
|
223
|
+
data.append(var_name)
|
|
224
|
+
if var_data["Limits Type"] == "Maximum":
|
|
225
|
+
value = str(var_data["Maximum"])
|
|
226
|
+
elif var_data["Limits Type"] == "Minimum":
|
|
227
|
+
value = str(var_data["Minimum"])
|
|
228
|
+
else:
|
|
229
|
+
value = "" # pragma no cover (won't occur with current TurboGrid data)
|
|
230
|
+
if value and var_data["Units"]:
|
|
231
|
+
value += " [" + var_data["Units"] + "]"
|
|
232
|
+
data.append(value)
|
|
233
|
+
data.append(str(var_data["Percent Bad"]))
|
|
234
|
+
data.append(str(var_data["Percent ok"]))
|
|
235
|
+
data.append(str(var_data["Percent OK"]))
|
|
236
|
+
row_data.append(data)
|
|
237
|
+
return row_data
|
|
238
|
+
|
|
239
|
+
def write_table_to_csv(self, file_name: str) -> None:
|
|
240
|
+
"""
|
|
241
|
+
Write the mesh statistics table to a CSV file.
|
|
242
|
+
|
|
243
|
+
The values in the mesh statistics table are obtained from the cached
|
|
244
|
+
mesh statistics.
|
|
245
|
+
|
|
246
|
+
Parameters
|
|
247
|
+
----------
|
|
248
|
+
file_name : str
|
|
249
|
+
Name of the file to write the mesh statistics table to.
|
|
250
|
+
"""
|
|
251
|
+
import csv
|
|
252
|
+
|
|
253
|
+
with open(file_name, "w", newline="") as f:
|
|
254
|
+
writer = csv.writer(f)
|
|
255
|
+
row_data = self.get_table_rows()
|
|
256
|
+
writer.writerow([self.get_domain_label(self.current_domain)])
|
|
257
|
+
for row in row_data:
|
|
258
|
+
writer.writerow(row)
|
|
259
|
+
|
|
260
|
+
def get_table_as_text(self) -> str:
|
|
261
|
+
"""Get a text version of the mesh statistics table from the cached mesh statistics.
|
|
262
|
+
|
|
263
|
+
Returns
|
|
264
|
+
-------
|
|
265
|
+
str
|
|
266
|
+
Mesh statistics table in a text version.
|
|
267
|
+
"""
|
|
268
|
+
table = "\n" + self.get_domain_label(self.current_domain) + "\n\n"
|
|
269
|
+
row_data = self.get_table_rows()
|
|
270
|
+
row_lengths = [9] * 5
|
|
271
|
+
for row in row_data:
|
|
272
|
+
for index, value in enumerate(row):
|
|
273
|
+
row_lengths[index] = max(row_lengths[index], len(value))
|
|
274
|
+
for row in row_data:
|
|
275
|
+
row_string = ""
|
|
276
|
+
for index, value in enumerate(row):
|
|
277
|
+
row_string += str(value).ljust(row_lengths[index]) + " "
|
|
278
|
+
table += row_string
|
|
279
|
+
table += "\n"
|
|
280
|
+
return table
|