courant-dev 0.6.0__tar.gz → 0.7.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. {courant_dev-0.6.0/courant_dev.egg-info → courant_dev-0.7.0}/PKG-INFO +2 -2
  2. {courant_dev-0.6.0 → courant_dev-0.7.0}/README.md +1 -1
  3. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/__init__.py +1 -1
  4. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/_foam_reader.py +336 -106
  5. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/config.py +51 -4
  6. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/mesh.py +198 -39
  7. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/polymesh.py +33 -4
  8. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/reads.py +53 -0
  9. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/regime.py +132 -3
  10. courant_dev-0.7.0/courant/case/reynolds.py +1153 -0
  11. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/solvers.py +13 -0
  12. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/wordre.py +20 -6
  13. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/spec.py +9 -7
  14. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/tail.py +20 -7
  15. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/series.py +92 -13
  16. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/__init__.py +1 -1
  17. courant_dev-0.7.0/courant/data/certification.json +1 -0
  18. courant_dev-0.7.0/courant/data/demo/pitzDaily_fixed_budget.tar.gz +0 -0
  19. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/bundle.py +27 -5
  20. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/checkers.py +240 -22
  21. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/kb.py +8 -2
  22. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/redact.py +291 -6
  23. courant_dev-0.7.0/courant/events/time_markers.py +22 -0
  24. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/mcp/tools.py +2 -1
  25. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/as_run.py +31 -8
  26. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/check.py +22 -13
  27. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/deck.py +202 -57
  28. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/taxonomy.py +5 -5
  29. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/_fluid_reader.py +13 -16
  30. courant_dev-0.7.0/courant/verification/_heat_reader.py +784 -0
  31. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/checks.py +90 -13
  32. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/convergence.py +316 -54
  33. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/fields.py +19 -5
  34. courant_dev-0.7.0/courant/verify/checks.py +228 -0
  35. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/html.py +2 -2
  36. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/ingest.py +8 -3
  37. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/pipeline.py +182 -17
  38. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/policy.py +1 -10
  39. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/preflight.py +16 -4
  40. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/schema.py +33 -12
  41. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/sentences.py +99 -0
  42. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/support.py +64 -1
  43. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/watcher/exitcode.py +6 -4
  44. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/watcher/parser.py +39 -0
  45. {courant_dev-0.6.0 → courant_dev-0.7.0/courant_dev.egg-info}/PKG-INFO +2 -2
  46. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant_dev.egg-info/SOURCES.txt +3 -0
  47. courant_dev-0.6.0/courant/data/certification.json +0 -1
  48. courant_dev-0.6.0/courant/data/demo/pitzDaily_fixed_budget.tar.gz +0 -0
  49. courant_dev-0.6.0/courant/verify/checks.py +0 -131
  50. {courant_dev-0.6.0 → courant_dev-0.7.0}/LICENSE +0 -0
  51. {courant_dev-0.6.0 → courant_dev-0.7.0}/MANIFEST.in +0 -0
  52. {courant_dev-0.6.0 → courant_dev-0.7.0}/NOTICE +0 -0
  53. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/__init__.py +0 -0
  54. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/dictscan.py +0 -0
  55. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/motion.py +0 -0
  56. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/schemes.py +0 -0
  57. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/case/viscosity.py +0 -0
  58. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/__init__.py +0 -0
  59. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/__init__.py +0 -0
  60. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/audit.py +0 -0
  61. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/convergence.py +0 -0
  62. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/ctest.py +0 -0
  63. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/doctor.py +0 -0
  64. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/gate.py +0 -0
  65. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/live.py +0 -0
  66. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/mcp.py +0 -0
  67. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/preflight.py +0 -0
  68. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/tour.py +0 -0
  69. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/update.py +0 -0
  70. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/commands/verify.py +0 -0
  71. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/config.py +0 -0
  72. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/guard.py +0 -0
  73. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/cli/main.py +0 -0
  74. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/config.py +0 -0
  75. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/__init__.py +0 -0
  76. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/assess.py +0 -0
  77. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/exact.py +0 -0
  78. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/render.py +0 -0
  79. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/scale.py +0 -0
  80. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/sentences.py +0 -0
  81. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/steady.py +0 -0
  82. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/tables.py +0 -0
  83. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/converge/transient.py +0 -0
  84. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/__init__.py +0 -0
  85. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/build.py +0 -0
  86. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/data/judge-v0.labels.jsonl +0 -0
  87. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/data/judge-v0.tasks.jsonl.gz +0 -0
  88. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/judges/__init__.py +0 -0
  89. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/judges/constant.py +0 -0
  90. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/judges/courant.py +0 -0
  91. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/judges/llm.py +0 -0
  92. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/judges/llm_spec.py +0 -0
  93. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/run.py +0 -0
  94. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/schema.py +0 -0
  95. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/score.py +0 -0
  96. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/ctest/splits.py +0 -0
  97. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/certified_codes.json +0 -0
  98. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__cfl_blowup.case.json +0 -0
  99. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__cfl_blowup.log.gz +0 -0
  100. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__healthy.case.json +0 -0
  101. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__healthy.log.gz +0 -0
  102. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__transport_units.case.json +0 -0
  103. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/demo/icoFoam_cavity__transport_units.log.gz +0 -0
  104. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/audit.1.json +0 -0
  105. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/cache.1.json +0 -0
  106. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/convergence.1.json +0 -0
  107. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/error-rates.1.json +0 -0
  108. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/preflight.1.json +0 -0
  109. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/record.1.json +0 -0
  110. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/release-signature.1.json +0 -0
  111. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/spec.1.json +0 -0
  112. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/support.1.json +0 -0
  113. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/verdict.1.json +0 -0
  114. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/data/schemas/verdict.2.json +0 -0
  115. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/__init__.py +0 -0
  116. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/deterministic.py +0 -0
  117. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/findings.py +0 -0
  118. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/kb_data.py +0 -0
  119. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/llm.py +0 -0
  120. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/diagnosis/schema.py +0 -0
  121. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/events/__init__.py +0 -0
  122. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/events/core.py +0 -0
  123. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/events/diverged.py +0 -0
  124. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/forks.py +0 -0
  125. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/gate/__init__.py +0 -0
  126. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/gate/config.py +0 -0
  127. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/gate/run.py +0 -0
  128. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/live/__init__.py +0 -0
  129. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/live/engine.py +0 -0
  130. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/live/watch.py +0 -0
  131. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/__init__.py +0 -0
  132. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/allowlist.py +0 -0
  133. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/anthropic.py +0 -0
  134. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/budget.py +0 -0
  135. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/door.py +0 -0
  136. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/errors.py +0 -0
  137. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/openrouter.py +0 -0
  138. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/policy.py +0 -0
  139. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/prices.py +0 -0
  140. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/llm/transport.py +0 -0
  141. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/mcp/__init__.py +0 -0
  142. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/mcp/server.py +0 -0
  143. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/record/__init__.py +0 -0
  144. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/record/filter.py +0 -0
  145. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/record/record.py +0 -0
  146. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/release.py +0 -0
  147. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/signing.py +0 -0
  148. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/__init__.py +0 -0
  149. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/extract.py +0 -0
  150. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/impossible.py +0 -0
  151. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/spec/model.py +0 -0
  152. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/__init__.py +0 -0
  153. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/bounding.py +0 -0
  154. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/grade.py +0 -0
  155. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verification/suite.py +0 -0
  156. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/__init__.py +0 -0
  157. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/about.py +0 -0
  158. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/audit.py +0 -0
  159. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/batch.py +0 -0
  160. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/cache.py +0 -0
  161. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/junit.py +0 -0
  162. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/outcome.py +0 -0
  163. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/pack.py +0 -0
  164. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/render.py +0 -0
  165. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/verify/verdict2.py +0 -0
  166. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/watcher/__init__.py +0 -0
  167. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/watcher/anomaly.py +0 -0
  168. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant/watcher/watcher.py +0 -0
  169. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant_dev.egg-info/dependency_links.txt +0 -0
  170. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant_dev.egg-info/entry_points.txt +0 -0
  171. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant_dev.egg-info/requires.txt +0 -0
  172. {courant_dev-0.6.0 → courant_dev-0.7.0}/courant_dev.egg-info/top_level.txt +0 -0
  173. {courant_dev-0.6.0 → courant_dev-0.7.0}/pyproject.toml +0 -0
  174. {courant_dev-0.6.0 → courant_dev-0.7.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: courant-dev
3
- Version: 0.6.0
3
+ Version: 0.7.0
4
4
  Summary: Courant: physics acceptance testing for machine-produced simulation. A read-only, deterministic gate that accepts, rejects or abstains on an OpenFOAM run, with the reasons it read.
5
5
  Author: Shivanshu Dwivedi
6
6
  Maintainer-email: Courant <hello@courant.dev>
@@ -264,7 +264,7 @@ run, and fails the check unless every run is accepted. Its logic is `courant gat
264
264
  the same way on any CI system.
265
265
 
266
266
  ```yaml
267
- - uses: courantdev/courant/.github/actions/courant-gate@v0.6.0
267
+ - uses: courantdev/courant/.github/actions/courant-gate@v0.7.0
268
268
  with:
269
269
  paths: runs/*.log.gz
270
270
  spec: task/spec.json
@@ -212,7 +212,7 @@ run, and fails the check unless every run is accepted. Its logic is `courant gat
212
212
  the same way on any CI system.
213
213
 
214
214
  ```yaml
215
- - uses: courantdev/courant/.github/actions/courant-gate@v0.6.0
215
+ - uses: courantdev/courant/.github/actions/courant-gate@v0.7.0
216
216
  with:
217
217
  paths: runs/*.log.gz
218
218
  spec: task/spec.json
@@ -6,7 +6,7 @@ task specification it decides whether a run is valid; with one, whether it is th
6
6
  was asked. First integration: OpenFOAM.
7
7
  """
8
8
 
9
- __version__ = "0.6.0"
9
+ __version__ = "0.7.0"
10
10
 
11
11
  #: The public repository of the open-source gate (H-DISTRIBUTION, 11 Oct 2026): its source, its
12
12
  #: releases (the signed binaries, the wheel and the installer) and its GitHub Action.
@@ -9,10 +9,13 @@ from __future__ import annotations
9
9
 
10
10
  import os
11
11
  import re
12
+ import stat
12
13
 
13
14
  from courant.case import wordre
14
- from courant.case.config import CaseConfig, LinearSolverSpec, phase_pseudonym
15
- from courant.case.reads import may_read, reading
15
+ from courant.case.config import CaseConfig, LinearSolverSpec, phase_pseudonym, region_pseudonym
16
+ from courant.case.reads import kind as path_kind
17
+ from courant.case.reads import may_read, reading, reason, unknown
18
+ from courant.spec.deck import INCLUDE_DIRECTIVES
16
19
 
17
20
 
18
21
  def _scalar(v):
@@ -77,8 +80,8 @@ def _switch(v) -> bool | None:
77
80
  #: read (its own rule, `deck.repeated_under_input_mode`); `#includeFunc` and `#includeModel` add
78
81
  #: a function object or a model.
79
82
  _INERT = frozenset({"#inputMode", "#includeFunc", "#includeModel"})
80
- #: The include directives `deck.expand` follows inside the case.
81
- _FOLLOWED_INCLUDES = ("#include", "#includeIfPresent", "#sinclude")
83
+ #: The include directives `deck.expand` follows inside the case: the deck's one list.
84
+ _FOLLOWED_INCLUDES = INCLUDE_DIRECTIVES
82
85
 
83
86
 
84
87
  def _unexpanded(v) -> str | None:
@@ -130,19 +133,21 @@ def _shown(name: str, value) -> str:
130
133
 
131
134
 
132
135
  def _names(keys, name: str) -> bool:
133
- """Whether one of a dictionary's `keys` names `name` for certain: the name itself, or a
134
- quoted keyword, a regular expression the case wrote, that matches it in full. Matched with
135
- bounded work (`courant.case.wordre`): Python's `re` backtracks exponentially on `"(a+)+b"`
136
- against a long name, holding the interpreter's lock, so `courant verify <case>` and
137
- `courant preflight` hung on a `$name;` in a solver entry (final review, 21 Oct 2026). A
138
- keyword the matcher does not evaluate is not taken to name it, so the `$name;` is noted as
139
- not read."""
140
- def pattern(key):
141
- quoted = isinstance(key, str) and len(key) > 1 and key[0] == key[-1] == '"'
142
- return key[1:-1] if quoted else None
143
-
144
- hit, _ = wordre.first_match([str(k) for k in keys], name, pattern=pattern)
145
- return hit is not None
136
+ """Whether one of a dictionary's `keys` names `name` for certain: the lookup v2406 makes,
137
+ `dictionary::csearch` (`wordre.csearch`, the one `deck.block` and the relaxation make; a
138
+ third, `first_match` in declaration order, was here: T-FOLLOWUP-MINORS (5)). A quoted
139
+ keyword is a regular expression the case wrote, matched with bounded work: Python's `re`
140
+ backtracks exponentially on `"(a+)+b"` against a long name, holding the interpreter's lock,
141
+ so `courant verify <case>` and `courant preflight` hung on a `$name;` in a solver entry
142
+ (final review, 21 Oct 2026). A keyword the matcher does not evaluate is not taken to name
143
+ it, so with none certain the `$name;` is noted as not read."""
144
+ def key(k) -> tuple[str, bool]:
145
+ text = str(k)
146
+ quoted = len(text) > 1 and text[0] == text[-1] == '"'
147
+ return (text[1:-1], True) if quoted else (text, False)
148
+
149
+ hits, _ = wordre.csearch([key(k) for k in keys], name)
150
+ return bool(hits)
146
151
 
147
152
 
148
153
  class _Dictionary:
@@ -181,7 +186,10 @@ class _Dictionary:
181
186
 
182
187
  from courant.spec import deck
183
188
 
184
- self._text, _ = deck._read_text(Path(self.case_dir), self.rel)
189
+ try:
190
+ self._text, _ = deck._read_text(Path(self.case_dir), self.rel)
191
+ except OSError: # a directory on the way cannot be searched (`Path.is_file`
192
+ self._text = None # raises): not read, as `_readable` already recorded
185
193
  return self._text
186
194
 
187
195
  def as_written(self) -> str | None:
@@ -406,6 +414,65 @@ def _get_quiet(src, *keys):
406
414
  #: regionProperties/regionProperties.C reads `constant/regionProperties`), and each region reads
407
415
  #: its own `system/<region>/fvSchemes`.
408
416
  REGION_PROPERTIES = os.path.join("constant", "regionProperties")
417
+ #: A region's name as this reader accepts it: a word that names a directory under `constant/`,
418
+ #: never `.` or `..` or a path.
419
+ _REGION_NAME = re.compile(r"[A-Za-z0-9_][A-Za-z0-9_.+-]{0,127}")
420
+ #: One group of `regions`: its kind (`fluid`, `solid`, ...) and the list of its region names.
421
+ _REGION_GROUP = re.compile(r"\s*(\w{1,64})\s*\(([^()]*)\)\s*")
422
+
423
+
424
+ def multi_region(case_dir: str | os.PathLike[str], solver: str | None) -> bool:
425
+ """Whether a case is read as regions: the solver that ran is one that reads its case as
426
+ regions (`courant.case.solvers.is_multi_region`: chtMultiRegionFoam,
427
+ chtMultiRegionSimpleFoam, chtMultiRegionTwoPhaseEulerFoam, foamMultiRun) and the case holds
428
+ `constant/regionProperties`. The one predicate of which case is read as regions
429
+ (T-MULTI-REGION): the case reader and the heat reader ask it. A single-region solver beside
430
+ a stray `regionProperties` never read it, so its case is read as one region. `solver` is the
431
+ log's (`solvers.solver_exec`), else `controlDict`'s `application`. (`mesh.solver_mesh` names
432
+ no mesh beside any `regionProperties`, the conservative side, as the committed tests hold.)"""
433
+ from courant.case.solvers import is_multi_region
434
+
435
+ return is_multi_region(solver) and os.path.lexists(
436
+ os.path.join(os.fspath(case_dir), REGION_PROPERTIES))
437
+
438
+
439
+ def read_region_properties(case_dir: str) -> dict[str, tuple[str, ...]] | None:
440
+ """`constant/regionProperties` as v2406 reads it (regionProperties.C: the `regions` list of
441
+ kinds, each followed by its regions' names), as `{"fluid": ("air",), "solid": ("plate",)}`
442
+ in the file's order; None when the case has no such file (one region). Noted for the
443
+ manifest once read (VER-14), confined (MCP-3).
444
+
445
+ Raises `OSError` when it cannot be read, and `ValueError` when it is not read whole: a
446
+ directive or a macro in it, no `regions` entry, a list that is not kinds and lists of names,
447
+ a name that is not one directory's, or one region named twice. The caller says so (TRD
448
+ VER-22). The one reader of the file's contents; T-MULTI-REGION is to fill
449
+ `CaseConfig.regions` from it."""
450
+ from courant.spec import deck
451
+
452
+ path = os.path.join(case_dir, REGION_PROPERTIES)
453
+ if not os.path.lexists(path):
454
+ return None
455
+ with reading(path), open(path, encoding="utf-8", errors="replace") as fh:
456
+ text = deck.strip_comments(fh.read())
457
+ if "#" in text or "$" in text:
458
+ raise ValueError("a directive or a macro is written in it")
459
+ raw = deck.entry(text, "regions")
460
+ if raw is None or not (raw.startswith("(") and raw.endswith(")")):
461
+ raise ValueError("no `regions` list")
462
+ body, at, out = raw[1:-1], 0, {}
463
+ seen: set[str] = set()
464
+ while at < len(body.rstrip()):
465
+ m = _REGION_GROUP.match(body, at)
466
+ if m is None:
467
+ raise ValueError("`regions` is not a list of kinds and lists of names")
468
+ names = tuple(m.group(2).split())
469
+ if not all(_REGION_NAME.fullmatch(n) for n in names) or seen & set(names) \
470
+ or len(set(names)) != len(names):
471
+ raise ValueError("a region's name is not a directory's, or is written twice")
472
+ seen.update(names)
473
+ out[m.group(1)] = out.get(m.group(1), ()) + names
474
+ at = m.end()
475
+ return out
409
476
 
410
477
 
411
478
  def _ddt_read_whole(fs: _Dictionary, case_dir: str) -> bool:
@@ -483,7 +550,8 @@ def _ddt_read_whole(fs: _Dictionary, case_dir: str) -> bool:
483
550
  REQUIRED = ("system/controlDict", "system/fvSchemes", "system/fvSolution")
484
551
 
485
552
 
486
- def _readable(f, path: str, rel: str, unreadable: dict[str, str], missing: list[str]) -> bool:
553
+ def _readable(f, path: str, rel: str, unreadable: dict[str, str], missing: list[str], *,
554
+ required: bool | None = None) -> bool:
487
555
  """Whether this file parses at all, recording the reason if not: absent (`missing`, for a
488
556
  dictionary in `REQUIRED`) or unreadable, two facts.
489
557
 
@@ -510,7 +578,7 @@ def _readable(f, path: str, rel: str, unreadable: dict[str, str], missing: list[
510
578
  try:
511
579
  _parse(f, path)
512
580
  except (FileNotFoundError, NotADirectoryError):
513
- if rel in REQUIRED:
581
+ if (rel in REQUIRED) if required is None else required:
514
582
  missing.append(rel)
515
583
  return False
516
584
  except OSError as exc:
@@ -575,9 +643,88 @@ def _residual_control(fv) -> dict[str, dict[str, float]]:
575
643
  return out
576
644
 
577
645
 
646
+ def _fv_solution(fv) -> dict:
647
+ """What `system/fvSolution` (or a region's) sets that the checks read: relaxation,
648
+ the SIMPLE and PIMPLE correctors, `residualControl` and the linear solvers, each key set
649
+ only when the file writes it. One reading, for the top level and for each region
650
+ (T-MULTI-REGION)."""
651
+ data: dict = {}
652
+ relax: dict[str, float] = {}
653
+ scopes: dict[str, str] = {}
654
+ # What `solution::read` relaxes equations from (`CaseConfig.relaxation_equations`):
655
+ # `equations`, or with neither sub-dictionary the flat entries. Read from the same values
656
+ # as the flattened map, so nothing more is read and nothing more is noted.
657
+ equations: dict[str, float | None] = {}
658
+ rf = fv.scope("relaxationFactors")
659
+ if rf is not None:
660
+ # flatten nested fields/equations, or a flat mapping
661
+ try:
662
+ items = list(rf.items())
663
+ except Exception: # noqa: BLE001
664
+ items = []
665
+ nested = any(k in ("fields", "equations") and hasattr(v, "items") for k, v in items)
666
+ for k, v in items:
667
+ if k in ("fields", "equations"):
668
+ try:
669
+ for kk, _vv in fv.scope("relaxationFactors", k).items():
670
+ s = _scalar(_get(fv, "relaxationFactors", k, kk))
671
+ if k == "equations":
672
+ equations[str(kk)] = s
673
+ if s is not None:
674
+ relax[kk] = s
675
+ scopes[kk] = k
676
+ except Exception: # noqa: BLE001
677
+ pass
678
+ else:
679
+ s = _scalar(_get(fv, "relaxationFactors", k))
680
+ if not nested:
681
+ equations[str(k)] = s
682
+ if s is not None:
683
+ relax[k] = s
684
+ scopes[k] = ""
685
+ if relax:
686
+ data["relaxation_factors"] = relax
687
+ data["relaxation_scopes"] = scopes
688
+ data["relaxation_equations"] = equations
689
+ for loop in ("SIMPLE", "PIMPLE"):
690
+ nno = _scalar(_get(fv, loop, "nNonOrthogonalCorrectors"))
691
+ if nno is not None:
692
+ data["n_non_orthogonal_correctors"] = int(nno)
693
+ ncorr = _scalar(_get(fv, loop, "nCorrectors"))
694
+ if ncorr is not None:
695
+ data["n_correctors"] = int(ncorr)
696
+ nouter = _scalar(_get(fv, "PIMPLE", "nOuterCorrectors"))
697
+ if nouter is not None:
698
+ data["n_outer_correctors"] = int(nouter)
699
+ control = _residual_control(fv)
700
+ if control:
701
+ data["residual_control"] = control
702
+ solvers: dict[str, LinearSolverSpec] = {}
703
+ for field, spec in _subdict_items(fv, "solvers"):
704
+ if not hasattr(spec, "get"):
705
+ continue
706
+ try:
707
+ solvers[field] = LinearSolverSpec(
708
+ field=field, solver=_tokens(_get(fv, "solvers", field, "solver")),
709
+ tolerance=_scalar(_get(fv, "solvers", field, "tolerance")),
710
+ rel_tol=_scalar(_get(fv, "solvers", field, "relTol")),
711
+ log=_solver_log(_get(fv, "solvers", field, "log")))
712
+ except Exception: # noqa: BLE001
713
+ pass
714
+ if solvers:
715
+ data["linear_solvers"] = solvers
716
+ return data
717
+
718
+
719
+ #: How `CaseConfig.unreadable` names the start-time directory when it cannot be listed or
720
+ #: searched (T-ZERO-UNLISTABLE): a directory, so with its slash, beside the files it names.
721
+ ZERO_DIR = "0/"
722
+
723
+
578
724
  @wordre.bounded # the case's keyword patterns (SPEC-2)
579
725
  def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool = False,
580
- steady_ddt: bool = False) -> CaseConfig:
726
+ steady_ddt: bool = False, zero_unlisted: bool = False,
727
+ regions: bool = False, solver: str | None = None) -> CaseConfig:
581
728
  """The case's settings as the checks need them. A value its dictionary writes through a
582
729
  directive the reader did not follow is reported in `unread_values` (TRD VER-3b); with
583
730
  `directives` (`--checks next`) the dictionary is read as the solver reads it, its includes
@@ -585,7 +732,26 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
585
732
  `steady_ddt` (`--checks next`, `cfl.steady`, TRD VER-13a): `ddtSchemes`' other entries are
586
733
  read beside its `default` (`CaseConfig.ddt_terms`), and whether foamlib read it as the
587
734
  solver does (`CaseConfig.ddt_read_whole`); without it neither is read, so the default reads
588
- of `fvSchemes` what v0.5.0 read."""
735
+ of `fvSchemes` what v0.5.0 read. `zero_unlisted` (`--checks next`, `case.zero_unlisted`, TRD
736
+ VER-3): a `0/` that cannot be listed or searched is recorded in `unreadable` as `0/` and the
737
+ rest of the configuration is kept; without it, a `0/` that cannot be listed raises, as in
738
+ v0.6.0, and the caller has no configuration.
739
+
740
+ `regions` (`--checks next`, `case.regions`, T-MULTI-REGION, TRD VER-3d): a multi-region case
741
+ (`multi_region`, the one predicate: the solver that ran, `solver` from the log or else
742
+ `controlDict`'s `application`, reads regions, and `constant/regionProperties` exists) is read
743
+ as that solver reads it. `CaseConfig.regions` is the file's regions (`read_region_properties`,
744
+ the one reader). The top level's `fvSchemes`, turbulence, transport and thermophysical
745
+ dictionaries and `0/` are not read (the solver builds no default region, so a copy there is
746
+ not what ran); of its `fvSolution` only what the solver reads there for the whole run that a
747
+ check reads, `PIMPLE/nOuterCorrectors` (readPIMPLEControls.H, v2406). Each region's
748
+ `system/<region>/fvSchemes` (divergence schemes) and `fvSolution` (`_fv_solution`) and the
749
+ boundary conditions of `0/<region>/` are read, keyed `<name>@<region>` by the region's place
750
+ (`config.region_pseudonym`). A region's `fvSchemes`, `fvSolution` or `0/<region>/` the case
751
+ does not hold is `missing`; a `0/<region>/` that cannot be listed or searched is
752
+ `unreadable` under `zero_unlisted`. A `regionProperties` that cannot be read whole, or names
753
+ no region, is `unreadable`, and the case is read as one region. Without `regions` the case is
754
+ read as v0.6.0 read it, `regionProperties` unopened."""
589
755
  from foamlib import FoamFile
590
756
 
591
757
  data: dict = {}
@@ -593,14 +759,16 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
593
759
  missing: list[str] = []
594
760
  opened: list[_Dictionary] = []
595
761
  ddt_read_whole = False # TRD VER-13a, `_ddt_read_whole`
762
+ region_names: list[str] = []
763
+ multi = False
596
764
 
597
- def open_file(rel):
765
+ def open_file(rel, *, required: bool | None = None):
598
766
  p = os.path.join(case_dir, rel)
599
767
  if not may_read(p): # MCP-3: asked before it is looked for
600
768
  return None
601
769
  f = FoamFile(p) # lazy: `_readable` reads it, and notes it (VER-14)
602
770
  failed: dict[str, str] = {}
603
- parsed = _readable(f, p, rel, failed, missing)
771
+ parsed = _readable(f, p, rel, failed, missing, required=required)
604
772
  d = _Dictionary(f if parsed else None, p, rel, case_dir, directives)
605
773
  if not parsed and not (directives and d.expand()): # `${name}` stops foamlib
606
774
  unreadable.update(failed)
@@ -621,8 +789,26 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
621
789
  data["write_control"] = str(wc) if wc is not None else None
622
790
  data["write_interval"] = _scalar(_get(cd, "writeInterval"))
623
791
 
624
- # --- fvSchemes ---
625
- fs = open_file("system/fvSchemes")
792
+ # --- the regions (T-MULTI-REGION, `regions`, under --checks next): only for a solver that
793
+ # reads them (`multi_region`), and only when the file names one; a file that cannot be read
794
+ # whole, or names none, is said, and the case is read as one region, nothing skipped ---
795
+ if regions and multi_region(case_dir, solver or data.get("solver")):
796
+ rel = REGION_PROPERTIES.replace(os.sep, "/")
797
+ try:
798
+ kinds = read_region_properties(case_dir)
799
+ region_names = [r for listed in (kinds or {}).values() for r in listed]
800
+ if not region_names:
801
+ unreadable[rel] = "ValueError: it names no region"
802
+ except OSError as exc:
803
+ unreadable[rel] = reason(exc)
804
+ except ValueError as exc:
805
+ unreadable[rel] = f"ValueError: {exc}"
806
+ multi = bool(region_names)
807
+ if multi:
808
+ data["regions"] = region_names
809
+
810
+ # --- fvSchemes --- (a multi-region case's are its regions', `_read_region`)
811
+ fs = open_file("system/fvSchemes") if not multi else None
626
812
  if fs is not None:
627
813
  ddt = _get(fs, "ddtSchemes", "default")
628
814
  data["ddt_scheme"] = _tokens(ddt)
@@ -645,74 +831,27 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
645
831
 
646
832
  # --- fvSolution ---
647
833
  fv = open_file("system/fvSolution")
648
- if fv is not None:
649
- relax: dict[str, float] = {}
650
- scopes: dict[str, str] = {}
651
- # What `solution::read` relaxes equations from (`CaseConfig.relaxation_equations`):
652
- # `equations`, or with neither sub-dictionary the flat entries. Read from the same values
653
- # as the flattened map, so nothing more is read and nothing more is noted.
654
- equations: dict[str, float | None] = {}
655
- rf = fv.scope("relaxationFactors")
656
- if rf is not None:
657
- # flatten nested fields/equations, or a flat mapping
658
- try:
659
- items = list(rf.items())
660
- except Exception: # noqa: BLE001
661
- items = []
662
- nested = any(k in ("fields", "equations") and hasattr(v, "items") for k, v in items)
663
- for k, v in items:
664
- if k in ("fields", "equations"):
665
- try:
666
- for kk, _vv in fv.scope("relaxationFactors", k).items():
667
- s = _scalar(_get(fv, "relaxationFactors", k, kk))
668
- if k == "equations":
669
- equations[str(kk)] = s
670
- if s is not None:
671
- relax[kk] = s
672
- scopes[kk] = k
673
- except Exception: # noqa: BLE001
674
- pass
675
- else:
676
- s = _scalar(_get(fv, "relaxationFactors", k))
677
- if not nested:
678
- equations[str(k)] = s
679
- if s is not None:
680
- relax[k] = s
681
- scopes[k] = ""
682
- if relax:
683
- data["relaxation_factors"] = relax
684
- data["relaxation_scopes"] = scopes
685
- data["relaxation_equations"] = equations
686
- for loop in ("SIMPLE", "PIMPLE"):
687
- nno = _scalar(_get(fv, loop, "nNonOrthogonalCorrectors"))
688
- if nno is not None:
689
- data["n_non_orthogonal_correctors"] = int(nno)
690
- ncorr = _scalar(_get(fv, loop, "nCorrectors"))
691
- if ncorr is not None:
692
- data["n_correctors"] = int(ncorr)
834
+ if fv is not None and not multi:
835
+ data.update(_fv_solution(fv))
836
+ elif fv is not None:
837
+ # A multi-region solver reads the top level's fvSolution for what is the whole run's
838
+ # (v2406, read in the pinned image): chtMultiRegionFoam's and
839
+ # chtMultiRegionTwoPhaseEulerFoam's outer loop (readPIMPLEControls.H: `fvSolution
840
+ # solutionDict(runTime)`, `PIMPLE/nOuterCorrectors`, default 1), the coupled energy field
841
+ # and the energy-coupling loops (createCoupledRegions.H, loopControl). Of these the checks
842
+ # read the outer correctors (VER-13: the Courant limit), so that alone is read here.
693
843
  nouter = _scalar(_get(fv, "PIMPLE", "nOuterCorrectors"))
694
844
  if nouter is not None:
695
845
  data["n_outer_correctors"] = int(nouter)
696
- control = _residual_control(fv)
697
- if control:
698
- data["residual_control"] = control
699
- solvers: dict[str, LinearSolverSpec] = {}
700
- for field, spec in _subdict_items(fv, "solvers"):
701
- if not hasattr(spec, "get"):
702
- continue
703
- try:
704
- solvers[field] = LinearSolverSpec(
705
- field=field, solver=_tokens(_get(fv, "solvers", field, "solver")),
706
- tolerance=_scalar(_get(fv, "solvers", field, "tolerance")),
707
- rel_tol=_scalar(_get(fv, "solvers", field, "relTol")),
708
- log=_solver_log(_get(fv, "solvers", field, "log")))
709
- except Exception: # noqa: BLE001
710
- pass
711
- if solvers:
712
- data["linear_solvers"] = solvers
713
846
 
714
- # --- turbulence ---
715
- for rel in ("constant/momentumTransport", "constant/turbulenceProperties"):
847
+ # --- each region's own (T-MULTI-REGION, `regions`, under --checks next) ---
848
+ for region in region_names:
849
+ _read_region(data, region, region_pseudonym(region_names, region), open_file,
850
+ case_dir, unreadable=unreadable, missing=missing,
851
+ zero_unlisted=zero_unlisted)
852
+
853
+ # --- turbulence --- (none at the top level of a multi-region case)
854
+ for rel in (() if multi else ("constant/momentumTransport", "constant/turbulenceProperties")):
716
855
  tf = open_file(rel)
717
856
  if tf is not None:
718
857
  sim = _get(tf, "simulationType")
@@ -739,8 +878,8 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
739
878
  data["turbulence_switch"] = switch
740
879
  break
741
880
 
742
- # --- transport ---
743
- tp = open_file("constant/transportProperties")
881
+ # --- transport --- (none at the top level of a multi-region case)
882
+ tp = open_file("constant/transportProperties") if not multi else None
744
883
  if tp is not None:
745
884
  transport = {}
746
885
  for name in ("nu", "rho", "Pr", "Prt", "beta", "TRef"):
@@ -771,20 +910,27 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
771
910
  # --- boundary conditions (0/ field files) ---
772
911
  boundary: dict[str, dict[str, str]] = {}
773
912
  zero = os.path.join(case_dir, "0")
774
- if os.path.isdir(zero) and may_read(zero): # MCP-3: listed, so confined like a read
775
- for fname in os.listdir(zero):
913
+ # A multi-region case's `0/` holds its regions' directories (`_read_region`); fields left at
914
+ # its top level are not what the solver read.
915
+ if not multi and os.path.isdir(zero) and may_read(zero): # MCP-3: listed, so confined
916
+ try:
917
+ names = os.listdir(zero)
918
+ except OSError as exc:
919
+ # 0.6.0 (the default, GATE-13): the exception ends the reading, and the whole
920
+ # configuration is lost. `zero_unlisted` (`case.zero_unlisted`, --checks next):
921
+ # `0/` is a directory the reader could not read, said as one, and the rest stands.
922
+ if not zero_unlisted:
923
+ raise
924
+ unreadable[ZERO_DIR] = reason(exc)
925
+ names = []
926
+ for fname in names:
776
927
  fpath = os.path.join(zero, fname)
777
928
  if not os.path.isfile(fpath):
929
+ # Listed, not searchable (mode 644): no file in it can be opened.
930
+ if zero_unlisted and (why := unknown(fpath)) is not None:
931
+ unreadable.setdefault(ZERO_DIR, reason(why))
778
932
  continue
779
- try:
780
- ff = FoamFile(fpath)
781
- _parse(ff, fpath) # VER-14: noted once read, parsed or not
782
- for patch, spec in _subdict_items(ff, "boundaryField"):
783
- t = _tokens(spec.get("type")) if hasattr(spec, "get") else None
784
- if t:
785
- boundary.setdefault(patch, {})[fname] = t
786
- except Exception: # noqa: BLE001
787
- continue
933
+ _boundary_types(fpath, fname, boundary)
788
934
  if boundary:
789
935
  data["boundary"] = boundary
790
936
 
@@ -809,7 +955,7 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
809
955
  # density of the case's equation of state since TRD PRE-6, behind
810
956
  # `--checks next` until 0.6.0 (`courant.case.viscosity`); `rho` is read for
811
957
  # `rhoConst` for that.
812
- thermo = open_file("constant/thermophysicalProperties")
958
+ thermo = open_file("constant/thermophysicalProperties") if not multi else None
813
959
  if thermo is not None:
814
960
  properties: dict[str, float] = dict(data.get("transport") or {})
815
961
  for group, keys in (("transport", ("mu", "Pr")),
@@ -838,10 +984,10 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
838
984
  if g is not None:
839
985
  data["gravity"] = g
840
986
  # `0/` files as the boundary loop above reads them: one that cannot be read is absent.
841
- tf = _field_file(case_dir, "0/T")
987
+ tf = _field_file(case_dir, "0/T") if not multi else None
842
988
  if tf is not None:
843
989
  data.update(_held_walls(case_dir, _fixed_values(tf), data.get("gravity")))
844
- pf = _field_file(case_dir, "0/p")
990
+ pf = _field_file(case_dir, "0/p") if not multi else None
845
991
  if pf is not None:
846
992
  p = _uniform(_get(pf, "internalField"))
847
993
  if p is not None:
@@ -870,6 +1016,90 @@ def read_case_config(case_dir: str, *, buoyancy: bool = True, directives: bool =
870
1016
  return config.model_copy(update={"ddt_read_whole": True}) if ddt_read_whole else config
871
1017
 
872
1018
 
1019
+ def _boundary_types(fpath: str, fname: str, boundary: dict[str, dict[str, str]]) -> None:
1020
+ """Each patch's boundary condition type in one field file into `boundary` (patch -> field ->
1021
+ type): the one reading of a `0/` field file's types, for the top level and for a region. A
1022
+ file that cannot be read or parsed adds nothing (noted once read, VER-14)."""
1023
+ from foamlib import FoamFile
1024
+
1025
+ try:
1026
+ ff = FoamFile(fpath)
1027
+ _parse(ff, fpath) # VER-14: noted once read, parsed or not
1028
+ for patch, spec in _subdict_items(ff, "boundaryField"):
1029
+ t = _tokens(spec.get("type")) if hasattr(spec, "get") else None
1030
+ if t:
1031
+ boundary.setdefault(patch, {})[fname] = t
1032
+ except Exception: # noqa: BLE001
1033
+ return
1034
+
1035
+
1036
+ def _read_region(data: dict, region: str, tag: str, open_file, case_dir: str, *,
1037
+ unreadable: dict[str, str], missing: list[str],
1038
+ zero_unlisted: bool = False) -> None:
1039
+ """One region of a multi-region case into `data` (T-MULTI-REGION, `regions`): its
1040
+ `system/<region>/fvSchemes` divergence schemes and `system/<region>/fvSolution`
1041
+ (`_fv_solution`), each required (`missing` when absent), and the boundary condition types of
1042
+ the field files in `0/<region>/`. Every key gets `@<tag>`, the region's place
1043
+ (`config.region_pseudonym`), so a key names no region: `U@region1`, `inlet@region1`.
1044
+
1045
+ Only what the setup rules read is merged: the relaxation factors and their scopes, the
1046
+ linear solvers, the divergence schemes and the boundary types. A region's correctors and
1047
+ `residualControl` are not (one value of each per case is what the checks read), nor its
1048
+ `constant/<region>/` dictionaries (the thermophysical model, a fluid's turbulence)."""
1049
+ def keyed(entries: dict) -> dict:
1050
+ return {f"{k}@{tag}": v for k, v in entries.items()}
1051
+
1052
+ fs = open_file(f"system/{region}/fvSchemes", required=True)
1053
+ if fs is not None:
1054
+ div = {k: v for k, v in ((k, _tokens(v)) for k, v in _subdict_items(fs, "divSchemes"))
1055
+ if v}
1056
+ if div:
1057
+ data.setdefault("div_schemes", {}).update(keyed(div))
1058
+ fv = open_file(f"system/{region}/fvSolution", required=True)
1059
+ if fv is not None:
1060
+ part = _fv_solution(fv)
1061
+ for key in ("relaxation_factors", "relaxation_scopes", "relaxation_equations"):
1062
+ if key in part:
1063
+ data.setdefault(key, {}).update(keyed(part[key]))
1064
+ solvers = part.get("linear_solvers") or {}
1065
+ if solvers:
1066
+ data.setdefault("linear_solvers", {}).update(
1067
+ {f"{k}@{tag}": s.model_copy(update={"field": f"{k}@{tag}"})
1068
+ for k, s in solvers.items()})
1069
+ # `0/<region>/` (the review of T-MULTI-REGION, M1): one that is not there is `missing`; one
1070
+ # that cannot be searched or listed, or whose files cannot be reached, is `unreadable` under
1071
+ # `zero_unlisted` (`case.zero_unlisted`, T-ZERO-UNLISTABLE's rule), never passed over in
1072
+ # silence. Recorded by its path; a finding names the region by its place.
1073
+ zero = os.path.join(case_dir, "0", region)
1074
+ rel = f"0/{region}/"
1075
+ there = path_kind(zero)
1076
+ if there is None:
1077
+ if zero_unlisted:
1078
+ unreadable.setdefault(rel, reason(unknown(zero)))
1079
+ return
1080
+ if not there:
1081
+ missing.append(rel)
1082
+ return
1083
+ if not may_read(zero): # MCP-3: listed, so confined like a read
1084
+ return
1085
+ try:
1086
+ listed = sorted(os.listdir(zero))
1087
+ except OSError as exc:
1088
+ if zero_unlisted:
1089
+ unreadable.setdefault(rel, reason(exc))
1090
+ return
1091
+ found: dict[str, dict[str, str]] = {}
1092
+ for fname in listed:
1093
+ fpath = os.path.join(zero, fname)
1094
+ is_regular = path_kind(fpath, stat.S_ISREG)
1095
+ if is_regular is None and zero_unlisted: # listed, not searchable
1096
+ unreadable.setdefault(rel, reason(unknown(fpath)))
1097
+ if is_regular:
1098
+ _boundary_types(fpath, fname, found)
1099
+ if found:
1100
+ data.setdefault("boundary", {}).update(keyed(found))
1101
+
1102
+
873
1103
  def _field_file(case_dir: str, rel: str):
874
1104
  """A `0/` field file, parsed and noted (VER-14), or None when it is missing or unreadable."""
875
1105
  from foamlib import FoamFile