To solve time stepping problems, i.e. systems of linear ordinary differential equations of the form [A2]{y"} + [A1]{y'} + [A0]{y} = {b}. More...
#include <TimeStepping.h>
Public Member Functions | |
TimeStepping () | |
Default constructor. | |
TimeStepping (TimeScheme s, real_t time_step=theTimeStep, real_t final_time=theFinalTime) | |
Constructor using time discretization data. More... | |
~TimeStepping () | |
Destructor. | |
void | set (TimeScheme s, real_t time_step=theTimeStep, real_t final_time=theFinalTime) |
Define data of the differential equation or system. More... | |
void | setLinearSolver (LinearSolver &ls) |
Set reference to LinearSolver instance. More... | |
void | setPDE (Equa &eq, bool nl=false) |
Define partial differential equation to solve. More... | |
void | setRK4RHS (Vect< real_t > &f) |
Set intermediate right-hand side vector for the Runge-Kutta method. More... | |
void | setRK3_TVDRHS (Vect< real_t > &f) |
Set intermediate right-hand side vector for the TVD Runge-Kutta 3 method. More... | |
void | setInitial (Vect< real_t > &u) |
Set initial condition for the system of differential equations. More... | |
void | setInitial (Vect< real_t > &u, Vect< real_t > &v) |
Set initial condition for a system of differential equations. More... | |
void | setInitialRHS (Vect< real_t > &f) |
Set initial RHS for a system of differential equations when the used scheme requires it. More... | |
void | setRHS (Vect< real_t > &b) |
Set right-hand side vector. | |
void | setRHS (string exp) |
Set right-hand side as defined by a regular expression. More... | |
void | setBC (Vect< real_t > &u) |
Set vector containing boundary condition to enforce. | |
void | setBC (int code, string exp) |
Set boundary condition as defined by a regular expression. More... | |
void | setNewmarkParameters (real_t beta, real_t gamma) |
Define parameters for the Newmark scheme. More... | |
void | setConstantMatrix () |
Say that matrix problem is constant. More... | |
void | setNonConstantMatrix () |
Say that matrix problem is variable. More... | |
void | setLinearSolver (Iteration s=DIRECT_SOLVER, Preconditioner p=DIAG_PREC) |
Set linear solver data. More... | |
void | setNLTerm0 (Vect< real_t > &a0, Matrix< real_t > &A0) |
Set vectors defining a nonlinear first order system of ODEs. More... | |
void | setNLTerm (Vect< real_t > &a0, Vect< real_t > &a1, Vect< real_t > &a2) |
Set vectors defining a nonlinear second order system of ODEs. More... | |
real_t | runOneTimeStep () |
Run one time step. More... | |
void | run (bool opt=false) |
Run the time stepping procedure. More... | |
void | Assembly (const Element &el, real_t *b, real_t *A0, real_t *A1, real_t *A2=nullptr) |
Assemble element arrays into global matrix and right-hand side. More... | |
void | SAssembly (const Side &sd, real_t *b, real_t *A=nullptr) |
Assemble side arrays into global matrix and right-hand side. More... | |
LinearSolver & | getLSolver () |
Return LinearSolver instance. | |
Detailed Description
To solve time stepping problems, i.e. systems of linear ordinary differential equations of the form [A2]{y"} + [A1]{y'} + [A0]{y} = {b}.
- Copyright
- GNU Lesser Public License
Features:
- The system may be first or second order (first and/or second order time derivatives
-
The following time integration schemes can be used:
-
For first order systems: The following schemes are implemented Forward Euler (value: FORWARD_EULER)
Backward Euler (value: BACKWARD_EULER)
Crank-Nicolson (value: CRANK_NICOLSON)
Heun (value: HEUN)
2nd Order Adams-Bashforth (value: AB2)
4-th order Runge-Kutta (value: RK4)
2nd order Backward Differentiation Formula (value: BDF2) - For second order systems: The following schemes are implemented Newmark (value: NEWMARK)
-
For first order systems: The following schemes are implemented Forward Euler (value: FORWARD_EULER)
Constructor & Destructor Documentation
◆ TimeStepping()
TimeStepping | ( | TimeScheme | s, |
real_t | time_step = theTimeStep , |
||
real_t | final_time = theFinalTime |
||
) |
Constructor using time discretization data.
- Parameters
-
[in] s Choice of the scheme: To be chosen in the enumerated variable TimeScheme (see the presentation of the class) [in] time_step Value of the time step. This value will be modified if an adaptive method is used. The default value for this parameter if the value given by the global variable theTimeStep
[in] final_time Value of the final time (time starts at 0). The default value for this parameter is the value given by the global variable theFinalTime
Member Function Documentation
◆ Assembly()
Assemble element arrays into global matrix and right-hand side.
This member function is to be called from finite element equation classes
- Parameters
-
[in] el Reference to Element class [in] b Pointer to element right-hand side [in] A0 Pointer to matrix of 0-th order term (involving no time derivative) [in] A1 Pointer to matrix of first order term (involving time first derivative) [in] A2 Pointer to matrix of second order term (involving time second derivative) [Default: nullptr
]
◆ run()
void run | ( | bool | opt = false | ) |
Run the time stepping procedure.
- Parameters
-
[in] opt Flag to say if problem matrix is constant while time stepping (true) or not (Default value is false)
- Note
- This argument is not used if the time stepping scheme is explicit
◆ runOneTimeStep()
real_t runOneTimeStep | ( | ) |
Run one time step.
- Returns
- Value of new time step if this one is updated
◆ SAssembly()
Assemble side arrays into global matrix and right-hand side.
This member function is to be called from finite element equation classes
- Parameters
-
[in] sd Reference to Side class [in] b Pointer to side right-hand side [in] A Pointer to matrix [Default: nullptr
]
◆ set()
void set | ( | TimeScheme | s, |
real_t | time_step = theTimeStep , |
||
real_t | final_time = theFinalTime |
||
) |
Define data of the differential equation or system.
- Parameters
-
[in] s Choice of the scheme: To be chosen in the enumerated variable TimeScheme (see the presentation of the class) [in] time_step Value of the time step. This value will be modified if an adaptive method is used. The default value for this parameter if the value given by the global variable theTimeStep
[in] final_time Value of the final time (time starts at 0). The default value for this parameter is the value given by the global variable theFinalTime
◆ setBC()
void setBC | ( | int | code, |
string | exp | ||
) |
Set boundary condition as defined by a regular expression.
- Parameters
-
[in] code Code for which expression is assigned [in] exp Regular expression to assign as a function of x
,y
,z
andt
◆ setConstantMatrix()
void setConstantMatrix | ( | ) |
Say that matrix problem is constant.
This is useful if the linear system is solved by a factorization method but has no effect otherwise
◆ setInitial() [1/2]
Set initial condition for the system of differential equations.
- Parameters
-
[in] u Vector containing initial condition for the unknown
- Remarks
- If a second-order differential equation is to be solved, use the the same function with two initial vectors (one for the unknown, the second for its time derivative)
◆ setInitial() [2/2]
Set initial condition for a system of differential equations.
- Parameters
-
[in] u Vector containing initial condition for the unknown [in] v Vector containing initial condition for the time derivative of the unknown
- Note
- This function can be used to provide solution at previous time step if a restarting procedure is used.
- This member function is to be used only in the case of a second order system
◆ setInitialRHS()
Set initial RHS for a system of differential equations when the used scheme requires it.
Giving the right-hand side at initial time is somtimes required for high order methods like Runge-Kutta
- Parameters
-
[in] f Vector containing right-hand side at initial time. This vector is helpful for high order methods
- Note
- This function can be used to provide solution at previous time step if a restarting procedure is used.
◆ setLinearSolver() [1/2]
void setLinearSolver | ( | Iteration | s = DIRECT_SOLVER , |
Preconditioner | p = DIAG_PREC |
||
) |
Set linear solver data.
- Parameters
-
[in] s Solver identification parameter. To be chosen in the enumeration variable Iteration:
DIRECT_SOLVER, CG_SOLVER, CGS_SOLVER, BICG_SOLVER, BICG_STAB_SOLVER, GMRES_SOLVER, QMR_SOLVER [Default:DIRECT_SOLVER
][in] p Preconditioner identification parameter. To be chosen in the enumeration variable Preconditioner:
IDENT_PREC, DIAG_PREC, ILU_PREC [Default:DIAG_PREC
]
- Note
- The argument p has no effect if the solver is DIRECT_SOLVER
◆ setLinearSolver() [2/2]
void setLinearSolver | ( | LinearSolver & | ls | ) |
Set reference to LinearSolver instance.
- Parameters
-
[in] ls Reference to LinearSolver instance
◆ setNewmarkParameters()
Define parameters for the Newmark scheme.
- Parameters
-
[in] beta Parameter beta [Default: 0.25
][in] gamma Parameter gamma [Default: 0.5
]
◆ setNLTerm()
Set vectors defining a nonlinear second order system of ODEs.
The ODE system has the form a2(u)'' + a1(u)' + a0(u) = 0
◆ setNLTerm0()
◆ setNonConstantMatrix()
void setNonConstantMatrix | ( | ) |
Say that matrix problem is variable.
This is useful if the linear system is solved by a factorization method but has no effect otherwise
◆ setPDE()
void setPDE | ( | Equa & | eq, |
bool | nl = false |
||
) |
Define partial differential equation to solve.
The used equation class must have been constructed using the Mesh instance
- Parameters
-
[in] eq Reference to equation instance [in] nl Toggle to say if the considered equation is linear [Default: 0
] or not
◆ setRHS()
void setRHS | ( | string | exp | ) |
Set right-hand side as defined by a regular expression.
- Parameters
-
[in] exp Regular expression as a function of x
,y
,z
andt
◆ setRK3_TVDRHS()
Set intermediate right-hand side vector for the TVD Runge-Kutta 3 method.
- Parameters
-
[in] f Vector containing the RHS