cffview 0.1.3__tar.gz → 0.2.1__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,20 +1,20 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cffview
3
- Version: 0.1.3
3
+ Version: 0.2.1
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
7
7
  Project-URL: Repository, https://github.com/preamer/cffview
8
8
  Keywords: fluent,cfd,ansys,hdf5,mesh
9
9
  Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
10
11
  Classifier: Programming Language :: Python :: 3.11
11
12
  Classifier: Programming Language :: Python :: 3.12
12
13
  Classifier: Programming Language :: Python :: 3.13
13
14
  Classifier: Programming Language :: Python :: 3.14
14
- Classifier: Programming Language :: C++
15
15
  Classifier: Topic :: Scientific/Engineering
16
16
  Classifier: Environment :: Console
17
- Requires-Python: >=3.11
17
+ Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: h5py>=3.16.0
@@ -31,7 +31,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
31
31
 
32
32
  - Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
33
33
  - 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
34
 
36
35
  ---
37
36
 
@@ -43,16 +42,12 @@ pip install cffview
43
42
 
44
43
  ### Build from source
45
44
 
46
- HDF5 development headers and libraries are required.
47
-
48
45
  ```bash
49
46
  git clone https://github.com/preamer/cffview.git
50
47
  cd cffview
51
48
  pip install .
52
49
  ```
53
50
 
54
- If auto-detection fails, set `HDF5_DIR` explicitly before installing.
55
-
56
51
  ---
57
52
 
58
53
  ## Usage
@@ -109,9 +104,7 @@ cffview case.cas.h5 --extract
109
104
  |---|---|---|
110
105
  | Case settings (`--solver`, `--mat`, `--bd`, …) | ✅ | — |
111
106
  | Mesh visualisation (3D) | ✅ | ✅ |
112
- | Mesh visualisation (2D) | ✅ | ⚠️ partial |
113
-
114
- > **Note:** 2D `.msh.h5` face connectivity (C0/C1) parsing is not yet fully implemented.
107
+ | Mesh visualisation (2D) | ✅ | |
115
108
 
116
109
  ---
117
110
 
@@ -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,23 +1,23 @@
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.1"
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
- requires-python = ">=3.11"
10
+ requires-python = ">=3.10"
11
11
  authors = [{ name = "preamer", email = "1524477126@qq.com" }]
12
12
  keywords = ["fluent", "cfd", "ansys", "hdf5", "mesh"]
13
13
  license = "BSD-3-Clause"
14
14
  classifiers = [
15
15
  "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3.10",
16
17
  "Programming Language :: Python :: 3.11",
17
18
  "Programming Language :: Python :: 3.12",
18
19
  "Programming Language :: Python :: 3.13",
19
20
  "Programming Language :: Python :: 3.14",
20
- "Programming Language :: C++",
21
21
  "Topic :: Scientific/Engineering",
22
22
  "Environment :: Console",
23
23
  ]
@@ -36,20 +36,3 @@ Repository = "https://github.com/preamer/cffview"
36
36
 
37
37
  [tool.setuptools.packages.find]
38
38
  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,85 @@ 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(
408
+ pv_points,
409
+ faces=pv_faces if dimension == 3 else None,
410
+ lines=pv_faces if dimension == 2 else None
411
+ )
412
+ plotter = pv.Plotter()
413
+ plotter.add_mesh(
414
+ mesh,
415
+ show_edges=True,
416
+ color='lightblue',
417
+ line_width=2,
418
+ smooth_shading=True,
419
+ split_sharp_edges=True,
420
+ )
421
+ plotter.add_axes()
422
+ plotter.show()
423
+
424
+
350
425
  def main() -> None:
351
426
  import argparse
352
427
 
353
- desc = "A Python CLI tool to get case settings and display mesh without opening Ansys Fluent"
428
+ desc = "A Python CLI tool to inspect Ansys Fluent .cas.h5/.msh.h5 files without opening Fluent"
354
429
  parser = argparse.ArgumentParser(description=desc)
355
430
 
356
431
  parser.add_argument(
@@ -434,20 +509,10 @@ def main() -> None:
434
509
  elif args.extract:
435
510
  extract_h5(args.file_path)
436
511
  elif args.file_path.endswith(".msh.h5"):
437
- ...
512
+ show_mesh(args.file_path)
438
513
  elif args.file_path.endswith(".cas.h5"):
439
514
  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)
515
+ show_mesh(args.file_path)
451
516
  else:
452
517
  from .utils import print_colored_dict
453
518
  kwargs = {
@@ -1,20 +1,20 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cffview
3
- Version: 0.1.3
3
+ Version: 0.2.1
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
7
7
  Project-URL: Repository, https://github.com/preamer/cffview
8
8
  Keywords: fluent,cfd,ansys,hdf5,mesh
9
9
  Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.10
10
11
  Classifier: Programming Language :: Python :: 3.11
11
12
  Classifier: Programming Language :: Python :: 3.12
12
13
  Classifier: Programming Language :: Python :: 3.13
13
14
  Classifier: Programming Language :: Python :: 3.14
14
- Classifier: Programming Language :: C++
15
15
  Classifier: Topic :: Scientific/Engineering
16
16
  Classifier: Environment :: Console
17
- Requires-Python: >=3.11
17
+ Requires-Python: >=3.10
18
18
  Description-Content-Type: text/markdown
19
19
  License-File: LICENSE
20
20
  Requires-Dist: h5py>=3.16.0
@@ -31,7 +31,6 @@ A command-line tool for inspecting Ansys Fluent `.cas.h5` / `.msh.h5` files **wi
31
31
 
32
32
  - Read solver settings, materials, boundary conditions, discretisation schemes, and more directly from the HDF5 file.
33
33
  - 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
34
 
36
35
  ---
37
36
 
@@ -43,16 +42,12 @@ pip install cffview
43
42
 
44
43
  ### Build from source
45
44
 
46
- HDF5 development headers and libraries are required.
47
-
48
45
  ```bash
49
46
  git clone https://github.com/preamer/cffview.git
50
47
  cd cffview
51
48
  pip install .
52
49
  ```
53
50
 
54
- If auto-detection fails, set `HDF5_DIR` explicitly before installing.
55
-
56
51
  ---
57
52
 
58
53
  ## Usage
@@ -109,9 +104,7 @@ cffview case.cas.h5 --extract
109
104
  |---|---|---|
110
105
  | Case settings (`--solver`, `--mat`, `--bd`, …) | ✅ | — |
111
106
  | Mesh visualisation (3D) | ✅ | ✅ |
112
- | Mesh visualisation (2D) | ✅ | ⚠️ partial |
113
-
114
- > **Note:** 2D `.msh.h5` face connectivity (C0/C1) parsing is not yet fully implemented.
107
+ | Mesh visualisation (2D) | ✅ | |
115
108
 
116
109
  ---
117
110
 
@@ -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
- }