Commit e740fc5
committed
Land the last time step exactly on the final time
The transient loop used `for(T=0; T<=FinalTime;)` with `T+=Dt` at the end of a
successful step, so it always ran one step too many and finished at up to
FinalTime+Dt instead of FinalTime (e.g. end-time=0.01 with dt=0.003 finished at
0.012, a 20% overshoot; with adaptive dt the overshoot can be a full dtmax).
Use a strict bound with a small relative tolerance and clamp the increment of the
final step so it lands exactly on the final time. Verified: a fixed-dt run now
ends at 1.00000e-02 (was 1.20000e-02); adaptive diffusion and J2-plasticity runs
land on their end-time; the clamped result is partition-consistent (np=1 vs np=4
agree to 6e-17).1 parent 73b5c23 commit e740fc5
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
83 | | - | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
84 | 91 | | |
85 | 92 | | |
86 | 93 | | |
| |||
0 commit comments