![]() |
Vulpes
0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
|
Leapfrog solver, in velocity Verlet form, for linear second order problems of the form. More...
#include <leapfrog.hpp>
Public Types | |
| using | real_t = PetscScalar |
| using | ForceFunc = std::function<void(real_t, la::Vector&)> |
Public Member Functions | |
| LeapfrogSolver (real_t time_step, real_t initial_time, real_t final_time, const la::SparseMatrix &lin_op, const la::SparseMatrix &mass, const la::Vector &u0, const la::Vector &v0, const ForceFunc &force_func) | |
| void | step () |
| void | setSolverType (la::LinearSolver::Type solver_type, la::LinearSolver::PrecondType pc_type) |
| auto & | getSolver () |
| const la::Vector & | getSolution () const |
| la::Vector | getVelocity () |
| Velocity du/dt, obtained solving a system with M. | |
| real_t | time () const |
| real_t | finalTime () const |
Private Member Functions | |
| void | setupSolver () |
Private Attributes | |
| real_t | m_time_step |
| real_t | m_initial_time |
| real_t | m_time |
| real_t | m_final_time |
| PetscInt | m_iter = 0 |
| const la::SparseMatrix & | m_mass |
| const la::SparseMatrix & | m_lin_op |
| la::SparseMatrix | m_RHS |
| la::Vector | m_u |
| la::Vector | m_u_old |
| la::Vector | m_w |
| la::Vector * | m_f_old = nullptr |
| la::Vector * | m_f_new = nullptr |
| la::Vector | m_f_1 |
| la::Vector | m_f_2 |
| la::Vector | m_tmp |
| la::Vector | m_rhs |
| la::LinearSolver | m_solver |
| la::LinearSolver::Type | m_solver_type = la::LinearSolver::PrecondOnly |
| la::LinearSolver::PrecondType | m_pc_type = la::LinearSolver::MUMPS |
| bool | m_solver_ready = false |
| const ForceFunc | m_force_func |
Leapfrog solver, in velocity Verlet form, for linear second order problems of the form.
M d^2u/dt^2 + A u = F(t)
With w = M du/dt, every step computes
M u_{n+1} = (M - h^2/2 A) u_{n} + h w_{n} + h^2/2 F_{n} w_{n+1} = w_{n} - h/2 A (u_{n} + u_{n+1}) + h/2 (F_{n} + F_{n+1})
The scheme is explicit and second order: the only system to solve has the matrix M, factorized once. For A symmetric positive definite it is stable for h sqrt(lambda_max) < 2, with lambda_max the largest eigenvalue of M^{-1} A, and without forcing the energy (w^T M^{-1} w + u^T A u) / 2 oscillates with an amplitude of order h^2, without drifting.
| using vulpes::timeintegration::LeapfrogSolver::ForceFunc = std::function<void(real_t, la::Vector&)> |
| using vulpes::timeintegration::LeapfrogSolver::real_t = PetscScalar |
| vulpes::timeintegration::LeapfrogSolver::LeapfrogSolver | ( | real_t | time_step, |
| real_t | initial_time, | ||
| real_t | final_time, | ||
| const la::SparseMatrix & | lin_op, | ||
| const la::SparseMatrix & | mass, | ||
| const la::Vector & | u0, | ||
| const la::Vector & | v0, | ||
| const ForceFunc & | force_func ) |
| time_step | step size h |
| initial_time | initial time |
| final_time | final time |
| lin_op | static linear operator A |
| mass | mass matrix M |
| u0 | initial condition |
| v0 | initial velocity |
| force_func | assembles F at the given time |
|
inline |
|
inline |
|
inline |
| la::Vector vulpes::timeintegration::LeapfrogSolver::getVelocity | ( | ) |
Velocity du/dt, obtained solving a system with M.
|
inline |
Linear solver used at every step (default: MUMPS direct solve). Other options (tolerances, ...) can be set on getSolver().
|
private |
| void vulpes::timeintegration::LeapfrogSolver::step | ( | ) |
|
inline |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |