Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions include/aspect/postprocess/topography.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,23 @@ namespace aspect
* @}
*/

/**
* Serialize the contents of this class as far as they are not read
* from input parameter files.
*/
template <class Archive>
void serialize (Archive &ar, const unsigned int version);

/**
* Save the state of this object.
*/
void save (std::map<std::string, std::string> &status_strings) const override;

/**
* Restore the state of the object.
*/
void load (const std::map<std::string, std::string> &status_strings) override;

private:
/**
* Whether or not to produce text files with topography values
Expand Down
38 changes: 38 additions & 0 deletions source/postprocess/topography.cc
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,44 @@ namespace aspect



template <int dim>
template <class Archive>
void Topography<dim>::serialize (Archive &ar, const unsigned int)
{
ar &last_output_time;
}



template <int dim>
void Topography<dim>::save (std::map<std::string, std::string> &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 <int dim>
void Topography<dim>::load (const std::map<std::string, std::string> &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);
}
}

}
}
Expand Down