12#ifndef DUMUX_ADAPTIVEGRIDRESTART_HH
13#define DUMUX_ADAPTIVEGRIDRESTART_HH
17#include <dune/alugrid/grid.hh>
20#include <dune/grid/common/backuprestore.hh>
34struct GridRestartCheck
36 static const bool allowRestart =
false;
41template<
int dim,
int dimworld, Dune::ALUGr
idElementType elType, Dune::ALUGr
idRefinementType refinementType>
42struct GridRestartCheck<
Dune::ALUGrid<dim, dimworld, elType, refinementType> >
44 static const bool allowRestart =
true;
53template <class Grid, bool allowGridRestart = GridRestartCheck<Grid>::allowRestart >
60 template<
class Problem>
63 DUNE_THROW(Dune::NotImplemented,
64 "Adaptive restart functionality currently only works for dune-ALUGrid.");
70 template<
class Problem>
73 DUNE_THROW(Dune::NotImplemented,
74 "Adaptive restart functionality currently only works for dune-ALUGrid.");
88 template<
class Problem>
91 std::string gridName = restartGridFileName_(problem);
93 Dune::BackupRestoreFacility<Grid>::backup(problem.grid(), gridName);
95 problem.grid().template writeGrid(gridName, problem.timeManager().time()
96 + problem.timeManager().timeStepSize());
103 template<
class Problem>
109 template<
class Problem>
110 static const std::string restartGridFileName_(Problem& problem)
112 int rank = problem.gridView().comm().rank();
113 std::ostringstream oss;
115 std::string name = getParam<std::string>(
"Problem.Name");
118 catch (ParameterException &e)
120 std::cerr << e.what() << std::endl;
121 std::cerr <<
"Taking name from problem.name(): " << problem.name() << std::endl;
122 std::cerr <<
"Be sure to provide a parameter Problem.Name if you want to restart." << std::endl;
123 oss << problem.name();
125 oss <<
"_time=" << problem.timeManager().time() + problem.timeManager().timeStepSize()
126 <<
"_rank=" << rank <<
".grs";
static void restartGrid(Problem &problem)
Restart the grid from the file.
Definition: adaptivegridrestart.hh:104
static void serializeGrid(Problem &problem)
Write the grid to a file.
Definition: adaptivegridrestart.hh:89
Indices denoting the different grid types.
Definition: adaptivegridrestart.hh:55
static void restartGrid(Problem &problem)
Restart the grid from the file.
Definition: adaptivegridrestart.hh:71
static void serializeGrid(Problem &problem)
Write the grid to a file.
Definition: adaptivegridrestart.hh:61
Some exceptions thrown in DuMux
Definition: common/pdesolver.hh:24
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.