Commit da17c26
committed
OOP NonlinearSolveAlg: reuse a static W across stages
The out-of-place branch of `build_nlsolver` builds `J, W` through `build_J_W`
and then throws both away: the inner `NonlinearProblem` gets no `jac` and the
cache stores `nothing`, so every inner Newton iteration recomputes the
Jacobian by AD with no reuse across stages or steps.
Wire the `W` back in for the case that is safe today, a `StaticWOperator`
problem with a `solve!`-only inner solver. The `W` lives in a `Ref` the inner
`NonlinearFunction`'s analytic `jac` reads, and `initialize!` refreshes it
under the same `always_new` / divergence / `new_W_dt_cutoff` policy `NLNewton`
uses, assembling it through `calc_J` like the `StaticWOperator` branch of
`calc_W`. A concrete-J `WOperator` needs the buffer-copy pattern from #3823
instead, so it stays on the existing no-reuse default.
`njacs` and `nw` now count the assemblies, which is the only inner work the
integrator can attribute on this path.1 parent 1d7c48d commit da17c26
4 files changed
Lines changed: 87 additions & 9 deletions
File tree
- lib/OrdinaryDiffEqNonlinearSolve
- src
- test
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
64 | 64 | | |
65 | 65 | | |
66 | 66 | | |
67 | | - | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
42 | 42 | | |
43 | 43 | | |
44 | 44 | | |
45 | | - | |
46 | | - | |
| 45 | + | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
55 | 74 | | |
56 | 75 | | |
57 | 76 | | |
| |||
230 | 249 | | |
231 | 250 | | |
232 | 251 | | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
233 | 263 | | |
234 | 264 | | |
235 | 265 | | |
| |||
243 | 273 | | |
244 | 274 | | |
245 | 275 | | |
246 | | - | |
| 276 | + | |
| 277 | + | |
247 | 278 | | |
248 | 279 | | |
249 | 280 | | |
| |||
811 | 842 | | |
812 | 843 | | |
813 | 844 | | |
814 | | - | |
| 845 | + | |
| 846 | + | |
815 | 847 | | |
816 | 848 | | |
817 | 849 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
663 | 663 | | |
664 | 664 | | |
665 | 665 | | |
| 666 | + | |
666 | 667 | | |
667 | 668 | | |
668 | 669 | | |
669 | 670 | | |
670 | | - | |
671 | | - | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
| 686 | + | |
| 687 | + | |
672 | 688 | | |
673 | 689 | | |
674 | 690 | | |
675 | 691 | | |
676 | 692 | | |
677 | | - | |
| 693 | + | |
| 694 | + | |
678 | 695 | | |
679 | 696 | | |
680 | 697 | | |
| |||
Lines changed: 30 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
5 | 6 | | |
6 | 7 | | |
7 | 8 | | |
| |||
208 | 209 | | |
209 | 210 | | |
210 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
0 commit comments