stacknordic 0.1.1__tar.gz → 0.1.2__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.
Files changed (79) hide show
  1. stacknordic-0.1.2/CHANGELOG.md +29 -0
  2. {stacknordic-0.1.1 → stacknordic-0.1.2}/PKG-INFO +5 -33
  3. stacknordic-0.1.2/README.md +49 -0
  4. stacknordic-0.1.2/docs/README.md +15 -0
  5. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/api/README.md +1 -1
  6. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/api/dataset.md +4 -4
  7. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/api/fields.md +35 -10
  8. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/api/filtering.md +6 -2
  9. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/api/openfoam.md +4 -4
  10. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/architecture/data-layout.md +2 -0
  11. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/architecture/workflow.md +3 -2
  12. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/developer/verification.md +2 -1
  13. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/installation.md +14 -4
  14. {stacknordic-0.1.1 → stacknordic-0.1.2}/pyproject.toml +1 -1
  15. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/__init__.py +1 -1
  16. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/computing.py +23 -8
  17. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/_contract.py +41 -10
  18. stacknordic-0.1.2/src/stacknordic/dataset/_manifest.py +44 -0
  19. stacknordic-0.1.2/src/stacknordic/dataset/_output.py +113 -0
  20. stacknordic-0.1.2/src/stacknordic/dataset/compute.py +468 -0
  21. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/derived.py +8 -5
  22. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/downsample.py +55 -75
  23. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/export.py +73 -214
  24. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/package.py +41 -52
  25. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/postprocess.py +26 -52
  26. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/case.py +14 -16
  27. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/environment.py +39 -4
  28. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/io.py +13 -6
  29. stacknordic-0.1.2/src/stacknordic/openfoam/layout.py +191 -0
  30. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/postprocess.py +13 -17
  31. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/write.py +14 -14
  32. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/reconstruction.py +26 -95
  33. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/resources.py +17 -9
  34. stacknordic-0.1.2/tests/dataset/test_compute.py +556 -0
  35. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/dataset/test_derived.py +7 -7
  36. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/dataset/test_downsample.py +50 -0
  37. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/dataset/test_export.py +74 -10
  38. stacknordic-0.1.2/tests/dataset/test_output.py +25 -0
  39. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/dataset/test_package.py +19 -0
  40. stacknordic-0.1.2/tests/openfoam/test_case_postprocess.py +97 -0
  41. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/reconstruction/test_cli.py +1 -1
  42. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/reconstruction/test_reconstruct.py +13 -9
  43. {stacknordic-0.1.1 → stacknordic-0.1.2}/uv.lock +1 -1
  44. stacknordic-0.1.1/CHANGELOG.md +0 -16
  45. stacknordic-0.1.1/README.md +0 -77
  46. stacknordic-0.1.1/docs/README.md +0 -29
  47. stacknordic-0.1.1/src/stacknordic/dataset/_manifest.py +0 -16
  48. stacknordic-0.1.1/src/stacknordic/dataset/compute.py +0 -294
  49. stacknordic-0.1.1/tests/dataset/test_compute.py +0 -302
  50. stacknordic-0.1.1/tests/openfoam/test_case_postprocess.py +0 -62
  51. {stacknordic-0.1.1 → stacknordic-0.1.2}/.gitattributes +0 -0
  52. {stacknordic-0.1.1 → stacknordic-0.1.2}/.github/workflows/tests.yml +0 -0
  53. {stacknordic-0.1.1 → stacknordic-0.1.2}/.gitignore +0 -0
  54. {stacknordic-0.1.1 → stacknordic-0.1.2}/LICENSE +0 -0
  55. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/architecture/principles.md +0 -0
  56. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/benchmarks/README.md +0 -0
  57. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/benchmarks/dataset.md +0 -0
  58. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/benchmarks/reconstruction.md +0 -0
  59. {stacknordic-0.1.1 → stacknordic-0.1.2}/docs/tutorials/case-to-dataset.md +0 -0
  60. {stacknordic-0.1.1 → stacknordic-0.1.2}/others/assets/banner_dark.svg +0 -0
  61. {stacknordic-0.1.1 → stacknordic-0.1.2}/others/assets/banner_light.svg +0 -0
  62. {stacknordic-0.1.1 → stacknordic-0.1.2}/others/assets/icon.svg +0 -0
  63. {stacknordic-0.1.1 → stacknordic-0.1.2}/others/assets/icon_dark.svg +0 -0
  64. {stacknordic-0.1.1 → stacknordic-0.1.2}/others/assets/icon_light.svg +0 -0
  65. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/__main__.py +0 -0
  66. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/_progress.py +0 -0
  67. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/cli.py +0 -0
  68. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/__init__.py +0 -0
  69. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/dataset/thermodynamics.py +0 -0
  70. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/filtering.py +0 -0
  71. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/openfoam/__init__.py +0 -0
  72. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/postprocess.py +0 -0
  73. {stacknordic-0.1.1 → stacknordic-0.1.2}/src/stacknordic/selection.py +0 -0
  74. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/dataset/test_postprocess.py +0 -0
  75. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/openfoam/test_case.py +0 -0
  76. {stacknordic-0.1.1 → stacknordic-0.1.2}/tests/test_filtering.py +0 -0
  77. {stacknordic-0.1.1 → stacknordic-0.1.2}/tools/templates/README.md +0 -0
  78. {stacknordic-0.1.1 → stacknordic-0.1.2}/tools/templates/openfoamHeaderESI.in +0 -0
  79. {stacknordic-0.1.1 → stacknordic-0.1.2}/tools/templates/openfoamHeaderFoundation.in +0 -0
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## Unreleased
4
+
5
+ ## 0.1.2 - 2026-11-30
6
+
7
+ - Select `foamPostProcess` or `postProcess` from the active OpenFOAM runtime for case operations and gradient export.
8
+ - Parallelise Cantera reaction rates in `Dataset.compute()` across snapshots and, for ideal-gas mechanisms, cell ranges. Automatic worker selection accounts for available work, CPUs and estimated memory.
9
+ - Preserve individual component precision and keep previously published data when a derived-field write fails.
10
+ - Use consistent Favre weighting in variance and SGS stress.
11
+ - Reject incomplete grouped-collated times and destinations that would replace input data. Validate grid coordinates before compiling snapshots into one HDF5 series.
12
+ - Reuse resolved mesh addressing files during parallel dataset export.
13
+ - Read bounded headers and reduce copies when decoding binary fields.
14
+ - Reuse the root boundary map when staging decomposed cases for OpenFOAM.com reconstruction.
15
+
16
+ ## 0.1.1 - 2026-11-03
17
+
18
+ - Replace Onsaemiro with Hedgehogs for progress reporting, preserving the final display in terminals and notebooks.
19
+ - Include explicitly selected time zero when reconstructing into a new destination.
20
+ - Export a uniform first field from reconstructed cases using the mesh to determine the cell count.
21
+ - Add installation and case-to-dataset guides and consolidate the API reference.
22
+
23
+ ## 0.1.0 - 2026-09-27
24
+
25
+ - Reconstruct decomposed OpenFOAM.com and OpenFOAM Foundation cases from Python or the command line.
26
+ - Export reconstructed and decomposed fields into Cartesian datasets without requiring permanent reconstruction.
27
+ - Compute declared combustion fields, package HDF5 datasets, and compile snapshot series.
28
+ - Filter and downsample DNS datasets with Reynolds, Favre, variance, and SGS reductions.
29
+ - Run the supported OpenFOAM and stored-data post-processing operations through one API.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: stacknordic
3
- Version: 0.1.1
3
+ Version: 0.1.2
4
4
  Summary: OpenFOAM data preparation and reduction for DNS, LES, and machine learning
