Public API
The reference is organized by workflow. Each manual page documents the symbols belonging to its topic; this page collects the remaining backend and grid helpers and provides a searchable index of everything.
Where to find each group
| Topic | Page |
|---|---|
| Particle containers, initialization, advection, maintenance, phase ratios, subgrid diffusion | Particles |
| Particle lifecycle | Particle lifecycle |
| Grid coordinates, staggering and ghosts | Grid layouts |
| CPU/GPU backend usage | Backends |
| Cell storage, allocation and halo exchange | CellArrays |
| Grid/particle and centroid transfers | Interpolations |
| PIC/FLIP updates | PIC/FLIP |
| Custom particle fields | Particle fields |
| Velocity reconstruction schemes | Velocity interpolation |
| Marker-chain surface tracking | Marker chain |
| Marker-surface (3D free surface) tracking | Marker surface |
| Checkpointing and restart | I/O |
| Argument checks and failure behavior | Input validation |
| Supported dimension, backend, precision, and grid combinations | Support matrix |
Backends
JustPIC dispatches on KernelAbstractions backend types directly — CPU for the CPU path and the vendor backends CUDA.CUDABackend, AMDGPU.ROCBackend, Metal.MetalBackend, introduced by the respective package extensions. Load the vendor package to activate its extension; JustPIC defines no backend tags of its own.
TA(backend) selects the plain array type for a backend, ka_backend(x) recovers the backend that stores x, and launch! runs a KernelAbstractions kernel on it, synchronizing before returning.
JustPIC.TA Function
TA()
TA(backend)Return the plain array type associated with backend (a KernelAbstractions backend type such as CPU).
For CPU this is Array. Loading CUDA.jl / AMDGPU.jl / Metal.jl extends this for CUDA.CUDABackend, AMDGPU.ROCBackend, and Metal.MetalBackend, respectively.
JustPIC.ka_backend Function
ka_backend(x)Return the KernelAbstractions backend instance (for example CPU()) that stores x: an array, a CellArray, or a Particles, MarkerChain, PassiveMarkers, or PhaseRatios container.
JustPIC.launch! Function
launch!(backend, kernel!, ndrange, args...)Instantiate and run KernelAbstractions kernel! on backend over ndrange, then block until it completes.
The trailing synchronize keeps the package's historical synchronous launch semantics: host reads, MPI halo exchanges and injection/cleanup all assume the previous kernel has finished. A later optimization pass may drop per-launch synchronization in favor of synchronizing only before host access.
Grid helpers
JustPIC.add_periodic_ghost_nodes Function
add_periodic_ghost_nodes(x::AbstractVector)Extend a 1D periodic grid with one ghost node on each side.
The added coordinates preserve the spacing of the last and first physical cells, respectively, which makes this helper work for both uniform and refined grids.
Example
xv = [0.0, 0.25, 0.5, 0.75, 1.0]
xv_periodic = add_periodic_ghost_nodes(xv)JustPIC.add_ghost_nodes Function
add_ghost_nodes(x, dx; backend = CPU)Extend the coordinates x with one ghost node on each side, at first(x) - dx and last(x) + dx, and return them as an array of type TA(backend). To extend only the ends on the global domain boundary, use add_global_ghost_nodes.
JustPIC.add_global_ghost_nodes Function
add_global_ghost_nodes(x, dx, origin; backend = CPU)Extend the rank-local coordinates x with a ghost node at each end that lies on the global domain boundary origin = (lower, upper): first(x) - dx when first(x) == lower and last(x) + dx when last(x) == upper. Ends inside the global domain, such as boundaries between MPI ranks, are left unchanged. The result is an array of type TA(backend).
JustPIC.inner_size Function
inner_size(A)
inner_size(A::Tuple)Return the size of A without one ghost layer on each side, size(A) .- 2. For a tuple, return the inner size of its first element.
Kernel helpers
Helpers for user kernels that loop over particle slots or grid cells.
JustPIC.doskip Function
doskip(index, ip, I...)Return true when slot ip of cell I is empty in the occupancy mask index (for example particles.index). Use it to skip inactive slots in kernels that loop over particles.
JustPIC.@dxi Macro
@dxi(dxi, I, J)
@dxi(dxi, I, J, K)Return the spacing of cell (I, J[, K]) in every direction for the spacing tuple dxi. Each entry of dxi is either a Number, the spacing of a uniform grid, or a vector of per-cell widths of a refined grid, indexed by the cell index. See also @dx, @dy, and @dz.
JustPIC.@dx Macro
@dx(dxi, I)Return the x spacing of cell I for the spacing tuple dxi; see @dxi.
JustPIC.@dy Macro
@dy(dxi, J)Return the y spacing of cell J for the spacing tuple dxi; see @dxi.
JustPIC.@dz Macro
@dz(dxi, K)Return the z spacing of cell K for the 3D spacing tuple dxi; see @dxi.
Container conversion
to_cpu copies arrays and JustPIC cell arrays to CPU storage. Pass a numeric type to convert the stored values during the copy; tuples are converted recursively.
JustPIC.to_cpu Function
to_cpu(x)
to_cpu(T, x)Copy arrays, cell arrays, tuples, or particle containers to CPU storage. With T, convert numeric values to element type T during the copy.
Index
JustPIC.AbstractAdvectionIntegratorJustPIC.AbstractParticlesJustPIC.EulerJustPIC.MarkerChainJustPIC.MarkerSurfaceJustPIC.ParticlesJustPIC.PassiveMarkersJustPIC.PhaseRatiosJustPIC.RungeKutta2JustPIC.RungeKutta4JustPIC.SubgridDiffusionCellArraysJustPIC.CAJustPIC.TAJustPIC.add_ghost_nodesJustPIC.add_global_ghost_nodesJustPIC.add_periodic_ghost_nodesJustPIC.advect_marker_surface!JustPIC.advect_markerchain!JustPIC.advect_surface_topo!JustPIC.advection!JustPIC.advection_LinP!JustPIC.advection_MQS!JustPIC.cell_arrayJustPIC.cell_indexJustPIC.cell_lengthJustPIC.cellaxesJustPIC.cellnumJustPIC.centroid2particle!JustPIC.centroid2particle_flip!JustPIC.checkpointing_particlesJustPIC.clean_particles!JustPIC.compute_avg_topoJustPIC.compute_rock_fraction!JustPIC.compute_rock_fraction!JustPIC.compute_topography_vertex!JustPIC.doskipJustPIC.fill_chain_from_chain!JustPIC.fill_chain_from_vertices!JustPIC.force_injection!JustPIC.grid2particle!JustPIC.grid2particle_flip!JustPIC.init_cell_arraysJustPIC.init_marker_surfaceJustPIC.init_markerchainJustPIC.init_particlesJustPIC.init_passive_markersJustPIC.inject_particles!JustPIC.inject_particles_phase!JustPIC.inner_sizeJustPIC.interpolate_velocity_to_markerchain!JustPIC.interpolate_velocity_to_surface_vertices!JustPIC.ka_backendJustPIC.launch!JustPIC.load_checkpointJustPIC.move_particles!JustPIC.nphasesJustPIC.numphasesJustPIC.particle2centroid!JustPIC.particle2centroid_flip!JustPIC.particle2grid!JustPIC.particle2grid_flip!JustPIC.phase_ratios_center!JustPIC.phase_ratios_midpoint!JustPIC.phase_ratios_vertex!JustPIC.resample!JustPIC.semilagrangian_advection!JustPIC.semilagrangian_advection_LinP!JustPIC.semilagrangian_advection_MQS!JustPIC.semilagrangian_advection_markerchain!JustPIC.set_precisionJustPIC.set_topo_from_array!JustPIC.smooth_surface_max_angle!JustPIC.subgrid_diffusion!JustPIC.subgrid_diffusion_centroid!JustPIC.to_cpuJustPIC.update_cell_halo!JustPIC.update_phase_ratios!JustPIC.update_surface_halo!JustPIC.@dxJustPIC.@dxiJustPIC.@dyJustPIC.@dz