[cig-commits] r1329 - trunk/aspect/source/postprocess
heister at dealii.org
heister at dealii.org
Thu Oct 25 08:19:58 PDT 2012
Author: heister
Date: 2012-10-25 09:19:58 -0600 (Thu, 25 Oct 2012)
New Revision: 1329
Modified:
trunk/aspect/source/postprocess/depth_average.cc
trunk/aspect/source/postprocess/tracer.cc
trunk/aspect/source/postprocess/visualization.cc
Log:
fix double output bug (due to wrong rounding)
Modified: trunk/aspect/source/postprocess/depth_average.cc
===================================================================
--- trunk/aspect/source/postprocess/depth_average.cc 2012-10-25 13:24:16 UTC (rev 1328)
+++ trunk/aspect/source/postprocess/depth_average.cc 2012-10-25 15:19:58 UTC (rev 1329)
@@ -224,16 +224,15 @@
DepthAverage<dim>::set_next_output_time (const double current_time)
{
// if output_interval is positive, then set the next output interval to
- // a positive multiple; we need to interpret output_interval either
- // as years or as seconds
+ // a positive multiple.
if (output_interval > 0)
{
- if (this->convert_output_to_years() == true)
- next_output_time = std::ceil(current_time / (output_interval * year_in_seconds)) *
- (output_interval * year_in_seconds);
- else
- next_output_time = std::ceil(current_time / (output_interval )) *
- output_interval;
+ // the current time is always in seconds, so we need to convert the output_interval to the same unit
+ double output_interval_in_s = (this->convert_output_to_years()) ? (output_interval*year_in_seconds) : output_interval;
+
+ // we need to compute the smallest integer that is bigger than current_time/my_output_interval,
+ // even if it is a whole number already (otherwise we output twice in a row)
+ next_output_time = (std::floor(current_time/output_interval_in_s)+1.0) * output_interval_in_s;
}
}
}
Modified: trunk/aspect/source/postprocess/tracer.cc
===================================================================
--- trunk/aspect/source/postprocess/tracer.cc 2012-10-25 13:24:16 UTC (rev 1328)
+++ trunk/aspect/source/postprocess/tracer.cc 2012-10-25 15:19:58 UTC (rev 1329)
@@ -113,16 +113,15 @@
PassiveTracers<dim>::set_next_data_output_time (const double current_time)
{
// if output_interval is positive, then set the next output interval to
- // a positive multiple; we need to interpret output_interval either
- // as years or as seconds
+ // a positive multiple.
if (_data_output_interval > 0)
{
- if (this->convert_output_to_years() == true)
- _next_data_output_time = std::ceil(current_time / (_data_output_interval * year_in_seconds)) *
- (_data_output_interval * year_in_seconds);
- else
- _next_data_output_time = std::ceil(current_time / (_data_output_interval)) *
- (_data_output_interval);
+ // the current time is always in seconds, so we need to convert the output_interval to the same unit
+ double output_interval_in_s = (this->convert_output_to_years()) ? (_data_output_interval*year_in_seconds) : _data_output_interval;
+
+ // we need to compute the smallest integer that is bigger than current_time/my_output_interval,
+ // even if it is a whole number already (otherwise we output twice in a row)
+ _next_data_output_time = (std::floor(current_time/output_interval_in_s)+1.0) * output_interval_in_s;
}
}
Modified: trunk/aspect/source/postprocess/visualization.cc
===================================================================
--- trunk/aspect/source/postprocess/visualization.cc 2012-10-25 13:24:16 UTC (rev 1328)
+++ trunk/aspect/source/postprocess/visualization.cc 2012-10-25 15:19:58 UTC (rev 1329)
@@ -587,16 +587,15 @@
Visualization<dim>::set_next_output_time (const double current_time)
{
// if output_interval is positive, then set the next output interval to
- // a positive multiple; we need to interpret output_interval either
- // as years or as seconds
+ // a positive multiple.
if (output_interval > 0)
{
- if (this->convert_output_to_years() == true)
- next_output_time = std::ceil(current_time / (output_interval * year_in_seconds)) *
- (output_interval * year_in_seconds);
- else
- next_output_time = std::ceil(current_time / (output_interval )) *
- output_interval;
+ // the current time is always in seconds, so we need to convert the output_interval to the same unit
+ double output_interval_in_s = (this->convert_output_to_years()) ? (output_interval*year_in_seconds) : output_interval;
+
+ // we need to compute the smallest integer that is bigger than current_time/my_output_interval,
+ // even if it is a whole number already (otherwise we output twice in a row)
+ next_output_time = (std::floor(current_time/output_interval_in_s)+1.0) * output_interval_in_s;
}
}
More information about the CIG-COMMITS
mailing list