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

Draft
wants to merge 597 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
597 commits
Select commit Hold shift + click to select a range
0df8e72
add comments
simone-silvestri Sep 25, 2024
246a1e9
notation for partialt_s
simone-silvestri Sep 25, 2024
32e152f
this should work now
simone-silvestri Sep 25, 2024
3427460
lock release
simone-silvestri Sep 25, 2024
088bb7d
lock-release with less substeps
simone-silvestri Sep 25, 2024
df600aa
Merge remote-tracking branch 'origin/main' into ss/z-star-coordinate
simone-silvestri Oct 7, 2024
8259edc
do not change grids
simone-silvestri Oct 7, 2024
c9ffe30
bugfix
simone-silvestri Oct 7, 2024
ef99d1b
remove rnode for now
simone-silvestri Oct 7, 2024
2009fd4
full non-linear free surface
simone-silvestri Oct 7, 2024
3b01635
simplify a bit
simone-silvestri Oct 7, 2024
229976a
still scaled
simone-silvestri Oct 7, 2024
7c6a57e
simplify even more
simone-silvestri Oct 7, 2024
3ba2bd6
some bugfixes
simone-silvestri Oct 7, 2024
6776ded
works for immersed boundaries
simone-silvestri Oct 7, 2024
7c68ad1
make sure continuity is respected
simone-silvestri Oct 7, 2024
0ed0516
works also for periodic
simone-silvestri Oct 7, 2024
21e7f03
some comment
simone-silvestri Oct 7, 2024
6df83c8
bugfix
simone-silvestri Oct 7, 2024
cce4ccc
include in different PR but usefull
simone-silvestri Oct 8, 2024
fc84680
revert to previous syntax
simone-silvestri Oct 8, 2024
5741b73
fix the offsets
simone-silvestri Oct 8, 2024
5ee08be
finally it works
simone-silvestri Oct 8, 2024
e73cadf
add a validation
simone-silvestri Oct 8, 2024
65ee342
not so much progress
simone-silvestri Oct 8, 2024
4044e16
new bottom height
simone-silvestri Oct 9, 2024
b83a6ae
now it should work
simone-silvestri Oct 9, 2024
5ebaa84
comment
simone-silvestri Oct 9, 2024
f9ad227
comment
simone-silvestri Oct 9, 2024
cbdb713
remove circular dependency for now
simone-silvestri Oct 9, 2024
7f08768
some bugfixes
simone-silvestri Oct 9, 2024
4b7926f
change name to column_height
simone-silvestri Oct 9, 2024
6b7b27c
correct column height
simone-silvestri Oct 9, 2024
fdee366
whoops
simone-silvestri Oct 9, 2024
d1c145c
another correction
simone-silvestri Oct 9, 2024
dbb411a
some more changes
simone-silvestri Oct 9, 2024
3ec05df
another correction
simone-silvestri Oct 9, 2024
cfd877c
start with some changes
simone-silvestri Oct 9, 2024
4e4d40b
couple of more bugfixes
simone-silvestri Oct 9, 2024
a6362ee
more bugfixes
simone-silvestri Oct 9, 2024
3bce6fc
this should make it work
simone-silvestri Oct 9, 2024
0fa1a67
unify the formulations
simone-silvestri Oct 9, 2024
135cac3
correct implementation
simone-silvestri Oct 9, 2024
156dada
correct implementation
simone-silvestri Oct 9, 2024
04e7170
correct partial cell bottom
simone-silvestri Oct 9, 2024
9258572
use center immersed condition for grid fitted boundary
simone-silvestri Oct 9, 2024
9df333a
use the *correct* center node
simone-silvestri Oct 9, 2024
053b26f
no h for z-values!
simone-silvestri Oct 9, 2024
61b7e7f
simplify partial cells
simone-silvestri Oct 9, 2024
1098c58
make sure we don't go out of bounds
simone-silvestri Oct 9, 2024
9e35af6
back to immersed condition
simone-silvestri Oct 9, 2024
b9abd22
change some stuff
simone-silvestri Oct 9, 2024
ac7c96d
name changes
simone-silvestri Oct 10, 2024
6058806
massive change of interface
simone-silvestri Oct 10, 2024
508306d
just need to fix binary operatinos now
simone-silvestri Oct 10, 2024
a715038
now it should work
simone-silvestri Oct 10, 2024
402e04d
just have to fix the immersed boundary
simone-silvestri Oct 10, 2024
1c477bf
now it should work with everything
simone-silvestri Oct 10, 2024
f8d5c18
bugfix
simone-silvestri Oct 10, 2024
fd8a028
another bugfix
simone-silvestri Oct 10, 2024
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
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
35 changes: 35 additions & 0 deletions .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,41 @@ 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"
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "Oceananigans"
uuid = "9e8cae18-63c1-5223-a75c-80ca9d6e9a09"
authors = ["Climate Modeling Alliance and contributors"]
version = "0.94.3"
version = "0.95.0"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down
2 changes: 1 addition & 1 deletion examples/langmuir_turbulence.jl
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ Vₙ = @lift view(time_series.V[$n], 1, 1, :)
wuₙ = @lift view(time_series.wu[$n], 1, 1, :)
wvₙ = @lift view(time_series.wv[$n], 1, 1, :)

