OGS 6.2.1-76-gbb689931b
NumLib::BackwardEuler Class Referencefinal

Detailed Description

Backward Euler scheme.

Definition at line 249 of file TimeDiscretization.h.

#include <TimeDiscretization.h>

Inheritance diagram for NumLib::BackwardEuler:
Collaboration diagram for NumLib::BackwardEuler:

Public Member Functions

 BackwardEuler ()
 
 ~BackwardEuler () override
 
void setInitialState (const double t0, GlobalVector const &x0) override
 Sets the initial condition. More...
 
double getRelativeChangeFromPreviousTimestep (GlobalVector const &x, MathLib::VecNormType norm_type) override
 
void pushState (const double, GlobalVector const &x, InternalMatrixStorage const &) override
 
void popState (GlobalVector &x) override
 
void nextTimestep (const double t, const double delta_t) override
 
double getCurrentTime () const override
 
double getNewXWeight () const override
 Returns $ \alpha = \partial \hat x / \partial x_N $. More...
 
void getWeightedOldX (GlobalVector &y) const override
 Returns $ x_O $. More...
 
- Public Member Functions inherited from NumLib::TimeDiscretization
 TimeDiscretization ()=default
 
void getXdot (GlobalVector const &x_at_new_timestep, GlobalVector &xdot) const
 
virtual ~TimeDiscretization ()=default
 
virtual bool isLinearTimeDisc () const
 
virtual double getDxDx () const
 
virtual GlobalVector const & getCurrentX (GlobalVector const &x_at_new_timestep) const
 
virtual bool needsPreload () const
 

Private Attributes

double _t = std::numeric_limits<double>::quiet_NaN()
 $ t_C $ More...
 
double _delta_t
 the timestep size More...
 
GlobalVector & _x_old
 the solution from the preceding timestep More...
 

Additional Inherited Members

- Protected Member Functions inherited from NumLib::TimeDiscretization
double computeRelativeChangeFromPreviousTimestep (GlobalVector const &x, GlobalVector const &x_old, MathLib::VecNormType norm_type)
 
- Protected Attributes inherited from NumLib::TimeDiscretization
std::unique_ptr< GlobalVector > _dx
 Used to store $ u_{n+1}-u_{n}$. More...
 

Constructor & Destructor Documentation

◆ BackwardEuler()

NumLib::BackwardEuler::BackwardEuler ( )
inline

Definition at line 252 of file TimeDiscretization.h.

254  {
255  }
GlobalVector & _x_old
the solution from the preceding timestep
static NUMLIB_EXPORT VectorProvider & provider

◆ ~BackwardEuler()

NumLib::BackwardEuler::~BackwardEuler ( )
inlineoverride

Definition at line 257 of file TimeDiscretization.h.

References NumLib::GlobalVectorProvider::provider, and NumLib::VectorProvider::releaseVector().

258  {
260  }
GlobalVector & _x_old
the solution from the preceding timestep
static NUMLIB_EXPORT VectorProvider & provider
virtual void releaseVector(GlobalVector const &x)=0

Member Function Documentation

◆ getCurrentTime()

double NumLib::BackwardEuler::getCurrentTime ( ) const
inlineoverridevirtual

Returns $ t_C $, i.e., the time at which the equation will be assembled.

Implements NumLib::TimeDiscretization.

Definition at line 288 of file TimeDiscretization.h.

288 { return _t; }

◆ getNewXWeight()

double NumLib::BackwardEuler::getNewXWeight ( ) const
inlineoverridevirtual

Returns $ \alpha = \partial \hat x / \partial x_N $.

Implements NumLib::TimeDiscretization.

Definition at line 289 of file TimeDiscretization.h.

289 { return 1.0 / _delta_t; }
double _delta_t
the timestep size

◆ getRelativeChangeFromPreviousTimestep()

double NumLib::BackwardEuler::getRelativeChangeFromPreviousTimestep ( GlobalVector const &  x,
MathLib::VecNormType  norm_type 
)
overridevirtual

Get the relative change of solutions between two successive time steps by $ e_n = \|u^{n+1}-u^{n}\|/\|u^{n+1}\| $.

Parameters
xThe solution at the current timestep.
norm_typeThe type of global vector norm.

Implements NumLib::TimeDiscretization.

Definition at line 56 of file TimeDiscretization.cpp.

References NumLib::TimeDiscretization::computeRelativeChangeFromPreviousTimestep().

58 {
60 }
GlobalVector & _x_old
the solution from the preceding timestep
double computeRelativeChangeFromPreviousTimestep(GlobalVector const &x, GlobalVector const &x_old, MathLib::VecNormType norm_type)

◆ getWeightedOldX()

void NumLib::BackwardEuler::getWeightedOldX ( GlobalVector &  y) const
inlineoverridevirtual

Returns $ x_O $.

Implements NumLib::TimeDiscretization.

Definition at line 290 of file TimeDiscretization.h.

References MathLib::LinAlg::copy(), and MathLib::LinAlg::scale().

291  {
292  namespace LinAlg = MathLib::LinAlg;
293 
294  // y = x_old / delta_t
295  LinAlg::copy(_x_old, y);
296  LinAlg::scale(y, 1.0 / _delta_t);
297  }
double _delta_t
the timestep size
GlobalVector & _x_old
the solution from the preceding timestep
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36
void scale(MatrixOrVector &x, double const a)
Scales x by a.
Definition: LinAlg.h:43

◆ nextTimestep()

void NumLib::BackwardEuler::nextTimestep ( const double  t,
const double  delta_t 
)
inlineoverridevirtual

Indicate that the computation of a new timestep is being started now.

Warning
Currently changing timestep sizes are not supported. Thus, delta_t must not change throughout the entire time integration process! This is not checked by this code!

Implements NumLib::TimeDiscretization.

Definition at line 282 of file TimeDiscretization.h.

283  {
284  _t = t;
285  _delta_t = delta_t;
286  }
double _delta_t
the timestep size

◆ popState()

void NumLib::BackwardEuler::popState ( GlobalVector &  x)
inlineoverridevirtual

Restores the given vector x to its old value. Used only for repeating of the time step with new time step size when the current time step is rejected. The restored x is only used as an initial guess for linear solver in the first Picard nonlinear iteration.

Parameters
xThe solution at the current time step, which is going to be reset to its previous value.

Implements NumLib::TimeDiscretization.

Definition at line 277 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

278  {
280  }
GlobalVector & _x_old
the solution from the preceding timestep
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

◆ pushState()

void NumLib::BackwardEuler::pushState ( const double  t,
GlobalVector const &  x,
InternalMatrixStorage const &  strg 
)
inlineoverridevirtual

Indicate that the current timestep is done and that you will proceed to the next one.

Warning
Do not use this method for setting the initial condition, rather use setInitialState()!
Parameters
tThe current timestep.
xThe solution at the current timestep.
strgTrigger storing some internal state. Currently only used by the CrankNicolson scheme.

Implements NumLib::TimeDiscretization.

Definition at line 271 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

273  {
275  }
GlobalVector & _x_old
the solution from the preceding timestep
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

◆ setInitialState()

void NumLib::BackwardEuler::setInitialState ( const double  t0,
GlobalVector const &  x0 
)
inlineoverridevirtual

Sets the initial condition.

Implements NumLib::TimeDiscretization.

Definition at line 262 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

263  {
264  _t = t0;
266  }
GlobalVector & _x_old
the solution from the preceding timestep
void copy(MatrixOrVector const &x, MatrixOrVector &y)
Copies x to y.
Definition: LinAlg.h:36

Member Data Documentation

◆ _delta_t

double NumLib::BackwardEuler::_delta_t
private
Initial value:
=
std::numeric_limits<double>::quiet_NaN()

the timestep size

Definition at line 301 of file TimeDiscretization.h.

◆ _t

double NumLib::BackwardEuler::_t = std::numeric_limits<double>::quiet_NaN()
private

$ t_C $

Definition at line 300 of file TimeDiscretization.h.

◆ _x_old

GlobalVector& NumLib::BackwardEuler::_x_old
private

the solution from the preceding timestep

Definition at line 303 of file TimeDiscretization.h.


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