Skip to content

adam_stepper_object ​

ADAM, the time integrator adapter: ADAM's [runge_kutta] schemes on a SELAH stepper (SELAH M7, issue #132).

SELAH owns the time operators (the coefficients, the registers and the stage kernels); this object is the thin ADAM side of it:

  • the input: [runge_kutta] scheme, read as rk_object reads it (no other key), and the mapping of ADAM's scheme names onto a SELAH scheme and storage form (stepper_map);
  • the field: ADAM's q(nv, 1-ngc:ni+ngc, 1-ngc:nj+ngc, 1-ngc:nk+ngc, nb) (LAYOUT_V_FIRST, the CPU backends) or q_gpu(nb, 1-ngc:ni+ngc, 1-ngc:nj+ngc, 1-ngc:nk+ngc, nv) (LAYOUT_V_LAST, the FNL backends), the box of each call built from the active blocks (field%blocks_number, never stored: it changes at every regrid);
  • the immersed boundary: ib%phi is SELAH's mask (a cell is active where the last component, the all-solids distance, is negative, as in rk_object);
  • the registers: allocated here through FUNDAL (device memory in a device build) and passed to SELAH (registers=); on the host zeroed block by block the first time a block is active (issue #45: zeroing the whole fill-the-node pool at allocation would commit all of it), on the device zeroed at allocation (as the FNL stage buffers always were); reachable between steps as scratch (scratch(n), the D_flux diagnostic and the equilibrium residual, #132 rule 3).

The scheme mapping (#132): runge-kutta-1/2/3 are the two-register Shu-Osher forms of Euler, SSP-22 and SSP-33 (ADAM's low-storage coefficients are these, bitwise); runge-kutta-ssp-11/22/33/54 are the Butcher forms of Euler, SSP-22, SSP-33 and SSP-54 (bitwise ADAM's tableaux), every stage on its own register (stages_on_q off), as ADAM's stages are; runge-kutta-yoshida is SELAH's Yoshida-4 splitting (the PRISM integrator of phase 4: it needs the components of its two partitions).

The stage window. Between begin_stage(k) and end_stage(k) the state of stage k is q itself when state_is_q(k) (every stage of the two-register forms), else stage_state(); the caller fills its ghost cells and writes the residual into rhs_register(). The masked (solid) cells of every stage state hold q, as every stage buffer of rk_object did: SELAH's mask policy (masked_q=.true., szaghi/SELAH#5), written by its stage kernel in the same pass; the immersed-boundary extrapolation of the residual starts from them.

The same source serves the CPU backends (host build) and the FNL backends (OpenACC build, -DDEV_OAC): the arrays passed (q, phi, dq) are host arrays in the first, device arrays (FUNDAL pointers) in the second.

Source: src/lib/common/adam_stepper_object.F90

Dependencies

Re-exports ​

NameKindModuleDescription
LAYOUT_V_FIRSTselah
LAYOUT_V_LASTselah

Contents ​

Variables ​

NameTypeAttributesDescription
RK_1character(len=13)parameterParameter of time scheme, Runge-Kutta 1.
RK_2character(len=13)parameterParameter of time scheme, Runge-Kutta 2.
RK_3character(len=13)parameterParameter of time scheme, Runge-Kutta 3.
RK_SSP_11character(len=18)parameterParameter of time scheme, Runge-Kutta SSP 11 (forward Euler).
RK_SSP_22character(len=18)parameterParameter of time scheme, Runge-Kutta SSP 22.
RK_SSP_33character(len=18)parameterParameter of time scheme, Runge-Kutta SSP 33.
RK_SSP_54character(len=18)parameterParameter of time scheme, Runge-Kutta SSP 54.
RK_YOSHIDAcharacter(len=19)parameterParameter of time scheme, Runge-Kutta Yoshida, symplectic 4.
INI_SECTION_NAMEcharacter(len=11)parameterINI (config) file section name containing configs.

Derived Types ​

stepper_object ​

ADAM's [runge_kutta] scheme on a SELAH stepper.

Components

NameTypeAttributesDescription
schemecharacter(len=:)allocatableADAM scheme name ([runge_kutta] scheme).
selah_schemecharacter(len=:)allocatableSELAH scheme.
formcharacter(len=:)allocatableSELAH storage form.
sttype(stepper)SELAH stepper.
regsreal(kind=R8P)pointer, contiguousRegisters (v, i, j, k, b, slot).
nregsinteger(kind=I4P)Registers number.
blocks_zeroedinteger(kind=I4P)Block slots of regs zeroed so far (issue #45).
nvinteger(kind=I4P)Number of variables.
niinteger(kind=I4P)Cells per block, per direction.
njinteger(kind=I4P)Cells per block, per direction.
nkinteger(kind=I4P)Cells per block, per direction.
ngcinteger(kind=I4P)Ghost cells.
nbinteger(kind=I4P)Block slots of the pool.
layoutinteger(kind=I4P)Field layout: (v, i, j, k, b) or (b, i, j, k, v).

Type-Bound Procedures

NameAttributesDescription
begin_steppass(self)Open a step.
begin_stagepass(self)Open stage k: build its state.
descriptionpass(self)Return pretty-printed object description.
destroypass(self)Free the registers.
end_stagepass(self)Close stage k.
finish_steppass(self)Close the step.
initializepass(self)Initialize the stepper and its registers.
imag_axis_boundpass(self)Stability bound on the imaginary axis (SELAH).
is_butcherpass(self)The form is Butcher's (the stages on their own registers).
is_splittingpass(self)The form is a splitting of two partitions.
is_two_registerpass(self)The form is the two-register (low-storage) Shu-Osher one.
load_from_filepass(self)Load config from file.
rhs_registerpass(self)Residual register of the active stage.
scratchpass(self)A register as scratch, between steps.
set_rhspass(self)Copy a residual into the residual register of the active stage.
ssp_coefficientpass(self)SSP coefficient of the scheme (SELAH; 0 if not SSP).
stage_euler_fractionpass(self)Forward-Euler step of stage k, a fraction of the step (SELAH).
stage_statepass(self)State register of the active stage (null when it is q).
stage_timepass(self)Fraction of the step at which stage k is evaluated.
stage_weightpass(self)Effective Butcher weight of stage k.
stagespass(self)Stages per step.
state_is_qpass(self)The state of stage k is q itself.
interior_boxpass(self)Box of the interior cells of the active blocks.

Subroutines ​

stepper_map ​

Map an ADAM [runge_kutta] scheme name onto a SELAH scheme and storage form; an unknown name gives empty strings.

Attributes: pure

fortran
subroutine stepper_map(scheme, selah_scheme, form)

Arguments

NameTypeIntentAttributesDescription
schemecharacter(len=*)inADAM scheme name.
selah_schemecharacter(len=:)outallocatableSELAH scheme.
formcharacter(len=:)outallocatableSELAH storage form.

Call graph

begin_step ​

Open a step: zero the block slots active for the first time, then let SELAH keep what its form needs of q.

fortran
subroutine begin_step(self, field, q, phi)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
fieldtype(field_object)inField (sibling realm component, threaded in).
qreal(kind=R8P)inState.
phireal(kind=R8P)inoptionalIB distance.

Call graph

begin_stage ​

Open stage k: SELAH builds its state (its masked cells q, the mask policy).

fortran
subroutine begin_stage(self, k, field, dt, q, phi)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
kinteger(kind=I4P)inStage.
fieldtype(field_object)inField (sibling realm component, threaded in).
dtreal(kind=R8P)inTime step.
qreal(kind=R8P)inState.
phireal(kind=R8P)inoptionalIB distance.

Call graph

destroy ​

Free the stepper and its registers.

fortran
subroutine destroy(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.

Call graph

end_stage ​

Close stage k, its residual written into rhs_register(): the two-register forms advance q here.

fortran
subroutine end_stage(self, k, field, dt, q, phi)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
kinteger(kind=I4P)inStage.
fieldtype(field_object)inField (sibling realm component, threaded in).
dtreal(kind=R8P)inTime step.
qreal(kind=R8P)inoutState.
phireal(kind=R8P)inoptionalIB distance.

Call graph

finish_step ​

Close the step: the Butcher form advances q now and gives the step residual dq = sum_k b_k R_k (0 in the masked cells, #128 D4); the two-register forms already advanced q and leave dq as the caller wrote it.

fortran
subroutine finish_step(self, field, dt, q, dq, phi)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
fieldtype(field_object)inField (sibling realm component, threaded in).
dtreal(kind=R8P)inTime step.
qreal(kind=R8P)inoutState.
dqreal(kind=R8P)inoutoptionalStep residual.
phireal(kind=R8P)inoptionalIB distance.

Call graph

initialize ​

Initialize the stepper of [runge_kutta] scheme (or of scheme) and its registers, the field's pool shape.

fortran
subroutine initialize(self, field, grid, file_parameters, scheme, partitions, layout)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
fieldtype(field_object)inField (sibling realm component, threaded in).
gridtype(grid_object)inGrid (sibling realm component, threaded in).
file_parameterstype(file_ini)inoptionalSimulation parameters ini file handler.
schemecharacter(len=*)inoptionalRunge-Kutta scheme.
partitionsinteger(kind=I4P)inoptionalSplitting: the variables of its two partitions.
layoutinteger(kind=I4P)inoptionalField layout (default LAYOUT_V_FIRST).

Call graph

load_from_file ​

Load config from file: [runge_kutta] scheme, the only key (as rk_object reads it).

fortran
subroutine load_from_file(self, file_parameters)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inoutStepper.
file_parameterstype(file_ini)inSimulation parameters ini file handler.

Call graph

set_rhs ​

Copy the residual dq into the residual register of the active stage, the interior cells of the active blocks (SELAH's copy kernel: on the device in a device build). For a caller that evaluates the residual into its own array (the residual log reads it, a correction acts on it) before the stage update reads the register.

fortran
subroutine set_rhs(self, field, dq)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
fieldtype(field_object)inField (sibling realm component, threaded in).
dqreal(kind=R8P)inResidual.

Call graph

Functions ​

stepper_stored_fields ​

Return the block-sized fields (of nv variables) the stepper of a scheme allocates: SELAH's registers_needed, the residual register included. It lets an app size its memory budget before the stepper exists; an unknown scheme returns -1.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function stepper_stored_fields(scheme) result(fields)

Arguments

NameTypeIntentAttributesDescription
schemecharacter(len=*)inADAM scheme name.

Call graph

stepper_butcher_stages ​

Return the stages of a scheme of the Butcher form (the SSP schemes), from SELAH's tableau; -1 for any other scheme. It lets an app size what follows the field's stages (PRISM's particle stages) before the stepper exists.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function stepper_butcher_stages(scheme) result(stages)

Arguments

NameTypeIntentAttributesDescription
schemecharacter(len=*)inADAM scheme name.

Call graph

description ​

Return a pretty-formatted object description.

Attributes: pure

Returns: character(len=:)

fortran
function description(self) result(desc)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

imag_axis_bound ​

Return the end of the scheme's stability region on the imaginary axis, |R(iy)| <= 1 for |y| <= beta (SELAH, from its stability polynomial; 0 when R(iy) leaves the unit disc at once, as for Euler and SSP-22).

Attributes: pure

Returns: real(kind=R8P)

fortran
function imag_axis_bound(self) result(beta)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

is_butcher ​

Return true if the form is Butcher's: every stage on its own state register, the step closed by finish_step.

Attributes: elemental

Returns: logical

fortran
function is_butcher(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

is_splitting ​

Return true if the form is a splitting of two partitions (each stage a flow of one partition).

Attributes: elemental

Returns: logical

fortran
function is_splitting(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

is_two_register ​

Return true if the form is the two-register Shu-Osher one (every stage on q, low storage).

Attributes: elemental

Returns: logical

fortran
function is_two_register(self) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

rhs_register ​

Return the residual register of the active stage, with the field's bounds (null outside a stage window).

Returns: real(kind=R8P)

fortran
function rhs_register(self) result(r)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

scratch ​

Return register n as scratch, between steps (SELAH's registers are scratch after finish_step): every form has at least two registers (#132 rule 3, #128 D1). Writing them leaves the next step unchanged: each step rebuilds what it reads of them.

Returns: real(kind=R8P)

fortran
function scratch(self, n) result(r)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
ninteger(kind=I4P)inRegister.

Call graph

ssp_coefficient ​

Return the SSP coefficient C of the scheme (SELAH, from its Shu-Osher form): every stage a convex combination of forward-Euler steps when C > 0; 0 for a scheme that is not SSP and for a splitting.

Attributes: pure

Returns: real(kind=R8P)

fortran
function ssp_coefficient(self) result(c)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

stage_euler_fraction ​

Return the forward-Euler step the residual of stage k enters, as a fraction of the step (SELAH, f_k = max_i beta_ik / alpha_ik of the Shu-Osher form): a limiter that makes the state of stage k plus f_k dt times its residual admissible keeps every later stage and the step admissible; 0 when the scheme has no such decomposition.

Attributes: pure

Returns: real(kind=R8P)

fortran
function stage_euler_fraction(self, k) result(f)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
kinteger(kind=I4P)inStage.

Call graph

stage_state ​

Return the state register of the active stage, with the field's bounds; null when the stage's state is q itself.

Returns: real(kind=R8P)

fortran
function stage_state(self) result(u)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

stage_time ​

Return the fraction of the step at which the residual of stage k is evaluated (the abscissa c_k).

Attributes: pure

Returns: real(kind=R8P)

fortran
function stage_time(self, k) result(c)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
kinteger(kind=I4P)inStage.

Call graph

stage_weight ​

Return the effective Butcher weight b_k of stage k: the weight of its fluxes in the step (the flux register's).

Attributes: pure

Returns: real(kind=R8P)

fortran
function stage_weight(self, k) result(w)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
kinteger(kind=I4P)inStage.

Call graph

stages ​

Return the stages per step.

Attributes: pure

Returns: integer(kind=I4P)

fortran
function stages(self) result(n)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.

Call graph

state_is_q ​

Return true if the state of stage k is q itself (every stage of the two-register forms).

Attributes: pure

Returns: logical

fortran
function state_is_q(self, k) result(yes)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
kinteger(kind=I4P)inStage.

Call graph

interior_box ​

Return the box of the interior cells of the active blocks (field%blocks_number, at the time of the call).

Attributes: pure

Returns: type(box)

fortran
function interior_box(self, field) result(bx)

Arguments

NameTypeIntentAttributesDescription
selfclass(stepper_object)inStepper.
fieldtype(field_object)inField.

Call graph