-
Notifications
You must be signed in to change notification settings - Fork 348
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix roundoff issue in SUNDIALS evolve() #4148
Fix roundoff issue in SUNDIALS evolve() #4148
Conversation
Src/Base/AMReX_RKIntegrator.H
Outdated
@@ -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 (std::abs(time_out - time_current - dt) <= 1.e5 * std::numeric_limits<amrex::Real>::epsilon() * std::abs(dt)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if Real is float?
We could also do amrex::almostEqual(time_current+dt, time_out)
. almostEqual
has an optional argument that can be used to fine tune what is considered almost equal.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds good, I'll test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@WeiqunZhang how is this?
Any reasons why |
@WeiqunZhang fixed |
Summary
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.
Additional background
Checklist
The proposed changes: