Skip to content

adam_prism_common_object ​

Source: src/app/prism/common/adam_prism_common_object.F90

Dependencies

Contents ​

Derived Types ​

prism_common_object ​

Maxwell equations system class definition, common data to all backends.

Inheritance

Extends: realm_object

Components ​

NameTypeAttributesDescription
iotype(io_object)IO handler.
amrtype(amr_object)AMR marker handler.
slicestype(slices_object)Slices handler.
blanesmoantype(blanesmoan_object)Blanes-Moan integrator.
cfmtype(cfm_object)Commutator-Free Magnus integrator.
leapfrogtype(leapfrog_object)Leapfrog integrator.
flailtype(flail_object)FLAIL, the elliptic solver library (issue #84).
wenotype(weno_object)WENO reconstructor.
ibtype(ib_object)Immersed boundary.
rktype(rk_object)Runge-Kutta integrator.
adamtype(adam_object)ADAM, grid + tree + field + maps orchestrator.
fdv_schemecharacter(len=:)allocatableFDV scheme, fd/fv.
fdv_orderinteger(kind=I4P)Order of finite difference/volume schemes, general order.
fdv_half_stencilinteger(kind=I4P)Half stencil length of finite difference/volume schemes.
fdv_half_stencilsinteger(kind=I4P)Half stencil length of fdv schemes for each derivative up to 6.
ngcinteger(kind=I4P)pointerNumber of ghost cells.
niinteger(kind=I4P)pointerNumber of cells in i direction.
njinteger(kind=I4P)pointerNumber of cells in j direction.
nkinteger(kind=I4P)pointerNumber of cells in k direction.
nbinteger(kind=I4P)pointerTotal blocks number for MPI.
blocks_numberinteger(kind=I4P)pointerActual blocks number.
nvinteger(kind=I4P)pointerNumber of variables in q vector.
realm_indexinteger(kind=I4P)Inter-realm seam coupling — currently-published stage buffer key.
stage_activeinteger(kind=I4P)A copy of the forest's flux register (its faces and lookup, the accumulators unused), refreshed by the forest each
flux_register_copytype(flux_register_object)Procedure pointer TBPs for FDV operators (set at initialization by backend).
compute_block_total_variationprocedure(compute_block_total_variation_interface)pass(self), pointerCompute TV.
compute_curlprocedure(compute_curl_interface)pass(self), pointerCompute curl.
compute_curl_extendedprocedure(compute_curl_interface)pass(self), pointerCompute curl on extended support.
compute_derivative1procedure(compute_derivative1_interface)pass(self), pointerCompute deriv1.
compute_derivative2procedure(compute_derivative2_interface)pass(self), pointerCompute deriv2.
compute_derivative4procedure(compute_derivative4_interface)pass(self), pointerCompute deriv4.
compute_divergenceprocedure(compute_divergence_interface)pass(self), pointerCompute dive.
compute_gradientprocedure(compute_gradient_interface)pass(self), pointerCompute grad.
compute_gradient_extendedprocedure(compute_gradient_interface)pass(self), pointerCompute gradient on extended support.
compute_laplacianprocedure(compute_laplacian_interface)pass(self), pointerCompute laplac.
save_em_onlylogical[IO] save_fields = em: the XH5F output holds D and B only.
amr_locked_logicalAMR regrid lock (issue #22 GA6): set .true. by backends whose device/topology
blocks_fields_numberinteger(kind=I4P)Block-sized fields per block of the blocks budget (issue #112).
reserved_memoryreal(kind=R8P)Memory reserved outside the blocks by the budget, GB (issue #112).
estimate_backend_memoryprocedure(estimate_backend_memory_interface)pointer, nopassBackend memory
nv_cinteger(kind=I4P)pointerNumber of conservative variables in q vector.
nv_sinteger(kind=I4P)pointerNumber of source variables in q vector.
nv_clinteger(kind=I4P)pointerNumber of divergence cleaning variables in q vector.
qreal(kind=R8P)allocatableConservative cell centered variables.
dqreal(kind=R8P)allocatableResiduals right hand side.
q_picreal(kind=R8P)allocatablePIC variables.
pic_fieldsreal(kind=R8P)allocatableFields value at particle locations.
curlreal(kind=R8P)allocatableCurl fields.
divergencereal(kind=R8P)allocatableDivergence fields.
q_nametype(string)allocatableFields names [1:nv].
dq_nametype(string)allocatableResiduals names [1:nv].
q_pic_nametype(string)allocatablePIC Fields names.
curl_nametype(string)allocatableCurl fields names.
div_nametype(string)allocatableDivergence fields names.
energy_Dreal(kind=R8P)allocatableEnergy of field D, time history.
energy_Breal(kind=R8P)allocatableEnergy of field B, time history.
coil_powerreal(kind=R8P)allocatablePower of coils, time history.
Poynting_fluxreal(kind=R8P)allocatableTotal Poynting flux from boundary, time history.
rms_energy_error_Dreal(kind=R8P)RMS energy error of D field.
rms_energy_error_Breal(kind=R8P)RMS energy error of B field.
max_divergence_Dreal(kind=R8P)Maximum of divergence of D field.
max_divergence_Breal(kind=R8P)Maximum of divergence of B field.
max_divergence_Jreal(kind=R8P)Maximum of divergence of J field.
single_particle_output_last_timereal(kind=R8P)Last time written to single-particle history.
single_particle_output_writtenlogicalSingle-particle history write sentinel.
bctype(prism_bc_object)Boundary conditions.
coiltype(prism_coil_object)Coil source term.
external_fieldstype(prism_external_fields_object)External fields.
fWLayertype(prism_fWLayer_object)Far-field weighted layer.
grmstype(prism_grms_object)Grms diagnostic.
ictype(prism_ic_object)Initial conditions.
leapfrog_pictype(prism_leapfrog_pic_object)Leapfrog PIC integrator.
magnetic_field_at_center_domaintype(prism_magnetic_field_at_center_domain_object)Domain-center B diagnostic.
numericstype(prism_numerics_object)Numerics configuration.
particle_injectiontype(prism_particle_injection_object)Particle injection.
physicstype(prism_physics_object)Physics configuration.
pictype(prism_pic_object)PIC state.
plasma_freqtype(prism_plasma_frequencies_object)Plasma frequencies and the PIC time-step limit.
pmltype(prism_pml_object)Perfectly matched layer.
probestype(prism_probes_object)Field probes.
rk_pictype(prism_rk_pic_object)Runge-Kutta PIC handler.
rk_pmltype(prism_rk_pml_object)Runge-Kutta PML auxiliary handler.
timetype(prism_time_object)Time integration state.

Type-Bound Procedures ​

NameAttributesDescription
load_fdv_from_filepass(self)Load FDV config from file.
initialize_forestpass(self)Invoked by forest%initialize per realm at startup.
compute_local_dt_forestpass(self)Invoked by forest%compute_global_dt during the min reduction.
advance_one_step_forestpass(self)Invoked by forest%evolve_one_step per realm per timestep.
stages_per_step_forestpass(self)Number of integrator stages this realm exposes per step.
open_step_forestpass(self)Per-step prologue (multi-realm path).
begin_stage_forestpass(self)Begin one integrator stage on this realm (multi-realm path).
end_stage_forestpass(self)End the stage: residuals + assignment (multi-realm path).
close_step_forestpass(self)Per-step epilogue (multi-realm path).
post_step_forestpass(self)Invoked by forest%post_step per realm per timestep.
runtime_amr_forestpass(self)Whether this realm regrids during the run (#74).
regrid_forestpass(self)Invoked by forest%regrid per realm per timestep (#74).
regrid_begin_forestpass(self)Multi-realm regrid, phase 1: is it a regrid step (#110).
regrid_mark_forestpass(self)Phase 2: mark one sweep, marks on the tree (#110).
regrid_apply_forestpass(self)Phase 3: adapt to the (balanced) tree marks (#110).
regrid_end_forestpass(self)Phase 4: refresh the grid-dependent state (#110).
is_done_forestpass(self)Invoked by forest%is_done during the termination reduction.
finalize_forestpass(self)Invoked by forest%finalize per realm at shutdown.
finalize_mpi_forestpass(self)Process-global MPI finalize; forest calls it ONCE after all.
fill_seam_from_peer_forestpass(self)Receive-side roundtrip: copy peer's interior into self's ghosts.
pack_seam_cells_forestpass(self)Pack own cells of the cross-rank seam send rows.
unpack_seam_cells_forestpass(self)Unpack the cross-rank seam receive rows into own ghosts.
after_topology_build_forestpass(self)Backend hook invoked once after the forest builds the seam maps.
apply_reflux_to_stage_forestpass(self)Apply Berger-Colella reflux to self's stage buffer.
close_block_xh5fnopassClose XH5F file block.
close_file_xh5fnopassClose XH5F file.
open_block_xh5fpass(self)Open block file XH5F.
open_file_xh5fpass(self)Open file XH5F.
save_q_xh5fpass(self)Save in XH5F (XDMF/HDF5) format.
compute_curl_fd_extendedpass(self)Compute curl of vector field, finite difference, even for half gcs.
compute_gradient_fd_extendedpass(self)Compute gradient of scalar field, finite difference, even for half
amr_updatepass(self)Do AMR update (init-time only where amr_locked_).
mark_by_geometrypass(self)Mark blocks to be refined by a primitive geometric box.
mark_by_j_vec_total_variationpass(self)Mark by j_vec total variation (backend override; common
allocate_commonpass(self)Allocate common data.
compute_auxiliary_fieldspass(self)Compute auxiliary fields.
compute_fields_numberpass(self)Compute the block-sized fields allocated per block.
initializepass(self)Initialize the equation common data.
initialize_block_face_datapass(self)(Re)build the per-block face data on the current grid.
fold_deposited_ghostspass(self)Fold PIC deposits spilled into ghosts, locally and across ranks.
initialize_pic_time_zeropass(self)Host-side PIC particle injection plus charge/current deposition at t=0.
verify_no_pic_deposition_on_coilspass(self)Guard against PIC deposition on coil cells.
weight_pic_fields_time_zeropass(self)Host-side PIC field interpolation at t=0.
save_pic_self_force_diagnostic_time_zeropass(self)Temporary PIC self-force diagnostic at t=0.
load_restart_filespass(self)Load restart files.
save_energy_errorpass(self)Save energy error history.
save_energy_historypass(self)Save energy history.
save_coils_current_diagnosticspass(self)Save instantaneous coil-current diagnostics.
save_divergence_historypass(self)Save divergence history.
save_grms_historypass(self)Save Grms history.
save_magnetic_field_at_center_domain_historypass(self)Save domain-center B history.
save_probes_historypass(self)Save the field probes history on its cadence.
sample_probespass(self)Sample the fields at the probes (backend override).
sync_probespass(self)Sync the probe stencils with the backend (backend override).
save_restart_filespass(self)Save restart files.
save_slicespass(self)Save the slices on their cadence.
save_xh5fpass(self)Save simulation data in XH5F format.
initialize_coilspass(self)Initialize coils.
compute_coils_current_time_zeropass(self)Host-side coil current initialization at t=0.
impose_pic_fields_time_zeropass(self)Host-side elliptic initialization for PIC/current-driven fields.
has_current_densitypass(self)True if the current density is non-zero on any rank.
set_rectangular_coil_xpass(self)Subroutine to set a rectangular coil source with +-x normal
set_rectangular_coil_ypass(self)Subroutine to set a rectangular coil source with +-y normal
set_rectangular_coil_zpass(self)Subroutine to set a rectangular coil source with +-z normal
set_circular_coil_xpass(self)Subroutine to set a circular coil source with +-x normal
set_circular_coil_ypass(self)Subroutine to set a circular coil source with +-y normal
set_circular_coil_zpass(self)Subroutine to set a circular coil source with +-z normal
set_solenoid_xpass(self)Subroutine to set a solenoid source with +-x normal
set_solenoid_ypass(self)Subroutine to set a solenoid source with +-y normal
set_solenoid_zpass(self)Subroutine to set a solenoid source with +-z normal
set_helicon_coilpass(self)Subroutine to set a helicon coil source.
compute_rectangular_current_flux_sidespass(self)Precompute rectangular side-current fluxes.
compute_helicon_current_flux_segmentspass(self)Precompute helicon segment-current fluxes.
coupling_descriptor_forestpass(self)Report (scheme_time, rk_scheme, nv) for β admissibility.

Subroutines ​

amr_update ​

Do AMR update.

fortran
subroutine amr_update(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
box_eminreal(kind=R8P)inBox minimum corner.
box_emaxreal(kind=R8P)inBox maximum corner.
target_levelinteger(kind=I4P)inRefine blocks below this level.
do_initlogicalinoptionalRe-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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
tv_tolreal(kind=R8P)inTotal variation tolerance value.
delta_typecharacter(len=*)inDelta criterion type.
delta_finereal(kind=R8P)inMaximum cell delta in fine grids.
delta_coarsereal(kind=R8P)inMinimum cell delta in coarse grids.
thresholdreal(kind=R8P)inoptionalThreshold for sphere proximity.
do_initlogicalinoptionalRe-initialize refinements queries.

Call graph

allocate_common ​

Allocate common data.

fortran
subroutine allocate_common(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.

Call graph

compute_auxiliary_fields ​

Compute auxiliary fields.

fortran
subroutine compute_auxiliary_fields(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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 Runge-Kutta stages (rk_stored_stages_number nv), 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; loads the coils number (it needs no grid or field).

fortran
subroutine compute_fields_number(self, file_parameters, fields_number)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
file_parameterstype(file_ini)inSimulation parameters ini file handler.
fields_numberinteger(kind=I4P)outBlock-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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inouttargetThe equation.
filenamecharacter(len=*)inInput file name.
memory_availreal(kind=R8P)invalueMemory available for single MPI process.
nvinteger(kind=I4P)inoptionalNumber of field variables.
fields_numberinteger(kind=I4P)inoptionalBlock-sized fields per block (default: computed).
verboselogicalinoptionalTrigger verbose output.
L0real(kind=R8P)inoptionalAdimensionalization 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
qreal(kind=R8P)inoutField variables.
v_firstinteger(kind=I4P)inFirst variable to fold.
v_lastinteger(kind=I4P)inLast variable to fold.

Call graph

verify_no_pic_deposition_on_coils ​

Ensure PIC deposition does not populate cells carrying analytic coil current.

fortran
subroutine verify_no_pic_deposition_on_coils(self, q, check_current, check_charge, context)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inThe equation.
qreal(kind=R8P)inDeposited field.
check_currentlogicalinoptionalCheck Jx/Jy/Jz overlap.
check_chargelogicalinoptionalCheck rho overlap.
contextcharacter(len=*)inoptionalCall-site label.

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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(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

NameTypeIntentAttributesDescription
filenamecharacter(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

NameTypeIntentAttributesDescription
filenamecharacter(len=*)in
timereal(kind=R8P)in
q_picreal(kind=R8P)in
pic_fieldsreal(kind=R8P)in
particle_numberinteger(kind=I4P)inParticles owned by this rank.

Call graph

load_restart_files ​

Save restart files.

fortran
subroutine load_restart_files(self, t, time)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
tinteger(kind=I4P)outTime iteration.
timereal(kind=R8P)outTime.

Call graph

load_pic_restart_files ​

Load PIC restart data stored outside the ADAM field restart.

fortran
subroutine load_pic_restart_files(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag to open file before first saving.
is_to_closelogicalinoptionalFlag to close file after last saving.
div_Dreal(kind=R8P)inMaximum of divergence of D field.
div_Breal(kind=R8P)inMaximum of divergence of B
div_Jreal(kind=R8P)inMaximum of divergence of J field.
current_solver_residualreal(kind=R8P)inoptionalMaximum 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag to open file before first saving.
is_to_closelogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag to open file before first saving.
is_to_closelogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.

Call graph

save_energy_error ​

Save energy error history.

fortran
subroutine save_energy_error(self, is_to_open, is_to_close)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag to open file before first saving.
is_to_closelogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
is_to_openlogicalinoptionalFlag to open file before first saving.
is_to_closelogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.

Call graph

save_restart_files ​

Save restart files.

fortran
subroutine save_restart_files(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inThe equation.

Call graph

save_xh5f ​

Save simulation data in HDF5 format.

fortran
subroutine save_xh5f(self, output_basename, with_ghost)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
output_basenamecharacter(len=*)inoptionalOutput basename.
with_ghostlogicalinoptionalFlag 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.

Call graph

initialize_coils ​

Initialize coils.

fortran
subroutine initialize_coils(self)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe 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).

fortran
subroutine impose_pic_fields_time_zero(self, ivar)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
ivarinteger(kind=I4P)inVariable (start) index in q.

Call graph

fortran
subroutine print_source_progress(label, progress_done, progress_total, last_percent)

Arguments

NameTypeIntentAttributesDescription
labelcharacter(len=*)in
progress_doneinteger(kind=I4P)in
progress_totalinteger(kind=I4P)in
last_percentinteger(kind=I4P)inout

Call graph

set_helicon_coil ​

Set helicon coil.

fortran
subroutine set_helicon_coil(self, n)

Arguments

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil 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

NameTypeIntentAttributesDescription
I_targetreal(kind=R8P)in
radiusreal(kind=R8P)in
sigmareal(kind=R8P)in
ninteger(kind=I4P)in
amplitudereal(kind=R8P)out

Call graph

compute_helicon_radial_gradient_centered ​

Compute the discrete centered gradient of the radial helicon primitive.

fortran
subroutine compute_helicon_radial_gradient_centered(hs, dxyz, cell_coord, x_c, y_c, z_c, normal, Radius, sigma, grad_G)

Arguments

NameTypeIntentAttributesDescription
hsinteger(kind=I4P)in
dxyzreal(kind=R8P)in
cell_coordreal(kind=R8P)in
x_creal(kind=R8P)in
y_creal(kind=R8P)in
z_creal(kind=R8P)in
normalcharacter(len=2)in
Radiusreal(kind=R8P)in
sigmareal(kind=R8P)in
grad_Greal(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

NameTypeIntentAttributesDescription
xreal(kind=R8P)inCartesian coordinates.
yreal(kind=R8P)inCartesian coordinates.
zreal(kind=R8P)inCartesian coordinates.
x_creal(kind=R8P)inCoil center coordinates.
y_creal(kind=R8P)inCoil center coordinates.
z_creal(kind=R8P)inCoil center coordinates.
normalcharacter(len=2)inNormal direction.
rreal(kind=R8P)outCylindrical coordinates.
thetareal(kind=R8P)outCylindrical coordinates.
axialreal(kind=R8P)outCylindrical 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

NameTypeIntentAttributesDescription
rreal(kind=R8P)in
thetareal(kind=R8P)in
axialreal(kind=R8P)in
x_creal(kind=R8P)in
y_creal(kind=R8P)in
z_creal(kind=R8P)in
normalcharacter(len=2)in
xreal(kind=R8P)out
yreal(kind=R8P)out
zreal(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

NameTypeIntentAttributesDescription
A_rreal(kind=R8P)in
A_thetareal(kind=R8P)in
A_axialreal(kind=R8P)in
thetareal(kind=R8P)in
normalcharacter(len=2)in
A_xreal(kind=R8P)out
A_yreal(kind=R8P)out
A_zreal(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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
filenamecharacter(len=*)inOutput file name.
coil_idinteger(kind=I4P)inCoil index.
current_densityreal(kind=R8P)inCurrent density coefficient.
timereal(kind=R8P)inCurrent 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
filenamecharacter(len=*)inOutput file name.
coil_idinteger(kind=I4P)inCoil index.
current_densityreal(kind=R8P)inCurrent density coefficient.
timereal(kind=R8P)inCurrent 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
coil_idinteger(kind=I4P)inCoil index.
i_dir_ninteger(kind=I4P)inCoil-normal direction.
i_dir_ainteger(kind=I4P)inFirst in-plane direction.
i_dir_binteger(kind=I4P)inSecond in-plane direction.
a1real(kind=R8P)inBounds along the local a direction.
a2real(kind=R8P)inBounds along the local a direction.
b1real(kind=R8P)inBounds along the local b direction.
b2real(kind=R8P)inBounds along the local b direction.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutThe equation.
coil_idinteger(kind=I4P)inCoil 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

NameTypeIntentAttributesDescription
normalcharacter(len=2)inCoil normal.
thetareal(kind=R8P)inSegment midpoint angle.
dsreal(kind=R8P)inUnrolled segment increments.
dareal(kind=R8P)inUnrolled segment increments.
lengthreal(kind=R8P)inSegment length.
t_hatreal(kind=R8P)outCartesian 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inCoil 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inSolenoid 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inSolenoid 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inoutCpu object.
ninteger(kind=I4P)inCoil number.
versereal(kind=R8P)inSolenoid 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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inThe realm.
scheme_timecharacter(len=:)outallocatableTime-integration family tag ("runge_kutta", "leapfrog", ...).
rk_schemecharacter(len=:)outallocatableWithin-family scheme tag ("runge-kutta-ssp-54", ...).
nvinteger(kind=I4P)outNumber of conserved variables on this realm.

Call graph

Functions ​

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

NameTypeIntentAttributesDescription
selfclass(prism_common_object)inThe 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

NameTypeIntentAttributesDescription
localreal(kind=R8P)inThis 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

NameTypeIntentAttributesDescription
rreal(kind=R8P)in
Radiusreal(kind=R8P)in
sigmareal(kind=R8P)in

Call graph

helicon_coil_A_at_point ​

Compute helicon/saddle coil auxiliary vector potential A at one point.

Returns: real(kind=R8P)

fortran
function helicon_coil_A_at_point(hs, dxyz, cell_coord, x_c, y_c, z_c, normal, Radius, N_points, s_map, csi_map, eta, theta_c, sigma) result(Ap)

Arguments

NameTypeIntentAttributesDescription
hsinteger(kind=I4P)in
dxyzreal(kind=R8P)in
cell_coordreal(kind=R8P)inCoordinate cartesiane del punto di valutazione.
x_creal(kind=R8P)inCoordinata x centro cilindro.
y_creal(kind=R8P)inCoordinata x centro cilindro.
z_creal(kind=R8P)inCoordinata z centro cilindro.
normalcharacter(len=2)inAsse cilindro.
Radiusreal(kind=R8P)inRaggio cilindro.
N_pointsinteger(kind=I4P)inNumero di punti della spline.
s_mapreal(kind=R8P)ins coordinates of the spline points for the helicon coil case.
csi_mapreal(kind=R8P)incsi coordinates of the spline points for the helicon coil case.
etareal(kind=R8P)in
theta_creal(kind=R8P)in
sigmareal(kind=R8P)inSmearing.

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

NameTypeIntentAttributesDescription
alphareal(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

NameTypeIntentAttributesDescription
N_pointsinteger(kind=I4P)in
x_pointsreal(kind=R8P)in
y_pointsreal(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

NameTypeIntentAttributesDescription
N_pointsinteger(kind=I4P)in
x_pointsreal(kind=R8P)in
y_pointsreal(kind=R8P)in
coordreal(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

NameTypeIntentAttributesDescription
xpreal(kind=R8P)inPunto di valutazione.
xcreal(kind=R8P)inCentro spira.
idir_ninteger(kind=I4P)inComponente normale: 1=x, 2=y, 3=z.
idir_ainteger(kind=I4P)inPrima coordinata locale nel piano spira.
idir_binteger(kind=I4P)inSeconda coordinata locale nel piano spira.
a1real(kind=R8P)inEstremi lato locale a.
a2real(kind=R8P)inEstremi lato locale a.
b1real(kind=R8P)inEstremi lato locale b.
b2real(kind=R8P)inEstremi lato locale b.
sigmareal(kind=R8P)inSmearing unico della spira.

Call graph

erf_function ​

Returns: real(kind=R8P)

fortran
function erf_function(s, mu, sigma) result(res)

Arguments

NameTypeIntentAttributesDescription
sreal(kind=R8P)in
mureal(kind=R8P)in
sigmareal(kind=R8P)in

Call graph

tangential_window ​

Returns: real(kind=R8P)

fortran
function tangential_window(s, smin, smax, sigma) result(res)

Arguments

NameTypeIntentAttributesDescription
sreal(kind=R8P)in
sminreal(kind=R8P)in
smaxreal(kind=R8P)in
sigmareal(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

NameTypeIntentAttributesDescription
sreal(kind=R8P)in
mureal(kind=R8P)in
sigmareal(kind=R8P)in

Call graph

build_A_ghost_stencil_rectangular ​

Build rectangular-coil ghost cell A array to compute J_vec value through the curl.

Returns: real(kind=R8P)

fortran
function build_A_ghost_stencil_rectangular(hs, dxyz, gc_coord, x_c, y_c, z_c, sigma, i_dir_n, i_dir_a, i_dir_b, a1, a2, b1, b2) result(A_gc)

Arguments

NameTypeIntentAttributesDescription
hsinteger(kind=I4P)inHalf-stencil size for the curl computation.
dxyzreal(kind=R8P)inSpace steps.
gc_coordreal(kind=R8P)inGhost cell coordinates.
x_creal(kind=R8P)inCenter coordinates.
y_creal(kind=R8P)inCenter coordinates.
z_creal(kind=R8P)inCenter coordinates.
sigmareal(kind=R8P)inWidth of the Gaussian profile.
i_dir_ninteger(kind=I4P)inDirection indices for the normal and tangential
i_dir_ainteger(kind=I4P)inDirection indices for the normal and tangential
i_dir_binteger(kind=I4P)inDirection indices for the normal and tangential
a1real(kind=R8P)inLocal coordinates of the rectangular coil
a2real(kind=R8P)inLocal coordinates of the rectangular coil
b1real(kind=R8P)inLocal coordinates of the rectangular coil
b2real(kind=R8P)inLocal coordinates of the rectangular coil

Call graph

build_A_ghost_stencil_helicon ​

Build the helicon A stencil at a ghost cell without reading outside allocated arrays.

Returns: real(kind=R8P)

fortran
function build_A_ghost_stencil_helicon(hs, dxyz, gc_coord, x_c, y_c, z_c, sigma, N_points, s_map, csi_map, eta, theta_c, r_coil, normal) result(A_gc)

Arguments

NameTypeIntentAttributesDescription
hsinteger(kind=I4P)in
dxyzreal(kind=R8P)in
gc_coordreal(kind=R8P)in
x_creal(kind=R8P)in
y_creal(kind=R8P)in
z_creal(kind=R8P)in
sigmareal(kind=R8P)in
N_pointsinteger(kind=I4P)in
s_mapreal(kind=R8P)in
csi_mapreal(kind=R8P)in
etareal(kind=R8P)in
theta_creal(kind=R8P)in
r_coilreal(kind=R8P)in
normalcharacter(len=2)in

Call graph

crossproduct ​

Returns: real(kind=R8P)

fortran
function crossproduct(a, b) result(cross)

Arguments

NameTypeIntentAttributesDescription
areal(kind=R8P)inLeft hand side.
breal(kind=R8P)inLeft hand side.

Call graph