Open lateral boundary conditions for anelastic models#494
Open
glwagner wants to merge 6 commits into
Open
Conversation
Add PerturbationMomentumAdvection scheme for density-aware open boundary radiation, GPU-compatible boundary mass flux computation for the anelastic solvability condition, and velocity field BC inheritance from momentum fields. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
A 2D rising thermal in a stably stratified atmosphere demonstrates gravity wave radiation through open lateral boundaries using the Klemp-Wilhelmson radiation scheme. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ve example The open boundary radiation scheme (PerturbationAdvection) was being applied 3x per RK3 stage instead of once, because fill_halo_regions! triggered it in update_state!, compute_velocities!, and compute_pressure_correction!. This caused boundary instability equivalent to advancing by 3*Δt instead of Δt. Fixes: - Add fill_open_bcs=false to fill_halo_regions! calls in update_state! and compute_velocities!, matching Oceananigans' NonhydrostaticModel pattern - Set clock.last_stage_Δt = Δt before first pressure correction so PMA uses correct Δt on the first time step (was Inf, making PMA a no-op) - Replace inherit_momentum_bcs with propagate_open_bcs for cleaner velocity BC handling at open boundaries - Handle ParcelModels with empty momentum in initialize_boundary_mass_fluxes - Fix ExplicitImports violation (view imported from Base, not Oceananigans.Fields) Adds mountain wave literate example with witch-of-Agnesi ridge, uniform 10 m/s wind, stable stratification, and PerturbationAdvection open boundaries with outflow_timescale=1. Adds uniform flow stability test to open_boundaries.jl. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ationAdvection Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
glwagner
added a commit
to CliMA/Oceananigans.jl
that referenced
this pull request
Feb 20, 2026
Extends PerturbationAdvection with two optional features needed for models with density-weighted prognostic variables (e.g., anelastic models): 1. `density` field: when provided, converts density-weighted fields (ρψ) to intensive fields (ψ) before radiation and back after. This fixes the dimensional inconsistency when applying PerturbationAdvection directly to prognostic variables like ρu, ρθ, ρq. 2. `gravity_wave_speed`: additional phase speed added to the advective velocity, following Klemp & Wilhelmson (1978). Useful for momentum fields where gravity waves propagate faster than the mean flow. Both default to `nothing` and `0` respectively, so this is fully backward compatible — existing code using PerturbationAdvection is unaffected. Also adds _fill_*_halo! methods for Center-located fields, enabling PerturbationAdvection to be used on scalar fields (tracers, ρθ, etc.) in addition to Face-located velocity/momentum fields. Motivated by NumericalEarth/Breeze.jl#494 which currently maintains a separate PerturbationMomentumAdvection scheme with ~270 lines of duplicated radiation logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Merged
3 tasks
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
glwagner
added a commit
to CliMA/Oceananigans.jl
that referenced
this pull request
Feb 26, 2026
…#5314) * Add density and gravity_wave_speed to PerturbationAdvection Extends PerturbationAdvection with two optional features needed for models with density-weighted prognostic variables (e.g., anelastic models): 1. `density` field: when provided, converts density-weighted fields (ρψ) to intensive fields (ψ) before radiation and back after. This fixes the dimensional inconsistency when applying PerturbationAdvection directly to prognostic variables like ρu, ρθ, ρq. 2. `gravity_wave_speed`: additional phase speed added to the advective velocity, following Klemp & Wilhelmson (1978). Useful for momentum fields where gravity waves propagate faster than the mean flow. Both default to `nothing` and `0` respectively, so this is fully backward compatible — existing code using PerturbationAdvection is unaffected. Also adds _fill_*_halo! methods for Center-located fields, enabling PerturbationAdvection to be used on scalar fields (tracers, ρθ, etc.) in addition to Face-located velocity/momentum fields. Motivated by NumericalEarth/Breeze.jl#494 which currently maintains a separate PerturbationMomentumAdvection scheme with ~270 lines of duplicated radiation logic. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Bump version to 0.105.1 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Add backward-compatible PerturbationAdvection constructor and update call sites Add a 2-positional-arg constructor for backward compatibility after the struct gained gravity_wave_speed and density fields. Update tests and validation scripts to use keyword arguments. Rename test_CGSolver to test_cgsolver to conform with naming conventions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Apply suggestion from @glwagner * Fix PerturbationAdvection doctest for new struct signature Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * Retrigger CI * Apply suggestion from @glwagner * Update Project.toml * update notation * Apply suggestion from @glwagner * Use unicode instead of LaTeX in PerturbationAdvection docstring Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
4 tasks
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.
Summary
PerturbationAdvectionradiation scheme and a new density-awarePerturbationMomentumAdvectionvariantBoundaryMassFluxesinfrastructure to enforce the anelastic solvability condition (net mass flux through open boundaries must vanish)fill_halo_regions!inupdate_state!,compute_velocities!, andcompute_pressure_correction!); now applied only once by passingfill_open_bcs=falseto non-pressure halo fillsclock.last_stage_Δtbefore first pressure correction so PMA uses correct Δt on the first time stepTest plan
Pkg.test("Breeze"))🤖 Generated with Claude Code