ymf 0.3.0__tar.gz → 0.3.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 (172) hide show
  1. {ymf-0.3.0/src/ymf.egg-info → ymf-0.3.2}/PKG-INFO +1 -1
  2. {ymf-0.3.0 → ymf-0.3.2}/docs/changes.md +40 -0
  3. {ymf-0.3.0 → ymf-0.3.2}/docs/problem-specification.md +90 -2
  4. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/boundaries.py +2 -2
  5. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/conditions.py +62 -5
  6. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/names.py +3 -3
  7. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/normalize.py +4 -2
  8. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/references.py +37 -0
  9. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/schema.py +15 -2
  10. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/stabilization.py +43 -7
  11. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/language.py +1 -1
  12. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/notation.py +32 -9
  13. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/printer.py +2 -2
  14. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/problem.py +3 -1
  15. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/split.py +68 -8
  16. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/vocabulary.py +1 -0
  17. {ymf-0.3.0 → ymf-0.3.2/src/ymf.egg-info}/PKG-INFO +1 -1
  18. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/SOURCES.txt +10 -0
  19. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/scm_file_list.json +10 -0
  20. ymf-0.3.2/src/ymf.egg-info/scm_version.json +8 -0
  21. ymf-0.3.2/tests/fixtures/proteus_dispatch_0_2/README.md +10 -0
  22. ymf-0.3.2/tests/fixtures/proteus_dispatch_0_2/dambreak.ymf +168 -0
  23. ymf-0.3.2/tests/fixtures/proteus_dispatch_0_2/two_phase_level_set.ymf +66 -0
  24. ymf-0.3.2/tests/fixtures/shallow_water/obstacle_inflow.ymf +38 -0
  25. ymf-0.3.2/tests/fixtures/shallow_water/santos_step.ymf +52 -0
  26. ymf-0.3.2/tests/fixtures/shallow_water/transcritical_bump.ymf +39 -0
  27. ymf-0.3.2/tests/test_atan.py +87 -0
  28. ymf-0.3.2/tests/test_boundary_parts.py +214 -0
  29. ymf-0.3.2/tests/test_boundary_trace.py +100 -0
  30. {ymf-0.3.0 → ymf-0.3.2}/tests/test_printer.py +1 -1
  31. {ymf-0.3.0 → ymf-0.3.2}/tests/test_stabilization.py +98 -0
  32. ymf-0.3.2/tests/test_stabilization_compat.py +81 -0
  33. ymf-0.3.0/src/ymf.egg-info/scm_version.json +0 -8
  34. {ymf-0.3.0 → ymf-0.3.2}/.gitignore +0 -0
  35. {ymf-0.3.0 → ymf-0.3.2}/LICENSE +0 -0
  36. {ymf-0.3.0 → ymf-0.3.2}/MANIFEST.in +0 -0
  37. {ymf-0.3.0 → ymf-0.3.2}/README.md +0 -0
  38. {ymf-0.3.0 → ymf-0.3.2}/RELEASING.md +0 -0
  39. {ymf-0.3.0 → ymf-0.3.2}/docs/README.md +0 -0
  40. {ymf-0.3.0 → ymf-0.3.2}/docs/archive-format.md +0 -0
  41. {ymf-0.3.0 → ymf-0.3.2}/docs/design/domains-beyond-box.md +0 -0
  42. {ymf-0.3.0 → ymf-0.3.2}/docs/design/time-outside-space.md +0 -0
  43. {ymf-0.3.0 → ymf-0.3.2}/docs/history/schema-v0.1.md +0 -0
  44. {ymf-0.3.0 → ymf-0.3.2}/docs/history/schema-v0.2-delta.md +0 -0
  45. {ymf-0.3.0 → ymf-0.3.2}/docs/history/session-2026-07-29.md +0 -0
  46. {ymf-0.3.0 → ymf-0.3.2}/docs/research/csdms-bmi.md +0 -0
  47. {ymf-0.3.0 → ymf-0.3.2}/docs/research/data-sources.md +0 -0
  48. {ymf-0.3.0 → ymf-0.3.2}/docs/research/units.md +0 -0
  49. {ymf-0.3.0 → ymf-0.3.2}/docs/xdmf-model.yaml +0 -0
  50. {ymf-0.3.0 → ymf-0.3.2}/examples/README.md +0 -0
  51. {ymf-0.3.0 → ymf-0.3.2}/examples/heat_equation.ymf +0 -0
  52. {ymf-0.3.0 → ymf-0.3.2}/examples/kovasznay_flow.ymf +0 -0
  53. {ymf-0.3.0 → ymf-0.3.2}/examples/navier_stokes/navier_stokes_model.ymf +0 -0
  54. {ymf-0.3.0 → ymf-0.3.2}/examples/navier_stokes/planar_couette.ymf +0 -0
  55. {ymf-0.3.0 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille.ymf +0 -0
  56. {ymf-0.3.0 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille_re100.ymf +0 -0
  57. {ymf-0.3.0 → ymf-0.3.2}/examples/navier_stokes/plane_poiseuille_refined.ymf +0 -0
  58. {ymf-0.3.0 → ymf-0.3.2}/examples/nonlinear_diffusion.ymf +0 -0
  59. {ymf-0.3.0 → ymf-0.3.2}/examples/notebooks/COMPARISON.md +0 -0
  60. {ymf-0.3.0 → ymf-0.3.2}/examples/notebooks/YMF-original.ipynb +0 -0
  61. {ymf-0.3.0 → ymf-0.3.2}/examples/notebooks/YMF-updated.ipynb +0 -0
  62. {ymf-0.3.0 → ymf-0.3.2}/examples/notebooks/build_updated_notebook.py +0 -0
  63. {ymf-0.3.0 → ymf-0.3.2}/examples/poisson.ymf +0 -0
  64. {ymf-0.3.0 → ymf-0.3.2}/examples/poisson_spaces.ymf +0 -0
  65. {ymf-0.3.0 → ymf-0.3.2}/examples/poisson_v02_enriched.ymf +0 -0
  66. {ymf-0.3.0 → ymf-0.3.2}/examples/read_archive.py +0 -0
  67. {ymf-0.3.0 → ymf-0.3.2}/examples/validate_spec.py +0 -0
  68. {ymf-0.3.0 → ymf-0.3.2}/examples/write_archive.py +0 -0
  69. {ymf-0.3.0 → ymf-0.3.2}/pyproject.toml +0 -0
  70. {ymf-0.3.0 → ymf-0.3.2}/setup.cfg +0 -0
  71. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/__init__.py +0 -0
  72. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/archive.py +0 -0
  73. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/cli.py +0 -0
  74. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/closure.py +0 -0
  75. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/compose.py +0 -0
  76. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/data_sources.py +0 -0
  77. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/discretizations.py +0 -0
  78. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/dispersion.py +0 -0
  79. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/domain.py +0 -0
  80. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/explicit.py +0 -0
  81. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/generated.py +0 -0
  82. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/mesh.py +0 -0
  83. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/spaces.py +0 -0
  84. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/state.py +0 -0
  85. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/__init__.py +0 -0
  86. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/symbolic/adr.py +0 -0
  87. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/units.py +0 -0
  88. {ymf-0.3.0 → ymf-0.3.2}/src/ymf/xdmf.py +0 -0
  89. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/dependency_links.txt +0 -0
  90. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/entry_points.txt +0 -0
  91. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/requires.txt +0 -0
  92. {ymf-0.3.0 → ymf-0.3.2}/src/ymf.egg-info/top_level.txt +0 -0
  93. {ymf-0.3.0 → ymf-0.3.2}/tests/_formulation.py +0 -0
  94. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/format1_two_spaces.xmf +0 -0
  95. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/format1_two_spaces.ymf +0 -0
  96. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/hexahedron.xmf +0 -0
  97. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/polyline.xmf +0 -0
  98. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/quadrilateral.xmf +0 -0
  99. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/tet_10.xmf +0 -0
  100. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/tetrahedron.xmf +0 -0
  101. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/tri_6.xmf +0 -0
  102. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/proteus/triangle.xmf +0 -0
  103. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/circular_dam_dispersive.ymf +0 -0
  104. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/dam3bumps.ymf +0 -0
  105. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/dispersive.ymf +0 -0
  106. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/dispersive_numerics.ymf +0 -0
  107. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/lake_at_rest.ymf +0 -0
  108. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/proteus_numerics.ymf +0 -0
  109. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/shallow_water.ymf +0 -0
  110. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/shallow_water/torino.ymf +0 -0
  111. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak.ymf +0 -0
  112. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_clsvof.ymf +0 -0
  113. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_formulation.ymf +0 -0
  114. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/two_phase/dambreak_porous.ymf +0 -0
  115. {ymf-0.3.0 → ymf-0.3.2}/tests/fixtures/two_phase/two_phase_level_set.ymf +0 -0
  116. {ymf-0.3.0 → ymf-0.3.2}/tests/test_archive.py +0 -0
  117. {ymf-0.3.0 → ymf-0.3.2}/tests/test_archive_spec_as_written.py +0 -0
  118. {ymf-0.3.0 → ymf-0.3.2}/tests/test_boundary_declaration.py +0 -0
  119. {ymf-0.3.0 → ymf-0.3.2}/tests/test_boundary_kinds.py +0 -0
  120. {ymf-0.3.0 → ymf-0.3.2}/tests/test_cells_per_axis.py +0 -0
  121. {ymf-0.3.0 → ymf-0.3.2}/tests/test_cli.py +0 -0
  122. {ymf-0.3.0 → ymf-0.3.2}/tests/test_closure.py +0 -0
  123. {ymf-0.3.0 → ymf-0.3.2}/tests/test_coefficient_roles.py +0 -0
  124. {ymf-0.3.0 → ymf-0.3.2}/tests/test_compose.py +0 -0
  125. {ymf-0.3.0 → ymf-0.3.2}/tests/test_condition_expansion.py +0 -0
  126. {ymf-0.3.0 → ymf-0.3.2}/tests/test_condition_sets.py +0 -0
  127. {ymf-0.3.0 → ymf-0.3.2}/tests/test_core_without_frontend.py +0 -0
  128. {ymf-0.3.0 → ymf-0.3.2}/tests/test_data_sources.py +0 -0
  129. {ymf-0.3.0 → ymf-0.3.2}/tests/test_decimals_as_written.py +0 -0
  130. {ymf-0.3.0 → ymf-0.3.2}/tests/test_discrete_domains.py +0 -0
  131. {ymf-0.3.0 → ymf-0.3.2}/tests/test_discretizations.py +0 -0
  132. {ymf-0.3.0 → ymf-0.3.2}/tests/test_dispersion.py +0 -0
  133. {ymf-0.3.0 → ymf-0.3.2}/tests/test_domain.py +0 -0
  134. {ymf-0.3.0 → ymf-0.3.2}/tests/test_examples.py +0 -0
  135. {ymf-0.3.0 → ymf-0.3.2}/tests/test_explicit.py +0 -0
  136. {ymf-0.3.0 → ymf-0.3.2}/tests/test_extends_initial_conditions.py +0 -0
  137. {ymf-0.3.0 → ymf-0.3.2}/tests/test_file_domains.py +0 -0
  138. {ymf-0.3.0 → ymf-0.3.2}/tests/test_gauges.py +0 -0
  139. {ymf-0.3.0 → ymf-0.3.2}/tests/test_generated.py +0 -0
  140. {ymf-0.3.0 → ymf-0.3.2}/tests/test_indicator_conditions.py +0 -0
  141. {ymf-0.3.0 → ymf-0.3.2}/tests/test_lagging.py +0 -0
  142. {ymf-0.3.0 → ymf-0.3.2}/tests/test_linear_solver.py +0 -0
  143. {ymf-0.3.0 → ymf-0.3.2}/tests/test_mesh.py +0 -0
  144. {ymf-0.3.0 → ymf-0.3.2}/tests/test_mesh_fingerprint.py +0 -0
  145. {ymf-0.3.0 → ymf-0.3.2}/tests/test_named_coefficients.py +0 -0
  146. {ymf-0.3.0 → ymf-0.3.2}/tests/test_named_equations.py +0 -0
  147. {ymf-0.3.0 → ymf-0.3.2}/tests/test_nesting.py +0 -0
  148. {ymf-0.3.0 → ymf-0.3.2}/tests/test_normalize.py +0 -0
  149. {ymf-0.3.0 → ymf-0.3.2}/tests/test_notation.py +0 -0
  150. {ymf-0.3.0 → ymf-0.3.2}/tests/test_notation_functions.py +0 -0
  151. {ymf-0.3.0 → ymf-0.3.2}/tests/test_periodic_regions.py +0 -0
  152. {ymf-0.3.0 → ymf-0.3.2}/tests/test_proteus_archive.py +0 -0
  153. {ymf-0.3.0 → ymf-0.3.2}/tests/test_references.py +0 -0
  154. {ymf-0.3.0 → ymf-0.3.2}/tests/test_removal.py +0 -0
  155. {ymf-0.3.0 → ymf-0.3.2}/tests/test_schema.py +0 -0
  156. {ymf-0.3.0 → ymf-0.3.2}/tests/test_select.py +0 -0
  157. {ymf-0.3.0 → ymf-0.3.2}/tests/test_shallow_water.py +0 -0
  158. {ymf-0.3.0 → ymf-0.3.2}/tests/test_spaces.py +0 -0
  159. {ymf-0.3.0 → ymf-0.3.2}/tests/test_split.py +0 -0
  160. {ymf-0.3.0 → ymf-0.3.2}/tests/test_state.py +0 -0
  161. {ymf-0.3.0 → ymf-0.3.2}/tests/test_state_coefficients.py +0 -0
  162. {ymf-0.3.0 → ymf-0.3.2}/tests/test_subproblems.py +0 -0
  163. {ymf-0.3.0 → ymf-0.3.2}/tests/test_symbolic.py +0 -0
  164. {ymf-0.3.0 → ymf-0.3.2}/tests/test_tag_regions.py +0 -0
  165. {ymf-0.3.0 → ymf-0.3.2}/tests/test_units.py +0 -0
  166. {ymf-0.3.0 → ymf-0.3.2}/tests/test_values.py +0 -0
  167. {ymf-0.3.0 → ymf-0.3.2}/tests/test_version.py +0 -0
  168. {ymf-0.3.0 → ymf-0.3.2}/tests/test_vocabulary.py +0 -0
  169. {ymf-0.3.0 → ymf-0.3.2}/tests/test_xdmf.py +0 -0
  170. {ymf-0.3.0 → ymf-0.3.2}/tests/test_xdmf_fragments.py +0 -0
  171. {ymf-0.3.0 → ymf-0.3.2}/tests/test_xdmf_model.py +0 -0
  172. {ymf-0.3.0 → ymf-0.3.2}/tools/check_dist.sh +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ymf
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: YAML Modeling Format for computational physics — problem specification, VVUQ, and multi-backend dispatch.
5
5
  Author: cekees
6
6
  License-Expression: MIT
@@ -7,6 +7,46 @@ rediscover why a thing is the way it is. Open gaps are in
7
7
 
8
8
  ## 2026-11
9
9
 
10
+ - **2026-11-25: C42 round 7, `reference` optional at `beta` 1.** `missing()` asked for `shock_capturing.reference` of every
11
+ stated shock-capturing block, though a `beta: 1` kernel (the classical `factor |R|/sqrt(∇uᵀ G ∇u)`, proteus's RDLS)
12
+ never reads it. It no longer does when `beta` is stated as 1 (any spelling: `beta`, `sc_beta`); stating a reference
13
+ there is still allowed and checked (positive), and any other or unstated `beta` still needs it. Nothing is defaulted.
14
+
15
+ - **2026-11-25: C42 round 7, a boundary value from another sub-problem's trace.** NCLS's inflow penalty is written
16
+ against RDLS's face values (C19 gap note G8), which a condition could not say: its value was an expression. Now a
17
+ Dirichlet, `inflow` or `characteristic` condition may give `trace: {of, via, at}` instead of a value; `split_problem`
18
+ carries it to the sub-problems that solve the variable (not `via` itself) and refuses a `via` that is not in the
19
+ discretization or a `current_step` read of a later sub-problem. It is part of an archive's key.
20
+
21
+ - **2026-11-25: C42 round 7, `atan`.** santos_step's bed, `0.1 (0.5 + arctan(x/0.075)/π)`, could not be written (`atan`
22
+ was not a function of the notation). Now `atan(e)` parses, prints back (the printer's round trip), is `numpy.arctan`
23
+ in code, and differentiates (the bed slope in the momentum equation). Fixture `santos_step.ymf`: the deck's solitary
24
+ wave over the step, dispersive, with its own hw. One test that used `atan` as its example of a function with no
25
+ notation now uses `asin`.
26
+
27
+ - **2026-11-25: C42 round 7, a state on part of a boundary.** The SWFlow decks impose their inflow node by node on
28
+ part of one boundary (`X[0] == 0`) and on one Cartesian component (`x_mom`, `y_mom`), which a spec could not say: a
29
+ `component` was the normal or tangential part only (it needs the side's orientation), and a condition held on its
30
+ whole region. Now a condition may carry `part`, a predicate like a region's `where`, and there it replaces the
31
+ region's conditions on the same variable without a part on an overlapping component; a `component` may be `x`, `y`,
32
+ `z`; and predicates take comparisons (`x = 0 and 0.4 ≤ y ≤ 0.6`). `split_problem` gives `part` and `excluding`
33
+ (codes), so a reader applies each entry as written. Fixtures: `transcritical_bump.ymf` (the deck's three conditions)
34
+ and `obstacle_inflow.ymf` (obstacle_flow's boundary on its box: the outflow set with the state on x = 0).
35
+
36
+ - **2026-11-18: 0.3.1, a stabilization without a method (C42 round 6).** ymf 0.3.0 required `method` in every
37
+ `stabilization:` block, so proteus's RDLS block (`stabilization: {shock_capturing: {factor: 0.9, lag: false}}`, read
38
+ as a free map by ymf 0.2) no longer loaded, and `test/dispatch` broke on every proteus PR. Now `method: none` is a
39
+ word (no residual-based method; it reads only `shock_capturing`), the bare `stabilization: none` says a sub-problem is
40
+ not stabilized at all (MCorr, PresInc), and a block that states only `shock_capturing` loads and means exactly
41
+ that, `method: none` plus that shock capturing; ymf picks no method for it and fills in no key. `tau` or `lagged`
42
+ without a method are refused (they belong to one). `ymf.stabilization.missing(block)` still lists what a reader that
43
+ must not guess needs: under `none` an unstated `shock_capturing` is not missing (the word says there is none), a
44
+ stated block must be complete (`beta`, `reference` for RDLS's). A spec written before 2026-11-17 loads unchanged:
45
+ proteus's own `test/dispatch/dambreak.ymf` and `two_phase_level_set.ymf` (`cekees/main` b9d98f5d) are fixtures
46
+ (`tests/fixtures/proteus_dispatch_0_2/`), loaded, resolved and round-tripped through an archive with the same key.
47
+ Suite 1032 -> 1048. What proteus's RDLS actually applies (SUPG with `tau: metric`, not lagged, and a classical
48
+ `beta` 1 shock capturing) is in `HANDOFF_2026-11-18_ymf-r6.md`: the old block was incomplete, not wrong to load.
49
+
10
50
  - **2026-11-17: C42 round 5, the formulation a generator and a dispatcher read (C19 spike report, C5 step 4 part 2).**
11
51
  The generator spike could not generate what the spec did not say (stabilization, shock capturing, lagging, boundary
12
52
  kind, porosity) and C5 could not state a dispersive model or a mesh of a box that is not square. Now the spec states
@@ -182,6 +182,70 @@ the region exists, the variable is an unknown or a coefficient, `slip` and
182
182
  a `component` are on a vector, and a kind gets a value exactly when it
183
183
  takes one.
184
184
 
185
+ **A state on part of a boundary** (round 7). A condition's `part` is a
186
+ predicate, written like a region's `where`, that says on which points of its
187
+ region it holds; there it replaces the region's conditions on the same
188
+ variable that have no part and are on an overlapping component, and those
189
+ hold on the rest. A `component` may also be a Cartesian one, `x`, `y` or
190
+ `z` (the vector's first, second, third), with a value (dirichlet, neumann,
191
+ inflow, characteristic). So the SWFlow decks' inflows read as they are
192
+ imposed:
193
+
194
+ ```yaml
195
+ # transcritical_bump: q's y component 0 on all of ∂Ω, its x component at x = 0, the depth at x = 25
196
+ boundary_regions: [{name: all, where: "∂Ω"}]
197
+ boundary_conditions:
198
+ - {region: all, variable: q, type: dirichlet, component: y, value: 0.0}
199
+ - {region: all, part: "x = 0", variable: q, type: dirichlet, component: x, value: 0.18}
200
+ - {region: all, part: "x = 25", variable: h, type: dirichlet, value: 0.28205279813802181}
201
+ # obstacle_flow: the whole state on x = 0, the outflow elsewhere
202
+ boundary_sets: [{region: all, set: outflow}]
203
+ boundary_conditions:
204
+ - {region: all, part: "x = 0", variable: h, type: dirichlet, value: 1.0}
205
+ - {region: all, part: "x = 0", variable: q, type: dirichlet, formula: "(1.5, 0)"}
206
+ # a window in a wall: the wall holds off it
207
+ boundary_sets: [{region: walls, set: wall}]
208
+ boundary_conditions:
209
+ - {region: walls, part: "x = 0 and 4 ≤ y ≤ 6", variable: q, type: dirichlet, formula: "(1.5, 0)"}
210
+ ```
211
+
212
+ Components overlap unless they are two different Cartesian ones or the
213
+ normal and the tangential part (`ymf.conditions.overlap`): the x component
214
+ at x = 0 leaves the y component's condition alone there, a whole-vector
215
+ state replaces both parts of a wall. A part is not a region, so it replaces
216
+ no condition set's member (the member is the rest), and a part of a tag
217
+ region is found by flag and position together. `split_problem` gives a
218
+ condition with a part its `part` (code, beside the region's `where` or
219
+ `flags`), and one without whose region other conditions carve parts out of
220
+ its `excluding` (a list of codes): it holds where its region does, less
221
+ those, so a reader applies each entry as written and decides no precedence.
222
+ A Cartesian component's entry acts on that one component (`components:
223
+ [q_0]`). Refused on load: a part that is the whole region (`∂Ω`), a part on
224
+ a periodic condition, a Cartesian component on slip, open, robin or
225
+ periodic. `adr_problem` (one system) runs neither a part nor a component.
226
+ Parts of one region and variable should not overlap; that is not checked.
227
+
228
+ **A value from another sub-problem's trace** (round 7). In a split
229
+ discretization one sub-problem may impose, on a boundary, the boundary
230
+ values another holds (NCLS's inflow penalty against RDLS's face values):
231
+ `trace: {of, via, at}` in place of `value`, `formula` or `series`. `via`
232
+ names the sub-problem, `of` the field (default the condition's variable),
233
+ `at` when (`previous_step`, or `current_step` from an earlier sub-problem of
234
+ the step, as a lag says it).
235
+
236
+ ```yaml
237
+ boundary_conditions:
238
+ - {region: top, variable: φ, type: dirichlet, imposed: weak,
239
+ trace: {of: φ, via: rdls, at: previous_step}}
240
+ ```
241
+
242
+ Dirichlet, `inflow` and `characteristic` only, whole fields (no
243
+ `component`). `split_problem` gives the entry `trace` (with `of` filled in)
244
+ and no `value`, to every sub-problem that solves the variable except `via`
245
+ itself, which has its own values; a `via` that is no sub-problem of the
246
+ discretization, or is solved later than a `current_step` read, is refused.
247
+ `adr_problem` runs none.
248
+
185
249
  **Condition sets.** What a free-slip wall or an open top means is part of
186
250
  the model: written once there, over its own unknowns and coefficients, and
187
251
  applied to regions by each problem.
@@ -370,13 +434,14 @@ solution_paths:
370
434
  | `(a, b)` | a vector |
371
435
  | `x² π³ x^n x**n` | powers |
372
436
  | `2π²κt`, `κ ΔT`, `sin(πx)` | implicit multiplication |
373
- | `sin cos tan exp log sqrt sinh cosh tanh abs` | functions, with parentheses |
437
+ | `sin cos tan atan exp log sqrt sinh cosh tanh abs` | functions, with parentheses (`atan` is the arctangent, `numpy.arctan` in code) |
374
438
  | `hypot(a, b)` | `sqrt(a² + b²)` rounded once (C99 `hypot`, `numpy.hypot` in code): a distance that matches code computing it with `hypot`, bit for bit |
375
439
  | `heaviside(φ)`, `sign(e)`, `min(a, b, ...)`, `max(a, b, ...)` | sharp functions; a solver needs `heaviside` and `sign` of an unknown regularized, since their derivatives are Dirac deltas |
376
440
  | `norm(v)`, `sym(∇v)` | `sqrt(v·v)`, and the symmetric part `(A + Aᵀ)/2` of a square tensor |
377
441
  | `grad div lap dt dx dy dz dot outer` | the operators spelled out, for ASCII-only text |
378
442
  | `lhs = rhs in Ω` | an equation; the `in ...` clause is ignored |
379
443
  | `y = 0 or x = 0 and y = H` | a boundary region; `∂Ω` is the whole boundary |
444
+ | `x = 0 and 0.4 ≤ y ≤ 0.6` | comparisons in a predicate (`≤ ≥ < >`, or `<= >=`; chained): a closed bound keeps the points on it (within `tol`), an open one drops them |
380
445
  | `Ω = [a, b] × [c, d], t ∈ (t0, t1]` | the domain, a box, and the time interval of a transient problem |
381
446
 
382
447
  **Decimals are kept as written.** A numeral is an IEEE double, and a
@@ -896,7 +961,7 @@ checked on load, so that a second solver reads the same ones:
896
961
  | model family (`physical_model.family`) | `two_phase_level_set`, `shallow_water`, `dispersive_shallow_water` |
897
962
  | sub-problem role (`role`) | two-phase: `velocity_pressure`, `velocity`, `pressure_increment`, `pressure`, `pressure_spin_up`, `volume_fraction`, `level_set`, `level_set_redistanced`, `redistancing`, `mass_correction`; shallow water: `shallow_water` |
898
963
  | `time_integration` | `backward_euler`, `bdf2`, `ssp_rk3`, `none` |
899
- | `stabilization.method` | `ASGS`, `SUPG`, `residual_shock_capturing`, `entropy_viscosity`, `graph_viscosity_smoothness`, `graph_viscosity_entropy_residual` |
964
+ | `stabilization.method` | `ASGS`, `SUPG`, `residual_shock_capturing`, `entropy_viscosity`, `graph_viscosity_smoothness`, `graph_viscosity_entropy_residual`, `none` |
900
965
  | `discretization.scheme` and its options | `graph_viscosity_convex_limiting`: `entropy_viscosity_coefficient`, `lumped_mass`, `bounds_relaxation` (and `time_integration`, `outputs`, `dt` for every scheme) |
901
966
  | `step_control.type` | `min_cfl`, `fixed` |
902
967
  | `regularize.*.by` | `smoothed_heaviside`, `smoothed_sign`, `wet_dry_cutoff` |
@@ -967,6 +1032,29 @@ the entropy and graph viscosities read none (their parameters are the scheme's o
967
1032
  `reference` positive, `factor` non-negative. `lag`, `sc_beta`, `sc_uref` (the keys proteus's dispatcher read first) are
968
1033
  accepted and resolve to `lagged`, `beta`, `reference`.
969
1034
 
1035
+ *No method, and shock capturing alone* (0.3.1). `method: none` says the sub-problem has no residual-based method; it reads
1036
+ only `shock_capturing`. Three statements, three meanings:
1037
+
1038
+ ```yaml
1039
+ stabilization: none # not stabilized at all, shock capturing included (MCorr, PresInc, a projection)
1040
+ stabilization: {method: none, shock_capturing: {factor: 0.9, lagged: false}} # shock capturing and no method
1041
+ stabilization: {shock_capturing: {factor: 0.9, lagged: false}} # the same: a block without `method`
1042
+ ```
1043
+
1044
+ A block with `shock_capturing` and no `method` is the second one, exactly: ymf never picks a method for a block that
1045
+ does not name one (it is neither `SUPG` nor `residual_shock_capturing`, which also takes `tau`), and `tau` or `lagged`
1046
+ without a method are refused, because they belong to a method. `resolve` returns `{"method": "none", ...}` for all
1047
+ three and adds no other key.
1048
+
1049
+ *What a reader that must not guess still needs: `ymf.stabilization.missing(block)`.* It returns the dotted keys the
1050
+ kernel generator reads that the block does not state, and nothing is filled in: `missing("SUPG")` is `["tau", "lagged",
1051
+ "shock_capturing"]`; with `shock_capturing: {factor: 0.9, lagged: false}` stated it also asks for `shock_capturing.beta` and
1052
+ `.reference` (stating `shock_capturing: none` answers the block as a whole; **at `beta: 1`, the classical form that never
1053
+ reads the reference value, `reference` is not asked for**: proteus's RDLS is `{factor: 0.9, beta: 1.0, lagged: false}`); the entropy and graph viscosities need
1054
+ nothing. For `none`, an unstated `shock_capturing` is not missing (the word says there is none); a `shock_capturing`
1055
+ block it does state must be complete, so `missing({"shock_capturing": {"factor": 0.9, "lag": False}})` is
1056
+ `["shock_capturing.beta", "shock_capturing.reference"]` and `missing("none")` is `[]`.
1057
+
970
1058
  **Lagging** (`lagged_coefficients`): `{μ: previous_iterate, ρ: previous_step}` says which of the model's coefficients
971
1059
  a sub-problem freezes, in the Newton iteration (a Picard step: the Jacobian drops the dependence) or in time (a
972
1060
  constant of the step). A field read from another sub-problem is `lags`; a stabilization's lag is its `lagged`.
@@ -103,14 +103,14 @@ def check_condition(condition: Dict[str, Any], where: str) -> None:
103
103
 
104
104
 
105
105
  def kinds(doc: Dict[str, Any]) -> List[Dict[str, Any]]:
106
- """Every boundary condition of the document, expanded, as ``{region, variable, type, [component], [only], kind,
106
+ """Every boundary condition of the document, expanded, as ``{region, [part], variable, type, [component], [only], kind,
107
107
  [penalty], [form]}`` in order: what a solver reads to choose its boundary terms."""
108
108
  from ymf.conditions import expand
109
109
  from ymf.normalize import boundary_conditions
110
110
  strong = ((expand(doc).get("model") or {}).get("strong_form") or {})
111
111
  out = []
112
112
  for bc in boundary_conditions(strong):
113
- entry = {k: bc[k] for k in ("region", "variable", "type", "component", "only") if bc.get(k) is not None}
113
+ entry = {k: bc[k] for k in ("region", "part", "variable", "type", "component", "only") if bc.get(k) is not None}
114
114
  entry["kind"] = kind_of(bc)
115
115
  for k in ("penalty", "form"):
116
116
  if bc.get(k) is not None:
@@ -13,9 +13,12 @@ be reproducible from its record.
13
13
  An expanded condition is one of the abstract forms, on
14
14
 
15
15
  * the whole variable, or a ``component`` of a vector: its ``normal`` or
16
- ``tangential`` part on the boundary;
17
- * the whole region, or ``only`` the part of it where the flow enters
18
- (``inflow``) or where characteristics enter (``incoming_characteristics``);
16
+ ``tangential`` part on the boundary, or a Cartesian component ``x``, ``y``,
17
+ ``z``;
18
+ * the whole region, or a ``part`` of it given by a predicate (``x = 0 and
19
+ 0.4 ≤ y ≤ 0.6``: a state imposed on part of a boundary), and ``only`` the
20
+ part of that where the flow enters (``inflow``) or where characteristics
21
+ enter (``incoming_characteristics``);
19
22
 
20
23
  with its value (``value``, ``formula`` or ``series``), optionally how it is
21
24
  ``imposed`` (``strong`` or ``weak``: C12 makes that a property of each
@@ -26,6 +29,21 @@ from.
26
29
  document; it is idempotent, and a document with no alias and no condition set
27
30
  comes back unchanged, so the outputs it keys keep their keys.
28
31
 
32
+ **A part, and the rest of its region.** A condition with a ``part`` holds
33
+ on the points of its region where the predicate holds, and there it replaces
34
+ the conditions on the same region and variable that have no part and are on
35
+ a component that overlaps its own (:func:`overlap`: the whole variable
36
+ overlaps every component; ``x`` and ``y``, or ``normal`` and ``tangential``,
37
+ do not): those hold on the rest of the region. So ``boundary_sets: [{region: all, set: wall}]``
38
+ and ``{region: all, part: "x = 0", variable: q, type: dirichlet, formula:
39
+ "(0.75, 0)"}`` is a wall everywhere but on x = 0, where the discharge is
40
+ given; ``{region: all, variable: q, type: dirichlet, component: y, value:
41
+ 0}`` with ``{region: all, part: "x = 0", variable: q, type: dirichlet,
42
+ component: x, value: 0.18}`` holds q's y component everywhere, x = 0
43
+ included. A part is not a region of its own, so a condition with a part does
44
+ not replace a condition set's member either: the member is the rest.
45
+ :func:`excluded` gives the parts a condition without one does not hold on.
46
+
29
47
  This module is stdlib only, like the rest of the spec core.
30
48
  """
31
49
 
@@ -34,7 +52,11 @@ from __future__ import annotations
34
52
  import copy
35
53
  from typing import Any, Dict, List, Tuple
36
54
 
37
- __all__ = ["ALIASES", "ABSTRACT", "expand", "expand_condition", "has_shorthand", "describe"]
55
+ __all__ = ["ALIASES", "ABSTRACT", "AXES", "expand", "expand_condition", "has_shorthand", "describe", "parts",
56
+ "excluded", "overlap"]
57
+
58
+ #: the Cartesian components a condition may be on, and the index of each
59
+ AXES = {"x": 0, "y": 1, "z": 2}
38
60
 
39
61
  #: the abstract forms: what an expansion is made of
40
62
  ABSTRACT = ("dirichlet", "neumann", "robin", "periodic")
@@ -43,7 +65,7 @@ ABSTRACT = ("dirichlet", "neumann", "robin", "periodic")
43
65
  _VALUE_KEYS = ("value", "formula", "series", "units")
44
66
 
45
67
  #: the order an expanded condition's keys are written in
46
- _ORDER = ("region", "variable", "type", "component", "only", "value", "formula", "series",
68
+ _ORDER = ("region", "part", "variable", "type", "component", "only", "value", "formula", "series",
47
69
  "alpha", "beta", "units", "imposed", "penalty", "form", "source", "source_url", "temporal",
48
70
  "expanded_from")
49
71
 
@@ -191,3 +213,38 @@ def expand(doc: Dict[str, Any]) -> Dict[str, Any]:
191
213
  def describe() -> List[Tuple[str, str, List[Dict[str, Any]]]]:
192
214
  """``(alias, what it means, its components)`` for the documentation."""
193
215
  return [(name, a["means"], copy.deepcopy(a["components"])) for name, a in ALIASES.items()]
216
+
217
+
218
+
219
+ def overlap(a: Any, b: Any) -> bool:
220
+ """Whether conditions on components ``a`` and ``b`` of one variable (None: the whole variable) can constrain the
221
+ same thing: not when they are two different Cartesian components, nor the normal and the tangential part."""
222
+ if a is None or b is None or a == b:
223
+ return True
224
+ if a in AXES and b in AXES:
225
+ return False
226
+ return {a, b} != {"normal", "tangential"}
227
+
228
+
229
+ def parts(conditions: List[Dict[str, Any]]) -> Dict[Tuple[Any, Any], List[Tuple[str, Any]]]:
230
+ """``{(region, variable): [(part, component), ...]}``: the parts of each region that conditions on a variable claim,
231
+ with the component each is on, in the order written, each once."""
232
+ out: Dict[Tuple[Any, Any], List[Tuple[str, Any]]] = {}
233
+ for bc in conditions:
234
+ if isinstance(bc, dict) and bc.get("part") is not None:
235
+ claimed = out.setdefault((bc.get("region"), bc.get("variable")), [])
236
+ if (bc["part"], bc.get("component")) not in claimed:
237
+ claimed.append((bc["part"], bc.get("component")))
238
+ return out
239
+
240
+
241
+ def excluded(bc: Dict[str, Any], claimed: Dict[Tuple[Any, Any], List[Tuple[str, Any]]]) -> List[str]:
242
+ """The parts a condition without a part does not hold on: those of its region that conditions on the same variable,
243
+ on a component that overlaps its own, claim (``claimed`` is :func:`parts`). Empty for a condition with a part."""
244
+ if bc.get("part") is not None:
245
+ return []
246
+ out: List[str] = []
247
+ for part, component in claimed.get((bc.get("region"), bc.get("variable")), []):
248
+ if overlap(component, bc.get("component")) and part not in out:
249
+ out.append(part)
250
+ return out
@@ -28,8 +28,8 @@ class NotationError(ValueError):
28
28
 
29
29
  _SUPERSCRIPTS = {"²": 2, "³": 3, "⁴": 4}
30
30
  _ALIASES = {"−": "-", "⋅": "·", "∙": "·", "–": "-", "∆": "Δ"}
31
- _OPERATORS = ["**", "^", "+", "-", "*", "/", "(", ")", "[", "]", ",", "=",
32
- "·", "⊗", "∇", "Δ", "∂", "×", "∈", ";"] + list(_SUPERSCRIPTS)
31
+ _OPERATORS = ["**", "^", "+", "-", "*", "/", "(", ")", "[", "]", ",", "<=", ">=", "=",
32
+ "≤", "≥", "<", ">", "·", "⊗", "∇", "Δ", "∂", "×", "∈", ";"] + list(_SUPERSCRIPTS)
33
33
  _NUMBER = re.compile(r"\d+(\.\d*)?([eE][+-]?\d+)?|\.\d+([eE][+-]?\d+)?")
34
34
 
35
35
 
@@ -97,7 +97,7 @@ _SUBSCRIPT_PLAIN.update({
97
97
  #: the notation's function names (``ymf.symbolic.notation``'s ``_FUNCTIONS``
98
98
  #: and the parser's own; a test checks the two agree)
99
99
  FUNCTION_NAMES = frozenset([
100
- "sin", "cos", "tan", "exp", "log", "sqrt", "sinh", "cosh", "tanh", "abs", "hypot",
100
+ "sin", "cos", "tan", "atan", "exp", "log", "sqrt", "sinh", "cosh", "tanh", "abs", "hypot",
101
101
  "heaviside", "sign", "min", "max",
102
102
  "div", "grad", "lap", "dt", "dot", "outer", "vec", "norm", "sym", "dx", "dy", "dz",
103
103
  ])
@@ -141,13 +141,15 @@ def boundary_conditions(strong_form: Dict[str, Any]) -> List[Dict[str, Any]]:
141
141
  of each applied set, with the region filled in and ``set`` naming where
142
142
  it came from. A condition written out for the same region and variable
143
143
  as a set's member replaces it: a case can apply ``atmosphere`` and still
144
- give the pressure its own value. Raises ``ValueError`` for a set nobody
144
+ give the pressure its own value. A condition with a ``part`` holds on
145
+ part of its region only, so it replaces no member: the member holds on
146
+ the rest (ymf.conditions). Raises ``ValueError`` for a set nobody
145
147
  defines, and for two sets that both give one region's variable a
146
148
  condition, which nothing would choose between.
147
149
  """
148
150
  sets = strong_form.get("condition_sets") or {}
149
151
  direct = [dict(bc) for bc in strong_form.get("boundary_conditions") or []]
150
- written = {(bc.get("region"), bc.get("variable")) for bc in direct}
152
+ written = {(bc.get("region"), bc.get("variable")) for bc in direct if bc.get("part") is None}
151
153
  expanded: List[Dict[str, Any]] = []
152
154
  given: Dict[Any, str] = {}
153
155
  for applied in strong_form.get("boundary_sets") or []:
@@ -278,6 +278,13 @@ def _check_split(doc: Dict[str, Any], entry: Dict[str, Any]) -> None:
278
278
  if symbol in readable:
279
279
  raise YmfReferenceError(
280
280
  "%s.binds.%s: %s is already a name" % (here, symbol, symbol))
281
+ for bc in _traces(strong):
282
+ trace = bc["trace"]
283
+ here = "model.strong_form.boundary_conditions[region=%r, variable=%r].trace" % (
284
+ bc.get("region"), bc.get("variable"))
285
+ _check(trace["via"], names, "%s.via (in %s)" % (here, where), "sub-problem")
286
+ _check(trace.get("of", bc.get("variable")), sorted(readable), "%s.of" % (here,),
287
+ "model unknown, coefficient or introduced unknown")
281
288
  if None not in equations:
282
289
  unsolved = [e for e in equations if e not in solved_by]
283
290
  if unsolved:
@@ -285,6 +292,15 @@ def _check_split(doc: Dict[str, Any], entry: Dict[str, Any]) -> None:
285
292
  "%s: no sub-problem solves %s" % (where, ", ".join(unsolved)))
286
293
 
287
294
 
295
+ def _traces(strong):
296
+ """The conditions (sets expanded) whose value is another sub-problem's trace."""
297
+ from ymf.normalize import boundary_conditions
298
+ try:
299
+ return [bc for bc in boundary_conditions(strong) if isinstance(bc, dict) and bc.get("trace") is not None]
300
+ except ValueError:
301
+ return []
302
+
303
+
288
304
  #: what each kind of condition needs: a value (value, formula or series),
289
305
  #: none, or either
290
306
  _NEEDS_VALUE = {"dirichlet": True, "neumann": True, "robin": True, "inflow": True,
@@ -323,12 +339,33 @@ def _check_conditions(doc: Dict[str, Any]) -> None:
323
339
  raise YmfReferenceError("%s: %s is neither an unknown nor a coefficient"
324
340
  % (where, variable))
325
341
  given = any(bc.get(k) is not None for k in ("value", "formula", "series"))
342
+ if bc.get("trace") is not None:
343
+ if given:
344
+ raise YmfReferenceError("%s: a trace is the condition's value; it takes no value, formula or series"
345
+ % (where,))
346
+ if kind not in ("dirichlet", "inflow", "characteristic"):
347
+ raise YmfReferenceError("%s: a %s condition takes no trace; a trace is the value of a dirichlet, "
348
+ "inflow or characteristic condition" % (where, kind))
349
+ if bc.get("component") is not None:
350
+ raise YmfReferenceError("%s: a trace is a whole field's; it takes no component" % (where,))
351
+ given = True
326
352
  if bc.get("component") and variable in unknowns and unknowns[variable] != 1:
327
353
  raise YmfReferenceError("%s: a %s component is a vector's, and %s is a scalar"
328
354
  % (where, bc["component"], variable))
329
355
  if kind == "slip" and variable in unknowns and unknowns[variable] != 1:
330
356
  raise YmfReferenceError("%s: slip gives the normal component of a vector, and "
331
357
  "%s is a scalar" % (where, variable))
358
+ if bc.get("component") in ("x", "y", "z") and kind in ("slip", "open", "robin", "periodic"):
359
+ raise YmfReferenceError("%s: a %s condition on the %s component; a Cartesian component takes a "
360
+ "value (dirichlet, neumann, inflow, characteristic)" % (where, kind, bc["component"]))
361
+ if bc.get("part") is not None:
362
+ part = str(bc["part"]).strip()
363
+ if kind == "periodic":
364
+ raise YmfReferenceError("%s: a periodic condition identifies a region's faces, whole; it has no part"
365
+ % (where,))
366
+ if part in ("", "∂Ω", "∂ Ω", "boundary"):
367
+ raise YmfReferenceError("%s: part %r is the whole region; give no part, or a predicate "
368
+ "(\"x = 0 and 0.4 ≤ y ≤ 0.6\")" % (where, bc["part"]))
332
369
  article = "an" if str(kind)[:1] in "aeiou" else "a"
333
370
  if _NEEDS_VALUE.get(kind) and not given:
334
371
  raise YmfReferenceError("%s: %s %s condition needs a value, formula or series"
@@ -112,9 +112,10 @@ ShockCapturingDef = Str() | Map(
112
112
  }
113
113
  )
114
114
 
115
+ # A block without ``method`` states shock capturing alone (``method: none``), ymf.stabilization.resolve.
115
116
  StabilizationDef = Str() | Map(
116
117
  {
117
- "method": Str(),
118
+ Optional("method"): Str(),
118
119
  Optional("tau"): Str(),
119
120
  Optional("lagged"): Bool(),
120
121
  Optional("lag"): Bool(),
@@ -397,8 +398,20 @@ _CONDITION_FIELDS = {
397
398
  # Where an alias expands (ymf.conditions): which part of a vector the
398
399
  # condition is on, which part of the region it holds on, how it is
399
400
  # imposed (C12: a property of each condition), and what it expanded from.
400
- Optional("component"): Enum(["normal", "tangential"]),
401
+ # A component is the normal or tangential part on the boundary, or one
402
+ # Cartesian component (x, y, z: the vector's first, second, third).
403
+ Optional("component"): Enum(["normal", "tangential", "x", "y", "z"]),
401
404
  Optional("only"): Enum(["inflow", "incoming_characteristics"]),
405
+ # The part of the region the condition holds on, a predicate like a
406
+ # region's where ("x = 0 and 0.4 ≤ y ≤ 0.6"): a state imposed on part of
407
+ # a boundary. On that part it replaces the region's conditions on the
408
+ # same variable that have no part; they hold on the rest (ymf.conditions).
409
+ Optional("part"): Str(),
410
+ # The value taken from another sub-problem's trace on the boundary
411
+ # (coupled sub-problems): instead of value, formula or series. `of` is the
412
+ # field read (default the condition's own variable), `via` the sub-problem
413
+ # whose trace it is, `at` when, as a lag says it. Dirichlet kinds only.
414
+ Optional("trace"): Map({Optional("of"): Str(), "via": Str(), "at": LagAtEnum}),
402
415
  Optional("imposed"): Enum(["strong", "weak", "none"]),
403
416
  # a weak (Nitsche) condition's penalty, over h, and its adjoint term
404
417
  # (ymf.boundaries); checked on load against the condition's type
@@ -14,6 +14,8 @@ or as a block::
14
14
  reference: 1.0 # the reference value of the unknown (sc_uref)
15
15
  lagged: true # the viscosity taken from the previous step (ShockCapturing lag)
16
16
  stabilization: {method: SUPG, shock_capturing: none} # none, stated: the solver adds no shock capturing
17
+ stabilization: none # nothing: no method, no shock capturing (MCorr, a projection)
18
+ stabilization: {shock_capturing: {factor: 0.9}} # shock capturing with no method (proteus's RDLS block of 0.2)
17
19
 
18
20
  What it is for. The generator (C19) turned VOF and NCLS into a functor each, but the SUPG tau, the shock capturing and
19
21
  their lag are the engine template's, and the template took them from the model's name (``dambreak.ymf`` stated none: the
@@ -28,6 +30,11 @@ becomes a block) and adds nothing: **a key the spec does not state stays unstate
28
30
 
29
31
  Which keys a method takes:
30
32
 
33
+ * ``none``: no residual-based method. It takes only ``shock_capturing``: ``stabilization: none`` (or ``method: none``)
34
+ says that the sub-problem is not stabilized at all, shock capturing included; ``{method: none, shock_capturing:
35
+ {factor: 0.9}}`` says shock capturing and nothing else. A block that states ``shock_capturing`` and no ``method`` is
36
+ exactly that second one (ymf 0.2 read such a block, proteus's RDLS stated one; 0.3.0 refused it; resolve gives it
37
+ ``method: none``). This is a meaning, not a default: ymf never picks a method for a block that does not name one.
31
38
  * ``SUPG``, ``ASGS``: ``tau``, ``lagged``, ``shock_capturing`` (the residual-based viscosity added to the method).
32
39
  * ``residual_shock_capturing``: the shock-capturing viscosity alone: ``tau``, ``shock_capturing`` (its block says how much;
33
40
  unstated, the solver's own coefficient applies).
@@ -53,6 +60,7 @@ class StabilizationError(ValueError):
53
60
 
54
61
  #: method -> the keys of the block it reads (beside ``method``)
55
62
  TAKES: Dict[str, tuple] = {
63
+ "none": ("shock_capturing",),
56
64
  "SUPG": ("tau", "lagged", "shock_capturing"),
57
65
  "ASGS": ("tau", "lagged", "shock_capturing"),
58
66
  "residual_shock_capturing": ("tau", "shock_capturing"),
@@ -139,13 +147,28 @@ def _shock_capturing(block: Any, where: str) -> Optional[Dict[str, Any]]:
139
147
 
140
148
  def resolve(block: Any, where: str = "stabilization") -> Dict[str, Any]:
141
149
  """The stabilization as a block with ymf's words and every stated key kept: ``{method, tau?, lagged?,
142
- shock_capturing?}``, ``shock_capturing`` a dict, or ``None`` when the spec says ``none``. Nothing is added.
143
- Raises :class:`StabilizationError`."""
150
+ shock_capturing?}``, ``shock_capturing`` a dict, or ``None`` when the spec says ``none``. Nothing is added, with one
151
+ reading of what is stated: a block that gives ``shock_capturing`` and no ``method`` has ``method: none`` (shock
152
+ capturing and no residual-based method), and the bare word ``none`` is ``{"method": "none"}``, which under
153
+ :data:`TAKES` ``none`` states no shock capturing either. Raises :class:`StabilizationError`."""
144
154
  if isinstance(block, str):
145
155
  block = {"method": block}
146
- if not isinstance(block, dict) or "method" not in block:
147
- raise StabilizationError("%s: say the method (stabilization: SUPG), or give a block with method:" % (where,))
156
+ if not isinstance(block, dict):
157
+ raise StabilizationError("%s: say the method (stabilization: SUPG, or none), or give a block with method:"
158
+ % (where,))
148
159
  block = _keys(block, "stabilization_key", where)
160
+ if "method" not in block:
161
+ if "shock_capturing" not in block:
162
+ raise StabilizationError(
163
+ "%s: say the method (stabilization: SUPG, or none), or give a block with method: (a block with only "
164
+ "shock_capturing has no method: none)" % (where,))
165
+ others = sorted(set(block) - {"shock_capturing"})
166
+ if others:
167
+ raise StabilizationError(
168
+ "%s: no method is stated, so the block is shock capturing and nothing else (method: none), and "
169
+ "%s %s read by a method: say which (method: SUPG, ASGS or residual_shock_capturing)"
170
+ % (where, ", ".join(others), "is" if len(others) == 1 else "are"))
171
+ block = dict(block, method="none")
149
172
  method = _method(block["method"], where + ".method")
150
173
  takes = TAKES[method]
151
174
  unread = sorted(set(block) - {"method"} - set(takes))
@@ -194,17 +217,30 @@ def missing(block: Any) -> List[str]:
194
217
 
195
218
  def generator_needs(method: str, resolved: Optional[Dict[str, Any]] = None) -> List[str]:
196
219
  """What the kernel generator reads of a stabilization of ``method``: ``tau`` (and ``lagged`` for SUPG and ASGS),
197
- and the shock-capturing block's four keys (or its explicit ``none``)."""
220
+ and the shock-capturing block's four keys (or its explicit ``none``; ``reference`` is not asked for when the block states
221
+ ``beta`` 1, the classical form, which never reads it). Method ``none`` needs no statement that there
222
+ is no shock capturing (it says so); only a shock-capturing block it does state must be complete."""
198
223
  takes = TAKES[method]
199
224
  needs = [k for k in ("tau", "lagged") if k in takes]
200
225
  if "shock_capturing" in takes:
201
226
  sc = (resolved or {}).get("shock_capturing", "unstated")
202
- needs.append("shock_capturing")
227
+ if method != "none":
228
+ needs.append("shock_capturing")
203
229
  if isinstance(sc, dict):
204
- needs += ["shock_capturing." + k for k in SHOCK_CAPTURING_KEYS]
230
+ needs += ["shock_capturing." + k for k in SHOCK_CAPTURING_KEYS
231
+ if not (k == "reference" and _classical(sc))]
205
232
  return needs
206
233
 
207
234
 
235
+ def _classical(shock_capturing: Dict[str, Any]) -> bool:
236
+ """Whether a shock-capturing block states ``beta`` 1: the classical form ``factor |R| / sqrt(∇uᵀ G ∇u)``, in which the
237
+ reference value of the unknown does not enter (proteus's RDLS). An unstated ``beta`` is not 1."""
238
+ try:
239
+ return float(shock_capturing["beta"]) == 1.0
240
+ except (KeyError, TypeError, ValueError):
241
+ return False
242
+
243
+
208
244
  def _has(resolved: Dict[str, Any], dotted: str) -> bool:
209
245
  here: Any = resolved
210
246
  for part in dotted.split("."):
@@ -210,7 +210,7 @@ class Space:
210
210
  "lap": lambda e: self.div(self.grad(e)),
211
211
  "identity": sympy.eye(self.dim),
212
212
  "pi": sympy.pi, "E": sympy.E,
213
- "sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan,
213
+ "sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "atan": sympy.atan,
214
214
  "exp": sympy.exp, "log": sympy.log, "sqrt": sympy.sqrt,
215
215
  "sinh": sympy.sinh, "cosh": sympy.cosh, "tanh": sympy.tanh,
216
216
  "abs": sympy.Abs, "Abs": sympy.Abs, "hypot": hypot,
@@ -23,8 +23,8 @@ Expressions
23
23
  ``² ³ ⁴``; implicit multiplication (``2π²κt``, ``κ ΔT``, ``sin(πx)``);
24
24
  ``·`` (a dot product of vectors, a product otherwise) and ``⊗``
25
25
  (outer product, binding tighter than ``·`` and ``*``); tuples
26
- ``(a, b)`` are vectors; functions sin cos tan exp log sqrt sinh cosh
27
- tanh abs, the sharp ones heaviside sign min max (min and max of any
26
+ ``(a, b)`` are vectors; functions sin cos tan atan exp log sqrt sinh
27
+ cosh tanh abs, the sharp ones heaviside sign min max (min and max of any
28
28
  number of arguments), and on vectors and tensors norm(v) = sqrt(v·v)
29
29
  and sym(A) = (A + Aᵀ)/2.
30
30
  Differential operators, each applied to the operand that follows it
@@ -36,8 +36,9 @@ single-letter names (``πx`` is π·x) when every letter is known, and is an
36
36
  error otherwise -- so a misspelt coefficient is reported, not multiplied.
37
37
 
38
38
  Equations are ``lhs = rhs``, optionally followed by ``in <region>``, which
39
- is ignored. Predicates (boundary regions) are ``a = b`` tests joined by
40
- ``and`` and ``or``. Domains are ``Ω = I × I [× I]`` with intervals
39
+ is ignored. Predicates (boundary regions, and the part of a region a
40
+ condition holds on) are ``a = b`` tests and comparisons ``a ≤ b``, ``a < b``
41
+ (``≥ >``, ``<= >=``; chained, ``0.4 ≤ y ≤ 0.6``) joined by ``and`` and ``or``. Domains are ``Ω = I × I [× I]`` with intervals
41
42
  ``[a, b]``, optionally followed by ``, t ∈ (t0, t1]``. Assignments
42
43
  (analytical solutions) are ``name = expr`` lines; ``T(x, y, t) = ...`` is
43
44
  accepted, and a name that is not an unknown becomes a local definition
@@ -83,7 +84,7 @@ def _sqrt(a):
83
84
 
84
85
 
85
86
  _FUNCTIONS = {
86
- "sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "exp": sympy.exp,
87
+ "sin": sympy.sin, "cos": sympy.cos, "tan": sympy.tan, "atan": sympy.atan, "exp": sympy.exp,
87
88
  "log": sympy.log, "sqrt": _sqrt, "sinh": sympy.sinh, "cosh": sympy.cosh,
88
89
  "tanh": sympy.tanh, "abs": sympy.Abs,
89
90
  # sqrt(a² + b²) rounded once (C99 hypot), so that a formula can match code
@@ -113,6 +114,16 @@ def _sym(a):
113
114
  return (a + a.T) / 2
114
115
 
115
116
 
117
+ #: a predicate's tests, as code over the difference d = lhs - rhs and the tolerance ``tol``
118
+ _COMPARISONS = {
119
+ "=": "abs(%s) <= tol",
120
+ "≤": "%s <= tol", "<=": "%s <= tol",
121
+ "≥": "-(%s) <= tol", ">=": "-(%s) <= tol",
122
+ "<": "%s < -tol",
123
+ ">": "-(%s) < -tol",
124
+ }
125
+
126
+
116
127
  class Parser:
117
128
  """Parse notation against a :class:`~ymf.symbolic.language.Space`."""
118
129
 
@@ -358,7 +369,13 @@ class Parser:
358
369
  return [sympy.sympify(residual)]
359
370
 
360
371
  def predicate(self, text: str) -> Optional[str]:
361
- """'x = 0 or y = H' -> numpy-free code using ``tol``; None for the whole boundary."""
372
+ """'x = 0 or y = H' -> numpy-free code using ``tol``; None for the whole boundary.
373
+
374
+ A test is ``a = b`` (within ``tol``) or a comparison ``a ≤ b``, ``a ≥ b`` (also ``<=``, ``>=``; within ``tol``,
375
+ so a closed bound keeps the points on it) or ``a < b``, ``a > b`` (by more than ``tol``, so an open bound drops
376
+ them); comparisons chain, ``0.4 ≤ y ≤ 0.6``. Tests join with ``and``, which binds tighter than ``or``. A part of
377
+ a face is ``x = 0 and 0.4 ≤ y ≤ 0.6``.
378
+ """
362
379
  stripped = text.strip()
363
380
  if stripped in ("∂Ω", "∂ Ω", "boundary"):
364
381
  return None
@@ -369,9 +386,15 @@ class Parser:
369
386
  tests = []
370
387
  while True:
371
388
  lhs = self._sum()
372
- self._expect("=")
373
- rhs = self._sum()
374
- tests.append("abs(%s) <= tol" % to_code(lhs - rhs))
389
+ op = self._take()
390
+ if op[1] not in _COMPARISONS:
391
+ self._fail("expected '=' or a comparison (≤ ≥ < >)", op)
392
+ while True:
393
+ rhs = self._sum()
394
+ tests.append(_COMPARISONS[op[1]] % to_code(lhs - rhs))
395
+ if self._peek()[1] not in _COMPARISONS or self._peek()[1] == "=":
396
+ break
397
+ lhs, op = rhs, self._take()
375
398
  if self._peek()[1] == "and":
376
399
  self._take(); continue
377
400
  break