Skip to content
Open
Show file tree
Hide file tree
Changes from 250 commits
Commits
Show all changes
519 commits
Select commit Hold shift + click to select a range
00cf837
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 11, 2025
bd39907
back on some stuff
simone-silvestri Sep 11, 2025
c7bc307
ok let's go!
simone-silvestri Sep 11, 2025
766edaf
ok this is working
simone-silvestri Sep 11, 2025
18b97c8
use this one
simone-silvestri Sep 11, 2025
b140cbc
cmon almost there
simone-silvestri Sep 11, 2025
6cc2e77
remove the matrix solver first
simone-silvestri Sep 12, 2025
40f5748
Merge remote-tracking branch 'origin/main' into ss/remove-matrix-solver
simone-silvestri Sep 12, 2025
063da11
Merge branch 'main' into ss/remove-matrix-solver
simone-silvestri Sep 12, 2025
66507e3
remove more stuff
simone-silvestri Sep 12, 2025
bd94021
Merge branch 'ss/remove-matrix-solver' of github.com:CliMA/Oceananiga…
simone-silvestri Sep 12, 2025
a283c75
upload
simone-silvestri Sep 12, 2025
767e63a
restore targets
simone-silvestri Sep 12, 2025
9b75574
Merge remote-tracking branch 'origin/ss/remove-matrix-solver' into ss…
simone-silvestri Sep 12, 2025
c0dc82c
try if this works
simone-silvestri Sep 12, 2025
0d4075e
remove the show
simone-silvestri Sep 12, 2025
b47de18
fix double definition
simone-silvestri Sep 12, 2025
7ad870c
save one line
simone-silvestri Sep 12, 2025
4665ee4
pass nothing
simone-silvestri Sep 12, 2025
7758430
pass this
simone-silvestri Sep 12, 2025
3c12819
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 17, 2025
6e6a17b
fix all tests
simone-silvestri Sep 18, 2025
49c6a0c
remove the shows
simone-silvestri Sep 18, 2025
5e54a02
remove `map`
simone-silvestri Sep 18, 2025
2d55080
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 18, 2025
48842d0
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 19, 2025
1a1ab47
add a forcing
simone-silvestri Sep 19, 2025
fa9d3a4
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 20, 2025
ae4fe89
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 22, 2025
c90859d
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 23, 2025
b59a993
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 23, 2025
b3175de
Merge remote-tracking branch 'origin/main' into ss/reformulate-hydros…
simone-silvestri Sep 23, 2025
713ae0d
chnage
simone-silvestri Sep 23, 2025
6185f76
fix double include
simone-silvestri Sep 23, 2025
1205129
fix the output synchronization
simone-silvestri Sep 25, 2025
a2ede5c
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 25, 2025
eebff7b
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Sep 25, 2025
a11e985
new RK3 formulation
simone-silvestri Sep 25, 2025
1060ed3
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Sep 25, 2025
54889fb
3-stages
simone-silvestri Sep 25, 2025
f239d42
some more changes
simone-silvestri Sep 25, 2025
88fd0aa
add this to the dissipation
simone-silvestri Sep 25, 2025
ce68c00
ok this works up to RK40
simone-silvestri Sep 25, 2025
69bb785
test a bit more high and low-order split RK schemes
simone-silvestri Sep 25, 2025
388f5f5
remove vestigial code
simone-silvestri Sep 25, 2025
a3d63fe
promote type
simone-silvestri Sep 25, 2025
269372d
only if it is static!
simone-silvestri Sep 25, 2025
882036c
add a nonhydrostatic ab2 step
simone-silvestri Sep 25, 2025
ca6b464
some more changes
simone-silvestri Sep 25, 2025
829ee72
variance dissipation
simone-silvestri Sep 25, 2025
2995d54
Update barotropic_split_explicit_corrector.jl
simone-silvestri Sep 26, 2025
103359e
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 29, 2025
f7d09d4
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Sep 29, 2025
db2ff89
make tests start
simone-silvestri Sep 29, 2025
3fbc4ed
correct tripolar test
simone-silvestri Sep 29, 2025
065fd00
fix single column mode
simone-silvestri Sep 29, 2025
d06c9ec
add AB2 for nonhydrostatic
simone-silvestri Sep 29, 2025
33acaf3
add ab2_step_field!
simone-silvestri Sep 29, 2025
cc1887a
at least nonhydrostatic should work
simone-silvestri Sep 29, 2025
80ffcee
some fixes
simone-silvestri Sep 29, 2025
0c857a0
some bugfixes
simone-silvestri Sep 29, 2025
54978cd
substep
simone-silvestri Sep 29, 2025
743e4f5
simplify substepping
simone-silvestri Sep 29, 2025
cf0b011
fix everything but the hydrostatic model
simone-silvestri Sep 29, 2025
67a2309
update the hydrostatic step
simone-silvestri Sep 29, 2025
acbee4e
go again
simone-silvestri Sep 29, 2025
9725a97
cache previous tendencies outside
simone-silvestri Sep 29, 2025
ac8acb7
fix shallow water model
simone-silvestri Sep 29, 2025
ee694e3
nonhydrostatic should be ready
simone-silvestri Sep 29, 2025
6822241
just pass the name
simone-silvestri Sep 29, 2025
f6fef2e
remove the show method
simone-silvestri Sep 29, 2025
394390e
need to pass the field!
simone-silvestri Sep 29, 2025
9dad1ca
implicit step is done on the stage dt
simone-silvestri Sep 29, 2025
21ed24e
more changes
simone-silvestri Sep 29, 2025
0ceb353
test only on the RK steppers
simone-silvestri Sep 29, 2025
98bca31
correct the shallow water model
simone-silvestri Sep 29, 2025
f5c9d33
fix this
simone-silvestri Sep 29, 2025
35b3c6b
fix SWM
simone-silvestri Sep 29, 2025
778edc8
fix couple more tests
simone-silvestri Sep 29, 2025
9ca7325
better
simone-silvestri Sep 29, 2025
9e944e9
this seems to work!
simone-silvestri Sep 29, 2025
85dae05
fix
simone-silvestri Sep 29, 2025
3b2d84d
do not include the explicit free surface for the moment
simone-silvestri Sep 29, 2025
5847b59
fix reactant tests
simone-silvestri Sep 29, 2025
7a7b2a5
do not test multiregion until we are aure
simone-silvestri Sep 29, 2025
57c3c97
remove another small file
simone-silvestri Sep 29, 2025
dc239c7
add this
simone-silvestri Sep 29, 2025
5a8723b
Merge branch 'main' into ss/optimize-weno
simone-silvestri Sep 30, 2025
d8c97f5
add this
simone-silvestri Sep 30, 2025
3fadd7c
new test
simone-silvestri Sep 30, 2025
a50494d
correct barotropic mode
simone-silvestri Sep 30, 2025
21db5ef
small fixes
simone-silvestri Sep 30, 2025
fab2f6d
fix couple of tests
simone-silvestri Sep 30, 2025
fd2480b
more changes
simone-silvestri Sep 30, 2025
5525fb6
correct barotropic mode
simone-silvestri Sep 30, 2025
38a80f5
this for the moment
simone-silvestri Sep 30, 2025
46d50c7
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Sep 30, 2025
eeb34aa
I will solve this tomorrow
simone-silvestri Sep 30, 2025
eb2a9c8
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Sep 30, 2025
d3fd74a
go with it
simone-silvestri Oct 1, 2025
303af69
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 1, 2025
db69388
fix device!
simone-silvestri Oct 1, 2025
f427be2
couple of fixes
simone-silvestri Oct 1, 2025
8532535
add a test
simone-silvestri Oct 1, 2025
39787e0
Bump patch release version 0.99.3
navidcy Oct 1, 2025
709be18
Update test_distributed_architectures.jl
simone-silvestri Oct 1, 2025
0a5167d
Modify ROCGPU device function for AMD compatibility
simone-silvestri Oct 1, 2025
b7ffe6a
Update architecture check for CUDAGPU
navidcy Oct 1, 2025
626bf9f
remove stray spaces
navidcy Oct 1, 2025
3d40eea
fix
simone-silvestri Oct 1, 2025
060d31a
Merge remote-tracking branch 'origin/ss/fix-distributed-memory-issue'…
simone-silvestri Oct 1, 2025
a1b38e3
Merge remote-tracking branch 'origin/ss/optimize-weno' into ss/reform…
simone-silvestri Oct 1, 2025
6b07b8e
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 1, 2025
c221bb8
fix the immersed problem
simone-silvestri Oct 1, 2025
eff67b5
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 1, 2025
db647c8
small fix
simone-silvestri Oct 1, 2025
dcfd9f5
add this
simone-silvestri Oct 2, 2025
7f1be57
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 2, 2025
e5be8a3
Update src/Advection/reconstruction_coefficients.jl
simone-silvestri Oct 2, 2025
9b07df6
test this
simone-silvestri Oct 2, 2025
9fcfe54
add a conservation test for distributed architectures
simone-silvestri Oct 2, 2025
91c2d8d
bugfix
simone-silvestri Oct 3, 2025
d723abd
Update src/Models/HydrostaticFreeSurfaceModels/pcg_implicit_free_surf…
simone-silvestri Oct 3, 2025
7ca87ac
reintroduce WENO11
simone-silvestri Oct 3, 2025
c854bf4
adding coefficients
simone-silvestri Oct 3, 2025
91cc41a
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 3, 2025
579b409
adding in the smoothness
simone-silvestri Oct 3, 2025
1ce4e4a
Merge branch 'ss/optimize-weno' of github.com:CliMA/Oceananigans.jl i…
simone-silvestri Oct 3, 2025
444f7b6
complete 11th order implementation
simone-silvestri Oct 3, 2025
97f8a70
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 3, 2025
1062702
small test
simone-silvestri Oct 3, 2025
312f620
bugfix
simone-silvestri Oct 3, 2025
5b553e3
Merge branch 'ss/optimize-weno' of github.com:CliMA/Oceananigans.jl i…
simone-silvestri Oct 3, 2025
31c5d7a
another bugfix
simone-silvestri Oct 3, 2025
18873fc
fix all coefficients
simone-silvestri Oct 3, 2025
1d216f1
fix catke RK
simone-silvestri Oct 3, 2025
7f19f0f
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 6, 2025
ed57c81
add order 11
simone-silvestri Oct 6, 2025
e49ba2b
added the different schemes
simone-silvestri Oct 6, 2025
c531a7e
bugfix
simone-silvestri Oct 6, 2025
c026077
fix all tests
simone-silvestri Oct 6, 2025
1a440fa
fixed all the orders
simone-silvestri Oct 6, 2025
9a7487c
fix all tests
simone-silvestri Oct 6, 2025
b455d76
try it like this
simone-silvestri Oct 6, 2025
1e83747
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 6, 2025
54da012
some more changes
simone-silvestri Oct 6, 2025
a70b84c
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 6, 2025
3465cd0
add sixth order also for immersed boundaries
simone-silvestri Oct 6, 2025
fe4c822
remove this for the moment
simone-silvestri Oct 6, 2025
51a6664
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 7, 2025
de2b59f
ok this now works
simone-silvestri Oct 7, 2025
6aac95d
works for distributed
simone-silvestri Oct 7, 2025
637596d
remove the compute tendencies in update state
simone-silvestri Oct 8, 2025
599f392
start fixing up tests
simone-silvestri Oct 8, 2025
ec54de3
same formulation for AB2
simone-silvestri Oct 8, 2025
6718991
this works
simone-silvestri Oct 8, 2025
2826f9b
do not compute tendencies in the shallow water
simone-silvestri Oct 8, 2025
40d7eed
back to how it was
simone-silvestri Oct 8, 2025
e1589e5
rmeove the storage space
simone-silvestri Oct 8, 2025
6378637
integers instead of floats
simone-silvestri Oct 8, 2025
b354f4a
all integers
simone-silvestri Oct 8, 2025
4f89324
some space
simone-silvestri Oct 8, 2025
fe84adf
test like this
simone-silvestri Oct 8, 2025
0bdf00d
try with Int32
simone-silvestri Oct 8, 2025
c164206
more improvements
simone-silvestri Oct 8, 2025
5064482
more updates
simone-silvestri Oct 8, 2025
0aa1f3a
commnt
simone-silvestri Oct 8, 2025
2d9cbca
fix zstar tests
simone-silvestri Oct 8, 2025
2dba4cb
add also AB2
simone-silvestri Oct 8, 2025
bf99394
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 9, 2025
1559975
chnage the example for the moment
simone-silvestri Oct 9, 2025
4b62ae3
limit correctly the scheme
simone-silvestri Oct 9, 2025
2280a4f
new changes
simone-silvestri Oct 9, 2025
89ad73d
small mistake
simone-silvestri Oct 9, 2025
59a51ad
Merge remote-tracking branch 'origin/ss/optimize-weno' into ss/reform…
simone-silvestri Oct 9, 2025
57a0381
we step the tracers at the end
simone-silvestri Oct 9, 2025
1d08364
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 9, 2025
6979dbb
why would this slow down?
simone-silvestri Oct 9, 2025
055dda8
why is this not running?
simone-silvestri Oct 9, 2025
abe8fe8
go back to upwind
simone-silvestri Oct 9, 2025
c09d818
improve the benchmark
simone-silvestri Oct 10, 2025
8cb8e17
improve benchmarks
simone-silvestri Oct 10, 2025
632b76f
not sure why this was different...
simone-silvestri Oct 10, 2025
7def910
Merge branch 'main' into ss/improve-benchmarks-pipeline
simone-silvestri Oct 10, 2025
91317f4
Allow scalar assignment in benchmark tests
simone-silvestri Oct 10, 2025
c4d3141
Merge remote-tracking branch 'origin/ss/improve-benchmarks-pipeline' …
simone-silvestri Oct 10, 2025
a087afe
this is the correct way to do it
simone-silvestri Oct 10, 2025
4cf6043
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 11, 2025
edf54df
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 13, 2025
4ae301c
correct
simone-silvestri Oct 13, 2025
52bfc01
changes
simone-silvestri Oct 13, 2025
6dfe3ed
bugfix
simone-silvestri Oct 13, 2025
9463b78
comment
simone-silvestri Oct 13, 2025
19a13f5
add the bias
simone-silvestri Oct 13, 2025
62d01ba
Merge branch 'main' into ss/optimize-weno
simone-silvestri Oct 13, 2025
656f44a
mask correct fields
simone-silvestri Oct 13, 2025
ae8803a
introduce correct biases
simone-silvestri Oct 13, 2025
89f5814
this should work
simone-silvestri Oct 13, 2025
c301878
Merge remote-tracking branch 'origin/ss/optimize-weno' into ss/reform…
simone-silvestri Oct 13, 2025
39767b2
immersed order
simone-silvestri Oct 13, 2025
c520979
immersed order
simone-silvestri Oct 13, 2025
60031e3
disambiguate
simone-silvestri Oct 13, 2025
611b5da
make sure this works
simone-silvestri Oct 13, 2025
7c5596c
abstract underlying grid
simone-silvestri Oct 13, 2025
ccf6747
6th order...
simone-silvestri Oct 13, 2025
948d003
fix bugs
simone-silvestri Oct 13, 2025
6bda30e
Update src/Advection/weno_coefficients.jl
simone-silvestri Oct 13, 2025
8461f1b
fill halo every time
simone-silvestri Oct 13, 2025
4b2f590
bugfix
simone-silvestri Oct 13, 2025
41f957d
bugfix
simone-silvestri Oct 13, 2025
a7a9c6f
fill halo in correct spot
simone-silvestri Oct 13, 2025
69c25b5
comment
simone-silvestri Oct 13, 2025
52e0c2d
back to how it was
simone-silvestri Oct 14, 2025
39057c9
fix the tests
simone-silvestri Oct 14, 2025
f87c5c2
Merge branch 'ss/optimize-weno' of github.com:CliMA/Oceananigans.jl i…
simone-silvestri Oct 14, 2025
c9fb757
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 14, 2025
1e3fed5
introduce cache tendencies
simone-silvestri Oct 14, 2025
ca8bb2f
Merge branch 'ss/optimize-weno' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 14, 2025
fb21894
cache field tendencies
simone-silvestri Oct 14, 2025
3ea0694
cache field tendencies
simone-silvestri Oct 14, 2025
e7d1c18
do not compute tendencies
simone-silvestri Oct 14, 2025
3926e60
add also shallow water
simone-silvestri Oct 14, 2025
fe97699
correct the implicit solver
simone-silvestri Oct 14, 2025
ce5367e
add the caching
simone-silvestri Oct 14, 2025
88b5015
moew bugfixes
simone-silvestri Oct 14, 2025
b18adb9
add fields(model)
simone-silvestri Oct 14, 2025
1cae6d6
go back to previous advection
simone-silvestri Oct 14, 2025
3810d84
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 14, 2025
40a5bb7
try this
simone-silvestri Oct 15, 2025
6bd3fb1
fix a couple of tests
simone-silvestri Oct 17, 2025
8a09ceb
back to how it was
simone-silvestri Oct 17, 2025
bb139d2
Merge remote-tracking branch 'origin/main' into ss/reformulate-hydros…
simone-silvestri Oct 17, 2025
d7b22af
show condition
simone-silvestri Oct 17, 2025
9853d65
send it
simone-silvestri Oct 17, 2025
17b1fac
more tests
simone-silvestri Oct 17, 2025
0676e44
comment
simone-silvestri Oct 17, 2025
fbbe5fe
fix the geostrophic adjustment
simone-silvestri Oct 17, 2025
a7469c8
correct
simone-silvestri Oct 17, 2025
5f05381
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 20, 2025
637daa7
not yet
simone-silvestri Oct 20, 2025
1b63922
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 20, 2025
87d53c5
more changes
simone-silvestri Oct 20, 2025
c3446d2
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 25, 2025
2f62b9e
remove QAB2 conservation testset
simone-silvestri Oct 27, 2025
692ac92
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 27, 2025
dbc37f8
Merge branch 'main' into ss/reformulate-hydrostatic-model-2
simone-silvestri Oct 27, 2025
915ec93
back to this default
simone-silvestri Oct 27, 2025
c492ed1
Merge branch 'ss/reformulate-hydrostatic-model-2' of github.com:CliMA…
simone-silvestri Oct 27, 2025
92173d9
fix another bug
simone-silvestri Oct 27, 2025
48eb436
fix shallow water
simone-silvestri Oct 27, 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
2 changes: 1 addition & 1 deletion .buildkite/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ steps:
- "🦢 shallow_water"
- "🐳 simulation"
- "🍂 lagrangian_particles"
- "🧅 multi_region"
# - "🧅 multi_region"
- "🦧 scripts"
- "👺 enzyme"
- "🍱 xesmf"
Expand Down
8 changes: 8 additions & 0 deletions ext/OceananigansNCDatasetsExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ using Dates: AbstractTime, UTC, now
using Printf: @sprintf
using OrderedCollections: OrderedDict

