Compact operators and line solvers
A compact (implicit, Padé) operator couples the unknowns along a line:
The band 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:
| Part | What | Where |
|---|---|---|
| the right side | an ordinary per-point kernel: window by offset, pure, device-callable, its row a compile-time constant | gideon_compact, the row <NAME>_RIGHT |
| the band | named constants, pair form (index | gideon_tables, <NAME>_LEFT |
| the solve | one line per call, the scratch the caller's arrays | gideon_line_solvers |
The caller computes the right side point by point with the kernel, then solves the band on the line:
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.
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
enddoThe operators
| Right side | Unknowns | Data | Bias | Order | Band | Right window |
|---|---|---|---|---|---|---|
gideon_fd_d1_p4 | d1 at the nodes | point values | centred | 4 | tridiagonal, FD_D1_P4_LEFT | q(-1:1) |
gideon_fd_d1_p6 | d1 at the nodes | point values | centred | 6 | tridiagonal, FD_D1_P6_LEFT | q(-2:2) |
gideon_fd_d1_p8 | d1 at the nodes | point values | centred | 8 | pentadiagonal, FD_D1_P8_LEFT | q(-2:2) |
gideon_fd_d1_p10 | d1 at the nodes | point values | centred | 10 | pentadiagonal, FD_D1_P10_LEFT | q(-3:3) |
gideon_fd_d2_p4 | d2 at the nodes | point values | centred | 4 | tridiagonal, FD_D2_P4_LEFT | q(-1:1) |
gideon_fd_d2_p6 | d2 at the nodes | point values | centred | 6 | tridiagonal, FD_D2_P6_LEFT | q(-2:2) |
gideon_fd_d2_p8 | d2 at the nodes | point values | centred | 8 | pentadiagonal, FD_D2_P8_LEFT | q(-2:2) |
gideon_fd_d2_p10 | d2 at the nodes | point values | centred | 10 | pentadiagonal, FD_D2_P10_LEFT | q(-3:3) |
gideon_fd_filter_p2 | filtered values at the nodes | point values | centred | 2 | tridiagonal, [alpha_f, 1, alpha_f] | q(-1:1) |
gideon_fd_filter_p4 | filtered values at the nodes | point values | centred | 4 | tridiagonal, [alpha_f, 1, alpha_f] | q(-2:2) |
gideon_fd_filter_p6 | filtered values at the nodes | point values | centred | 6 | tridiagonal, [alpha_f, 1, alpha_f] | q(-3:3) |
gideon_fd_filter_p8 | filtered values at the nodes | point values | centred | 8 | tridiagonal, [alpha_f, 1, alpha_f] | q(-4:4) |
gideon_fd_filter_p10 | filtered values at the nodes | point values | centred | 10 | tridiagonal, [alpha_f, 1, alpha_f] | q(-5:5) |
gideon_fd_face_p4 | values at the faces | point values | centred | 4 | tridiagonal, FD_FACE_P4_LEFT | q(0:1) |
gideon_fd_face_p6 | values at the faces | point values | centred | 6 | tridiagonal, FD_FACE_P6_LEFT | q(-1:2) |
gideon_fd_face_p8 | values at the faces | point values | centred | 8 | pentadiagonal, FD_FACE_P8_LEFT | q(-1:2) |
gideon_fd_face_p10 | values at the faces | point values | centred | 10 | pentadiagonal, FD_FACE_P10_LEFT | q(-2:3) |
gideon_fd_face_d1_p4 | d1 at the faces | point values | centred | 4 | tridiagonal, FD_FACE_D1_P4_LEFT | q(0:1) |
gideon_fd_face_d1_p6 | d1 at the faces | point values | centred | 6 | tridiagonal, FD_FACE_D1_P6_LEFT | q(-1:2) |
gideon_fd_face_d1_p8 | d1 at the faces | point values | centred | 8 | pentadiagonal, FD_FACE_D1_P8_LEFT | q(-1:2) |
gideon_fd_face_d1_p10 | d1 at the faces | point values | centred | 10 | pentadiagonal, FD_FACE_D1_P10_LEFT | q(-2:3) |
gideon_fv_face_p4 | values at the faces | cell averages | centred | 4 | tridiagonal, FV_FACE_P4_LEFT | q(0:1) |
gideon_fv_face_p6 | values at the faces | cell averages | centred | 6 | tridiagonal, FV_FACE_P6_LEFT | q(-1:2) |
gideon_fv_face_p8 | values at the faces | cell averages | centred | 8 | pentadiagonal, FV_FACE_P8_LEFT | q(-1:2) |
gideon_fv_face_p10 | values at the faces | cell averages | centred | 10 | pentadiagonal, FV_FACE_P10_LEFT | q(-2:3) |
gideon_fv_face_pbr5 | values at the faces | cell averages | biased right | 5 | tridiagonal, FV_FACE_PBR5_LEFT | q(0:2) |
gideon_fv_face_pbl5 | values at the faces | cell averages | biased left | 5 | tridiagonal, FV_FACE_PBL5_LEFT | q(-1:1) |
gideon_fv_face_pbr7 | values at the faces | cell averages | biased right | 7 | tridiagonal, FV_FACE_PBR7_LEFT | q(-1:3) |
gideon_fv_face_pbl7 | values at the faces | cell averages | biased left | 7 | tridiagonal, FV_FACE_PBL7_LEFT | q(-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,, exact on the polynomials of degree below and zero on the odd-even mode. The conditions are linear in , so the weights are _RIGHT + alpha_f * _ALPHA, the kernel takesalphaas an argument and the caller passes the band[alpha, 1, alpha]to the solver;(at 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>,), a tridiagonal band whose two off-diagonals are both solved for, cells with one more on the upwind side. gideon_fv_face_pbl5, bandon cells , is Pirozzoli's (2002) compact upwind face value: the linear branch of his compact–WENO hybrid. pblreadspbr'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
| Routine | Band | Line |
|---|---|---|
gideon_tri_bounded_{const,var,masked} | bounded: Thomas' algorithm | |
gideon_tri_periodic_{const,var,masked} | the same, indices modulo | periodic |
gideon_penta_bounded_{const,var,masked} | bounded: elimination without pivoting | |
gideon_penta_periodic_{const,var,masked} | the same, indices modulo | periodic |
Every routine, the private helpers included (they are generated in the same three variants):
| Routine | What | Band | Arguments |
|---|---|---|---|
tri_factor_const | bounded tridiagonal solve, the factor kept (private) | constant (scalars) | (n, a, b, c, d, w) |
tri_factor_var | bounded tridiagonal solve, the factor kept (private) | one coefficient per row (arrays) | (n, a, b, c, d, w) |
tri_factor_masked | bounded tridiagonal solve, the factor kept (private) | constant, the rows where mask(i) the identity | (n, a, b, c, mask, d, w) |
tri_resolve_const | another right side with that factor (private) | constant (scalars) | (n, a, b, c, d, w) |
tri_resolve_var | another right side with that factor (private) | one coefficient per row (arrays) | (n, a, b, c, d, w) |
tri_resolve_masked | another right side with that factor (private) | constant, the rows where mask(i) the identity | (n, a, b, c, mask, d, w) |
gideon_tri_bounded_const | tridiagonal line, bounded (Thomas) | constant (scalars) | (n, a, b, c, d, w) |
gideon_tri_bounded_var | tridiagonal line, bounded (Thomas) | one coefficient per row (arrays) | (n, a, b, c, d, w) |
gideon_tri_bounded_masked | tridiagonal line, bounded (Thomas) | constant, the rows where mask(i) the identity | (n, a, b, c, mask, d, w) |
gideon_tri_periodic_const | tridiagonal line, periodic (interior + 1x1 Schur complement) | constant (scalars) | (n, a, b, c, d, w, z) |
gideon_tri_periodic_var | tridiagonal line, periodic (interior + 1x1 Schur complement) | one coefficient per row (arrays) | (n, a, b, c, d, w, z) |
gideon_tri_periodic_masked | tridiagonal line, periodic (interior + 1x1 Schur complement) | constant, the rows where mask(i) the identity | (n, a, b, c, mask, d, w, z) |
penta_factor_const | bounded pentadiagonal solve, the factor kept (private) | constant (scalars) | (n, e, a, b, c, f, d, u1, u2) |
penta_factor_var | bounded pentadiagonal solve, the factor kept (private) | one coefficient per row (arrays) | (n, e, a, b, c, f, d, u1, u2) |
penta_factor_masked | bounded 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_const | another right side with that factor (private) | constant (scalars) | (n, e, a, b, c, f, d, u1, u2) |
penta_resolve_var | another right side with that factor (private) | one coefficient per row (arrays) | (n, e, a, b, c, f, d, u1, u2) |
penta_resolve_masked | another 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_const | pentadiagonal line, bounded | constant (scalars) | (n, e, a, b, c, f, d, u1, u2) |
gideon_penta_bounded_var | pentadiagonal line, bounded | one coefficient per row (arrays) | (n, e, a, b, c, f, d, u1, u2) |
gideon_penta_bounded_masked | pentadiagonal line, bounded | constant, the rows where mask(i) the identity | (n, e, a, b, c, f, mask, d, u1, u2) |
gideon_penta_periodic_const | pentadiagonal line, periodic (interior + 2x2 Schur complement) | constant (scalars) | (n, e, a, b, c, f, d, u1, u2, z1, z2) |
gideon_penta_periodic_var | pentadiagonal 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_masked | pentadiagonal 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_rows | the bounded tridiagonal factor of rows 1..m, leading dimension ld (private) | constant, factored once | (m, ld, a, b, c, fac) |
gideon_tri_bounded_factor | factor of a bounded tridiagonal line, once for every line | constant, factored once | (n, a, b, c, fac) |
gideon_tri_bounded_solve | a bounded tridiagonal line with that factor: multiplications only | constant, factored once | (n, a, fac, d) |
gideon_tri_periodic_factor | factor of a periodic tridiagonal line, once for every line | constant, factored once | (n, a, b, c, fac) |
tri_interior_solve | the interior solve of the border column, in the factor (private) | constant, factored once | (n, a, fac) |
gideon_tri_periodic_solve | a periodic tridiagonal line with that factor: multiplications only | constant, factored once | (n, a, c, fac, d) |
penta_factor_rows | the 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_factor | factor of a bounded pentadiagonal line, once for every line | constant, factored once | (n, e, a, b, c, f, fac) |
gideon_penta_bounded_solve | a bounded pentadiagonal line with that factor: multiplications only | constant, factored once | (n, e, fac, d) |
gideon_penta_periodic_factor | factor of a periodic pentadiagonal line, once for every line | constant, factored once | (n, e, a, b, c, f, fac) |
penta_interior_solve | the interior solve of a border column, in the factor (private) | constant, factored once | (n, e, fac, col) |
gideon_penta_periodic_solve | a periodic pentadiagonal line with that factor: multiplications only | constant, 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 dimensionn, read only by the solves, so on a GPU one copy serves every thread. The solve multiplies by reciprocal pivots where_constdivides: 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 wheremask(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 bandis not diagonally dominant ( ); its symbol makes it positive definite. - A coefficient that reaches outside a bounded line (
, , …) is never read. - Device use: one line per thread,
!$acc parallel loopover 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:
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.