stacknordic 0.1.0__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 (87) hide show
  1. stacknordic-0.1.2/.gitattributes +1 -0
  2. stacknordic-0.1.2/CHANGELOG.md +29 -0
  3. {stacknordic-0.1.0 → stacknordic-0.1.2}/PKG-INFO +17 -40
  4. stacknordic-0.1.2/README.md +49 -0
  5. stacknordic-0.1.2/docs/README.md +15 -0
  6. stacknordic-0.1.2/docs/api/README.md +28 -0
  7. stacknordic-0.1.2/docs/api/dataset.md +180 -0
  8. stacknordic-0.1.2/docs/api/fields.md +257 -0
  9. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/api/filtering.md +12 -8
  10. stacknordic-0.1.2/docs/api/openfoam.md +158 -0
  11. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/architecture/data-layout.md +2 -0
  12. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/architecture/workflow.md +6 -3
  13. stacknordic-0.1.2/docs/benchmarks/README.md +10 -0
  14. stacknordic-0.1.2/docs/developer/verification.md +28 -0
  15. stacknordic-0.1.2/docs/installation.md +186 -0
  16. stacknordic-0.1.2/docs/tutorials/case-to-dataset.md +64 -0
  17. stacknordic-0.1.2/others/assets/banner_dark.svg +15 -0
  18. stacknordic-0.1.2/others/assets/banner_light.svg +15 -0
  19. stacknordic-0.1.2/others/assets/icon.svg +9 -0
  20. stacknordic-0.1.2/others/assets/icon_dark.svg +9 -0
  21. stacknordic-0.1.2/others/assets/icon_light.svg +9 -0
  22. {stacknordic-0.1.0 → stacknordic-0.1.2}/pyproject.toml +2 -2
  23. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/__init__.py +1 -1
  24. stacknordic-0.1.2/src/stacknordic/_progress.py +19 -0
  25. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/computing.py +23 -8
  26. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/_contract.py +41 -10
  27. stacknordic-0.1.2/src/stacknordic/dataset/_manifest.py +44 -0
  28. stacknordic-0.1.2/src/stacknordic/dataset/_output.py +113 -0
  29. stacknordic-0.1.2/src/stacknordic/dataset/compute.py +468 -0
  30. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/derived.py +8 -5
  31. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/downsample.py +55 -75
  32. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/export.py +82 -221
  33. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/package.py +41 -52
  34. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/postprocess.py +26 -52
  35. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/case.py +14 -16
  36. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/environment.py +39 -4
  37. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/io.py +13 -6
  38. stacknordic-0.1.2/src/stacknordic/openfoam/layout.py +191 -0
  39. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/postprocess.py +13 -17
  40. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/write.py +14 -14
  41. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/reconstruction.py +28 -95
  42. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/resources.py +17 -9
  43. stacknordic-0.1.2/tests/dataset/test_compute.py +556 -0
  44. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/dataset/test_derived.py +7 -7
  45. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/dataset/test_downsample.py +50 -0
  46. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/dataset/test_export.py +89 -10
  47. stacknordic-0.1.2/tests/dataset/test_output.py +25 -0
  48. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/dataset/test_package.py +19 -0
  49. stacknordic-0.1.2/tests/openfoam/test_case_postprocess.py +97 -0
  50. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/reconstruction/test_cli.py +1 -1
  51. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/reconstruction/test_reconstruct.py +31 -9
  52. {stacknordic-0.1.0 → stacknordic-0.1.2}/uv.lock +17 -17
  53. stacknordic-0.1.0/CHANGELOG.md +0 -9
  54. stacknordic-0.1.0/README.md +0 -72
  55. stacknordic-0.1.0/docs/README.md +0 -25
  56. stacknordic-0.1.0/docs/api/computing.md +0 -132
  57. stacknordic-0.1.0/docs/api/dataset.md +0 -69
  58. stacknordic-0.1.0/docs/api/openfoam.md +0 -85
  59. stacknordic-0.1.0/docs/api/packaging.md +0 -96
  60. stacknordic-0.1.0/docs/api/postprocess.md +0 -92
  61. stacknordic-0.1.0/docs/api/reconstruction.md +0 -76
  62. stacknordic-0.1.0/docs/developer/verification.md +0 -10
  63. stacknordic-0.1.0/src/stacknordic/_progress.py +0 -21
  64. stacknordic-0.1.0/src/stacknordic/dataset/_manifest.py +0 -16
  65. stacknordic-0.1.0/src/stacknordic/dataset/compute.py +0 -294
  66. stacknordic-0.1.0/tests/dataset/test_compute.py +0 -302
  67. stacknordic-0.1.0/tests/openfoam/test_case_postprocess.py +0 -62
  68. {stacknordic-0.1.0 → stacknordic-0.1.2}/.github/workflows/tests.yml +0 -0
  69. {stacknordic-0.1.0 → stacknordic-0.1.2}/.gitignore +0 -0
  70. {stacknordic-0.1.0 → stacknordic-0.1.2}/LICENSE +0 -0
  71. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/architecture/principles.md +0 -0
  72. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/benchmarks/dataset.md +0 -0
  73. {stacknordic-0.1.0 → stacknordic-0.1.2}/docs/benchmarks/reconstruction.md +0 -0
  74. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/__main__.py +0 -0
  75. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/cli.py +0 -0
  76. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/__init__.py +0 -0
  77. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/dataset/thermodynamics.py +0 -0
  78. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/filtering.py +0 -0
  79. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/openfoam/__init__.py +0 -0
  80. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/postprocess.py +0 -0
  81. {stacknordic-0.1.0 → stacknordic-0.1.2}/src/stacknordic/selection.py +0 -0
  82. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/dataset/test_postprocess.py +0 -0
  83. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/openfoam/test_case.py +0 -0
  84. {stacknordic-0.1.0 → stacknordic-0.1.2}/tests/test_filtering.py +0 -0
  85. {stacknordic-0.1.0 → stacknordic-0.1.2}/tools/templates/README.md +0 -0
  86. {stacknordic-0.1.0 → stacknordic-0.1.2}/tools/templates/openfoamHeaderESI.in +0 -0
  87. {stacknordic-0.1.0 → stacknordic-0.1.2}/tools/templates/openfoamHeaderFoundation.in +0 -0
