Commit e2aefebc authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

replace try-catch with grid capability check

parent fb26f4c1
......@@ -6,6 +6,7 @@
#include <dune/common/hybridutilities.hh>
#include <dune/common/timer.hh>
#include <dune/grid/common/capabilities.hh>
#include <dune/typetree/childextraction.hh>
#include <amdis/AdaptInfo.hpp>
......@@ -489,23 +490,26 @@ template <class Traits>
void ProblemStat<Traits>::
backup(std::string const& filename) const
{
try {
if (Dune::Capabilities::hasBackupRestoreFacilities<Grid>::v)
Dune::BackupRestoreFacility<Grid>::backup(*grid_, filename);
} catch (Dune::NotImplemented const&) {
else {
warning("Falling back to backup of gridview.");
BackupRestoreByGridFactory<Grid>::backup(gridView(), filename);
}
}
template <class Traits>
void ProblemStat<Traits>::
backup(AdaptInfo& adaptInfo)
{
auto param = Parameters::get<std::string>(name_ + "->backup->grid");
std::string grid_filename = param ? *param : name_ + "_" + std::to_string(adaptInfo.timestepNumber()) + ".grid";
std::string grid_filename = param ? *param :
name_ + "_" + std::to_string(adaptInfo.timestepNumber()) + ".grid";
auto param2 = Parameters::get<std::string>(name_ + "->backup->solution");
std::string solution_filename = param2 ? *param2 : name_ + "_" + std::to_string(adaptInfo.timestepNumber()) + ".solution";
std::string solution_filename = param2 ? *param2 :
name_ + "_" + std::to_string(adaptInfo.timestepNumber()) + ".solution";
backup(grid_filename);
solution_->backup(solution_filename);
......@@ -519,14 +523,14 @@ restore(std::string const& filename)
{
// restore grid from file
std::unique_ptr<Grid> grid;
try {
if (Dune::Capabilities::hasBackupRestoreFacilities<Grid>::v)
grid.reset(Dune::BackupRestoreFacility<Grid>::restore(filename));
} catch (Dune::NotImplemented const&) {
else
grid.reset(BackupRestoreByGridFactory<Grid>::restore(filename));
}
return std::move(grid);
}
template <class Traits>
void ProblemStat<Traits>::
restore(Flag initFlag)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment