You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AMR: Euler-Euler bubbles (bubbles_euler) and surface tension have no AMR validation #2233
bubbles_euler = T and surface_tension = T are rejected under AMR only because no AMR test exists for them.
Current behaviour
Validator: amr is incompatible with bubbles_euler = T / surface_tension = T (case_validator.py:2149).
Why
Both run through the shared RHS, which fine blocks reuse, so they likely need no code change. Surface tension's capillary source uses a curvature from volume-fraction gradients across block faces; Euler bubbles add per-cell bubble variables that prolongation and restriction already move like other conserved variables. Neither has been run under AMR.
Add one AMR golden each (e.g. a refined bubble screen; a refined static/oscillating droplet), check against a uniform fine grid, then lift the gate.
Done when
Two AMR goldens on CPU and GPU, gate removed, docs updated.
Context: AMR landed in #2117 (merged as eb63cfa). This issue is one of the follow-ups listed in that PR's "Known limitations and follow-ups" section; line links are pinned to that commit. Drafted with Claude Code.
Correction to the issue: neither feature is test-only; the gate cannot simply be lifted. Found in the code:
Surface tension: s_get_capillary ends with s_populate_capillary_buffers (src/simulation/m_surface_tension.fpp:306), which has no fine-advance guard (only s_populate_variables_buffers has one, m_boundary_common.fpp:103). On a fine block it would run the rank's MPI exchange or physical BC on c_divs with swapped extents (m_boundary_common.fpp:239-241). And the flux registers capture flux_src_rsx_vf for momentum and energy only if (viscous) (m_amr_registers.fpp:425), but the capillary flux is written there (m_riemann_solver_hllc.fpp:1692-1693, applied at m_rhs.fpp:1914-1925), so inviscid capillary cases would not reflux it.
Euler bubbles: the coarse post-RK s_comp_alpha_from_n (adv_n, m_time_steppers.fpp:590) has no fine twin in s_amr_batch_post_rk_hooks; adap_dt integrates the bubble ODE on level 0 only (s_adaptive_dt_bubble, m_time_steppers.fpp:473, :659, :675) while the RHS source is skipped (m_rhs.fpp:910), so fine blocks would get no bubble dynamics; s_compute_ptilde (m_rhs.fpp:921) would overwrite the coarse probe field ptil from the fine frame.
Approach – Two small PRs, one per feature, each fixing the listed seams and adding goldens. Bubble variables are ordinary entries of sys_size, so prolongation, restriction and the advective reflux already cover them; the bubble source is cell-local with scratch sized to m_alloc (m_bubbles_EE.fpp:56-64). Rejected: lifting both gates in one PR; the failure modes are unrelated.
Steps
Surface tension
m_surface_tension.fpp, s_get_capillary (l.247): when amr_in_fine_advance, run the gradient and norm loops over idwbuff%beg + 1 : idwbuff%end - 1 in each active direction (ghost primitives are filled) and skip s_populate_capillary_buffers. The capillary "reconstruction" is piecewise constant (l.316-338), so one valid ghost layer of c_divs is all the faces -1..m need. Use loop-bound locals so the coarse path is textually unchanged.
m_amr_registers.fpp:425: if (viscous .or. surface_tension). Coarse and fine share s_amr_capture_total, so both sides change together.
No swap entry: c_divs, gL_x, gR_x are scratch sized to idwbuff_alloc.
Euler bubbles
4. m_amr_frame.fpp: new s_amr_comp_alpha_fine() (new name) shaped like s_amr_cont_damage_fine (l.81) calling s_comp_alpha_from_n(amr_cons_br); call it in s_amr_batch_post_rk_hooks where the coarse order has it (after pressure relaxation, before IB) and add adv_n to the condition at m_amr_advance.fpp:200.
5. m_rhs.fpp:921: add .and. .not. amr_in_fine_advance to the s_compute_ptilde call.
6. Keep adap_dt with bubbles_euler rejected under AMR (narrowed gate); a fine twin of s_adaptive_dt_bubble needs per-block divu, which is only valid right after that block's RHS.
Validator and docs
case_validator.py:2149: drop bubbles_euler and surface_tension from the loop; add prohibits for bubbles_euler and adap_dt, bubbles_euler and num_fluids > 1 and bubbles_euler and amr_prolong == 2 (see Risks). Update the comment at :2141.
AMR_VETTED_FLAGS: add "bubbles_euler", "surface_tension" (adv_n, polytropic, polydisperse are already there).
amr.md: move both out of "Not supported"; note that dt must satisfy the finest level's capillary limit in lock-step.
Tests (cases.py)
Bubbles: AMR variants in alter_bubbles (l.1848) or amr_golden_tests: 1D bubble screen (as examples/1D_poly_bubscreen) with a static block over the screen and a regrid variant; one with adv_n = T; one polydisperse.
Surface tension: 2D static droplet (see alter_capillary, l.506) with the block cutting the interface, and an oscillating droplet with regrid; np = 2 with the block across the rank seam (this is the case step 1 fixes).
Verification: uniform bubbly state stays uniform (free-stream); total mass, momentum and energy at round-off with capillary flux active and viscous = F (fails without step 2); restricted fine solution vs uniform fine run converges at the scheme order; static-droplet parasitic currents no larger than the uniform fine run's.
amr = F goldens unchanged.
Risks and open questions
Volume-fraction closure: prolongation closes alpha_n = 1 - sum when num_fluids > 1 unless bubbles_lagrange (m_amr_ghost.fpp:126, m_amr_transfer.fpp:459, :526, :532). I did not determine how eqn_idx%adv is laid out for bubbles_euler with num_fluids > 1, hence the proposed gate.
The quartic guard checks density and internal energy only; n*R and the void fraction can go non-positive, and nbub is a root of their ratio.
The bubble source kernel runs over the whole slab, including padding cells of smaller members (finite filler, m_amr_store.fpp:485); f_rddot on filler must not trap.
Non-conservative terms (alpha div u, the colour-function term at m_rhs.fpp:1900-1909) are not refluxed, as for the existing multi-fluid K div u term.
Size and order – S each (M together with tests). Bubbles must land before qbmm.
Plan drafted with Claude Code from a read of master at eb63cfa (path:line references are to that commit). Nothing here has been implemented or run; items marked as unverified need checking before they are relied on.
Sweep result (information only, no fix). I reran every non-AMR test in the suite with one static refined block added and the AMR validator gates turned into notes (Frontier, MI250X, amdflang, OpenMP offload, master at 53957c0; two block placements).
For the tests gated on bubbles_euler, qbmm and surface_tension:
None failed in the solver. Every failure among the bubble and QBMM tests was the block sitting over the acoustic source, which the solver correctly refuses ("amr with acoustic_source: the source support overlaps a fine block"). That is my block placement, not a bubble problem.
Euler-Euler bubbles without QBMM: 17 to 18 tests ran. Most match the uniform-grid golden exactly, which mainly says the block sat in a uniform region of those cases; two differ by a large amount in a near-zero field and I have not looked at them.
QBMM: 12 tests ran, all matching the golden to 3e-12 or better. Same caveat: this is a free-stream check, not evidence the bubble source is right on a fine block.
Surface tension: 5 tests ran, with a relative L1 difference from the golden of 5e-5 to 3e-2 with the block across the interface.
So the plan above still stands (neither gate can simply be lifted from this evidence), but nothing crashed, hung or went NaN. The next step is a comparison against a uniform fine-grid run with the block placed over a bubble cloud that is actually evolving, away from the acoustic source.
Surface tension with a block: compared against a fine-grid run; not ready to lift.
Case: 2D -> 2 Fluid(s) -> weno_order=5 -> surface_tension=T -> int_comp=1 (50 x 40, 50 steps), run three ways: coarse uniform (C), coarse with a static block over cells 6..30 x 6..25 (A, validator gate bypassed), and uniform at twice the resolution (F). L1 difference from F restricted to the coarse grid, relative to the L1 norm of F (absolute where F is zero), in the output variables. Frontier, MI250X, amdflang, OpenMP offload.
C against F
A against F
all variables but one
1.0e-3 to 6.2e-1
the same as C to two digits
one momentum/velocity component, exactly zero in C and F
0
3.3e-2
The same case with surface_tension = F (and mpp_lim = T, which AMR requires): A again equals C in every variable, and the zero component is 2.8e-3 in A.
What this says:
The block does not improve this case with or without surface tension, so it is a poor test of whether the capillary term is right on a block. A case where the block covers the interface and the error is dominated there is needed.
A component that is exactly zero on both uniform grids becomes nonzero with a block even without surface tension, so part of the 3.3e-2 is a general block effect and not the capillary term. The same thing appears in the plain 2D case in AMR: allow Riemann-extrapolation boundaries (bc = -4) (fixes #2238) #2267. I have not traced it.
The surface-tension A run was made without mpp_lim, which the validator requires for AMR with more than one fluid, so the factor of 12 between the two numbers is not a clean measurement of the capillary term.
So the gate stays. Next steps: trace the nonzero component in the plain 2D case first, then repeat this with mpp_lim = T and a block that covers the interface.
Where the extra momentum is: the test is a y-directed shock tube whose fluid interface sits at y = 0.1, two coarse cells below the block's lower edge, so the interface lies in the block's ghost band and crosses the block's two side faces. The x-momentum that is zero on uniform grids appears only at those two side faces, in the rows around the interface. It is antisymmetric between the two faces.
run
summed abs x-momentum
no surface tension, mpp_lim = T
2.8e-3
surface tension, mpp_lim = F
3.3e-2
surface tension, mpp_lim = T
3.3e-2
surface tension, mpp_lim = T, capillary gradient computed in the first ghost layer on fine frames (below)
3.3e-2
What I ruled out:
mpp_lim: no effect.
The capillary ghost fill.s_get_capillary fills the ghost cells of the colour-function gradient with s_populate_capillary_buffers, which has no amr_in_fine_advance guard, so on a fine frame it applies physical boundary conditions at block faces. That is wrong in principle, and I tried the obvious fix (compute the gradient one layer into the coarse-filled ghosts and skip the boundary fill on fine frames). It changed the result in the third digit only, so it is not the cause here. I did not push it.
What I think it is, not verified: the same coarse-fine mismatch that gives 2.8e-3 without surface tension, amplified by the capillary stress. The stress scales with the magnitude of the colour gradient, and a diffuse interface is about twice as sharp on the fine level as on the coarse one. Where the interface crosses a side face, the stress on the two sides differs at leading order, which is a transverse force. With sigma = 1 and pressures of order 1 that is large.
If that is right, this case can never pass, and the missing piece is a rule or a test where the interface stays inside the block: a droplet or bubble fully covered by the block, compared against a fine-grid run on the Laplace pressure jump. I tried a block spanning the full width of this case to remove the side faces, but the validator rejects it (a block's fine extent may not exceed the base grid).
So the gate stays, and the next step is the droplet-in-block comparison.
Droplet inside a block: Laplace pressure jump improves, spurious currents at the block faces get worse.
Case: examples/2D_laplace_pressure_jump changed to a full droplet centred in the domain (radius 0.06, 8 coarse cells), 50 x 50, sigma = 8, 6-equation model, mpp_lim = T, extrapolation boundaries, 20000 steps (t = 0.1, about 100 acoustic crossings). Three runs: coarse uniform (C), coarse with a static block over cells 13..36 in each direction (A, validator gate bypassed, master at 53957c0), and uniform 100 x 100 (F). The block edge is 4 coarse cells outside the nominal interface. Frontier, MI250X, amdflang, OpenMP offload.
C
A (block)
F
pressure jump, inside minus outside
135.41
134.83
133.50
pressure spread inside the droplet (max minus min, r < R/2)
3.77
0.75
0.99
pressure spread far outside (r > 2R)
0.08
0.31
0.07
maximum speed
0.131
0.213
0.084
where the maximum speed is
r = 1.59 R
r = 1.59 R
r = 1.46 R
Theory: sigma/R = 133.3 for the nominal radius, 132.5 to 133.1 for the effective radii of the three runs.
Reading:
The capillary term on the block is doing the right thing to first order: the jump moves from the coarse value toward the fine one, and the pressure inside the droplet is as uniform as on the fine grid.
The spurious currents are 60% larger than on the coarse grid and sit at r = 1.59 R, which is the block face (0.09 from the centre is 1.5 R). The far-field pressure is also noisier. So something at the coarse-fine face drives flow that neither uniform grid has. The tail of the smoothed interface still reaches the face in this setup, so this may be the same sharpness mismatch as in the slab case, or the unguarded capillary ghost fill noted above; this run does not separate them.
So this is not a pass, and the gate stays. To finish it: repeat with a wider margin between the interface and the block face (a larger domain, since a block cannot exceed half the grid), and with the ghost-gradient change applied, and see which removes the excess.
I only compared at one time, without time-averaging, so the speed figures carry whatever oscillation phase each run was in.
Surface tension (needs research). The capillary ghost fill is unguarded on fine frames. The registers capture the capillary flux only if (viscous). The spurious currents at block faces are unexplained.
Activity
sbryngelson commentedon Nov 13, 2026
Implementation plan
Correction to the issue: neither feature is test-only; the gate cannot simply be lifted. Found in the code:
s_get_capillaryends withs_populate_capillary_buffers(src/simulation/m_surface_tension.fpp:306), which has no fine-advance guard (onlys_populate_variables_buffershas one,m_boundary_common.fpp:103). On a fine block it would run the rank's MPI exchange or physical BC onc_divswith swapped extents (m_boundary_common.fpp:239-241). And the flux registers captureflux_src_rsx_vffor momentum and energy onlyif (viscous)(m_amr_registers.fpp:425), but the capillary flux is written there (m_riemann_solver_hllc.fpp:1692-1693, applied atm_rhs.fpp:1914-1925), so inviscid capillary cases would not reflux it.s_comp_alpha_from_n(adv_n,m_time_steppers.fpp:590) has no fine twin ins_amr_batch_post_rk_hooks;adap_dtintegrates the bubble ODE on level 0 only (s_adaptive_dt_bubble,m_time_steppers.fpp:473,:659,:675) while the RHS source is skipped (m_rhs.fpp:910), so fine blocks would get no bubble dynamics;s_compute_ptilde(m_rhs.fpp:921) would overwrite the coarse probe fieldptilfrom the fine frame.Approach – Two small PRs, one per feature, each fixing the listed seams and adding goldens. Bubble variables are ordinary entries of
sys_size, so prolongation, restriction and the advective reflux already cover them; the bubble source is cell-local with scratch sized tom_alloc(m_bubbles_EE.fpp:56-64). Rejected: lifting both gates in one PR; the failure modes are unrelated.Steps
Surface tension
m_surface_tension.fpp,s_get_capillary(l.247): whenamr_in_fine_advance, run the gradient and norm loops overidwbuff%beg + 1 : idwbuff%end - 1in each active direction (ghost primitives are filled) and skips_populate_capillary_buffers. The capillary "reconstruction" is piecewise constant (l.316-338), so one valid ghost layer ofc_divsis all the faces-1..mneed. Use loop-bound locals so the coarse path is textually unchanged.m_amr_registers.fpp:425:if (viscous .or. surface_tension). Coarse and fine shares_amr_capture_total, so both sides change together.c_divs,gL_x,gR_xare scratch sized toidwbuff_alloc.Euler bubbles
4.
m_amr_frame.fpp: news_amr_comp_alpha_fine()(new name) shaped likes_amr_cont_damage_fine(l.81) callings_comp_alpha_from_n(amr_cons_br); call it ins_amr_batch_post_rk_hookswhere the coarse order has it (after pressure relaxation, before IB) and addadv_nto the condition atm_amr_advance.fpp:200.5.
m_rhs.fpp:921: add.and. .not. amr_in_fine_advanceto thes_compute_ptildecall.6. Keep
adap_dtwithbubbles_eulerrejected under AMR (narrowed gate); a fine twin ofs_adaptive_dt_bubbleneeds per-blockdivu, which is only valid right after that block's RHS.Validator and docs
case_validator.py:2149: dropbubbles_eulerandsurface_tensionfrom the loop; add prohibits forbubbles_euler and adap_dt,bubbles_euler and num_fluids > 1andbubbles_euler and amr_prolong == 2(see Risks). Update the comment at:2141.AMR_VETTED_FLAGS: add"bubbles_euler","surface_tension"(adv_n,polytropic,polydisperseare already there).amr.md: move both out of "Not supported"; note thatdtmust satisfy the finest level's capillary limit in lock-step.Tests (
cases.py)alter_bubbles(l.1848) oramr_golden_tests: 1D bubble screen (asexamples/1D_poly_bubscreen) with a static block over the screen and a regrid variant; one withadv_n = T; one polydisperse.alter_capillary, l.506) with the block cutting the interface, and an oscillating droplet with regrid; np = 2 with the block across the rank seam (this is the case step 1 fixes).viscous = F(fails without step 2); restricted fine solution vs uniform fine run converges at the scheme order; static-droplet parasitic currents no larger than the uniform fine run's.amr = Fgoldens unchanged.Risks and open questions
alpha_n = 1 - sumwhennum_fluids > 1unlessbubbles_lagrange(m_amr_ghost.fpp:126,m_amr_transfer.fpp:459,:526,:532). I did not determine howeqn_idx%advis laid out forbubbles_eulerwithnum_fluids > 1, hence the proposed gate.n*Rand the void fraction can go non-positive, andnbubis a root of their ratio.m_amr_store.fpp:485);f_rddoton filler must not trap.alpha div u, the colour-function term atm_rhs.fpp:1900-1909) are not refluxed, as for the existing multi-fluidK div uterm.Size and order – S each (M together with tests). Bubbles must land before
qbmm.Plan drafted with Claude Code from a read of master at eb63cfa (
path:linereferences are to that commit). Nothing here has been implemented or run; items marked as unverified need checking before they are relied on.sbryngelson commentedon Nov 14, 2026
Sweep result (information only, no fix). I reran every non-AMR test in the suite with one static refined block added and the AMR validator gates turned into notes (Frontier, MI250X, amdflang, OpenMP offload, master at 53957c0; two block placements).
For the tests gated on
bubbles_euler,qbmmandsurface_tension:So the plan above still stands (neither gate can simply be lifted from this evidence), but nothing crashed, hung or went NaN. The next step is a comparison against a uniform fine-grid run with the block placed over a bubble cloud that is actually evolving, away from the acoustic source.
Run with Claude Code.
sbryngelson commentedon Nov 15, 2026
Surface tension with a block: compared against a fine-grid run; not ready to lift.
Case:
2D -> 2 Fluid(s) -> weno_order=5 -> surface_tension=T -> int_comp=1(50 x 40, 50 steps), run three ways: coarse uniform (C), coarse with a static block over cells 6..30 x 6..25 (A, validator gate bypassed), and uniform at twice the resolution (F). L1 difference from F restricted to the coarse grid, relative to the L1 norm of F (absolute where F is zero), in the output variables. Frontier, MI250X, amdflang, OpenMP offload.The same case with
surface_tension = F(andmpp_lim = T, which AMR requires): A again equals C in every variable, and the zero component is 2.8e-3 in A.What this says:
mpp_lim, which the validator requires for AMR with more than one fluid, so the factor of 12 between the two numbers is not a clean measurement of the capillary term.So the gate stays. Next steps: trace the nonzero component in the plain 2D case first, then repeat this with
mpp_lim = Tand a block that covers the interface.Checked with Claude Code.
sbryngelson commentedon Nov 15, 2026
Surface tension with a block: traced further.
Where the extra momentum is: the test is a y-directed shock tube whose fluid interface sits at y = 0.1, two coarse cells below the block's lower edge, so the interface lies in the block's ghost band and crosses the block's two side faces. The x-momentum that is zero on uniform grids appears only at those two side faces, in the rows around the interface. It is antisymmetric between the two faces.
mpp_lim = Tmpp_lim = Fmpp_lim = Tmpp_lim = T, capillary gradient computed in the first ghost layer on fine frames (below)What I ruled out:
mpp_lim: no effect.s_get_capillaryfills the ghost cells of the colour-function gradient withs_populate_capillary_buffers, which has noamr_in_fine_advanceguard, so on a fine frame it applies physical boundary conditions at block faces. That is wrong in principle, and I tried the obvious fix (compute the gradient one layer into the coarse-filled ghosts and skip the boundary fill on fine frames). It changed the result in the third digit only, so it is not the cause here. I did not push it.What I think it is, not verified: the same coarse-fine mismatch that gives 2.8e-3 without surface tension, amplified by the capillary stress. The stress scales with the magnitude of the colour gradient, and a diffuse interface is about twice as sharp on the fine level as on the coarse one. Where the interface crosses a side face, the stress on the two sides differs at leading order, which is a transverse force. With
sigma = 1and pressures of order 1 that is large.If that is right, this case can never pass, and the missing piece is a rule or a test where the interface stays inside the block: a droplet or bubble fully covered by the block, compared against a fine-grid run on the Laplace pressure jump. I tried a block spanning the full width of this case to remove the side faces, but the validator rejects it (a block's fine extent may not exceed the base grid).
So the gate stays, and the next step is the droplet-in-block comparison.
Checked with Claude Code.
sbryngelson commentedon Nov 15, 2026
Droplet inside a block: Laplace pressure jump improves, spurious currents at the block faces get worse.
Case:
examples/2D_laplace_pressure_jumpchanged to a full droplet centred in the domain (radius 0.06, 8 coarse cells), 50 x 50,sigma = 8, 6-equation model,mpp_lim = T, extrapolation boundaries, 20000 steps (t = 0.1, about 100 acoustic crossings). Three runs: coarse uniform (C), coarse with a static block over cells 13..36 in each direction (A, validator gate bypassed, master at 53957c0), and uniform 100 x 100 (F). The block edge is 4 coarse cells outside the nominal interface. Frontier, MI250X, amdflang, OpenMP offload.Theory:
sigma/R= 133.3 for the nominal radius, 132.5 to 133.1 for the effective radii of the three runs.Reading:
So this is not a pass, and the gate stays. To finish it: repeat with a wider margin between the interface and the block face (a larger domain, since a block cannot exceed half the grid), and with the ghost-gradient change applied, and see which removes the excess.
I only compared at one time, without time-averaging, so the speed figures carry whatever oscillation phase each run was in.
Run with Claude Code.
sbryngelson commentedon Nov 27, 2026
Plan from the AMR triage: M each.
adv_nfine hook is already on master (m_stage_hooks), so step 4 of the plan is done. Still needed:s_compute_ptildeon fine frames;adap_dtwith bubbles under AMR, since it runs the bubble ODE on level 0 only;if (viscous). The spurious currents at block faces are unexplained.(Posted with Claude Code.)
sbryngelson commentedon Nov 28, 2026
Where the rest of this issue went.
This issue can close when #2539 merges.
(Posted with Claude Code.)