Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ rediscover why a thing is the way it is. Open gaps are in

## 2026-11

- **2026-11-18: 0.3.1, a stabilization without a method (C42 round 6).** ymf 0.3.0 required `method` in every
`stabilization:` block, so proteus's RDLS block (`stabilization: {shock_capturing: {factor: 0.9, lag: false}}`, read
as a free map by ymf 0.2) no longer loaded, and `test/dispatch` broke on every proteus PR. Now `method: none` is a
word (no residual-based method; it reads only `shock_capturing`), the bare `stabilization: none` says a sub-problem is
not stabilized at all (MCorr, PresInc), and a block that states only `shock_capturing` loads and means exactly
that, `method: none` plus that shock capturing; ymf picks no method for it and fills in no key. `tau` or `lagged`
without a method are refused (they belong to one). `ymf.stabilization.missing(block)` still lists what a reader that
must not guess needs: under `none` an unstated `shock_capturing` is not missing (the word says there is none), a
stated block must be complete (`beta`, `reference` for RDLS's). A spec written before 2026-11-17 loads unchanged:
proteus's own `test/dispatch/dambreak.ymf` and `two_phase_level_set.ymf` (`cekees/main` b9d98f5d) are fixtures
(`tests/fixtures/proteus_dispatch_0_2/`), loaded, resolved and round-tripped through an archive with the same key.
Suite 1032 -> 1048. What proteus's RDLS actually applies (SUPG with `tau: metric`, not lagged, and a classical
`beta` 1 shock capturing) is in `HANDOFF_2026-11-18_ymf-r6.md`: the old block was incomplete, not wrong to load.

