Skip to content

Commit f4280ca

Browse files
authored
Allow single-step backward Euler integrator (#1773)
now if you add `integrator.do_single_step=1` then `BackwardEuler` will ignore the tolerances and just do a single step.
1 parent ed280a5 commit f4280ca

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

Docs/source/ode_integrators.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ Presently, allowed integrators are:
2727
* ``BackwardEuler``: an implicit first-order accurate backward-Euler
2828
method. An error estimate is done by taking 2 half steps and
2929
comparing to a single full step. This error is then used to control
30-
the timestep by using the local truncation error scaling.
30+
the timestep by using the local truncation error scaling. Optionally, the
31+
user can disable error estimation and force a single-step backward-Euler
32+
integration by setting `integrator.do_single_step = 1`.
3133

3234
* ``ForwardEuler``: an explicit first-order forward-Euler method. This is
3335
meant for testing purposes only. No Jacobian is needed.

integration/BackwardEuler/_parameters

+3
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,6 @@ max_iter int 25
55

66
# tolerance for the Newton solve
77
tol real 1.e-10
8+
9+
# toggle single-step BackwardEuler integration and ignoring error tolerance
10+
do_single_step int 0

integration/BackwardEuler/be_integrator.H

+9
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,15 @@ int be_integrator (BurnT& state, BeT& be)
181181

182182
int ierr;
183183

184+
if (integrator_rp::do_single_step == 1) {
185+
// Do a single step to the final time
186+
const amrex::Real dt_single_step = be.tout - be.t;
187+
ierr = single_step(state, be, dt_single_step);
188+
be.t = be.tout;
189+
++be.n_step;
190+
return ierr;
191+
}
192+
184193
// estimate the timestep
185194

186195
amrex::Array1D<amrex::Real, 1, int_neqs> ydot;

0 commit comments

Comments
 (0)