Skip to content

8. The flux register ​

On an AMR grid, a coarse cell next to a fine level is updated with the coarse flux through the shared face. The fine level computes its own, more accurate fluxes. To keep the scheme conservative, the solver accumulates the difference over the step in a flux register and corrects the coarse cell afterwards (refluxing).

With a Runge–Kutta step, "the flux over the step" is a weighted sum of the stage fluxes, and the weights are the scheme's bk:

qn+1−qn=−ΔtΔx∑kbk(Fright−Fleft)k.

stage_weight(k) returns bk in every Runge–Kutta form, including the low-storage ones, whose coefficients are not bk but imply them.

fortran
! the flux register accumulates F_right - F_left of stage k, with the stage's effective weight
flux_w = flux_w + st%stage_weight(k) * boundary_flux(u)
flux_u = flux_u + boundary_flux(u) / st%stages()             ! the wrong weights: uniform, for comparison

The program advects a profile with inflow on the left and outflow on the right. For each stage it adds the stage's net boundary flux, once with stage_weight(k) and once with uniform weights 1/s, then compares both sums with the change of the mass over the step.

Running it ​

text
$ flux_register
mass change + dt sum_k stage_weight(k) flux_k:  4.50E-16
the same with uniform weights 1/s:             3.60E-06

With stage_weight the identity holds to round-off. With uniform weights it misses by the size of the time error, which is how a refluxed AMR solver silently stops conserving.

What you learned

stage_weight(k) is the weight of stage k in the step's fluxes, in every form. Reference: Stepper, P4 Conservation, Cookbook: AMR.

Next: 9. On the GPU.

GPL-3.0-or-later, BSD-2-Clause, BSD-3-Clause or MIT, at your choice