Commit dbd4ccf5 authored by Lukas Riedel's avatar Lukas Riedel

fixed bug where time step could become negative. Controller can now deal with last changeTime=tEnd

parent bb5573a1
......@@ -14,8 +14,8 @@ private:
R dt; //!< current time step
int it; //!< current number of allowed iterations for Newton solver
int verbose; //!< verbosity level
const R eps; //!< error margin
const R dtmax, dtmin; //!< time step limits
const R eps; //!< error margin
const R dtinc, dtdec; //!< time step mutliplicators
R tEnd; //!< simulation time limits
const R itmax,itmin; //!< newton iteration limits
......@@ -32,9 +32,9 @@ public:
: time(config.get<R>("time.start"))
, dt(config.get<R>("time.startTimestep"))
, verbose(config.get<int>("output.verbose"))
, eps(1e-5)
, dtmax(config.get<R>("time.maxTimestep"))
, dtmin(config.get<R>("time.minTimestep"))
, eps(dtmin/10.0)
, dtinc(config.get<R>("time.timestepIncreaseFactor"))
, dtdec(config.get<R>("time.timestepDecreaseFactor"))
, tEnd(config.get<R>("time.end"))
......@@ -48,8 +48,8 @@ public:
userInputCheck();
// Check whether first time step needs adjustment
R changeTime = tsc.getNextTimeStamp(time);
if(changeTime>0.0 && changeTime-time < dt){
const R changeTime = tsc.getNextTimeStamp(time);
if(changeTime>0.0 && time+dt >= changeTime){
dt = changeTime-time-eps;
if(verbose>2){
std::cout << "ADAPTING TIME STEP: DT : "
......@@ -106,26 +106,26 @@ public:
if (!exc) // solution was successfully computed
{
// time has advanced after calculation
time+=dt;
time += dt;
if(time>=tEnd) // Simulation has ended. Do nothing
if(time >= tEnd-eps) // Simulation has ended. Do nothing
return true;
dt = std::min(dt*dtinc,dtmax);
changeTime = tsc.getNextTimeStamp(time);
if(changeTime==time+eps){
if(time >= changeTime-eps && time <= changeTime){
// 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){
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){
else if(changeTime > 0.0 && time+dt >= changeTime){
// time step adjustment to BC Change
dt = changeTime-time-eps;
adapt_to_bc = true;
......
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