k = searchsortedfirst(grid.zᵃᵃᶠ[:], -8)
k = searchsortedfirst(znodes(grid, Center(); with_halos=true), -8)
wxyₙ = @lift view(time_series.w[$n], :, :, k)
wxzₙ = @lift view(time_series.w[$n], :, 1, :)
uxzₙ = @lift view(time_series.u[$n], :, 1, :)
Expand Down
2 changes: 2 additions & 0 deletions src/AbstractOperations/grid_metrics.jl
Original file line number Diff line number Diff line change
Expand Up @@ -290,10 +290,12 @@ end
@inline zspacings(field::AbstractField) = zspacings(field.grid, location(field)...)
@inline λspacings(field::AbstractField) = λspacings(field.grid, location(field)...)
@inline φspacings(field::AbstractField) = φspacings(field.grid, location(field)...)
@inline rspacings(field::AbstractField) = rspacings(field.grid, location(field)...)

# Some defaults for e.g. easy CFL computations.
@inline xspacings(grid::AbstractGrid) = xspacings(grid, Center(), Center(), Center())
@inline yspacings(grid::AbstractGrid) = yspacings(grid, Center(), Center(), Center())
@inline zspacings(grid::AbstractGrid) = zspacings(grid, Center(), Center(), Center())
@inline λspacings(grid::AbstractGrid) = λspacings(grid, Center(), Center(), Center())
@inline φspacings(grid::AbstractGrid) = φspacings(grid, Center(), Center(), Center())
@inline rspacings(grid::AbstractGrid) = rspacings(grid, Center(), Center(), Center())
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, coordinates
using Oceananigans.Architectures: architecture, CPU

