Skip to content
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

(0.95.7) Yet another ZStar implementation #3956

Merged
merged 700 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
700 commits
Select commit Hold shift + click to select a range
3ecd318
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 21, 2024
b967754
static_column_depth
simone-silvestri Oct 21, 2024
3f36846
Merge branch 'ss/new-bottom-height' of github.com:CliMA/Oceananigans.…
simone-silvestri Oct 21, 2024
9ff305e
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 21, 2024
6046d2d
Update src/Grids/grid_utils.jl
simone-silvestri Oct 21, 2024
8106a70
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 23, 2024
a10df16
address comments
simone-silvestri Oct 23, 2024
5ee7623
new comment
simone-silvestri Oct 23, 2024
9777ee6
another name change
simone-silvestri Oct 23, 2024
34bf768
Merge remote-tracking branch 'origin/ss/new-bottom-height' into ss/z-…
simone-silvestri Oct 23, 2024
1d219af
AGFBIBG istead of AGFBIB and z_bottom only in TurbulenceClosures
simone-silvestri Oct 23, 2024
4510adf
Merge remote-tracking branch 'origin/ss/new-bottom-height' into ss/z-…
simone-silvestri Oct 23, 2024
238fa74
some bugfixes
simone-silvestri Oct 23, 2024
f97f9e0
Merge remote-tracking branch 'origin/ss/new-bottom-height' into ss/z-…
simone-silvestri Oct 23, 2024
d12fea0
adapting to new interface
simone-silvestri Oct 23, 2024
5286440
should change these operators
simone-silvestri Oct 23, 2024
f1aab48
remove orthogonalsphericalshellgrids for the moment
simone-silvestri Oct 23, 2024
ace678b
better bottom height
simone-silvestri Oct 23, 2024
210ead1
bugfix in bottom height
simone-silvestri Oct 23, 2024
90dfa7a
better definition of bottom height
simone-silvestri Oct 23, 2024
99a152a
fixed partial cells?
simone-silvestri Oct 23, 2024
f2402f0
fixed partial cell
simone-silvestri Oct 23, 2024
55d7432
fixed partial cells
simone-silvestri Oct 23, 2024
525f4be
fix split explicit tests
simone-silvestri Oct 23, 2024
c25d67d
check if these pass on a GPU for the moment
simone-silvestri Oct 23, 2024
849c253
remove OrthogonalSphericalShellGrids while we decide what to do
simone-silvestri Oct 23, 2024
510a858
these files shouldn't go here
simone-silvestri Oct 23, 2024
c2102dc
nothing was happening
simone-silvestri Oct 23, 2024
6e560a4
correct coordinate test
simone-silvestri Oct 24, 2024
926feda
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 25, 2024
aea0601
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 28, 2024
dfd0b30
Merge remote-tracking branch 'origin/main' into ss/new-bottom-height
simone-silvestri Oct 28, 2024
fe2d552
new operators
simone-silvestri Oct 28, 2024
7d53e21
Merge branch 'main' into ss/z-star-coordinate
simone-silvestri Oct 28, 2024
5227a13
fix pipeline
simone-silvestri Oct 29, 2024
1225061
mpi test and gpu test
simone-silvestri Oct 29, 2024
1652c6b
do we need to precompile it inside?
simone-silvestri Oct 29, 2024
9323203
precompile inside the node
simone-silvestri Oct 29, 2024
37b17ff
try previous climacommon version
simone-silvestri Oct 29, 2024
2ac8cde
go even more back
simone-silvestri Oct 29, 2024
0eb2720
use the ClimaOcean implementation
simone-silvestri Oct 29, 2024
50d0ec3
using the ClimaOcean implementation
simone-silvestri Oct 29, 2024
070c179
try removing boundary conditoin on barotropic velocity
simone-silvestri Oct 29, 2024
8feff8b
found the bug
simone-silvestri Oct 29, 2024
dea8f30
remove the show
simone-silvestri Oct 29, 2024
97b41e4
check where it is failing
simone-silvestri Oct 29, 2024
040bcad
fairer comparison
simone-silvestri Oct 30, 2024
6e183bd
see if this test passes
simone-silvestri Oct 30, 2024
d66baf2
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 30, 2024
c57a321
this was removed
simone-silvestri Oct 30, 2024
cfc6ad0
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 31, 2024
bd84d38
Merge branch 'main' into ss/fix-gpu-tests
simone-silvestri Oct 31, 2024
c56b15b
maybe precompiling before...
simone-silvestri Oct 31, 2024
371a45b
Merge branch 'ss/fix-gpu-tests' of github.com:CliMA/Oceananigans.jl i…
simone-silvestri Oct 31, 2024
e30973f
double O0
simone-silvestri Oct 31, 2024
e4cb16e
back to previous clima_common
simone-silvestri Oct 31, 2024
0c1f01c
another quick test
simone-silvestri Nov 1, 2024
88c5d3a
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Nov 1, 2024
bec1cd1
change environment
simone-silvestri Nov 1, 2024
75546af
correct the utils
simone-silvestri Nov 1, 2024
5f49ec0
Merge branch 'main' into ss/fix-gpu-tests
simone-silvestri Nov 1, 2024
9b334af
this should load mpitrampoline
simone-silvestri Nov 4, 2024
f8c6401
Fix formatting
glwagner Nov 4, 2024
1dc42bb
Go back to latest climacommon
glwagner Nov 4, 2024
5a870e7
try adding Manifest
simone-silvestri Nov 5, 2024
9e63f56
Manifest from julia 1.10
simone-silvestri Nov 5, 2024
59548f8
we probably need to initialize on a GPU
simone-silvestri Nov 5, 2024
642cfd9
these options should not create problems
simone-silvestri Nov 5, 2024
db58da1
restart the tests
simone-silvestri Nov 5, 2024
4cee49a
let's see if this differs
simone-silvestri Nov 5, 2024
a46b25d
just version infos
simone-silvestri Nov 5, 2024
4dffbe5
fiddling with O0
simone-silvestri Nov 6, 2024
9c3c6cd
why are we using 8 threads?
simone-silvestri Nov 6, 2024
3b28ecb
memory requirements are not this huge
simone-silvestri Nov 6, 2024
00f87a4
update enzyme
simone-silvestri Nov 6, 2024
7126c7c
speed up the precompilation a bit, to revert later
simone-silvestri Nov 6, 2024
733ab2b
might this be the culprit?
simone-silvestri Nov 6, 2024
2dbf1a0
revert to 8 tasks to precompile
simone-silvestri Nov 6, 2024
a4b129a
final version?
simone-silvestri Nov 6, 2024
29f7d69
return to previous state of affairs
simone-silvestri Nov 6, 2024
56ded6a
Merge branch 'ss/fix-gpu-tests' into ss/new-bottom-height
simone-silvestri Nov 6, 2024
3154a34
bugfix
simone-silvestri Nov 6, 2024
3803ff3
cuda runtime version
simone-silvestri Nov 6, 2024
cd0e05e
Merge remote-tracking branch 'origin/ss/new-bottom-height' into ss/z-…
simone-silvestri Nov 6, 2024
a60185c
Merge branch 'main' into ss/z-star-coordinate
simone-silvestri Nov 9, 2024
43dc001
Merge branch 'main' into ss/z-star-coordinate
simone-silvestri Nov 10, 2024
d738760
Merge branch 'main' into ss/z-star-coordinate
simone-silvestri Nov 11, 2024
a4d4bc6
Merge remote-tracking branch 'origin/main' into ss/z-star-coordinate
simone-silvestri Nov 15, 2024
349f71d
bugfix
simone-silvestri Nov 15, 2024
cf7b639
some bugfixes
simone-silvestri Nov 15, 2024
0edb48f
more fixes
simone-silvestri Nov 16, 2024
4b62393
just need to fix immersed boundaries
simone-silvestri Nov 17, 2024
0f69fcb
new zstar
simone-silvestri Nov 17, 2024
3d145da
Merge remote-tracking branch 'origin/main' into ss/new-zstar
simone-silvestri Nov 23, 2024
6321fba
much better!
simone-silvestri Nov 23, 2024
9cbf5d4
this should work nicely
simone-silvestri Nov 23, 2024
96f8d66
more working
simone-silvestri Nov 23, 2024
1bfe7d7
fx grid generation
simone-silvestri Nov 23, 2024
a8b1228
delete zstar
simone-silvestri Nov 23, 2024
d42e313
should work like this
simone-silvestri Nov 23, 2024
50cd210
going on
simone-silvestri Nov 23, 2024
1fd22c8
some simplification
simone-silvestri Nov 23, 2024
a339f6a
this to finish
simone-silvestri Nov 23, 2024
0370864
should compile
simone-silvestri Nov 25, 2024
d46cb79
better
simone-silvestri Nov 25, 2024
3520d00
add new definitions
simone-silvestri Nov 25, 2024
1863ef7
should work?
simone-silvestri Nov 25, 2024
ca65b6b
This works
simone-silvestri Nov 25, 2024
c15ebfd
This seems to work
simone-silvestri Nov 25, 2024
9e05e21
make sure implicit operator works
simone-silvestri Nov 25, 2024
e32956a
do not change this
simone-silvestri Nov 25, 2024
8262e16
changes
simone-silvestri Nov 25, 2024
eeff71e
some changes
simone-silvestri Nov 25, 2024
df33f47
more changes
simone-silvestri Nov 25, 2024
0555e28
more changes
simone-silvestri Nov 25, 2024
662c78a
add some more tests
simone-silvestri Nov 25, 2024
6b83651
better
simone-silvestri Nov 25, 2024
1ef6eef
make it compile
simone-silvestri Nov 25, 2024
1cf9323
make sure adapts work
simone-silvestri Nov 25, 2024
91c811c
some more corrections
simone-silvestri Nov 25, 2024
d4effbc
a comment
simone-silvestri Nov 25, 2024
a2fba41
remove duplicate field
simone-silvestri Nov 25, 2024
eee652f
where is zspacing???
simone-silvestri Nov 25, 2024
e6a35c4
works
simone-silvestri Nov 25, 2024
0585e3b
add cpu face constructor
simone-silvestri Nov 26, 2024
48b567a
Merge branch 'main' into ss/new-zstar
simone-silvestri Nov 27, 2024
b1276fb
correct aliases
simone-silvestri Nov 28, 2024
34fe9b2
Merge branch 'ss/new-zstar' of github.com:CliMA/Oceananigans.jl into …
simone-silvestri Nov 28, 2024
f0511df
at least some tests should pass
simone-silvestri Nov 28, 2024
a1a7a4e
sloggin along
simone-silvestri Nov 28, 2024
8ab0d1d
another bugfix
simone-silvestri Nov 28, 2024
abf72ce
most of the tests should pass
simone-silvestri Nov 28, 2024
8080929
remove partial cells from this business
simone-silvestri Nov 28, 2024
9b6eed2
transport the correct term
simone-silvestri Nov 28, 2024
b62e4a2
some more comment
simone-silvestri Nov 28, 2024
f9d71ae
better comment
simone-silvestri Nov 28, 2024
5d30064
some more bugfixes
simone-silvestri Nov 28, 2024
ad0f453
add z face constructor for nothing
simone-silvestri Nov 29, 2024
fb54ac7
a couple of bugfixes
simone-silvestri Nov 29, 2024
cb54a6f
another bugfix
simone-silvestri Nov 29, 2024
0e0c5e7
it works for all free surfaces!!
simone-silvestri Nov 29, 2024
b85287f
it works for all free surfaces
simone-silvestri Nov 29, 2024
f468109
back to previous cpu face constructor
simone-silvestri Nov 29, 2024
0c06253
change vector invariant upwinding
simone-silvestri Nov 29, 2024
5a2f91b
no need for a loop
simone-silvestri Nov 29, 2024
b5a8ed8
simplify
simone-silvestri Nov 29, 2024
e3ac54c
couple of fixes
simone-silvestri Nov 29, 2024
5e3a411
some improvements
simone-silvestri Dec 2, 2024
c309254
regression tests should pass
simone-silvestri Dec 2, 2024
e55cac5
rework the constructor
simone-silvestri Dec 2, 2024
ff2e3c0
simplify a bit
simone-silvestri Dec 2, 2024
322373e
change face constructor
simone-silvestri Dec 2, 2024
6d71d86
fix distributed tests
simone-silvestri Dec 2, 2024
8ca1f7f
still debugging
simone-silvestri Dec 2, 2024
f1e56c7
fix gpu scripts
simone-silvestri Dec 3, 2024
8a6937f
correct the face constructor
simone-silvestri Dec 3, 2024
4da8c75
comment
simone-silvestri Dec 3, 2024
dd98875
all tests should be fixed now except for the distributed
simone-silvestri Dec 3, 2024
bda37bf
last bugfix
simone-silvestri Dec 3, 2024
ae012de
now it should work
simone-silvestri Dec 3, 2024
ee8866d
check which is the test that errors
simone-silvestri Dec 3, 2024
846b27b
remove stackoverflow
simone-silvestri Dec 3, 2024
3f2de73
fix tests
simone-silvestri Dec 4, 2024
677db6b
Merge remote-tracking branch 'origin/main' into ss/new-zstar
simone-silvestri Dec 11, 2024
2d61d0d
revert file
simone-silvestri Dec 11, 2024
500339a
revert file
simone-silvestri Dec 11, 2024
9c55647
removed rk3 by mistake
simone-silvestri Dec 11, 2024
7fed979
revert files
simone-silvestri Dec 11, 2024
bb7d8ab
revert to rk3
simone-silvestri Dec 11, 2024
eebc1f5
make sure we do not need to use regular grids
simone-silvestri Dec 11, 2024
569b9b3
change e₃ to σ
simone-silvestri Dec 11, 2024
1425c5b
chenga name
simone-silvestri Dec 11, 2024
35780bf
more corrections
simone-silvestri Dec 11, 2024
bfd24cc
add a test for active_cells_map
simone-silvestri Dec 11, 2024
e576565
make the test a bit smaller
simone-silvestri Dec 11, 2024
1e5573c
improve test
simone-silvestri Dec 11, 2024
5552bcf
xor instead of or
simone-silvestri Dec 11, 2024
70ef066
correct all tests
simone-silvestri Dec 11, 2024
071e14a
on architecture
simone-silvestri Dec 11, 2024
998ce3b
removed the drift in immersed boundary grids
simone-silvestri Dec 11, 2024
dc11dd4
better lock_release validation
simone-silvestri Dec 11, 2024
e8c6a34
remove extra validation examples
simone-silvestri Dec 11, 2024
0e6f26e
update tests
simone-silvestri Dec 11, 2024
01856ea
increase the time step
simone-silvestri Dec 11, 2024
7eef5cd
works for all free surfaces
simone-silvestri Dec 12, 2024
f66a66a
test also rectilinear grids
simone-silvestri Dec 12, 2024
e3d7f93
better info msg
simone-silvestri Dec 12, 2024
5c137ed
back to all the grids
simone-silvestri Dec 12, 2024
2835aea
deepcopy before integrating
simone-silvestri Dec 12, 2024
6224b7d
make sure tests do not crash
simone-silvestri Dec 12, 2024
9066f1f
remove space
simone-silvestri Dec 12, 2024
cdfa58f
use correct timesteps
simone-silvestri Dec 12, 2024
c2d572a
zstar following coordinate
simone-silvestri Dec 12, 2024
3e5ac72
skip the test
simone-silvestri Dec 13, 2024
63d1be3
chnage emojii
simone-silvestri Dec 13, 2024
aa6540c
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 13, 2024
6377362
update to new syntax
simone-silvestri Dec 13, 2024
dffbeb5
Merge branch 'ss/new-zstar' of github.com:CliMA/Oceananigans.jl into …
simone-silvestri Dec 13, 2024
2953b06
align
simone-silvestri Dec 13, 2024
c94606a
skip the correct tests
simone-silvestri Dec 13, 2024
08ac22e
remove correct tests
simone-silvestri Dec 13, 2024
344308b
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 14, 2024
68dcb2a
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 15, 2024
27f0fc9
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 15, 2024
08cbad8
make sure we don't hit nans
simone-silvestri Dec 15, 2024
3fb5874
Merge branch 'ss/new-zstar' of github.com:CliMA/Oceananigans.jl into …
simone-silvestri Dec 15, 2024
c0f5bab
bugfix
simone-silvestri Dec 15, 2024
2dd3238
Update src/Grids/grid_generation.jl
simone-silvestri Dec 17, 2024
609b84d
Update src/Grids/grid_generation.jl
simone-silvestri Dec 17, 2024
0cdb4da
new name
simone-silvestri Dec 17, 2024
6a3ea4b
Merge branch 'ss/new-zstar' of github.com:CliMA/Oceananigans.jl into …
simone-silvestri Dec 17, 2024
06e7eb8
corrections
simone-silvestri Dec 17, 2024
fdc8ea5
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 17, 2024
abfe351
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 18, 2024
38241f7
Update hydrostatic_free_surface_ab2_step.jl
simone-silvestri Dec 18, 2024
688632c
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 19, 2024
26f30ff
Update step_split_explicit_free_surface.jl
simone-silvestri Dec 19, 2024
752dac0
bugfix
simone-silvestri Dec 19, 2024
34db795
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 21, 2024
f1bd706
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 23, 2024
96a1ea9
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 24, 2024
19d6285
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 24, 2024
f027eff
Merge branch 'main' into ss/new-zstar
simone-silvestri Dec 28, 2024
26df996
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 3, 2025
53505c5
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 8, 2025
84c82c9
add function support
simone-silvestri Jan 10, 2025
4588e21
add function support
simone-silvestri Jan 10, 2025
8b46f5d
remove convenience functionality
simone-silvestri Jan 10, 2025
309c68b
Update grid_generation.jl
simone-silvestri Jan 10, 2025
1e179ef
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 11, 2025
92414e5
merge main
simone-silvestri Jan 13, 2025
9825ef8
add a docstring
simone-silvestri Jan 13, 2025
1915982
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 13, 2025
22d0a91
Update test/test_active_cells_map.jl
simone-silvestri Jan 13, 2025
9361705
Update test/test_split_explicit_vertical_integrals.jl
simone-silvestri Jan 13, 2025
3a4c62e
Update test/test_split_explicit_vertical_integrals.jl
simone-silvestri Jan 13, 2025
597c323
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 14, 2025
7043914
start implementing suggestions
simone-silvestri Jan 14, 2025
0b8ab4b
continue changing comments
simone-silvestri Jan 14, 2025
ec6bb0d
simplify unscale tracer
simone-silvestri Jan 14, 2025
97a35f0
all the refactor
simone-silvestri Jan 16, 2025
7fb6afd
some bugfix
simone-silvestri Jan 16, 2025
3ffa927
remove HydrostaticFreeSurfaceModel
simone-silvestri Jan 16, 2025
c290619
Merge branch 'main' into ss/new-zstar
simone-silvestri Jan 16, 2025
e7a5445
scale tracers for all moving coordinates
simone-silvestri Jan 16, 2025
1a4324a
Merge branch 'ss/new-zstar' of github.com:CliMA/Oceananigans.jl into …
simone-silvestri Jan 16, 2025
d44bace
should work now
simone-silvestri Jan 17, 2025
cb50742
bump version
simone-silvestri Jan 17, 2025
036815c
name changes, remove exporting and add test
simone-silvestri Jan 17, 2025
80334f6
make sure that the test is appropriate
simone-silvestri Jan 17, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,42 @@ steps:
limit: 1
depends_on: "init_cpu"

