#include <TimeStepper.hpp>
Public Member Functions | |
TimeStepper (double startTime, double endTime, double dt, bool enforceConstantTimeStep=false, std::vector< double > additionalTimes=std::vector< double >()) | |
void | AdvanceOneTimeStep () |
double | GetTime () const |
double | GetNextTime () const |
double | GetNextTimeStep () |
bool | IsTimeAtEnd () const |
unsigned | EstimateTimeSteps () const |
unsigned | GetTotalTimeStepsTaken () const |
Private Member Functions | |
double | CalculateNextTime () |
Private Attributes | |
double | mStart |
double | mEnd |
double | mDt |
unsigned | mTotalTimeStepsTaken |
unsigned | mAdditionalTimesReached |
double | mTime |
double | mNextTime |
std::vector< double > | mAdditionalTimes |
Friends | |
class | TestTimeStepper |
An incremented integer counter is used to calculate the current time and ensure that the correct end time.
Definition at line 41 of file TimeStepper.hpp.
TimeStepper::TimeStepper | ( | double | startTime, | |
double | endTime, | |||
double | dt, | |||
bool | enforceConstantTimeStep = false , |
|||
std::vector< double > | additionalTimes = std::vector<double> () | |||
) |
Create a new time stepper over some simulation interval. Time units are not specified, but all parameters should have consistent units.
startTime | the start of the interval | |
endTime | the end of the interval | |
dt | the time step to use. | |
enforceConstantTimeStep | If this is true the stepper estimates whether non-constant timesteps will be used and quits if so. | |
additionalTimes | If the timestepper needs to stop at certain additional times, that aren't (necessarily) multiples of dt, they can be passed in in this std::vector. Defaults to empty. These times must be in ascending order. |
Definition at line 38 of file TimeStepper.cpp.
References CalculateNextTime(), EstimateTimeSteps(), EXCEPTION, mAdditionalTimes, mDt, mEnd, mNextTime, and mStart.
void TimeStepper::AdvanceOneTimeStep | ( | ) |
Step forward one step in time and update member variables.
Definition at line 100 of file TimeStepper.cpp.
References CalculateNextTime(), EXCEPTION, mNextTime, mTime, and mTotalTimeStepsTaken.
Referenced by AbstractOneStepIvpOdeSolver::InternalSolve(), NhsModelWithBackwardSolver::RunDoNotUpdate(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), CvodeAdaptor::Solve(), AbstractOneStepIvpOdeSolver::Solve(), CardiacElectroMechanicsProblem< DIM >::Solve(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCvodeCell::Solve().
double TimeStepper::GetTime | ( | ) | const |
Get the time
Definition at line 112 of file TimeStepper.cpp.
References mTime.
Referenced by AbstractOneStepIvpOdeSolver::InternalSolve(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), AbstractOneStepIvpOdeSolver::Solve(), CardiacElectroMechanicsProblem< DIM >::Solve(), and AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve().
double TimeStepper::GetNextTime | ( | ) | const |
Get the value time will take at the next step
Definition at line 117 of file TimeStepper.cpp.
References mNextTime.
Referenced by CvodeAdaptor::Solve(), AbstractOneStepIvpOdeSolver::Solve(), CardiacElectroMechanicsProblem< DIM >::Solve(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCvodeCell::Solve().
double TimeStepper::GetNextTimeStep | ( | ) |
Get the size of the next time step which will be taken. GetNextTimeStep() == GetNextTime() - GetTime()
Definition at line 122 of file TimeStepper.cpp.
References mAdditionalTimes, mAdditionalTimesReached, mDt, mEnd, mNextTime, and mTime.
Referenced by AbstractOneStepIvpOdeSolver::InternalSolve(), and AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve().
bool TimeStepper::IsTimeAtEnd | ( | ) | const |
True when GetTime == endTime
Definition at line 142 of file TimeStepper.cpp.
Referenced by AbstractOneStepIvpOdeSolver::InternalSolve(), NhsModelWithBackwardSolver::RunDoNotUpdate(), AbstractDynamicLinearPdeSolver< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), CvodeAdaptor::Solve(), AbstractOneStepIvpOdeSolver::Solve(), CardiacElectroMechanicsProblem< DIM >::Solve(), AbstractCardiacProblem< ELEMENT_DIM, SPACE_DIM, PROBLEM_DIM >::Solve(), and AbstractCvodeCell::Solve().
unsigned TimeStepper::EstimateTimeSteps | ( | ) | const |
Estimate number of time steps, which may be an overestimate Used to reserve memory for writing intermediate solutions.
Definition at line 147 of file TimeStepper.cpp.
References mAdditionalTimes, mDt, mEnd, and mStart.
Referenced by CvodeAdaptor::Solve(), AbstractOneStepIvpOdeSolver::Solve(), AbstractCvodeCell::Solve(), and TimeStepper().
unsigned TimeStepper::GetTotalTimeStepsTaken | ( | ) | const |
The number of time AdvanceOneTimeStep() has been called.
Definition at line 152 of file TimeStepper.cpp.
References mTotalTimeStepsTaken.
Referenced by CvodeAdaptor::Solve(), AbstractOneStepIvpOdeSolver::Solve(), and AbstractCvodeCell::Solve().
double TimeStepper::CalculateNextTime | ( | ) | [private] |
Compute what the time will be after the next time step.
Definition at line 81 of file TimeStepper.cpp.
References mAdditionalTimes, mAdditionalTimesReached, mDt, mEnd, mStart, and mTotalTimeStepsTaken.
Referenced by AdvanceOneTimeStep(), and TimeStepper().
double TimeStepper::mStart [private] |
The start time.
Definition at line 100 of file TimeStepper.hpp.
Referenced by CalculateNextTime(), EstimateTimeSteps(), and TimeStepper().
double TimeStepper::mEnd [private] |
The end time.
Definition at line 103 of file TimeStepper.hpp.
Referenced by CalculateNextTime(), EstimateTimeSteps(), GetNextTimeStep(), IsTimeAtEnd(), and TimeStepper().
double TimeStepper::mDt [private] |
The size of time step.
Definition at line 106 of file TimeStepper.hpp.
Referenced by CalculateNextTime(), EstimateTimeSteps(), GetNextTimeStep(), and TimeStepper().
unsigned TimeStepper::mTotalTimeStepsTaken [private] |
The total number of time steps taken, including those to get one of the 'additional times'.
Definition at line 109 of file TimeStepper.hpp.
Referenced by AdvanceOneTimeStep(), CalculateNextTime(), and GetTotalTimeStepsTaken().
unsigned TimeStepper::mAdditionalTimesReached [private] |
The number of times one of the 'additional times' has been passed.
Definition at line 112 of file TimeStepper.hpp.
Referenced by CalculateNextTime(), and GetNextTimeStep().
double TimeStepper::mTime [private] |
The current time.
Definition at line 115 of file TimeStepper.hpp.
Referenced by AdvanceOneTimeStep(), GetNextTimeStep(), GetTime(), and IsTimeAtEnd().
double TimeStepper::mNextTime [private] |
What the time will be after the next time step.
Definition at line 118 of file TimeStepper.hpp.
Referenced by AdvanceOneTimeStep(), GetNextTime(), GetNextTimeStep(), and TimeStepper().
std::vector<double> TimeStepper::mAdditionalTimes [private] |
Vector to store the additional times the stepper must stop at.
Definition at line 124 of file TimeStepper.hpp.
Referenced by CalculateNextTime(), EstimateTimeSteps(), GetNextTimeStep(), and TimeStepper().