fill_stencil Subroutine

private pure subroutine fill_stencil(field, n_pts, pt_start, pt_step, ghost_lo, ghost_hi, periodic, stencil)

Fill a reconstruction stencil from field, applying ghost states at domain boundaries.

Iterates over stencil positions i = 1 .. size(stencil, 2) and maps each to grid index pt_idx = pt_start + (i-1)*pt_step. Out-of-bounds indices are handled as follows: - Periodic domain: wrap into [1, n_pts-1] via modulo arithmetic. - Non-periodic, low side (pt_idx < 1): use ghost_lo. - Non-periodic, high side (pt_idx > n_pts): use ghost_hi.

Use pt_step = +1 for a left-biased stencil (F^+, Q_L reconstruction). Use pt_step = -1 for a right-biased (mirror) stencil (F^-, Q_R).

Arguments

Type IntentOptional Attributes Name
real(kind=wp), intent(in) :: field(:,:)
integer, intent(in) :: n_pts

Number of active grid points.

integer, intent(in) :: pt_start

Number of active grid points. Grid index for stencil position i = 1.

integer, intent(in) :: pt_step

Number of active grid points. Grid index for stencil position i = 1. Index stride per position: +1 (left-biased) or -1 (right-biased).

real(kind=wp), intent(in) :: ghost_lo(:)
real(kind=wp), intent(in) :: ghost_hi(:)
logical, intent(in) :: periodic

If .true., wrap out-of-bounds indices periodically.

real(kind=wp), intent(out) :: stencil(:,:)