Skip to content

[Draft] AMR support for particles with terrain-following coordinates#3082

Draft
debog wants to merge 22 commits intoerf-model:developmentfrom
llnl:dg/particles_w_AMR
Draft

[Draft] AMR support for particles with terrain-following coordinates#3082
debog wants to merge 22 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 and terrain-following coordinates.

Tagging: Auto-snap refinement box indices to ref_ratio alignment instead of aborting when user-specified box coordinates don't produce aligned indices.

Particle advection with AMR: On level 0, Redistribute(0,0) keeps particles local. On fine levels, ExtractAndRouteOORParticles handles particles escaping the fine level's z-extent by recomputing k-indices for the target level before per-level redistribute. FixKIndexAMR recomputes terrain-aware k-indices after regrid. compute_k_from_z supports both uniform and stretched vertical grids.

Cell assignor: ERFParticlesAssignor now clamps k to domain bounds so that out-of-range particles survive until ExtractAndRouteOORParticles can route them. Added GetParticleBinERF binner struct for DenseBins.

Bounds checks: AdvectWithFlow guards against out-of-bounds terrain stencil access (k+2 >= z_nd extent) and NaN velocities. ComputeTemperature skips interpolation for particles whose k-index is outside the local z_nd range.

Redistribute plumbing: ParticleData::Redistribute(z_phys_nd) calls FixKIndexAMR per species. post_timestep and post-regrid paths use the terrain-aware overload. Premature Redistribute() calls removed from MakeNewLevelFromScratch and RemakeLevel.

InitCustomPert fixes: Removed AMREX_ALWAYS_ASSERT(bx.length()[2] == khi+1) in ERF_InitCustomPert_ParticleTests.H (fails for partial-z boxes). Fixed ERF_InitCustomPertVels_ParticleTests.H to use ProbHi[2] for domain top instead of z_nd(i,j,khi+1) which is out of bounds for partial-z L1.

Diagnostics: Per-level particle counts printed in EvolveParticles. Verbose level read from <species_name>.verbose in inputs.

Example input files: Added 4 tracer particle advection test cases in Exec/RegTests/ParticleTests/ — flat terrain and Witch-of-Agnesi hill, each with full-z and partial-z AMR1 refinement (ref_ratio 2 1 2, box-tagged L1 covering x=[4,6]).

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