cffview 0.3.2__tar.gz → 0.3.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cffview
3
- Version: 0.3.2
3
+ Version: 0.3.3
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
@@ -83,6 +83,7 @@ cffview <file> [options]
83
83
  | `--iter` | Iteration / time-step settings |
84
84
  | `--contours` | Graphics contours settings |
85
85
  | `--vectors` | Graphics vectors settings |
86
+ | `--xy`, `--xy-plot` | Graphics xy-plot settings |
86
87
  | `--save` | Save the output to `<file>.json` |
87
88
 
88
89
  Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
@@ -59,6 +59,7 @@ cffview <file> [options]
59
59
  | `--iter` | Iteration / time-step settings |
60
60
  | `--contours` | Graphics contours settings |
61
61
  | `--vectors` | Graphics vectors settings |
62
+ | `--xy`, `--xy-plot` | Graphics xy-plot settings |
62
63
  | `--save` | Save the output to `<file>.json` |
63
64
 
64
65
  Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cffview"
7
- version = "0.3.2"
7
+ version = "0.3.3"
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,4 +1,4 @@
1
- from dataclasses import dataclass
1
+ from dataclasses import dataclass, field
2
2
 
3
3
 
4
4
  class BoundaryConsts:
@@ -79,7 +79,7 @@ class Fluid:
79
79
  id_: str
80
80
  material: str = ''
81
81
  sources: str = ''
82
- sources_terms: str = ''
82
+ source_terms: dict[str, dict[str, str]] = field(default_factory=dict)
83
83
  fixed: str = ''
84
84
  mrf_motion: str = ''
85
85
  mgrid_motion: str = ''
@@ -92,7 +92,7 @@ class Fluid:
92
92
  data = self.__dict__.copy()
93
93
 
94
94
  if data['sources'] == '#f':
95
- data.pop('sources_terms', None)
95
+ data.pop('source_terms', None)
96
96
 
97
97
  return data
98
98
 
@@ -104,7 +104,7 @@ class Solid:
104
104
  id_: str
105
105
  material: str = ''
106
106
  sources: str = ''
107
- sources_terms: str = ''
107
+ source_terms: dict[str, dict[str, str]] = field(default_factory=dict)
108
108
  fixed: str = ''
109
109
  solid_motion: str = ''
110
110
 
@@ -112,7 +112,7 @@ class Solid:
112
112
  data = self.__dict__.copy()
113
113
 
114
114
  if data['sources'] == '#f':
115
- data.pop('sources_terms', None)
115
+ data.pop('source_terms', None)
116
116
 
117
117
  return data
118
118
 
@@ -235,14 +235,11 @@ class PressureInlet:
235
235
  data['coordinate_system'] = BoundaryConsts.COORDINATE_SYSTEM.get(self.coordinate_system, 'unknown')
236
236
  data['ke_spec'] = BoundaryConsts.KE_SPEC.get(self.ke_spec, 'unknown')
237
237
 
238
- match data['direction_spec']:
239
- case 'Direction Vector':
240
- pass
241
- case 'Normal to Boundary':
242
- data.pop('coordinate_system', None)
243
- data.pop('ni', None)
244
- data.pop('nj', None)
245
- data.pop('nk', None)
238
+ if data['direction_spec'] == 'Normal to Boundary':
239
+ data.pop('coordinate_system', None)
240
+ data.pop('ni', None)
241
+ data.pop('nj', None)
242
+ data.pop('nk', None)
246
243
 
247
244
  match data['ke_spec']:
248
245
  case 'Intensity and Length Scale':
@@ -265,6 +262,7 @@ class PressureOutlet:
265
262
  id_: str
266
263
  p: str = ''
267
264
  t0: str = ''
265
+
268
266
  ke_spec: str = ''
269
267
  prevent_reverse_flow: str = ''
270
268
  radial: str = ''
@@ -333,25 +331,28 @@ class Wall:
333
331
  planar_conduction: str = ''
334
332
  shell_conduction: str = ''
335
333
 
336
- _THERMAL_BC_WHITELIST = {
337
- '0': {'q_dot'}, # Heat Flux
338
- '1': {'t'}, # Temperature
339
- '3': set(), # Coupled
340
- }
341
-
342
334
  def to_dict(self) -> dict[str, str]:
343
335
  data = self.__dict__.copy()
344
336
 
345
- allowed_attrs = self._THERMAL_BC_WHITELIST.get(self.thermal_bc, set())
346
- all_thermal_attrs = {'t', 'q_dot', 'h', 'q'}
347
- attrs_to_remove = all_thermal_attrs - allowed_attrs
348
- for attr in attrs_to_remove:
349
- data.pop(attr, None)
350
-
351
337
  data['thermal_bc'] = BoundaryConsts.THERMAL_BC.get(self.thermal_bc, 'unknown')
352
338
  data['motion_bc'] = BoundaryConsts.MOTION_BC.get(self.motion_bc, 'unknown')
353
339
  data['shear_bc'] = BoundaryConsts.SHEAR_BC.get(self.shear_bc, 'unknown')
354
340
 
341
+ match data['thermal_bc']:
342
+ case 'Heat Flux':
343
+ data.pop('t', None)
344
+ data.pop('q', None)
345
+ data.pop('h', None)
346
+ case 'Temperature':
347
+ data.pop('q_dot', None)
348
+ data.pop('q', None)
349
+ data.pop('h', None)
350
+ case 'Coupled':
351
+ data.pop('q_dot', None)
352
+ data.pop('t', None)
353
+ data.pop('q', None)
354
+ data.pop('h', None)
355
+
355
356
  if data['planar_conduction'] == '#f':