#####
##### Vertical Coordinates tests
#####

- label: "🥑 gpu vertical coordinate"
env:
JULIA_DEPOT_PATH: "$SVERDRUP_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
TEST_GROUP: "vertical_coordinate"
GPU_TEST: "true"
commands:
- "$SVERDRUP_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'"
agents:
queue: Oceananigans
architecture: GPU
retry:
automatic:
- exit_status: 1
limit: 1
depends_on: "init_gpu"

- label: "🥒 cpu vertical coordinate"
env:
JULIA_DEPOT_PATH: "$TARTARUS_HOME/.julia-$BUILDKITE_BUILD_NUMBER"
TEST_GROUP: "vertical_coordinate"
CUDA_VISIBLE_DEVICES: "-1"
commands:
- "$TARTARUS_HOME/julia-$JULIA_VERSION/bin/julia -O0 --color=yes --project -e 'using Pkg; Pkg.test()'"
agents:
queue: Oceananigans
architecture: CPU
retry:
automatic:
- exit_status: 1
limit: 1
depends_on: "init_cpu"

#####
##### Enzyme extension tests
#####
Expand Down
1 change: 1 addition & 0 deletions src/Advection/Advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ using Oceananigans.Grids: with_halo
using Oceananigans.Architectures: architecture, CPU

