[ADDITION][FIXES] DYREL VS; Sol Benchmarks and Bug fixes - #499
Draft
aelligp wants to merge 52 commits into
Draft
Conversation
… fix a missing `γfact` in the constructor that silently overwrote whatever one set. minor: bug fixes
Picks up PR #498 (local-viscosity penalty scaling in compute_bulk_viscosity_and_penalty!). Both branches implemented the same fix independently; kept the upstream comment since the code was identical.
Deterministic, grid-based sticky-air rising-plume configuration for solve_DYREL! with a RockRatio phi, exercising every masked DYREL kernel (grad-V+strain+RP, stress, residual+damped update) with and without the free-surface stabilization term. 9/9 passing.
This reverts commit 4fb20b0.
…ar_viscosity case
aelligp
marked this pull request as draft
July 30, 2026 14:59
`docs/src/.vitepress/config.mts` is committed, so DocumenterVitepress uses it instead of substituting its own template (the build log lists a substitution for every `.vitepress` file except `config.mts`). It was a fork of the 0.2 template, so the 0.3 bump left it out of step with the new `docs/package.json`: - it imported `markdown-it-mathjax3`, which 0.3 no longer installs, failing the vitepress build with `Cannot find package 'markdown-it-mathjax3'`; - 0.3 copies in its own `VersionPicker.vue`, which reads `__DEPLOY_ABSPATH__`, defined only by the `vite.define` block the 0.2 config lacks — so restoring the npm package alone would just have moved the failure one step later. Rebase it on the 0.3.5 template, keeping our four customizations (`ignoreDeadLinks`, the custom nav, the Slack social link and the footer copyright). The nav gains the `VersionPicker` entry, which is how 0.3 renders the version dropdown. `theme/index.ts` was an unmodified copy of the 0.2 template, so delete it and let DocumenterVitepress substitute the current one. That picks up `virtual:mathjax-styles.css` (where MathJax 4's SVG styling now comes from), `docstrings.css`/`overrides.css` and the sidebar drawer toggle, and future template changes now arrive with the package. Our `theme/style.css` is untouched and still overrides the defaults. `config.mts` cannot be dropped the same way: without `ignoreDeadLinks` the build fails on two dead `./@ref` links in `man/listfunctions.md`, left by the unresolved `accumulate_tensor!` references Documenter already warns about. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`accumulate_vol!`'s docstring links to [`accumulate_tensor!`](@ref), but `accumulate_tensor!` carried no docstring, so Documenter had no binding to resolve against and warned once per module. The unresolved reference was emitted as a literal `./@ref` link, which is what the two dead links vitepress reports on `man/listfunctions` are. Give it a docstring. The reference now resolves to the generated anchor and the dead links are gone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
`ignoreDeadLinks: true` was in the vendored config to tolerate the two `./@ref` links left by the unresolved `accumulate_tensor!` reference. That reference now resolves, and a full build passes with dead-link checking on, so drop the flag instead of leaving it to swallow future broken links silently. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Merged
Fix docs build
…ax.jl into pa-dyrel_VS_2D
`CuArray` is a `StridedArray`, so the scalar-iterating methods of `noninf_stats` and `masked_extrema` captured GPU arrays and threw "Scalar indexing is disallowed". Restrict those to `Array` and give every other array type whole-array reductions over `+`, `min` and `max`, the reducers for which a device backend knows a neutral element. Assisted-by: Claude Opus 5 (claude-opus-5)
`compute_P!` reads the temperature difference at `ΔT[(I .+ 1)...]`, so the array carries one ghost node per boundary and has size `ni .+ 2`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`get_α` dispatches on `ThreePhase_Density`, which GeoParams gained in 0.7.18. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`noninf_stats` and `masked_extrema` return a tuple. Called from top-level scope that return is boxed on Julia 1.10, so `@allocated` there reports the caller's boxing rather than the reduction; from function scope both are allocation-free on every supported version. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The variational reduced space excludes velocity faces whose stencil neighbours carry no rock, which removes the sticky-air faces that used to set the maxima. Both `maxVy` and the free-surface `maxVy_fs` drop by about a third, and the two now differ by 0.12%, so the guard that keeps the stabilization term active is tightened to `rtol = 5e-4`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
# Conflicts: # docs/Project.toml # miniapps/Project.toml # miniapps/benchmarks/stokes2D/free_surface_stabilization/RayleighTaylor2D_VariationalStokes.jl # src/phases/PhaseRatios.jl # src/rheology/Melting.jl # src/stokes/StressKernels.jl # test/test_shearband2D_DYREL.jl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What is the purpose of this PR?
Summary
This PR adds a 2D variational Stokes implementation of the self-tuned dynamic-relaxation (DYREL) solver, improves the original variational APT solver, adds free-surface stabilization (FSSA), and introduces SolCx/SolKz/SolVi validation benchmarks. It also fixes correctness, conditioning, masking, boundary-condition, non-uniform-grid, and 3D stress-rotation issues uncovered during validation.
Following Larionov, Batty, and Bridson (2017), pressure, stress, and staggered velocity samples are weighted by their rock control-volume fractions, collected in diagonal matrices
W_p,W_τ, andW_u. Schematically,Variables whose constraints reference a zero-weight velocity sample are removed from the active system, eliminating the variational null spaces described in Section 5.3 of the paper.
Variational DYREL solver
_solve_DYREL!dispatch onϕ::RockRatio, mirroring the existing variational APT dispatch. DYREL remains 2D because its Gershgorin estimator is currently 2D-only.ϕ-aware Gershgorin stencil using the same weighted viscosity, penalty, pressure, stress, and FSSA contributions as the matrix-free operator.Inf*0 = NaN.Reduced-space consistency
The active pressure rule is
The same mask is used by the pressure residual, convergence norm, field spans, and active degree-of-freedom count. The empirical lower-eigenvalue estimate used by the DR auto-tuner is likewise restricted to active, boundary-trimmed velocity rows:
Previously, eliminated cut-cell and boundary entries could contaminate this quotient even though they were absent from the convergence norm.
Powell-Hestenes penalty weighting
For an active pressure sample,
W_p G^T u=0is equivalent to the retained constraintG^T u=0. The numerical Powell-Hestenes coefficient is therefore not itself volume-weighted:The variational gradient supplies the single physical volume weight. The previous construction weighted
γ_effbyϕand then applied the weighted gradient, producing approximatelyϕ²scaling near the interface:The physical bulk viscosity remains
η_b = ϕ K_b Δt; only the algorithmic PH penalty is unweighted before the weighted momentum gradient.Automatic DR tuning and Gershgorin validation
Pseudo-time steps and damping coefficients are selected from
with
λ_maxsupplied by theD⁻¹AGershgorin row bound andc_Vderived from the reduced-space estimate ofλ_min.A CPU regression assembles the actual matrix-free velocity Jacobian by applying production kernels to unit velocity vectors. For full and cut domains it verifies symmetry to roundoff, full reduced rank, positive definiteness, and that every exact preconditioned absolute row sum is bounded by the stored Gershgorin estimate.
For a controlled horizontal cut, the Jacobi/Gershgorin-preconditioned spectra are:
κκ4²6²8²10²The cut interface adds about 10% in this case; the dominant
O(N²)trend is the expected limitation of diagonal preconditioning.Free-surface stabilization
The vertical residual contains the implicit Kaus et al. (2010) correction
Accordingly:
V_ydiagonal and row bound;D_y,λ_max,y,Δτ_y,α_y, andβ_ybefore the first DR window and during periodic tuning;ϕ-weighted buoyancy derivative as the residual;γ_effreceives an FSSA-dependent floor so the penalty diagonal cannot become negligible relative to FSSA.Original variational APT solver
The original non-DR solver now follows the same reduced-space convergence rules. Its residuals are active-space RMS values,
where
M_pis theisvalid_c(ϕ)mask,M_{u_d}selects retained staggered velocity rows, and eachNis the corresponding global active degree-of-freedom count. This replaces full-grid normalization, which made a fixed tolerance depend on rock fraction and resolution. It also fixes the 3D continuity metric, which divided the L2 norm byN_pinstead ofsqrt(N_p).For
free_surface=true, the APT vertical update now includes the FSSA diagonal in its local pseudo-time denominator:Because
η dτhas dimensions of length squared, the added term has viscosity units. It is identically zero when FSSA is disabled and bounds the pseudo-time amplification caused by a sharp free-surface density jump.Matched sticky-air comparison
The deterministic plume harness can run ordinary sticky air or reduced variational Stokes with identical geometry, timestep, penalty, tolerances, initial fields, and residual normalization. Without FSSA:
20²40²80²Both formulations converge at every resolution. A permanent
40²regression requires both solves to converge and prevents the reduced solve from becoming more than 25% slower than sticky air.Other changes
ϕ ≡ 1) equivalence tests.γ_eff/η = O(γfact)across heterogeneous materials.err,iter, andconvergeddiagnostics.Validation
test_dyrel_kernels: 69/69ϕ≡1equivalence: 18/18ExactFieldSolutionswas unavailable to SolCx/SolKz visualization testsThe latest focused APT rerun is currently blocked before test execution by an external GeoParams version mismatch: the branch references
ThreePhase_Density, which is absent from the locally resolved GeoParams. Static parsing andgit diff --checkpass. CUDA/AMDGPU execution was not available on the development machine, so GPU validation remains for CI or a GPU-enabled runner.Checklist