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

#include <lib-algorithms.h>

Public Member Functions

 RK3 (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::RK3< T >

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

Constructor & Destructor Documentation

◆ RK3()

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

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

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

Member Function Documentation

◆ operator()() [1/2]

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

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

562  {
563 // Take a step using RK3
564 
565 // Initialization
566  Y0 = Y;
567 
568 // Step 1
569  (*F)(Y0,Yh); Yh *= h; // Yh = h*F(Y0)
570  Y0 += Yh;
571 // Y0 = Y0 + h*Yh
572 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
573 
574 // Step 2
575  (*F)(Y0,Yh); Yh *= h; // Yh = h*F(Y0)
576  Y0 += Yh; Y *= 3.0; Y0 += Y; Y0 *= 0.25; // Changed Y to 3*Y!
577 // Y0 = 1/4 * ( 3*Y + (Y0 + h*Yh) )
578 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
579 
580 // Step 3
581  (*F)(Y0,Yh); Yh *= h; // Yh = h*F(Y0)
582  Y0 += Yh; Y0 *= 6.0; Y += Y0; Y *= (1.0/9.0);
583 // Y = 1/3 * ( Y + 2 * (Y0+h*Yh) )
584 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
585 
586  return Y;
587  }

◆ operator()() [2/2]

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

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

590  {
591 // Take a step using RK3
592 
593 // Initialization
594  Y0 = Y;
595 
596 // Step 1
597  (*F)(Y0,Yh,dir); Yh *= h; // Yh = h*F(Y0)
598  Y0 += Yh;
599 // Y0 = Y0 + h*Yh
600 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
601 
602 // Step 2
603  (*F)(Y0,Yh,dir); Yh *= h; // Yh = h*F(Y0)
604  Y0 += Yh; Y *= 3.0; Y0 += Y; Y0 *= 0.25; // Changed Y to 3*Y!
605 // Y0 = 1/4 * ( 3*Y + (Y0 + h*Yh) )
606 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
607 
608 // Step 3
609  (*F)(Y0,Yh,dir); Yh *= h; // Yh = h*F(Y0)
610  Y0 += Yh; Y0 *= 6.0; Y += Y0; Y *= (1.0/9.0);
611 // Y = 1/3 * ( Y + 2 * (Y0+h*Yh) )
612 // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
613 
614  return Y;
615  }

Field Documentation

◆ Y0

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

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

◆ Yh

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

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


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