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

Yet another ZStar implementation #3956

Open
wants to merge 657 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
657 commits
Select commit Hold shift + click to select a range
5b3d3bf
remove tripolar grid just to check tests
simone-silvestri Oct 10, 2024
a9535b6
bugfix in latlon grid
simone-silvestri Oct 10, 2024
c26c8ff
Merge remote-tracking branch 'origin' into ss/z-star-coordinate
simone-silvestri Oct 10, 2024
09d1a34
more fixes
simone-silvestri Oct 10, 2024
6de18a6
remove vestigial code
simone-silvestri Oct 10, 2024
f518d41
fix bugs
simone-silvestri Oct 11, 2024
983b956
some corrections
simone-silvestri Oct 11, 2024
dfada79
another bugfix
simone-silvestri Oct 11, 2024
2705b03
domain_depth
simone-silvestri Oct 11, 2024
ca935b6
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 11, 2024
cc9cd4f
some remaining `z_bottom`s
simone-silvestri Oct 11, 2024
495f6ea
Merge branch 'ss/new-bottom-height' of github.com:CliMA/Oceananigans.…
simone-silvestri Oct 11, 2024
45b5cd4
back as it was
simone-silvestri Oct 11, 2024
340163a
Merge remote-tracking branch 'origin/main' into ss/z-star-coordinate
simone-silvestri Oct 16, 2024
c3d66ea
Merge remote-tracking branch 'origin/ss/new-bottom-height' into ss/z-…
simone-silvestri Oct 16, 2024
3151408
use new bottom
simone-silvestri Oct 16, 2024
52870c9
some correction
simone-silvestri Oct 16, 2024
9f97e90
constructor had an error
simone-silvestri Oct 16, 2024
53c87d7
getting there
simone-silvestri Oct 16, 2024
f668c5a
another test
simone-silvestri Oct 16, 2024
1a6babd
bugfix
simone-silvestri Oct 16, 2024
d89aac9
better, still not ok
simone-silvestri Oct 16, 2024
1d09bed
some name changes
simone-silvestri Oct 16, 2024
cd16d6c
corrected everything
simone-silvestri Oct 16, 2024
bf95000
some bugfix now works also for immersed boundaries
simone-silvestri Oct 16, 2024
d381037
bugfix
simone-silvestri Oct 16, 2024
14d0a22
make sure the cells do not wet or dry
simone-silvestri Oct 16, 2024
58ed7f4
rnodes and rspacings
simone-silvestri Oct 16, 2024
d0de5a9
removing some NaNs
simone-silvestri Oct 16, 2024
9b5811e
it's `Δr` for partial cells
simone-silvestri Oct 16, 2024
764119f
some changes
simone-silvestri Oct 16, 2024
c63a7bc
another small bugfix
simone-silvestri Oct 16, 2024
a544227
figure this out later
simone-silvestri Oct 16, 2024
e8f2855
internal tide works
simone-silvestri Oct 16, 2024
b8401cc
correct correction
simone-silvestri Oct 16, 2024
cfd5c42
Merge branch 'main' into ss/new-bottom-height
simone-silvestri Oct 17, 2024
eb3dd44
on_architecture
simone-silvestri Oct 17, 2024
2d36ed7
correct nonhydrostatic tendency
simone-silvestri Oct 17, 2024
275a642
some more fixes plus a testset
simone-silvestri Oct 17, 2024
3e99c79
whoops
simone-silvestri Oct 17, 2024
01ddfdf
revert the outputwriter
simone-silvestri Oct 17, 2024
0f4dfc5
back to the previous split_explicit barotropic mode
simone-silvestri Oct 17, 2024
9fea102
simpler baroclinic gyre
simone-silvestri Oct 17, 2024
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
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
25 changes: 21 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,37 @@
##### Cross and Self Upwinding of the Divergence flux
#####

# This is the additional term appearing in the continuity equation due to a moving grid.
# The discrete divergence is calculated as:
#
# wᵏ⁺¹ - wᵏ δx(Ax u) + δy(Ay v) Δrᶜᶜᶜ ∂t_σ
# ---------- = - --------------------- - -------------
# Δzᶜᶜᶜ Vᶜᶜᶜ Δzᶜᶜᶜ
#
# We upwind with 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 V_times_∂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)
∂ts = _symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, cross_scheme, V_times_∂t_σ)

