43TimeStepper::TimeStepper(
double startTime,
double endTime,
double dt,
bool enforceConstantTimeStep, std::vector<double> additionalTimes)
47 mTotalTimeStepsTaken(0),
48 mAdditionalTimesReachedDeprecated(0),
52 if (startTime > endTime)
54 EXCEPTION(
"The simulation duration must be positive, not " << endTime-startTime);
58 for (
unsigned i=0; i<additionalTimes.size(); i++)
62 if (additionalTimes[i-1] >= additionalTimes[i])
64 EXCEPTION(
"The additional times vector should be in ascending numerical order; "
65 "entry " << i <<
" is less than or equal to entry " << i-1 <<
".");
69 double time_interval = additionalTimes[i] - startTime;
72 if (!Divides(
mDt, time_interval) && (time_interval > DBL_EPSILON))
75 EXCEPTION(
"Additional times are now deprecated. Use only to check whether the given times are met: e.g. Electrode events should only happen on printing steps.");
90 if (enforceConstantTimeStep)
96 EXCEPTION(
"TimeStepper estimates non-constant timesteps will need to be used: check timestep "
97 "divides (end_time-start_time) (or divides printing timestep). "
98 "[End time=" <<
mEnd <<
"; start=" <<
mStart <<
"; dt=" <<
mDt <<
"; error="
99 << fabs(
mEnd-expected_end_time) <<
"]");