Skip to content

Commit

Permalink
Fix roundoff issue in SUNDIALS evolve() (AMReX-Codes#4148)
Browse files Browse the repository at this point in the history
Fix a roundoff issue in the SUNDIALS evolve() function that caused the
integrator to run a second time with a very tiny dt in a given time
step.
  • Loading branch information
ajnonaka authored Sep 17, 2024
1 parent eecb9ea commit 73716d9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Src/Base/AMReX_RKIntegrator.H
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ public:
for (int step_number = 0; step_number < BaseT::max_steps && !stop; ++step_number)
{
// Adjust step size to reach output time
if (time_out - time_current < dt) {
// protect against roundoff
if ((time_out-time_current) < dt || almostEqual(time_out-time_current,dt,10)) {
dt = time_out - time_current;
stop = true;
}
Expand Down

0 comments on commit 73716d9

Please sign in to comment.