-
Notifications
You must be signed in to change notification settings - Fork 193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FINALLY reverse the k index #462
Merged
Merged
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
ed46bb2
Reverse index for operators
ali-ramadhan 0a929bd
Reverse index for turbulence operators
ali-ramadhan 826d302
Reverse index for halos
ali-ramadhan 9ec27d3
Reverse index for compute_w_from_continuity
ali-ramadhan 534c4c1
Reverse zC and zF
ali-ramadhan d362be6
Fix grid tests
ali-ramadhan 6f47019
Model is incompressible again
ali-ramadhan 8e26cf8
Update k indexing on turbulence closure tests
ali-ramadhan 2343bdf
Add test for grid range lengths
ali-ramadhan 79d055d
Update variable names in ancient grid tests
ali-ramadhan 43bd7e9
Add test for roundoff error in ranges that fails
ali-ramadhan b08f6fa
Fix grid ranges.
ali-ramadhan 52d85ea
Rename Pearson vortex to Taylor-Green vortex
ali-ramadhan 05fb3ac
Update halo filling for no-penetration boundary conditions.
ali-ramadhan 1377c34
Integrate from bottom upwards to recompute w from continuity.
ali-ramadhan d1c906f
Fix indexing on turbulence closure tests.
ali-ramadhan 7c1fa1c
Perform buoyancy integral from the surface downwards.
ali-ramadhan b1542c9
Only have to zero out `div_u` at `k=Nz`.
ali-ramadhan f462471
Generate all ranges with function
ali-ramadhan 9a8aa2f
Correct buoyancy integral
ali-ramadhan bc049e1
Reverse output for rising thermal bubble regression test.
ali-ramadhan 20be6f4
Remapping `:bottom -> :left` and `:top -> :right`.
ali-ramadhan 0445cd4
Reverse k index and remap top/bottom for filling VBC and GBC halos
ali-ramadhan 5ea35a3
Reverse output for Rayleigh-Benard convection regression test.
ali-ramadhan 0de2765
Only compare `k = 2:Nz` as `w[:, :, 1] = 0`.
ali-ramadhan fb8d906
Fix bottom/top alias when using `CoordinateBoundaryConditions`.
ali-ramadhan 8f09f58
Fix flux boundary conditions after reversing k index.
ali-ramadhan f0a91d6
Merge branch 'master' into reverse-k-index
ali-ramadhan a8b5a9a
Update old regression tests and fix post-merge typo.
ali-ramadhan 5dff125
Reverse output for LES regression tests.
ali-ramadhan 6ee988b
Fix bottom/top mixup in applying flux boundary conditions.
ali-ramadhan ed452ff
`return` -> `return nothing`
ali-ramadhan 861a0ea
Switch `_fill_bottom_halo!` and `_fill_top_halo!` where appropriate.
ali-ramadhan 4170bbd
Merge branch 'master' into reverse-k-index
ali-ramadhan 41575ad
Need to export NetCDFOutputWriter.
ali-ramadhan 419f176
Fix thermal bubble regression test by directly using NCDatasets.jl
ali-ramadhan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,20 +139,17 @@ const CBC = CoordinateBoundaryConditions | |
PeriodicBCs() = CBC(PeriodicBC(), PeriodicBC()) | ||
|
||
# Here we overload setproperty! and getproperty to permit users to call | ||
# the 'right' and 'left' bcs in the z-direction 'bottom' and 'top'. | ||
# | ||
# Note that 'right' technically corresponds to face point N+1. Thus | ||
# the fact that right == bottom is associated with the reverse z-indexing | ||
# convention. With ordinary indexing, right == top. | ||
# the 'left' and 'right' bcs in the z-direction 'bottom' and 'top'. | ||
# Note that 'right' technically corresponds to face point N+1. | ||
Base.setproperty!(cbc::CBC, side::Symbol, bc) = setbc!(cbc, Val(side), bc) | ||
setbc!(cbc::CBC, ::Val{S}, bc) where S = setfield!(cbc, S, bc) | ||
setbc!(cbc::CBC, ::Val{:bottom}, bc) = setfield!(cbc, :right, bc) | ||
setbc!(cbc::CBC, ::Val{:top}, bc) = setfield!(cbc, :left, bc) | ||
setbc!(cbc::CBC, ::Val{:bottom}, bc) = setfield!(cbc, :left, bc) | ||
setbc!(cbc::CBC, ::Val{:top}, bc) = setfield!(cbc, :right, bc) | ||
|
||
Base.getproperty(cbc::CBC, side::Symbol) = getbc(cbc, Val(side)) | ||
getbc(cbc::CBC, ::Val{S}) where S = getfield(cbc, S) | ||
getbc(cbc::CBC, ::Val{:bottom}) = getfield(cbc, :right) | ||
getbc(cbc::CBC, ::Val{:top}) = getfield(cbc, :left) | ||
getbc(cbc::CBC, ::Val{:bottom}) = getfield(cbc, :left) | ||
getbc(cbc::CBC, ::Val{:top}) = getfield(cbc, :right) | ||
|
||
##### | ||
##### Boundary conditions for Fields | ||
|
@@ -189,7 +186,7 @@ function HorizontallyPeriodicBCs(; top = BoundaryCondition(Flux, nothing), | |
|
||
x = PeriodicBCs() | ||
y = PeriodicBCs() | ||
z = CoordinateBoundaryConditions(top, bottom) | ||
z = CoordinateBoundaryConditions(bottom, top) | ||
|
||
return FieldBoundaryConditions(x, y, z) | ||
end | ||
|
@@ -214,7 +211,7 @@ function ChannelBCs(; north = BoundaryCondition(Flux, nothing), | |
|
||
x = PeriodicBCs() | ||
y = CoordinateBoundaryConditions(south, north) | ||
z = CoordinateBoundaryConditions(top, bottom) | ||
z = CoordinateBoundaryConditions(bottom, top) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Very satisfying. |
||
|
||
return FieldBoundaryConditions(x, y, z) | ||
end | ||
|
@@ -228,12 +225,12 @@ default_tracer_bcs(tracers, solution_bcs) = DefaultTracerBoundaryConditions(solu | |
""" | ||
SolutionBoundaryConditions(tracers, proposal_bcs) | ||
Construct a `NamedTuple` of `FieldBoundaryConditions` for a model with | ||
fields `u`, `v`, `w`, and `tracers` from the proposal boundary conditions | ||
`proposal_bcs`, which must contain the boundary conditions on `u`, `v`, and `w` | ||
Construct a `NamedTuple` of `FieldBoundaryConditions` for a model with | ||
fields `u`, `v`, `w`, and `tracers` from the proposal boundary conditions | ||
`proposal_bcs`, which must contain the boundary conditions on `u`, `v`, and `w` | ||
and may contain some or all of the boundary conditions on `tracers`. | ||
""" | ||
SolutionBoundaryConditions(tracers, proposal_bcs) = | ||
SolutionBoundaryConditions(tracers, proposal_bcs) = | ||
with_tracers(tracers, proposal_bcs, default_tracer_bcs, with_velocities=true) | ||
|
||
""" | ||
|
@@ -282,7 +279,7 @@ const BoundaryConditions = HorizontallyPeriodicSolutionBCs | |
##### | ||
##### Tracer, tendency and pressure boundary condition "translators": | ||
##### | ||
##### * Default boundary conditions on tracers are periodic or no flux and | ||
##### * Default boundary conditions on tracers are periodic or no flux and | ||
##### can be derived from boundary conditions on any field | ||
##### | ||
##### * Boundary conditions on tendency terms are | ||
|
@@ -296,7 +293,7 @@ const BoundaryConditions = HorizontallyPeriodicSolutionBCs | |
DefaultTracerBC(::BC) = BoundaryCondition(Flux, nothing) | ||
DefaultTracerBC(::PBC) = PeriodicBC() | ||
|
||
DefaultTracerCoordinateBCs(bcs) = | ||
DefaultTracerCoordinateBCs(bcs) = | ||
CoordinateBoundaryConditions(DefaultTracerBC(bcs.left), DefaultTracerBC(bcs.right)) | ||
|
||
DefaultTracerBoundaryConditions(field_bcs) = | ||
|
@@ -310,7 +307,7 @@ TendencyBC(::NPBC) = NoPenetrationBC() | |
TendencyCoordinateBCs(bcs) = | ||
CoordinateBoundaryConditions(TendencyBC(bcs.left), TendencyBC(bcs.right)) | ||
|
||
TendencyFieldBCs(field_bcs) = | ||
TendencyFieldBCs(field_bcs) = | ||
FieldBoundaryConditions(Tuple(TendencyCoordinateBCs(bcs) for bcs in field_bcs)) | ||
|
||
TendenciesBoundaryConditions(solution_bcs) = | ||
|
@@ -365,7 +362,7 @@ the source term `Gc` at the top and bottom. | |
""" | ||
function apply_z_bcs!(Gc, arch, grid, top_bc, bottom_bc, args...) | ||
@launch device(arch) config=launch_config(grid, 2) _apply_z_bcs!(Gc, grid, top_bc, bottom_bc, args...) | ||
return | ||
return nothing | ||
end | ||
|
||
# Fall back functions for boundary conditions that are not of type Flux. | ||
|
@@ -390,7 +387,7 @@ If `top_bc.condition` is a function, the function must have the signature | |
`top_bc.condition(i, j, grid, boundary_condition_args...)` | ||
""" | ||
@inline apply_z_top_bc!(Gc, top_flux::BC{<:Flux}, i, j, grid, args...) = | ||
@inbounds Gc[i, j, 1] -= getbc(top_flux, i, j, grid, args...) / grid.Δz | ||
@inbounds Gc[i, j, grid.Nz] -= getbc(top_flux, i, j, grid, args...) / grid.Δz | ||
|
||
""" | ||
apply_z_bottom_bc!(Gc, bottom_flux::BC{<:Flux}, i, j, grid, args...) | ||
|
@@ -406,18 +403,18 @@ If `bottom_bc.condition` is a function, the function must have the signature | |
`bottom_bc.condition(i, j, grid, boundary_condition_args...)` | ||
""" | ||
@inline apply_z_bottom_bc!(Gc, bottom_flux::BC{<:Flux}, i, j, grid, args...) = | ||
@inbounds Gc[i, j, grid.Nz] += getbc(bottom_flux, i, j, grid, args...) / grid.Δz | ||
@inbounds Gc[i, j, 1] += getbc(bottom_flux, i, j, grid, args...) / grid.Δz | ||
|
||
""" | ||
_apply_z_bcs!(Gc, grid, top_bc, bottom_bc, args...) | ||
Apply a top and/or bottom boundary condition to variable `c`. | ||
""" | ||
function _apply_z_bcs!(Gc, grid, top_bc, bottom_bc, args...) | ||
function _apply_z_bcs!(Gc, grid, bottom_bc, top_bc, args...) | ||
@loop for j in (1:grid.Ny; (blockIdx().y - 1) * blockDim().y + threadIdx().y) | ||
@loop for i in (1:grid.Nx; (blockIdx().x - 1) * blockDim().x + threadIdx().x) | ||
apply_z_top_bc!(Gc, top_bc, i, j, grid, args...) | ||
apply_z_bottom_bc!(Gc, bottom_bc, i, j, grid, args...) | ||
apply_z_top_bc!(Gc, top_bc, i, j, grid, args...) | ||
end | ||
end | ||
end |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this was an issue after I merged master in, I guess we forgot to export it in PR #433.
Bad practice on my part to include changes not relevant to reversing the k index.