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
- set_initial_conditions
- amr_update
- register_amr_criterion
- save_output
- advance_time
- accumulate_seam_skin
- apply_reflux
- compute_local_dt_forest
- is_done_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. | |
blanesmoan | type(blanesmoan_object) | Blanes-Moan integrator. | |
cfm | type(cfm_object) | Commutator-Free Magnus integrator. | |
leapfrog | type(leapfrog_object) | Leapfrog integrator. | |
flail | type(flail_object) | FLAIL, the elliptic solver library (issue #84). | |
weno | type(weno_object) | WENO reconstructor. | |
ib | type(ib_object) | Immersed boundary. | |
rk | type(rk_object) | Runge-Kutta integrator. | |
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. |
realm_index | integer(kind=I4P) | 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 | |
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. | |
cfl | real(kind=R8P) | CFL number. | |
time | real(kind=R8P) | Current time. | |
time_max | real(kind=R8P) | Final time. | |
dt | real(kind=R8P) | Current time step. | |
it | integer(kind=I4P) | Current iteration. | |
it_max | integer(kind=I4P) | Iterations number; <= 0: run to time_max. | |
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_forest | pass(self) | Invoked by forest%initialize per realm at startup. |
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 |
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. |
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). |
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 initialized by the backend, before.
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
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
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