sin_reconstruction Program

program~~sin_reconstruction~~UsesGraph program~sin_reconstruction sin_reconstruction module~pyplot_module pyplot_module module~pyplot_module->program~sin_reconstruction module~penf penf module~penf->program~sin_reconstruction module~wenoof wenoof module~penf->module~wenoof module~wenoof_polynomials wenoof_polynomials module~penf->module~wenoof_polynomials module~wenoof_optimal_weights wenoof_optimal_weights module~penf->module~wenoof_optimal_weights module~wenoof_interpolator_js wenoof_interpolator_js module~penf->module~wenoof_interpolator_js module~wenoof_smoothness_indicators_js wenoof_smoothness_indicators_js module~penf->module~wenoof_smoothness_indicators_js module~wenoof_polynomials_js wenoof_polynomials_js module~penf->module~wenoof_polynomials_js module~wenoof_alpha_coefficients_z wenoof_alpha_coefficients_z module~penf->module~wenoof_alpha_coefficients_z module~wenoof_interpolator wenoof_interpolator module~penf->module~wenoof_interpolator module~wenoof_alpha_coefficients wenoof_alpha_coefficients module~penf->module~wenoof_alpha_coefficients module~wenoof_optimal_weights_js wenoof_optimal_weights_js module~penf->module~wenoof_optimal_weights_js module~wenoof_alpha_coefficients_m wenoof_alpha_coefficients_m module~penf->module~wenoof_alpha_coefficients_m module~wenoof_smoothness_indicators wenoof_smoothness_indicators module~penf->module~wenoof_smoothness_indicators module~wenoof_alpha_coefficients_js wenoof_alpha_coefficients_js module~penf->module~wenoof_alpha_coefficients_js module~wenoof->program~sin_reconstruction iso_fortran_env iso_fortran_env iso_fortran_env->module~pyplot_module module~penf_stringify penf_stringify iso_fortran_env->module~penf_stringify iso_fortran_env->module~wenoof_interpolator_js module~penf_global_parameters_variables penf_global_parameters_variables module~penf_global_parameters_variables->module~penf module~penf_b_size penf_b_size module~penf_global_parameters_variables->module~penf_b_size module~penf_global_parameters_variables->module~penf_stringify module~penf_b_size->module~penf module~penf_b_size->module~penf_stringify module~penf_stringify->module~penf module~wenoof_polynomials->module~wenoof module~wenoof_polynomials->module~wenoof_interpolator_js module~wenoof_polynomials->module~wenoof_polynomials_js module~wenoof_polynomials->module~wenoof_interpolator module~wenoof_objects_factory wenoof_objects_factory module~wenoof_polynomials->module~wenoof_objects_factory module~wenoof_optimal_weights->module~wenoof module~wenoof_optimal_weights->module~wenoof_interpolator_js module~wenoof_optimal_weights->module~wenoof_interpolator module~wenoof_optimal_weights->module~wenoof_optimal_weights_js module~wenoof_optimal_weights->module~wenoof_objects_factory module~wenoof_interpolator_js->module~wenoof module~wenoof_smoothness_indicators_js->module~wenoof module~wenoof_smoothness_indicators_js->module~wenoof_interpolator_js module~wenoof_smoothness_indicators_js->module~wenoof_objects_factory module~wenoof_polynomials_js->module~wenoof module~wenoof_polynomials_js->module~wenoof_interpolator_js module~wenoof_polynomials_js->module~wenoof_objects_factory module~wenoof_alpha_coefficients_z->module~wenoof module~wenoof_alpha_coefficients_z->module~wenoof_interpolator_js module~wenoof_alpha_coefficients_z->module~wenoof_alpha_coefficients_m module~wenoof_alpha_coefficients_z->module~wenoof_objects_factory module~wenoof_interpolator->module~wenoof module~wenoof_interpolator->module~wenoof_interpolator_js module~wenoof_alpha_coefficients->module~wenoof module~wenoof_alpha_coefficients->module~wenoof_interpolator_js module~wenoof_alpha_coefficients->module~wenoof_alpha_coefficients_z module~wenoof_alpha_coefficients->module~wenoof_interpolator module~wenoof_alpha_coefficients->module~wenoof_alpha_coefficients_m module~wenoof_alpha_coefficients->module~wenoof_alpha_coefficients_js module~wenoof_alpha_coefficients->module~wenoof_objects_factory module~wenoof_optimal_weights_js->module~wenoof module~wenoof_optimal_weights_js->module~wenoof_interpolator_js module~wenoof_optimal_weights_js->module~wenoof_objects_factory module~wenoof_alpha_coefficients_m->module~wenoof module~wenoof_alpha_coefficients_m->module~wenoof_interpolator_js module~wenoof_alpha_coefficients_m->module~wenoof_objects_factory module~wenoof_smoothness_indicators->module~wenoof module~wenoof_smoothness_indicators->module~wenoof_interpolator_js module~wenoof_smoothness_indicators->module~wenoof_smoothness_indicators_js module~wenoof_smoothness_indicators->module~wenoof_interpolator module~wenoof_smoothness_indicators->module~wenoof_objects_factory module~wenoof_alpha_coefficients_js->module~wenoof module~wenoof_alpha_coefficients_js->module~wenoof_interpolator_js module~wenoof_alpha_coefficients_js->module~wenoof_alpha_coefficients_m module~wenoof_alpha_coefficients_js->module~wenoof_objects_factory module~wenoof_base_object wenoof_base_object module~wenoof_base_object->module~wenoof_polynomials module~wenoof_base_object->module~wenoof_optimal_weights module~wenoof_base_object->module~wenoof_interpolator_js module~wenoof_base_object->module~wenoof_smoothness_indicators_js module~wenoof_base_object->module~wenoof_polynomials_js module~wenoof_base_object->module~wenoof_interpolator module~wenoof_base_object->module~wenoof_alpha_coefficients module~wenoof_base_object->module~wenoof_alpha_coefficients_m module~wenoof_base_object->module~wenoof_smoothness_indicators module~wenoof_base_object->module~wenoof_objects_factory module~wenoof_objects_factory->module~wenoof_interpolator
Help


