24#ifndef DUMUX_ADAPTIVEGRIDRESTART_HH
25#define DUMUX_ADAPTIVEGRIDRESTART_HH
29#include <dune/alugrid/grid.hh>
32#include <dune/grid/common/backuprestore.hh>
46struct GridRestartCheck
48 static const bool allowRestart =
false;
53template<
int dim,
int dimworld, Dune::ALUGr
idElementType elType, Dune::ALUGr
idRefinementType refinementType>
54struct GridRestartCheck<
Dune::ALUGrid<dim, dimworld, elType, refinementType> >
56 static const bool allowRestart =
true;
65template <class Grid, bool allowGridRestart = GridRestartCheck<Grid>::allowRestart >
72 template<
class Problem>
75 DUNE_THROW(Dune::NotImplemented,
76 "Adaptive restart functionality currently only works for dune-ALUGrid.");
82 template<
class Problem>
85 DUNE_THROW(Dune::NotImplemented,
86 "Adaptive restart functionality currently only works for dune-ALUGrid.");
100 template<
class Problem>
103 std::string gridName = restartGridFileName_(problem);
105 Dune::BackupRestoreFacility<Grid>::backup(problem.grid(), gridName);
107 problem.grid().template writeGrid(gridName, problem.timeManager().time()
108 + problem.timeManager().timeStepSize());
115 template<
class Problem>
121 template<
class Problem>
122 static const std::string restartGridFileName_(Problem& problem)
124 int rank = problem.gridView().comm().rank();
125 std::ostringstream oss;
127 std::string name = getParam<std::string>(
"Problem.Name");
130 catch (ParameterException &e)
132 std::cerr << e.what() << std::endl;
133 std::cerr <<
"Taking name from problem.name(): " << problem.name() << std::endl;
134 std::cerr <<
"Be sure to provide a parameter Problem.Name if you want to restart." << std::endl;
135 oss << problem.name();
137 oss <<
"_time=" << problem.timeManager().time() + problem.timeManager().timeStepSize()
138 <<
"_rank=" << rank <<
".grs";
Some exceptions thrown in DuMux
The infrastructure to retrieve run-time parameters from Dune::ParameterTrees.
make the local view function available whenever we use the grid geometry
Definition: adapt.hh:29
Definition: common/properties/model.hh:34
Indices denoting the different grid types.
Definition: adaptivegridrestart.hh:67
static void restartGrid(Problem &problem)
Restart the grid from the file.
Definition: adaptivegridrestart.hh:83
static void serializeGrid(Problem &problem)
Write the grid to a file.
Definition: adaptivegridrestart.hh:73
static void restartGrid(Problem &problem)
Restart the grid from the file.
Definition: adaptivegridrestart.hh:116
static void serializeGrid(Problem &problem)
Write the grid to a file.
Definition: adaptivegridrestart.hh:101