using Oceananigans.Operators
using Oceananigans.Operators: flux_div_xyᶜᶜᶜ, Γᶠᶠᶜ, ∂t_σ

import Base: show, summary
import Oceananigans.Grids: required_halo_size_x, required_halo_size_y, required_halo_size_z
Expand Down
19 changes: 8 additions & 11 deletions src/Advection/vector_invariant_advection.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
using Oceananigans.Operators
using Oceananigans.Operators: flux_div_xyᶜᶜᶜ, Γᶠᶠᶜ

# These are also used in Coriolis/hydrostatic_spherical_coriolis.jl
struct EnergyConserving{FT} <: AbstractAdvectionScheme{1, FT} end
struct EnstrophyConserving{FT} <: AbstractAdvectionScheme{1, FT} end
Expand Down Expand Up @@ -168,7 +165,7 @@ Base.show(io::IO, a::VectorInvariant{N, FT}) where {N, FT} =
##### Convenience for WENO Vector Invariant
#####

nothing_to_default(user_value; default) = isnothing(user_value) ? default : user_value
nothing_to_default(user_value; default = nothing) = isnothing(user_value) ? default : user_value

"""
WENOVectorInvariant(FT = Float64;
Expand Down Expand Up @@ -221,14 +218,14 @@ function WENOVectorInvariant(FT::DataType = Float64;
default_upwinding = OnlySelfUpwinding(cross_scheme = divergence_scheme)
upwinding = nothing_to_default(upwinding; default = default_upwinding)

N = max(required_halo_size_x(vorticity_scheme),
required_halo_size_y(vorticity_scheme),
required_halo_size_x(divergence_scheme),
required_halo_size_y(divergence_scheme),
required_halo_size_x(kinetic_energy_gradient_scheme),
required_halo_size_y(kinetic_energy_gradient_scheme),
required_halo_size_z(vertical_scheme))
schemes = (vorticity_scheme, vertical_scheme, kinetic_energy_gradient_scheme, divergence_scheme)

NX = maximum(required_halo_size_x(s) for s in schemes)
NY = maximum(required_halo_size_y(s) for s in schemes)
NZ = maximum(required_halo_size_z(s) for s in schemes)

N = max(NX, NY, NZ)

FT = eltype(vorticity_scheme) # assumption

return VectorInvariant{N, FT, multi_dimensional_stencil}(vorticity_scheme,
Expand Down
24 changes: 20 additions & 4 deletions src/Advection/vector_invariant_cross_upwinding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,36 @@
##### Cross and Self Upwinding of the Divergence flux
#####

# The discrete continuity equation is calculated as:
#
# wᵏ⁺¹ - wᵏ δx(Ax u) + δy(Ay v) Δrᶜᶜᶜ ∂t_σ
# ---------- = - --------------------- - -------------
# Δzᶜᶜᶜ Vᶜᶜᶜ Δzᶜᶜᶜ
#
# We upwind the discrete divergence `δx(Ax u) + δy(Ay v)` and then divide by the volume,
# therefore, the correct term to be added to the divergence transport due to the moving grid is:
#
# Azᶜᶜᶜ Δrᶜᶜᶜ ∂t_σ
#
# which represents the static volume times the time derivative of the vertical grid scaling.
@inline Az_Δr_∂t_σ(i, j, k, grid) = Azᶜᶜᶜ(i, j, k, grid) * Δrᶜᶜᶜ(i, j, k, grid) * ∂t_σ(i, j, k, grid)

@inline function upwinded_divergence_flux_Uᶠᶜᶜ(i, j, k, grid, scheme::VectorInvariantCrossVerticalUpwinding, u, v)
@inbounds û = u[i, j, k]
δ_stencil = scheme.upwinding.divergence_stencil

δᴿ = _biased_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(û), flux_div_xyᶜᶜᶜ, δ_stencil, u, v)
δᴿ = _biased_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(û), flux_div_xyᶜᶜᶜ, δ_stencil, u, v)
∂t_σ = _symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, cross_scheme, Az_Δr_∂t_σ)

return û * δᴿ
return û * (δᴿ + ∂t_σ)
end

@inline function upwinded_divergence_flux_Vᶜᶠᶜ(i, j, k, grid, scheme::VectorInvariantCrossVerticalUpwinding, u, v)
@inbounds v̂ = v[i, j, k]
δ_stencil = scheme.upwinding.divergence_stencil

δᴿ = _biased_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(v̂), flux_div_xyᶜᶜᶜ, δ_stencil, u, v)
δᴿ = _biased_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(v̂), flux_div_xyᶜᶜᶜ, δ_stencil, u, v)
∂t_σ = _symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, cross_scheme, Az_Δr_∂t_σ)

return v̂ * δᴿ
return v̂ * (δᴿ + ∂t_σ)
end
13 changes: 8 additions & 5 deletions src/Advection/vector_invariant_self_upwinding.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,26 @@
##### Self Upwinding of Divergence Flux, the best option!
#####

@inline δx_U(i, j, k, grid, u, v) = δxᶜᵃᵃ(i, j, k, grid, Ax_qᶠᶜᶜ, u)
@inline δy_V(i, j, k, grid, u, v) = δyᵃᶜᵃ(i, j, k, grid, Ay_qᶜᶠᶜ, v)
@inline δx_U(i, j, k, grid, u, v) = δxᶜᶜᶜ(i, j, k, grid, Ax_qᶠᶜᶜ, u)
@inline δy_V(i, j, k, grid, u, v) = δyᶜᶜᶜ(i, j, k, grid, Ay_qᶜᶠᶜ, v)

@inline δx_U_plus_metric(i, j, k, grid, u, v) = δxᶜᶜᶜ(i, j, k, grid, Ax_qᶠᶜᶜ, u) + Az_Δr_∂t_σ(i, j, k, grid)
@inline δy_V_plus_metric(i, j, k, grid, u, v) = δyᶜᶜᶜ(i, j, k, grid, Ay_qᶜᶠᶜ, v) + Az_Δr_∂t_σ(i, j, k, grid)

# Velocity smoothness for divergence upwinding
@inline U_smoothness(i, j, k, grid, u, v) = ℑxᶜᵃᵃ(i, j, k, grid, Ax_qᶠᶜᶜ, u)
@inline V_smoothness(i, j, k, grid, u, v) = ℑyᵃᶜᵃ(i, j, k, grid, Ay_qᶜᶠᶜ, v)

# Divergence smoothness for divergence upwinding
@inline divergence_smoothness(i, j, k, grid, u, v) = δx_U(i, j, k, grid, u, v) + δy_V(i, j, k, grid, u, v)
@inline divergence_smoothness(i, j, k, grid, u, v) = δx_U(i, j, k, grid, u, v) + δy_V(i, j, k, grid, u, v) + Az_Δr_∂t_σ(i, j, k, grid)

@inline function upwinded_divergence_flux_Uᶠᶜᶜ(i, j, k, grid, scheme::VectorInvariantSelfVerticalUpwinding, u, v)

δU_stencil = scheme.upwinding.δU_stencil
cross_scheme = scheme.upwinding.cross_scheme

@inbounds û = u[i, j, k]
δvˢ = _symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, cross_scheme, δy_V, u, v)
δvˢ = _symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, cross_scheme, δy_V_plus_metric, u, v)
δuᴿ = _biased_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(û), δx_U, δU_stencil, u, v)

return û * (δvˢ + δuᴿ)
Expand All @@ -30,7 +33,7 @@ end
cross_scheme = scheme.upwinding.cross_scheme

@inbounds v̂ = v[i, j, k]
δuˢ = _symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, cross_scheme, δx_U, u, v)
δuˢ = _symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, cross_scheme, δx_U_plus_metric, u, v)
δvᴿ = _biased_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, scheme.divergence_scheme, bias(v̂), δy_V, δV_stencil, u, v)

return v̂ * (δuˢ + δvᴿ)
Expand Down
2 changes: 2 additions & 0 deletions src/Grids/Grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export XRegularRG, YRegularRG, ZRegularRG, XYRegularRG, XYZRegularRG
export LatitudeLongitudeGrid, XRegularLLG, YRegularLLG, ZRegularLLG
export OrthogonalSphericalShellGrid, ConformalCubedSphereGrid, ZRegOrthogonalSphericalShellGrid
export conformal_cubed_sphere_panel
export ZStarVerticalCoordinate
export node, nodes
export ξnode, ηnode, rnode
export xnode, ynode, znode, λnode, φnode
Expand All @@ -19,6 +20,7 @@ export spacings
export xspacings, yspacings, zspacings, λspacings, φspacings, rspacings
export minimum_xspacing, minimum_yspacing, minimum_zspacing
export static_column_depthᶜᶜᵃ, static_column_depthᶠᶜᵃ, static_column_depthᶜᶠᵃ, static_column_depthᶠᶠᵃ
export dynamic_column_depthᶜᶜᵃ, dynamic_column_depthᶠᶜᵃ, dynamic_column_depthᶜᶠᵃ, dynamic_column_depthᶠᶠᵃ
export offset_data, new_data
export on_architecture

Expand Down
45 changes: 45 additions & 0 deletions src/Grids/grid_generation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,48 @@ function generate_coordinate(FT, ::Flat, N, H, ::Nothing, coordinate_name, arch)
return FT(1), nothing, nothing, FT(1), FT(1)
end
end

#####
##### ZStarVerticalCoordinate
#####

generate_coordinate(FT, ::Periodic, N, H, ::ZStarVerticalCoordinate, coordinate_name, arch, args...) =
throw(ArgumentError("Periodic domains are not supported for ZStarVerticalCoordinate"))

# Generate a moving coordinate with evolving scaling (`σ`) for spacings and znodes
function generate_coordinate(FT, topo, size, halo, coordinate::ZStarVerticalCoordinate, coordinate_name, dim::Int, arch)

Nx, Ny, Nz = size
Hx, Hy, Hz = halo

if dim != 3
msg = "ZStarVerticalCoordinate is supported only in the third dimension (z)"
throw(ArgumentError(msg))
end

if coordinate_name != :z
msg = "ZStarVerticalCoordinate is supported only for the z-coordinate"
throw(ArgumentError(msg))
end

r_faces = coordinate.cᵃᵃᶠ

Lr, rᵃᵃᶠ, rᵃᵃᶜ, Δrᵃᵃᶠ, Δrᵃᵃᶜ = generate_coordinate(FT, topo[3](), Nz, Hz, r_faces, :r, arch)

args = (topo, (Nx, Ny, Nz), (Hx, Hy, Hz))

σᶜᶜ⁻ = new_data(FT, arch, (Center, Center, Nothing), args...)
σᶜᶜⁿ = new_data(FT, arch, (Center, Center, Nothing), args...)
σᶠᶜⁿ = new_data(FT, arch, (Face, Center, Nothing), args...)
σᶜᶠⁿ = new_data(FT, arch, (Center, Face, Nothing), args...)
σᶠᶠⁿ = new_data(FT, arch, (Face, Face, Nothing), args...)
ηⁿ = new_data(FT, arch, (Center, Center, Nothing), args...)
∂t_σ = new_data(FT, arch, (Center, Center, Nothing), args...)

# Fill all the scalings with one (at rest coordinate)
for σ in (σᶜᶜ⁻, σᶜᶜⁿ, σᶠᶜⁿ, σᶜᶠⁿ, σᶠᶠⁿ)
fill!(σ, 1)
end

return Lr, ZStarVerticalCoordinate(rᵃᵃᶠ, rᵃᵃᶜ, Δrᵃᵃᶠ, Δrᵃᵃᶜ, ηⁿ, σᶜᶜⁿ, σᶠᶜⁿ, σᶜᶠⁿ, σᶠᶠⁿ, σᶜᶜ⁻, ∂t_σ)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this return two things

end
10 changes: 8 additions & 2 deletions src/Grids/grid_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -299,7 +299,7 @@ end
function dimension_summary(topo, name, dom, z::AbstractVerticalCoordinate, pad_domain=0)
prefix = domain_summary(topo, name, dom)
padding = " "^(pad_domain+1)
return string(prefix, padding, coordinate_summary(topo, z.Δᵃᵃᶜ, name))
return string(prefix, padding, coordinate_summary(topo, z, name))
end

function dimension_summary(topo, name, dom, spacing, pad_domain=0)
Expand All @@ -317,14 +317,20 @@ coordinate_summary(topo, Δ::Union{AbstractVector, AbstractMatrix}, name) =
name, prettysummary(maximum(parent(Δ))))

#####
##### Static column depths
##### Static and Dynamic column depths
#####

@inline static_column_depthᶜᶜᵃ(i, j, grid) = grid.Lz
@inline static_column_depthᶜᶠᵃ(i, j, grid) = grid.Lz
@inline static_column_depthᶠᶜᵃ(i, j, grid) = grid.Lz
@inline static_column_depthᶠᶠᵃ(i, j, grid) = grid.Lz

# Will be extended in the `ImmersedBoundaries` module for any ZStar grid type
@inline dynamic_column_depthᶜᶜᵃ(i, j, k, grid, η) = static_column_depthᶜᶜᵃ(i, j, grid)
@inline dynamic_column_depthᶠᶜᵃ(i, j, k, grid, η) = static_column_depthᶠᶜᵃ(i, j, grid)
@inline dynamic_column_depthᶜᶠᵃ(i, j, k, grid, η) = static_column_depthᶜᶠᵃ(i, j, grid)
@inline dynamic_column_depthᶠᶠᵃ(i, j, k, grid, η) = static_column_depthᶠᶠᵃ(i, j, grid)

#####
##### Spherical geometry
#####
Expand Down
79 changes: 75 additions & 4 deletions src/Grids/vertical_coordinates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,41 @@ struct StaticVerticalCoordinate{C, D, E, F} <: AbstractVerticalCoordinate
Δᵃᵃᶜ :: F
end

struct ZStarVerticalCoordinate{C, D, E, F, H, CC, FC, CF, FF} <: AbstractVerticalCoordinate
cᵃᵃᶠ :: C
cᵃᵃᶜ :: D
Δᵃᵃᶠ :: E
Δᵃᵃᶜ :: F
ηⁿ :: H
σᶜᶜⁿ :: CC
σᶠᶜⁿ :: FC
σᶜᶠⁿ :: CF
σᶠᶠⁿ :: FF
σᶜᶜ⁻ :: CC
∂t_σ :: CC
end

"""
ZStarVerticalCoordinate(r_faces)