return û * δᴿ
return û * (δᴿ + ∂ts)
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)
∂ts = _symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, cross_scheme, V_times_∂t_σ)

return v̂ * δᴿ
return v̂ * (δᴿ + ∂ts)
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) + V_times_∂t_σ(i, j, k, grid)
@inline δy_V_plus_metric(i, j, k, grid, u, v) = δyᶜᶜᶜ(i, j, k, grid, Ay_qᶜᶠᶜ, v) + V_times_∂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) + V_times_∂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 @@ -18,7 +18,9 @@ export xnodes, ynodes, znodes, λnodes, φnodes, rnodes
export spacings
export xspacings, yspacings, zspacings, λspacings, φspacings, rspacings
export minimum_xspacing, minimum_yspacing, minimum_zspacing
export ZStarVerticalCoordinate, vertical_scaling, previous_vertical_scaling, reference_zspacings
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 (`s`) 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 = "Only z-coordinate is supported for ZStarVerticalCoordinate"
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_σ)
end
8 changes: 7 additions & 1 deletion src/Grids/grid_utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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: 76 additions & 3 deletions src/Grids/vertical_coordinate.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,50 @@ struct StaticVerticalCoordinate{C, D} <: AbstractVerticalCoordinate
Δᵃᵃᶜ :: D
end

# Represents a z-star three-dimensional vertical coordinate.
#
# # Fields
# - `cᶜ::C`: Cell-centered coordinate.
# - `cᶠ::C`: Face-centered coordinate.
# - `Δᶜ::D`: Cell-centered grid spacing.
# - `Δᶠ::D`: Face-centered grid spacing.
# - `ηⁿ::E`: Surface elevation at the current time step.
# - `σᶜᶜⁿ::CC`: Vertical grid scaling at center-center at the current time step.
# - `σᶠᶜⁿ::FC`: Vertical grid scaling at face-center at the current time step.
# - `σᶜᶠⁿ::CF`: Vertical grid scaling at center-face at the current time step.
# - `σᶠᶠⁿ::FF`: Vertical grid scaling at face-face at the current time step.
# - `σᶜᶜ⁻::CC`: Vertical grid scaling at center-center at the previous time step.
# - `∂t_σ::CC`: Time derivative of the vertical grid scaling at cell centers.
struct ZStarVerticalCoordinate{C, D, E, CC, FC, CF, FF} <: AbstractVerticalCoordinate
cᵃᵃᶠ :: C
cᵃᵃᶜ :: C
Δᵃᵃᶠ :: D
Δᵃᵃᶜ :: D
ηⁿ :: E
σᶜᶜⁿ :: CC
σᶠᶜⁿ :: FC
σᶜᶠⁿ :: CF
σᶠᶠⁿ :: FF
σᶜᶜ⁻ :: CC
∂t_σ :: CC
end

# Convenience constructors for Zstar vertical coordinate
ZStarVerticalCoordinate(r_faces::Union{Tuple, AbstractVector}) = ZStarVerticalCoordinate(r_faces, r_faces, [nothing for i in 1:9]...)
ZStarVerticalCoordinate(r⁻::Number, r⁺::Number) = ZStarVerticalCoordinate((r⁻, r⁺), (r⁻, r⁺), [nothing for i in 1:9]...)

####
#### Some usefull aliases
####

const RegularVerticalCoordinate = StaticVerticalCoordinate{<:Any, <:Number}
const RegularVerticalGrid = AbstractUnderlyingGrid{<:Any, <:Any, <:Any, <:Any, <:RegularVerticalCoordinate}
const RegularStaticVerticalCoordinate = StaticVerticalCoordinate{<:Any, <:Number}
const RegularZStarVerticalCoordinate = ZStarVerticalCoordinate{<: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 @@ -46,6 +84,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 @@ -93,11 +157,20 @@ 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) =
coordinate_summary(::Bounded, z::ZStarVerticalCoordinate, name) =
@sprintf("Free-surface following with Δ%s=%s", name, prettysummary(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
5 changes: 2 additions & 3 deletions src/ImmersedBoundaries/immersed_grid_metrics.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using Oceananigans.AbstractOperations: GridMetricOperation

import Oceananigans.Grids: coordinates
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 @@ -23,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