OGS
NumLib::FixedTimeStepping Class Referencefinal

Detailed Description

Fixed time stepping algorithm.

This algorithm returns time step size defined by a user priori.

Definition at line 27 of file FixedTimeStepping.h.

#include <FixedTimeStepping.h>

Inheritance diagram for NumLib::FixedTimeStepping:
[legend]
Collaboration diagram for NumLib::FixedTimeStepping:
[legend]

Public Member Functions

 FixedTimeStepping (double t0, double tn, double dt)
 
 FixedTimeStepping (double t0, double tn, const std::vector< double > &vec_all_dt)
 
std::tuple< bool, double > next (double solution_error, int number_iterations) override
 
bool accepted () const override
 return if current time step is accepted or not More...
 
- Public Member Functions inherited from NumLib::TimeStepAlgorithm
 TimeStepAlgorithm (const double t0, const double t_end)
 
 TimeStepAlgorithm (const double t0, const double t_end, const double dt)
 
 TimeStepAlgorithm (const double t0, const double t_end, const std::vector< double > &all_step_sizes)
 
virtual ~TimeStepAlgorithm ()=default
 
double begin () const
 return the beginning of time steps More...
 
double end () const
 return the end of time steps More...
 
const TimeStep getTimeStep () const
 return current time step More...
 
void resetCurrentTimeStep (const double dt)
 reset the current step size from the previous time More...
 
virtual void setAcceptedOrNot (const bool accepted)
 
const std::vector< double > & getTimeStepSizeHistory () const
 return a history of time step sizes More...
 
virtual bool isSolutionErrorComputationNeeded () const
 
virtual bool canReduceTimestepSize () const
 Query the timestepper if further time step size reduction is possible. More...
 

Static Private Member Functions

static double computeEnd (double t_initial, double t_end, const std::vector< double > &dt_vector)
 determine true end time More...
 

Additional Inherited Members

- Protected Attributes inherited from NumLib::TimeStepAlgorithm
const double _t_initial
 initial time More...
 
const double _t_end
 end time More...
 
TimeStep _ts_prev
 previous time step information More...
 
TimeStep _ts_current
 current time step information More...
 
std::vector< double > _dt_vector
 a vector of time step sizes More...
 

Constructor & Destructor Documentation

◆ FixedTimeStepping() [1/2]

NumLib::FixedTimeStepping::FixedTimeStepping ( double  t0,
double  tn,
double  dt 
)

Constructor with homogeneous time step size

A user provides a single time step size \(\Delta t\). Total number of time steps is calculated by

\[ n=\frac{t_{\rm n} - t_0}{\Delta t} \]

.

Parameters
t0start time
tnfinish time
dtuniform time step size

Definition at line 29 of file FixedTimeStepping.cpp.

30  : TimeStepAlgorithm(t0, tn, dt)
31 {
32 }
TimeStepAlgorithm(const double t0, const double t_end)

◆ FixedTimeStepping() [2/2]

NumLib::FixedTimeStepping::FixedTimeStepping ( double  t0,
double  tn,
const std::vector< double > &  vec_all_dt 
)

Constructor with user-specified time step sizes

A user can specify \(\Delta t\) for each time step (i.e. \(\Delta t_1, \Delta t_2, ..., \Delta t_n\)). Time at \(m\) th step is given as

\[ t_{m}=\sum_{i=1}^m \Delta t_i + t_0 \]

.

Parameters
t0start time
tnfinish time
vec_all_dta vector of all time steps

Definition at line 22 of file FixedTimeStepping.cpp.

25  : TimeStepAlgorithm(t0, computeEnd(t0, tn, vec_all_dt), vec_all_dt)
26 {
27 }
static double computeEnd(double t_initial, double t_end, const std::vector< double > &dt_vector)
determine true end time

Member Function Documentation

◆ accepted()

bool NumLib::FixedTimeStepping::accepted ( ) const
inlineoverridevirtual

return if current time step is accepted or not

Implements NumLib::TimeStepAlgorithm.

Definition at line 64 of file FixedTimeStepping.h.

64 { return true; }

◆ computeEnd()

double NumLib::FixedTimeStepping::computeEnd ( double  t_initial,
double  t_end,
const std::vector< double > &  dt_vector 
)
staticprivate

determine true end time

Definition at line 54 of file FixedTimeStepping.cpp.

57 {
58  double t_sum =
59  t_initial + std::accumulate(dt_vector.begin(), dt_vector.end(), 0.);
60  return std::min(t_end, t_sum);
61 }

◆ next()

std::tuple< bool, double > NumLib::FixedTimeStepping::next ( double  solution_error,
int  number_iterations 
)
overridevirtual

Move to the next time step

Parameters
solution_errorSolution error \(e_n\) between two successive time steps.
number_iterationsNumber of non-linear iterations used.
Returns
A step acceptance flag and the computed step size.

Implements NumLib::TimeStepAlgorithm.

Definition at line 34 of file FixedTimeStepping.cpp.

36 {
37  // check if last time step
38  if (_ts_current.steps() == _dt_vector.size() ||
39  std::abs(_ts_current.current() - _t_end) <
40  std::numeric_limits<double>::epsilon())
41  {
42  return std::make_tuple(false, 0.0);
43  }
44 
45  double dt = _dt_vector[_ts_current.steps()];
46  if (_ts_current.current() + dt > _t_end)
47  { // upper bound by t_end
48  dt = _t_end - _ts_current.current();
49  }
50 
51  return std::make_tuple(true, dt);
52 }
std::vector< double > _dt_vector
a vector of time step sizes
TimeStep _ts_current
current time step information
const double _t_end
end time
double current() const
return current time step
Definition: TimeStep.h:109
std::size_t steps() const
the number of time _steps
Definition: TimeStep.h:113

References NumLib::TimeStepAlgorithm::_dt_vector, NumLib::TimeStepAlgorithm::_t_end, NumLib::TimeStepAlgorithm::_ts_current, NumLib::TimeStep::current(), and NumLib::TimeStep::steps().


The documentation for this class was generated from the following files: