diff --git a/src/amdis/ProblemStat.inc.hpp b/src/amdis/ProblemStat.inc.hpp index 0a942639d2b8038814a3c898a271384b12087f2d..deacf75c5a5985280d6d99a825e4eb2725350992 100644 --- a/src/amdis/ProblemStat.inc.hpp +++ b/src/amdis/ProblemStat.inc.hpp @@ -479,16 +479,26 @@ writeFiles(AdaptInfo& adaptInfo, bool force) } +template ::backup(std::declval(), std::string("")))> +void backup_impl(Grid const& grid, GridView const& gv, std::string filename, std::true_type) +{ + Dune::BackupRestoreFacility::backup(grid, filename); +} + +template ::backup(std::declval(), std::string("")))> +void backup_impl(Grid const& grid, GridView const& gv, std::string filename, bool_t) +{ + warning("Falling back to backup of gridview."); + BackupRestoreByGridFactory::backup(gv, filename); +} + template void ProblemStat:: backup(std::string const& filename) const { - if (Dune::Capabilities::hasBackupRestoreFacilities::v) - Dune::BackupRestoreFacility::backup(*grid_, filename); - else { - warning("Falling back to backup of gridview."); - BackupRestoreByGridFactory::backup(gridView(), filename); - } + backup_impl(*grid_, gridView(), filename, bool_t::v>{}); } @@ -510,16 +520,26 @@ backup(AdaptInfo& adaptInfo) } +template ::restore(std::string("")))> +auto restore_impl(std::string filename, std::true_type) +{ + return Dune::BackupRestoreFacility::restore(filename); +} + +template ::restore(std::string("")))> +auto restore_impl(std::string filename, bool_t) +{ + return BackupRestoreByGridFactory::restore(filename); +} + template auto ProblemStat:: restore(std::string const& filename) { // restore grid from file - std::unique_ptr grid; - if (Dune::Capabilities::hasBackupRestoreFacilities::v) - grid.reset(Dune::BackupRestoreFacility::restore(filename)); - else - grid.reset(BackupRestoreByGridFactory::restore(filename)); + std::unique_ptr grid(restore_impl(filename, bool_t::v>{})); return std::move(grid); }