WenOOF test: reconstruction of sin function.

Calls

program~~sin_reconstruction~~CallsGraph program~sin_reconstruction sin_reconstruction proc~wenoof_create wenoof_create program~sin_reconstruction->proc~wenoof_create interface~str str program~sin_reconstruction->interface~str proc~create_interpolator_js_constructor create_interpolator_js_constructor proc~wenoof_create->proc~create_interpolator_js_constructor proc~create_polynomials_js_constructor create_polynomials_js_constructor proc~wenoof_create->proc~create_polynomials_js_constructor proc~create_optimal_weights_js_constructor create_optimal_weights_js_constructor proc~wenoof_create->proc~create_optimal_weights_js_constructor proc~create_smoothness_indicators_js_constructor create_smoothness_indicators_js_constructor proc~wenoof_create->proc~create_smoothness_indicators_js_constructor proc~create_alpha_coefficients_js_constructor create_alpha_coefficients_js_constructor proc~wenoof_create->proc~create_alpha_coefficients_js_constructor proc~strf_i2p strf_I2P interface~str->proc~strf_i2p proc~strf_i4p strf_I4P interface~str->proc~strf_i4p proc~str_a_i2p str_a_I2P interface~str->proc~str_a_i2p proc~str_i8p str_I8P interface~str->proc~str_i8p proc~strf_i1p strf_I1P interface~str->proc~strf_i1p proc~str_a_i1p str_a_I1P interface~str->proc~str_a_i1p proc~strf_r4p strf_R4P interface~str->proc~strf_r4p proc~str_a_i4p str_a_I4P interface~str->proc~str_a_i4p proc~str_i1p str_I1P interface~str->proc~str_i1p proc~str_i2p str_I2P interface~str->proc~str_i2p proc~str_a_i8p str_a_I8P interface~str->proc~str_a_i8p proc~str_r4p str_R4P interface~str->proc~str_r4p proc~strf_i8p strf_I8P interface~str->proc~strf_i8p proc~str_a_r8p str_a_R8P interface~str->proc~str_a_r8p proc~str_i4p str_I4P interface~str->proc~str_i4p proc~str_bol str_bol interface~str->proc~str_bol proc~str_a_r4p str_a_R4P interface~str->proc~str_a_r4p proc~str_r8p str_R8P interface~str->proc~str_r8p proc~strf_r8p strf_R8P interface~str->proc~strf_r8p proc~str_a_i2p->proc~str_i2p proc~str_a_i1p->proc~str_i1p proc~str_a_i4p->proc~str_i4p proc~str_a_i8p->proc~str_i8p proc~compact_real_string compact_real_string proc~str_r4p->proc~compact_real_string proc~str_a_r8p->proc~str_r8p proc~str_a_r4p->proc~str_r4p proc~str_r8p->proc~compact_real_string
Help