using Oceananigans.Operators
using Oceananigans.Operators: flux_div_xyᶜᶜᶜ, Γᶠᶠᶜ, ∂t_e₃

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_e₃
# ---------- = - --------------------- - -------------
# Δ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_e₃
#
# which represents the static volume times the time derivative of the vertical grid scaling.
@inline V_times_∂t_e₃(i, j, k, grid) = Azᶜᶜᶜ(i, j, k, grid) * Δrᶜᶜᶜ(i, j, k, grid) * ∂t_e₃(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_e₃)

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_e₃)

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_e₃(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_e₃(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_e₃(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[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* (δuˢ + δvᴿ)
Expand Down
38 changes: 22 additions & 16 deletions src/DistributedComputations/distributed_grids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ import Oceananigans.Grids: RectilinearGrid, LatitudeLongitudeGrid, with_halo

const DistributedGrid{FT, TX, TY, TZ} = AbstractGrid{FT, TX, TY, TZ, <:Distributed}

const DistributedRectilinearGrid{FT, TX, TY, TZ, FX, FY, FZ, VX, VY, VZ} =
RectilinearGrid{FT, TX, TY, TZ, FX, FY, FZ, VX, VY, VZ, <:Distributed} where {FT, TX, TY, TZ, FX, FY, FZ, VX, VY, VZ}
const DistributedRectilinearGrid{FT, TX, TY, TZ, CZ, FX, FY, VX, VY} =
RectilinearGrid{FT, TX, TY, TZ, CZ, FX, FY, VX, VY, <:Distributed} where {FT, TX, TY, TZ, CZ, FX, FY, VX, VY}

const DistributedLatitudeLongitudeGrid{FT, TX, TY, TZ, M, MY, FX, FY, FZ, VX, VY, VZ} =
LatitudeLongitudeGrid{FT, TX, TY, TZ, M, MY, FX, FY, FZ, VX, VY, VZ, <:Distributed} where {FT, TX, TY, TZ, M, MY, FX, FY, FZ, VX, VY, VZ}
const DistributedLatitudeLongitudeGrid{FT, TX, TY, TZ, CZ, M, MY, FX, FY, VX, VY} =
LatitudeLongitudeGrid{FT, TX, TY, TZ, CZ, M, MY, FX, FY, VX, VY, <:Distributed} where {FT, TX, TY, TZ, CZ, M, MY, FX, FY, VX, VY}

# Local size from global size and architecture
local_size(arch::Distributed, global_sz) = (local_size(global_sz[1], arch.partition.x, arch.local_index[1]),
Expand Down Expand Up @@ -81,20 +81,23 @@ function RectilinearGrid(arch::Distributed,
TY = insert_connected_topology(topology[2], Ry, rj)
TZ = insert_connected_topology(topology[3], Rz, rk)

local_topo = (TX, TY, TZ)

xl = Rx == 1 ? x : partition_coordinate(x, nx, arch, 1)
yl = Ry == 1 ? y : partition_coordinate(y, ny, arch, 2)
zl = Rz == 1 ? z : partition_coordinate(z, nz, arch, 3)
Lx, xᶠᵃᵃ, xᶜᵃᵃ, Δxᶠᵃᵃ, Δxᶜᵃᵃ = generate_coordinate(FT, topology[1](), nx, Hx, xl, :x, child_architecture(arch))
Ly, yᵃᶠᵃ, yᵃᶜᵃ, Δyᵃᶠᵃ, Δyᵃᶜᵃ = generate_coordinate(FT, topology[2](), ny, Hy, yl, :y, child_architecture(arch))
Lz, zᵃᵃᶠ, zᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ = generate_coordinate(FT, topology[3](), nz, Hz, zl, :z, child_architecture(arch))

Lx, xᶠᵃᵃ, xᶜᵃᵃ, Δxᶠᵃᵃ, Δxᶜᵃᵃ = generate_coordinate(FT, local_topo, local_sz, halo, xl, :x, 1, child_architecture(arch))
Ly, yᵃᶠᵃ, yᵃᶜᵃ, Δyᵃᶠᵃ, Δyᵃᶜᵃ = generate_coordinate(FT, local_topo, local_sz, halo, yl, :y, 2, child_architecture(arch))
Lz, z = generate_coordinate(FT, local_topo, local_sz, halo, zl, :z, 3, child_architecture(arch))

return RectilinearGrid{TX, TY, TZ}(arch,
nx, ny, nz,
Hx, Hy, Hz,
Lx, Ly, Lz,
Δxᶠᵃᵃ, Δxᶜᵃᵃ, xᶠᵃᵃ, xᶜᵃᵃ,
Δyᵃᶜᵃ, Δyᵃᶠᵃ, yᵃᶠᵃ, yᵃᶜᵃ,
Δzᵃᵃᶠ, Δzᵃᵃᶜ, zᵃᵃᶠ, zᵃᵃᶜ)
z)
end

"""
Expand Down Expand Up @@ -127,15 +130,17 @@ function LatitudeLongitudeGrid(arch::Distributed,
TY = insert_connected_topology(topology[2], Ry, rj)
TZ = insert_connected_topology(topology[3], Rz, rk)

local_topo = (TX, TY, TZ)

λl = Rx == 1 ? longitude : partition_coordinate(longitude, nλ, arch, 1)
φl = Ry == 1 ? latitude : partition_coordinate(latitude, nφ, arch, 2)
zl = Rz == 1 ? z : partition_coordinate(z, nz, arch, 3)

# Calculate all direction (which might be stretched)
# A direction is regular if the domain passed is a Tuple{<:Real, <:Real},
# it is stretched if being passed is a function or vector (as for the VerticallyStretchedRectilinearGrid)
Lλ, λᶠᵃᵃ, λᶜᵃᵃ, Δλᶠᵃᵃ, Δλᶜᵃᵃ = generate_coordinate(FT, TX(), nλ, Hλ, λl, :longitude, arch.child_architecture)
Lz, zᵃᵃᶠ, zᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ = generate_coordinate(FT, TZ(), nz, Hz, zl, :z, arch.child_architecture)
Lλ, λᶠᵃᵃ, λᶜᵃᵃ, Δλᶠᵃᵃ, Δλᶜᵃᵃ = generate_coordinate(FT, local_topo, local_sz, halo, λl, :longitude, 1, child_architecture(arch))
Lz, z = generate_coordinate(FT, local_topo, local_sz, halo, zl, :z, 3, child_architecture(arch))

# The Latitudinal direction is _special_:
# precompute_metrics assumes that `length(φᵃᶠᵃ) = length(φᵃᶜᵃ) + 1`, which is always the case in a
Expand All @@ -145,15 +150,16 @@ function LatitudeLongitudeGrid(arch::Distributed,
# we disregard the topology when constructing the metrics and add a halo point!
# Furthermore, the `LatitudeLongitudeGrid` requires an extra halo on it's latitudinal coordinate to allow calculating
# the z-area on halo cells. (see: Az = R^2 * Δλ * (sin(φ[j]) - sin(φ[j-1]))
Lφ, φᵃᶠᵃ, φᵃᶜᵃ, Δφᵃᶠᵃ, Δφᵃᶜᵃ = generate_coordinate(FT, Bounded(), nφ, Hφ + 1, φl, :latitude, arch.child_architecture)
Lφ, φᵃᶠᵃ, φᵃᶜᵃ, Δφᵃᶠᵃ, Δφᵃᶜᵃ = generate_coordinate(FT, Bounded(), nφ, Hφ + 1, φl, :latitude, child_architecture(arch))


preliminary_grid = LatitudeLongitudeGrid{TX, TY, TZ}(arch,
nλ, nφ, nz,
Hλ, Hφ, Hz,
Lλ, Lφ, Lz,
Δλᶠᵃᵃ, Δλᶜᵃᵃ, λᶠᵃᵃ, λᶜᵃᵃ,
Δφᵃᶠᵃ, Δφᵃᶜᵃ, φᵃᶠᵃ, φᵃᶜᵃ,
Δzᵃᵃᶠ, Δzᵃᵃᶜ, zᵃᵃᶠ, zᵃᵃᶜ,
z,
(nothing for i=1:10)..., convert(FT, radius))

return !precompute_metrics ? preliminary_grid : with_precomputed_metrics(preliminary_grid)
Expand Down Expand Up @@ -199,15 +205,15 @@ function reconstruct_global_grid(grid::DistributedRectilinearGrid)

Lx, xᶠᵃᵃ, xᶜᵃᵃ, Δxᶠᵃᵃ, Δxᶜᵃᵃ = generate_coordinate(FT, TX(), Nx, Hx, xG, :x, child_arch)
Ly, yᵃᶠᵃ, yᵃᶜᵃ, Δyᵃᶠᵃ, Δyᵃᶜᵃ = generate_coordinate(FT, TY(), Ny, Hy, yG, :y, child_arch)
Lz, zᵃᵃᶠ, zᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ = generate_coordinate(FT, TZ(), Nz, Hz, zG, :z, child_arch)
Lz, z = generate_coordinate(FT, (TX, TY, TZ), (Nx, Ny, Nz), H, zG, :z, 3, child_arch)

return RectilinearGrid{TX, TY, TZ}(child_arch,
Nx, Ny, Nz,
Hx, Hy, Hz,
Lx, Ly, Lz,
Δxᶠᵃᵃ, Δxᶜᵃᵃ, xᶠᵃᵃ, xᶜᵃᵃ,
Δyᵃᶠᵃ, Δyᵃᶜᵃ, yᵃᶠᵃ, yᵃᶜᵃ,
Δzᵃᵃᶠ, Δzᵃᵃᶜ, zᵃᵃᶠ, zᵃᵃᶜ)
z)
end

function reconstruct_global_grid(grid::DistributedLatitudeLongitudeGrid)
Expand Down Expand Up @@ -245,7 +251,7 @@ function reconstruct_global_grid(grid::DistributedLatitudeLongitudeGrid)
# it is stretched if being passed is a function or vector
Lλ, λᶠᵃᵃ, λᶜᵃᵃ, Δλᶠᵃᵃ, Δλᶜᵃᵃ = generate_coordinate(FT, TX(), Nλ, Hλ, λG, :longitude, child_arch)
Lφ, φᵃᶠᵃ, φᵃᶜᵃ, Δφᵃᶠᵃ, Δφᵃᶜᵃ = generate_coordinate(FT, TY(), Nφ, Hφ, φG, :latitude, child_arch)
Lz, zᵃᵃᶠ, zᵃᵃᶜ, Δzᵃᵃᶠ, Δzᵃᵃᶜ = generate_coordinate(FT, TZ(), Nz, Hz, zG, :z, child_arch)
Lz, z = generate_coordinate(FT, (TX, TY, TZ), (Nλ, Nφ, Nz), H, zG, :z, 3, child_arch)

precompute_metrics = metrics_precomputed(grid)

Expand All @@ -255,7 +261,7 @@ function reconstruct_global_grid(grid::DistributedLatitudeLongitudeGrid)
Lλ, Lφ, Lz,
Δλᶠᵃᵃ, Δλᶜᵃᵃ, λᶠᵃᵃ, λᶜᵃᵃ,
Δφᵃᶠᵃ, Δφᵃᶜᵃ, φᵃᶠᵃ, φᵃᶜᵃ,
Δzᵃᵃᶠ, Δzᵃᵃᶜ, zᵃᵃᶠ, zᵃᵃᶜ,
z,
(nothing for i=1:10)..., grid.radius)

return !precompute_metrics ? preliminary_grid : with_precomputed_metrics(preliminary_grid)
Expand Down
4 changes: 2 additions & 2 deletions src/DistributedComputations/distributed_on_architecture.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function on_architecture(new_arch::Distributed, old_grid::LatitudeLongitudeGrid)
child_arch = child_architecture(new_arch)
old_properties = (old_grid.Δλᶠᵃᵃ, old_grid.Δλᶜᵃᵃ, old_grid.λᶠᵃᵃ, old_grid.λᶜᵃᵃ,
old_grid.Δφᵃᶠᵃ, old_grid.Δφᵃᶜᵃ, old_grid.φᵃᶠᵃ, old_grid.φᵃᶜᵃ,
old_grid.Δzᵃᵃᶠ, old_grid.Δzᵃᵃᶜ, old_grid.zᵃᵃᶠ, old_grid.zᵃᵃᶜ,
old_grid.z,
old_grid.Δxᶠᶜᵃ, old_grid.Δxᶜᶠᵃ, old_grid.Δxᶠᶠᵃ, old_grid.Δxᶜᶜᵃ,
old_grid.Δyᶠᶜᵃ, old_grid.Δyᶜᶠᵃ,
old_grid.Azᶠᶜᵃ, old_grid.Azᶜᶠᵃ, old_grid.Azᶠᶠᵃ, old_grid.Azᶜᶜᵃ)
Expand All @@ -44,7 +44,7 @@ function on_architecture(new_arch::Distributed, old_grid::RectilinearGrid)
child_arch = child_architecture(new_arch)
old_properties = (old_grid.Δxᶠᵃᵃ, old_grid.Δxᶜᵃᵃ, old_grid.xᶠᵃᵃ, old_grid.xᶜᵃᵃ,
old_grid.Δyᵃᶠᵃ, old_grid.Δyᵃᶜᵃ, old_grid.yᵃᶠᵃ, old_grid.yᵃᶜᵃ,
old_grid.Δzᵃᵃᶠ, old_grid.Δzᵃᵃᶜ, old_grid.zᵃᵃᶠ, old_grid.zᵃᵃᶜ)
old_grid.z)

new_properties = Tuple(on_architecture(child_arch, p) for p in old_properties)

Expand Down
Loading