Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
vulpes::timeintegration::LeapfrogSolver Class Reference

Leapfrog solver, in velocity Verlet form, for linear second order problems of the form. More...

#include <leapfrog.hpp>

Collaboration diagram for vulpes::timeintegration::LeapfrogSolver:
[legend]

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

Detailed Description

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.

Member Typedef Documentation

◆ ForceFunc

◆ real_t

Constructor & Destructor Documentation

◆ LeapfrogSolver()

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 )
Parameters
time_stepstep size h
initial_timeinitial time
final_timefinal time
lin_opstatic linear operator A
massmass matrix M
u0initial condition
v0initial velocity
force_funcassembles F at the given time

Member Function Documentation

◆ finalTime()

real_t vulpes::timeintegration::LeapfrogSolver::finalTime ( ) const
inline

◆ getSolution()

const la::Vector & vulpes::timeintegration::LeapfrogSolver::getSolution ( ) const
inline

◆ getSolver()

auto & vulpes::timeintegration::LeapfrogSolver::getSolver ( )
inline

◆ getVelocity()

la::Vector vulpes::timeintegration::LeapfrogSolver::getVelocity ( )

Velocity du/dt, obtained solving a system with M.

◆ setSolverType()

void vulpes::timeintegration::LeapfrogSolver::setSolverType ( la::LinearSolver::Type solver_type,
la::LinearSolver::PrecondType pc_type )
inline

Linear solver used at every step (default: MUMPS direct solve). Other options (tolerances, ...) can be set on getSolver().

◆ setupSolver()

void vulpes::timeintegration::LeapfrogSolver::setupSolver ( )
private

◆ step()

void vulpes::timeintegration::LeapfrogSolver::step ( )

◆ time()

real_t vulpes::timeintegration::LeapfrogSolver::time ( ) const
inline

Member Data Documentation

◆ m_f_1

la::Vector vulpes::timeintegration::LeapfrogSolver::m_f_1
private

◆ m_f_2

la::Vector vulpes::timeintegration::LeapfrogSolver::m_f_2
private

◆ m_f_new

la::Vector* vulpes::timeintegration::LeapfrogSolver::m_f_new = nullptr
private

◆ m_f_old

la::Vector* vulpes::timeintegration::LeapfrogSolver::m_f_old = nullptr
private

◆ m_final_time

real_t vulpes::timeintegration::LeapfrogSolver::m_final_time
private

◆ m_force_func

const ForceFunc vulpes::timeintegration::LeapfrogSolver::m_force_func
private

◆ m_initial_time

real_t vulpes::timeintegration::LeapfrogSolver::m_initial_time
private

◆ m_iter

PetscInt vulpes::timeintegration::LeapfrogSolver::m_iter = 0
private

◆ m_lin_op

const la::SparseMatrix& vulpes::timeintegration::LeapfrogSolver::m_lin_op
private

◆ m_mass

const la::SparseMatrix& vulpes::timeintegration::LeapfrogSolver::m_mass
private

◆ m_pc_type

la::LinearSolver::PrecondType vulpes::timeintegration::LeapfrogSolver::m_pc_type = la::LinearSolver::MUMPS
private

◆ m_RHS

la::SparseMatrix vulpes::timeintegration::LeapfrogSolver::m_RHS
private

◆ m_rhs

la::Vector vulpes::timeintegration::LeapfrogSolver::m_rhs
private

◆ m_solver

la::LinearSolver vulpes::timeintegration::LeapfrogSolver::m_solver
private

◆ m_solver_ready

bool vulpes::timeintegration::LeapfrogSolver::m_solver_ready = false
private

◆ m_solver_type

la::LinearSolver::Type vulpes::timeintegration::LeapfrogSolver::m_solver_type = la::LinearSolver::PrecondOnly
private

◆ m_time

real_t vulpes::timeintegration::LeapfrogSolver::m_time
private

◆ m_time_step

real_t vulpes::timeintegration::LeapfrogSolver::m_time_step
private

◆ m_tmp

la::Vector vulpes::timeintegration::LeapfrogSolver::m_tmp
private

◆ m_u

la::Vector vulpes::timeintegration::LeapfrogSolver::m_u
private

◆ m_u_old

la::Vector vulpes::timeintegration::LeapfrogSolver::m_u_old
private

◆ m_w

la::Vector vulpes::timeintegration::LeapfrogSolver::m_w
private

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