Construct a `ZStarVerticalCoordinate` from `r_faces` that can be a `Tuple`, a function of an index `k`,
or an `AbstractArray`. A `ZStarVerticalCoordinate` is a vertical coordinate that evolves in time
following the surface.
"""
ZStarVerticalCoordinate(r_faces) = ZStarVerticalCoordinate(r_faces, r_faces, [nothing for i in 1:9]...)

####
#### Some useful aliases
####

const RegularVerticalCoordinate = StaticVerticalCoordinate{<:Any, <:Any, <:Number, <:Number}
const RegularVerticalGrid = AbstractUnderlyingGrid{<:Any, <:Any, <:Any, <:Any, <:RegularVerticalCoordinate}
const RegularStaticVerticalCoordinate = StaticVerticalCoordinate{<:Any, <:Any, <:Number}
const RegularZStarVerticalCoordinate = ZStarVerticalCoordinate{<:Any, <:Any, <:Number}

const RegularVerticalCoordinate = Union{RegularStaticVerticalCoordinate, RegularZStarVerticalCoordinate}

const AbstractZStarGrid = AbstractUnderlyingGrid{<:Any, <:Any, <:Any, <:Bounded, <:ZStarVerticalCoordinate}
const AbstractStaticGrid = AbstractUnderlyingGrid{<:Any, <:Any, <:Any, <:Any, <:StaticVerticalCoordinate}
const RegularVerticalGrid = AbstractUnderlyingGrid{<:Any, <:Any, <:Any, <:Any, <:RegularVerticalCoordinate}

####
#### Adapt and on_architecture
Expand All @@ -52,6 +81,32 @@ on_architecture(arch, coord::StaticVerticalCoordinate) =
on_architecture(arch, coord.Δᵃᵃᶠ),
on_architecture(arch, coord.Δᵃᵃᶜ))

Adapt.adapt_structure(to, coord::ZStarVerticalCoordinate) =
ZStarVerticalCoordinate(Adapt.adapt(to, coord.cᵃᵃᶠ),
Adapt.adapt(to, coord.cᵃᵃᶜ),
Adapt.adapt(to, coord.Δᵃᵃᶠ),
Adapt.adapt(to, coord.Δᵃᵃᶜ),
Adapt.adapt(to, coord.ηⁿ),
Adapt.adapt(to, coord.σᶜᶜⁿ),
Adapt.adapt(to, coord.σᶠᶜⁿ),
Adapt.adapt(to, coord.σᶜᶠⁿ),
Adapt.adapt(to, coord.σᶠᶠⁿ),
Adapt.adapt(to, coord.σᶜᶜ⁻),
Adapt.adapt(to, coord.∂t_σ))

on_architecture(arch, coord::ZStarVerticalCoordinate) =
ZStarVerticalCoordinate(on_architecture(arch, coord.cᵃᵃᶠ),
on_architecture(arch, coord.cᵃᵃᶜ),
on_architecture(arch, coord.Δᵃᵃᶠ),
on_architecture(arch, coord.Δᵃᵃᶜ),
on_architecture(arch, coord.ηⁿ),
on_architecture(arch, coord.σᶜᶜⁿ),
on_architecture(arch, coord.σᶠᶜⁿ),
on_architecture(arch, coord.σᶜᶠⁿ),
on_architecture(arch, coord.σᶠᶠⁿ),
on_architecture(arch, coord.σᶜᶜ⁻),
on_architecture(arch, coord.∂t_σ))

#####
##### Nodes and spacings (common to every grid)...
#####
Expand Down Expand Up @@ -99,11 +154,27 @@ z_domain(grid) = domain(topology(grid, 3)(), grid.Nz, grid.z.cᵃᵃᶠ)
end

@inline cpu_face_constructor_z(grid) = cpu_face_constructor_r(grid)
@inline cpu_face_constructor_z(grid::AbstractZStarGrid) = ZStarVerticalCoordinate(cpu_face_constructor_r(grid))

####
#### Utilities
####

function validate_dimension_specification(T, ξ::ZStarVerticalCoordinate, dir, N, FT)
cᶠ = validate_dimension_specification(T, ξ.cᵃᵃᶠ, dir, N, FT)
cᶜ = validate_dimension_specification(T, ξ.cᵃᵃᶜ, dir, N, FT)
args = Tuple(getproperty(ξ, prop) for prop in propertynames(ξ))

return ZStarVerticalCoordinate(cᶠ, cᶜ, args[3:end]...)
end

# Summaries
coordinate_summary(::Bounded, z::AbstractVerticalCoordinate, name) =
@sprintf("Free-surface following with Δ%s=%s", name, prettysummary(z.Δᵃᵃᶜ))
coordinate_summary(topo, z::StaticVerticalCoordinate, name) = coordinate_summary(topo, z.Δᵃᵃᶜ, name)

coordinate_summary(::Bounded, z::RegularZStarVerticalCoordinate, name) =
@sprintf("Free-surface following with Δr=%s", prettysummary(z.Δᵃᵃᶜ))

coordinate_summary(::Bounded, z::ZStarVerticalCoordinate, name) =
@sprintf("Free-surface following with min(Δr)=%s, max(Δr)=%s",
prettysummary(minimum(z.Δᵃᵃᶜ)),
prettysummary(maximum(z.Δᵃᵃᶜ)))
1 change: 1 addition & 0 deletions src/ImmersedBoundaries/ImmersedBoundaries.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,6 @@ include("immersed_boundary_condition.jl")
include("conditional_differences.jl")
include("mask_immersed_field.jl")
include("immersed_reductions.jl")
include("zstar_immersed_grid.jl")

end # module
4 changes: 2 additions & 2 deletions src/ImmersedBoundaries/immersed_grid_metrics.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Oceananigans.AbstractOperations: GridMetricOperation

import Oceananigans.Operators: Δrᵃᵃᶠ, Δrᵃᵃᶜ
import Oceananigans.Operators: Δrᵃᵃᶠ, Δrᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ
import Oceananigans.Operators: Δxᶠᵃᵃ, Δxᶜᵃᵃ, Δxᶠᶜᵃ, Δxᶜᶠᵃ, Δxᶠᶠᵃ, Δxᶜᶜᵃ
import Oceananigans.Operators: Δyᵃᶠᵃ, Δyᵃᶜᵃ, Δyᶠᶜᵃ, Δyᶜᶠᵃ, Δyᶠᶠᵃ, Δyᶜᶜᵃ
import Oceananigans.Operators: Azᶠᶜᵃ, Azᶜᶠᵃ, Azᶠᶠᵃ, Azᶜᶜᵃ
Expand All @@ -22,8 +22,8 @@ import Oceananigans.Operators: intrinsic_vector, extrinsic_vector

@inline Δrᵃᵃᶠ(i, j, k, ibg::IBG) = Δrᵃᵃᶠ(i, j, k, ibg.underlying_grid)
@inline Δrᵃᵃᶜ(i, j, k, ibg::IBG) = Δrᵃᵃᶜ(i, j, k, ibg.underlying_grid)
@inline Δzᵃᵃᶠ(i, j, k, ibg::IBG) = Δzᵃᵃᶠ(i, j, k, ibg.underlying_grid)
@inline Δzᵃᵃᶜ(i, j, k, ibg::IBG) = Δzᵃᵃᶜ(i, j, k, ibg.underlying_grid)
@inline Δzᵃᵃᶠ(i, j, k, ibg::IBG) = Δzᵃᵃᶠ(i, j, k, ibg.underlying_grid)

# 1D Horizontal spacings

Expand Down
Loading
Loading