Skip to content

Compact operators and line solvers ​

A compact (implicit, Padé) operator couples the unknowns along a line:

∑j=−llαjui+j(n)=1hn∑mwmqi+m.

The band α on the left (tridiagonal, l=1, or pentadiagonal, l=2, with α0=1) buys accuracy and resolution that an explicit stencil of the same width cannot have: gideon_fd_d1_p6 reaches order 6 with a right side of five points where the explicit gideon_fd_d1_c6 needs seven, and its error is about 1/15 of the explicit one's on the same grid (T7). The price is a solve along every line.

GIDEON splits a compact operator into three things (roadmap #2, decision D2), so that every rule of the explicit kernels still holds:

PartWhatWhere
the right sidean ordinary per-point kernel: window by offset, pure, device-callable, its row a compile-time constantgideon_compact, the row <NAME>_RIGHT
the bandnamed constants, pair form (index j multiplies the unknowns at ±j) or by offset when not symmetricgideon_tables, <NAME>_LEFT
the solveone line per call, the scratch the caller's arraysgideon_line_solvers

The caller computes the right side point by point with the kernel, then solves the band on the line:

fortran
do i=0, n-1                                   ! the right side, one kernel call per node
   call gideon_fd_d1_p6(u(i-2:i+2), h, du(i))
enddo
call gideon_tri_periodic_const(n, FD_D1_P6_LEFT(1), FD_D1_P6_LEFT(0), FD_D1_P6_LEFT(1), du, w1, w2)

When many lines share the band and the length (every line of a grid direction), factor the band once and solve each line with multiplications only: the factor depends on nothing else.

fortran
real(R_P) :: fac(n,3)                         ! the factor: (n,3) tridiagonal, (n,6) pentadiagonal
call gideon_tri_periodic_factor(n, FD_D1_P6_LEFT(1), FD_D1_P6_LEFT(0), FD_D1_P6_LEFT(1), fac)   ! once
do l=1, nlines
   ! ... the right side of line l into du(:,l), as above ...
   call gideon_tri_periodic_solve(n, FD_D1_P6_LEFT(1), FD_D1_P6_LEFT(1), fac, du(:,l))         ! per line
enddo

The operators ​

Right sideUnknownsDataBiasOrderBandRight window
gideon_fd_d1_p4d1 at the nodespoint valuescentred4tridiagonal, FD_D1_P4_LEFTq(-1:1)
gideon_fd_d1_p6d1 at the nodespoint valuescentred6tridiagonal, FD_D1_P6_LEFTq(-2:2)
gideon_fd_d1_p8d1 at the nodespoint valuescentred8pentadiagonal, FD_D1_P8_LEFTq(-2:2)
gideon_fd_d1_p10d1 at the nodespoint valuescentred10pentadiagonal, FD_D1_P10_LEFTq(-3:3)
gideon_fd_d2_p4d2 at the nodespoint valuescentred4tridiagonal, FD_D2_P4_LEFTq(-1:1)
gideon_fd_d2_p6d2 at the nodespoint valuescentred6tridiagonal, FD_D2_P6_LEFTq(-2:2)
gideon_fd_d2_p8d2 at the nodespoint valuescentred8pentadiagonal, FD_D2_P8_LEFTq(-2:2)
gideon_fd_d2_p10d2 at the nodespoint valuescentred10pentadiagonal, FD_D2_P10_LEFTq(-3:3)
gideon_fd_filter_p2filtered values at the nodespoint valuescentred2tridiagonal, [alpha_f, 1, alpha_f]q(-1:1)
gideon_fd_filter_p4filtered values at the nodespoint valuescentred4tridiagonal, [alpha_f, 1, alpha_f]q(-2:2)
gideon_fd_filter_p6filtered values at the nodespoint valuescentred6tridiagonal, [alpha_f, 1, alpha_f]q(-3:3)
gideon_fd_filter_p8filtered values at the nodespoint valuescentred8tridiagonal, [alpha_f, 1, alpha_f]q(-4:4)
gideon_fd_filter_p10filtered values at the nodespoint valuescentred10tridiagonal, [alpha_f, 1, alpha_f]q(-5:5)
gideon_fd_face_p4values at the facespoint valuescentred4tridiagonal, FD_FACE_P4_LEFTq(0:1)
gideon_fd_face_p6values at the facespoint valuescentred6tridiagonal, FD_FACE_P6_LEFTq(-1:2)
gideon_fd_face_p8values at the facespoint valuescentred8pentadiagonal, FD_FACE_P8_LEFTq(-1:2)
gideon_fd_face_p10values at the facespoint valuescentred10pentadiagonal, FD_FACE_P10_LEFTq(-2:3)
gideon_fd_face_d1_p4d1 at the facespoint valuescentred4tridiagonal, FD_FACE_D1_P4_LEFTq(0:1)
gideon_fd_face_d1_p6d1 at the facespoint valuescentred6tridiagonal, FD_FACE_D1_P6_LEFTq(-1:2)
gideon_fd_face_d1_p8d1 at the facespoint valuescentred8pentadiagonal, FD_FACE_D1_P8_LEFTq(-1:2)
gideon_fd_face_d1_p10d1 at the facespoint valuescentred10pentadiagonal, FD_FACE_D1_P10_LEFTq(-2:3)
gideon_fv_face_p4values at the facescell averagescentred4tridiagonal, FV_FACE_P4_LEFTq(0:1)
gideon_fv_face_p6values at the facescell averagescentred6tridiagonal, FV_FACE_P6_LEFTq(-1:2)
gideon_fv_face_p8values at the facescell averagescentred8pentadiagonal, FV_FACE_P8_LEFTq(-1:2)
gideon_fv_face_p10values at the facescell averagescentred10pentadiagonal, FV_FACE_P10_LEFTq(-2:3)
gideon_fv_face_pbr5values at the facescell averagesbiased right5tridiagonal, FV_FACE_PBR5_LEFTq(0:2)
gideon_fv_face_pbl5values at the facescell averagesbiased left5tridiagonal, FV_FACE_PBL5_LEFTq(-1:1)
gideon_fv_face_pbr7values at the facescell averagesbiased right7tridiagonal, FV_FACE_PBR7_LEFTq(-1:3)
gideon_fv_face_pbl7values at the facescell averagesbiased left7tridiagonal, FV_FACE_PBL7_LEFTq(-2:2)
  • Node derivatives (gideon_fd_d1_p<o>, gideon_fd_d2_p<o>): Lele's centred first and second derivatives, tridiagonal orders 4 and 6, pentadiagonal 8 and 10. The band and the right side are solved together for the highest order the window allows: the derived rows are Lele's (1992) as the generator recalls them (a cross-check, not evidence; Sources).
  • Compact filters (gideon_fd_filter_p<2N>): Gaitonde and Visbal's form, αfu~i−1+u~i+αfu~i+1=∑mwm(αf)ui+m, exact on the polynomials of degree below 2N and zero on the odd-even mode. The conditions are linear in αf, so the weights are _RIGHT + alpha_f * _ALPHA, the kernel takes alpha as an argument and the caller passes the band [alpha, 1, alpha] to the solver; |αf|<1/2 (at 1/2 the band is singular at the odd-even mode).
  • Face values and derivatives from point values (gideon_fd_face_p<o>, gideon_fd_face_d1_p<o>): the unknowns at the faces, the data at the nodes on either side (staggered use: the viscous flux of a compact scheme).
  • Face values from cell averages: centred (gideon_fv_face_p<o>) and upwind-biased (gideon_fv_face_pbr<o>, gideon_fv_face_pbl<o>, o=5,7), a tridiagonal band whose two off-diagonals are both solved for, 2k+1 cells with one more on the upwind side. gideon_fv_face_pbl5, band (1/2,1,1/6) on cells (1/18,19/18,5/9), is Pirozzoli's (2002) compact upwind face value: the linear branch of his compact–WENO hybrid. pbl reads pbr's row mirrored, bitwise, and keeps its own (mirrored) band.

No run-time order dispatcher exists for the compact operators: the band changes with the order, so a dispatcher of the right side alone would be half an operator.

The solvers ​

RoutineBandLine
gideon_tri_bounded_{const,var,masked}aixi−1+bixi+cixi+1bounded: Thomas' algorithm
gideon_tri_periodic_{const,var,masked}the same, indices modulo n (n≥3)periodic
gideon_penta_bounded_{const,var,masked}eixi−2+aixi−1+bixi+cixi+1+fixi+2bounded: elimination without pivoting
gideon_penta_periodic_{const,var,masked}the same, indices modulo n (n≥5)periodic

Every routine, the private helpers included (they are generated in the same three variants):

RoutineWhatBandArguments
tri_factor_constbounded tridiagonal solve, the factor kept (private)constant (scalars)(n, a, b, c, d, w)
tri_factor_varbounded tridiagonal solve, the factor kept (private)one coefficient per row (arrays)(n, a, b, c, d, w)
tri_factor_maskedbounded tridiagonal solve, the factor kept (private)constant, the rows where mask(i) the identity(n, a, b, c, mask, d, w)
tri_resolve_constanother right side with that factor (private)constant (scalars)(n, a, b, c, d, w)
tri_resolve_varanother right side with that factor (private)one coefficient per row (arrays)(n, a, b, c, d, w)
tri_resolve_maskedanother right side with that factor (private)constant, the rows where mask(i) the identity(n, a, b, c, mask, d, w)
gideon_tri_bounded_consttridiagonal line, bounded (Thomas)constant (scalars)(n, a, b, c, d, w)
gideon_tri_bounded_vartridiagonal line, bounded (Thomas)one coefficient per row (arrays)(n, a, b, c, d, w)
gideon_tri_bounded_maskedtridiagonal line, bounded (Thomas)constant, the rows where mask(i) the identity(n, a, b, c, mask, d, w)
gideon_tri_periodic_consttridiagonal line, periodic (interior + 1x1 Schur complement)constant (scalars)(n, a, b, c, d, w, z)
gideon_tri_periodic_vartridiagonal line, periodic (interior + 1x1 Schur complement)one coefficient per row (arrays)(n, a, b, c, d, w, z)
gideon_tri_periodic_maskedtridiagonal line, periodic (interior + 1x1 Schur complement)constant, the rows where mask(i) the identity(n, a, b, c, mask, d, w, z)
penta_factor_constbounded pentadiagonal solve, the factor kept (private)constant (scalars)(n, e, a, b, c, f, d, u1, u2)
penta_factor_varbounded pentadiagonal solve, the factor kept (private)one coefficient per row (arrays)(n, e, a, b, c, f, d, u1, u2)
penta_factor_maskedbounded pentadiagonal solve, the factor kept (private)constant, the rows where mask(i) the identity(n, e, a, b, c, f, mask, d, u1, u2)
penta_resolve_constanother right side with that factor (private)constant (scalars)(n, e, a, b, c, f, d, u1, u2)
penta_resolve_varanother right side with that factor (private)one coefficient per row (arrays)(n, e, a, b, c, f, d, u1, u2)
penta_resolve_maskedanother right side with that factor (private)constant, the rows where mask(i) the identity(n, e, a, b, c, f, mask, d, u1, u2)
gideon_penta_bounded_constpentadiagonal line, boundedconstant (scalars)(n, e, a, b, c, f, d, u1, u2)
gideon_penta_bounded_varpentadiagonal line, boundedone coefficient per row (arrays)(n, e, a, b, c, f, d, u1, u2)
gideon_penta_bounded_maskedpentadiagonal line, boundedconstant, the rows where mask(i) the identity(n, e, a, b, c, f, mask, d, u1, u2)
gideon_penta_periodic_constpentadiagonal line, periodic (interior + 2x2 Schur complement)constant (scalars)(n, e, a, b, c, f, d, u1, u2, z1, z2)
gideon_penta_periodic_varpentadiagonal line, periodic (interior + 2x2 Schur complement)one coefficient per row (arrays)(n, e, a, b, c, f, d, u1, u2, z1, z2)
gideon_penta_periodic_maskedpentadiagonal line, periodic (interior + 2x2 Schur complement)constant, the rows where mask(i) the identity(n, e, a, b, c, f, mask, d, u1, u2, z1, z2)
tri_factor_rowsthe bounded tridiagonal factor of rows 1..m, leading dimension ld (private)constant, factored once(m, ld, a, b, c, fac)
gideon_tri_bounded_factorfactor of a bounded tridiagonal line, once for every lineconstant, factored once(n, a, b, c, fac)
gideon_tri_bounded_solvea bounded tridiagonal line with that factor: multiplications onlyconstant, factored once(n, a, fac, d)
gideon_tri_periodic_factorfactor of a periodic tridiagonal line, once for every lineconstant, factored once(n, a, b, c, fac)
tri_interior_solvethe interior solve of the border column, in the factor (private)constant, factored once(n, a, fac)
gideon_tri_periodic_solvea periodic tridiagonal line with that factor: multiplications onlyconstant, factored once(n, a, c, fac, d)
penta_factor_rowsthe bounded pentadiagonal factor of rows 1..m, leading dimension ld (private)constant, factored once(m, ld, e, a, b, c, f, fac)
gideon_penta_bounded_factorfactor of a bounded pentadiagonal line, once for every lineconstant, factored once(n, e, a, b, c, f, fac)
gideon_penta_bounded_solvea bounded pentadiagonal line with that factor: multiplications onlyconstant, factored once(n, e, fac, d)
gideon_penta_periodic_factorfactor of a periodic pentadiagonal line, once for every lineconstant, factored once(n, e, a, b, c, f, fac)
penta_interior_solvethe interior solve of a border column, in the factor (private)constant, factored once(n, e, fac, col)
gideon_penta_periodic_solvea periodic pentadiagonal line with that factor: multiplications onlyconstant, factored once(n, e, a, c, f, fac, d)
  • _factor / _solve (a constant band): the factor once per band and length, every line solved with it by multiplications only; the factor is one caller array of leading dimension n, read only by the solves, so on a GPU one copy serves every thread. The solve multiplies by reciprocal pivots where _const divides: the two agree within round-off, not bitwise (C8). This is the fast path for the compact operators (Performance).
  • _const: the band a constant (scalars): the compact operators. _var: one coefficient per row (arrays). _masked: the constant band, with the rows where mask(i) replaced by the identity: their right side is the value the caller gives there (below). The three are emitted from one template by the generator, so they cannot drift: on the same band they agree bitwise (C8).
  • A periodic line is solved as its interior (a bounded band, for the right side and for the columns of the border unknowns, with one factor) followed by the border's 1×1 or 2×2 Schur complement, solved by elimination: no Sherman–Morrison shift to choose, and a border row replaced by the identity returns its value exactly.
  • Elimination without pivoting is stable for diagonally dominant bands and for symmetric positive definite ones, and every GIDEON band is one or the other. gideon_fd_d1_p10's band [1/20,1/2,1,1/2,1/20] is not diagonally dominant (2α+2β=1.1); its symbol 1+cos⁡ξ+cos⁡(2ξ)/10≥1/10 makes it positive definite.
  • A coefficient that reaches outside a bounded line (a1, cn, …) is never read.
  • Device use: one line per thread, !$acc parallel loop over the lines, the scratch a column of the caller's arrays (w(:,l)), the inner loops !$acc loop seq. Nothing is allocated.

Compact-WENO coupling ​

In a hybrid compact–WENO/TENO scheme the face values come from the compact operator where the solution is smooth and from a nonlinear scheme where a sensor flags a discontinuity (Pirozzoli 2002). For the solve, a flagged face drops its compact row: its row becomes the identity and its right side the nonlinear value. That is _masked:

fortran
do i=1, n
   mask(i) = sensor(i) > threshold                 ! the caller's switch
   if (mask(i)) then
      f(i) = weno_value(i)                        ! the caller's nonlinear value
   else
      call gideon_fv_face_pbl5(u(i-1:i+1), f(i))  ! the compact row's right side
   endif
enddo
call gideon_tri_periodic_masked(n, FV_FACE_PBL5_LEFT(-1), FV_FACE_PBL5_LEFT(0), FV_FACE_PBL5_LEFT(1), mask, f, w, z)

GIDEON provides the operator and the solve; the sensor, the threshold and the nonlinear value are the caller's (SETH's: decision D7). The flagged faces return their given values exactly, every face keeps one value (the flux form stays conservative), and away from the flagged region the compact order is kept: the band's inverse decays geometrically, so the influence of a step falls below the truncation error a few dozen cells away (A5). A worked example: Compact-WENO rows.

Not here (yet) ​

  • Boundary closures for bounded lines (D4: periodic lines only in this roadmap; the bounded solvers exist).
  • Optimised (dispersion-relation-preserving, selective) filters and rows: their coefficients are not derivable by meaning (D3).
  • A multi-dimensional compact operator: apply along one axis at a time, the caller's loop over lines.

Released under your choice of GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT.