@@ -2212,47 +2212,6 @@ Amr::coarseTimeStep (Real stop_time)
22122212 runlog_terse.flush ();
22132213 }
22142214
2215- int check_test = 0 ;
2216-
2217- if (check_per > 0.0 )
2218- {
2219-
2220- // Check to see if we've crossed a check_per interval by comparing
2221- // the number of intervals that have elapsed for both the current
2222- // time and the time at the beginning of this timestep.
2223-
2224- int num_per_old = static_cast <int >((cumtime-dt_level[0 ]) / check_per);
2225- int num_per_new = static_cast <int >((cumtime ) / check_per);
2226-
2227- // Before using these, however, we must test for the case where we're
2228- // within machine epsilon of the next interval. In that case, increment
2229- // the counter, because we have indeed reached the next check_per interval
2230- // at this point.
2231-
2232- const Real eps = std::numeric_limits<Real>::epsilon () * 10 .0_rt * std::abs (cumtime);
2233- const Real next_chk_time = static_cast <Real>(num_per_old + 1 ) * check_per;
2234-
2235- if ((num_per_new == num_per_old) && std::abs (cumtime - next_chk_time) <= eps)
2236- {
2237- num_per_new += 1 ;
2238- }
2239-
2240- // Similarly, we have to account for the case where the old time is within
2241- // machine epsilon of the beginning of this interval, so that we don't double
2242- // count that time threshold -- we already plotted at that time on the last timestep.
2243-
2244- if ((num_per_new != num_per_old) && std::abs ((cumtime - dt_level[0 ]) - next_chk_time) <= eps)
2245- {
2246- num_per_old += 1 ;
2247- }
2248-
2249- if (num_per_old != num_per_new)
2250- {
2251- check_test = 1 ;
2252- }
2253-
2254- }
2255-
22562215 int to_stop = 0 ;
22572216 int to_checkpoint = 0 ;
22582217 int to_plot = 0 ;
@@ -2323,8 +2282,7 @@ Amr::coarseTimeStep (Real stop_time)
23232282 to_small_plot = 1 ;
23242283 }
23252284
2326- if ((check_int > 0 && level_steps[0 ] % check_int == 0 ) || check_test == 1
2327- || to_checkpoint)
2285+ if (checkPointNow () || to_checkpoint)
23282286 {
23292287 checkPoint ();
23302288 }
@@ -2359,6 +2317,54 @@ Amr::coarseTimeStep (Real stop_time)
23592317 }
23602318}
23612319
2320+ bool
2321+ Amr::checkPointNow () noexcept
2322+ {
2323+ int check_test = 0 ;
2324+
2325+ if (check_per > 0.0 )
2326+ {
2327+
2328+ // Check to see if we've crossed a check_per interval by comparing
2329+ // the number of intervals that have elapsed for both the current
2330+ // time and the time at the beginning of this timestep.
2331+
2332+ int num_per_old = static_cast <int >((cumtime-dt_level[0 ]) / check_per);
2333+ int num_per_new = static_cast <int >((cumtime ) / check_per);
2334+
2335+ // Before using these, however, we must test for the case where we're
2336+ // within machine epsilon of the next interval. In that case, increment
2337+ // the counter, because we have indeed reached the next check_per interval
2338+ // at this point.
2339+
2340+ const Real eps = std::numeric_limits<Real>::epsilon () * 10 .0_rt * std::abs (cumtime);
2341+ const Real next_chk_time = static_cast <Real>(num_per_old + 1 ) * check_per;
2342+
2343+ if ((num_per_new == num_per_old) && std::abs (cumtime - next_chk_time) <= eps)
2344+ {
2345+ num_per_new += 1 ;
2346+ }
2347+
2348+ // Similarly, we have to account for the case where the old time is within
2349+ // machine epsilon of the beginning of this interval, so that we don't double
2350+ // count that time threshold -- we already plotted at that time on the last timestep.
2351+
2352+ if ((num_per_new != num_per_old) && std::abs ((cumtime - dt_level[0 ]) - next_chk_time) <= eps)
2353+ {
2354+ num_per_old += 1 ;
2355+ }
2356+
2357+ if (num_per_old != num_per_new)
2358+ {
2359+ check_test = 1 ;
2360+ }
2361+
2362+ }
2363+
2364+ return ((check_int > 0 && level_steps[0 ] % check_int == 0 ) ||
2365+ check_test == 1 ||
2366+ amr_level[0 ]->checkPointNow ());
2367+ }
23622368bool
23632369Amr::writePlotNow () noexcept
23642370{
0 commit comments