OSHUN  beta
Arbitrary Order Spherical-Harmonic 1D-3P Vlasov-Fokker-Planck-Maxwell code
Algorithms::RK2< T > Class Template Reference

#include <lib-algorithms.h>

Public Member Functions

 RK2 (T &Yin)
 
T & operator() (T &Y, double h, AbstFunctor< T > *F)
 
T & operator() (T &Y, double h, AbstFunctor< T > *F, size_t dir)
 

Private Attributes

Y0
 
Yh
 

Detailed Description

template<class T>
class Algorithms::RK2< T >

Definition at line 489 of file lib-algorithms.h.

Constructor & Destructor Documentation

◆ RK2()

template<class T >
Algorithms::RK2< T >::RK2 ( T &  Yin)
inline

Definition at line 492 of file lib-algorithms.h.

492 : Y0(Yin), Yh(Yin) { }

Member Function Documentation

◆ operator()() [1/2]

template<class T >
T & Algorithms::RK2< T >::operator() ( T &  Y,
double  h,
AbstFunctor< T > *  F 
)

Definition at line 504 of file lib-algorithms.h.

504  {
505 // Take a step using RK2
506 
507 // Initialization
508  Y0 = Y;
509 
510 // Step 1
511  (*F)(Y0,Yh); Yh *= h; // Yh = h*F(Y0)
512  Y0 += Yh; // Y0 = Y0 + h*Yh
513  Yh *= 0.5; Y += Yh; // Y = Y + (h/2)*F(Y0)
514 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
515 
516 // Step 2
517  (*F)(Y0,Yh); Yh *= 0.5*h; // Yh = (h/2)*F(Y0)
518  Y += Yh; // Y = Y + (h/2)*F(Y0)
519 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
520 
521  return Y;
522  }

◆ operator()() [2/2]

template<class T >
T & Algorithms::RK2< T >::operator() ( T &  Y,
double  h,
AbstFunctor< T > *  F,
size_t  dir 
)

Definition at line 524 of file lib-algorithms.h.

524  {
525 // Take a step using RK2
526 
527 // Initialization
528  Y0 = Y;
529 
530 // Step 1
531  (*F)(Y0,Yh,dir); Yh *= h; // Yh = h*F(Y0)
532  Y0 += Yh; // Y0 = Y0 + h*Yh
533  Yh *= 0.5; Y += Yh; // Y = Y + (h/2)*F(Y0)
534 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
535 
536 // Step 2
537  (*F)(Y0,Yh,dir); Yh *= 0.5*h; // Yh = (h/2)*F(Y0)
538  Y += Yh; // Y = Y + (h/2)*F(Y0)
539 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
540 
541  return Y;
542  }

Field Documentation

◆ Y0

template<class T >
T Algorithms::RK2< T >::Y0
private

Definition at line 500 of file lib-algorithms.h.

◆ Yh

template<class T >
T Algorithms::RK2< T >::Yh
private

Definition at line 500 of file lib-algorithms.h.


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