OGS 6.2.0-405-gb717f6088
NumLib::ForwardEuler Class Referencefinal

Detailed Description

Forward Euler scheme.

Definition at line 306 of file TimeDiscretization.h.

#include <TimeDiscretization.h>

Inheritance diagram for NumLib::ForwardEuler:
Collaboration diagram for NumLib::ForwardEuler:

Public Member Functions

 ForwardEuler ()
 
 ~ForwardEuler () 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
 
GlobalVector const & getCurrentX (const GlobalVector &) 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...
 
bool isLinearTimeDisc () const override
 
double getDxDx () const override
 
GlobalVector const & getXOld () const
 Returns the solution from the preceding timestep. 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 needsPreload () const
 

Private Attributes

double _t
 $ t_C $ More...
 
double _t_old
 the time of the preceding timestep 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

◆ ForwardEuler()

NumLib::ForwardEuler::ForwardEuler ( )
inline

Definition at line 309 of file TimeDiscretization.h.

310  {
311  }
static NUMLIB_EXPORT VectorProvider & provider
GlobalVector & _x_old
the solution from the preceding timestep

◆ ~ForwardEuler()

NumLib::ForwardEuler::~ForwardEuler ( )
inlineoverride

Definition at line 313 of file TimeDiscretization.h.

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

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

Member Function Documentation

◆ getCurrentTime()

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

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

Implements NumLib::TimeDiscretization.

Definition at line 346 of file TimeDiscretization.h.

347  {
348  return _t_old; // forward Euler does assembly at the preceding timestep
349  }
double _t_old
the time of the preceding timestep

◆ getCurrentX()

GlobalVector const& NumLib::ForwardEuler::getCurrentX ( const GlobalVector &  x_at_new_timestep) const
inlineoverridevirtual

Returns $ x_C $, i.e., the state at which the equation will be assembled.

This method is overridden in the ForwardEuler scheme.

Reimplemented from NumLib::TimeDiscretization.

Definition at line 351 of file TimeDiscretization.h.

353  {
354  return _x_old;
355  }
GlobalVector & _x_old
the solution from the preceding timestep

◆ getDxDx()

double NumLib::ForwardEuler::getDxDx ( ) const
inlineoverridevirtual

Returns $ \partial x_C / \partial x_N $.

The ForwardEuler scheme overrides this.

Reimplemented from NumLib::TimeDiscretization.

Definition at line 368 of file TimeDiscretization.h.

368 { return 0.0; }

◆ getNewXWeight()

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

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

Implements NumLib::TimeDiscretization.

Definition at line 357 of file TimeDiscretization.h.

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

◆ getRelativeChangeFromPreviousTimestep()

double NumLib::ForwardEuler::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 62 of file TimeDiscretization.cpp.

References NumLib::TimeDiscretization::computeRelativeChangeFromPreviousTimestep().

64 {
66 }
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::ForwardEuler::getWeightedOldX ( GlobalVector &  y) const
inlineoverridevirtual

Returns $ x_O $.

Implements NumLib::TimeDiscretization.

Definition at line 358 of file TimeDiscretization.h.

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

359  {
360  namespace LinAlg = MathLib::LinAlg;
361 
362  // y = x_old / delta_t
363  LinAlg::copy(_x_old, y);
364  LinAlg::scale(y, 1.0 / _delta_t);
365  }
GlobalVector & _x_old
the solution from the preceding timestep
double _delta_t
the timestep size
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

◆ getXOld()

GlobalVector const& NumLib::ForwardEuler::getXOld ( ) const
inline

Returns the solution from the preceding timestep.

Definition at line 370 of file TimeDiscretization.h.

370 { return _x_old; }
GlobalVector & _x_old
the solution from the preceding timestep

◆ isLinearTimeDisc()

bool NumLib::ForwardEuler::isLinearTimeDisc ( ) const
inlineoverridevirtual

Tell whether this scheme inherently requires a nonlinear solver or not.

The ForwardEuler scheme is inherently linear in that sense, the others are not.

Reimplemented from NumLib::TimeDiscretization.

Definition at line 367 of file TimeDiscretization.h.

367 { return true; }

◆ nextTimestep()

void NumLib::ForwardEuler::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 339 of file TimeDiscretization.h.

340  {
341  _t_old = _t;
342  _t = t;
343  _delta_t = delta_t;
344  }
double _t_old
the time of the preceding timestep
double _delta_t
the timestep size

◆ popState()

void NumLib::ForwardEuler::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 334 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

335  {
337  }
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::ForwardEuler::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 328 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

330  {
332  }
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::ForwardEuler::setInitialState ( const double  t0,
GlobalVector const &  x0 
)
inlineoverridevirtual

Sets the initial condition.

Implements NumLib::TimeDiscretization.

Definition at line 318 of file TimeDiscretization.h.

References MathLib::LinAlg::copy().

319  {
320  _t = t0;
321  _t_old = t0;
323  }
double _t_old
the time of the preceding timestep
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::ForwardEuler::_delta_t
private

the timestep size

Definition at line 374 of file TimeDiscretization.h.

◆ _t

double NumLib::ForwardEuler::_t
private

$ t_C $

Definition at line 372 of file TimeDiscretization.h.

◆ _t_old

double NumLib::ForwardEuler::_t_old
private

the time of the preceding timestep

Definition at line 373 of file TimeDiscretization.h.

◆ _x_old

GlobalVector& NumLib::ForwardEuler::_x_old
private

the solution from the preceding timestep

Definition at line 375 of file TimeDiscretization.h.


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