- **2026-11-17: C42 round 5, the formulation a generator and a dispatcher read (C19 spike report, C5 step 4 part 2).**
The generator spike could not generate what the spec did not say (stabilization, shock capturing, lagging, boundary
kind, porosity) and C5 could not state a dispersive model or a mesh of a box that is not square. Now the spec states
Expand Down
24 changes: 23 additions & 1 deletion docs/problem-specification.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ checked on load, so that a second solver reads the same ones:
| model family (`physical_model.family`) | `two_phase_level_set`, `shallow_water`, `dispersive_shallow_water` |
| 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` |
| `time_integration` | `backward_euler`, `bdf2`, `ssp_rk3`, `none` |
| `stabilization.method` | `ASGS`, `SUPG`, `residual_shock_capturing`, `entropy_viscosity`, `graph_viscosity_smoothness`, `graph_viscosity_entropy_residual` |
| `stabilization.method` | `ASGS`, `SUPG`, `residual_shock_capturing`, `entropy_viscosity`, `graph_viscosity_smoothness`, `graph_viscosity_entropy_residual`, `none` |
| `discretization.scheme` and its options | `graph_viscosity_convex_limiting`: `entropy_viscosity_coefficient`, `lumped_mass`, `bounds_relaxation` (and `time_integration`, `outputs`, `dt` for every scheme) |
| `step_control.type` | `min_cfl`, `fixed` |
| `regularize.*.by` | `smoothed_heaviside`, `smoothed_sign`, `wet_dry_cutoff` |
Expand Down Expand Up @@ -967,6 +967,28 @@ the entropy and graph viscosities read none (their parameters are the scheme's o
`reference` positive, `factor` non-negative. `lag`, `sc_beta`, `sc_uref` (the keys proteus's dispatcher read first) are
accepted and resolve to `lagged`, `beta`, `reference`.

*No method, and shock capturing alone* (0.3.1). `method: none` says the sub-problem has no residual-based method; it reads
only `shock_capturing`. Three statements, three meanings:

```yaml
stabilization: none # not stabilized at all, shock capturing included (MCorr, PresInc, a projection)
stabilization: {method: none, shock_capturing: {factor: 0.9, lagged: false}} # shock capturing and no method
stabilization: {shock_capturing: {factor: 0.9, lagged: false}} # the same: a block without `method`
```

A block with `shock_capturing` and no `method` is the second one, exactly: ymf never picks a method for a block that
does not name one (it is neither `SUPG` nor `residual_shock_capturing`, which also takes `tau`), and `tau` or `lagged`
without a method are refused, because they belong to a method. `resolve` returns `{"method": "none", ...}` for all
three and adds no other key.

*What a reader that must not guess still needs: `ymf.stabilization.missing(block)`.* It returns the dotted keys the
kernel generator reads that the block does not state, and nothing is filled in: `missing("SUPG")` is `["tau", "lagged",
"shock_capturing"]`; with `shock_capturing: {factor: 0.9, lagged: false}` stated it also asks for `shock_capturing.beta` and
`.reference` (stating `shock_capturing: none` answers the block as a whole); the entropy and graph viscosities need
nothing. For `none`, an unstated `shock_capturing` is not missing (the word says there is none); a `shock_capturing`
block it does state must be complete, so `missing({"shock_capturing": {"factor": 0.9, "lag": False}})` is
`["shock_capturing.beta", "shock_capturing.reference"]` and `missing("none")` is `[]`.

**Lagging** (`lagged_coefficients`): `{μ: previous_iterate, ρ: previous_step}` says which of the model's coefficients
a sub-problem freezes, in the Newton iteration (a Picard step: the Jacobian drops the dependence) or in time (a
constant of the step). A field read from another sub-problem is `lags`; a stabilization's lag is its `lagged`.
Expand Down
3 changes: 2 additions & 1 deletion src/ymf/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,10 @@
}
)

# A block without ``method`` states shock capturing alone (``method: none``), ymf.stabilization.resolve.
StabilizationDef = Str() | Map(
{
"method": Str(),
Optional("method"): Str(),
Optional("tau"): Str(),
Optional("lagged"): Bool(),
Optional("lag"): Bool(),
Expand Down
37 changes: 31 additions & 6 deletions src/ymf/stabilization.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
reference: 1.0 # the reference value of the unknown (sc_uref)
lagged: true # the viscosity taken from the previous step (ShockCapturing lag)
stabilization: {method: SUPG, shock_capturing: none} # none, stated: the solver adds no shock capturing
stabilization: none # nothing: no method, no shock capturing (MCorr, a projection)
stabilization: {shock_capturing: {factor: 0.9}} # shock capturing with no method (proteus's RDLS block of 0.2)

What it is for. The generator (C19) turned VOF and NCLS into a functor each, but the SUPG tau, the shock capturing and
their lag are the engine template's, and the template took them from the model's name (``dambreak.ymf`` stated none: the
Expand All @@ -28,6 +30,11 @@

Which keys a method takes:

* ``none``: no residual-based method. It takes only ``shock_capturing``: ``stabilization: none`` (or ``method: none``)
says that the sub-problem is not stabilized at all, shock capturing included; ``{method: none, shock_capturing:
{factor: 0.9}}`` says shock capturing and nothing else. A block that states ``shock_capturing`` and no ``method`` is
exactly that second one (ymf 0.2 read such a block, proteus's RDLS stated one; 0.3.0 refused it; resolve gives it
``method: none``). This is a meaning, not a default: ymf never picks a method for a block that does not name one.
* ``SUPG``, ``ASGS``: ``tau``, ``lagged``, ``shock_capturing`` (the residual-based viscosity added to the method).
* ``residual_shock_capturing``: the shock-capturing viscosity alone: ``tau``, ``shock_capturing`` (its block says how much;
unstated, the solver's own coefficient applies).
Expand All @@ -53,6 +60,7 @@ class StabilizationError(ValueError):

#: method -> the keys of the block it reads (beside ``method``)
TAKES: Dict[str, tuple] = {
"none": ("shock_capturing",),
"SUPG": ("tau", "lagged", "shock_capturing"),
"ASGS": ("tau", "lagged", "shock_capturing"),
"residual_shock_capturing": ("tau", "shock_capturing"),
Expand Down Expand Up @@ -139,13 +147,28 @@ def _shock_capturing(block: Any, where: str) -> Optional[Dict[str, Any]]:

def resolve(block: Any, where: str = "stabilization") -> Dict[str, Any]:
"""The stabilization as a block with ymf's words and every stated key kept: ``{method, tau?, lagged?,
shock_capturing?}``, ``shock_capturing`` a dict, or ``None`` when the spec says ``none``. Nothing is added.
Raises :class:`StabilizationError`."""
shock_capturing?}``, ``shock_capturing`` a dict, or ``None`` when the spec says ``none``. Nothing is added, with one
reading of what is stated: a block that gives ``shock_capturing`` and no ``method`` has ``method: none`` (shock
capturing and no residual-based method), and the bare word ``none`` is ``{"method": "none"}``, which under
:data:`TAKES` ``none`` states no shock capturing either. Raises :class:`StabilizationError`."""
if isinstance(block, str):
block = {"method": block}
if not isinstance(block, dict) or "method" not in block:
raise StabilizationError("%s: say the method (stabilization: SUPG), or give a block with method:" % (where,))
if not isinstance(block, dict):
raise StabilizationError("%s: say the method (stabilization: SUPG, or none), or give a block with method:"
% (where,))
block = _keys(block, "stabilization_key", where)
if "method" not in block:
if "shock_capturing" not in block:
raise StabilizationError(
"%s: say the method (stabilization: SUPG, or none), or give a block with method: (a block with only "
"shock_capturing has no method: none)" % (where,))
others = sorted(set(block) - {"shock_capturing"})
if others:
raise StabilizationError(
"%s: no method is stated, so the block is shock capturing and nothing else (method: none), and "
"%s %s read by a method: say which (method: SUPG, ASGS or residual_shock_capturing)"
% (where, ", ".join(others), "is" if len(others) == 1 else "are"))
block = dict(block, method="none")
method = _method(block["method"], where + ".method")
takes = TAKES[method]
unread = sorted(set(block) - {"method"} - set(takes))
Expand Down Expand Up @@ -194,12 +217,14 @@ def missing(block: Any) -> List[str]:

def generator_needs(method: str, resolved: Optional[Dict[str, Any]] = None) -> List[str]:
"""What the kernel generator reads of a stabilization of ``method``: ``tau`` (and ``lagged`` for SUPG and ASGS),
and the shock-capturing block's four keys (or its explicit ``none``)."""
and the shock-capturing block's four keys (or its explicit ``none``). Method ``none`` needs no statement that there
is no shock capturing (it says so); only a shock-capturing block it does state must be complete."""
takes = TAKES[method]
needs = [k for k in ("tau", "lagged") if k in takes]
if "shock_capturing" in takes:
sc = (resolved or {}).get("shock_capturing", "unstated")
needs.append("shock_capturing")
if method != "none":
needs.append("shock_capturing")
if isinstance(sc, dict):
needs += ["shock_capturing." + k for k in SHOCK_CAPTURING_KEYS]
return needs
Expand Down
1 change: 1 addition & 0 deletions src/ymf/vocabulary.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ def roles_of(doc: Dict[str, Any], entry: Dict[str, Any]) -> Dict[str, Optional[s
}

STABILIZATION: Dict[str, str] = {
"none": "no residual-based method (and no shock capturing unless the block states it): a projection, a correction",
"ASGS": "algebraic subgrid scale stabilization (variational multiscale)",
"SUPG": "streamline-upwind Petrov-Galerkin",
"residual_shock_capturing": "residual-based shock-capturing viscosity alone",
Expand Down
10 changes: 10 additions & 0 deletions tests/fixtures/proteus_dispatch_0_2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Specs written against ymf 0.2 / main before 2026-11-17, kept as they were, so that every ymf release still loads them
(tests/test_stabilization_compat.py). Copied byte for byte from proteus `cekees/main` b9d98f5d, `test/dispatch/`:

| file | git blob |
|---|---|
| `two_phase_level_set.ymf` | 59cb5110b87d3557718f98014f2cf6f44b54e4eb |
| `dambreak.ymf` | 88aa84631839ec89bbdbda6bd190240da22bec80 |

Do not edit them or bring them up to date: their old spellings (`lag`, `sc_beta`, `sc_uref`) and RDLS's `stabilization`
block, which states `shock_capturing` and no `method`, are what they test.
168 changes: 168 additions & 0 deletions tests/fixtures/proteus_dispatch_0_2/dambreak.ymf
Original file line number Diff line number Diff line change
@@ -0,0 +1,168 @@
# The 2-D dam break of test/TwoPhaseFlow, three ways, as discretizations of one
# model (YMF_MODEL_FAMILIES_C42 section 2.5, with ymf's tests/fixtures/two_phase
# for the case). test_dispatch.py checks that proteus.Dispatch maps each one
# onto exactly the modules and flags TwoPhaseFlow builds for its deck:
#
# level_set_five damBreakLevelSet.py RANS2P, VOF, NCLS, RDLS, MCorr
# level_set_clsvof damBreakLevelSet.py interface=1 RANS2P, CLSVOF
# clsvof_projection damBreak.py CLSVOF, RANS3PF, PresInc, Pres, PresInit
#
# All three solve the non-conservative inertia form: RANS2P's default
# (NONCONSERVATIVE_FORM = 1.0) and the only one RANS3PF has.
# The proteus: blocks are interim hints (D8): model names are checked against
# the dispatch, and eb_penalty_constant (the decks' 1e6, the table's default
# 100) is an option ymf does not type yet.
extends: two_phase_level_set.ymf

model:
name: "Dam break, 3.22 m × 1.8 m tank, 1.2 m × 0.6 m column (2-D)"
physical_model: {provenance: human_specified}
strong_form:
domain: "Ω = [0, 3.22] × [0, 1.8], t ∈ (0, 3]"
boundary_regions:
- {name: walls, where: "x = 0 or x = 3.22 or y = 0"}
- {name: top, where: "y = 1.8"}
boundary_sets:
- {region: walls, set: free_slip}
- {region: top, set: atmosphere}
initial_conditions:
- {field: v, type: constant, value: 0.0}
- {field: p, type: constant, value: 0.0}
- field: φ
type: function
formula: "sqrt(max(x − 1.2, 0)² + max(y − 0.6, 0)²) + min(max(x − 1.2, y − 0.6), 0)"
units: m
coefficients:
ρw: {value: 998.2}
νw: {value: 1.004e-6}
ρa: {value: 1.205}
νa: {value: 1.5e-5}
g: {formula: "(0, -9.8)"}

solution_paths:
analytical: []
discretizations:
- name: level_set_five
provenance: proteus_derived
from_weak_form: nonconservative_inertia
mesh: {h: 0.0322}
binds:
h: {meaning: element_size}
ε: {formula: "1.5 h"}
regularize:
heaviside: {by: smoothed_heaviside, width: ε}
step_control: {type: min_cfl, cfl: 0.25, step_exact: true}
solver: {type: nonlinear, nonlinear_solver: newton, linear_solver: iterative, max_iterations: 50}
subproblems:
- name: flow
solves: [momentum, continuity]
lags: {φ: previous_step, χ: {via: vof, at: previous_step}}
finite_element: {velocity: {family: CG, order: 1}, pressure: {family: CG, order: 1}}
time_integration: backward_euler
stabilization: {method: ASGS, lag: true, shock_capturing: {factor: 0.5, lag: true}}
solver: {max_iterations: 100}
proteus: {model: RANS2P, useVF: 1.0, eb_penalty_constant: 1.0e6}
- name: vof
introduces: {name: χh, approximates: χ, units: "1"}
equation: "∂χh/∂t + ∇·(v χh) = 0"
initial_condition: "heaviside(φ)"
lags: {v: {via: flow, at: current_step}}
finite_element: {fields: {family: CG, order: 1}}
time_integration: backward_euler
stabilization: {method: SUPG, shock_capturing: {factor: 0.5, lag: true, sc_uref: 1.0, sc_beta: 1.5}}
proteus: {model: VOF}
- name: ncls
solves: [interface]
lags: {v: {via: flow, at: current_step}}
finite_element: {fields: {family: CG, order: 1}}
time_integration: backward_euler
stabilization: {method: SUPG, shock_capturing: {factor: 0.5, lag: true, sc_uref: 1.0, sc_beta: 1.5}}
proteus: {model: NCLS}
- name: rdls
enforces: "norm(∇φ) = 1"
for: φ
equation: "sign(φs) (norm(∇φ) − 1) = 0"
lags: {φs: {of: φ, via: ncls, at: current_step}}
regularize: {sign: {by: smoothed_sign, width: εr}}
binds: {εr: {formula: "0.75 h"}}
pseudo_time: steady
writes_back: {φ: replace}
finite_element: {fields: {family: CG, order: 1}}
stabilization: {shock_capturing: {factor: 0.9, lag: false}}
proteus: {model: RDLS, epsFact: 0.75}
- name: mcorr
enforces: "heaviside(φ) = χh"
introduces: {name: φc, correction_of: φ, units: m}
equation: "heaviside(φ + φc) − χh − ∇·(εd ∇φc) = 0"
binds: {εd: {formula: "10 h"}}
lags: {φ: {via: rdls, at: current_step}, χh: {via: vof, at: current_step}}
writes_back: {φ: add}
finite_element: {fields: {family: CG, order: 1}}
time_integration: none
proteus: {model: MCorr}

# RANS2P with CLSVOF in place of the four interface solves
- name: level_set_clsvof
provenance: proteus_derived
from_weak_form: nonconservative_inertia
mesh: {h: 0.0322}
binds:
h: {meaning: element_size}
ε: {formula: "1.5 h"}
regularize:
heaviside: {by: smoothed_heaviside, width: ε}
step_control: {type: min_cfl, cfl: 0.25, step_exact: true}
solver: {type: nonlinear, nonlinear_solver: newton, linear_solver: iterative, max_iterations: 50}
subproblems:
- name: flow
solves: [momentum, continuity]
lags: {φ: previous_step, χ: {via: clsvof, at: previous_step}}
finite_element: {velocity: {family: CG, order: 1}, pressure: {family: CG, order: 1}}
time_integration: backward_euler
solver: {max_iterations: 100}
proteus: {model: RANS2P, eb_penalty_constant: 1.0e6}
- name: clsvof
solves: [interface]
enforces: "norm(∇φ) = 1"
lags: {v: {via: flow, at: current_step}}
finite_element: {fields: {family: CG, order: 1}}
time_integration: backward_euler

# damBreak.py: CLSVOF first, then the projection scheme's velocity step
# (P2), the pressure increment and update, and a pressure spin-up
- name: clsvof_projection
provenance: proteus_derived
from_weak_form: nonconservative_inertia
mesh: {h: 0.0322}
binds:
h: {meaning: element_size}
ε: {formula: "1.5 h"}
regularize:
heaviside: {by: smoothed_heaviside, width: ε}
step_control: {type: min_cfl, cfl: 0.25, step_exact: true}
solver: {type: nonlinear, nonlinear_solver: newton, linear_solver: iterative}
subproblems:
- name: clsvof
solves: [interface]
enforces: "norm(∇φ) = 1"
lags: {v: {via: flow, at: previous_step}}
solver: {max_iterations: 50}
proteus: {model: CLSVOF, disc_ICs: true}
- name: flow
solves: [momentum]
lags: {φ: {via: clsvof, at: current_step}, χ: {via: clsvof, at: current_step}, p: {via: pressure, at: previous_step}}
finite_element: {velocity: {family: CG, order: 2}}
time_integration: bdf2
solver: {max_iterations: 1}
proteus: {model: RANS3PF, eb_penalty_constant: 1.0e6}
- name: pressureInc
enforces: "∇·v = 0"
solver: {max_iterations: 50}
proteus: {model: PresInc}
- name: pressure
solves: [continuity]
lags: {v: {via: flow, at: current_step}}
proteus: {model: Pres}
- name: pressureInit
spin_up: true
proteus: {model: PresInit}
Loading
Loading