Commit e3f159a5 authored by Andreas Lauser's avatar Andreas Lauser
Browse files

box models: do not overwrite previous solution in updateSuccessful()

instead, do it in a new method called advanceTimeLevel()

git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@4203 2fb0f335-1f38-0410-981e-8018bf24f1b0
parent c0634d1d
......@@ -100,10 +100,10 @@ public:
* \brief Returns the relative weight of a primary variable for
* calculating relative errors.
*/
Scalar primaryVarWeight(int vertIdx, int pvIdx) const
Scalar primaryVarWeight(int globalVertexIdx, int pvIdx) const
{
if (Indices::pressureIdx == pvIdx)
return 1e-5;
return std::min(1.0/this->prevSol()[globalVertexIdx][pvIdx], 1.0);
return 1;
}
......
......@@ -214,20 +214,25 @@ public:
* \brief Returns the relative weight of a primary variable for
* calculating relative errors.
*/
Scalar primaryVarWeight(int vertIdx, int pvIdx) const
Scalar primaryVarWeight(int globalVertexIdx, int pvIdx) const
{
if (Indices::pressureIdx == pvIdx)
return 1e-5;
return std::min(1.0/this->oldSol()[globalVertexIdx][pvIdx], 1);
return 1;
}
/*!
* \brief Called by the BoxModel's update method.
* \brief Called by the problem if a timeintegration was
* successful, post processing of the solution is done and the
* result has been written to disk.
*
* This should perpare the model for the next time integration.
*/
void updateSuccessful()
void advanceTimeLevel()
{
ParentType::updateSuccessful();
ParentType::advanceTimeLevel();
// update the phase state
updateOldPhasePresence_();
setSwitched_(false);
}
......
......@@ -130,7 +130,8 @@ public:
* \brief Compute the global residual for an arbitrary solution
* vector.
*/
Scalar globalResidual(SolutionVector &dest, const SolutionVector &u)
Scalar globalResidual(SolutionVector &dest,
const SolutionVector &u)
{
SolutionVector tmp(curSol());
curSol() = u;
......@@ -351,14 +352,6 @@ public:
*/
void updateSuccessful()
{
// the jacobian matrix of the last iteration of the current
// time step is the same as the jacobian of the first
// iteration of the next time step
if (enableJacobianRecycling)
jacAsm_->setMatrixReuseable(true);
// make the current solution the previous one.
uPrev_ = uCur_;
};
/*!
......@@ -375,6 +368,19 @@ public:
jacAsm_->reassembleAll();
};
/*!
* \brief Called by the problem if a timeintegration was
* successful, post processing of the solution is done and the
* result has been written to disk.
*
* This should perpare the model for the next time integration.
*/
void advanceTimeLevel()
{
// make the current solution the previous one.
uPrev_ = uCur_;
}
/*!
* \brief Serializes the current state of the model.
*/
......
......@@ -176,11 +176,8 @@ public:
* timestep has been computed and the simulation time has
* been updated.
*/
Scalar nextTimeStepSize()
{
Scalar dt = asImp_().timeManager().timeStepSize();
return newtonCtl_.suggestTimeStepSize(dt);
};
Scalar nextTimeStepSize(Scalar dt)
{ return newtonCtl_.suggestTimeStepSize(dt); };
/*!
* \brief Returns true if a restart file should be written to
......@@ -208,13 +205,26 @@ public:
{ return true; }
/*!
* \brief Called by the time manager after the time integration.
* \brief Called by the time manager after the time integration to
* do some post processing on the solution.
*/
void postTimeStep()
{ }
/*!
* \brief Called when the end of an simulation episode is reached.
* \brief Called by the time manager after everything which can be
* done about the current time step is finished and the
* model should be prepared to do the next time integration.
*/
void advanceTimeLevel()
{
model_->advanceTimeLevel();
}
/*!
* \brief Called when the end of an simulation episode is reached.
*
* Typically a new episode should be started in this method.
*/
void episodeEnd()
{
......
......@@ -336,28 +336,31 @@ public:
if (problem_->shouldWriteOutput())
problem_->writeOutput();
// perpare the model for the next time integration
problem_->advanceTimeLevel();
// advance the simulated time by the current time step size
Scalar dt = timeStepSize();
time_ += timeStepSize_;
time_ += dt;
++timeStepIdx_;
// write restart file if mandated by the problem
if (problem_->shouldWriteRestartFile())
problem_->serialize();
// notify the problem if an episode is finished
if (episodeIsOver())
problem_->episodeEnd();
// notify the problem that the timestep is done and ask it
// for a suggestion for the next timestep size
// set the time step size for the next step
setTimeStepSize(problem_->nextTimeStepSize());
Scalar nextDt = timeStepSize();
setTimeStepSize(problem_->nextTimeStepSize(timeStepSize_));
if (verbose_) {
std::cout <<
boost::format("Time step %d done. CPU time:%.4g, time:%.4g, last step size:%.4g, next step size:%.4g\n")
%timeStepIndex()%timer.elapsed()%time()%dt%nextDt;
boost::format("Time step %d done. CPU time:%.4g, time:%.4g, time step size:%.4g\n")
%timeStepIndex()%timer.elapsed()%time()%dt;
}
}
......
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