Interpolate values.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(interpolator_js), | intent(inout) | :: | self | Interpolator. |
||
integer(kind=I_P), | intent(in) | :: | S | Number of stencils actually used. |
||
real(kind=R_P), | intent(in) | :: | stencil(1:,1-S:) | Stencil of the interpolation [1:2, 1-S:-1+S]. |
||
character(len=*), | intent(in) | :: | location | Location of interpolation: left, right, both. |
||
real(kind=R_P), | intent(out) | :: | interpolation(1:) | Result of the interpolation, [1:2]. |
pure subroutine interpolate(self, S, stencil, location, interpolation)
!< Interpolate values.
class(interpolator_js), intent(inout) :: self !< Interpolator.
integer(I_P), intent(in) :: S !< Number of stencils actually used.
real(R_P), intent(in) :: stencil(1:, 1 - S:) !< Stencil of the interpolation [1:2, 1-S:-1+S].
character(*), intent(in) :: location !< Location of interpolation: left, right, both.
real(R_P), intent(out) :: interpolation(1:) !< Result of the interpolation, [1:2].
real(R_P) :: weights(1:2, 0:S - 1) !< Weights of the stencils, [1:2, 0:S-1].
integer(I_P) :: f1, f2, ff !< Faces to be computed.
integer(I_P) :: f, k !< Counters.
select case(location)
case('both', 'b')
f1=1_I_P; f2=2_I_P; ff=0_I_P
case('left', 'l')
f1=1_I_P; f2=1_I_P; ff=0_I_P
case('right', 'r')
f1=2_I_P; f2=2_I_P; ff=-1_I_P
endselect
call self%polynom%compute(S=S, stencil=stencil, f1=f1, f2=f2, ff = ff)
call self%is%compute(S=S, stencil=stencil, f1=f1, f2=f2, ff = ff)
call self%alpha%compute(S=S, weight_opt=self%weights%opt, IS = self%IS%si, eps = self%eps, f1=f1, f2=f2)
! computing the weights
do k = 0, S - 1 ! stencils loop
do f = f1, f2 ! 1 => left interface (i-1/2), 2 => right interface (i+1/2)
weights(f, k) = self%alpha%alpha_coef(f, k) / self%alpha%alpha_tot(f)
enddo
enddo
! computing the convolution
interpolation = 0.
do k = 0, S - 1 ! stencils loop
do f = f1, f2 ! 1 => left interface (i-1/2), 2 => right interface (i+1/2)
interpolation(f + ff) = interpolation(f + ff) + weights(f, k) * self%polynom%poly(f, k)
enddo
enddo
endsubroutine interpolate