Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added: stopping criterion in time stepping #567

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/ASM/TimeDomain.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ struct TimeDomain
double dt; //!< Current timestep (or load parameter) increment
double dtn; //!< Previous timestep (or load parameter) increment
double CFL; //!< Current CFL number (used by CFD simulators)
double incNorm; //!< Norm of change between timesteps
int it; //!< Current iteration within current time/load step
char first; //!< If \e true, this is the first load/time step

//! \brief Default constructor.
explicit TimeDomain(int i = 0, bool f = true) : it(i), first(f)
{ t = dt = dtn = CFL = 0.0; }
{ t = dt = dtn = CFL = incNorm = 0.0; }
//! \brief Constructor for linear problems with fixed (non-zero) time.
explicit TimeDomain(double t0) : t(t0), it(0), first(true)
{ dt = dtn = CFL = 0.0; }
{ dt = dtn = CFL = incNorm = 0.0; }
};

#endif
9 changes: 9 additions & 0 deletions src/SIM/TimeStep.C
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ TimeStep::TimeStep () : step(0), iter(time.it), lstep(0)
f1 = 1.5;
f2 = 0.25;
maxStep = niter = 0;
stop_tol = 0.0;
stepIt = mySteps.end();
}

Expand All @@ -51,6 +52,7 @@ TimeStep& TimeStep::operator= (const TimeStep& ts)
maxStep = ts.maxStep;
niter = ts.niter;
iter = ts.iter;
stop_tol = ts.stop_tol;

time = ts.time;
mySteps = ts.mySteps;
Expand Down Expand Up @@ -110,6 +112,7 @@ bool TimeStep::parse (const TiXmlElement* elem)
utl::getAttribute(elem,"dtMax",dtMax);
utl::getAttribute(elem,"maxCFL",maxCFL);
utl::getAttribute(elem,"nInitStep",nInitStep);
utl::getAttribute(elem,"stop_tolerance",stop_tol);
utl::getAttribute(elem,"maxStep",maxStep);
utl::getAttribute(elem,"f1",f1);
utl::getAttribute(elem,"f2",f2);
Expand Down Expand Up @@ -266,6 +269,12 @@ bool TimeStep::increment ()
<< std::endl;
return false;
}
else if (time.incNorm > 0.0 && time.incNorm < stop_tol)
{
IFEM::cout <<"\n ** Terminating, solution increment norm "
<< time.incNorm << " less than tolerance " << stop_tol << std::endl;
return false;
}

niter = iter;
time.t += time.dt;
Expand Down
5 changes: 5 additions & 0 deletions src/SIM/TimeStep.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ class TimeStep
//! \brief Returns \e true if the end of the simulation has been reached.
bool finished() const;

//! \brief Returns configured stopping tolerance.
double stopTolerance() const { return stop_tol; }

//! \brief Serialize internal state for restarting purposes.
//! \param data Container for serialized data
bool serialize(std::map<std::string,std::string>& data) const;
Expand All @@ -87,6 +90,8 @@ class TimeStep
double f1; //!< Scale factor for increased time step size
double f2; //!< Scale factor for reduced time step size

double stop_tol; //!< Stop time step loop if incNorm < stop_tol

typedef std::pair<std::vector<double>,double> Step; //!< Time step definition
typedef std::vector<Step> TimeSteps; //!< Time step container

Expand Down