From de618c9e4bdbbf6d7bca914ad4bd93f045a2ead9 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 5 Nov 2026 01:54:10 +0000 Subject: [PATCH 1/2] Use the default Newton W cutoff in the DFG example solver new_W_dt_cutoff = 0 refactorized the W matrix on every step (197 factorizations); the default cutoff needs 35 and gives identical cD, cL and dp to 10 digits, with 2.4x less solve time at 16,430 dofs. Agent-Harness: Claude Code 2.1.318 Agent-Model: claude-sonnet-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code --- examples/dfg_cylinder/dfg_cylinder.jl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/dfg_cylinder/dfg_cylinder.jl b/examples/dfg_cylinder/dfg_cylinder.jl index cc624e62..c0a816a8 100644 --- a/examples/dfg_cylinder/dfg_cylinder.jl +++ b/examples/dfg_cylinder/dfg_cylinder.jl @@ -84,7 +84,10 @@ differential_abstol(prob, abstol) = [d ? abstol : 1.0e8 for d in prob.differenti # pattern as the analyzed matrix" on these Newton matrices, as it does on Ferrite's own ns_vs_diffeq tutorial. # Naming it also removes the default's silent fall-back to sparse QR when a Newton matrix is singular, which # for this index-2 system took tens of GB: a singular matrix now fails the step, and `check_solved` raises. -const DFG_ALG = DFBDF(nlsolve = NLNewton(new_W_dt_cutoff = 0), linsolve = UMFPACKFactorization()) +# UMFPACK's default has no iterative refinement and its residual grows above ~60k dofs; at this size (16,430) it is +# accurate. Above about 60k dofs use KLUFactorization() until pivot_tolerance/strategy are available in a released +# LinearSolve, then UMFPACKFactorization(control = (; strategy = 3, irstep = 2)). +const DFG_ALG = DFBDF(linsolve = UMFPACKFactorization()) "Raise unless `sol` succeeded and reached its final time (a callback can stop it early with `Terminated`, a success code); a DAE solve that stopped early must not report coefficients." function check_solved(sol) From a7f4bcb322d82f58d4b37ecbfabd7bed8631ad43 Mon Sep 17 00:00:00 2001 From: t Date: Thu, 5 Nov 2026 02:01:00 +0000 Subject: [PATCH 2/2] Match the Navier-Stokes docs snippet to the example solver The page showed NLNewton(new_W_dt_cutoff = 0), which the example no longer uses, and gains a note on UMFPACK accuracy above about 60k dofs. Agent-Harness: Claude Code 2.1.312 Agent-Model: claude-sonnet-5-5 Agent-Session: 43e03fde-3384-4386-bae9-03e81f19ba7c Agent-Review: unreviewed Co-authored-by: Claude Code --- docs/src/navier_stokes.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/src/navier_stokes.md b/docs/src/navier_stokes.md index fc665024..dfef71cc 100644 --- a/docs/src/navier_stokes.md +++ b/docs/src/navier_stokes.md @@ -35,7 +35,7 @@ disc = FEMDiscretization(Ω, t; spaces = Dict(u => Q2, v => Q2, p => Q1), pairing = Dict(eqs[3] => p), initializealg = CheckInit()) prob = DAEProblem(dfg, disc) abstol = [d ? 1e-7 : 1e8 for d in prob.differential_vars] # pressure and Dirichlet rows out of error control -sol = solve(prob, DFBDF(nlsolve = NLNewton(new_W_dt_cutoff = 0), linsolve = UMFPACKFactorization()); +sol = solve(prob, DFBDF(linsolve = UMFPACKFactorization()); abstol, reltol = 1e-7) ``` @@ -65,6 +65,11 @@ sol = solve(prob, DFBDF(nlsolve = NLNewton(new_W_dt_cutoff = 0), linsolve = UMFP (and on Ferrite's own `ns_vs_diffeq.jl` tutorial). Naming it also removes the default's silent fall-back to sparse QR on a singular Newton matrix, which costs tens of gigabytes here; the example's `check_solved` raises if the solve stops before its final time. + UMFPACK's default has no iterative refinement and its residual grows above about 60k dofs + (about 1e-12 at 62k, 2e-4 at 248k, on this example's matrices); it is accurate at the 16,430 + dofs here. Above about 60k dofs use `KLUFactorization()` until `pivot_tolerance` and `strategy` + are available in a released LinearSolve, then + `UMFPACKFactorization(control = (; strategy = 3, irstep = 2))`. ## Drag and lift