356
357
  data.pop('shell_conduction', None)
357
358
 
@@ -389,6 +390,13 @@ class Interior:
389
390
  id_: str
390
391
 
391
392
 
393
+ @dataclass
394
+ @BoundaryFactory.register('interface')
395
+ class Interface:
396
+ name: str
397
+ id_: str
398
+
399
+
392
400
  @dataclass
393
401
  @BoundaryFactory.register('symmetry')
394
402
  class Symmetry:
@@ -205,13 +205,22 @@ def read_case(file_path: str, **kwargs) -> dict[
205
205
  new_boundary = BoundaryFactory.create(name, id_, type_)
206
206
  b_list = data['boundary'].get(type_, [])
207
207
 
208
- for property_ in boundary_info[2]:
208
+ for property_ in filter(lambda x: len(x) > 1, boundary_info[2]):
209
209
  property_name = str(property_[0]).replace('-', '_').replace('?', '').replace('/', '_')
210
210
  if hasattr(new_boundary, property_name):
211
- if len(property_) > 1:
212
- if property_[1] == sexpdata.Symbol('.'):
213
- setattr(new_boundary, property_name, str(property_[2]))
214
- elif isinstance(property_[1], list):
211
+ if property_[1] == sexpdata.Symbol('.'):
212
+ setattr(new_boundary, property_name, str(property_[2]))
213
+ elif isinstance(property_[1], list):
214
+ if property_name == 'source_terms':
215
+ source_terms_list = property_[1:]
216
+ value = {}
217
+ for source_term in filter(lambda x: len(x) > 1, source_terms_list):
218
+ value[source_term[0]] = {}
219
+ source_property = source_term[1]
220
+ for source_property_ in filter(lambda x: x[1] == sexpdata.Symbol('.'), source_property):
221
+ value[source_term[0]][source_property_[0]] = str(source_property_[2])
222
+ setattr(new_boundary, property_name, value)
223
+ else:
215
224
  setattr(new_boundary, property_name, f'{property_[1][0]}/{property_[1][2]}')
216
225
 
217
226
  b_list.append(new_boundary.to_dict() if hasattr(new_boundary, 'to_dict') else new_boundary.__dict__)
@@ -470,6 +479,27 @@ def read_case(file_path: str, **kwargs) -> dict[
470
479
  }
471
480
  data['vectors'][vector_dict['name']] = vector_dict
472
481
 
482
+ if kwargs['xy']:
483
+ data['xy-plot'] = {}
484
+ xy_plots = re.search(
485
+ r'(\(graphics/xy-plot.*)',
486
+ general_info,
487
+ re.M
488
+ ).group(1)
489
+ xy_plots = sexpdata.loads(xy_plots, true=None)[1]
490
+ for xy_plot in xy_plots:
491
+ xy_plot_dict = {
492
+ str(property_[0]): str(property_[2])
493
+ for property_ in xy_plot
494
+ if str(property_[0]) not in [
495
+ 'options', 'x-axis-data', 'y-axis-data',
496
+ 'surfaces-list', 'location-ids', 'locations',
497
+ 'option', 'plot-direction', 'axes',
498
+ ]
499
+ }
500
+ xy_plot_dict['surfaces-list'] = xy_plot[7][1]
501
+ data['xy-plot'][xy_plot_dict['name']] = xy_plot_dict
502
+
473
503
  return data
474
504
 
475
505
 
@@ -607,7 +637,6 @@ def show_mesh(file_path: str) -> None:
607
637
 
608
638
 
609
639
  def main() -> None:
610
- import os
611
640
  import argparse
612
641
 
613
642
  BANNER = r"""
@@ -648,6 +677,7 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
648
677
  (("--iter",), "show iteration settings"),
649
678
  (("--contours",), "show graphics contours settings"),
650
679
  (("--vectors",), "show graphics vectors settings"),
680
+ (("--xy", "--xy-plot"), "show graphics xy-plot settings"),
651
681
  (("--save",), "save output to file"),
652
682
  ]
653
683
 
@@ -673,7 +703,8 @@ A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening
673
703
  from .utils import print_colored_dict
674
704
  keys = [
675
705
  'solver', 'mat', 'bd', 'ne', 'disc', 'rd',
676
- 'plotsets', 'monitorsets', 'residuals', 'iter', 'contours', 'vectors',
706
+ 'plotsets', 'monitorsets', 'residuals', 'iter',
707
+ 'contours', 'vectors', 'xy',
677
708
  ]
678
709
  kwargs = {k: getattr(args, k) for k in keys}
679
710
  output = read_case(args.file_path, **kwargs)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cffview
3
- Version: 0.3.2
3
+ Version: 0.3.3
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
@@ -83,6 +83,7 @@ cffview <file> [options]
83
83
  | `--iter` | Iteration / time-step settings |
84
84
  | `--contours` | Graphics contours settings |
85
85
  | `--vectors` | Graphics vectors settings |
86
+ | `--xy`, `--xy-plot` | Graphics xy-plot settings |
86
87
  | `--save` | Save the output to `<file>.json` |
87
88
 
88
89
  Multiple flags can be combined freely. Case settings flags (`--solver`, `--mat`, etc.) apply to `.cas.h5` files only.
File without changes
File without changes
File without changes