-
Notifications
You must be signed in to change notification settings - Fork 186
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
Vector Invariant Formulation of the ShallowWaterModel
#2522
Vector Invariant Formulation of the ShallowWaterModel
#2522
Conversation
Wonderful to see @simone-silvestri ! Please let me know how I can help. One question, could we change the name of this PR to Also, as a test problem, could we use the same initial conditions as we have in the Bickley Jet example? Might make for a good comparison. |
ShallowWaterModel
ShallowWaterModel
sounds like a good idea! |
You probably also want to fix #1866 I think what makes the most sense is to store velocities (AbstractOperations) inside the velocities = (u = uh / h, v = vh / h) (these have the correct location as well, which can be checked) then use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great so far!
src/Models/ShallowWaterModels/shallow_water_advection_operators.jl
Outdated
Show resolved
Hide resolved
src/Models/ShallowWaterModels/shallow_water_advection_operators.jl
Outdated
Show resolved
Hide resolved
Perhaps if formulation isa ConservativeFormulation
solution = (uh = XFaceField(grid),
vh = YFaceField(grid),
h = CenterField(grid))
else
solution = (u = XFaceField(grid),
v = YFaceField(grid),
h = CenterField(grid))
end |
@francispoulin I have implemented the vector invariant / non conservative form of the equations. I have also separated the advection between momentum / velocity, height and tracers. Now we have to think at some nice test cases, I ll start with the bickley jet experiment |
That is great news @simone-silvestri, and very fast! Yes, I think the Bickley jet is a good place to start. I'll think of others that would be fun. When we put in closure we could do a gyre with a Munk layer. For now, we could do bottom drag and get a Stommel layer. I can look for a reference to compare this too if you like the idea? |
…iMA/Oceananigans.jl into ss-fjp/non-conservative-shallow-water
@@ -32,6 +32,8 @@ function calculate_tendencies!(model::ShallowWaterModel) | |||
model.grid, | |||
model.gravitational_acceleration, | |||
model.advection, | |||
model.tracer_advection, | |||
model.height_advection, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be better to use advection.tracers
and advection.mass
, so that we don't have to refactor this model too when we change the advection scheme implementations for nonhydrostatic and hydrostatic models in #2454
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its ok if you don't want to, just trying to be lazy
@@ -115,7 +125,7 @@ compute!(ω) | |||
|
|||
# and finally set the "true" initial condition with noise, | |||
|
|||
set!(model, uh = uhⁱ) | |||
formulation isa VectorInvariantFormulation ? set!(model, u = uhⁱ) : set!(model, uh = uhⁱ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the case of vector invariant, should we set u = u^i
and not the mass flux?
@@ -77,19 +83,19 @@ function calculate_interior_tendency_contributions!(tendencies, | |||
|
|||
barrier = Event(device(arch)) | |||
|
|||
Guh_event = calculate_Guh_kernel!(tendencies.uh, | |||
Guh_event = calculate_Guh_kernel!(tendencies[1], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that the only difference between the next 3 steps is the index, would it be more compact to put these in a for loop over 1,2,3
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it written out personally!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am happy either way. Just a thought.
U.uh[i, j, k] += Δt * (γⁿ * Gⁿ.uh[i, j, k] + ζⁿ * G⁻.uh[i, j, k]) | ||
U.vh[i, j, k] += Δt * (γⁿ * Gⁿ.vh[i, j, k] + ζⁿ * G⁻.vh[i, j, k]) | ||
U.h[i, j, k] += Δt * (γⁿ * Gⁿ.h[i, j, k] + ζⁿ * G⁻.h[i, j, k]) | ||
U[1][i, j, k] += Δt * (γⁿ * Gⁿ[1][i, j, k] + ζⁿ * G⁻[1][i, j, k]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could loop over these three too, right?
U.uh[i, j, k] += Δt * γ¹ * G¹.uh[i, j, k] | ||
U.vh[i, j, k] += Δt * γ¹ * G¹.vh[i, j, k] | ||
U.h[i, j, k] += Δt * γ¹ * G¹.h[i, j, k] | ||
U[1][i, j, k] += Δt * γ¹ * G¹[1][i, j, k] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Loop?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like it written out.
The main thing to fix here are the errors in units in advection terms etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Look great! This will be very easy to use and build on to add topography and closure schemes.
I agree that we should not wait to get bathymetry working with @simone-silvestri and I were playing with a realistic global ocean model using the And we have 208 comments. That must be a record? |
OK, when test pass let's merge. And let's open an issue or PR for proper treatment of bathymetry in conservative formulation. |
Should we export Oceananigans.jl/src/Models/ShallowWaterModels/shallow_water_model.jl Lines 54 to 56 in d7588de
? |
If we don't export it then the user needs to import them manually? I am fine either way but have a slight preference for exporting it, so it makes things a little easier for the user. |
I agree. So I pushed 8eaf216. If there are opposing opinions we can undo this. With this export we can do: julia> ShallowWaterModel(; gravitational_acceleration=1, grid, formulation=VectorInvariantFormulation(), momentum_advection = VectorInvariant()) instead of julia> ShallowWaterModel(; gravitational_acceleration=1, grid, formulation=Oceananigans.Models.ShallowWaterModels.VectorInvariantFormulation(), momentum_advection = VectorInvariant()) |
is there anything wrong with the regression? |
Co-authored-by: Gregory L. Wagner <wagner.greg@gmail.com>
I am not sure why it's not passing. I ll fix it, when it passes we can merge! |
…iMA/Oceananigans.jl into ss-fjp/non-conservative-shallow-water
omg, there is only one test pending... smells like merging is close by... |
Vorticity in near_global_lat_lon_1440_600__fine_surface.6.mp4and a single-layer near_global_lat_lon_1440_600_1_fine_surface.2.mp4both with flat bathymetry. The free surface model is using the implicit free surface solver with a long time-step. Note the difference in the color scale. (via @simone-silvestri and @francispoulin) |
The hydrostatic simulation was done by @francispoulin |
I 'll merge when the last test passes |
Omg |
As for now the
ShallowWaterModel
is implemented in a conservative form.This PR attempts to introduce a non-conservative form of the equation with a vector invariant formulation of advection
such that we can treat the advection with high order WENO reconstruction.
and
) and viscous term (#2403)
We should also think about introducing bathymetric terms (
with @francispoulin