Appearance
adam_prism_common_object
Source: src/app/prism/common/adam_prism_common_object.F90
Dependencies
Contents
- prism_common_object
- amr_update_initial_forest
- rebalance_initial_forest
- reset_time_forest
- amr_update
- rebalance
- mark_by_geometry
- mark_by_j_vec_total_variation
- allocate_common
- compute_auxiliary_fields
- compute_fields_number
- initialize
- initialize_block_face_data
- initialize_pic_time_zero
- fold_deposited_ghosts
- register_pic_deposition_on_coils
- report_plasma_on_coils
- weight_pic_fields_time_zero
- save_pic_self_force_diagnostic_time_zero
- initialize_single_particle_output
- write_single_particle_output
- load_restart_files
- load_pic_restart_files
- save_divergence_history
- save_grms_history
- save_magnetic_field_at_center_domain_history
- save_probes_history
- sample_probes
- sync_probes
- save_energy_error
- save_energy_history
- save_coils_current_diagnostics
- save_restart_files
- save_pml_restart_files
- load_pml_restart_files
- save_pic_restart_files
- save_xh5f
- save_slices
- initialize_coils
- compute_coils_current_time_zero
- impose_pic_fields_time_zero
- print_source_progress
- set_helicon_coil
- compute_Helicon_coil_amplitude
- cartesian_to_cylindrical
- cylindrical_to_cartesian
- cylindrical_vector_to_cartesian
- write_rectangular_current_tab
- write_helicon_current_tab
- compute_rectangular_current_flux_sides
- compute_helicon_current_flux_segments
- helicon_segment_tangent
- set_rectangular_coil_x
- set_rectangular_coil_y
- set_rectangular_coil_z
- set_circular_coil_x
- set_circular_coil_y
- set_circular_coil_z
- set_solenoid_x
- set_solenoid_y
- set_solenoid_z
- coupling_descriptor_forest
- coil_block_box
- coil_face_ghost_curl
- rectangular_coil_block_extension
- axial_coil_block_extension
- helicon_coil_block_A
- initial_amr_iterations_forest
- has_current_density
- global_max
- helicon_radial_primitive
- helicon_coil_chi_at_point
- wrap_to_pi
- compute_signed_area
- compute_windings_number
- rectangular_coil_A_at_point
- erf_function
- tangential_window
- erf_primitive_function
- coil_ext_coord
- rectangular_block_active
- helicon_block_active
- axial_coil_A_at_point
- crossproduct
Variables
| Name | Type | Attributes | Description |
|---|---|---|---|
COIL_SATURATION_SIGMAS | real(kind=R8P) | parameter | Beyond this many sigma from its centre every coil erf is +-1 in double precision (erf(x/(sqrt(2) sigma)) = +-1 for |x| > 8.4 sigma). |
Derived Types
prism_common_object
Maxwell equations system class definition, common data to all backends.
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. |
save_em_only | logical | [IO] save_fields = em: the XH5F output holds D and B only. | |
amr_locked_ | logical | AMR regrid lock (issue #22 GA6): set .true. by backends whose device/topology state cannot follow a regrid after initialization (FNL sets it at the end of initialize_forest); amr_update error_stops when locked. CPU never sets it. | |
blocks_fields_number | integer(kind=I4P) | Block-sized fields per block of the blocks budget (issue #112). | |
reserved_memory | real(kind=R8P) | Memory reserved outside the blocks by the budget, GB (issue #112). | |
restarted_at | integer(kind=I4P) | Iteration the run restarted from (-1: not a restart), issue #129 R6. | |
estimate_backend_memory | procedure(estimate_backend_memory_interface) | pointer, nopass | Backend memory outside the block fields, estimated before the blocks budget (issue #112); set by the backend before initialize, none when null (CPU). |
nv_c | integer(kind=I4P) | pointer | Number of conservative variables in q vector. |
nv_s | integer(kind=I4P) | pointer | Number of source variables in q vector. |
nv_cl | integer(kind=I4P) | pointer | Number of divergence cleaning variables in q vector. |
q | real(kind=R8P) | allocatable | Conservative cell centered variables. |
dq | real(kind=R8P) | allocatable | Residuals right hand side. |
q_pic | real(kind=R8P) | allocatable | PIC variables. |
pic_fields | real(kind=R8P) | allocatable | Fields value at particle locations. |
curl | real(kind=R8P) | allocatable | Curl fields. |
divergence | real(kind=R8P) | allocatable | Divergence fields. |
q_name | type(string) | allocatable | Fields names [1:nv]. |
dq_name | type(string) | allocatable | Residuals names [1:nv]. |
q_pic_name | type(string) | allocatable | PIC Fields names. |
curl_name | type(string) | allocatable | Curl fields names. |
div_name | type(string) | allocatable | Divergence fields names. |
energy_D | real(kind=R8P) | allocatable | Energy of field D, time history. |
energy_B | real(kind=R8P) | allocatable | Energy of field B, time history. |
coil_power | real(kind=R8P) | allocatable | Power of coils, time history. |
Poynting_flux | real(kind=R8P) | allocatable | Total Poynting flux from boundary, time history. |
rms_energy_error_D | real(kind=R8P) | RMS energy error of D field. | |
rms_energy_error_B | real(kind=R8P) | RMS energy error of B field. | |
max_divergence_D | real(kind=R8P) | Maximum of divergence of D field. | |
max_divergence_B | real(kind=R8P) | Maximum of divergence of B field. | |
max_divergence_J | real(kind=R8P) | Maximum of divergence of J field. | |
single_particle_output_last_time | real(kind=R8P) | Last time written to single-particle history. | |
single_particle_output_written | logical | Single-particle history write sentinel. | |
bc | type(prism_bc_object) | Boundary conditions. | |
coil | type(prism_coil_object) | Coil source term. | |
external_fields | type(prism_external_fields_object) | External fields. | |
fWLayer | type(prism_fWLayer_object) | Far-field weighted layer. | |
grms | type(prism_grms_object) | Grms diagnostic. | |
ic | type(prism_ic_object) | Initial conditions. | |
io_prism | type(prism_io_object) | The [IO] options only PRISM reads. | |
magnetic_field_at_center_domain | type(prism_magnetic_field_at_center_domain_object) | Domain-center B diagnostic. | |
numerics | type(prism_numerics_object) | Numerics configuration. | |
particle_injection | type(prism_particle_injection_object) | Particle injection. | |
physics | type(prism_physics_object) | Physics configuration. | |
pic | type(prism_pic_object) | PIC state. | |
plasma_freq | type(prism_plasma_frequencies_object) | Plasma frequencies and the PIC time-step limit. | |
pml | type(prism_pml_object) | Perfectly matched layer. | |
probes | type(prism_probes_object) | Field probes. | |
pic_st | type(stepper) | Particles: a SELAH companion (#134 D5). | |
pml_st | type(prism_pml_stepper_object) | PML auxiliary fields: SELAH companions (#134 D5). | |
time | type(prism_time_object) | Time integration state. |
Type-Bound Procedures
| Name | Attributes | Description |
|---|---|---|
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. |
set_initial_state_forest | pass(self) | Template hook: the initial condition, from scratch. |
post_initial_state_forest | pass(self) | Template hook: everything after the initial state. |
compute_local_dt_forest | pass(self) | Invoked by forest%compute_global_dt during the min reduction. |
advance_one_step_forest | pass(self) | Invoked by forest%evolve_one_step per realm per timestep. |
stages_per_step_forest | pass(self) | Number of integrator stages this realm exposes per step. |
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). |
is_done_forest | pass(self) | Invoked by forest%is_done during the termination reduction. |
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 |
amr_update | pass(self) | Do AMR update (init-time only where amr_locked_). |
amr_update_initial_forest | pass(self) | Template hook: one initial regrid (host). |
initial_amr_iterations_forest | pass(self) | Template hook: [initial_conditions] AMR passes. |
rebalance_initial_forest | pass(self) | Template hook: the static rebalance (issue #123). |
reset_time_forest | pass(self) | Template hook: time and step counter to zero. |
rebalance | pass(self) | Balance the static grid's blocks by count (issue #123). |
mark_by_geometry | pass(self) | Mark blocks to be refined by a primitive geometric box. |
mark_by_j_vec_total_variation | pass(self) | Mark by j_vec total variation (backend override; common default error_stops — the marker needs backend ghost/coil machinery that only the CPU override provides today). |
allocate_common | pass(self) | Allocate common data. |
compute_auxiliary_fields | pass(self) | Compute auxiliary fields. |
compute_fields_number | pass(self) | Compute the block-sized fields allocated per block. |
initialize | pass(self) | Initialize the equation common data. |
initialize_block_face_data | pass(self) | (Re)build the per-block face data on the current grid. |
fold_deposited_ghosts | pass(self) | Fold PIC deposits spilled into ghosts, locally and across ranks. |
initialize_pic_time_zero | pass(self) | Host-side PIC particle injection plus charge/current deposition at t=0. |
register_pic_deposition_on_coils | pass(self) | Keep the plasma current a PIC deposit put on coil cells. |
report_plasma_on_coils | pass(self) | Repeat at the end of the run the warning of plasma on coil cells. |
weight_pic_fields_time_zero | pass(self) | Host-side PIC field interpolation at t=0. |
save_pic_self_force_diagnostic_time_zero | pass(self) | Temporary PIC self-force diagnostic at t=0. |
load_restart_files | pass(self) | Load restart files. |
save_energy_error | pass(self) | Save energy error history. |
save_energy_history | pass(self) | Save energy history. |
save_coils_current_diagnostics | pass(self) | Save instantaneous coil-current diagnostics. |
save_divergence_history | pass(self) | Save divergence history. |
save_grms_history | pass(self) | Save Grms history. |
save_magnetic_field_at_center_domain_history | pass(self) | Save domain-center B history. |
save_probes_history | pass(self) | Save the field probes history on its cadence. |
sample_probes | pass(self) | Sample the fields at the probes (backend override). |
sync_probes | pass(self) | Sync the probe stencils with the backend (backend override). |
save_restart_files | pass(self) | Save restart files. |
save_slices | pass(self) | Save the slices on their cadence. |
save_xh5f | pass(self) | Save simulation data in XH5F format. |
initialize_coils | pass(self) | Initialize coils. |
compute_coils_current_time_zero | pass(self) | Host-side coil current initialization at t=0. |
impose_pic_fields_time_zero | pass(self) | Host-side elliptic initialization for PIC/current-driven fields. |
has_current_density | pass(self) | True if the current density is non-zero on any rank. |
set_rectangular_coil_x | pass(self) | Subroutine to set a rectangular coil source with +-x normal |
set_rectangular_coil_y | pass(self) | Subroutine to set a rectangular coil source with +-y normal |
set_rectangular_coil_z | pass(self) | Subroutine to set a rectangular coil source with +-z normal |
set_circular_coil_x | pass(self) | Subroutine to set a circular coil source with +-x normal |
set_circular_coil_y | pass(self) | Subroutine to set a circular coil source with +-y normal |
set_circular_coil_z | pass(self) | Subroutine to set a circular coil source with +-z normal |
set_solenoid_x | pass(self) | Subroutine to set a solenoid source with +-x normal |
set_solenoid_y | pass(self) | Subroutine to set a solenoid source with +-y normal |
set_solenoid_z | pass(self) | Subroutine to set a solenoid source with +-z normal |
set_helicon_coil | pass(self) | Subroutine to set a helicon coil source. |
compute_rectangular_current_flux_sides | pass(self) | Precompute rectangular side-current fluxes. |
compute_helicon_current_flux_segments | pass(self) | Precompute helicon segment-current fluxes. |
coupling_descriptor_forest | pass(self) | Report (scheme_time, rk_scheme, nv) for β admissibility. |
prism_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
prism_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
prism_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
prism_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
prism_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
prism_common_object%set_initial_state_forest
Template hook: the initial condition on the current grid (and what derives from it). Default error-stops.
fortran
subroutine set_initial_state_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | inout | The realm. |
Call graph
prism_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
prism_common_object%compute_local_dt_forest
Compute this realm's local stability-limited dt (no MPI reduction).
Invoked by forest%compute_global_dt during the min reduction across all realms in the forest. The reduction itself is the orchestrator's job; this method computes only the value local to self.
Default implementation error-stops: every consumer app MUST override this method (the CFL criterion and umax are app-specific). PRISM's override lives on prism_cpu_object/prism_fnl_object.
fortran
subroutine compute_local_dt_forest(self, dt_local)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. | |
dt_local | real(kind=R8P) | out | Local stability-limited dt. |
Call graph
prism_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
prism_common_object%stages_per_step_forest
Return the number of integrator stages this realm exposes per step.
Integrator-agnostic: K is the number of inter-realm seam-coherence boundaries the realm wants visible to the forest: K = ts%stages() for the SSP schemes the staged path admits (FLUME and PRISM refuse the others here). A realm that does all its work atomically and needs one peer-sync per step would report K = 1.
Invoked by forest%evolve_one_step on the multi-realm path to size the stage loop. Under α (end-of-step seam coupling) realms may report different K values: the orchestrator iterates k = 1..max(K_realm) and gates each per-stage TBP on k <= K_realm(is). Under β (stage-coincident) admissibility requires equal K on both endpoints of every β seam (enforced at init).
Default implementation error-stops: every realm that participates in a multi-realm forest MUST override this. Apps that only ever run as N=1 may leave it (the N=1 fast path doesn't call this).
Returns: integer(kind=I4P)
fortran
function stages_per_step_forest(self) result(K)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. |
Call graph
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_common_object%is_done_forest
Decide whether this realm's local termination criterion is met.
Invoked by forest%is_done during the termination reduction across all realms in the forest. The reduction itself (typically a logical AND or OR depending on coupling semantics) is the orchestrator's job; this method computes only the predicate local to self.
Default implementation error-stops: every consumer app MUST override this method (the termination criterion mixes iteration count, simulated time, and app-specific physics signals). PRISM's override lives on prism_cpu_object/prism_fnl_object.
fortran
subroutine is_done_forest(self, done)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(realm_object) | in | The realm. | |
done | logical | out | True if this realm is done evolving. |
Call graph
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
prism_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
amr_update_initial_forest
One initial regrid on the host (the FNL override of amr_update follows it with the device PML twins).
fortran
subroutine amr_update_initial_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
rebalance_initial_forest
PRISM regrids at initialization only: balance the blocks by count, sibling sets split (issue #123).
fortran
subroutine rebalance_initial_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
reset_time_forest
The time and the step counter of a run from scratch to zero (dt is kept: the conserving PIC t0 path set it).
fortran
subroutine reset_time_forest(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
amr_update
Do AMR update.
fortran
subroutine amr_update(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
rebalance
Balance the blocks over the ranks by count, complete sibling sets split (issue #123), after the initial AMR. PRISM regrids at initialization only (amr_locked_), so its grid is never derefined afterwards. The per-block data are rebuilt as amr_update rebuilds them after a grid change; the caller imposes the initial conditions (and the device copies) after it.
fortran
subroutine rebalance(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
mark_by_geometry
Mark blocks to be refined by a primitive axis-aligned box (deterministic, solution-independent).
A block is flagged TO_BE_REFINED iff its centroid lies inside [box_emin, box_emax] AND its current refinement level is below target_level. This is the AMR_GEO + AMR_GEO_PRIMITIVE_BOX marker: it produces a deterministic 2:1 coarse-fine jump at known coordinates, decoupled from the IB/solid geometry, for the issue #13 intra-realm AMR seam test fixture (#13 §7.5, M0).
fortran
subroutine mark_by_geometry(self, box_emin, box_emax, target_level, do_init)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
box_emin | real(kind=R8P) | in | Box minimum corner. | |
box_emax | real(kind=R8P) | in | Box maximum corner. | |
target_level | integer(kind=I4P) | in | Refine blocks below this level. | |
do_init | logical | in | optional | Re-initialize refinements queries. |
Call graph
mark_by_j_vec_total_variation
Mark blocks by j_vec total variation — common DEFAULT: unavailable. The real marker needs backend-specific ghost updates and coil initialization; prism_cpu_object overrides this with the working host implementation. Backends without an override stop loudly instead of marking from stale data (issue #22 F0).
fortran
subroutine mark_by_j_vec_total_variation(self, tv_tol, delta_type, delta_fine, delta_coarse, threshold, do_init)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
tv_tol | real(kind=R8P) | in | Total variation tolerance value. | |
delta_type | character(len=*) | in | Delta criterion type. | |
delta_fine | real(kind=R8P) | in | Maximum cell delta in fine grids. | |
delta_coarse | real(kind=R8P) | in | Minimum cell delta in coarse grids. | |
threshold | real(kind=R8P) | in | optional | Threshold for sphere proximity. |
do_init | logical | in | optional | Re-initialize refinements queries. |
Call graph
allocate_common
Allocate common data.
fortran
subroutine allocate_common(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
compute_auxiliary_fields
Compute auxiliary fields.
fortran
subroutine compute_auxiliary_fields(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
compute_fields_number
Compute the block-sized fields PRISM allocates per block, the fields_number of the blocks budget.
Both backends allocate the same nb-sized arrays, on the host (CPU) or on the device (FNL), so one count serves both: q, dq, curl, divergence (4 nv), the time integrator's registers (SELAH's, stepper_stored_fields nv: the stage states and residuals, the residual register included, #132), the coils current density (3 per coil), the two PIC charge-continuity accumulators (only with a charge-conservation history), and the flux arrays of the scheme in use: the cell fluxes flxyz_c (9 nv) for FV and WENO, the face fluxes (3 nv, counted as full block fields) for FV only, none for centered FD (issue #112). Backend-only arrays are added by the backend estimate of initialize; face-local PML storage is not block-sized and is not counted. The FNL estimate also takes curl and divergence off the count: there they are host arrays only, recomputed from q at the saves (issue #112 C). Requires physics and numerics initialized and [runge_kutta] parsed into rk; loads the coils number (it needs no grid or field).
fortran
subroutine compute_fields_number(self, file_parameters, fields_number)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
file_parameters | type(file_ini) | in | Simulation parameters ini file handler. | |
fields_number | integer(kind=I4P) | out | Block-sized fields allocated per block. |
Call graph
initialize
Initialize the equation common data.
fortran
subroutine initialize(self, filename, memory_avail, nv, fields_number, verbose, L0)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | target | The equation. |
filename | character(len=*) | in | Input 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 per block (default: computed). |
verbose | logical | in | optional | Trigger verbose output. |
L0 | real(kind=R8P) | in | optional | Adimensionalization parameter. |
Call graph
initialize_block_face_data
(Re)build the per-block face data on the current grid: the PEC faces of the external fields, the fWLayer ranges and the PML support with its RK storage. All are indexed by local block, so they must follow every change of the block set: the uniform refinement in initialize, each init-time amr_update, a restart (issue #95, P5.1). Every initializer called here resets its object first; the PML auxiliary state restarts from zero, as at any initialization.
fortran
subroutine initialize_block_face_data(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
initialize_pic_time_zero
Initialize PIC particles and deposit host-side charge/current sources at t=0.
fortran
subroutine initialize_pic_time_zero(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
fold_deposited_ghosts
Fold the PIC deposits that spilled into ghost cells back onto the cells they mirror, on this rank and across ranks, then refill the ghosts: the result equals a single-block deposit of the same particles. With one rank this is reduce_ghost_local alone. Collective.
fortran
subroutine fold_deposited_ghosts(self, q, v_first, v_last)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
q | real(kind=R8P) | inout | Field variables. | |
v_first | integer(kind=I4P) | in | First variable to fold. | |
v_last | integer(kind=I4P) | in | Last variable to fold. |
Call graph
register_pic_deposition_on_coils
Right after a PIC deposit into q: plasma current or charge on the coil support is no longer an error. The current is kept (committed or stage slot) and summed with the coil current by every later coil stamp of that state; the first occurrence is warned and repeated at the end of the run (report_plasma_on_coils). Collective (with coils): the overlap is reduced over the ranks and, when found, the ghosts of q are refreshed before the support (ghost cells included) is kept, so a ghost copy of a support cell carries its plasma current too. Without overlap q is untouched.
fortran
subroutine register_pic_deposition_on_coils(self, q, stage, check_current, check_charge, context)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
q | real(kind=R8P) | inout | Deposited field. | |
stage | logical | in | q is a stage state (else the committed one). | |
check_current | logical | in | optional | The J rows hold a fresh deposit. |
check_charge | logical | in | optional | The charge row holds a fresh deposit. |
context | character(len=*) | in | optional | Call-site label. |
Call graph
report_plasma_on_coils
End of the run: repeat the warning of plasma deposited on coil cells, with the first iteration (and its call site) and the last one over all the ranks. Collective.
fortran
subroutine report_plasma_on_coils(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in | The equation. |
Call graph
weight_pic_fields_time_zero
Interpolate initialized fields at particle positions at t=0.
fortran
subroutine weight_pic_fields_time_zero(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_pic_self_force_diagnostic_time_zero
Temporary diagnostic for single-particle PIC self-force analysis.
fortran
subroutine save_pic_self_force_diagnostic_time_zero(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in |
Call graph
initialize_single_particle_output
Reset the single-particle output file before a fresh run from t = 0 (rank 0 writes it).
fortran
subroutine initialize_single_particle_output(filename)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
filename | character(len=*) | in |
Call graph
write_single_particle_output
Append the single-particle trajectory/state sample. The particle lives on one rank (the owner of its block): the sample is reduced over the ranks and rank 0 writes it. Collective.
fortran
subroutine write_single_particle_output(filename, time, q_pic, pic_fields, particle_number)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
filename | character(len=*) | in | ||
time | real(kind=R8P) | in | ||
q_pic | real(kind=R8P) | in | ||
pic_fields | real(kind=R8P) | in | ||
particle_number | integer(kind=I4P) | in | Particles owned by this rank. |
Call graph
load_restart_files
Save restart files.
fortran
subroutine load_restart_files(self, t, time)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
t | integer(kind=I4P) | out | Time iteration. | |
time | real(kind=R8P) | out | Time. |
Call graph
load_pic_restart_files
Load PIC restart data stored outside the ADAM field restart.
fortran
subroutine load_pic_restart_files(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_divergence_history
Save divergence history.
fortran
subroutine save_divergence_history(self, is_to_open, is_to_close, div_D, div_B, div_J, current_solver_residual)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open file before first saving. |
is_to_close | logical | in | optional | Flag to close file after last saving. |
div_D | real(kind=R8P) | in | Maximum of divergence of D field. | |
div_B | real(kind=R8P) | in | Maximum of divergence of B | |
div_J | real(kind=R8P) | in | Maximum of divergence of J field. | |
current_solver_residual | real(kind=R8P) | in | optional | Maximum current linear-solve residual. |
Call graph
save_grms_history
Save Grms history.
fortran
subroutine save_grms_history(self, is_to_open, is_to_close)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open file before first saving. |
is_to_close | logical | in | optional | Flag to close file after last saving. |
Call graph
save_magnetic_field_at_center_domain_history
Save domain-center magnetic-field history.
fortran
subroutine save_magnetic_field_at_center_domain_history(self, is_to_open, is_to_close)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open file before first saving. |
is_to_close | logical | in | optional | Flag to close file after last saving. |
Call graph
save_probes_history
Save the field probes history on its cadence ([probes] save_every and the last step); collective.
With is_to_open the stencils are built on the current grid, synced with the backend and the files opened. The probes sample q as stored: the external fields, if any, are not added.
fortran
subroutine save_probes_history(self, is_to_open)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open the files before the first saving. |
Call graph
sample_probes
Sample the fields at the probes: local sums of the host q (CPU); a device backend overrides it.
fortran
subroutine sample_probes(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
sync_probes
Sync the probe stencils with the backend after they are built: nothing on the host; a device backend overrides it.
fortran
subroutine sync_probes(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_energy_error
Save energy error history.
fortran
subroutine save_energy_error(self, is_to_open, is_to_close)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open file before first saving. |
is_to_close | logical | in | optional | Flag to close file after last saving. |
Call graph
save_energy_history
Save energy history.
fortran
subroutine save_energy_history(self, is_to_open, is_to_close)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
is_to_open | logical | in | optional | Flag to open file before first saving. |
is_to_close | logical | in | optional | Flag to close file after last saving. |
Call graph
save_coils_current_diagnostics
Save instantaneous coil-current diagnostics.
fortran
subroutine save_coils_current_diagnostics(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_restart_files
Save restart files.
fortran
subroutine save_restart_files(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_pml_restart_files
Save the PML auxiliary state (issue #129, R3): one file per rank, for each of the six faces the shape of its compact array (zeros if the face has no layer on this rank) and its values. The host arrays must be current (the FNL backend copies its device state back first).
fortran
subroutine save_pml_restart_files(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in | The equation. |
Call graph
load_pml_restart_files
Load the PML auxiliary state into the face arrays just rebuilt on the restored blocks (issue #129, R3): the shapes must be those of the file (same ranks, same blocks). A restart written before has no file: the layer then restarts from zero, with a warning (the run departs from the uninterrupted one while a wave is in the layer).
fortran
subroutine load_pml_restart_files(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
save_pic_restart_files
Save PIC restart data stored outside the ADAM field restart.
fortran
subroutine save_pic_restart_files(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in | The equation. |
Call graph
save_xh5f
Save simulation data in HDF5 format.
fortran
subroutine save_xh5f(self, output_basename, with_ghost)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
output_basename | character(len=*) | in | optional | Output basename. |
with_ghost | logical | in | optional | Flag to save ghost cells. |
Call graph
save_slices
Save the slices (library slices_object, [slices] / [slice_N]) on their cadence, one file per field set: <basename>-slice_NN-<it>.mat holds q (the total field when external fields are applied, as the XH5F output), <basename>-curl-slice_NN-<it>.mat and <basename>-div-slice_NN-<it>.mat the curl and divergence fields when their XH5F output is enabled ([IO] save_curl_fields, save_divergence_fields). The caller has refreshed the ghost cells of the host q and computed the auxiliary fields. These are computed on the interior cells only, so their intra-realm ghost cells are refreshed here: the stencil of a point in the half cell next to a block face reads them. Their physical-boundary ghost cells are not set: a point in the half cell next to the domain boundary interpolates with them.
fortran
subroutine save_slices(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
initialize_coils
Initialize coils.
fortran
subroutine initialize_coils(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
compute_coils_current_time_zero
Compute coils current sources on the host at time t=0.
fortran
subroutine compute_coils_current_time_zero(self)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. |
Call graph
impose_pic_fields_time_zero
Compute initial condition for the fields in presence of plasma or current sources.
The electric field (PIC): D(G) phi = -rho/eps, then D <- D - eps G phi. The magnetic field: D(G) A_d = -mu J_d per component, then B <- B + curl A. D(G) is PRISM's own operator, the order-p centred derivative composed with itself (fdv_order), so the corrected field satisfies div D = rho to round-off with PRISM's divergence (issue #84, E3a). The solves run by FLAIL's FFT solver (E3b); an exact/open face holds the free-space potential of the source in its ghosts, summed over the whole domain (E3c). A refined grid is refused: the wide operator across 2:1 faces is not defined yet (E7).
The correction is written in the interior cells only: the caller refreshes the ghosts of the corrected field (exchange and boundary conditions, refresh_time_zero_ghosts of each backend), as every stage does before reading them. The former extension of the gradient/curl into the first ngc/2 ghost layers read the potential ngc/2 + hs layers deep, which tied ngc to 2 hs (issue #112, the ghost cells of FD6) for values every stage overwrites.
fortran
subroutine impose_pic_fields_time_zero(self, ivar)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
ivar | integer(kind=I4P) | in | Variable (start) index in q. |
Call graph
print_source_progress
fortran
subroutine print_source_progress(label, progress_done, progress_total, last_percent)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
label | character(len=*) | in | ||
progress_done | integer(kind=I4P) | in | ||
progress_total | integer(kind=I4P) | in | ||
last_percent | integer(kind=I4P) | inout |
Call graph
set_helicon_coil
Set helicon coil.
fortran
subroutine set_helicon_coil(self, n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. |
Call graph
compute_Helicon_coil_amplitude
Compute amplitude correction for helicon coil
fortran
subroutine compute_Helicon_coil_amplitude(I_target, radius, sigma, n, amplitude)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
I_target | real(kind=R8P) | in | ||
radius | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in | ||
n | integer(kind=I4P) | in | ||
amplitude | real(kind=R8P) | out |
Call graph
cartesian_to_cylindrical
Convert cartesian coordinates to cylindrical coordinates with respect to the coil center and normal direction.
Attributes: pure
fortran
subroutine cartesian_to_cylindrical(x, y, z, x_c, y_c, z_c, normal, r, theta, axial)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
x | real(kind=R8P) | in | Cartesian coordinates. | |
y | real(kind=R8P) | in | Cartesian coordinates. | |
z | real(kind=R8P) | in | Cartesian coordinates. | |
x_c | real(kind=R8P) | in | Coil center coordinates. | |
y_c | real(kind=R8P) | in | Coil center coordinates. | |
z_c | real(kind=R8P) | in | Coil center coordinates. | |
normal | character(len=2) | in | Normal direction. | |
r | real(kind=R8P) | out | Cylindrical coordinates. | |
theta | real(kind=R8P) | out | Cylindrical coordinates. | |
axial | real(kind=R8P) | out | Cylindrical coordinates. |
Call graph
cylindrical_to_cartesian
Convert cylindrical coordinates to cartesian coordinates with respect to the coil center and normal direction.
Attributes: pure
fortran
subroutine cylindrical_to_cartesian(r, theta, axial, x_c, y_c, z_c, normal, x, y, z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
r | real(kind=R8P) | in | ||
theta | real(kind=R8P) | in | ||
axial | real(kind=R8P) | in | ||
x_c | real(kind=R8P) | in | ||
y_c | real(kind=R8P) | in | ||
z_c | real(kind=R8P) | in | ||
normal | character(len=2) | in | ||
x | real(kind=R8P) | out | ||
y | real(kind=R8P) | out | ||
z | real(kind=R8P) | out |
Call graph
cylindrical_vector_to_cartesian
Convert cylindrical vector A components to cartesian vector components.
Attributes: pure
fortran
subroutine cylindrical_vector_to_cartesian(A_r, A_theta, A_axial, theta, normal, A_x, A_y, A_z)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
A_r | real(kind=R8P) | in | ||
A_theta | real(kind=R8P) | in | ||
A_axial | real(kind=R8P) | in | ||
theta | real(kind=R8P) | in | ||
normal | character(len=2) | in | ||
A_x | real(kind=R8P) | out | ||
A_y | real(kind=R8P) | out | ||
A_z | real(kind=R8P) | out |
write_rectangular_current_tab
Append numerical per-side rectangular current measured from the analytic J_vec support.
fortran
subroutine write_rectangular_current_tab(self, filename, coil_id, current_density, time)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
filename | character(len=*) | in | Output file name. | |
coil_id | integer(kind=I4P) | in | Coil index. | |
current_density | real(kind=R8P) | in | Current density coefficient. | |
time | real(kind=R8P) | in | Current time. |
Call graph
write_helicon_current_tab
Append numerical per-segment helicon current measured from the analytic J_vec support.
fortran
subroutine write_helicon_current_tab(self, filename, coil_id, current_density, time)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
filename | character(len=*) | in | Output file name. | |
coil_id | integer(kind=I4P) | in | Coil index. | |
current_density | real(kind=R8P) | in | Current density coefficient. | |
time | real(kind=R8P) | in | Current time. |
Call graph
compute_rectangular_current_flux_sides
Numerically measure the current crossing each local side-normal section of a rectangular coil.
fortran
subroutine compute_rectangular_current_flux_sides(self, coil_id, i_dir_n, i_dir_a, i_dir_b, a1, a2, b1, b2, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
coil_id | integer(kind=I4P) | in | Coil index. | |
i_dir_n | integer(kind=I4P) | in | Coil-normal direction. | |
i_dir_a | integer(kind=I4P) | in | First in-plane direction. | |
i_dir_b | integer(kind=I4P) | in | Second in-plane direction. | |
a1 | real(kind=R8P) | in | Bounds along the local a direction. | |
a2 | real(kind=R8P) | in | Bounds along the local a direction. | |
b1 | real(kind=R8P) | in | Bounds along the local b direction. | |
b2 | real(kind=R8P) | in | Bounds along the local b direction. | |
verse | real(kind=R8P) | in | Coil orientation sign. |
Call graph
compute_helicon_current_flux_segments
Numerically measure the current crossing each local segment-normal section.
fortran
subroutine compute_helicon_current_flux_segments(self, coil_id)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | The equation. | |
coil_id | integer(kind=I4P) | in | Coil index. |
Call graph
helicon_segment_tangent
Build the local 3D unit tangent of a helicon segment from its unrolled-cylinder tangent.
Attributes: pure
fortran
subroutine helicon_segment_tangent(normal, theta, ds, da, length, t_hat)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
normal | character(len=2) | in | Coil normal. | |
theta | real(kind=R8P) | in | Segment midpoint angle. | |
ds | real(kind=R8P) | in | Unrolled segment increments. | |
da | real(kind=R8P) | in | Unrolled segment increments. | |
length | real(kind=R8P) | in | Segment length. | |
t_hat | real(kind=R8P) | out | Cartesian tangent. |
Call graph
set_rectangular_coil_x
Set rectangular coil with normal direction parallel to x.
fortran
subroutine set_rectangular_coil_x(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+x, -1=-x. |
Call graph
set_rectangular_coil_y
Set rectangular coil with normal direction parallel to y.
fortran
subroutine set_rectangular_coil_y(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+y, -1=-y. |
Call graph
set_rectangular_coil_z
Set rectangular coil with normal direction parallel to z.
fortran
subroutine set_rectangular_coil_z(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+z, -1=-z. |
Call graph
set_circular_coil_x
Set circular coil with normal direction parallel to x.
fortran
subroutine set_circular_coil_x(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+x, -1=-x. |
Call graph
set_circular_coil_y
Set circular coil with normal direction parallel to y.
fortran
subroutine set_circular_coil_y(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+y, -1=-y. |
Call graph
set_circular_coil_z
Set circular coil with normal direction parallel to z.
fortran
subroutine set_circular_coil_z(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Coil normal direction, +1=+z, -1=-z. |
Call graph
set_solenoid_x
Set solenoid with axis direction parallel to x.
fortran
subroutine set_solenoid_x(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Solenoid axis direction, +1=+x, -1=-x. |
Call graph
set_solenoid_y
Set solenoid with axis direction parallel to y.
fortran
subroutine set_solenoid_y(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Solenoid axis direction, +1=+y, -1=-y. |
Call graph
set_solenoid_z
Set solenoid with axis direction parallel to z.
fortran
subroutine set_solenoid_z(self, n, verse)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | inout | Cpu object. | |
n | integer(kind=I4P) | in | Coil number. | |
verse | real(kind=R8P) | in | Solenoid axis direction, +1=+z, -1=-z. |
Call graph
coupling_descriptor_forest
Report this realm's coupling descriptor for β admissibility.
Returns (numerics%scheme_time, rk%scheme, physics%nv). β admits a seam between two realms iff all three values agree. Spatial operator (numerics%scheme_space) is intentionally NOT in the descriptor — β exists precisely to support different spatial operators per realm.
Provided on prism_common_object so both prism_cpu_object and prism_fnl_object inherit a single implementation.
fortran
subroutine coupling_descriptor_forest(self, scheme_time, rk_scheme, nv)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_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
coil_block_box
Box of the cell centres whose coil potential reaches the source of a block: the block with its ghost cells, widened by reach cells (the curl stencil, plus the radial gradient for a helicon).
Attributes: pure
fortran
subroutine coil_block_box(ngc, ni, nj, nk, x_cell, y_cell, z_cell, dxyz, reach, lo, hi)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ngc | integer(kind=I4P) | in | Ghost cells. | |
ni | integer(kind=I4P) | in | Interior cells. | |
nj | integer(kind=I4P) | in | Interior cells. | |
nk | integer(kind=I4P) | in | Interior cells. | |
x_cell | real(kind=R8P) | in | Cell centres along x. | |
y_cell | real(kind=R8P) | in | Cell centres along y. | |
z_cell | real(kind=R8P) | in | Cell centres along z. | |
dxyz | real(kind=R8P) | in | Space steps. | |
reach | integer(kind=I4P) | in | Cells beyond the ghosts. | |
lo | real(kind=R8P) | out | Lower corner. | |
hi | real(kind=R8P) | out | Upper corner. |
Call graph
coil_face_ghost_curl
Centred curl of a coil potential on the face ghost cells of one block (compute_curl covers the interior; edge and corner ghosts are left as they are), read from the block potential extended along the face normals.
fortran
subroutine coil_face_ghost_curl(fdv_scheme, hs, ngc, ni, nj, nk, dxyz, Ae, Jb)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
fdv_scheme | character(len=*) | in | FD or FV. | |
hs | integer(kind=I4P) | in | Half stencil. | |
ngc | integer(kind=I4P) | in | Ghost cells. | |
ni | integer(kind=I4P) | in | Interior cells. | |
nj | integer(kind=I4P) | in | Interior cells. | |
nk | integer(kind=I4P) | in | Interior cells. | |
dxyz | real(kind=R8P) | in | Space steps. | |
Ae | real(kind=R8P) | in | Extended potential. | |
Jb | real(kind=R8P) | inout | Source of the block. |
Call graph
rectangular_coil_block_extension
Rectangular coil potential of one block extended hs cells beyond its ghosts along each axis, the points the curls of the face ghosts read: the block values copied, the extension evaluated.
fortran
subroutine rectangular_coil_block_extension(hs, ngc, ni, nj, nk, x_cell, y_cell, z_cell, dxyz, A, xc, idir_n, idir_a, idir_b, a1, a2, b1, b2, sigma, Ae)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
hs | integer(kind=I4P) | in | Half stencil. | |
ngc | integer(kind=I4P) | in | Ghost cells. | |
ni | integer(kind=I4P) | in | Interior cells. | |
nj | integer(kind=I4P) | in | Interior cells. | |
nk | integer(kind=I4P) | in | Interior cells. | |
x_cell | real(kind=R8P) | in | Cell centres along x. | |
y_cell | real(kind=R8P) | in | Cell centres along y. | |
z_cell | real(kind=R8P) | in | Cell centres along z. | |
dxyz | real(kind=R8P) | in | Space steps. | |
A | real(kind=R8P) | in | Potential of the block. | |
xc | real(kind=R8P) | in | Coil centre. | |
idir_n | integer(kind=I4P) | in | Normal and tangential directions. | |
idir_a | integer(kind=I4P) | in | Normal and tangential directions. | |
idir_b | integer(kind=I4P) | in | Normal and tangential directions. | |
a1 | real(kind=R8P) | in | Sides along the tangential directions. | |
a2 | real(kind=R8P) | in | Sides along the tangential directions. | |
b1 | real(kind=R8P) | in | Sides along the tangential directions. | |
b2 | real(kind=R8P) | in | Sides along the tangential directions. | |
sigma | real(kind=R8P) | in | Smearing. | |
Ae | real(kind=R8P) | out | Extended potential. |
Call graph
axial_coil_block_extension
Circular coil (h = sigma) or solenoid (h = half length) potential of one block extended hs cells beyond its ghosts along each axis, the points the curls of the face ghosts read: the block values copied, the extension evaluated.
fortran
subroutine axial_coil_block_extension(hs, ngc, ni, nj, nk, x_cell, y_cell, z_cell, dxyz, A, xc, ax, r_c, h, sigma, Ae)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
hs | integer(kind=I4P) | in | Half stencil. | |
ngc | integer(kind=I4P) | in | Ghost cells. | |
ni | integer(kind=I4P) | in | Interior cells. | |
nj | integer(kind=I4P) | in | Interior cells. | |
nk | integer(kind=I4P) | in | Interior cells. | |
x_cell | real(kind=R8P) | in | Cell centres along x. | |
y_cell | real(kind=R8P) | in | Cell centres along y. | |
z_cell | real(kind=R8P) | in | Cell centres along z. | |
dxyz | real(kind=R8P) | in | Space steps. | |
A | real(kind=R8P) | in | Potential of the block. | |
xc | real(kind=R8P) | in | Coil centre. | |
ax | integer(kind=I4P) | in | Coil axis: 1=x, 2=y, 3=z. | |
r_c | real(kind=R8P) | in | Coil radius. | |
h | real(kind=R8P) | in | Axial half-extent of the window. | |
sigma | real(kind=R8P) | in | Smearing. | |
Ae | real(kind=R8P) | out | Extended potential. |
Call graph
helicon_coil_block_A
Helicon coil potential A = eta chi grad(G) of one block, on its cells and hs cells beyond its ghosts along each axis (the points the curls of the face ghosts read). G, the primitive of the radial window, is evaluated once per cell centre on the block widened by ngc + 2 hs cells, and its gradient is the centred difference of those values.
fortran
subroutine helicon_coil_block_A(hs, ngc, ni, nj, nk, x_cell, y_cell, z_cell, dxyz, x_c, y_c, z_c, normal, Radius, N_points, s_map, csi_map, eta, theta_c, sigma, Ae)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
hs | integer(kind=I4P) | in | Half stencil. | |
ngc | integer(kind=I4P) | in | Ghost cells. | |
ni | integer(kind=I4P) | in | Interior cells. | |
nj | integer(kind=I4P) | in | Interior cells. | |
nk | integer(kind=I4P) | in | Interior cells. | |
x_cell | real(kind=R8P) | in | Cell centres along x. | |
y_cell | real(kind=R8P) | in | Cell centres along y. | |
z_cell | real(kind=R8P) | in | Cell centres along z. | |
dxyz | real(kind=R8P) | in | Space steps. | |
x_c | real(kind=R8P) | in | Coil axis point. | |
y_c | real(kind=R8P) | in | Coil axis point. | |
z_c | real(kind=R8P) | in | Coil axis point. | |
normal | character(len=2) | in | Coil axis. | |
Radius | real(kind=R8P) | in | Coil radius. | |
N_points | integer(kind=I4P) | in | Polyline points. | |
s_map | real(kind=R8P) | in | Polyline s = R theta. | |
csi_map | real(kind=R8P) | in | Polyline axial coordinates. | |
eta | real(kind=R8P) | in | Current sense. | |
theta_c | real(kind=R8P) | in | Reference azimuth. | |
sigma | real(kind=R8P) | in | Smearing. | |
Ae | real(kind=R8P) | out | Extended potential. |
Call graph
Functions
initial_amr_iterations_forest
The passes of initial conditions + regrid before the final initial conditions, ic%amr_iterations.
Returns: integer(kind=I4P)
fortran
function initial_amr_iterations_forest(self) result(n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in | The equation. |
Call graph
has_current_density
Return true if the current density (host q) is non-zero on any rank; every rank must call it. It decides whether the elliptic magnetic-field initialization runs. A rank-local test let the ranks holding current enter that solve while the others skipped it, and the solve's ghost exchange then waited forever (issue #84).
Returns: logical
fortran
function has_current_density(self) result(has)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
self | class(prism_common_object) | in | The equation. |
Call graph
global_max
Return the maximum of local over all MPI ranks; every rank must call it. The FLAIL convergence tests use it (issue #84): a rank-local test let ranks leave the elliptic iterations at different counts, and the inter-block ghost exchange of the next sweep then waited forever on the ranks that left.
Returns: real(kind=R8P)
fortran
function global_max(local) result(global)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
local | real(kind=R8P) | in | This rank's value. |
Call graph
helicon_radial_primitive
Primitive of the radial helicon window.
G'(r) = W_r(r)
W_r(r) = 0.5 * [E(r; R - sigma) - E(r; R + sigma)].
Returns: real(kind=R8P)
fortran
function helicon_radial_primitive(r, Radius, sigma) result(G)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
r | real(kind=R8P) | in | ||
Radius | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in |
Call graph
helicon_coil_chi_at_point
Helicon/saddle coil inside indicator chi at one point: 1/2 (1 + erf(d/sigma)) of the signed distance d to the polyline in the unrolled (s, csi) plane, exactly 0 or 1 beyond 8 sigma. The potential is A = eta chi grad(G).
Returns: real(kind=R8P)
fortran
function helicon_coil_chi_at_point(cell_coord, x_c, y_c, z_c, normal, Radius, N_points, s_map, csi_map, theta_c, sigma) result(chi)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
cell_coord | real(kind=R8P) | in | Coordinate cartesiane del punto di valutazione. | |
x_c | real(kind=R8P) | in | Coordinata x centro cilindro. | |
y_c | real(kind=R8P) | in | Coordinata x centro cilindro. | |
z_c | real(kind=R8P) | in | Coordinata z centro cilindro. | |
normal | character(len=2) | in | Asse cilindro. | |
Radius | real(kind=R8P) | in | Raggio cilindro. | |
N_points | integer(kind=I4P) | in | Numero di punti della spline. | |
s_map | real(kind=R8P) | in | s coordinates of the spline points for the helicon coil case. | |
csi_map | real(kind=R8P) | in | csi coordinates of the spline points for the helicon coil case. | |
theta_c | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in | Smearing. |
Call graph
wrap_to_pi
Wrap angle to [-pi, pi).
Attributes: pure, elemental
Returns: real(kind=R8P)
fortran
function wrap_to_pi(alpha) result(alpha_w)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
alpha | real(kind=R8P) | in |
Call graph
compute_signed_area
Compute signed area of a a 2D polygon
Returns: real(kind=R8P)
fortran
function compute_signed_area(N_points, x_points, y_points) result(signed_area)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
N_points | integer(kind=I4P) | in | ||
x_points | real(kind=R8P) | in | ||
y_points | real(kind=R8P) | in |
Call graph
compute_windings_number
Returns: real(kind=R8P)
fortran
function compute_windings_number(N_points, x_points, y_points, coord) result(w_n)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
N_points | integer(kind=I4P) | in | ||
x_points | real(kind=R8P) | in | ||
y_points | real(kind=R8P) | in | ||
coord | real(kind=R8P) | in |
Call graph
rectangular_coil_A_at_point
Returns: real(kind=R8P)
fortran
function rectangular_coil_A_at_point(xp, xc, idir_n, idir_a, idir_b, a1, a2, b1, b2, sigma) result(Ap)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
xp | real(kind=R8P) | in | Punto di valutazione. | |
xc | real(kind=R8P) | in | Centro spira. | |
idir_n | integer(kind=I4P) | in | Componente normale: 1=x, 2=y, 3=z. | |
idir_a | integer(kind=I4P) | in | Prima coordinata locale nel piano spira. | |
idir_b | integer(kind=I4P) | in | Seconda coordinata locale nel piano spira. | |
a1 | real(kind=R8P) | in | Estremi lato locale a. | |
a2 | real(kind=R8P) | in | Estremi lato locale a. | |
b1 | real(kind=R8P) | in | Estremi lato locale b. | |
b2 | real(kind=R8P) | in | Estremi lato locale b. | |
sigma | real(kind=R8P) | in | Smearing unico della spira. |
Call graph
erf_function
Returns: real(kind=R8P)
fortran
function erf_function(s, mu, sigma) result(res)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
s | real(kind=R8P) | in | ||
mu | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in |
Call graph
tangential_window
Returns: real(kind=R8P)
fortran
function tangential_window(s, smin, smax, sigma) result(res)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
s | real(kind=R8P) | in | ||
smin | real(kind=R8P) | in | ||
smax | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in |
Call graph
erf_primitive_function
Primitive of erf((s-mu)/(sqrt(2)*sigma)).
Returns: real(kind=R8P)
fortran
function erf_primitive_function(s, mu, sigma) result(res)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
s | real(kind=R8P) | in | ||
mu | real(kind=R8P) | in | ||
sigma | real(kind=R8P) | in |
Call graph
coil_ext_coord
Cell-centre coordinate of index i along one direction, continued by whole cells beyond the ghost cells.
Attributes: pure
Returns: real(kind=R8P)
fortran
function coil_ext_coord(ngc, xc, n, ds, i) result(x)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
ngc | integer(kind=I4P) | in | Ghost cells. | |
xc | real(kind=R8P) | in | Cell centres [1-ngc:n+ngc]. | |
n | integer(kind=I4P) | in | Interior cells. | |
ds | real(kind=R8P) | in | Space step. | |
i | integer(kind=I4P) | in | Index. |
Call graph
rectangular_block_active
True when a rectangular coil may give a source in the box. Farther than COIL_SATURATION_SIGMAS sigma from the layer |x_n - x_c| <= sigma, or from the sides in the plane, every erf of the potential is +-1 in double precision: the potential is 0 there, or the same constant across the stencils (inside the sides), and its curl is exactly 0.
Attributes: pure
Returns: logical
fortran
function rectangular_block_active(lo, hi, xc, idir_n, idir_a, idir_b, a1, a2, b1, b2, sigma) result(active)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lo | real(kind=R8P) | in | Box corners. | |
hi | real(kind=R8P) | in | Box corners. | |
xc | real(kind=R8P) | in | Coil centre. | |
idir_n | integer(kind=I4P) | in | Normal and tangential directions. | |
idir_a | integer(kind=I4P) | in | Normal and tangential directions. | |
idir_b | integer(kind=I4P) | in | Normal and tangential directions. | |
a1 | real(kind=R8P) | in | Sides along the tangential directions. | |
a2 | real(kind=R8P) | in | Sides along the tangential directions. | |
b1 | real(kind=R8P) | in | Sides along the tangential directions. | |
b2 | real(kind=R8P) | in | Sides along the tangential directions. | |
sigma | real(kind=R8P) | in | Smearing. |
Call graph
helicon_block_active
True when a helicon coil may give a source in the box. The radial window lives in the shell R -+ sigma: farther than COIL_SATURATION_SIGMAS sigma from it its erfs are saturated and G is constant (gradient at round-off). Beyond the axial extent of the polyline by more than 8 sigma, chi is exactly 0.
Attributes: pure
Returns: logical
fortran
function helicon_block_active(lo, hi, x_c, y_c, z_c, normal, Radius, sigma, csi_min, csi_max) result(active)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
lo | real(kind=R8P) | in | Box corners. | |
hi | real(kind=R8P) | in | Box corners. | |
x_c | real(kind=R8P) | in | Coil axis point. | |
y_c | real(kind=R8P) | in | Coil axis point. | |
z_c | real(kind=R8P) | in | Coil axis point. | |
normal | character(len=2) | in | Coil axis. | |
Radius | real(kind=R8P) | in | Coil radius. | |
sigma | real(kind=R8P) | in | Smearing. | |
csi_min | real(kind=R8P) | in | Axial extent of the polyline, from the axis point. | |
csi_max | real(kind=R8P) | in | Axial extent of the polyline, from the axis point. |
Call graph
axial_coil_A_at_point
Potential of a circular coil (h = sigma) or of a solenoid (h = half length) at one point, with the arithmetic of set_circular_coil_* and set_solenoid_*: only the axial component, A_ax = -erf(r; r_c) W(x_ax; x_c -+ h), r the distance from the axis.
Returns: real(kind=R8P)
fortran
function axial_coil_A_at_point(xp, xc, ax, r_c, h, sigma) result(Ap)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
xp | real(kind=R8P) | in | Point. | |
xc | real(kind=R8P) | in | Coil centre. | |
ax | integer(kind=I4P) | in | Coil axis: 1=x, 2=y, 3=z. | |
r_c | real(kind=R8P) | in | Coil radius. | |
h | real(kind=R8P) | in | Axial half-extent of the window. | |
sigma | real(kind=R8P) | in | Smearing. |
Call graph
crossproduct
Returns: real(kind=R8P)
fortran
function crossproduct(a, b) result(cross)Arguments
| Name | Type | Intent | Attributes | Description |
|---|---|---|---|---|
a | real(kind=R8P) | in | Left hand side. | |
b | real(kind=R8P) | in | Left hand side. |