using Oceananigans: fields
using Oceananigans: initialize!, prettytime, pretty_filesize, AbstractModel
using Oceananigans.Architectures: CPU, GPU, on_architecture
using Oceananigans.AbstractOperations: KernelFunctionOperation, AbstractOperation
using Oceananigans.DistributedComputations: synchronize_communication!
using Oceananigans.BuoyancyFormulations: BuoyancyForce, BuoyancyTracer, SeawaterBuoyancy, LinearEquationOfState
using Oceananigans.Fields
using Oceananigans.Fields: Reduction, reduced_dimensions, reduced_location, location
Expand Down Expand Up @@ -1352,6 +1354,12 @@ Write output to netcdf file `output_writer.filepath` at specified intervals. Inc
every time an output is written to the file.
"""
function write_output!(ow::NetCDFWriter, model::AbstractModel)

# Synchronize model state if needed
for field in fields(model)
synchronize_communication!(field)
end
Copy link
Member

Choose a reason for hiding this comment

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

how related to this PR?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am trying to figure out how to distribute operations in time. I don't think this is necessary anymore.


# Start a new file if the file_splitting(model) is true
ow.file_splitting(model) && start_next_file(model, ow)
update_file_splitting_schedule!(ow.file_splitting, ow.filepath)
Expand Down
10 changes: 2 additions & 8 deletions ext/OceananigansReactantExt/TimeSteppers.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ using Oceananigans.Utils: @apply_regionally, apply_regionally!
using Oceananigans.TimeSteppers:
update_state!,
tick!,
compute_pressure_correction!,
correct_velocities_and_cache_previous_tendencies!,
step_lagrangian_particles!,
QuasiAdamsBashforth2TimeStepper,
compute_flux_bc_tendencies!
Expand Down Expand Up @@ -87,8 +85,7 @@ function time_step!(model::ReactantModel{<:QuasiAdamsBashforth2TimeStepper{FT}},
ab2_timestepper.χ = χ

# Full step for tracers, fractional step for velocities.
compute_flux_bc_tendencies!(model)
ab2_step!(model, Δt)
ab2_step!(model, Δt, callbacks)

tick!(model.clock, Δt)

Expand All @@ -105,10 +102,7 @@ function time_step!(model::ReactantModel{<:QuasiAdamsBashforth2TimeStepper{FT}},
model.clock.last_stage_Δt = Δt
end

compute_pressure_correction!(model, Δt)
correct_velocities_and_cache_previous_tendencies!(model, Δt)

update_state!(model, callbacks; compute_tendencies=true)
update_state!(model, callbacks)
step_lagrangian_particles!(model, Δt)

# Return χ to initial value
Expand Down
6 changes: 4 additions & 2 deletions src/Advection/Advection.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ import Base: show, summary, Callable
import Oceananigans.Grids: required_halo_size_x, required_halo_size_y, required_halo_size_z
import Oceananigans.Architectures: on_architecture

using Oceananigans.Grids: XFlatGrid, YFlatGrid, ZFlatGrid

abstract type AbstractAdvectionScheme{B, FT} end
abstract type AbstractCenteredAdvectionScheme{B, FT} <: AbstractAdvectionScheme{B, FT} end
abstract type AbstractUpwindBiasedAdvectionScheme{B, FT} <: AbstractAdvectionScheme{B, FT} end
Expand All @@ -52,11 +54,11 @@ abstract type AbstractUpwindBiasedAdvectionScheme{B, FT} <: AbstractAdvectionSch
# are constructed via metaprogramming. (The `advection_buffer` is the width of
# the halo region required for an advection scheme on a non-immersed-boundary grid.)
# An upper limit of `advection_buffer = 6` means we can build advection schemes up to
# `Centered(order=12`) and `UpwindBiased(order=11)`. The list can be extended in order to
# `Centered(order=10`) and `UpwindBiased(order=9)`. The list can be extended in order to
# compile schemes with higher orders; for example `advection_buffers = [1, 2, 3, 4, 5, 6, 8]`
# will compile schemes for `advection_buffer=8` and thus `Centered(order=16)` and `UpwindBiased(order=15)`.
# Note that it is not possible to compile schemes for `advection_buffer = 41` or higher.
const advection_buffers = [1, 2, 3, 4, 5, 6]
const advection_buffers = [1, 2, 3, 4, 5]
Copy link
Member

Choose a reason for hiding this comment

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

why?

Copy link
Member

Choose a reason for hiding this comment

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

we should compile past the recommended order. If order=9 is recommended we need order=11 to verify this.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Okay, I guess I'll take this suggestion for #4434, which, apart from this change, should be ready.


@inline Base.eltype(::AbstractAdvectionScheme{<:Any, FT}) where FT = FT

Expand Down
15 changes: 8 additions & 7 deletions src/Advection/adapt_advection_order.jl
Original file line number Diff line number Diff line change
Expand Up @@ -72,25 +72,26 @@ adapt_advection_order(advection, N, grid) = advection
##### Directional adapt advection order
#####

function adapt_advection_order(advection::Centered{B}, N::Int, grid::AbstractGrid) where B
function adapt_advection_order(advection::Centered{B, FT}, N::Int, grid::AbstractGrid) where {B, FT}
if N >= B
return advection
else
return Centered(; order=2N)
return Centered(FT; order=2N)
end
end

function adapt_advection_order(advection::UpwindBiased{B}, N::Int, grid::AbstractGrid) where B
function adapt_advection_order(advection::UpwindBiased{B, FT}, N::Int, grid::AbstractGrid) where {B, FT}
if N >= B
return advection
else
return UpwindBiased(; order=2N-1)
return UpwindBiased(FT; order=2N-1)
end
end
function adapt_advection_order(advection::WENO{B}, N::Int, grid::AbstractGrid) where B

function adapt_advection_order(advection::WENO{B, FT}, N::Int, grid::AbstractGrid) where {B, FT}
if N >= B
return advection
else
return WENO(order=2N-1)
return WENO(FT; order=2N-1)
end
end
end
84 changes: 46 additions & 38 deletions src/Advection/centered_reconstruction.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,62 @@
##### Centered advection scheme
#####

struct Centered{N, FT, CA} <: AbstractCenteredAdvectionScheme{N, FT}
buffer_scheme :: CA

Centered{N, FT}(buffer_scheme::CA) where {N, FT, CA} = new{N, FT, CA}(buffer_scheme)
end
struct Centered{N, FT} <: AbstractCenteredAdvectionScheme{N, FT} end

function Centered(FT::DataType=Oceananigans.defaults.FloatType; order = 2)

mod(order, 2) != 0 && throw(ArgumentError("Centered reconstruction scheme is defined only for even orders"))

N = Int(order ÷ 2)
if N > 1
buffer_scheme = Centered(FT; order=order-2)
else
buffer_scheme = nothing
end

return Centered{N, FT}(buffer_scheme)
N = Int(order ÷ 2)
return Centered{N, FT}()
end

Base.summary(a::Centered{N}) where N = string("Centered(order=", 2N, ")")

Base.show(io::IO, a::Centered{N, FT}) where {N, FT} =
print(io, summary(a), " \n",
"└── buffer_scheme: ", summary(a.buffer_scheme))


Adapt.adapt_structure(to, scheme::Centered{N, FT}) where {N, FT} = Centered{N, FT}(Adapt.adapt(to, scheme.buffer_scheme))
on_architecture(to, scheme::Centered{N, FT}) where {N, FT} = Centered{N, FT}(on_architecture(to, scheme.buffer_scheme))
Base.show(io::IO, a::Centered{N, FT}) where {N, FT} = summary(a)

const ACAS = AbstractCenteredAdvectionScheme

# left and right biased for Centered reconstruction are just symmetric!
@inline biased_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, args...)
@inline biased_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, args...)
@inline biased_interpolate_zᵃᵃᶠ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, scheme, args...)
@inline biased_interpolate_xᶜᵃᵃ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_xᶜᵃᵃ(i, j, k, grid, scheme, args...)
@inline biased_interpolate_yᵃᶜᵃ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_yᵃᶜᵃ(i, j, k, grid, scheme, args...)
@inline biased_interpolate_zᵃᵃᶜ(i, j, k, grid, scheme::ACAS, bias, args...) = symmetric_interpolate_zᵃᵃᶜ(i, j, k, grid, scheme, args...)

# uniform centered reconstruction
for buffer in advection_buffers, FT in fully_supported_float_types
@eval begin
@inline symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :x, false))
@inline symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :y, false))
@inline symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :z, false))

@inline symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :x, true))
@inline symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :y, true))
@inline symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, ::Centered{$buffer, $FT}, ψ::Callable, args...) = @inbounds @muladd $(calc_reconstruction_stencil(FT, buffer, :symmetric, :z, true))
@inline _biased_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_xᶠᵃᵃ(i, j, k, grid, scheme, c, args...)
@inline _biased_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_yᵃᶠᵃ(i, j, k, grid, scheme, c, args...)
@inline _biased_interpolate_zᵃᵃᶠ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_zᵃᵃᶠ(i, j, k, grid, scheme, c, args...)
@inline _biased_interpolate_xᶜᵃᵃ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_xᶜᵃᵃ(i, j, k, grid, scheme, c, args...)
@inline _biased_interpolate_yᵃᶜᵃ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_yᵃᶜᵃ(i, j, k, grid, scheme, c, args...)
@inline _biased_interpolate_zᵃᵃᶜ(i, j, k, grid, scheme::ACAS, bias, c, args...) = _symmetric_interpolate_zᵃᵃᶜ(i, j, k, grid, scheme, c, args...)

for (side, dir) in zip((:ᶠᵃᵃ, :ᵃᶠᵃ, :ᵃᵃᶠ), (:x, :y, :z))
for (F, bool) in zip((:Any, :(Base.Callable)), (false, true))
for FT in fully_supported_float_types
interp = Symbol(:symmetric_interpolate_, dir, side)
@eval begin
@inline $interp(i, j, k, grid, ::Centered{1, $FT}, red_order::Int, ψ::$F, args...) = @muladd $(stencil_reconstruction(FT, 1, :symmetric, dir, bool))

@inline function $interp(i, j, k, grid, ::Centered{2, $FT}, red_order::Int, ψ::$F, args...)
@muladd ifelse(red_order==1, $(stencil_reconstruction(FT, 1, :symmetric, dir, bool)),
$(stencil_reconstruction(FT, 2, :symmetric, dir, bool)))
end

@inline function $interp(i, j, k, grid, ::Centered{3, $FT}, red_order::Int, ψ::$F, args...)
@muladd ifelse(red_order==1, $(stencil_reconstruction(FT, 1, :symmetric, dir, bool)),
ifelse(red_order==2, $(stencil_reconstruction(FT, 2, :symmetric, dir, bool)),
$(stencil_reconstruction(FT, 3, :symmetric, dir, bool))))
end

@inline function $interp(i, j, k, grid, ::Centered{4, $FT}, red_order::Int, ψ::$F, args...)
@muladd ifelse(red_order==1, $(stencil_reconstruction(FT, 1, :symmetric, dir, bool)),
ifelse(red_order==2, $(stencil_reconstruction(FT, 2, :symmetric, dir, bool)),
ifelse(red_order==3, $(stencil_reconstruction(FT, 3, :symmetric, dir, bool)),
$(stencil_reconstruction(FT, 4, :symmetric, dir, bool)))))
end

@inline function $interp(i, j, k, grid, ::Centered{5, $FT}, red_order::Int, ψ::$F, args...)
@muladd ifelse(red_order==1, $(stencil_reconstruction(FT, 1, :symmetric, dir, bool)),
ifelse(red_order==2, $(stencil_reconstruction(FT, 2, :symmetric, dir, bool)),
ifelse(red_order==3, $(stencil_reconstruction(FT, 3, :symmetric, dir, bool)),
ifelse(red_order==4, $(stencil_reconstruction(FT, 4, :symmetric, dir, bool)),
$(stencil_reconstruction(FT, 5, :symmetric, dir, bool))))))
end
end
end
end
end
26 changes: 11 additions & 15 deletions src/Advection/flat_advective_fluxes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,15 @@ FlatGrids = [:XFG, :YFG, :ZFG, :XFG, :YFG, :ZFG]
for (dir, GridType) in zip((:xᶠᵃᵃ, :yᵃᶠᵃ, :zᵃᵃᶠ, :xᶜᵃᵃ, :yᵃᶜᵃ, :zᵃᵃᶜ), FlatGrids)
alt_symm_interp = Symbol(:_symmetric_interpolate_, dir)
alt_biased_interp = Symbol(:_biased_interpolate_, dir)
@eval begin
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::HOADV, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::LOADV, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::HOADV, ψ::Callable, args...) = @inbounds ψ(i, j, k, grid, args...)
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::LOADV, ψ::Callable, args...) = @inbounds ψ(i, j, k, grid, args...)
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::HOADV, ψ::Callable, ::AS, args...) = @inbounds ψ(i, j, k, grid, args...)
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::LOADV, ψ::Callable, ::AS, args...) = @inbounds ψ(i, j, k, grid, args...)

@inline $alt_biased_interp(i, j, k, grid::$GridType, ::HOADV, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::LOADV, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::HOADV, bias, ψ::Callable, args...) = ψ(i, j, k, grid, args...)
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::LOADV, bias, ψ::Callable, args...) = ψ(i, j, k, grid, args...)
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::HOADV, bias, ψ::Callable, ::AS, args...) = ψ(i, j, k, grid, args...)
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::LOADV, bias, ψ::Callable, ::AS, args...) = ψ(i, j, k, grid, args...)
for Scheme in [:Centered, :UpwindBiased, :WENO]
@eval begin
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::$Scheme, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::$Scheme, ψ::Callable, args...) = @inbounds ψ(i, j, k, grid, args...)
@inline $alt_symm_interp(i, j, k, grid::$GridType, ::$Scheme, ψ::Callable, ::AS, args...) = @inbounds ψ(i, j, k, grid, args...)

@inline $alt_biased_interp(i, j, k, grid::$GridType, ::$Scheme, ψ, args...) = @inbounds ψ[i, j, k]
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::$Scheme, bias, ψ::Callable, args...) = ψ(i, j, k, grid, args...)
@inline $alt_biased_interp(i, j, k, grid::$GridType, ::$Scheme, bias, ψ::Callable, ::AS, args...) = ψ(i, j, k, grid, args...)
end
end
end
end
Loading
Loading