[cig-commits] [commit] master: fix visualization output interval (4c5e243)

cig_noreply at geodynamics.org cig_noreply at geodynamics.org
Thu Dec 25 01:00:25 PST 2014


Repository : https://github.com/geodynamics/aspect

On branch  : master
Link       : https://github.com/geodynamics/aspect/compare/1a6b7735396a24c6b2d09b93f5acbcbe86bc2e64...fef0a8c311e49678b2ecbce0941ac0f2fd57d12e

>---------------------------------------------------------------

commit 4c5e243a6c3595460a9ea662394fcc5169d0a921
Author: Timo Heister <timo.heister at gmail.com>
Date:   Thu Dec 18 03:42:39 2014 -0500

    fix visualization output interval
    
    This fixes the test composition-passive-tracers which happens to reach a
    time step that is an exact multiple of the output interval. Bug was
    introduced in 8e658c7b94f.


>---------------------------------------------------------------

4c5e243a6c3595460a9ea662394fcc5169d0a921
 source/postprocess/visualization.cc | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/source/postprocess/visualization.cc b/source/postprocess/visualization.cc
index f605ecc..e3a59ac 100644
--- a/source/postprocess/visualization.cc
+++ b/source/postprocess/visualization.cc
@@ -844,10 +844,14 @@ namespace aspect
       // time
       if (output_interval > 0)
         {
-          // we need to find the last time output was supposed to be written.
+          // We need to find the last time output was supposed to be written.
           // this is the last_output_time plus the largest positive multiple
-          // of output_intervals that passed since then
-          last_output_time = last_output_time + std::floor((current_time-last_output_time)/output_interval) * output_interval;
+          // of output_intervals that passed since then. We need to handle the
+          // edge case where last_output_time+output_interval==current_time,
+          // we did an output and std::floor sadly rounds to zero. This is done
+          // by forcing std::floor to round 1.0-eps to 1.0.
+          const double magic = 1.0+2.0*std::numeric_limits<double>::epsilon();
+          last_output_time = last_output_time + std::floor((current_time-last_output_time)/output_interval*magic) * output_interval/magic;
         }
     }
 



More information about the CIG-COMMITS mailing list