From 73716d921e378554f618d913080ea5786e8f9b81 Mon Sep 17 00:00:00 2001 From: Andy Nonaka Date: Tue, 17 Sep 2024 12:17:47 -0700 Subject: [PATCH] Fix roundoff issue in SUNDIALS evolve() (#4148) 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. --- Src/Base/AMReX_RKIntegrator.H | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Src/Base/AMReX_RKIntegrator.H b/Src/Base/AMReX_RKIntegrator.H index a6efd02853..a4769dc915 100644 --- a/Src/Base/AMReX_RKIntegrator.H +++ b/Src/Base/AMReX_RKIntegrator.H @@ -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; }