[cig-commits] [commit] master: Handle change of output_interval during restart. (8b38e5e)
cig_noreply at geodynamics.org
cig_noreply at geodynamics.org
Thu Dec 4 09:05:13 PST 2014
Repository : https://github.com/geodynamics/aspect
On branch : master
Link : https://github.com/geodynamics/aspect/compare/66c0a9b8dcd358b4709abe5984f05de5e376e87b...8e658c7b94fac5e74f13922ee8f0eb288218ea50
>---------------------------------------------------------------
commit 8b38e5e3573928fa97eaff38d73f2e88c43d8492
Author: Rene Gassmoeller <R.Gassmoeller at mailbox.org>
Date: Tue Dec 2 15:25:33 2014 +0100
Handle change of output_interval during restart.
>---------------------------------------------------------------
8b38e5e3573928fa97eaff38d73f2e88c43d8492
doc/modules/changes.h | 14 +++++++++-
include/aspect/postprocess/visualization.h | 24 +++++++----------
source/postprocess/visualization.cc | 42 ++++++++++++++----------------
3 files changed, 43 insertions(+), 37 deletions(-)
diff --git a/doc/modules/changes.h b/doc/modules/changes.h
index f9e016b..71f5f58 100644
--- a/doc/modules/changes.h
+++ b/doc/modules/changes.h
@@ -6,7 +6,19 @@
*
*
* <ol>
- *<li> New: There is now the possibility to interpolate the visualization
+ * <li> Changed: The behaviour when one changed the visualization
+ * output_interval during a checkpoint restart was previously undefined,
+ * and working in slightly unexpected ways like never writing output for
+ * the first timestep after the restart. This now works as one would expect,
+ * e.g. every timestep that ends more than output_interval after the last
+ * output time step will produce output. Old checkpoint files will continue
+ * to work, only with a possible short gap in visualization output right
+ * after restart.
+ *
+ * <br>
+ * (Rene Gassmoeller, 2014/12/03)
+ *
+ * <li> New: There is now the possibility to interpolate the visualization
* output to a refined output mesh. This accounts for the fact that most
* visualization software only offers linear interpolation between grid points
* and therefore the output file is a very coarse representation of the actual
diff --git a/include/aspect/postprocess/visualization.h b/include/aspect/postprocess/visualization.h
index a44022b..e3a9b26 100644
--- a/include/aspect/postprocess/visualization.h
+++ b/include/aspect/postprocess/visualization.h
@@ -325,19 +325,14 @@ namespace aspect
* Interval between the generation of graphical output. This parameter
* is read from the input file and consequently is not part of the
* state that needs to be saved and restored.
- *
- * For technical reasons, this value is stored as given in the input
- * file and upon use is either interpreted as seconds or years,
- * depending on how the global flag in the input parameter file is
- * set.
*/
double output_interval;
/**
- * A time (in years) after which the next time step should produce
- * graphical output again.
+ * A time (in seconds) at which the last graphical output was supposed
+ * to be produced. Used to check for the next necessary output time.
*/
- double next_output_time;
+ double last_output_time;
/**
* Consecutively counted number indicating the how-manyth time we will
@@ -372,13 +367,14 @@ namespace aspect
bool interpolate_output;
/**
- * Compute the next output time from the current one. In the simplest
- * case, this is simply the previous next output time plus the
- * interval, but in general we'd like to ensure that it is larger than
- * the current time to avoid falling behind with next_output_time and
- * having to catch up once the time step becomes larger.
+ * Set the time output was supposed to be written. In the simplest
+ * case, this is the previous last output time plus the interval, but
+ * in general we'd like to ensure that it is the largest supposed
+ * output time, which is smaller than the current time, to avoid
+ * falling behind with last_output_time and having to catch up once
+ * the time step becomes larger. This is done after every output.
*/
- void set_next_output_time (const double current_time);
+ void set_last_output_time (const double current_time);
/**
* Record that the mesh changed. This helps some output writers avoid
diff --git a/source/postprocess/visualization.cc b/source/postprocess/visualization.cc
index 2b0eee8..f605ecc 100644
--- a/source/postprocess/visualization.cc
+++ b/source/postprocess/visualization.cc
@@ -144,7 +144,7 @@ namespace aspect
output_interval (0),
// initialize this to a nonsensical value; set it to the actual time
// the first time around we get to check it
- next_output_time (std::numeric_limits<double>::quiet_NaN()),
+ last_output_time (std::numeric_limits<double>::quiet_NaN()),
output_file_number (0)
{}
@@ -172,16 +172,16 @@ namespace aspect
std::pair<std::string,std::string>
Visualization<dim>::execute (TableHandler &statistics)
{
- // if this is the first time we get here, set the next output time
- // to the current time. this makes sure we always produce data during
- // the first time step
- if (std::isnan(next_output_time))
+ // if this is the first time we get here, set the last output time
+ // to the current time - output_interval. this makes sure we
+ // always produce data during the first time step
+ if (std::isnan(last_output_time))
{
- next_output_time = this->get_time();
+ last_output_time = this->get_time() - output_interval;
}
- // see if graphical output is requested at this time
- if (this->get_time() < next_output_time)
+ // return if graphical output is not requested at this time
+ if (this->get_time() < last_output_time + output_interval)
return std::pair<std::string,std::string>();
@@ -472,7 +472,7 @@ namespace aspect
// up the counter of the number of the file by one; also
// up the next time we need output
++output_file_number;
- set_next_output_time (this->get_time());
+ set_last_output_time (this->get_time());
// return what should be printed to the screen.
return std::make_pair (std::string ("Writing graphical output:"),
@@ -724,6 +724,9 @@ namespace aspect
prm.enter_subsection("Visualization");
{
output_interval = prm.get_double ("Time between graphical output");
+ if (this->convert_output_to_years())
+ output_interval *= year_in_seconds;
+
output_format = prm.get ("Output format");
group_files = prm.get_integer("Number of grouped files");
interpolate_output = prm.get_bool("Interpolate output");
@@ -790,7 +793,7 @@ namespace aspect
template <class Archive>
void Visualization<dim>::serialize (Archive &ar, const unsigned int)
{
- ar &next_output_time
+ ar &last_output_time
& output_file_number
& times_and_pvtu_names
& output_file_names_by_timestep
@@ -830,26 +833,21 @@ namespace aspect
}
//TODO: do something about the visualization postprocessor plugins
-
- // set next output time to something useful
- set_next_output_time (this->get_time());
}
template <int dim>
void
- Visualization<dim>::set_next_output_time (const double current_time)
+ Visualization<dim>::set_last_output_time (const double current_time)
{
- // if output_interval is positive, then set the next output interval to
- // a positive multiple.
+ // if output_interval is positive, then update the last supposed output
+ // time
if (output_interval > 0)
{
- // 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;
+ // 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;
}
}
More information about the CIG-COMMITS
mailing list