Source Code


Variables

Type AttributesNameInitial
class(interpolator), allocatable:: weno_interpolator

WENO interpolator.

integer(kind=I_P), parameter:: S =6_I_P

Stencils used.

integer(kind=I_P), parameter:: Nv =30_I_P

Number of discretized values to be interpolated.

real(kind=R_P), parameter:: pi =4._R_P*atan(1._R_P)

Extent of domain.

real(kind=R_P) :: x(1-S:Nv+S)

Whole domain.

real(kind=R_P) :: fx(1-S:Nv+S)

Discretized values to be interpolated.

real(kind=R_P) :: xi(1:Nv)

Domain of the interpolation.

real(kind=R_P) :: fx_ref(1:Nv)

Reference values.

real(kind=R_P) :: interpolation(1:1,1:Nv)

Interpolated values.

type(pyplot) :: plt

Plotter handler.

integer :: i

Counters.

integer :: j

Counters.

integer :: f

Counters.


Source Code

program sin_reconstruction
!< WenOOF test: reconstruction of sin function.

use penf, only : I_P, R_P, str
use wenoof, only : interpolator, wenoof_create
use pyplot_module, only :  pyplot

implicit none
class(interpolator), allocatable :: weno_interpolator          !< WENO interpolator.
integer(I_P), parameter          :: S = 6_I_P                  !< Stencils used.
integer(I_P), parameter          :: Nv = 30_I_P                !< Number of discretized values to be interpolated.
real(R_P),    parameter          :: pi = 4._R_P * atan(1._R_P) !< Extent of domain.
real(R_P)                        :: x(1-S:Nv+S)                !< Whole domain.
real(R_P)                        :: fx(1-S:Nv+S)               !< Discretized values to be interpolated.
real(R_P)                        :: xi(1:Nv)                   !< Domain of the interpolation.
real(R_P)                        :: fx_ref(1:Nv)               !< Reference values.
real(R_P)                        :: interpolation(1:1, 1:Nv)   !< Interpolated values.
type(pyplot)                     :: plt                        !< Plotter handler.
integer                          :: i, j, f                    !< Counters.

! build the values used for the reconstruction of sin function: nodal values
x = 0.
do i = 1 - S, Nv + S
  x(i) = i * 2 * pi / Nv
  fx(i) = sin(x(i))
enddo
! face values to which the reconstruction should tend
do i = 1, Nv
  xi(i) = x(i) + pi / Nv
  fx_ref(i) = sin(xi(i))
enddo

! create weno interpolator
call wenoof_create(interpolator_type='JS', S=S, wenoof_interpolator=weno_interpolator)

! interpolate values
interpolation = 0.
do i = 1, Nv ! interpolated values loop
  call weno_interpolator%interpolate(S=S,                                                      &
                                     stencil=reshape(source=fx(i+1-S:i-1+S), shape=[1,2*S-1]), &
                                     location='right',                                         &
                                     interpolation=interpolation(1:1, i))
enddo

! print results
print "(A)", '# x, sin(x), weno_interpolation(x)'
do i = 1, Nv
  print "(A)", str(n=xi(i))//' '//str(n=fx_ref(i))//' '//str(n=interpolation(1, i))
enddo

! plotting graph to image file
call plt%initialize(grid=.true., xlabel='angle (rad)', title='WENO interpolation of $\sin(x)$', legend=.true.)
call plt%add_plot(x=xi(1:Nv),        &
                  y=fx_ref(1:Nv),    &
                  label='$\sin(x)$', &
                  linestyle='k-',    &
                  linewidth=2)
call plt%add_plot(x=xi(1:Nv),                 &
                  y=interpolation(1, 1:Nv),   &
                  label='WENO interpolation', &
                  linestyle='ro',             &
                  markersize=6)
call plt%savefig('sin_reconstruction.png')
endprogram sin_reconstruction