changes in restart behaviour: - restart mechanism is now called from init(..) method in time manager for all models via problem().restart(...); - hence, calls to problem or models in application files and in the default start procedure are deleted (included in timeManager) - timeManager().init(...) now has a real restart bool defining if a restart was called by the user. Bool is true if restart is desired. - Decoupled models: to enable restart, the writer is only called with the access function to avoid segmentation fault. - Adapt tutorial to the change

This commit is contained in:
Benjamin Faigle 2011-10-11 12:54:41 +00:00 committed by Andreas Lauser
parent 51b13ab8f3
commit 72832a8b24
4 changed files with 19 additions and 23 deletions

View File

@ -209,8 +209,10 @@ parse the time when the simulation ends and the initial time step size.
After this, a grid is created in line
\ref{tutorial-coupled:create-grid} and the problem is instantiated for
its leaf grid view in line \ref{tutorial-coupled:instantiate-problem}.
Finally, on line \ref{tutorial-coupled:begin-restart} a state written to
disk by a previous simulation run is restored if requested by the user.
Finally, on line \ref{tutorial-coupled:initTimeManager} the time
manager is created with the parsed starting parameters. If requested by
the user, a state written to disk by a previous simulation run can be
restored if via the restart flag.
The simulation procedure is started in line
\ref{tutorial-coupled:execute}.

View File

@ -70,13 +70,14 @@ parse the time when the simulation ends. As the maximum time-step in the
sequential model is strictly bound by a CFL-criterion, the first time-step
size is initialized with the simulation time.
After this, a grid is created in line \ref{tutorial-decoupled:create-grid}
and the time manager controlling the simulation run is instantiated
with the start parameters in line \ref{tutorial-decoupled:initTimeManager}.
After this, a grid is created in line \ref{tutorial-decoupled:create-grid}.
The problem is instantiated with the time manager and information about the grid
(via its leaf grid view) on line \ref{tutorial-decoupled:instantiate-problem}.
If demanded, on line \ref{tutorial-decoupled:mainRestart} a state written to
disk by a previous simulation run is restored on request by the user.
The time manager controlling the simulation run is instantiated
with the start parameters in line \ref{tutorial-decoupled:initTimeManager}.
If demanded, the time manager also restarts a state written to
disk by a previous simulation run via the last flag, using the appropriate
starting time (which has to be the same as the restart file).
Finally, the simulation proceedure is started by the time manager in line
\ref{tutorial-decoupled:execute}.
@ -150,7 +151,7 @@ subsection \label{decoupled-problem:boundary}), the problem class also contains
general information about the current simulation. First, the name used by
the \texttt{VTK-writer} to generate output is defined in the method of line
\ref{tutorial-decoupled:name}, and line \ref{tutorial-decoupled:restart} indicates
weather restart files are written. As decoupled schemes usually feature small
wether restart files are written. As decoupled schemes usually feature small
timesteps, the method controlling the output in line \ref{tutorial-decoupled:output}
is very useful. The divisor of the modulo operation defines after how many timesteps
output should be written out -- the default ``1'' resembles output after each

View File

@ -54,12 +54,12 @@ int main(int argc, char** argv)
// parse restart time if restart is requested
int argPos = 1;
bool restart = false;
double restartTime = 0;
double startTime = 0;
if (std::string("--restart") == argv[argPos]) {
restart = true;
++argPos;
std::istringstream(argv[argPos++]) >> restartTime;
// use restart time as start time
std::istringstream(argv[argPos++]) >> startTime;
}
// read the initial time step and the end time
@ -78,10 +78,7 @@ int main(int argc, char** argv)
// instantiate the problem on the leaf grid
Problem problem(timeManager, gridPtr->leafView()); /*@\label{tutorial-coupled:instantiate-problem}@*/
timeManager.init(problem, 0, dt, tEnd, !restart);
// load some previously saved state from disk
if (restart)
problem.restart(restartTime); /*@\label{tutorial-coupled:begin-restart}@*/
timeManager.init(problem, startTime, dt, tEnd, restart); /*@\label{tutorial-coupled:initTimeManager}@*/
// run the simulation
timeManager.run(); /*@\label{tutorial-coupled:execute}@*/
return 0;

View File

@ -71,12 +71,12 @@ int main(int argc, char** argv)
// deal with the restart stuff
int argPos = 1;
bool restart = false;
double restartTime = 0;
double startTime = 0.;
if (std::string("--restart") == argv[argPos]) {
restart = true;
++argPos;
std::istringstream(argv[argPos++]) >> restartTime;
// use restart time as start time
std::istringstream(argv[argPos++]) >> startTime;
}
// output in case of wrong numbers of input parameters
if (argc - argPos != 1) {
@ -100,11 +100,7 @@ int main(int argc, char** argv)
Problem problem(timeManager, gridPtr->leafView()); /*@\label{tutorial-decoupled:instantiate-problem}@*/
// define simulation parameters
timeManager.init(problem, 0, dt, tEnd, !restart); /*@\label{tutorial-decoupled:initTimeManager}@*/
// load restart file if necessary
if (restart) /*@\label{tutorial-decoupled:mainRestart}@*/
problem.deserialize(restartTime);
timeManager.init(problem, startTime, dt, tEnd, restart); /*@\label{tutorial-decoupled:initTimeManager}@*/
// run the simulation
timeManager.run(); /*@\label{tutorial-decoupled:execute}@*/