AMR support for particles with terrain-following coordinates#3082
Merged
asalmgren merged 37 commits intoerf-model:developmentfrom Apr 10, 2026
Merged
AMR support for particles with terrain-following coordinates#3082asalmgren merged 37 commits intoerf-model:developmentfrom
asalmgren merged 37 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
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…test for HIP since it freezes
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, 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.ref_ratioalignment instead of aborting on misaligned user coordinates, since user-specified box coordinates rarely produce indices exactly divisible by the refinement ratioExtractAndRouteOORParticlesrecomputes 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 domainFixKIndexAMRrecomputes terrain-aware k-indices after regrid since grid topology changes invalidate stored k-indices;compute_k_from_zhandles both uniform and stretched gridsERFParticlesAssignorclamps k to domain bounds so out-of-range particles survive until routing can move them to the correct level; addedGetParticleBinERFbinner forDenseBinsAdvectWithFlowguards against out-of-bounds terrain stencil access (k+2 >= z_ndextent) and NaN velocities that arise near level boundariesParticleData::Redistribute(z_phys_nd)callsFixKIndexAMRper species; removed prematureRedistribute()calls fromMakeNewLevelFromScratchandRemakeLevelthat ran before terrain data was availableAMREX_ALWAYS_ASSERT(bx.length()[2] == khi+1)inInitCustomPertsince it fails for partial-z boxes; fixed domain-top reference to useProbHi[2]instead ofz_ndatkhi+1which is out of bounds for partial-z L1EvolveParticlesfor diagnostics; verbose level read from<species_name>.verbosein inputsExec/RegTests/ParticleTests/covering flat/hill terrain, AMR0/1/2,box_fullz/box_partialz/particlecounttaggingParticleAdvect_AMR1_box,ParticleAdvect_AMR1_pcount,ParticleAdvect_AMR2_pcountParticles.rst(AMR section, particle-count refinement) andRegressionTests.rst(new CI entries)