Backend agnostic
The same KernelAbstractions kernels run on CPU, CUDA, AMDGPU, and Metal; the backend is chosen by the array type.
Particle containers, advection, and particle/grid interpolation for large-scale, multi-XPU geodynamics simulations.
Particle-in-Cell (PIC) advection for large-scale, multi-XPU simulations. JustPIC runs the same code on CPU, CUDA, AMDGPU, and Metal through KernelAbstractions: the compute backend is chosen by the array type, not by rewriting the algorithm.
JustPIC is registered in the General registry:
using Pkg
Pkg.add("JustPIC")To run on a GPU, additionally install the matching backend package (CUDA, AMDGPU, or Metal) and select its backend — see Backends.
Choose a backend, build a staggered grid, and initialize a particle container:
julia> using JustPIC
julia> backend = JustPIC.CPU;
julia> nxcell, max_xcell, min_xcell = 6, 12, 3;
julia> n = 8; # vertices per dimension
julia> xv = yv = LinRange(0.0, 1.0, n);
julia> dx = dy = xv[2] - xv[1];
julia> xc = yc = LinRange(dx / 2, 1 - dx / 2, n - 1);
julia> grid_vx = xv, LinRange(first(yc) - dy, last(yc) + dy, length(yc) + 2);
julia> grid_vy = LinRange(first(xc) - dx, last(xc) + dx, length(xc) + 2), yv;
julia> particles = init_particles(backend, nxcell, max_xcell, min_xcell, grid_vx, grid_vy);
julia> sum(particles.index.data) # number of active markers across the grid
392particles can then be advected through a velocity field and used for grid-to-particle and particle-to-grid interpolation. See Particles and Interpolations for the full workflow, or the runnable 2D field advection example.
Particles and Particle lifecycle — the Particles container and the interpolate/advect/move/inject time step
Grid layouts — vertex, centroid, and staggered velocity grids
Backends — running on CPU, CUDA, AMDGPU, and Metal
CellArrays — the cell-local storage layout
Particle fields — per-particle data carried with the particles
Marker chain — 2D free-surface / topography tracking
Marker surface — 3D free-surface / topography tracking
Examples: 2D, 2D with MPI, 3D, periodic, and PIC/FLIP advection
I/O — checkpointing and restart
Mixed CPU/GPU — particles on the CPU alongside a GPU solver
Performance — benchmark history on CPU and GPU backends
The development of this package is supported by the GPU4GEO PASC project.