[Draft] AMR support for particles with terrain-following coordinates#3082
Draft
debog wants to merge 22 commits intoerf-model:developmentfrom
Draft
[Draft] AMR support for particles with terrain-following coordinates#3082debog wants to merge 22 commits intoerf-model:developmentfrom
debog wants to merge 22 commits intoerf-model:developmentfrom
Conversation
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.
468933d to
a1f3c47
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…l-by-level Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
asalmgren
approved these changes
Apr 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_ratioalignment 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,ExtractAndRouteOORParticleshandles particles escaping the fine level's z-extent by recomputing k-indices for the target level before per-level redistribute.FixKIndexAMRrecomputes terrain-aware k-indices after regrid.compute_k_from_zsupports both uniform and stretched vertical grids.Cell assignor:
ERFParticlesAssignornow clamps k to domain bounds so that out-of-range particles survive untilExtractAndRouteOORParticlescan route them. AddedGetParticleBinERFbinner struct forDenseBins.Bounds checks:
AdvectWithFlowguards against out-of-bounds terrain stencil access (k+2 >= z_nd extent) and NaN velocities.ComputeTemperatureskips interpolation for particles whose k-index is outside the local z_nd range.Redistribute plumbing:
ParticleData::Redistribute(z_phys_nd)callsFixKIndexAMRper species.post_timestepand post-regrid paths use the terrain-aware overload. PrematureRedistribute()calls removed fromMakeNewLevelFromScratchandRemakeLevel.InitCustomPert fixes: Removed
AMREX_ALWAYS_ASSERT(bx.length()[2] == khi+1)inERF_InitCustomPert_ParticleTests.H(fails for partial-z boxes). FixedERF_InitCustomPertVels_ParticleTests.Hto useProbHi[2]for domain top instead ofz_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>.verbosein 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]).