cffview 0.3.3__tar.gz → 0.3.4__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.
- {cffview-0.3.3/src/cffview.egg-info → cffview-0.3.4}/PKG-INFO +3 -8
- {cffview-0.3.3 → cffview-0.3.4}/README.md +2 -7
- {cffview-0.3.3 → cffview-0.3.4}/pyproject.toml +1 -1
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview/main.py +103 -66
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview/utils.py +7 -0
- {cffview-0.3.3 → cffview-0.3.4/src/cffview.egg-info}/PKG-INFO +3 -8
- {cffview-0.3.3 → cffview-0.3.4}/LICENSE +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/setup.cfg +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview/boundary.py +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview.egg-info/SOURCES.txt +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview.egg-info/dependency_links.txt +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview.egg-info/entry_points.txt +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview.egg-info/requires.txt +0 -0
- {cffview-0.3.3 → cffview-0.3.4}/src/cffview.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cffview
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening Fluent
|
|
5
5
|
Author-email: preamer <1524477126@qq.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -35,8 +35,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
|
|
|
35
35
|
- Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
|
|
36
36
|
- Visualise the mesh with [PyVista](https://pyvista.org).
|
|
37
37
|
|
|
38
|
-
---
|
|
39
|
-
|
|
40
38
|
## Installation
|
|
41
39
|
|
|
42
40
|
### PyPI
|
|
@@ -53,8 +51,6 @@ cd cffview
|
|
|
53
51
|
pip install .
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
---
|
|
57
|
-
|
|
58
54
|
## Usage
|
|
59
55
|
|
|
60
56
|
> [!IMPORTANT]
|
|
@@ -70,7 +66,7 @@ cffview <file> [options]
|
|
|
70
66
|
|---|---|
|
|
71
67
|
| `--version` | Print the Fluent version of file |
|
|
72
68
|
| `--extract` | Dump raw Scheme settings to `general.scm` and `boundary.scm` |
|
|
73
|
-
| `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
69
|
+
| `--mesh`, `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
74
70
|
| `--solver` | Solver type, time, dimension, precision, turbulence model, energy, radiation, gravity |
|
|
75
71
|
| `--mat`, `--materials` | Material properties |
|
|
76
72
|
| `--bd`, `--boundary` | Boundary condition settings |
|
|
@@ -85,6 +81,7 @@ cffview <file> [options]
|
|
|
85
81
|
| `--vectors` | Graphics vectors settings |
|
|
86
82
|
| `--xy`, `--xy-plot` | Graphics xy-plot settings |
|
|
87
83
|
| `--save` | Save the output to `<file>.json` |
|
|
84
|
+
| `--plot` | Plot the outfile with matplotlib |
|
|
88
85
|
|
|
89
86
|
Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
|
|
90
87
|
|
|
@@ -112,8 +109,6 @@ cffview case.cas.h5 --extract
|
|
|
112
109
|
|
|
113
110
|
[demo.webm](https://github.com/user-attachments/assets/9047a354-b5cb-475e-b030-97609e2a1274)
|
|
114
111
|
|
|
115
|
-
---
|
|
116
|
-
|
|
117
112
|
## License
|
|
118
113
|
|
|
119
114
|
[BSD-3-Clause](LICENSE)
|
|
@@ -11,8 +11,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
|
|
|
11
11
|
- Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
|
|
12
12
|
- Visualise the mesh with [PyVista](https://pyvista.org).
|
|
13
13
|
|
|
14
|
-
---
|
|
15
|
-
|
|
16
14
|
## Installation
|
|
17
15
|
|
|
18
16
|
### PyPI
|
|
@@ -29,8 +27,6 @@ cd cffview
|
|
|
29
27
|
pip install .
|
|
30
28
|
```
|
|
31
29
|
|
|
32
|
-
---
|
|
33
|
-
|
|
34
30
|
## Usage
|
|
35
31
|
|
|
36
32
|
> [!IMPORTANT]
|
|
@@ -46,7 +42,7 @@ cffview <file> [options]
|
|
|
46
42
|
|---|---|
|
|
47
43
|
| `--version` | Print the Fluent version of file |
|
|
48
44
|
| `--extract` | Dump raw Scheme settings to `general.scm` and `boundary.scm` |
|
|
49
|
-
| `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
45
|
+
| `--mesh`, `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
50
46
|
| `--solver` | Solver type, time, dimension, precision, turbulence model, energy, radiation, gravity |
|
|
51
47
|
| `--mat`, `--materials` | Material properties |
|
|
52
48
|
| `--bd`, `--boundary` | Boundary condition settings |
|
|
@@ -61,6 +57,7 @@ cffview <file> [options]
|
|
|
61
57
|
| `--vectors` | Graphics vectors settings |
|
|
62
58
|
| `--xy`, `--xy-plot` | Graphics xy-plot settings |
|
|
63
59
|
| `--save` | Save the output to `<file>.json` |
|
|
60
|
+
| `--plot` | Plot the outfile with matplotlib |
|
|
64
61
|
|
|
65
62
|
Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
|
|
66
63
|
|
|
@@ -88,8 +85,6 @@ cffview case.cas.h5 --extract
|
|
|
88
85
|
|
|
89
86
|
[demo.webm](https://github.com/user-attachments/assets/9047a354-b5cb-475e-b030-97609e2a1274)
|
|
90
87
|
|
|
91
|
-
---
|
|
92
|
-
|
|
93
88
|
## License
|
|
94
89
|
|
|
95
90
|
[BSD-3-Clause](LICENSE)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "cffview"
|
|
7
|
-
version = "0.3.
|
|
7
|
+
version = "0.3.4"
|
|
8
8
|
description = "A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening Fluent"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
from typing import Literal, TypeAlias, Union
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
def print_version(file_path: str) ->
|
|
4
|
+
def print_version(file_path: str) -> None:
|
|
5
5
|
"""Get the version of the .h5 file
|
|
6
6
|
|
|
7
7
|
Parameters
|
|
@@ -24,7 +24,7 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
24
24
|
Literal[
|
|
25
25
|
'solver', 'materials', 'boundary', 'named-expressions',
|
|
26
26
|
'disc-scheme', 'report-definitions', 'plotsets', 'monitorsets',
|
|
27
|
-
'residuals', 'iter', 'contours', 'vectors'
|
|
27
|
+
'residuals', 'iter', 'contours', 'vectors', 'xy-plot',
|
|
28
28
|
],
|
|
29
29
|
dict[str]
|
|
30
30
|
]:
|
|
@@ -43,8 +43,9 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
43
43
|
import re
|
|
44
44
|
import h5py
|
|
45
45
|
import sexpdata
|
|
46
|
+
from .utils import stringify_nested_list
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
NestedStrList: TypeAlias = list[Union[str, 'NestedStrList']]
|
|
48
49
|
|
|
49
50
|
with h5py.File(file_path) as f:
|
|
50
51
|
settings: h5py.Group = f['/settings']
|
|
@@ -159,35 +160,34 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
159
160
|
general_info,
|
|
160
161
|
re.M
|
|
161
162
|
).group(1)
|
|
162
|
-
materials:
|
|
163
|
+
materials: NestedStrList = stringify_nested_list(sexpdata.loads(materials))
|
|
163
164
|
for material in materials[1]:
|
|
164
|
-
name =
|
|
165
|
+
name = material[0]
|
|
165
166
|
data['materials'][name] = {}
|
|
166
|
-
data['materials'][name]['type'] =
|
|
167
|
+
data['materials'][name]['type'] = material[1]
|
|
167
168
|
for property_ in material[2:]:
|
|
168
|
-
property_name =
|
|
169
|
-
if property_[1] ==
|
|
170
|
-
data['materials'][name][property_name] =
|
|
169
|
+
property_name = property_[0]
|
|
170
|
+
if property_[1] == '.':
|
|
171
|
+
data['materials'][name][property_name] = property_[2]
|
|
171
172
|
elif isinstance(property_value_list := property_[1], list):
|
|
172
|
-
if property_value_list[1] ==
|
|
173
|
+
if property_value_list[1] == '.':
|
|
173
174
|
data['materials'][name][property_name] = f'{property_value_list[0]}/{property_value_list[2]}'
|
|
174
|
-
elif
|
|
175
|
+
elif property_value_list[1] == 'piecewise-linear':
|
|
175
176
|
value = [f'{p[0]}, {p[2]}' for p in property_value_list[2:]]
|
|
176
177
|
data['materials'][name][property_name] = {
|
|
177
178
|
f'{property_value_list[0]}/{property_value_list[1]}': value
|
|
178
179
|
}
|
|
179
|
-
elif
|
|
180
|
+
elif property_value_list[1] in ['piecewise-polynomial', 'nasa-9-piecewise-polynomial']:
|
|
180
181
|
value = [str(p).strip('[]') for p in property_value_list[2:]]
|
|
181
182
|
data['materials'][name][property_name] = {
|
|
182
183
|
f'{property_value_list[0]}/{property_value_list[1]}': value
|
|
183
184
|
}
|
|
184
|
-
elif
|
|
185
|
+
elif property_value_list[0] == 'orthotropic':
|
|
185
186
|
value = {}
|
|
186
187
|
for p in property_value_list[1:]:
|
|
187
|
-
orth_property_name =
|
|
188
|
+
orth_property_name = p[0]
|
|
188
189
|
if orth_property_name in ['direction-0', 'direction-1', 'direction-2']:
|
|
189
190
|
value[orth_property_name] = str(p[1:]).strip('[]')
|
|
190
|
-
value[orth_property_name] = sexpdata.cdr(p)
|
|
191
191
|
elif orth_property_name in ['k0', 'k1', 'k2']:
|
|
192
192
|
value[orth_property_name] = f'{sexpdata.car(p[1])}/{sexpdata.cdr(p[1])}'
|
|
193
193
|
data['materials'][name][property_name] = {f'{property_value_list[0]}': value}
|
|
@@ -199,17 +199,17 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
199
199
|
from .boundary import BoundaryFactory
|
|
200
200
|
|
|
201
201
|
data['boundary'] = {}
|
|
202
|
-
boundaries: list[
|
|
202
|
+
boundaries: list[NestedStrList] = stringify_nested_list(sexpdata.parse(boundary_info, true=None))
|
|
203
203
|
for boundary_info in boundaries:
|
|
204
|
-
id_, type_, name, _ = [
|
|
204
|
+
id_, type_, name, _ = [_ for _ in boundary_info[1]]
|
|
205
205
|
new_boundary = BoundaryFactory.create(name, id_, type_)
|
|
206
206
|
b_list = data['boundary'].get(type_, [])
|
|
207
207
|
|
|
208
208
|
for property_ in filter(lambda x: len(x) > 1, boundary_info[2]):
|
|
209
|
-
property_name =
|
|
209
|
+
property_name = property_[0].replace('-', '_').replace('?', '').replace('/', '_')
|
|
210
210
|
if hasattr(new_boundary, property_name):
|
|
211
|
-
if property_[1] ==
|
|
212
|
-
setattr(new_boundary, property_name,
|
|
211
|
+
if property_[1] == '.':
|
|
212
|
+
setattr(new_boundary, property_name, property_[2])
|
|
213
213
|
elif isinstance(property_[1], list):
|
|
214
214
|
if property_name == 'source_terms':
|
|
215
215
|
source_terms_list = property_[1:]
|
|
@@ -217,8 +217,8 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
217
217
|
for source_term in filter(lambda x: len(x) > 1, source_terms_list):
|
|
218
218
|
value[source_term[0]] = {}
|
|
219
219
|
source_property = source_term[1]
|
|
220
|
-
for source_property_ in filter(lambda x: x[1] ==
|
|
221
|
-
value[source_term[0]][source_property_[0]] =
|
|
220
|
+
for source_property_ in filter(lambda x: x[1] == '.', source_property):
|
|
221
|
+
value[source_term[0]][source_property_[0]] = source_property_[2]
|
|
222
222
|
setattr(new_boundary, property_name, value)
|
|
223
223
|
else:
|
|
224
224
|
setattr(new_boundary, property_name, f'{property_[1][0]}/{property_[1][2]}')
|
|
@@ -233,10 +233,10 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
233
233
|
general_info,
|
|
234
234
|
re.M
|
|
235
235
|
).group(1)
|
|
236
|
-
nes:
|
|
236
|
+
nes: NestedStrList = stringify_nested_list(sexpdata.loads(nes, true=None)[1])
|
|
237
237
|
for ne in nes:
|
|
238
238
|
ne_dict = {
|
|
239
|
-
|
|
239
|
+
property_[0]: property_[2]
|
|
240
240
|
for property_ in ne
|
|
241
241
|
}
|
|
242
242
|
data['named-expressions'][ne_dict['name']] = ne_dict
|
|
@@ -285,22 +285,22 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
285
285
|
general_info,
|
|
286
286
|
re.M
|
|
287
287
|
).group(1)
|
|
288
|
-
rds:
|
|
288
|
+
rds: NestedStrList = stringify_nested_list(sexpdata.loads(rds, true=None)[1])
|
|
289
289
|
for rd in rds:
|
|
290
|
-
name =
|
|
291
|
-
type_ =
|
|
290
|
+
name = rd[0][2]
|
|
291
|
+
type_ = rd[1][1]
|
|
292
292
|
data['report-definitions'][name] = {'type': type_}
|
|
293
293
|
if 'volume' in type_:
|
|
294
|
-
data['report-definitions'][name]['field'] =
|
|
295
|
-
data['report-definitions'][name]['zones'] = [
|
|
296
|
-
data['report-definitions'][name]['per-zone?'] =
|
|
294
|
+
data['report-definitions'][name]['field'] = rd[1][2][2]
|
|
295
|
+
data['report-definitions'][name]['zones'] = [zone for zone in rd[1][6][1:]]
|
|
296
|
+
data['report-definitions'][name]['per-zone?'] = rd[1][-5][2]
|
|
297
297
|
elif 'surface' in type_:
|
|
298
|
-
data['report-definitions'][name]['field'] =
|
|
299
|
-
data['report-definitions'][name]['surfaces'] = [
|
|
300
|
-
data['report-definitions'][name]['per-surface?'] =
|
|
298
|
+
data['report-definitions'][name]['field'] = rd[1][2][2]
|
|
299
|
+
data['report-definitions'][name]['surfaces'] = [surface for surface in rd[1][5][1:]]
|
|
300
|
+
data['report-definitions'][name]['per-surface?'] = rd[1][-5][2]
|
|
301
301
|
elif 'flux' in type_:
|
|
302
|
-
data['report-definitions'][name]['zones'] = [
|
|
303
|
-
data['report-definitions'][name]['per-zone?'] =
|
|
302
|
+
data['report-definitions'][name]['zones'] = [zone for zone in rd[1][3][1:]]
|
|
303
|
+
data['report-definitions'][name]['per-zone?'] = rd[1][-5][2]
|
|
304
304
|
|
|
305
305
|
if kwargs['plotsets']:
|
|
306
306
|
data['plotsets'] = {}
|
|
@@ -309,12 +309,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
309
309
|
general_info,
|
|
310
310
|
re.M
|
|
311
311
|
).group(1)
|
|
312
|
-
plotsets:
|
|
312
|
+
plotsets: NestedStrList = stringify_nested_list(sexpdata.loads(plotsets, true=None)[1])
|
|
313
313
|
for plotset in plotsets:
|
|
314
314
|
plotset_dict = {
|
|
315
|
-
|
|
315
|
+
property_[0]: property_[2]
|
|
316
316
|
for property_ in plotset
|
|
317
|
-
if
|
|
317
|
+
if property_[0] not in ['old-props', 'report-defs']
|
|
318
318
|
}
|
|
319
319
|
plotset_dict['report-defs'] = plotset[6][1:]
|
|
320
320
|
data['plotsets'][plotset_dict['name']] = plotset_dict
|
|
@@ -326,12 +326,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
326
326
|
general_info,
|
|
327
327
|
re.M
|
|
328
328
|
).group(1)
|
|
329
|
-
monitorsets:
|
|
329
|
+
monitorsets: NestedStrList = stringify_nested_list(sexpdata.loads(monitorsets, true=None)[1])
|
|
330
330
|
for monitorset in monitorsets:
|
|
331
331
|
monitorset_dict = {
|
|
332
|
-
|
|
332
|
+
property_[0]: property_[2]
|
|
333
333
|
for property_ in monitorset
|
|
334
|
-
if
|
|
334
|
+
if property_[0] not in ['old-props', 'report-defs']
|
|
335
335
|
}
|
|
336
336
|
monitorset_dict['report-defs'] = monitorset[-4][1:]
|
|
337
337
|
data['monitorsets'][monitorset_dict['name']] = monitorset_dict
|
|
@@ -369,12 +369,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
369
369
|
general_info,
|
|
370
370
|
re.M
|
|
371
371
|
).group(1)
|
|
372
|
-
res:
|
|
372
|
+
res: NestedStrList = stringify_nested_list(sexpdata.loads(res, true=None)[1])
|
|
373
373
|
for eq in res:
|
|
374
|
-
data['residuals'][
|
|
375
|
-
'monitor':
|
|
376
|
-
'check-convergence':
|
|
377
|
-
'absolute-criteria':
|
|
374
|
+
data['residuals'][eq[0]] = {
|
|
375
|
+
'monitor': eq[1],
|
|
376
|
+
'check-convergence': eq[3],
|
|
377
|
+
'absolute-criteria': eq[4],
|
|
378
378
|
}
|
|
379
379
|
|
|
380
380
|
if kwargs['iter']:
|
|
@@ -420,12 +420,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
420
420
|
general_info,
|
|
421
421
|
re.M
|
|
422
422
|
).group(1)
|
|
423
|
-
contours:
|
|
423
|
+
contours: NestedStrList = stringify_nested_list(sexpdata.loads(contours, true=None)[1])
|
|
424
424
|
for contour in contours:
|
|
425
425
|
contour_dict = {
|
|
426
|
-
|
|
426
|
+
property_[0]: property_[2]
|
|
427
427
|
for property_ in contour
|
|
428
|
-
if
|
|
428
|
+
if property_[0] not in [
|
|
429
429
|
'locations', 'location-ids', 'options',
|
|
430
430
|
'range-options', 'range-option', 'surfaces-list',
|
|
431
431
|
'color-map', 'colorings', 'annotations-list',
|
|
@@ -433,11 +433,11 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
433
433
|
}
|
|
434
434
|
contour_dict['surface-list'] = contour[2][1]
|
|
435
435
|
contour_dict['range-options'] = {
|
|
436
|
-
|
|
436
|
+
range_option[0]: range_option[2]
|
|
437
437
|
for range_option in contour[6][1:]
|
|
438
438
|
}
|
|
439
439
|
contour_dict['color-map'] = {
|
|
440
|
-
|
|
440
|
+
color_map[0]: color_map[2]
|
|
441
441
|
for color_map in contour[-7][1:]
|
|
442
442
|
}
|
|
443
443
|
data['contours'][contour_dict['name']] = contour_dict
|
|
@@ -449,12 +449,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
449
449
|
general_info,
|
|
450
450
|
re.M
|
|
451
451
|
).group(1)
|
|
452
|
-
vectors:
|
|
452
|
+
vectors: NestedStrList = stringify_nested_list(sexpdata.loads(vectors, true=None)[1])
|
|
453
453
|
for vector in vectors:
|
|
454
454
|
vector_dict = {
|
|
455
|
-
|
|
455
|
+
property_[0]: property_[2]
|
|
456
456
|
for property_ in vector
|
|
457
|
-
if
|
|
457
|
+
if property_[0] not in [
|
|
458
458
|
'locations', 'location-ids', 'options', 'scale',
|
|
459
459
|
'range-options', 'range-option', 'surfaces-list',
|
|
460
460
|
'color-map', 'vector-opt', 'annotations-list',
|
|
@@ -462,19 +462,19 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
462
462
|
}
|
|
463
463
|
vector_dict['surface-list'] = vector[3][1]
|
|
464
464
|
vector_dict['range-options'] = {
|
|
465
|
-
|
|
465
|
+
range_option[0]: range_option[2]
|
|
466
466
|
for range_option in vector[7][1:]
|
|
467
467
|
}
|
|
468
468
|
vector_dict['scale'] = {
|
|
469
|
-
|
|
469
|
+
scale[0]: scale[2]
|
|
470
470
|
for scale in vector[9][1:]
|
|
471
471
|
}
|
|
472
472
|
vector_dict['vector-opt'] = {
|
|
473
|
-
|
|
473
|
+
vector_opt[0]: vector_opt[2]
|
|
474
474
|
for vector_opt in vector[-6][1:]
|
|
475
475
|
}
|
|
476
476
|
vector_dict['color-map'] = {
|
|
477
|
-
|
|
477
|
+
color_map[0]: color_map[2]
|
|
478
478
|
for color_map in vector[-5][1:]
|
|
479
479
|
}
|
|
480
480
|
data['vectors'][vector_dict['name']] = vector_dict
|
|
@@ -486,12 +486,12 @@ def read_case(file_path: str, **kwargs) -> dict[
|
|
|
486
486
|
general_info,
|
|
487
487
|
re.M
|
|
488
488
|
).group(1)
|
|
489
|
-
xy_plots = sexpdata.loads(xy_plots, true=None)[1]
|
|
489
|
+
xy_plots: NestedStrList = stringify_nested_list(sexpdata.loads(xy_plots, true=None)[1])
|
|
490
490
|
for xy_plot in xy_plots:
|
|
491
491
|
xy_plot_dict = {
|
|
492
|
-
|
|
492
|
+
property_[0]: property_[2]
|
|
493
493
|
for property_ in xy_plot
|
|
494
|
-
if
|
|
494
|
+
if property_[0] not in [
|
|
495
495
|
'options', 'x-axis-data', 'y-axis-data',
|
|
496
496
|
'surfaces-list', 'location-ids', 'locations',
|
|
497
497
|
'option', 'plot-direction', 'axes',
|
|
@@ -636,6 +636,39 @@ def show_mesh(file_path: str) -> None:
|
|
|
636
636
|
pl.show()
|
|
637
637
|
|
|
638
638
|
|
|
639
|
+
def plot_outfile(file_path: str) -> None:
|
|
640
|
+
"""Plot Ansys Fluent report files
|
|
641
|
+
|
|
642
|
+
Parameters
|
|
643
|
+
---------
|
|
644
|
+
file_path : str
|
|
645
|
+
Path to the outfile
|
|
646
|
+
"""
|
|
647
|
+
import numpy as np
|
|
648
|
+
import matplotlib.pyplot as plt
|
|
649
|
+
|
|
650
|
+
with open(file_path, encoding='utf-8') as f:
|
|
651
|
+
for line_num, line in enumerate(f, start=1):
|
|
652
|
+
match line_num:
|
|
653
|
+
case 1:
|
|
654
|
+
title = line.strip().strip('"')
|
|
655
|
+
case 2:
|
|
656
|
+
_, *report_definitions = [s.strip('"') for s in line.strip().split()]
|
|
657
|
+
case 3:
|
|
658
|
+
xlabel, *ylabels = [s.strip('"') for s in line.strip('( )').split()]
|
|
659
|
+
case _:
|
|
660
|
+
break
|
|
661
|
+
|
|
662
|
+
data = np.loadtxt(file_path, skiprows=3)
|
|
663
|
+
plt.figure()
|
|
664
|
+
plt.plot(data[:, 0], data[:, 1:])
|
|
665
|
+
plt.title(title)
|
|
666
|
+
plt.xlabel(xlabel)
|
|
667
|
+
plt.legend(ylabels)
|
|
668
|
+
plt.grid()
|
|
669
|
+
plt.show()
|
|
670
|
+
|
|
671
|
+
|
|
639
672
|
def main() -> None:
|
|
640
673
|
import argparse
|
|
641
674
|
|
|
@@ -658,13 +691,13 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
|
|
|
658
691
|
parser.add_argument(
|
|
659
692
|
"file_path",
|
|
660
693
|
type=str,
|
|
661
|
-
help="path to the .h5 file"
|
|
694
|
+
help="path to the .h5 file",
|
|
662
695
|
)
|
|
663
696
|
|
|
664
697
|
ARGUMENTS = [
|
|
665
698
|
(("--version",), "show the version of the .h5 file"),
|
|
666
699
|
(("--extract",), "extract cas.h5 general and boundary string to files"),
|
|
667
|
-
(("--showmesh",), "show mesh using pyvista"),
|
|
700
|
+
(("--mesh", "--showmesh",), "show mesh using pyvista"),
|
|
668
701
|
(("--solver",), "show solver settings"),
|
|
669
702
|
(("--mat", "--materials"), "show materials settings"),
|
|
670
703
|
(("--bd", "--boundary"), "show boundary settings"),
|
|
@@ -679,6 +712,7 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
|
|
|
679
712
|
(("--vectors",), "show graphics vectors settings"),
|
|
680
713
|
(("--xy", "--xy-plot"), "show graphics xy-plot settings"),
|
|
681
714
|
(("--save",), "save output to file"),
|
|
715
|
+
(("--plot",), "plot outfile"),
|
|
682
716
|
]
|
|
683
717
|
|
|
684
718
|
for flags, help_text in ARGUMENTS:
|
|
@@ -686,8 +720,9 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
|
|
|
686
720
|
|
|
687
721
|
args = parser.parse_args()
|
|
688
722
|
|
|
689
|
-
if not args.file_path.endswith((".cas.h5", ".msh.h5")):
|
|
690
|
-
print("Invalid
|
|
723
|
+
if not args.file_path.endswith((".cas.h5", ".msh.h5")) and not args.plot:
|
|
724
|
+
print("Invalid arguments.")
|
|
725
|
+
print("Please provide a .cas.h5 or .msh.h5 file or add --plot argument to plot outfile")
|
|
691
726
|
return
|
|
692
727
|
|
|
693
728
|
if args.version:
|
|
@@ -697,7 +732,7 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
|
|
|
697
732
|
elif args.file_path.endswith(".msh.h5"):
|
|
698
733
|
show_mesh(args.file_path)
|
|
699
734
|
elif args.file_path.endswith(".cas.h5"):
|
|
700
|
-
if args.
|
|
735
|
+
if args.mesh:
|
|
701
736
|
show_mesh(args.file_path)
|
|
702
737
|
else:
|
|
703
738
|
from .utils import print_colored_dict
|
|
@@ -714,3 +749,5 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
|
|
|
714
749
|
import json
|
|
715
750
|
with open(f"{args.file_path}.json", "w", encoding="utf-8") as f:
|
|
716
751
|
json.dump(output, f, ensure_ascii=False, indent=4)
|
|
752
|
+
elif args.plot:
|
|
753
|
+
plot_outfile(args.file_path)
|
|
@@ -162,3 +162,10 @@ def print_colored_dict(data) -> None:
|
|
|
162
162
|
else:
|
|
163
163
|
# Number / boolean / null inside an array
|
|
164
164
|
print(f"{indent}{PRIM_COLOR}{content}{RESET}")
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def stringify_nested_list(lst):
|
|
168
|
+
return [
|
|
169
|
+
stringify_nested_list(item) if isinstance(item, list) else str(item)
|
|
170
|
+
for item in lst
|
|
171
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cffview
|
|
3
|
-
Version: 0.3.
|
|
3
|
+
Version: 0.3.4
|
|
4
4
|
Summary: A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening Fluent
|
|
5
5
|
Author-email: preamer <1524477126@qq.com>
|
|
6
6
|
License-Expression: BSD-3-Clause
|
|
@@ -35,8 +35,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
|
|
|
35
35
|
- Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
|
|
36
36
|
- Visualise the mesh with [PyVista](https://pyvista.org).
|
|
37
37
|
|
|
38
|
-
---
|
|
39
|
-
|
|
40
38
|
## Installation
|
|
41
39
|
|
|
42
40
|
### PyPI
|
|
@@ -53,8 +51,6 @@ cd cffview
|
|
|
53
51
|
pip install .
|
|
54
52
|
```
|
|
55
53
|
|
|
56
|
-
---
|
|
57
|
-
|
|
58
54
|
## Usage
|
|
59
55
|
|
|
60
56
|
> [!IMPORTANT]
|
|
@@ -70,7 +66,7 @@ cffview <file> [options]
|
|
|
70
66
|
|---|---|
|
|
71
67
|
| `--version` | Print the Fluent version of file |
|
|
72
68
|
| `--extract` | Dump raw Scheme settings to `general.scm` and `boundary.scm` |
|
|
73
|
-
| `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
69
|
+
| `--mesh`, `--showmesh` | Visualise the mesh interactively with PyVista |
|
|
74
70
|
| `--solver` | Solver type, time, dimension, precision, turbulence model, energy, radiation, gravity |
|
|
75
71
|
| `--mat`, `--materials` | Material properties |
|
|
76
72
|
| `--bd`, `--boundary` | Boundary condition settings |
|
|
@@ -85,6 +81,7 @@ cffview <file> [options]
|
|
|
85
81
|
| `--vectors` | Graphics vectors settings |
|
|
86
82
|
| `--xy`, `--xy-plot` | Graphics xy-plot settings |
|
|
87
83
|
| `--save` | Save the output to `<file>.json` |
|
|
84
|
+
| `--plot` | Plot the outfile with matplotlib |
|
|
88
85
|
|
|
89
86
|
Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
|
|
90
87
|
|
|
@@ -112,8 +109,6 @@ cffview case.cas.h5 --extract
|
|
|
112
109
|
|
|
113
110
|
[demo.webm](https://github.com/user-attachments/assets/9047a354-b5cb-475e-b030-97609e2a1274)
|
|
114
111
|
|
|
115
|
-
---
|
|
116
|
-
|
|
117
112
|
## License
|
|
118
113
|
|
|
119
114
|
[BSD-3-Clause](LICENSE)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|