Commit 98bc2c45 authored by Lukas Riedel's avatar Lukas Riedel

controller now steps directly to time stamps. introduced minimal 'blind step'...

controller now steps directly to time stamps. introduced minimal 'blind step' to ensure that BCs are queried correctly #25
parent 175fc994
......@@ -32,7 +32,7 @@ public:
: time(config.get<R>("time.start"))
, dt(config.get<R>("time.startTimestep"))
, verbose(config.get<int>("output.verbose"))
, eps(1e-10)
, eps(1e-5)
, dtmax(config.get<R>("time.maxTimestep"))
, dtmin(config.get<R>("time.minTimestep"))
, dtinc(config.get<R>("time.timestepIncreaseFactor"))
......@@ -50,7 +50,7 @@ public:
// Check whether first time step needs adjustment
R changeTime = tsc.getNextTimeStamp(time);
if(changeTime>0.0 && changeTime-time < dt){
dt = changeTime-time+dtmin;
dt = changeTime-time-eps;
if(verbose>2){
std::cout << "ADAPTING TIME STEP: DT : "
<< std::setprecision(4) << std::scientific << dt
......@@ -65,11 +65,11 @@ public:
}
/// Return current time
R getTime () const { return time; }
inline R getTime () const { return time; }
/// Return timestep for next calculation
R getDT () const { return dt; }
inline R getDT () const { return dt; }
/// Return maximum number of Newton iterations allowed for next calculation
int getIterations () const { return it; }
inline int getIterations () const { return it; }
/// Return boolean whether new time step shall be computed
bool doStep () const {
if(time<tEnd-eps) return true;
......@@ -86,28 +86,36 @@ public:
* \return Boolean if solution is valid
* \throw Dune::Exception Newton solver does not converge at dt>=dtmin and it<=itmax
*/
bool validate (const bool& exc)
bool validate (const bool exc)
{
bool adapt_to_end = false, adapt_to_bc = false;
R changeTime = 0.0;
if (!exc) // solution was successfully computed
if (!exc) // solution was successfully computed
{
// time has advanced after calculation
time+=dt;
if(time>tEnd) // Simulation has ended. Do nothing
if(time>=tEnd) // Simulation has ended. Do nothing
return true;
dt = std::min(dt*dtinc,dtmax);
changeTime = tsc.getNextTimeStamp(time);
if(changeTime<0.0 && time+dt>tEnd){ // time step adjustment to tEnd
dt = tEnd-time+dtmin;
if(changeTime==time+eps){
// small step to ensure that next time step starts with new BC
time = changeTime;
changeTime = tsc.getNextTimeStamp(time);
}
if(changeTime<0.0 && time+dt>tEnd){
// time step adjustment to tEnd
dt = tEnd-time;
adapt_to_end = true;
}
else if(changeTime>0.0 && time+dt>changeTime){ // time step adjustment to BC Change
dt = changeTime-time+dtmin;
else if(changeTime>0.0 && time+dt>changeTime){
// time step adjustment to BC Change
dt = changeTime-time-eps;
adapt_to_bc = true;
}
}
......@@ -157,7 +165,7 @@ private:
/** \param dt Timestep size
* \return Number of allowed Newton steps for inserted dt
*/
int calcIterations (const R& dt)
inline int calcIterations (const R dt)
{
return (int)( (itmin-itmax) * std::log10(dt-dtmin+1.0) / std::log10(dtmax-dtmin+1.0) + itmax );
}
......
Markdown is supported
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