diff --git a/include/aspect/postprocess/topography.h b/include/aspect/postprocess/topography.h index 46f29389c9a..97598784ddc 100644 --- a/include/aspect/postprocess/topography.h +++ b/include/aspect/postprocess/topography.h @@ -65,6 +65,23 @@ namespace aspect * @} */ + /** + * Serialize the contents of this class as far as they are not read + * from input parameter files. + */ + template + void serialize (Archive &ar, const unsigned int version); + + /** + * Save the state of this object. + */ + void save (std::map &status_strings) const override; + + /** + * Restore the state of the object. + */ + void load (const std::map &status_strings) override; + private: /** * Whether or not to produce text files with topography values diff --git a/source/postprocess/topography.cc b/source/postprocess/topography.cc index f555a391dd3..f975109125d 100644 --- a/source/postprocess/topography.cc +++ b/source/postprocess/topography.cc @@ -217,6 +217,44 @@ namespace aspect + template + template + void Topography::serialize (Archive &ar, const unsigned int) + { + ar &last_output_time; + } + + + + template + void Topography::save (std::map &status_strings) const + { + // Serialize into a stringstream. Put the following into a code + // block of its own to ensure the destruction of the 'oa' + // archive triggers a flush() on the stringstream so we can + // query the completed string below. + std::ostringstream os; + { + aspect::oarchive oa (os); + oa << (*this); + } + + status_strings["Topography"] = os.str(); + } + + + + template + void Topography::load (const std::map &status_strings) + { + // see if something was saved + if (status_strings.find("Topography") != status_strings.end()) + { + std::istringstream is (status_strings.find("Topography")->second); + aspect::iarchive ia (is); + ia >> (*this); + } + } } }