5
5
  Project-URL: Homepage, https://github.com/PentagonToy/StackNordic
6
6
  Project-URL: Documentation, https://github.com/PentagonToy/StackNordic/blob/main/docs/README.md
@@ -42,19 +42,13 @@ StackNordic reconstructs and prepares stored OpenFOAM results for DNS, LES and m
42
42
 
43
43
  ## Installation
44
44
 
45
- Use Python 3.11 or 3.12. Install the PyPI release with pip:
45
+ Use Python 3.11 or 3.12.
46
46
 
47
47
  ```console
48
48
  pip install stacknordic
49
49
  ```
50
50
 
51
- Or use uv in an existing virtual environment:
52
-
53
- ```console
54
- uv pip install stacknordic
55
- ```
56
-
57
- Follow the public [installation guide](https://pentagontoy.github.io/FoamNordic/stacknordic/installation/) for optional environment setup, OpenFOAM requirements, installation checks and main or editable installation. The [repository copy](docs/installation.md) contains the same guide.
51
+ Activate a compatible OpenFOAM runtime for reconstruction and other operations that call OpenFOAM utilities. See the [installation guide](docs/installation.md) for runtime and environment setup.
58
52
 
59
53
  ## Reconstruct a case
60
54
 
@@ -64,27 +58,7 @@ Activate the Python environment and the OpenFOAM runtime, enter a decomposed cas
64
58
  stacknordic reconstruct --n-jobs -1 --progress
65
59
  ```
66
60
 
67
- The OpenFOAM-style alias is equivalent:
68
-
69
- ```console
70
- stacknordic -reconstructPar --n-jobs -1 --progress
71
- ```
72
-
73
- Select times, fields and another destination explicitly when required:
74
-
75
- ```console
76
- stacknordic reconstruct \
77
- --case-dir cases/TaylorGreenVortex3D \
78
- --output-dir output/TaylorGreenVortex3D \
79
- --time-range 0 0.1 \
80
- --fields U p nut \
81
- --n-jobs 8 \
82
- --progress
83
- ```
84
-
85
- StackNordic isolates concurrent physical-time reconstructions, preserves the source case and removes temporary case views after success or failure. See the [reconstruction API and CLI contract](docs/api/openfoam.md#reconstruction).
86
-
87
- Read the [case-to-dataset example](https://pentagontoy.github.io/FoamNordic/stacknordic/tutorials/case-to-dataset/) for copyable Python steps and the expected output structure.
61
+ Use `--time` or `--time-range` to select times, `--fields` to select fields and `--output-dir` to write to a separate case. The `-reconstructPar` alias accepts the same options. See the [CLI reference](docs/api/openfoam.md#command-line) for examples.
88
62
 
89
63
  ## Core workflows
90
64
 
@@ -94,9 +68,7 @@ Read the [case-to-dataset example](https://pentagontoy.github.io/FoamNordic/stac
94
68
  - [Filter and downsample DNS data](docs/api/filtering.md) with declared Reynolds, Favre, variance and SGS reductions.
95
69
  - [Run a closed set of post-processing operations](docs/api/fields.md#post-processing) on OpenFOAM cases or exported Cartesian datasets.
96
70
 
97
- StackNordic is independent of [FoamNordic](https://github.com/PentagonToy/FoamNordic), but the projects are designed to be used together. FoamNordic owns solver execution and resident model coupling; StackNordic owns reconstruction, stored-data preparation, packaging and filtering.
98
-
99
- Read the [shared documentation site](https://pentagontoy.github.io/FoamNordic/stacknordic/) or the [repository index](docs/README.md) for API, architecture and validation references.
71
+ Use the [case-to-dataset example](docs/tutorials/case-to-dataset.md) to turn a stored result into HDF5, or browse the [documentation index](docs/README.md).
100
72
 
101
73
  ## Development
102
74
 
@@ -0,0 +1,49 @@
1
+ <picture>
2
+ <source media="(prefers-color-scheme: dark)" srcset="others/assets/banner_dark.svg">
3
+ <img src="others/assets/banner_light.svg" alt="StackNordic" width="960">
4
+ </picture>
5
+
6
+ # StackNordic
7
+
8
+ StackNordic reconstructs and prepares stored OpenFOAM results for DNS, LES and machine-learning workflows. It reads OpenFOAM.com and OpenFOAM Foundation cases, including reconstructed, uncollated, collated and grouped-collated layouts.
9
+
10
+ [Documentation](https://pentagontoy.github.io/FoamNordic/stacknordic/) · [Installation](https://pentagontoy.github.io/FoamNordic/stacknordic/installation/) · [API](https://pentagontoy.github.io/FoamNordic/stacknordic/api/)
11
+
12
+ ## Installation
13
+
14
+ Use Python 3.11 or 3.12.
15
+
16
+ ```console
17
+ pip install stacknordic
18
+ ```
19
+
20
+ Activate a compatible OpenFOAM runtime for reconstruction and other operations that call OpenFOAM utilities. See the [installation guide](docs/installation.md) for runtime and environment setup.
21
+
22
+ ## Reconstruct a case
23
+
24
+ Activate the Python environment and the OpenFOAM runtime, enter a decomposed case, and run:
25
+
26
+ ```console
27
+ stacknordic reconstruct --n-jobs -1 --progress
28
+ ```
29
+
30
+ Use `--time` or `--time-range` to select times, `--fields` to select fields and `--output-dir` to write to a separate case. The `-reconstructPar` alias accepts the same options. See the [CLI reference](docs/api/openfoam.md#command-line) for examples.
31
+
32
+ ## Core workflows
33
+
34
+ - [Export reconstructed or decomposed fields directly](docs/api/dataset.md), including time-local decomposition and mesh addressing.
35
+ - [Compute progress variables and reaction rates](docs/api/fields.md#field-computing) from declared Cantera contracts.
36
+ - [Package and compile Cartesian datasets](docs/api/dataset.md#snapshot-packaging) as self-describing HDF5 snapshots or time series.
37
+ - [Filter and downsample DNS data](docs/api/filtering.md) with declared Reynolds, Favre, variance and SGS reductions.
38
+ - [Run a closed set of post-processing operations](docs/api/fields.md#post-processing) on OpenFOAM cases or exported Cartesian datasets.
39
+
40
+ Use the [case-to-dataset example](docs/tutorials/case-to-dataset.md) to turn a stored result into HDF5, or browse the [documentation index](docs/README.md).
41
+
42
+ ## Development
43
+
44
+ ```console
45
+ uv sync --dev
46
+ uv run pytest
47
+ uv run ruff check .
48
+ uv build
49
+ ```
@@ -0,0 +1,15 @@
1
+ <picture>
2
+ <source media="(prefers-color-scheme: dark)" srcset="../others/assets/banner_dark.svg">
3
+ <img src="../others/assets/banner_light.svg" alt="StackNordic" width="960">
4
+ </picture>
5
+
6
+ # StackNordic documentation
7
+
8
+ | Task | Guide |
9
+ | --- | --- |
10
+ | Install Python and configure OpenFOAM | [Installation](installation.md) |
11
+ | Inspect or reconstruct a stored case | [OpenFOAM cases](api/openfoam.md) |
12
+ | Export fields, package snapshots or compile HDF5 | [Case-to-dataset example](tutorials/case-to-dataset.md) and [dataset API](api/dataset.md) |
13
+ | Compute fields, filter or downsample data | [Field operations](api/fields.md) and [filtering](api/filtering.md) |
14
+ | Check input layouts and reduction rules | [Architecture](architecture/principles.md) |
15
+ | Verify numerical results or performance | [Validation](benchmarks/README.md) and [developer checks](developer/verification.md) |
@@ -8,7 +8,7 @@ StackNordic inspects stored OpenFOAM cases, reconstructs selected times and prep
8
8
  | --- | --- | --- |
9
9
  | Stored cases | `OpenFOAM.case`, `case.reconstruct`, `case.export` | Inspect, reconstruct and export existing results |
10
10
  | Dataset storage | `Dataset.package`, `Dataset.compile` | Package Cartesian snapshots and compile time series |
11
- | Derived fields | `Computing`, `case.compute`, `dataset.compute` | Declare and evaluate thermochemical fields |
11
+ | Derived fields | `Computing`, `Dataset.compute`, `case.compute` | Declare and evaluate progress variables and reaction rates |
12
12
  | Field operations | `Postprocess`, `case.postprocess`, `dataset.postprocess` | Apply supported spatial and temporal operations |
13
13
  | Reduction | `Filtering`, `dataset.downsample`, `Dataset.downsample` | Declare physical reductions and produce coarser datasets |
14
14
 
@@ -39,17 +39,17 @@ case.export(
39
39
 
40
40
  `times=None` selects every complete time. A tuple such as `(0.00114, 0.00120)` selects the inclusive range. A list such as `[0.00114, 0.00120]` selects exactly those two values; a two-element list is not interpreted as a range.
41
41
 
42
- Uniform reconstructed fields obtain their cell count from the selected-time mesh.
43
-
44
42
  `mode="direct"` prefers a complete reconstructed time and otherwise reads `processorN`, `processorsN` or `processorsN_a-b` data without creating reconstructed time directories. Decomposition and `cellProcAddressing` are resolved for every time, so a changing rank layout or time-local mesh is not treated as static.
45
43
 
44
+ A grouped-collated snapshot is complete when its files cover all declared ranks. Use a destination outside the input case or a dedicated subdirectory. Export and packaging reject a destination that would replace their input or one of its parent directories.
45
+
46
46
  When the first field of a reconstructed snapshot is uniform, StackNordic reads the mesh owner and neighbour lists to determine the cell count.
47
47
 
48
48
  For decomposed data, mesh addressing is indexed once per mesh generation and shared read-only through a memory map. Independent time-field tasks run in worker processes and write directly to staged arrays. Automatic worker selection respects the active Slurm or container memory limit before using the allocated CPUs.
49
49
 
50
50
  If `rho` is requested but not stored, direct mode derives it from `p`, `T`, complete species mass fractions and molecular weights when the case declares a multicomponent `perfectGas` equation of state. Stored density remains authoritative, and unsupported thermodynamic contracts fail explicitly.
51
51
 
52
- Each scalar requires one output name, a vector three names, a symmetric tensor six names and a tensor nine names. `gradU` and `gradp` may be generated automatically with OpenFOAM `postProcess` in `mode="reconstruct"`. Direct mode never starts an implicit full reconstruction; it reports the required derived-field action instead.
52
+ Each scalar requires one output name, a vector three names, a symmetric tensor six names and a tensor nine names. In `mode="reconstruct"`, StackNordic can generate `gradU` and `gradp` with the [active runtime's post-processing utility](fields.md#openfoam-case). Direct mode reports the required action when a requested field is missing.
53
53
 
54
54
  ```python
55
55
  from pathlib import Path
@@ -140,7 +140,7 @@ packaged = sno.Dataset.package(
140
140
 
141
141
  Scalars use `(z, y, x)` order; multi-component fields add a final component axis, giving `(z, y, x, 3)` for velocity. Grid axes use `grid/x_axis`, `grid/y_axis` and `grid/z_axis`.
142
142
 
143
- HDF5 attributes retain physical time, source precision and dataset metadata. The embedded contract records logical field paths, component order, grid paths, shape and dtype.
143
+ HDF5 attributes retain physical time, stored precision and dataset metadata. Each packaging call uses one dtype for the grid and selected fields across all snapshots. If any selected component or grid coordinate uses `float64`, the package uses `float64`. The embedded contract records logical field paths, component order, grid paths, shape and dtype.
144
144
 
145
145
  Packaging is staged beside `output_dir` and published atomically. Incomplete files are removed after failure or interruption.
146
146
 
@@ -7,7 +7,7 @@ Declare combustion fields and apply supported spatial or temporal operations to
7
7
 
8
8
  ## Field computing
9
9
 
10
- `sno.Computing` declares physical fields evaluated before filtering. `Dataset.compute()` supports every contract below. `case.compute()` currently supports a single-species progress variable because writing a multi-field boundary transformation requires additional OpenFOAM boundary semantics.
10
+ `sno.Computing` declares progress variables and reaction rates for evaluation before filtering. Use `Dataset.compute()` to store these fields in a Cartesian dataset. Use [`case.compute()`](openfoam.md#case-inspection-and-runtime) to write a single-species progress variable into an OpenFOAM case.
11
11
 
12
12
  ### `sno.Computing.progress`
13
13
 
@@ -49,6 +49,10 @@ $$
49
49
  The unburnt state is the declared mixture. The burnt state is its constant-enthalpy, constant-pressure Cantera equilibrium state. Negative weights may represent consumed reactants; positive weights may represent products.
50
50
 
51
51
  ```python
52
+ import stacknordic as sno
53
+
54
+ MECHANISM = "h2o2.yaml"
55
+
52
56
  progress = sno.Computing.progress(
53
57
  mechanism=MECHANISM,
54
58
  equivalence_ratio=0.45,
@@ -102,9 +106,28 @@ $$
102
106
 
103
107
  Selecting `units="1/s"` returns the corresponding specific source $\dot{\omega}/\rho$. StackNordic records the selected basis in dataset metadata and does not infer it from the output name.
104
108
 
105
- Compatible reaction-rate declarations are fused automatically. Definitions sharing the mechanism, species fields, temperature field and pressure or density field use one Cantera state evaluation per bounded cell chunk; requesting species and progress-variable rates therefore does not repeat kinetics evaluation.
109
+ Definitions that share the mechanism, species fields, temperature field and pressure or density field use one Cantera state evaluation per cell chunk.
110
+
111
+ ### `sno.Dataset.compute`
112
+
113
+ Compute the declared fields for every snapshot in an exported Cartesian dataset. Each definition must name the logical scalar fields it reads and a unique output field.
114
+
115
+ | Parameter | Type | Default | Meaning |
116
+ | --- | --- | --- | --- |
117
+ | `dataset_dir` | `str \| Path` | Required | Dataset directory containing `info.json`. |
118
+ | `computations` | `Sequence[Computation]` | Required | Progress-variable and reaction-rate declarations. |
119
+ | `dtype` | `str \| None` | `None` | Output precision. Use `"float32"` or `"float64"`. The default uses the stored dtype. |
120
+ | `n_jobs` | `int \| None` | `None` | The default selects workers automatically for Cantera reaction rates where `fork` is available and uses one worker otherwise. Use `-1` for automatic selection or a positive worker limit. |
121
+ | `progress` | `bool` | `False` | Show progress by completed cell range, chunk or whole snapshot, according to the selected execution path. |
122
+ | `overwrite` | `bool` | `False` | Allow replacement of existing output fields. |
123
+
124
+ Workers for ideal-gas Cantera mechanisms take contiguous cell ranges from a queue shared across snapshots. Small snapshots and computations with a nonideal mechanism use whole snapshots as tasks. Worker limits account for available tasks and CPUs. Automatic selection also uses estimated memory, including applicable Slurm CPU and cgroup memory limits. Set `n_jobs=1` to run serially. The `ComputedDataset` result reports the dataset directory, output fields, snapshot count, worker count and elapsed time.
106
125
 
107
- With `progress=True`, the display starts before computation and advances by completed cell chunks across all snapshots. Long Cantera evaluations therefore remain visible before the first snapshot completes.
126
+ Resolve field filenames through `info.json`. When replacing fields, StackNordic publishes the new filenames and dtypes together after writing the arrays.
127
+
128
+ The manifest records the precision of each computed component. Subsequent computation, post-processing, reduction and packaging read each component at its stored precision. Coordinates and fields from the original export retain their original precision.
129
+
130
+ The example uses `progress` defined above and an argon-free H₂–air dataset with logical fields named `T`, `rho` and the species names below. Both rates use the same Cantera state. If you already hold the result from `case.export()`, call `dataset.compute()` with the same arguments except `dataset_dir`.
108
131
 
109
132
  ```python
110
133
  state = {name: name for name in ("H2", "H", "O2", "OH", "O", "H2O", "HO2", "H2O2", "N2")}
@@ -113,7 +136,7 @@ omega_h2 = sno.Computing.reaction_rate(
113
136
  mechanism=MECHANISM,
114
137
  species=state,
115
138
  temperature="T",
116
- pressure="p",
139
+ density="rho",
117
140
  target="H2",
118
141
  output="omega_H2_mass",
119
142
  units="kg/m^3/s",
@@ -129,12 +152,10 @@ omega_c = sno.Computing.reaction_rate(
129
152
  units="1/s",
130
153
  )
131
154
 
132
- computed = dataset.compute(
155
+ computed = sno.Dataset.compute(
156
+ dataset_dir="datasets/h2",
133
157
  computations=(progress, omega_h2, omega_c),
134
- dtype="float32",
135
- n_jobs=-1,
136
158
  progress=True,
137
- overwrite=False,
138
159
  )
139
160
  ```
140
161
 
@@ -148,7 +169,7 @@ computed = dataset.compute(
148
169
  | --- | --- | --- | --- | --- |
149
170
  | `grad(field=..., output=None)` | `grad<field>` | yes | yes | Spatial gradient of a scalar or vector field. |
150
171
  | `div(field=..., output=None)` | `div<field>` | yes | yes | Divergence of a vector field. |
151
- | `ddt(field=..., output=None)` | `ddt<field>` | yes | yes | OpenFOAM temporal derivative or finite difference between stored dataset snapshots. |
172
+ | `ddt(field=..., output=None)` | `ddt<field>` | runtime-dependent | yes | OpenFOAM temporal derivative or finite difference between stored dataset snapshots. |
152
173
  | `components(field=..., outputs=None)` | `<field>x`, `<field>y`, `<field>z` | yes | yes | Scalar components of a three-component vector. |
153
174
  | `mag(field=..., output=None)` | `mag<field>` | yes | yes | Scalar absolute value or vector magnitude. |
154
175
  | `mag_sqr(field=..., output=None)` | `magSqr<field>` | yes | yes | Squared scalar or vector magnitude. |
@@ -195,7 +216,11 @@ result = case.postprocess(
195
216
  )
196
217
  ```
197
218
 
198
- This path requires reconstructed time directories and invokes only the listed OpenFOAM function objects through the case-local runtime. Direct decomposed export remains available independently.
219
+ This path requires reconstructed time directories. StackNordic looks in `FOAM_APPBIN` and then in `PATH` after applying the case's environment setup. Use the same operation declarations with Foundation 14's `foamPostProcess` and OpenFOAM.com's `postProcess`.
220
+
221
+ The Foundation utility writes cell volumes as `Vc`. StackNordic publishes that field under the requested name, with `V` as the default.
222
+
223
+ The offline utilities in Foundation 14 and OpenFOAM.com v2606 reject `ddt` and StackNordic reports their diagnostic. Use `dataset.postprocess()` for a finite difference between exported snapshots.
199
224
 
200
225
  ### Cartesian dataset
201
226
 
@@ -21,8 +21,8 @@ sno.Filtering(
21
21
  | `density` | `str \| None` | `None` | Density field used by Favre reductions. |
22
22
  | `mean` | `Sequence[str]` | `()` | Fields reduced by an unweighted spatial mean. |
23
23
  | `favre` | `Sequence[str]` | `()` | Fields reduced as $\widetilde{\phi}=\overline{\rho\phi}/\overline{\rho}$. |
24
- | `variance` | `Mapping[str, str]` | `{}` | Scalar source fields mapped to filtered variance outputs. |
25
- | `stress` | `Mapping[str, str]` | `{}` | Three-component velocity fields mapped to six-component SGS stress outputs. |
24
+ | `variance` | `Mapping[str, str]` | `{}` | Scalar source fields mapped to variance outputs. Both moments use density weighting when `density` is supplied. |
25
+ | `stress` | `Mapping[str, str]` | `{}` | Three-component velocity fields mapped to six-component SGS stress outputs. Both moments use density weighting when `density` is supplied. |
26
26
  | `energy` | `Mapping[str, str]` | `{}` | SGS stress outputs mapped to SGS kinetic-energy outputs. |
27
27
  | `specific` | `Mapping[str, str]` | `{}` | Filtered volumetric sources mapped to specific-source outputs obtained by division by filtered density. |
28
28
 
@@ -59,6 +59,8 @@ filtering = sno.Filtering.combustion(
59
59
 
60
60
  `flow="compressible"` requires `density` and applies Favre filtering to transported fields. `flow="incompressible"` applies ordinary spatial means; `density` may be omitted.
61
61
 
62
+ A field can appear in `mean` and also supply a variance or stress. With density, the output in `mean` is the Reynolds mean and the central moment uses its own Favre mean. Without density, both terms of each central moment use unweighted spatial means.
63
+
62
64
  `reaction_rate` is filtered as a volumetric source. When `specific_reaction_rate` is provided, StackNordic derives the specific source after filtering:
63
65
 
64
66
  $$
@@ -124,6 +126,8 @@ Box filtering uses each non-overlapping block and trims only incomplete cells at
124
126
 
125
127
  Passing `output_file` filters snapshots in parallel and commits each completed snapshot to one HDF5 series through a single writer. Temporary snapshots are bounded by the worker count, deleted after commit and removed after failure or interruption.
126
128
 
129
+ Choose a destination that preserves the input dataset and its parent directories.
130
+
127
131
  ```python
128
132
  les = sno.Dataset.downsample(
129
133
  dataset_dir=DNS_DIR / "phi045.h5",
@@ -20,10 +20,10 @@ case = sno.OpenFOAM.case(
20
20
  | Parameter | Type | Default | Meaning |
21
21
  | --- | --- | --- | --- |
22
22
  | `case_dir` | `str \| Path` | Required | OpenFOAM case directory containing `system/controlDict` and `constant/`. |
23
- | `of_cmd` | `str \| None` | `None` | Environment command evaluated before this case invokes OpenFOAM. A shorthand such as `openfoam/2512` expands to `module load openfoam/2512`. |
23
+ | `of_cmd` | `str \| None` | `None` | Environment setup command for this case. `None` inherits the active environment. Module shorthands such as `openfoam-org/14` and `openfoam/2512` expand to `module load` commands. |
24
24
  | `shell` | `str` | `"bash"` | Shell used to evaluate `of_cmd`. |
25
25
 
26
- The returned case exposes `family`, `source_versions`, `reconstructed_times`, `decomposed_times`, `processor_count`, and `collated`. Direct exports prefer a complete reconstructed time and otherwise assemble the corresponding processor or collated data without running `reconstructPar`.
26
+ The returned case exposes `family`, `source_versions`, `reconstructed_times`, `decomposed_times`, `processor_count`, and `collated`. When complete times use different decompositions, the last two properties describe the latest complete decomposed time. Direct export selects the layout for each time.
27
27
 
28
28
  Use `case.compute()` to write derived fields into the existing reconstructed, `processorN`, or collated layout. The generated files are valid OpenFOAM volume fields and are immediately available to `case.export()`.
29
29
 
@@ -72,7 +72,7 @@ Each output is committed atomically beside its source fields. Existing source fi
72
72
 
73
73
  See [Dataset export](dataset.md) for the complete `case.export()` parameter contract.
74
74
 
75
- Use `case.postprocess()` for the closed set of supported OpenFOAM function objects. The case-local `of_cmd` and `shell` configuration is reused automatically. See [Post-processing](fields.md#post-processing) for the operation and parameter contracts.
75
+ Use `case.postprocess()` to run the supported OpenFOAM function objects. StackNordic selects the executable in the environment configured for the case. See [OpenFOAM post-processing](fields.md#openfoam-case) for the operation contract and runtime requirements.
76
76
 
77
77
  Module names are site-specific. StackNordic accepts OpenFOAM Foundation and OpenFOAM.com runtimes. When the configured runtime family differs from an identifiable case family, inspection reports two short lines and keeps direct stored-data operations available.
78
78
 
@@ -80,7 +80,7 @@ Module names are site-specific. StackNordic accepts OpenFOAM Foundation and Open
80
80
 
81
81
  Selected time zero is included when reconstructing into a new destination.
82
82
 
83
- StackNordic reconstructs complete physical times from decomposed OpenFOAM cases produced by OpenFOAM Foundation or OpenFOAM.com.
83
+ StackNordic reconstructs complete physical times from one decomposition produced by OpenFOAM Foundation or OpenFOAM.com. Use direct export to read times from multiple layouts in the same case.
84
84
 
85
85
  ### `case.reconstruct`
86
86
 
@@ -5,3 +5,5 @@ Direct export supports uncollated `processorN`, collated `processorsN` and group
5
5
  Time-local `polyMesh/cellProcAddressing` takes precedence over `constant/polyMesh/cellProcAddressing`. Rank-count changes, repartitioning and moving or topology-changing meshes therefore do not inherit stale addressing from an earlier time.
6
6
 
7
7
  Cartesian coordinates are emitted only when a single-block `blockMeshDict` is verified against the global cell count and no selected time contains a local mesh. All other exports use stable global cell indices and record `layout="cells"`.
8
+
9
+ For a Cartesian dataset, the global `dtype` describes the grid axes and provides the default for field components. The optional `component_dtypes` mapping records the stored dtype of individual components. Readers use the full cell count and file size to recover the precision of older computed fields that lack this mapping.
@@ -7,8 +7,9 @@ OpenFOAM case
7
7
  │
8
8
  ├── inspect distribution, decomposition, times and topology
9
9
  ├── decode directly or reconstruct in an isolated workspace
10
- ├── derive requested fields with OpenFOAM or a declared numerical provider
10
+ ├── derive fields in the case when needed
11
11
  ├── validate and export canonical snapshots
12
+ ├── compute declared progress variables and reaction rates on the exported grid
12
13
  ├── filter or downsample with explicit physical rules
13
14
  └── publish atomically with provenance and validation results
14
15
  ```
@@ -32,6 +33,6 @@ Box reduction trims incomplete blocks at the upper end of each axis. A filtered
32
33
 
33
34
  ## Execution
34
35
 
35
- Parallel work is bounded by selected work, available CPUs, and estimated memory. Temporary data remains beside its destination and is removed after success or failure.
36
+ Automatic worker selection accounts for available work and CPUs. Dataset operations with a worker memory estimate also use the memory limit when available. See [field computation](../api/fields.md#snodatasetcompute) for the Cantera defaults.
36
37
 
37
38
  Operations with `progress=True` report completed tasks or chunks through Hedgehogs. Failed operations retain the completed count; they do not report full completion.
@@ -7,9 +7,10 @@ Choose checks according to the changed behaviour. Keep generated cases, datasets
7
7
  | Documentation | Read the diff; check links, signatures, units and rendering |
8
8
  | Stored-case inspection or decoding | Test layouts, time-local addressing, component order and source preservation |
9
9
  | Reconstruction | Compare selected outputs with the native OpenFOAM tool; check failure cleanup |
10
+ | OpenFOAM post-processing | Run the same operations on case copies under Foundation and OpenFOAM.com. Check generated field names, gradient export and diagnostics for unavailable operations. |
10
11
  | Packaging or compilation | Check field contracts, grid metadata, snapshot identity and atomic publication |
11
12
  | Computing or reduction | Check declared physical definitions, finite values, units and requested conservation properties |
12
- | Worker selection | Check work, CPU and memory bounds and failure propagation |
13
+ | Worker selection | Check work, CPU and memory bounds and failure propagation. Compare automatically parallelised Cantera output with a serial run. |
13
14
 
14
15
  ## Portable checks
15
16
 
@@ -6,7 +6,7 @@ Install StackNordic from PyPI, check the Python environment, then choose a store
6
6
 
7
7
  Use Python 3.11 or 3.12 on Linux or macOS. The package installs NumPy, SciPy, h5py, Cantera and Hedgehogs as dependencies. The commands below use a bash or zsh terminal.
8
8
 
9
- StackNordic is under active development. The site records its [source revision](https://pentagontoy.github.io/FoamNordic/versions/); a PyPI release can differ from the current repository API. Use a matching release or pinned source revision for reproducible work.
9
+ For reproducible work, record the installed StackNordic release or pin the source revision. The documentation site lists the [Git revision it describes](https://pentagontoy.github.io/FoamNordic/versions/).
10
10
 
11
11
  ## 1. Install the Python package
12
12
 
@@ -53,7 +53,7 @@ See the [uv installation guide](https://docs.astral.sh/uv/getting-started/instal
53
53
 
54
54
  </details>
55
55
 
56
- StackNordic 0.1.1 uses Hedgehogs for progress displays. To update an existing installation in the active environment, run `uv pip install --upgrade stacknordic` or `python -m pip install --upgrade stacknordic`.
56
+ To update an existing installation in the active environment, run `uv pip install --upgrade stacknordic` or `python -m pip install --upgrade stacknordic`.
57
57
 
58
58
  ## 2. Check the installation
59
59
 
@@ -88,11 +88,21 @@ Reconstruction and OpenFOAM-backed post-processing require an installed OpenFOAM
88
88
  <!-- tabs -->
89
89
  ### Linux / HPC
90
90
 
91
- Load the site's OpenFOAM module; the module name below is an example:
91
+ Load the module for the OpenFOAM distribution used by the case. On Roihu, use `module spider` to check compiler and MPI prerequisites before loading Foundation 14.
92
+
93
+ ```console
94
+ module spider openfoam-org/14
95
+ module load openfoam-org/14
96
+ reconstructPar -help
97
+ foamPostProcess -help
98
+ ```
99
+
100
+ In an OpenFOAM.com environment, check `postProcess`. Use the module name provided by the site.
92
101
 
93
102
  ```console
94
103
  module load openfoam/2512
95
104
  reconstructPar -help
105
+ postProcess -help
96
106
  ```
97
107
 
98
108
  For a standalone installation, source its `etc/bashrc` instead, following its compiler and MPI setup instructions.
@@ -113,7 +123,7 @@ openfoam "$(command -v stacknordic)" reconstruct --case-dir cases/cavity --n-job
113
123
 
114
124
  <!-- /tabs -->
115
125
 
116
- Continue with the [reconstruction example](../README.md#reconstruct-a-case). In Python, declare the environment through `sno.OpenFOAM.case(of_cmd=..., shell=...)`: use the local module command with `shell="bash"`, or `of_cmd="openfoam"` with `shell="zsh"` on macOS.
126
+ Continue with the [reconstruction example](../README.md#reconstruct-a-case) or the [post-processing API](api/fields.md#openfoam-case). In Python, omit `of_cmd` when the process or notebook kernel already inherits the OpenFOAM environment. To configure the case explicitly, pass its setup command with `shell="bash"` on Linux or `of_cmd="openfoam"` with `shell="zsh"` for OpenFOAM.app.
117
127
 
118
128
  ## If installation stops
119
129
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "stacknordic"
7
- version = "0.1.1"
7
+ version = "0.1.2"
8
8
  description = "OpenFOAM data preparation and reduction for DNS, LES, and machine learning"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.11,<3.13"
@@ -17,7 +17,7 @@ from .openfoam.write import ComputedFields
17
17
  from .postprocess import Postprocess, PostprocessOperation
18
18
  from .reconstruction import Reconstruction, reconstruct
19
19
 
20
- __version__ = "0.1.1"
20
+ __version__ = "0.1.2"
21
21
 
22
22
  OpenFOAM = openfoam
23
23
 
@@ -131,7 +131,7 @@ class ReactionRateComputation:
131
131
 
132
132
  return (
133
133
  self.mechanism,
134
- tuple(self.species_fields.items()),
134
+ tuple(sorted(self.species_fields.items())),
135
135
  self.temperature_field,
136
136
  self.pressure_field,
137
137
  self.density_field,
@@ -172,6 +172,9 @@ def reaction_rate_chunks(
172
172
  raise ValueError("reaction-rate fields must share one shape")
173
173
  indices = {name: gas.species_index(name) for name in first.species_fields}
174
174
  molecular_weights = gas.molecular_weights
175
+ state_property = "TPY" if first.pressure_field is not None else "TDY"
176
+ needs_density = any(definition.units == "1/s" for definition in definitions)
177
+ ideal_gas = gas.thermo_model == "ideal-gas"
175
178
  for start in range(0, size, chunk_cells):
176
179
  stop = min(start + chunk_cells, size)
177
180
  chunk_temperature = np.asarray(temperature[start:stop], dtype=np.float64)
@@ -192,13 +195,25 @@ def reaction_rate_chunks(
192
195
  raise ValueError(
193
196
  "reaction-rate mass fractions must include a complete state summing to one"
194
197
  )
195
- states = ct.SolutionArray(gas, stop - start)
196
- state = (chunk_temperature, chunk_thermodynamic, mass_fractions)
197
- if first.pressure_field is not None:
198
- states.TPY = state
198
+ if ideal_gas:
199
+ # Avoid storing and restoring each ideal-gas state between queries
200
+ rates = np.empty_like(mass_fractions)
201
+ density = np.empty(stop - start) if needs_density else None
202
+ for cell, state in enumerate(
203
+ zip(chunk_temperature, chunk_thermodynamic, mass_fractions, strict=True)
204
+ ):
205
+ setattr(gas, state_property, state)
206
+ rates[cell] = gas.net_production_rates
207
+ if density is not None:
208
+ density[cell] = gas.density
199
209
  else:
200
- states.TDY = state
201
- rates = states.net_production_rates
210
+ states = ct.SolutionArray(gas, stop - start)
211
+ setattr(
212
+ states, state_property,
213
+ (chunk_temperature, chunk_thermodynamic, mass_fractions),
214
+ )
215
+ rates = states.net_production_rates
216
+ density = states.density if needs_density else None
202
217
  outputs: dict[str, np.ndarray] = {}
203
218
  for definition in definitions:
204
219
  values = np.zeros(stop - start)
@@ -206,7 +221,7 @@ def reaction_rate_chunks(
206
221
  index = gas.species_index(species)
207
222
  values += coefficient * molecular_weights[index] * rates[:, index]
208
223
  if definition.units == "1/s":
209
- values /= states.density
224
+ values /= density
210
225
  outputs[definition.output] = values
211
226
  yield start, stop, outputs
212
227
 
@@ -3,11 +3,13 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  import json
6
- from dataclasses import dataclass
6
+ from collections.abc import Mapping
7
+ from dataclasses import dataclass, replace
7
8
  from types import MappingProxyType
8
9
  from typing import Any
9
10
 
10
11
  import h5py
12
+ import numpy as np
11
13
 
12
14
  SNAPSHOT_SCHEMA = "stacknordic-hdf5-snapshot-v1"
13
15
  SERIES_SCHEMA = "stacknordic-hdf5-series-v1"
@@ -26,6 +28,43 @@ def normalise_hdf5_path(value: str) -> str:
26
28
  return "/".join(parts)
27
29
 
28
30
 
31
+ def normalise_hdf5_fields(fields: Mapping[str, str] | None) -> dict[str, str]:
32
+ if not isinstance(fields, Mapping) or not fields:
33
+ raise TypeError("fields must be a non-empty mapping")
34
+ try:
35
+ selected = {str(name): normalise_hdf5_path(path) for name, path in fields.items()}
36
+ except ValueError as error:
37
+ raise ValueError(f"[StackNordic] {error}") from error
38
+ if "" in selected:
39
+ raise ValueError("[StackNordic] field names must be non-empty")
40
+ if len(selected) != len(fields):
41
+ raise ValueError("[StackNordic] field names must be unique")
42
+ targets = set(selected.values())
43
+ if len(targets) != len(selected):
44
+ raise ValueError("[StackNordic] HDF5 field paths must be unique")
45
+ for target in selected.values():
46
+ parent = target.rpartition("/")[0]
47
+ while parent:
48
+ if parent in targets:
49
+ raise ValueError(f"[StackNordic] HDF5 field path {parent!r} conflicts with {target!r}")
50
+ parent = parent.rpartition("/")[0]
51
+
52
+ return selected
53
+
54
+
55
+ def compression_options(compression: str | None) -> dict[str, object]:
56
+ if compression not in {None, "lzf", "gzip"}:
57
+ raise ValueError("[StackNordic] compression must be None, 'lzf', or 'gzip'")
58
+ if compression is None:
59
+ return {}
60
+
61
+ return {"compression": compression, "shuffle": True, "chunks": True}
62
+
63
+
64
+ def read_grid(file: h5py.File) -> dict[str, np.ndarray]:
65
+ return {axis: np.asarray(file[f"grid/{axis}_axis"]) for axis in "xyz"}
66
+
67
+
29
68
  @dataclass(frozen=True, slots=True)
30
69
  class HDF5Contract:
31
70
  """Immutable logical-field contract stored with every package."""
@@ -57,15 +96,7 @@ class HDF5Contract:
57
96
  }
58
97
 
59
98
  def with_schema(self, schema: str) -> HDF5Contract:
60
- return HDF5Contract(
61
- schema=schema,
62
- name=self.name,
63
- dtype=self.dtype,
64
- shape_zyx=self.shape_zyx,
65
- fields=self.fields,
66
- components=self.components,
67
- metadata=self.metadata,
68
- )
99
+ return replace(self, schema=schema)
69
100
 
70
101
 
71
102
  def contract(