Skip to content

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 ​

TopicPage
Particle containers, initialization, advection, maintenance, phase ratios, subgrid diffusionParticles
Particle lifecycleParticle lifecycle
Grid coordinates, staggering and ghostsGrid layouts
CPU/GPU backend usageBackends
Cell storage, allocation and halo exchangeCellArrays
Grid/particle and centroid transfersInterpolations
PIC/FLIP updatesPIC/FLIP
Custom particle fieldsParticle fields
Velocity reconstruction schemesVelocity interpolation
Marker-chain surface trackingMarker chain
Marker-surface (3D free surface) trackingMarker surface
Checkpointing and restartI/O
Argument checks and failure behaviorInput validation
Supported dimension, backend, precision, and grid combinationsSupport 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
julia
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.

source
JustPIC.ka_backend Function
julia
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.

source
JustPIC.launch! Function
julia
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.

source

Grid helpers ​

JustPIC.add_periodic_ghost_nodes Function
julia
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

julia
xv = [0.0, 0.25, 0.5, 0.75, 1.0]
xv_periodic = add_periodic_ghost_nodes(xv)
source
JustPIC.add_ghost_nodes Function
julia
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.

source
JustPIC.add_global_ghost_nodes Function
julia
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).

source
JustPIC.inner_size Function
julia
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.

source

Kernel helpers ​

Helpers for user kernels that loop over particle slots or grid cells.

JustPIC.doskip Function
julia
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.

source
JustPIC.@dxi Macro
julia
@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.

source
JustPIC.@dx Macro
julia
@dx(dxi, I)

Return the x spacing of cell I for the spacing tuple dxi; see @dxi.

source
JustPIC.@dy Macro
julia
@dy(dxi, J)

Return the y spacing of cell J for the spacing tuple dxi; see @dxi.

source
JustPIC.@dz Macro
julia
@dz(dxi, K)

Return the z spacing of cell K for the 3D spacing tuple dxi; see @dxi.

source

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
julia
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.

source

Index ​