Skip to content

AMR support for particles with terrain-following coordinates#3082

Merged
asalmgren merged 37 commits intoerf-model:developmentfrom
llnl:dg/particles_w_AMR
Apr 10, 2026
Merged

AMR support for particles with terrain-following coordinates#3082
asalmgren merged 37 commits intoerf-model:developmentfrom
llnl:dg/particles_w_AMR

Conversation

@debog
Copy link
Copy Markdown
Contributor

@debog debog commented Apr 3, 2026

Enables tracer particles (and any ERFPC-based species) to work correctly with AMR, including partial-z refinement, terrain-following coordinates, and particle-count-based dynamic tagging. Tested across flat terrain and Witch-of-Agnesi hill with 0/1/2 AMR levels, static box and particle-count tagging, and one-way coupling.

  • Auto-snap refinement box indices to ref_ratio alignment instead of aborting on misaligned user coordinates, since user-specified box coordinates rarely produce indices exactly divisible by the refinement ratio
  • Particle-count tagging averages down level-by-level (finest to coarsest) for correct tagging with 3+ AMR levels; previous code only averaged between adjacent levels, missing intermediate contributions
  • ExtractAndRouteOORParticles recomputes k-indices for particles that escape a fine level's z-extent before per-level redistribute, needed because partial-z refined regions don't cover the full vertical domain
  • FixKIndexAMR recomputes terrain-aware k-indices after regrid since grid topology changes invalidate stored k-indices; compute_k_from_z handles both uniform and stretched grids
  • ERFParticlesAssignor clamps k to domain bounds so out-of-range particles survive until routing can move them to the correct level; added GetParticleBinERF binner for DenseBins
  • AdvectWithFlow guards against out-of-bounds terrain stencil access (k+2 >= z_nd extent) and NaN velocities that arise near level boundaries
  • ParticleData::Redistribute(z_phys_nd) calls FixKIndexAMR per species; removed premature Redistribute() calls from MakeNewLevelFromScratch and RemakeLevel that ran before terrain data was available
  • Removed AMREX_ALWAYS_ASSERT(bx.length()[2] == khi+1) in InitCustomPert since it fails for partial-z boxes; fixed domain-top reference to use ProbHi[2] instead of z_nd at khi+1 which is out of bounds for partial-z L1
  • Per-level particle counts printed in EvolveParticles for diagnostics; verbose level read from <species_name>.verbose in inputs
  • Comprehensive input file matrix in Exec/RegTests/ParticleTests/ covering flat/hill terrain, AMR0/1/2, box_fullz/box_partialz/particlecount tagging
  • 3 new ctests for particle advection with AMR: ParticleAdvect_AMR1_box, ParticleAdvect_AMR1_pcount, ParticleAdvect_AMR2_pcount
  • Updated Particles.rst (AMR section, particle-count refinement) and RegressionTests.rst (new CI entries)

debog added 6 commits April 2, 2026 16:32
Instead of aborting when user-specified refinement box indices are not
divisible by ref_ratio, automatically snap lo indices down and hi
indices up to the nearest aligned value, with a diagnostic print.
ERF_InitCustomPertVels_ParticleTests.H accessed z_nd at the full
domain khi+1, which is out of bounds for partial-z L1 boxes. Use
geomdata.ProbHi()[2] for the domain top height instead.

ERF_InitCustomPert_ParticleTests.H had an assertion requiring the
box to span the full z-domain, which fails with partial-z AMR.
Removed the assertion and unused khi variable.
Add terrain-aware k-index fixing (FixKIndexAMR) and per-level
Redistribute for particles on refined levels. Add
ExtractAndRouteOORParticles to handle particles escaping the fine
level z-extent in partial-z refinement by recomputing k-indices for
the target level. Add compute_k_from_z for uniform and stretched
vertical grids. Add k-clamping in ERFParticlesAssignor and bounds
checks in AdvectWithFlow and ComputeTemperature. Use terrain-aware
Redistribute(z_phys_nd) in post_timestep and after regrid. Remove
premature Redistribute calls from MakeNewLevel functions.
@debog debog changed the title [Draft] Particle support for AMR with terrain-following coordinates [Draft] AMR support for particles with terrain-following coordinates Apr 3, 2026
@debog debog force-pushed the dg/particles_w_AMR branch from 468933d to a1f3c47 Compare April 3, 2026 05:22
@debog debog marked this pull request as ready for review April 8, 2026 23:22
@debog debog changed the title [Draft] AMR support for particles with terrain-following coordinates AMR support for particles with terrain-following coordinates Apr 8, 2026
@debog debog requested a review from asalmgren April 8, 2026 23:23
@asalmgren asalmgren merged commit 97d4b90 into erf-model:development Apr 10, 2026
26 checks passed
@debog debog deleted the dg/particles_w_AMR branch April 10, 2026 22:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants