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

#include <lib-algorithms.h>

Public Member Functions

 RK4 (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
 
Y1
 
Yh
 

Detailed Description

template<class T>
class Algorithms::RK4< T >

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

Constructor & Destructor Documentation

◆ RK4()

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

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

623 : Y0(Yin), Y1(Yin), Yh(Yin) { }

Member Function Documentation

◆ operator()() [1/2]

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

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

635  {
636 // Take a step using RK4
637 
638 // Initialization
639  Y0 = Y; Y1 = Y;
640 
641 // Step 1
642  (*F)(Y1,Yh); // slope in the beginning
643  Yh *= (0.5*h); Y1 += Yh; // Y1 = Y1 + (h/2)*Yh
644  Yh *= (1.0/3.0); Y += Yh; // Y = Y + (h/6)*Yh
645 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
646 
647 // Step 2
648  (*F)(Y1,Yh); Y1 = Y0; // slope in the middle
649  Yh *= (0.5*h); Y1 += Yh; // Y1 = Y0 + (h/2)*Yh
650  Yh *= (2.0/3.0); Y += Yh; // Y = Y + (h/3)*Yh
651 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
652 
653 // Step 3
654  (*F)(Y1,Yh); // slope in the middle again
655  Yh *= h; Y0 += Yh; // Y0 = Y0 + h*Yh
656  Yh *= (1.0/3.0); Y += Yh; // Y = Y + (h/3)*Yh
657 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
658 
659 // Step 4
660  (*F)(Y0,Yh); // slope at the end
661  Yh *= (h/6.0); Y += Yh; // Y = Y + (h/6)*Yh
662 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
663 
664  return Y;
665  }

◆ operator()() [2/2]

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

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

667  {
668 // Take a step using RK4
669 
670 // Initialization
671  Y0 = Y; Y1 = Y;
672 
673 // Step 1
674  (*F)(Y1,Yh,dir); // slope in the beginning
675  Yh *= (0.5*h); Y1 += Yh; // Y1 = Y1 + (h/2)*Yh
676  Yh *= (1.0/3.0); Y += Yh; // Y = Y + (h/6)*Yh
677 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
678 
679 // Step 2
680  (*F)(Y1,Yh,dir); Y1 = Y0; // slope in the middle
681  Yh *= (0.5*h); Y1 += Yh; // Y1 = Y0 + (h/2)*Yh
682  Yh *= (2.0/3.0); Y += Yh; // Y = Y + (h/3)*Yh
683 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
684 
685 // Step 3
686  (*F)(Y1,Yh,dir); // slope in the middle again
687  Yh *= h; Y0 += Yh; // Y0 = Y0 + h*Yh
688  Yh *= (1.0/3.0); Y += Yh; // Y = Y + (h/3)*Yh
689 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
690 
691 // Step 4
692  (*F)(Y0,Yh,dir); // slope at the end
693  Yh *= (h/6.0); Y += Yh; // Y = Y + (h/6)*Yh
694 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
695 
696  return Y;
697  }

Field Documentation

◆ Y0

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

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

◆ Y1

template<class T>
T Algorithms::RK4< T >::Y1
private

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

◆ Yh

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

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


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