cffview 0.1.3__tar.gz → 0.2.0__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.1.3
3
+ Version: 0.2.0
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
@@ -11,7 +11,6 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
- Classifier: Programming Language :: C++
15
14
  Classifier: Topic :: Scientific/Engineering
16
15
  Classifier: Environment :: Console
17
16
  Requires-Python: >=3.11
@@ -31,7 +30,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
31
30
 
32
31
  - Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
33
32
  - Visualise the mesh with [PyVista](https://pyvista.org).
34
- - Mesh reader based on a modified version of VTK's [`vtkFLUENTCFFReader`](https://github.com/Kitware/VTK/tree/master/IO/FLUENTCFF), with the VTK dependency removed. Supports all VTK cell types including polyhedra, for both `.cas.h5` and `.msh.h5`.
35
33
 
36
34
  ---
37
35
 
@@ -43,16 +41,12 @@ pip install cffview
43
41
 
44
42
  ### Build from source
45
43
 
46
- HDF5 development headers and libraries are required.
47
-
48
44
  ```bash
49
45
  git clone https://github.com/preamer/cffview.git
50
46
  cd cffview
51
47
  pip install .
52
48
  ```
53
49
 
54
- If auto-detection fails, set `HDF5_DIR` explicitly before installing.
55
-
56
50
  ---
57
51
 
58
52
  ## Usage
@@ -109,9 +103,7 @@ cffview case.cas.h5 --extract
109
103
  |---|---|---|
110
104
  | Case settings (`--solver`, `--mat`, `--bd`, …) | ✅ | — |
111
105
  | Mesh visualisation (3D) | ✅ | ✅ |
112
- | Mesh visualisation (2D) | ✅ | ⚠️ partial |
113
-
114
- > **Note:** 2D `.msh.h5` face connectivity (C0/C1) parsing is not yet fully implemented.
106
+ | Mesh visualisation (2D) | ✅ | |
115
107
 
116
108
  ---
117
109
 
@@ -6,7 +6,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
6
6
 
7
7
  - Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
8
8
  - Visualise the mesh with [PyVista](https://pyvista.org).
9
- - Mesh reader based on a modified version of VTK's [`vtkFLUENTCFFReader`](https://github.com/Kitware/VTK/tree/master/IO/FLUENTCFF), with the VTK dependency removed. Supports all VTK cell types including polyhedra, for both `.cas.h5` and `.msh.h5`.
10
9
 
11
10
  ---
12
11
 
@@ -18,16 +17,12 @@ pip install cffview
18
17
 
19
18
  ### Build from source
20
19
 
21
- HDF5 development headers and libraries are required.
22
-
23
20
  ```bash
24
21
  git clone https://github.com/preamer/cffview.git
25
22
  cd cffview
26
23
  pip install .
27
24
  ```
28
25
 
29
- If auto-detection fails, set `HDF5_DIR` explicitly before installing.
30
-
31
26
  ---
32
27
 
33
28
  ## Usage
@@ -84,9 +79,7 @@ cffview case.cas.h5 --extract
84
79
  |---|---|---|
85
80
  | Case settings (`--solver`, `--mat`, `--bd`, …) | ✅ | — |
86
81
  | Mesh visualisation (3D) | ✅ | ✅ |
87
- | Mesh visualisation (2D) | ✅ | ⚠️ partial |
88
-
89
- > **Note:** 2D `.msh.h5` face connectivity (C0/C1) parsing is not yet fully implemented.
82
+ | Mesh visualisation (2D) | ✅ | |
90
83
 
91
84
  ---
92
85
 
@@ -1,10 +1,10 @@
1
1
  [build-system]
2
- requires = ["setuptools>=83.0.0", "wheel", "pybind11>=3.0.4", "numpy>=1.20.0"]
2
+ requires = ["setuptools>=83.0.0"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "cffview"
7
- version = "0.1.3"
7
+ version = "0.2.0"
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.11"
@@ -17,7 +17,6 @@ classifiers = [
17
17
  "Programming Language :: Python :: 3.12",
18
18
  "Programming Language :: Python :: 3.13",
19
19
  "Programming Language :: Python :: 3.14",
20
- "Programming Language :: C++",
21
20
  "Topic :: Scientific/Engineering",
22
21
  "Environment :: Console",
23
22
  ]
@@ -36,20 +35,3 @@ Repository = "https://github.com/preamer/cffview"
36
35
 
37
36
  [tool.setuptools.packages.find]
38
37
  where = ["src"]
39
-
40
- [tool.cibuildwheel]
41
- build = "cp311-* cp312-* cp313-* cp314-*"
42
- skip = ["*-win32", "*-musllinux*", "*-manylinux_i686"]
43
-
44
- [tool.cibuildwheel.linux]
45
- before-all = "bash tools/build_hdf5_linux.sh"
46
- environment = { HDF5_DIR = "/opt/hdf5", PIP_ONLY_BINARY = ":all:" }
47
-
48
- [tool.cibuildwheel.macos]
49
- environment = { HDF5_DIR = "/tmp/hdf5", MACOSX_DEPLOYMENT_TARGET = "11.0", DYLD_LIBRARY_PATH = "/tmp/hdf5/lib", CC = "clang", CXX = "clang++" }
50
- before-all = "bash tools/build_hdf5_macos.sh"
51
-
52
- [tool.cibuildwheel.windows]
53
- before-all = "powershell tools/build_hdf5_windows.ps1"
54
- environment = { HDF5_DIR = "C:/Users/runneradmin/hdf5" }
55
- repair-wheel-command = "delvewheel repair --add-path C:\\Users\\runneradmin\\hdf5\\bin -w {dest_dir} {wheel}"
@@ -347,10 +347,74 @@ def extract_h5(file_path: str) -> None:
347
347
  f.write(boundary_info)
348
348
 
349
349
 
350
+ def show_mesh(file_path: str) -> None:
351
+ """Show mesh with PyVista
352
+
353
+ Parameters
354
+ ---------
355
+ file_path : str
356
+ Path to the .h5 file
357
+ """
358
+ import pyvista as pv
359
+ if file_path.endswith('cas.h5'):
360
+ pv.plot(
361
+ pv.read(file_path, progress_bar=True),
362
+ show_edges=True,
363
+ show_axes=True,
364
+ smooth_shading=True,
365
+ split_sharp_edges=True,
366
+ )
367
+ elif file_path.endswith('msh.h5'):
368
+ import numpy as np
369
+ from h5py import File, Group, Dataset
370
+
371
+ with File(file_path) as f:
372
+ root_group: Group = f['/meshes/1']
373
+ dimension: np.int32 = root_group.attrs['dimension'][0]
374
+ nodeCount: np.uint64 = root_group.attrs['nodeCount'][0]
375
+ faceCount: np.uint64 = root_group.attrs['faceCount'][0]
376
+ pv_points = np.zeros((nodeCount, 3), dtype=np.float64)
377
+ nnodes = np.zeros(faceCount, dtype=np.int16)
378
+ zoneTopology: Group = root_group['nodes/zoneTopology']
379
+ nZones: np.uint64 = zoneTopology.attrs['nZones'][0]
380
+ minId: Dataset = zoneTopology['minId']
381
+ maxId: Dataset = zoneTopology['maxId']
382
+
383
+ coords_group: Group = root_group['nodes/coords']
384
+ for i in range(nZones):
385
+ pv_points[minId[i] - 1: maxId[i], :dimension] = coords_group[f'{i+1}'][:]
386
+
387
+ zoneTopology: Group = root_group['faces/zoneTopology']
388
+ minId: Dataset = zoneTopology['minId']
389
+ maxId: Dataset = zoneTopology['maxId']
390
+
391
+ faces_nodes_group: Group = root_group['faces/nodes']
392
+ nSections: np.uint64 = faces_nodes_group.attrs['nSections'][0]
393
+ for i in range(nSections):
394
+ section_group: Group = faces_nodes_group[f"{i+1}"]
395
+ nnodes[minId[i] - 1: maxId[i]] = section_group['nnodes'][:]
396
+ nodes_count = np.sum(nnodes)
397
+ nodes = np.zeros(nodes_count, dtype=np.uint32)
398
+ nodes_start_index = 0
399
+ for i in range(nSections):
400
+ section_group: Group = faces_nodes_group[f"{i+1}"]
401
+ nodes_num = section_group['nodes'].size
402
+ nodes[nodes_start_index: nodes_start_index + nodes_num] = section_group['nodes'][:] - 1
403
+ nodes_start_index += nodes_num
404
+ offsets = np.cumsum(nnodes) - nnodes
405
+ pv_faces = np.insert(nodes, offsets, nnodes)
406
+
407
+ mesh = pv.PolyData(pv_points, pv_faces)
408
+ plotter = pv.Plotter()
409
+ plotter.add_mesh(mesh, show_edges=True, color='cyan', line_width=2, smooth_shading=True, split_sharp_edges=True)
410
+ plotter.add_axes()
411
+ plotter.show()
412
+
413
+
350
414
  def main() -> None:
351
415
  import argparse
352
416
 
353
- desc = "A Python CLI tool to get case settings and display mesh without opening Ansys Fluent"
417
+ desc = "A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening Fluent"
354
418
  parser = argparse.ArgumentParser(description=desc)
355
419
 
356
420
  parser.add_argument(
@@ -434,20 +498,10 @@ def main() -> None:
434
498
  elif args.extract:
435
499
  extract_h5(args.file_path)
436
500
  elif args.file_path.endswith(".msh.h5"):
437
- ...
501
+ show_mesh(args.file_path)
438
502
  elif args.file_path.endswith(".cas.h5"):
439
503
  if args.showmesh:
440
- import pyvista as pv
441
- try:
442
- pv.plot(
443
- pv.read(args.file_path, progress_bar=True),
444
- show_edges=True,
445
- show_axes=True,
446
- smooth_shading=True,
447
- split_sharp_edges=True,
448
- )
449
- except Exception as e:
450
- print(e)
504
+ show_mesh(args.file_path)
451
505
  else:
452
506
  from .utils import print_colored_dict
453
507
  kwargs = {
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cffview
3
- Version: 0.1.3
3
+ Version: 0.2.0
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
@@ -11,7 +11,6 @@ Classifier: Programming Language :: Python :: 3.11
11
11
  Classifier: Programming Language :: Python :: 3.12
12
12
  Classifier: Programming Language :: Python :: 3.13
13
13
  Classifier: Programming Language :: Python :: 3.14
14
- Classifier: Programming Language :: C++
15
14
  Classifier: Topic :: Scientific/Engineering
16
15
  Classifier: Environment :: Console
17
16
  Requires-Python: >=3.11
@@ -31,7 +30,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
31
30
 
32
31
  - Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
33
32
  - Visualise the mesh with [PyVista](https://pyvista.org).
34
- - Mesh reader based on a modified version of VTK's [`vtkFLUENTCFFReader`](https://github.com/Kitware/VTK/tree/master/IO/FLUENTCFF), with the VTK dependency removed. Supports all VTK cell types including polyhedra, for both `.cas.h5` and `.msh.h5`.
35
33
 
36
34
  ---
37
35
 
@@ -43,16 +41,12 @@ pip install cffview
43
41
 
44
42
  ### Build from source
45
43
 
46
- HDF5 development headers and libraries are required.
47
-
48
44
  ```bash
49
45
  git clone https://github.com/preamer/cffview.git
50
46
  cd cffview
51
47
  pip install .
52
48
  ```
53
49
 
54
- If auto-detection fails, set `HDF5_DIR` explicitly before installing.
55
-
56
50
  ---
57
51
 
58
52
  ## Usage
@@ -109,9 +103,7 @@ cffview case.cas.h5 --extract
109
103
  |---|---|---|
110
104
  | Case settings (`--solver`, `--mat`, `--bd`, …) | ✅ | — |
111
105
  | Mesh visualisation (3D) | ✅ | ✅ |
112
- | Mesh visualisation (2D) | ✅ | ⚠️ partial |
113
-
114
- > **Note:** 2D `.msh.h5` face connectivity (C0/C1) parsing is not yet fully implemented.
106
+ | Mesh visualisation (2D) | ✅ | |
115
107
 
116
108
  ---
117
109
 
@@ -1,14 +1,9 @@
1
1
  LICENSE
2
- MANIFEST.in
3
2
  README.md
4
3
  pyproject.toml
5
- setup.py
6
4
  src/cffview/boundary.py
7
- src/cffview/main.cxx
8
5
  src/cffview/main.py
9
6
  src/cffview/utils.py
10
- src/cffview/vtkFLUENTCFFReader.cxx
11
- src/cffview/vtkFLUENTCFFReader.h
12
7
  src/cffview.egg-info/PKG-INFO
13
8
  src/cffview.egg-info/SOURCES.txt
14
9
  src/cffview.egg-info/dependency_links.txt
cffview-0.1.3/MANIFEST.in DELETED
@@ -1 +0,0 @@
1
- recursive-include src/cffview *.h
cffview-0.1.3/setup.py DELETED
@@ -1,120 +0,0 @@
1
- import os
2
- import sys
3
- import warnings
4
- from pathlib import Path
5
-
6
- import pybind11
7
- import numpy as np
8
- from setuptools import setup
9
- from pybind11.setup_helpers import Pybind11Extension, build_ext
10
-
11
-
12
- def _has_hdf5_header(d: Path) -> bool:
13
- return (d / "hdf5.h").exists()
14
-
15
-
16
- def find_hdf5() -> tuple[list, list, list, list, list]:
17
- """Returns (include_dirs, library_dirs, libraries, define_macros, extra_link_args)."""
18
- include_dirs: list[str] = []
19
- library_dirs: list[str] = []
20
- libraries: list[str] = ["hdf5"]
21
- define_macros: list = []
22
- extra_link_args: list = []
23
-
24
- hdf5_dir = os.environ.get("HDF5_DIR", "").strip()
25
- if hdf5_dir:
26
- p = Path(hdf5_dir)
27
- if (p / "include").is_dir():
28
- include_dirs.append(str(p / "include"))
29
- if (p / "lib").is_dir():
30
- library_dirs.append(str(p / "lib"))
31
-
32
- if not include_dirs:
33
- local_inc, local_lib = Path("include"), Path("lib")
34
- if _has_hdf5_header(local_inc):
35
- include_dirs.append(str(local_inc))
36
- if local_lib.is_dir() and any(local_lib.iterdir()):
37
- library_dirs.append(str(local_lib))
38
-
39
- if sys.platform == "win32":
40
- define_macros.append(("H5_BUILT_AS_DYNAMIC_LIB", None))
41
- conda_base = Path(sys.prefix) / "Library"
42
- if _has_hdf5_header(conda_base / "include"):
43
- include_dirs.append(str(conda_base / "include"))
44
- library_dirs.append(str(conda_base / "lib"))
45
- elif sys.platform.startswith("linux"):
46
- for candidate in [Path("/usr/include/hdf5/serial"), Path("/usr/include")]:
47
- if _has_hdf5_header(candidate):
48
- include_dirs.append(str(candidate))
49
- break
50
- for candidate in [Path("/usr/lib/x86_64-linux-gnu/hdf5/serial"), Path("/usr/lib64")]:
51
- if candidate.is_dir():
52
- library_dirs.append(str(candidate))
53
- break
54
-
55
- if sys.platform == "win32":
56
- define_macros.append(("H5_BUILT_AS_DYNAMIC_LIB", None))
57
- found_lib = False
58
- for ldir in library_dirs:
59
- lib_path = Path(ldir)
60
- if (lib_path / "hdf5.lib").exists():
61
- libraries = ["hdf5"]
62
- found_lib = True
63
- break
64
- elif (lib_path / "libhdf5.lib").exists():
65
- libraries = ["libhdf5"]
66
- found_lib = True
67
- break
68
- if not found_lib:
69
- libraries = ["hdf5"]
70
- else:
71
- for ldir in library_dirs:
72
- extra_link_args.append(f"-Wl,-rpath,{ldir}")
73
-
74
- if not any(_has_hdf5_header(Path(d)) for d in include_dirs):
75
- warnings.warn(
76
- f"\n\n*** Could not locate hdf5.h inside {include_dirs} — build will likely fail. ***\n"
77
- "Please check if HDF5_DIR is set correctly.\n",
78
- stacklevel=2
79
- )
80
-
81
- return include_dirs, library_dirs, libraries, define_macros, extra_link_args
82
-
83
-
84
- def get_compile_args() -> list[str]:
85
- if sys.platform == "win32":
86
- return ["/utf-8", "/EHsc", "/bigobj", "/O2"]
87
- return ["-O2", "-fvisibility=hidden"]
88
-
89
-
90
- # ---------------------------------------------------------------------------
91
- # Extension module
92
- # ---------------------------------------------------------------------------
93
- hdf5_inc, hdf5_lib, hdf5_libs, macros, link_args = find_hdf5()
94
-
95
- ext_modules = [
96
- Pybind11Extension(
97
- "cffview.mesh_reader",
98
- sources=[
99
- "src/cffview/main.cxx",
100
- "src/cffview/vtkFLUENTCFFReader.cxx",
101
- ],
102
- include_dirs=[
103
- *hdf5_inc,
104
- str(Path("include")),
105
- np.get_include(),
106
- pybind11.get_include(),
107
- ],
108
- library_dirs=[*hdf5_lib, str(Path("lib"))],
109
- libraries=hdf5_libs,
110
- define_macros=macros,
111
- extra_compile_args=get_compile_args(),
112
- extra_link_args=link_args,
113
- cxx_std=17,
114
- ),
115
- ]
116
-
117
- setup(
118
- ext_modules=ext_modules,
119
- cmdclass={"build_ext": build_ext},
120
- )
@@ -1,24 +0,0 @@
1
- #include "vtkFLUENTCFFReader.h"
2
- #include <pybind11/pybind11.h>
3
- #include <pybind11/numpy.h>
4
-
5
- namespace py = pybind11;
6
-
7
- py::dict read_mesh_data(const std::string& filename)
8
- {
9
- vtkFLUENTCFFReader reader;
10
- return reader.ReadMeshData(filename);
11
- }
12
-
13
- py::object read_pyvista_mesh(const std::string& filename)
14
- {
15
- vtkFLUENTCFFReader reader;
16
- return reader.ReadPyVistaMesh(filename);
17
- }
18
-
19
- PYBIND11_MODULE(mesh_reader, m)
20
- {
21
- m.doc() = "Fluent .cas.h5 reader for PyVista";
22
- m.def("read_mesh_data", &read_mesh_data);
23
- m.def("read_pyvista_mesh", &read_pyvista_mesh);
24
- }