@@ -0,0 +1 @@
1
+ *.ipynb linguist-detectable=false
@@ -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.0
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
@@ -24,34 +24,31 @@ Classifier: Topic :: Scientific/Engineering
24
24
  Requires-Python: <3.13,>=3.11
25
25
  Requires-Dist: cantera<4,>=3.1
26
26
  Requires-Dist: h5py<4,>=3.12
27
+ Requires-Dist: hedgehogs>=0.0.1
27
28
  Requires-Dist: numpy<3,>=2
28
- Requires-Dist: onsaemiro>=1.0.5
29
29
  Requires-Dist: scipy<2,>=1.14
30
30
  Description-Content-Type: text/markdown
31
31
 
32
+ <picture>
33
+ <source media="(prefers-color-scheme: dark)" srcset="others/assets/banner_dark.svg">
34
+ <img src="others/assets/banner_light.svg" alt="StackNordic" width="960">
35
+ </picture>
36
+
32
37
  # StackNordic
33
38
 
34
39
  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.
35
40
 
36
- ## Installation
37
-
38
- Install the released package:
41
+ [Documentation](https://pentagontoy.github.io/FoamNordic/stacknordic/) · [Installation](https://pentagontoy.github.io/FoamNordic/stacknordic/installation/) · [API](https://pentagontoy.github.io/FoamNordic/stacknordic/api/)
39
42
 
40
- ```console
41
- uv pip install stacknordic
42
- ```
43
+ ## Installation
43
44
 
44
- Install the current repository version when working ahead of a release:
45
+ Use Python 3.11 or 3.12.
45
46
 
46
47
  ```console
47
- uv pip install "git+https://github.com/PentagonToy/StackNordic.git"
48
+ pip install stacknordic
48
49
  ```
49
50
 
50
- Install a local checkout for development:
51
-
52
- ```console
53
- uv pip install --editable .
54
- ```
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.
55
52
 
56
53
  ## Reconstruct a case
57
54
 
@@ -61,37 +58,17 @@ Activate the Python environment and the OpenFOAM runtime, enter a decomposed cas
61
58
  stacknordic reconstruct --n-jobs -1 --progress
62
59
  ```
63
60
 
64
- The OpenFOAM-style alias is equivalent:
65
-
66
- ```console
67
- stacknordic -reconstructPar --n-jobs -1 --progress
68
- ```
69
-
70
- Select times, fields and another destination explicitly when required:
71
-
72
- ```console
73
- stacknordic reconstruct \
74
- --case-dir cases/TaylorGreenVortex3D \
75
- --output-dir output/TaylorGreenVortex3D \
76
- --time-range 0 0.1 \
77
- --fields U p nut \
78
- --n-jobs 8 \
79
- --progress
80
- ```
81
-
82
- 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/reconstruction.md).
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.
83
62
 
84
63
  ## Core workflows
85
64
 
86
65
  - [Export reconstructed or decomposed fields directly](docs/api/dataset.md), including time-local decomposition and mesh addressing.
87
- - [Compute progress variables and reaction rates](docs/api/computing.md) from declared Cantera contracts.
88
- - [Package and compile Cartesian datasets](docs/api/packaging.md) as self-describing HDF5 snapshots or time series.
66
+ - [Compute progress variables and reaction rates](docs/api/fields.md#field-computing) from declared Cantera contracts.
67
+ - [Package and compile Cartesian datasets](docs/api/dataset.md#snapshot-packaging) as self-describing HDF5 snapshots or time series.
89
68
  - [Filter and downsample DNS data](docs/api/filtering.md) with declared Reynolds, Favre, variance and SGS reductions.
90
- - [Run a closed set of post-processing operations](docs/api/postprocess.md) on OpenFOAM cases or exported Cartesian datasets.
91
-
92
- 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.
69
+ - [Run a closed set of post-processing operations](docs/api/fields.md#post-processing) on OpenFOAM cases or exported Cartesian datasets.
93
70
 
94
- See the [documentation index](docs/README.md) for the complete API, architecture and validation records.
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).
95
72
 
96
73
  ## Development
97
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) |
@@ -0,0 +1,28 @@
1
+ # Python API reference
2
+
3
+ StackNordic inspects stored OpenFOAM cases, reconstructs selected times and prepares datasets. Examples use `import stacknordic as sno`. OpenFOAM retains mesh, field and boundary semantics.
4
+
5
+ ## Public namespace
6
+
7
+ | Group | Main API | Use it for |
8
+ | --- | --- | --- |
9
+ | Stored cases | `OpenFOAM.case`, `case.reconstruct`, `case.export` | Inspect, reconstruct and export existing results |
10
+ | Dataset storage | `Dataset.package`, `Dataset.compile` | Package Cartesian snapshots and compile time series |
11
+ | Derived fields | `Computing`, `Dataset.compute`, `case.compute` | Declare and evaluate progress variables and reaction rates |
12
+ | Field operations | `Postprocess`, `case.postprocess`, `dataset.postprocess` | Apply supported spatial and temporal operations |
13
+ | Reduction | `Filtering`, `dataset.downsample`, `Dataset.downsample` | Declare physical reductions and produce coarser datasets |
14
+
15
+ ## Reference map
16
+
17
+ | Task | Reference |
18
+ | --- | --- |
19
+ | Inspect cases, configure a runtime or reconstruct times | [OpenFOAM cases and reconstruction](openfoam.md) |
20
+ | Export arrays, package snapshots or compile HDF5 | [Dataset export and storage](dataset.md) |
21
+ | Compute progress variables, reaction rates or field operations | [Field computation and post-processing](fields.md) |
22
+ | Filter and downsample with declared physical rules | [Filtering and downsampling](filtering.md) |
23
+
24
+ ## Reference conventions
25
+
26
+ Signatures mark keyword-only arguments with `*`. Paths accept strings or `Path` objects. `times=None` selects all complete times, a tuple selects an inclusive range and a list selects exact values. Worker limits and overwrite behaviour are documented per operation.
27
+
28
+ Export, storage and reduction operations return result summaries. A reconstruction also returns its source identity, selected times and execution details. Data-changing operations require explicit fields or declarations; names alone do not choose physical reduction rules. See [Stored-data layout](../architecture/data-layout.md) for geometry constraints and [Dataset workflow](../architecture/workflow.md) for provenance and publication.
@@ -0,0 +1,180 @@
1
+ # Dataset export and storage
2
+
3
+ Export case fields into arrays, package snapshots and compile HDF5 time series.
4
+
5
+ - [Dataset export](#dataset-export)
6
+ - [Snapshot packaging](#snapshot-packaging)
7
+ - [Time-series compilation](#snodatasetcompile)
8
+
9
+ ## Dataset export
10
+
11
+ `case.export()` converts selected OpenFOAM volume fields into NumPy-compatible scalar arrays and an `info.json` manifest. Create the case with `sno.OpenFOAM.case()` so OpenFOAM-backed operations share one explicit runtime.
12
+
13
+ ```python
14
+ case.export(
15
+ *,
16
+ output_dir,
17
+ fields,
18
+ times=None,
19
+ dtype="float32",
20
+ mode="direct",
21
+ metadata=None,
22
+ n_jobs=None,
23
+ progress=False,
24
+ overwrite=False,
25
+ )
26
+ ```
27
+
28
+ | Parameter | Type | Default | Meaning |
29
+ | --- | --- | --- | --- |
30
+ | `output_dir` | `str \| Path` | Required | Dataset destination. A missing or empty directory is accepted. |
31
+ | `fields` | `Mapping[str, str \| Sequence[str]]` | Required | OpenFOAM field names mapped to exported scalar component names. |
32
+ | `times` | `list[float] \| tuple[float, float] \| None` | `None` | Exact times, an inclusive range, or every complete time. |
33
+ | `dtype` | `"float32" \| "float64"` | `"float32"` | Stored floating-point type. |
34
+ | `mode` | `"direct" \| "reconstruct"` | `"direct"` | Read existing reconstructed or decomposed data directly, or reconstruct selected results in an isolated workspace. |
35
+ | `metadata` | `Mapping[str, object] \| None` | `None` | JSON-compatible user metadata. |
36
+ | `n_jobs` | `int \| None` | `None` | Concurrent export workers. `-1` uses the time-field work count, allocated CPUs and available-memory limit. |
37
+ | `progress` | `bool` | `False` | Show completed time-field tasks with a Hedgehogs progress display. |
38
+ | `overwrite` | `bool` | `False` | Replace a non-empty existing dataset only after the new export completes. |
39
+
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
+
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.
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
+ When the first field of a reconstructed snapshot is uniform, StackNordic reads the mesh owner and neighbour lists to determine the cell count.
47
+
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
+
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
+
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
+
54
+ ```python
55
+ from pathlib import Path
56
+ import stacknordic as sno
57
+
58
+ case = sno.OpenFOAM.case(
59
+ case_dir=Path("cases/Premixed_H2"),
60
+ of_cmd="openfoam/2512",
61
+ shell="bash",
62
+ )
63
+
64
+ dataset = case.export(
65
+ output_dir=Path("dataset/rawdata/output/phi045"),
66
+ fields={
67
+ "U": ("UX_ms-1", "UY_ms-1", "UZ_ms-1"),
68
+ "p": "P_Pa",
69
+ "T": "T_K",
70
+ },
71
+ times=[0.00114, 0.00120],
72
+ dtype="float32",
73
+ mode="direct",
74
+ metadata=None,
75
+ n_jobs=-1,
76
+ progress=True,
77
+ overwrite=False,
78
+ )
79
+ ```
80
+
81
+ For a verified single-block Cartesian mesh, StackNordic records `Nxyz` and one-dimensional cell-centre coordinates. General, moving and topology-changing meshes remain cell-indexed; no fixed Cartesian geometry is invented. Export is staged beside `output_dir`, committed atomically and removed completely after failure.
82
+
83
+ ## Snapshot packaging
84
+
85
+ `sno.Dataset.package()` writes each Cartesian snapshot as one portable HDF5 file. Source arrays remain memory-mapped and are copied in bounded slabs.
86
+
87
+ ```python
88
+ sno.Dataset.package(
89
+ *,
90
+ dataset_dir,
91
+ output_dir,
92
+ name,
93
+ format="hdf5",
94
+ fields,
95
+ compression="lzf",
96
+ n_jobs=None,
97
+ progress=False,
98
+ overwrite=False,
99
+ )
100
+ ```
101
+
102
+ | Parameter | Type | Default | Meaning |
103
+ | --- | --- | --- | --- |
104
+ | `dataset_dir` | `str \| Path` | Required | Cartesian StackNordic dataset. |
105
+ | `output_dir` | `str \| Path` | Required | Destination for packaged snapshots. |
106
+ | `name` | `str` | Required | Filename stem; snapshot identifiers are appended automatically. |
107
+ | `format` | `str` | `"hdf5"` | Package format. Only `"hdf5"` is currently supported. |
108
+ | `fields` | `Mapping[str, str]` | Required | Logical source fields mapped to relative HDF5 paths. |
109
+ | `compression` | `None \| "lzf" \| "gzip"` | `"lzf"` | HDF5 dataset compression. |
110
+ | `n_jobs` | `int \| None` | `None` | Concurrent snapshots. `-1` is bounded by snapshots, CPUs and estimated memory. |
111
+ | `progress` | `bool` | `False` | Show a Hedgehogs progress display. |
112
+ | `overwrite` | `bool` | `False` | Replace an existing package only after the new package completes. |
113
+
114
+ Each `/`-separated output segment is stripped of surrounding whitespace. `"species_fields/H2O2"` and `"species_fields / H2O2"` therefore select the same dataset path. Empty segments, parent traversal and dataset/group collisions are rejected.
115
+
116
+ ```python
117
+ packaged = sno.Dataset.package(
118
+ dataset_dir=RAWDATA_DIR / "output",
119
+ output_dir=DNS_DIR / "output",
120
+ name="phi045",
121
+ format="hdf5",
122
+ fields={
123
+ "c": "c",
124
+ "T": "T_K",
125
+ "p": "P_Pa",
126
+ "rho": "RHO",
127
+ "U": "U",
128
+ "omega_c_mass": "omega_c_mass",
129
+ "omega_c_chem": "omega_c_chem",
130
+ "H2": "species_fields/H2",
131
+ "O2": "species_fields/O2",
132
+ "H2O": "species_fields/H2O",
133
+ },
134
+ compression="lzf",
135
+ n_jobs=-1,
136
+ progress=True,
137
+ overwrite=False,
138
+ )
139
+ ```
140
+
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
+
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
+
145
+ Packaging is staged beside `output_dir` and published atomically. Incomplete files are removed after failure or interruption.
146
+
147
+ ### `sno.Dataset.compile`
148
+
149
+ `sno.Dataset.compile()` combines compatible snapshot packages into one self-describing HDF5 time series. It validates the embedded contracts before writing and does not infer fields from arbitrary HDF5 layouts.
150
+
151
+ ```python
152
+ sno.Dataset.compile(
153
+ *,
154
+ dataset_dir,
155
+ output_file,
156
+ pattern,
157
+ progress=False,
158
+ overwrite=False,
159
+ )
160
+ ```
161
+
162
+ | Parameter | Type | Default | Meaning |
163
+ | --- | --- | --- | --- |
164
+ | `dataset_dir` | `str \| Path` | Required | Directory containing StackNordic snapshot packages. |
165
+ | `output_file` | `str \| Path` | Required | Compiled HDF5 destination. |
166
+ | `pattern` | `str` | Required | Glob selecting snapshot packages, for example `"*phi045_id*.h5"`. |
167
+ | `progress` | `bool` | `False` | Show a Hedgehogs progress display. |
168
+ | `overwrite` | `bool` | `False` | Replace an existing file only after the new series completes. |
169
+
170
+ ```python
171
+ compiled = sno.Dataset.compile(
172
+ dataset_dir=DNS_DIR / "output",
173
+ output_file=DNS_DIR / "phi045.h5",
174
+ pattern="*phi045_id*.h5",
175
+ progress=True,
176
+ overwrite=False,
177
+ )
178
+ ```
179
+
180
+ The compiled file stores the Cartesian grid once and places each snapshot under an `id_NNN` group. Snapshot identifiers and physical times remain available in the series metadata. Publication is atomic and incomplete temporary files are removed.
@@ -0,0 +1,257 @@
1
+ # Field computation and post-processing
2
+
3
+ Declare combustion fields and apply supported spatial or temporal operations to cases and Cartesian datasets.
4
+
5
+ - [Field computing](#field-computing)
6
+ - [Post-processing](#post-processing)
7
+
8
+ ## Field computing
9
+
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
+
12
+ ### `sno.Computing.progress`
13
+
14
+ ```python
15
+ sno.Computing.progress(
16
+ *,
17
+ mechanism,
18
+ equivalence_ratio,
19
+ fuel,
20
+ oxidizer,
21
+ species,
22
+ temperature,
23
+ pressure,
24
+ output="c",
25
+ )
26
+ ```
27
+
28
+ | Parameter | Type | Default | Meaning |
29
+ | --- | --- | --- | --- |
30
+ | `mechanism` | `str \| Path` | Required | Cantera mechanism. |
31
+ | `equivalence_ratio` | `float` | Required | Positive equivalence ratio used for the reference states. |
32
+ | `fuel` | `Mapping[str, float]` | Required | Fuel mole composition. |
33
+ | `oxidizer` | `Mapping[str, float]` | Required | Oxidiser mole composition. |
34
+ | `species` | `Mapping[str, float]` | Required | Species mass-fraction fields and their linear weights $\alpha_i$. |
35
+ | `temperature` | `float` | Required | Unburnt reference temperature in kelvin. |
36
+ | `pressure` | `float` | Required | Reference pressure in pascals. |
37
+ | `output` | `str` | `"c"` | Stored logical field name. |
38
+
39
+ The unnormalised progress variable and its normalised form are
40
+
41
+ $$
42
+ Y_c = \sum_i \alpha_i Y_i,
43
+ $$
44
+
45
+ $$
46
+ c = \frac{Y_c-Y_{c,u}}{Y_{c,b}-Y_{c,u}}.
47
+ $$
48
+
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
+
51
+ ```python
52
+ import stacknordic as sno
53
+
54
+ MECHANISM = "h2o2.yaml"
55
+
56
+ progress = sno.Computing.progress(
57
+ mechanism=MECHANISM,
58
+ equivalence_ratio=0.45,
59
+ fuel={"H2": 1.0},
60
+ oxidizer={"O2": 0.21, "N2": 0.79},
61
+ species={"H2": -1.0, "H2O": 1.0},
62
+ temperature=300.0,
63
+ pressure=101325.0,
64
+ output="c",
65
+ )
66
+ ```
67
+
68
+ ### `sno.Computing.reaction_rate`
69
+
70
+ ```python
71
+ sno.Computing.reaction_rate(
72
+ *,
73
+ mechanism,
74
+ species,
75
+ temperature,
76
+ target,
77
+ output,
78
+ pressure=None,
79
+ density=None,
80
+ units="kg/m^3/s",
81
+ )
82
+ ```
83
+
84
+ | Parameter | Type | Default | Meaning |
85
+ | --- | --- | --- | --- |
86
+ | `mechanism` | `str \| Path` | Required | Cantera mechanism. |
87
+ | `species` | `Mapping[str, str]` | Required | Cantera species names mapped to stored mass-fraction fields. The fields must describe a complete state summing to one. |
88
+ | `temperature` | `str` | Required | Stored temperature field in kelvin. |
89
+ | `target` | `str \| ProgressComputation` | Required | One Cantera species or a progress-variable definition. |
90
+ | `output` | `str` | Required | Stored reaction-rate field name. |
91
+ | `pressure` | `str \| None` | `None` | Stored pressure field in pascals. Exactly one of `pressure` and `density` is required. |
92
+ | `density` | `str \| None` | `None` | Stored density field in kilograms per cubic metre. Exactly one of `pressure` and `density` is required. |
93
+ | `units` | `str` | `"kg/m^3/s"` | Output basis: `"kg/m^3/s"` or `"1/s"`. |
94
+
95
+ For species $i$, Cantera supplies the molar production rate $\dot{\omega}_i$ and StackNordic computes
96
+
97
+ $$
98
+ \dot{\omega}_{i,m} = W_i\dot{\omega}_i \quad [\mathrm{kg\,m^{-3}\,s^{-1}}].
99
+ $$
100
+
101
+ For the normalised progress variable, the coefficients are inherited from `ProgressComputation`:
102
+
103
+ $$
104
+ \dot{\omega}_{c,m} = \sum_i \frac{\alpha_i}{Y_{c,b}-Y_{c,u}}\dot{\omega}_{i,m}.
105
+ $$
106
+
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.
108
+
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.
125
+
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`.
131
+
132
+ ```python
133
+ state = {name: name for name in ("H2", "H", "O2", "OH", "O", "H2O", "HO2", "H2O2", "N2")}
134
+
135
+ omega_h2 = sno.Computing.reaction_rate(
136
+ mechanism=MECHANISM,
137
+ species=state,
138
+ temperature="T",
139
+ density="rho",
140
+ target="H2",
141
+ output="omega_H2_mass",
142
+ units="kg/m^3/s",
143
+ )
144
+
145
+ omega_c = sno.Computing.reaction_rate(
146
+ mechanism=MECHANISM,
147
+ species=state,
148
+ temperature="T",
149
+ density="rho",
150
+ target=progress,
151
+ output="omega_c",
152
+ units="1/s",
153
+ )
154
+
155
+ computed = sno.Dataset.compute(
156
+ dataset_dir="datasets/h2",
157
+ computations=(progress, omega_h2, omega_c),
158
+ progress=True,
159
+ )
160
+ ```
161
+
162
+ ## Post-processing
163
+
164
+ `sno.Postprocess` declares the supported field operations. A declaration can be executed by `case.postprocess()` through OpenFOAM or by `dataset.postprocess()` on an exported Cartesian dataset.
165
+
166
+ ### Operations
167
+
168
+ | Factory | Default output | OpenFOAM case | Cartesian dataset | Definition |
169
+ | --- | --- | --- | --- | --- |
170
+ | `grad(field=..., output=None)` | `grad<field>` | yes | yes | Spatial gradient of a scalar or vector field. |
171
+ | `div(field=..., output=None)` | `div<field>` | yes | yes | Divergence of a vector field. |
172
+ | `ddt(field=..., output=None)` | `ddt<field>` | runtime-dependent | yes | OpenFOAM temporal derivative or finite difference between stored dataset snapshots. |
173
+ | `components(field=..., outputs=None)` | `<field>x`, `<field>y`, `<field>z` | yes | yes | Scalar components of a three-component vector. |
174
+ | `mag(field=..., output=None)` | `mag<field>` | yes | yes | Scalar absolute value or vector magnitude. |
175
+ | `mag_sqr(field=..., output=None)` | `magSqr<field>` | yes | yes | Squared scalar or vector magnitude. |
176
+ | `vorticity(field="U", output="vorticity")` | `vorticity` | yes | yes | Curl of a three-component velocity field. |
177
+ | `Q(field="U", output="Q")` | `Q` | yes | yes | Second invariant of the velocity-gradient tensor. |
178
+ | `Lambda2(field="U", output="Lambda2")` | `Lambda2` | yes | yes | Intermediate eigenvalue of $S^2 + \Omega^2$. |
179
+ | `write_cell_centres(output="C")` | `C` | yes | yes | Cell-centre coordinates. |
180
+ | `write_cell_volumes(output="V")` | `V` | yes | yes | Cell volumes. |
181
+
182
+ The OpenFOAM implementations of `vorticity`, `Q`, and `Lambda2` currently require the conventional velocity field `U`. Dataset-native implementations accept another three-component field explicitly. `components()` accepts custom output names and requires one name per component.
183
+
184
+ ### OpenFOAM case
185
+
186
+ ```python
187
+ case.postprocess(
188
+ *,
189
+ operations,
190
+ times=None,
191
+ n_jobs=None,
192
+ progress=False,
193
+ overwrite=False,
194
+ )
195
+ ```
196
+
197
+ | Parameter | Type | Default | Meaning |
198
+ | --- | --- | --- | --- |
199
+ | `operations` | `Sequence[PostprocessOperation]` | Required | Operations created by `sno.Postprocess`. |
200
+ | `times` | `list[float] \| tuple[float, float] \| None` | `None` | Exact physical times, an inclusive range, or every reconstructed time. |
201
+ | `n_jobs` | `int \| None` | `None` | Concurrent time/operation jobs. `-1` uses the available CPU and work limits. |
202
+ | `progress` | `bool` | `False` | Show a Hedgehogs progress display. |
203
+ | `overwrite` | `bool` | `False` | Replace existing generated fields. |
204
+
205
+ ```python
206
+ result = case.postprocess(
207
+ operations=(
208
+ sno.Postprocess.grad(field="U"),
209
+ sno.Postprocess.vorticity(),
210
+ sno.Postprocess.Q(),
211
+ ),
212
+ times=(0.0, 0.1),
213
+ n_jobs=4,
214
+ progress=True,
215
+ overwrite=False,
216
+ )
217
+ ```
218
+
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.
224
+
225
+ ### Cartesian dataset
226
+
227
+ ```python
228
+ dataset.postprocess(
229
+ *,
230
+ operations,
231
+ n_jobs=None,
232
+ progress=False,
233
+ overwrite=False,
234
+ )
235
+ ```
236
+
237
+ | Parameter | Type | Default | Meaning |
238
+ | --- | --- | --- | --- |
239
+ | `operations` | `Sequence[PostprocessOperation]` | Required | Operations created by `sno.Postprocess`. |
240
+ | `n_jobs` | `int \| None` | `None` | Concurrent snapshot/operation jobs. `-1` uses the available CPU and work limits. |
241
+ | `progress` | `bool` | `False` | Show a Hedgehogs progress display. |
242
+ | `overwrite` | `bool` | `False` | Replace existing logical fields without overwriting components owned by another field. |
243
+
244
+ ```python
245
+ result = dataset.postprocess(
246
+ operations=(
247
+ sno.Postprocess.grad(field="U"),
248
+ sno.Postprocess.mag(field="U"),
249
+ sno.Postprocess.write_cell_volumes(),
250
+ ),
251
+ n_jobs=-1,
252
+ progress=True,
253
+ overwrite=False,
254
+ )
255
+ ```
256
+
257
+ Dataset-native post-processing is intentionally limited to single-block Cartesian DNS or LES data with `Nxyz` and one-dimensional cell-centre coordinates. It rejects cell-indexed, moving, curvilinear, unstructured, and topology-changing datasets rather than inferring invalid geometry.