Skip to content
Merged
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/ODE_statistics.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ namespace aspect
std::pair<std::string,std::string>
execute (TableHandler &statistics) override;

/**
* 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:
/**
* This function clears all the saved solver information that is
Expand Down
42 changes: 42 additions & 0 deletions source/postprocess/ODE_statistics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,48 @@ namespace aspect

return std::make_pair (std::string(),std::string());
}



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



template <int dim>
void ODEStatistics<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["ODEStatistics"] = os.str();
}



template <int dim>
void ODEStatistics<dim>::load (const std::map<std::string, std::string> &status_strings)
{
// see if something was saved
if (status_strings.find("ODEStatistics") != status_strings.end())
{
std::istringstream is (status_strings.find("ODEStatistics")->second);
aspect::iarchive ia (is);
ia >> (*this);
}
}
}
}

Expand Down