How RAM works: mesh-density functions and rapid advection on arbitrary meshes
Companion research note — Transforming core ideas from Benítez-Llambay, Krapp, Ramos, & Kratter (2023) into clear intuition and practical astrophysical examples in FARGO3D.
The CFL timestep constraint on non-uniform meshes
Many problems in computational astrophysics require substantially different spatial resolution across a single simulation domain. Resolving the gas flow inside a planet’s Hill sphere—to model a circumplanetary disk, for example—demands fine grid spacing near the planet while retaining coarser cells in the outer circumstellar disk to keep total cell counts manageable.
On a standard explicit fluid solver, however, the global timestep is constrained by the smallest cell via the Courant–Friedrichs–Lewy (CFL) stability condition:
\[\Delta t \le \min_i \left(\frac{\Delta x_i}{|v_i|}\right)\]
When fluid sweeps supersonically across a refined zone—as Keplerian disk gas does relative to an embedded planet—refining cell widths by a factor of \(10\) reduces the explicit CFL timestep by a factor of \(10\) across the entire mesh, offsetting much of the computational benefit of a non-uniform grid.
The original FARGO orbital advection algorithm removed that restriction for uniformly spaced grids by shifting conserved quantities by an integer number of equal-width cells in one step. When cell sizes \(\Delta x_i\) vary in space, shifting by a fixed integer cell index no longer corresponds to a uniform physical displacement.
Velocity decomposition and conservative interpolation
In RAM (Benítez-Llambay et al. 2023), rapid advection is generalized to arbitrary non-uniform meshes. The method rests on two components:
1. Splitting bulk velocity from residual motion
Following orbital advection, the flow velocity is decomposed into a uniform bulk speed \(v_0\) and a smaller local residual \(\delta v(x, t)\):
\[v(x, t) = v_0 + \delta v(x, t), \qquad \partial_t Q + v_0 \partial_x Q + \partial_x (Q\,\delta v) = 0\]
Using operator splitting:
- Rapid conservative step: The bulk transport (\(v_0\)) is solved via conservative piecewise-linear or piecewise-parabolic interpolation along characteristics—remapping conserved quantities across arbitrary cell widths without being limited to crossing a single cell per step.
- Residual step: Only the residual velocity \(\delta v\) enters standard explicit finite-volume advection, relaxing the CFL timestep constraint substantially and lowering cumulative numerical diffusion because fewer substeps are required.
2. Why the mesh-density function \(\psi\) matters
Generalizing rapid advection to non-uniform grids raises a practical algorithmic question: when cell widths \(\Delta x_i\) vary across space, how can the solver quickly determine the upstream departure intervals and overlapping source cells during conservative interpolation?
To avoid searching through arbitrary cell interfaces at each step, RAM constructs non-uniform grids from a smooth mesh-density function \(\psi(s)\):
- Where \(\psi\) is large, grid points cluster tightly to form high-resolution zones (such as the periodic-bump and radial-bump refinements constructed in Appendix B of the paper).
- Where \(\psi\) is small, cell spacing increases smoothly toward coarser outer cells.
Integrating the mesh-density function defines a coordinate transformation that maps the non-uniform physical space onto a uniform computational coordinate \(\xi\). In \(\xi\)-space, every cell has uniform computational width, so:
- Knowing \(\psi\) allows direct mapping between physical cell boundaries and uniform computational indices, eliminating cell-search overhead during multi-cell remapping.
- Because the grid spacing varies smoothly according to \(\psi\), piecewise-polynomial conservative interpolation maintains high accuracy across refined regions with low geometric distortion.
Applications in multi-scale disk simulations
Combining RAM with structured mesh-density functions allows simulations across large spatial dynamic ranges in FARGO3D:
- Circumplanetary disks & moon formation: Resolving sub-Hill scales around an embedded giant planet in 2D and 3D global disks without the timestep being restricted by the bulk Keplerian velocity in the finest cells.
- Advection across locally refined zones: Benchmarks in the paper demonstrate order-of-magnitude speedups alongside substantially lower truncation error than standard explicit upwind schemes whenever fluid advects rapidly across refined meshes.
Further reading: - Paper overview: RAM — rapid advection algorithm on arbitrary meshes (2023) - FARGO3D project page
