-
Notifications
You must be signed in to change notification settings - Fork 208
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
Remove Tullio dependency; take #2 and implement universally accurate CFL time-scale #3037
Conversation
Oceananigans.jl/src/Advection/cell_advection_timescale.jl Lines 1 to 18 in bcc34f0
|
Ok, it's doing the same thing, I'll just remove Tullio and use this for the CFL |
I am going to change a bit the definition to be in line with what we had before, so instead of @inline function cell_advection_timescaleᶜᶜᶜ(i, j, k, grid, u, v, w)
Δx = Δxᶠᶜᶜ(i, j, k, grid)
Δy = Δyᶜᶠᶜ(i, j, k, grid)
Δz = Δzᶜᶜᶠ(i, j, k, grid)
return @inbounds min(Δx / abs(u[i, j, k]),
Δy / abs(v[i, j, k]),
Δz / abs(w[i, j, k]))
end take all 3 dimensions @inline function cell_advection_timescaleᶜᶜᶜ(i, j, k, grid, u, v, w)
Δx = Δxᶠᶜᶜ(i, j, k, grid)
Δy = Δyᶜᶠᶜ(i, j, k, grid)
Δz = Δzᶜᶜᶠ(i, j, k, grid)
return @inbounds 1 / (abs(u[i, j, k]) / Δx +
abs(v[i, j, k]) / Δy +
abs(w[i, j, k]) / Δz)
end it is a small difference but it is a more conservative definition (and usually used in n-dimensional cases) |
Looks good. Do we want this |
I guess there is diffusive cfl...? |
return @inbounds 1 / (abs(u[i, j, k]) / Δx + | ||
abs(v[i, j, k]) / Δy + | ||
abs(w[i, j, k]) / Δz) |
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.
is this the proper way to compute CFL? I'll trust you on that... That's like the geometric mean of the timescales in each direction?
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.
Imagine a 2D situation, we start from
We have advection in x and y, by extension from the 1D CFL condition we can approximate the CFL condition as
This means that
where
The extension to 3D includes also the advection in z
This is just a choice, as to account for diagonal motion probably you can get away with a square root of 2 somewhere. But it is the usual definition of the CFL condition
https://en.wikipedia.org/wiki/Courant%E2%80%93Friedrichs%E2%80%93Lewy_condition
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.
Sounds good! Why don't we include all this in the docstring of the cell_advection
?
Ok, I was a bit unsure which CFL definition is the best, so I checked the 2D stability and I got a slightly better proof. |
Co-authored-by: Gregory L. Wagner <[email protected]>
src/Diagnostics/cfl.jl
Outdated
|
||
return min_timescale | ||
end | ||
accurate_cell_advection_timescale(model) = cell_advection_timescale(model.grid, model.velocities) |
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.
Why we would keep the function accurate_cell_advection_timescale
as a duplicate of cell_advection_timescale
? The word "accurate" is meaningless now.
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.
Agree!
merge? |
Take two on PR #2252
i.e. use AbstractOperations to calculate the CFL instead of Tullio.jl