Appearance
adam_ripple_common_object
RIPPLE, the common realm: what the CPU and FNL backends share.
RIPPLE solves the scalar linear advection u_t + a . grad(u) = 0 on a periodic box: the worked example of the "build your own solver" tutorial (issue #59). A RIPPLE realm extends the library's realm_object, which already owns the grid, the tree, the field, the maps, the WENO and the Runge-Kutta objects; this module adds the state q, the advection velocity, the time bookkeeping, the initial condition (a smooth profile with an exact translated solution), the initial AMR and the parts of the forest contract that do not depend on where q lives.
The scheme is the Shu-Osher conservative finite difference: point values at the cell centres, the upwind split flux a+ u / a- u reconstructed at every face by the library's WENO, dq = -sum_d (F_{i+1/2} - F_{i-1/2}) / dx_d. The backends own the residuals and the integration.
Source: src/app/ripple/common/adam_ripple_common_object.F90
Dependencies
Contents
- ripple_common_object
- initialize_ripple
- check_input
- amr_update_initial_forest
- rebalance_initial_forest
- reset_time_forest
- set_initial_state_forest
- set_initial_conditions
- amr_update
- register_amr_criterion
- save_output
- advance_time
- accumulate_seam_skin
- apply_reflux
- compute_local_dt_forest
- is_done_forest
- initial_amr_iterations_forest
- compute_total
- stages_per_step_forest
- exact_solution
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
PI2 | real(kind=R8P) | parameter | 2 pi. |
Derived Types
ripple_common_object
RIPPLE common realm.
Inheritance
Extends: realm_object
Components
| Name | Type | Attributes | Description |
|---|---|---|---|
io | type(io_object) | IO handler. | |
amr | type(amr_object) | AMR marker handler. | |
slices | type(slices_object) | Slices handler. | |
flail | type(flail_object) | FLAIL, the elliptic solver library (issue #84). | |
weno | type(weno_object) | WENO reconstructor. | |
with_weno | logical | Read [weno] and initialize weno (the app clears it when unused, #80 P5). | |
with_fdv | logical | Read [fdv] and bind the FD/FV operators (cleared when unused, #80 P5). | |
ib | type(ib_object) | Immersed boundary. | |
ts | type(stepper_object) | Time integrator on SELAH (stepper_object, #132). | |
selah_layout | integer(kind=I4P) | Layout of the fields ts integrates (the FNL apps set LAYOUT_V_LAST, their (b, i, j, k, v) device fields). | |
selah_partitions | integer(kind=I4P) | The variables (first, last) of the two partitions of a splitting scheme (PRISM's Yoshida: B then D); 0 for none. | |
adam | type(adam_object) | ADAM, grid + tree + field + maps orchestrator. | |
fdv_scheme | character(len=:) | allocatable | FDV scheme, fd/fv. |
fdv_order | integer(kind=I4P) | Order of finite difference/volume schemes, general order. | |
fdv_half_stencil | integer(kind=I4P) | Half stencil length of finite difference/volume schemes. | |
fdv_half_stencils | integer(kind=I4P) | Half stencil length of fdv schemes for each derivative up to 6. | |
ngc | integer(kind=I4P) | pointer | Number of ghost cells. |
ni | integer(kind=I4P) | pointer | Number of cells in i direction. |
nj | integer(kind=I4P) | pointer | Number of cells in j direction. |
nk | integer(kind=I4P) | pointer | Number of cells in k direction. |
nb | integer(kind=I4P) | pointer | Total blocks number for MPI. |
blocks_number | integer(kind=I4P) | pointer | Actual blocks number. |
nv | integer(kind=I4P) | pointer | Number of variables in q vector. 1-based position of this realm in the forest's realm(:) array, or 0 in the N=1 single-realm legacy path (where the program driver calls realm%initialize_forest directly, bypassing the forest orchestrator). |
realm_index | integer(kind=I4P) | ||
realms_number | integer(kind=I4P) | Realms in the forest (set by initialize_forest, #80 P3). Inter-realm seam coupling — currently-published stage buffer key. | |
stage_active | integer(kind=I4P) | A copy of the forest's flux register (its faces and lookup, the accumulators unused), refreshed by the forest each time it builds the register (init, regrid). A realm can accumulate one residual evaluation's seam fluxes into it for a diagnostic without touching the forest's step accumulators (FLUME's D_flux, issue #68 A2). | |
flux_register_copy | type(flux_register_object) | Procedure pointer TBPs for FDV operators (set at initialization by backend). | |
compute_block_total_variation | procedure(compute_block_total_variation_interface) | pass(self), pointer | Compute TV. |
compute_curl | procedure(compute_curl_interface) | pass(self), pointer | Compute curl. |
compute_curl_extended | procedure(compute_curl_interface) | pass(self), pointer | Compute curl on extended support. |
compute_derivative1 | procedure(compute_derivative1_interface) | pass(self), pointer | Compute deriv1. |
compute_derivative2 | procedure(compute_derivative2_interface) | pass(self), pointer | Compute deriv2. |
compute_derivative4 | procedure(compute_derivative4_interface) | pass(self), pointer | Compute deriv4. |
compute_divergence | procedure(compute_divergence_interface) | pass(self), pointer | Compute dive. |
compute_gradient | procedure(compute_gradient_interface) | pass(self), pointer | Compute grad. |
compute_gradient_extended | procedure(compute_gradient_interface) | pass(self), pointer | Compute gradient on extended support. |
compute_laplacian | procedure(compute_laplacian_interface) | pass(self), pointer | Compute laplac. |
q | real(kind=R8P) | allocatable | State, point values u [1, 1-ngc:ni+ngc, ..., nb]. |
dq | real(kind=R8P) | allocatable | Residuals, same shape. |
a | real(kind=R8P) | Advection velocity. | |
time | type(time_object) | Time handler (library): it, time, dt and the [time] keys. | |
history_unit | integer(kind=I4P) | Unit of the history file (rank 0). | |
amr_criteria | type(amr_criterion_pointer) | allocatable | Registered refinement criteria (issue #110). |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
initialize | pass(self) | Initialize common data. |
load_fdv_from_file | pass(self) | Load FDV config from file. |
initialize_process_context | pass(self) | Process-global MPI (+ device) init; forest calls it ONCE first. |
initialize_forest | pass(self), non_overridable | Invoked by forest%initialize per realm: the template. |
initialize_app_forest | pass(self) | Template hook: parse, build, backend, before the state. |
restart_state_forest | pass(self) | Template hook: the state from the restart files. |
post_initial_state_forest | pass(self) | Template hook: everything after the initial state. |
advance_one_step_forest | pass(self) | Invoked by forest%evolve_one_step per realm per timestep. |
coupling_descriptor_forest | pass(self) | Report (scheme_time, rk_scheme, nv) for β admissibility. |
open_step_forest | pass(self) | Per-step prologue (multi-realm path). |
begin_stage_forest | pass(self) | Begin one integrator stage on this realm (multi-realm path). |
end_stage_forest | pass(self) | End the stage: residuals + assignment (multi-realm path). |
close_step_forest | pass(self) | Per-step epilogue (multi-realm path). |
post_step_forest | pass(self) | Invoked by forest%post_step per realm per timestep. |
runtime_amr_forest | pass(self) | Whether this realm regrids during the run (#74). |
regrid_forest | pass(self) | Invoked by forest%regrid per realm per timestep (#74). |
regrid_begin_forest | pass(self) | Multi-realm regrid, phase 1: is it a regrid step (#110). |
regrid_mark_forest | pass(self) | Phase 2: mark one sweep, marks on the tree (#110). |
regrid_apply_forest | pass(self) | Phase 3: adapt to the (balanced) tree marks (#110). |
regrid_end_forest | pass(self) | Phase 4: refresh the grid-dependent state (#110). |
finalize_forest | pass(self) | Invoked by forest%finalize per realm at shutdown. |
finalize_mpi_forest | pass(self) | Process-global MPI finalize; forest calls it ONCE after all. |
fill_seam_from_peer_forest | pass(self) | Receive-side roundtrip: copy peer's interior into self's ghosts. |
pack_seam_cells_forest | pass(self) | Pack own cells of the cross-rank seam send rows. |
unpack_seam_cells_forest | pass(self) | Unpack the cross-rank seam receive rows into own ghosts. |
after_topology_build_forest | pass(self) | Backend hook invoked once after the forest builds the seam maps. |
apply_reflux_to_stage_forest | pass(self) | Apply Berger-Colella reflux to self's stage buffer. |
close_block_xh5f | nopass | Close XH5F file block. |
close_file_xh5f | nopass | Close XH5F file. |
open_block_xh5f | pass(self) | Open block file XH5F. |
open_file_xh5f | pass(self) | Open file XH5F. |
save_q_xh5f | pass(self) | Save in XH5F (XDMF/HDF5) format. |
compute_curl_fd_extended | pass(self) | Compute curl of vector field, finite difference, even for half gcs. |
compute_gradient_fd_extended | pass(self) | Compute gradient of scalar field, finite difference, even for half gcs. private FDV operators |
initialize_ripple | pass(self) | Initialize the common data. |
check_input | pass(self) | Refuse the inputs RIPPLE cannot honour. |
set_initial_conditions | pass(self) | Set the initial profile on the interior cells. |
amr_update | pass(self) | Initial AMR: box markers and registered criteria. |
register_amr_criterion | pass(self) | Register a refinement criterion by name (issue #110). |
compute_total | pass(self) | Total of u dV on this rank. |
save_output | pass(self) | Save one history row and the state (XH5F). |
advance_time | pass(self) | Count the step and cap dt on time_max. |
accumulate_seam_skin | pass(self) | Route one seam face skin to the flux register. |
apply_reflux | pass(self) | Berger-Colella correction of the coarse seam cells of q. |
amr_update_initial_forest | pass(self) | Template hook: the initial regrid. |
initial_amr_iterations_forest | pass(self) | Template hook: one initial regrid with markers, none without. |
rebalance_initial_forest | pass(self) | Template hook: no static rebalance. |
reset_time_forest | pass(self) | Template hook: time and step counter to zero. |
set_initial_state_forest | pass(self) | Template hook: the initial profile. |
compute_local_dt_forest | pass(self) | Local CFL time step. |
is_done_forest | pass(self) | True when the run is over. |
stages_per_step_forest | pass(self) | Runge-Kutta stages per step (staged path). |
ripple_common_object%initialize
Initialize common data: MPI, ADAM, grid, field and data replica pointers.
[weno] and [fdv] are read on demand (issue #80 P5): before calling this, the application says whether its configuration uses the WENO coefficients (self%with_weno) and the realm's FD/FV operators (self%with_fdv), both .true. by default. A component not wanted is not initialized and its section is not read, so an input that carries it anyway reports its keys unread.
fortran
subroutine initialize(self, filename, memory_avail, nv, fields_number, verbose, L0)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | target | The equation. |
filename | character(len=*) | in | Input parameters file name. | |
memory_avail | real(kind=R8P) | in | value | Memory available for single MPI process. |
nv | integer(kind=I4P) | in | optional | Number of field variables. |
fields_number | integer(kind=I4P) | in | optional | Block-sized fields allocated per block (default 170). |
verbose | logical | in | optional | Trigger verbose output. |
L0 | real(kind=R8P) | in | optional | Adimensionalization parameter. |
Call graph
ripple_common_object%load_fdv_from_file
Load FDV config from file.
fortran
subroutine load_fdv_from_file(self, file_parameters)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The equation. | |
file_parameters | type(file_ini) | in | Simulation parameters ini file handler. |
Call graph
ripple_common_object%initialize_process_context
Initialize the process-global MPI handler (and the device, on the device backends).
MPI and the device context are process-global: the forest calls this ONCE, on a single realm, before any realm is initialized (issue #80 P3, the mirror of finalize_mpi_forest); a realm never initializes them itself. The default initializes the CPU mpih singleton; the FNL backends override it to initialize mpih_fnl (device binding, the ranks sharing a device) first. mpih%initialize is once-only, so a test driver that called it already is harmless.
fortran
subroutine initialize_process_context(self, verbose)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm (carries no MPI state; dispatch picks the backend). | |
verbose | logical | in | optional | Trigger verbose output. |
Call graph
ripple_common_object%initialize_forest
Initialize this realm, the library template (issue #80 P3): the sequence every application shares, its steps delegated to the *_forest hooks below.
fortran
call self%initialize_app_forest(filename, realms_number) ! parse, build the library and app objects, the backend
if (self%io%restart) then
call self%restart_state_forest ! the state from the restart files
else
do i=1, self%initial_amr_iterations_forest() ! the initial state, then a regrid on it, n times
call self%set_initial_state_forest
call self%amr_update_initial_forest
enddo
call self%rebalance_initial_forest ! [amr].(balance_static)
call self%set_initial_state_forest ! the initial state on the final grid
call self%adam%make_comm_local_maps_ghost_bc ! the maps of the final grid
call self%reset_time_forest
endif
call self%post_initial_state_forest ! device push, ghosts, t0 diagnostics, history filesInvoked by forest%initialize once per realm at startup, before the time loop; MPI and the device are up already (initialize_process_context). The forest sets self%realm_index = is BEFORE invoking it, so the hooks can read their forest position for per-realm IO filenames, log prefixes, etc. The template is non-overridable: an application implements the hooks, whose defaults error-stop, except restart_state_forest, which refuses [IO].(restart) = .true..
fortran
subroutine initialize_forest(self, filename, realms_number)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
filename | character(len=*) | in | Input parameters file name. | |
realms_number | integer(kind=I4P) | in | optional | Realm count in the forest. |
Call graph
ripple_common_object%initialize_app_forest
Template hook: everything before the initial state (parse the input, build the library and app objects, set up the backend); realms_number divides the memory budget in a forest. Default error-stops.
fortran
subroutine initialize_app_forest(self, filename, realms_number)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
filename | character(len=*) | in | Input parameters file name. | |
realms_number | integer(kind=I4P) | in | optional | Realm count in the forest. |
Call graph
ripple_common_object%restart_state_forest
Template hook: the state from the restart files (time and step counter included). Default refuses the restart.
fortran
subroutine restart_state_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. |
Call graph
ripple_common_object%post_initial_state_forest
Template hook: everything after the initial state, restart or not (device push, ghost update, t0 diagnostics, history files, the AMR lock). Default error-stops.
fortran
subroutine post_initial_state_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. |
Call graph
ripple_common_object%advance_one_step_forest
Advance this realm by one full timestep of size dt.
Invoked by forest%evolve_one_step once per realm per timestep when the forest contains a single realm (N=1 fast path). For N>1 the forest drives the stage loop itself via open_step_forest, begin_stage_forest, end_stage_forest, close_step_forest, and this TBP is NOT invoked — see forest_object%evolve_one_step for the multi-realm path.
The orchestrator owns global dt selection (compute_global_dt) and the termination check; this method owns the integration itself — RK substages, BC application, intra-realm ghost exchange, divergence cleaning — i.e. everything that turns q at time t into q at time t + dt.
Default implementation error-stops: every consumer app MUST override this method (the integrator catalog and the substage layout are app-specific). PRISM's override lives on prism_cpu_object and prism_fnl_object as a thin wrapper around the legacy integrate / integrate_dev dispatch.
fortran
subroutine advance_one_step_forest(self, dt)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
dt | real(kind=R8P) | in | Timestep size. |
Call graph
ripple_common_object%coupling_descriptor_forest
Report this realm's coupling descriptor for β admissibility.
Returns the identity of the realm's ODE solver + physics layout. Two realms may share a seam with CADENCE_STAGE_COINCIDENT only if all three values match between them; otherwise the forest rejects the manifest. Spatial operator (scheme_space) and grid resolution are NOT in the descriptor — those are precisely the dimensions β allows to differ between realms.
Default implementation returns empty strings and sentinel nv = -1: a realm that does not override this TBP cannot participate in β. App-side overrides (e.g. prism_common_object) report numerics%scheme_time, ts%scheme, physics%nv.
fortran
subroutine coupling_descriptor_forest(self, scheme_time, rk_scheme, nv)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. | |
scheme_time | character(len=:) | out | allocatable | Time-integration family tag ("runge_kutta", "leapfrog", ...). |
rk_scheme | character(len=:) | out | allocatable | Within-family scheme tag ("runge-kutta-ssp-54", ...). |
nv | integer(kind=I4P) | out | Number of conserved variables on this realm. |
Call graph
ripple_common_object%open_step_forest
Per-step prologue on the multi-realm path: pre-stage-loop setup.
Invoked once per realm per timestep, BEFORE the forest's stage loop starts. Body owns whatever the integrator does once per step before its first stage: external-field prelude, integrator-private state initialization (for SELAH realms: ts%begin_step), time bookkeeping (it increment, dt capping for time_max), progress prints.
Default implementation error-stops: every multi-realm participant MUST override this. N=1 apps can leave it.
fortran
subroutine open_step_forest(self, dt)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
dt | real(kind=R8P) | in | Timestep size from the forest. |
Call graph
ripple_common_object%begin_stage_forest
Open one integrator stage on this realm — multi-realm path.
Invoked once per (realm, stage) by the forest, with k iterating from 1 to K_total. Body publishes the realm's stage-k buffer to peers: it runs whatever integrator-private work is needed BEFORE residuals (for SELAH realms: ts%begin_stage(k) building the stage state from self%q and the prior stages), and assigns self%stage_active = k so peer-realm reads pick up the right buffer. Crucially it does NOT touch ghost cells from peer realms; peer realms may not yet have opened their own stage-k buffer when this fires.
The forest invokes begin_stage_forest on EVERY realm before proceeding to the seam fill and end_stage_forest, so by the time residuals evaluate, every peer realm has its stage-k buffer populated and the inter-realm ghost exchange returns coherent values.
Default implementation error-stops: every multi-realm participant MUST override this.
fortran
subroutine begin_stage_forest(self, k, K_total, dt, realm)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
k | integer(kind=I4P) | in | Stage index (1..K_total). | |
K_total | integer(kind=I4P) | in | Forest-wide stage count for this step. | |
dt | real(kind=R8P) | in | Timestep size from the forest. | |
realm | type(realm_pointer) | inout | target, optional | Sibling realms (contract parity). |
Call graph
ripple_common_object%end_stage_forest
Close one integrator stage on this realm — multi-realm path.
Invoked once per (realm, stage) by the forest AFTER its Phase 2 inter-realm seam fill has populated the seam ghost cells. The body runs the integrator's per-stage work that needs valid peer ghosts: residual computation and stage assignment in a single sweep (for SELAH realms: compute_residuals + ts%set_rhs). The read-after- overwrite race that originally required a three-phase split is eliminated by the upstream seam fill, which decouples peer state reads from the in-place overwrite of the stage buffer's interior.
flux_register is an optional dummy used by FV residuals (compute_residuals_fv_centered) to accumulate seam-face flux contributions for Phase-A Berger–Colella reflux. Backends that don't implement FV reflux (e.g. FNL's FD-centered path) ignore it.
Default implementation error-stops: every multi-realm participant MUST override this. realm accepted on contract for parity but is not needed: peer state is read via the seam fill, not here.
fortran
subroutine end_stage_forest(self, k, K_total, dt, realm, flux_register)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
k | integer(kind=I4P) | in | Stage index (1..K_total). | |
K_total | integer(kind=I4P) | in | Forest-wide stage count for this step. | |
dt | real(kind=R8P) | in | Timestep size from the forest. | |
realm | type(realm_pointer) | inout | target, optional | Sibling realms (parity only). |
flux_register | class(flux_register_object) | inout | optional | Forest's flux register for FV reflux. |
Call graph
ripple_common_object%close_step_forest
Per-step epilogue on the multi-realm path: post-stage-loop finalization.
Invoked once per realm per timestep, AFTER the forest's stage loop completes. Body owns whatever the integrator does once per step at the end: assembly of the committed state from stage buffers (for SELAH realms: ts%finish_step), BC update, divergence cleaning, coil current refresh, residual save, time advance. Should also clear self%stage_active = 0 so any inter-step fill_seam_from_peer_forest query reads from the committed state rather than a stale stage buffer.
Default implementation error-stops: every multi-realm participant MUST override this.
fortran
subroutine close_step_forest(self, dt)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
dt | real(kind=R8P) | in | Timestep size from the forest. |
Call graph
ripple_common_object%post_step_forest
Run this realm's per-timestep post-step work: diagnostics, IO, AMR.
Invoked by forest%post_step once per realm per timestep, after the advance. The orchestrator owns cadence decisions (when to save state, when to refine the mesh, etc.) and conveys them via the optional do_* flags; this method executes the work that those flags enable. Cadence flags absent ⇒ caller wants the default cadence (today: do everything every step, since save_*_data routines internally respect the realm's own it_save settings).
Default implementation error-stops: every consumer app MUST override this method (the diagnostic catalog and IO layout are app-specific). PRISM's override lives on prism_cpu_object and prism_fnl_object.
Optional realm(:): forest realm array threaded for inter-realm halo refresh inside save_simulation_data (which calls update_ghost). FNL backend forwards it through; CPU backend ignores it.
fortran
subroutine post_step_forest(self, dt, t, it, do_save_state, do_save_residuals, do_save_restart, do_amr, realm)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
dt | real(kind=R8P) | in | Timestep size just advanced. | |
t | real(kind=R8P) | in | Simulation time after the advance. | |
it | integer(kind=I4P) | in | Iteration index after the advance. | |
do_save_state | logical | in | optional | Save state output this step. |
do_save_residuals | logical | in | optional | Save residuals output this step. |
do_save_restart | logical | in | optional | Save restart dump this step. |
do_amr | logical | in | optional | Run AMR update this step. |
realm | type(realm_pointer) | inout | target, optional | Sibling realms for inter-realm halo refresh. |
Call graph
ripple_common_object%runtime_amr_forest
Return whether this realm regrids during the time loop (issue #74, runtime AMR).
The forest asks it before every regrid: with a realm that regrids, a multi-realm forest fills its seams before the realms mark and balances their marks across the seams (issue #110). Default: no runtime regridding, the behaviour of every app before #74; an app that regrids overrides it.
Returns: logical
fortran
function runtime_amr_forest(self) result(yes)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. |
Call graph
ripple_common_object%regrid_forest
Regrid this realm if its cadence asks for it now (issue #74, runtime AMR).
Invoked by forest%regrid once per realm after post_step_forest, on committed q (no stage active). The realm marks its blocks, calls adam%amr_update and refreshes its grid-dependent state; regridded tells the forest whether the tree changed, so it rebuilds what it owns (the flux register). Default: never regrid.
fortran
subroutine regrid_forest(self, regridded)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
regridded | logical | out | True if the tree changed. |
Call graph
ripple_common_object%regrid_begin_forest
Start a multi-realm regrid of this realm: active if its cadence asks for a regrid now (issue #110).
fortran
subroutine regrid_begin_forest(self, active)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
active | logical | out | This realm marks its blocks at this step. |
Call graph
ripple_common_object%regrid_mark_forest
Mark the blocks of this realm for sweep sweep and gather the marks on its replicated tree (issue #110).
marked is false when the realm does not mark in this sweep (no regrid step, or more sweeps than its [amr] iters); the forest then clears its tree marks before balancing the seams.
fortran
subroutine regrid_mark_forest(self, sweep, marked)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
sweep | integer(kind=I4P) | in | Sweep of the regrid, from 1. | |
marked | logical | out | The realm marked its blocks. |
Call graph
ripple_common_object%regrid_apply_forest
Adapt this realm to the marks on its replicated tree, as the forest balanced them (issue #110).
fortran
subroutine regrid_apply_forest(self, changed)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
changed | logical | out | The tree changed. |
Call graph
ripple_common_object%regrid_end_forest
End a multi-realm regrid of this realm: refresh the state of the new grid, regridded if any sweep changed it.
fortran
subroutine regrid_end_forest(self, regridded)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
regridded | logical | out | The tree changed in some sweep. |
Call graph
ripple_common_object%finalize_forest
Shut this realm down: final state dump, final diagnostics, close output files, finalize the realm's MPI handler.
Invoked by forest%finalize once per realm at shutdown, after the time loop exits. Mirror of initialize_forest: every IO file opened in initialize_forest is closed here; every per-realm resource the orchestrator did not acquire is released here.
Default implementation error-stops: every consumer app MUST override this method (the close-order and final-dump catalog are app-specific). PRISM's override lives on prism_cpu_object/prism_fnl_object.
fortran
subroutine finalize_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. |
Call graph
ripple_common_object%finalize_mpi_forest
Finalize the process-global MPI handler.
MPI_FINALIZE is process-global and must run EXACTLY ONCE, after every realm has completed all MPI-using teardown. The forest therefore calls this on a SINGLE realm after the per-realm finalize_forest loop — not inside finalize_forest (which runs per realm; doing the finalize there tore MPI down while later realms still had IO/ghost work pending — the next realm's update_ghost would hit MPI_Type_f2c on a finalized communicator). The default targets the CPU mpih singleton; the FNL backend overrides to finalize mpih_fnl.
fortran
subroutine finalize_mpi_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm (carries no MPI state; dispatch picks the backend handler). |
Call graph
ripple_common_object%fill_seam_from_peer_forest
Fill THIS realm's seam ghost cells for peer slot p_idx from peer's interior. Default: error_stops; every multi-realm participant MUST override (the receiver is the dispatch target).
fortran
subroutine fill_seam_from_peer_forest(self, peer, p_idx)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | ||
peer | class(realm_object) | in | target | |
p_idx | integer(kind=I4P) | in |
Call graph
ripple_common_object%pack_seam_cells_forest
Pack this realm's cells of the cross-rank seam send rows of peer slot p_idx (maps%seam_mpi_send_cell), from the active buffer (stage_active rule of fill_seam_from_peer_forest), nv values per row in row order. Default: error_stops; every multi-realm participant MUST override.
fortran
subroutine pack_seam_cells_forest(self, p_idx, buf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. | |
p_idx | integer(kind=I4P) | in | Peer slot (the realm that owns the ghosts). | |
buf | real(kind=R8P) | out | Packed values, nv * rows. |
Call graph
ripple_common_object%unpack_seam_cells_forest
Unpack buf into this realm's seam ghosts of the cross-rank receive rows of peer slot p_idx (maps%seam_mpi_recv_cell), on the active buffer, nv values per row in row order. Default: error_stops; every multi-realm participant MUST override.
fortran
subroutine unpack_seam_cells_forest(self, p_idx, buf)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
p_idx | integer(kind=I4P) | in | Peer slot (the realm that owns the cells). | |
buf | real(kind=R8P) | in | Packed values, nv * rows. |
Call graph
ripple_common_object%after_topology_build_forest
Backend hook invoked by forest%populate_inter_realm_topology AFTER all host-side seam maps have been built. CPU default is a no-op (host maps are the production state). GPU backends override to propagate the freshly-built host seam maps to device-resident copies (e.g. via maps_fnl%copy_cpu_gpu).
fortran
subroutine after_topology_build_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout |
Call graph
ripple_common_object%apply_reflux_to_stage_forest
Apply the Berger-Colella reflux correction to THIS realm's stage-stage buffer for every flux-register face where self is the coarse side.
Invoked by forest_object%evolve_one_step once per realm per stage, AFTER flux_register%reduce_fine_sums has globalised the fine-side accumulators. The realm filters the register's face array by face%coarse_realm == self%realm_index, picks up its OWN integrator- specific stage weight (self%ts%stage_weight(stage)), and writes the correction delta into its OWN stage buffer (the stepper's registers).
Architectural role: this TBP keeps the per-realm reflux write integrator-private. The forest never names a stepper register or a stage weight: those live realm-side (ts), so a realm can change its integrator without touching the orchestrator.
The realm's 1-based forest position is read from self%realm_index, which the forest writes once at initialize-time; no per-call plumbing of is through the dispatch is needed.
Default implementation error-stops: every multi-realm participant that uses FV reflux MUST override this. Multi-realm participants that DO NOT accumulate flux contributions (e.g. an FD-only realm) should override with a no-op body.
fortran
subroutine apply_reflux_to_stage_forest(self, stage, dt, flux_register)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. | |
stage | integer(kind=I4P) | in | Integrator stage 1..K_total. | |
dt | real(kind=R8P) | in | Time step. | |
flux_register | class(flux_register_object) | in | Forest's flux register (read-only). |
Call graph
ripple_common_object%close_block_xh5f
Close XH5F file block.
fortran
subroutine close_block_xh5f(xh5f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
xh5f | type(xh5f_file_object) | inout | XH5F file handler. |
Call graph
ripple_common_object%close_file_xh5f
Close XH5F file.
fortran
subroutine close_file_xh5f(xh5f)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
xh5f | type(xh5f_file_object) | inout | XH5F file handler. |
Call graph
ripple_common_object%open_block_xh5f
Open XH5F file block; length_scale multiplies the written block origin and spacing (output units of an application, e.g. FLUME [reference] output_units). The origin is the corner of the first stored cell: ngc_saved cells below the block's first interior cell, ngc_saved the ghost layers the caller writes (default all, ngc; 0 for the interior only, e.g. the restart snapshot, issue #109).
fortran
subroutine open_block_xh5f(self, xh5f, b, nijk, t, time, length_scale, ngc_saved)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The equation. | |
xh5f | type(xh5f_file_object) | inout | XH5F file handler. | |
b | integer(kind=I4P) | in | Block index. | |
nijk | integer(kind=I8P) | in | Blocks dimensions. | |
t | integer(kind=I4P) | in | optional | Time iteration. |
time | real(kind=R8P) | in | optional | Time. |
length_scale | real(kind=R8P) | in | optional | Scale of the written origin and spacing. |
ngc_saved | integer(kind=I4P) | in | optional | Ghost layers written (default ngc). |
Call graph
ripple_common_object%open_file_xh5f
Open XH5F file.
fortran
subroutine open_file_xh5f(self, basename, xh5f, directory)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The equation. | |
basename | character(len=*) | in | Base name of output files. | |
xh5f | type(xh5f_file_object) | out | XH5F file handler. | |
directory | character(len=*) | in | optional | Directory name of output files. |
Call graph
ripple_common_object%save_q_xh5f
Save ADAM in XH5F format.
fortran
subroutine save_q_xh5f(self, basename, q, q_name, directory, with_ghost, with_cell_morton, t, time)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The equation. | |
basename | character(len=*) | in | Base name of output files. | |
q | real(kind=R8P) | in | Q-vector variables [nv,ni,nj,nk,nb]. | |
q_name | character(len=*) | in | optional | Q-vector variables names [nv]. |
directory | character(len=*) | in | optional | Directory name of output files. |
with_ghost | logical | in | optional | Flag to save ghost cells. |
with_cell_morton | logical | in | optional | Flag to save Morton code also in cells. |
t | integer(kind=I4P) | in | optional | Time iteration. |
time | real(kind=R8P) | in | optional | Time. |
Call graph
ripple_common_object%compute_curl_fd_extended
Compute curl of vector fields, div(q(ivar:ivar+2), using finite difference schemes.
fortran
subroutine compute_curl_fd_extended(self, hs, ivar, q, curl)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The equation. | |
hs | integer(kind=I4P) | in | FDV half stencil length. | |
ivar | integer(kind=I4P) | in | Start index of variable of q. | |
q | real(kind=R8P) | in | Field variables. | |
curl | real(kind=R8P) | inout | Curl. |
Call graph
ripple_common_object%compute_gradient_fd_extended
Compute gradient of scalar variable q(ivar), finite difference schemes.
fortran
subroutine compute_gradient_fd_extended(self, hs, ivar, q, gradient)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The equation. | |
hs | integer(kind=I4P) | in | FDV half stencil length. | |
ivar | integer(kind=I4P) | in | Index of scalar variable of q. | |
q | real(kind=R8P) | in | Field variables. | |
gradient | real(kind=R8P) | inout | Gradient. |
Call graph
Subroutines
initialize_ripple
Initialize the common data: the library objects (realm_object%initialize), periodic faces, [ripple] and [time], the state, the uniform refinement. MPI is up already: the forest initializes it once, before any realm.
fortran
subroutine initialize_ripple(self, filename, memory_avail)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. | |
filename | character(len=*) | in | Input file name. | |
memory_avail | real(kind=R8P) | in | Memory (GB) the blocks budget may use. |
Call graph
check_input
Refuse the inputs RIPPLE cannot honour, at initialization: a library key that the app silently ignored would run a different scheme than the input asks for.
fortran
subroutine check_input(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. |
Call graph
amr_update_initial_forest
The initial regrid: box markers and registered criteria, on the initial profile.
fortran
subroutine amr_update_initial_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
rebalance_initial_forest
No static rebalance: RIPPLE keeps the blocks where the initial regrid put them ([amr].(balance_static) unused).
fortran
subroutine rebalance_initial_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
reset_time_forest
The time and the step counter of a run from scratch to zero.
fortran
subroutine reset_time_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
set_initial_state_forest
The initial profile on the interior cells.
fortran
subroutine set_initial_state_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
set_initial_conditions
Set the initial profile u0 (exact_solution at t = 0) on the interior cells of every block.
fortran
subroutine set_initial_conditions(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
amr_update
Initial AMR, [amr] iters sweeps over the [amr_marker_N] sections: a box (mode 1, primitive-box) refines the blocks whose centroid lies in it until they reach its target_level; a registered criterion (mode 6, issue #110) marks with its own votes (mark with initial = .true.). Other markers are refused by check_input.
fortran
subroutine amr_update(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. |
Call graph
register_amr_criterion
Register a refinement criterion (issue #110): [amr_marker_N] mode = 6, name = <criterion%name> selects it. RIPPLE refines at initialization only, so the criterion must act there (runtime_only = .false.). The realm keeps a pointer: the program owns the instance (a TARGET of the main program, outliving the run).
fortran
subroutine register_amr_criterion(self, criterion)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. | |
criterion | class(amr_criterion_object) | in | pointer | The criterion (a TARGET actual is pointed to). |
Call graph
save_output
Append one row (it, time, total of u dV over the domain) to the history file and, when fields, save the host q in XH5F (one HDF5 file per rank, interior cells, <output_basename>-<it>).
fortran
subroutine save_output(self, fields)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. | |
fields | logical | in | Save the fields too. |
Call graph
advance_time
Count the step and take the forest's dt, capped so that a time-driven run lands on time_max.
fortran
subroutine advance_time(self, dt)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. | |
dt | real(kind=R8P) | in | Time step from the forest. |
Call graph
accumulate_seam_skin
Route one face skin of block b, face fec, weighted by weight, to the forest's flux register.
skin(1, c) is the face flux with c running over the two tangential axes, inner fastest (x faces: j, k; y faces: i, k; z faces: i, j). A positive register index marks the coarse side of a 2:1 face: the skin is the coarse face. A negative one marks a fine block: its skin is restricted (2x2 average, 2x1 on a quadtree) into its quadrant of the coarse face. Weighting every stage by its SSP coefficient makes the register hold sum_s beta_s F_s, the flux of the committed step.
fortran
subroutine accumulate_seam_skin(self, flux_register, b, fec, weight, skin)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. | |
flux_register | class(flux_register_object) | inout | Forest's flux register. | |
b | integer(kind=I4P) | in | Block, face (1..6: -x, +x, -y, +y, -z, +z). | |
fec | integer(kind=I4P) | in | Block, face (1..6: -x, +x, -y, +y, -z, +z). | |
weight | real(kind=R8P) | in | Stage weight. | |
skin | real(kind=R8P) | in | Face skin (1, inner_n*outer_n). |
Call graph
apply_reflux
Berger-Colella reflux on the host q: every coarse seam cell this rank owns receives sgn dt / dx (F_coarse - F_fine), the coarse flux the step used replaced by the restricted fine one, so that the total of u dV is conserved across the 2:1 faces to round-off.
fortran
subroutine apply_reflux(self, flux_register)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | inout | The realm. | |
flux_register | class(flux_register_object) | in | Forest's flux register. |
Call graph
compute_local_dt_forest
Return the local CFL time step, CFL / max_b sum_d |a_d| / dx_d (the forest takes the minimum over the ranks).
fortran
subroutine compute_local_dt_forest(self, dt_local)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. | |
dt_local | real(kind=R8P) | out | Local time step. |
Call graph
is_done_forest
Return true when it_max steps are done or, with it_max <= 0, when time_max is reached.
fortran
subroutine is_done_forest(self, done)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. | |
done | logical | out | True if the realm is done. |
Call graph
Functions
initial_amr_iterations_forest
One initial regrid when there are markers (a registered criterion may mark on the initial state, issue #110).
Returns: integer(kind=I4P)
fortran
function initial_amr_iterations_forest(self) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. |
Call graph
compute_total
Return the total of u dV over the interior cells of this rank's blocks (host q).
Returns: real(kind=R8P)
fortran
function compute_total(self) result(total)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. |
Call graph
stages_per_step_forest
Return the Runge-Kutta stages per step: the staged path (2:1 AMR faces) needs an SSP scheme.
Returns: integer(kind=I4P)
fortran
function stages_per_step_forest(self) result(K)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(ripple_common_object) | in | The realm. |
Call graph
exact_solution
Return the exact solution at point x, time t: the profile u0 = prod_d sin(2 pi (x_d - emin_d) / L_d) over the non-null axes, translated by a t (periodic box).
Attributes: pure
Returns: real(kind=R8P)
fortran
function exact_solution(x, t, a, emin, emax, is_null) result(u)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Point. | |
t | real(kind=R8P) | in | Time. | |
a | real(kind=R8P) | in | Advection velocity. | |
emin | real(kind=R8P) | in | Domain minimum corner. | |
emax | real(kind=R8P) | in | Domain maximum corner. | |
is_null | logical | in | Null axes. |
Call graph