Skip to content

batch_interpolate_3d: kink-robust BC variant + compact coefficient storage #326

Description

@krystophny

batch_interpolate_3d: kink-robust BC variant + compact coefficient storage (for real-space field splines)

Two enhancements to the batch 3D splines (src/interpolate/batch_interpolate_3d.f90)
motivated by adding an ASCOT5-style direct real-space (R,phi,z) magnetic-field spline as
a fast, GPU-friendly field representation for full-orbit tracers (itpplasma/SIMPLE#423;
perf context SIMPLE#422). The existing engine already covers most needs -- cubic AND
quintic orders, periodic/natural BCs, value/1st/2nd-derivative evaluate, SoA batch, and
GPU !$acc routine seq + resident device kernel with the managed-memory fix. Two gaps:

1. Kink-robust / boundary-aware spline variant

Today the only BCs are natural and periodic (spl_reg/spl_per in
spl_three_to_five.f90); there is no monotone/Steffen-limited/WENO/one-sided option. A
real-space field grid is rectangular but the plasma boundary (LCFS) is not, so a grid
line crossing rho=1 sees a C1 kink (real field inside, clamped/extrapolated outside). A
global C2 cubic rings near that kink within ~3 nodes; a quintic rings worse and wider --
and the kink sits exactly at the edge where particle losses are decided. Request: a
limited/one-sided (e.g. Steffen-monotone or boundary ghost-node) construction option,
selectable per axis, that suppresses the overshoot near a data discontinuity while
keeping the interior accuracy. Lets us spline up to the LCFS without corrupting the edge
shell, and is reusable for any field with a sharp boundary.

2. Compact coefficient storage option

The current batch layout stores a dense (order+1)^3 coefficient block per cell
(coeff(iq, k1,k2,k3, i1,i2,i3)). For a real-space field grid this is the dominant
memory cost: a 4-quantity QUINTIC field at 200x64x200 is ~190 GB; cubic ~36 GB. ASCOT5's
interp3Dcomp stores one compact set per node (function value + 2nd derivatives, 8 per
node for tricubic) and reconstructs the cell polynomial on the fly, which is far lighter
and is what makes high-resolution 3D field grids affordable. Request: an optional compact
storage mode for BatchSplineData3D (store f + second derivatives, reconstruct in
evaluate), so high-resolution and/or quintic real-space field splines fit in memory. The
device evaluate kernels already exist; the change is the storage/reconstruction path.

Both are opt-in and do not change the default natural/periodic dense path. Needed for the
SIMPLE real-space-field-spline work (SIMPLE#423) but generally useful for any large 3D
field spline. Related: the chartmap covariant-basis work in PR #325.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions