Open boundary conditions using SplitExplicitFreeSurface#5351
Open boundary conditions using SplitExplicitFreeSurface#5351simone-silvestri wants to merge 94 commits intomainfrom
SplitExplicitFreeSurface#5351Conversation
@simone-silvestri that was fast! I will see if I can get to this at the end of the week, or @rafmudaf may be able to test first with our current Med config. |
| BoundaryCondition, | ||
| FluxBoundaryCondition, ValueBoundaryCondition, GradientBoundaryCondition, OpenBoundaryCondition, | ||
| PerturbationAdvection, | ||
| PerturbationAdvection, Flather, Radiation, |
There was a problem hiding this comment.
What's the difference between these three? Isn't Radiation a subset of PerturbationAdvection?
There was a problem hiding this comment.
I think it's the opposite. PerturbationAdvection requires specifying a phase velocity at the boundary while radiation computes it (from what I understood of perturbation advection)
There was a problem hiding this comment.
I think you could make the phase velocity computation the condition and then use perturbation advection?
There was a problem hiding this comment.
Heh, I mean in either case --- whether Radiation is a subset of PerturbationAdvection, or whether PerturbationAdvection is a subset of Radiation --- in either of those cases, we should not introduce a new type but instead reuse the same type to express both schemes.
There was a problem hiding this comment.
we should not introduce a new type but instead reuse the same type to express both schemes.
I'm not sure. Radiation schemes can differ widely in their internals. Having different scheme types for each one may be useful just for the sake of simplicity. That said, the name Radiation is pretty generic and I think most people would call PertubationAdvection, Orlanski, the oblique scheme, and even Flather, radiation schemes.
@simone-silvestri from talking to you at the conference it seems like what you're implementing here for the baroclinic flow is an Orkanski scheme, no?
There was a problem hiding this comment.
I'd say just replace the existing periodic one with this. We don't need both.
…ith `SplitExplicitFreeSurface` (#5378) * Validate any bc on nothing-dimension fields * Add U and V to field location map * Fix missing u, v reference * Add missing b_bg helper function for sponge layer * Maintain barotropic velocities for free surface Co-authored-by: Simone Silvestri <silvestri.simone0@gmail.com> * Add sea-surface height to field location map Co-authored-by: Simone Silvestri <silvestri.simone0@gmail.com> * Remove extra validation dispatch --------- Co-authored-by: Simone Silvestri <silvestri.simone0@gmail.com>
…ananigans.jl into ss/prepare-for-open-boundaries
…ananigans.jl into ss/prepare-for-open-boundaries
Can you show how you have set up the boundary conditions? |
I have: and then later: |
Don't you have to put a "target" for the u_obc_east = OpenBoundaryCondition(0, scheme=Radiation())
u_obc_south = OpenBoundaryCondition(0, scheme=Radiation())
v_obc_east = OpenBoundaryCondition(0, scheme=Radiation())
v_obc_south = OpenBoundaryCondition(0, scheme=Radiation())if you're going for a zero mass flux, for example. |
|
I think if we see that |
|
In the soliton case there is no background flow right? If so then PertubationAdvection is just relaxing to zero? |
Fair, but usually it's useful for models to have more than one option of radiation scheme. My impression from talking to ROMS and MITgcm users is that they tend to use different combinations of open BC for different problems, since it's hard to get one BC that works well across the board. |
If by relaxing you mean the nudging at the boundaries using the timescales then no, it's nudging to the analytical solution. I set it up that way to mimic having a solution from a parent domain. But yes, there's no mean flow in that example. |
| outflow_relaxation_timescale :: FT | ||
| inflow_relaxation_timescale :: FT |
There was a problem hiding this comment.
Can we keep it consistent with PerturbationAdvection and call these outflow_timescale and inflow_timescale?
|
I think this test case might be weirder than I thought. This is with periodic BCs: barotropic_soliton_split_explicit.mp4 |
|
Weird! That shouldn't happen though, right? On another note, after some testing I can see no difference between |
|
Hmmm, we might want to reduce the complexity of the case, something like a wave that exits the domain might be a good test (and a wave entering) |
|
@simone-silvestri in your simulation with periodic boundary conditions, did you by any chance leave the nudging and sponge layers on? |
|
Ah I hadn't check, indeed, if there are I left them |
|
I'm pretty sure that's creating the weird results then. |
I tried following closer to the example provided in internal_tide_open_boundaries.jl, and I am trying to set the boundaries to u and v velocities that are stored in CuArrays that are updated over time. To do this I tried (just showing u boundaries, v are identically set up): Which ultimately throws:
Thanks for the help with this! |
Have you tried running this on CPU? It might give a more descriptive error message. I think the signature for |
I switched to CPU, and it revealed that the signatures were wrong, as you suspected, however, I also had to drop p, and build the functions like: etc. However, now I get:
which makes me realize that in the internal_tide_open_boundaries.jl test case there are two signatures for tidal_forcing, one taking (z,t,p) and the other (i, grid::Oceananigans.Grids.AbstractGrid, clock). Perhaps OpenBoundaryCondition doesn't support discrete functions? Is there an equivalent to the "discrete_form=true" passed to Forcing()? Sorry if these are silly questions! |
Yes you have to pass BoundaryCondition(classification::AbstractBoundaryConditionClassification, condition::Function;
parameters = nothing,
discrete_form = false,
field_dependencies=())I just realised that you're just passing arrays, so you can actually just put the array directly as the grid = RectilinearGrid(topology = (Periodic, Bounded, Bounded), size = (10, 10, 10), extent = (1, 1, 1))
south_v = zeros(10, 10)
south_obc = OpenBoundaryCondition(south_v)Perhaps we need to note in the docstrings that all the boundary conditions take the kwargs of |
It doesn't make sense to me that we need to pass Also, we should discourage or discontinue support for arrays. As for the note, I'm not sure I understand the suggestion. The docstring should say something like "see the docstring for BoundaryCondition for kwargs", or copy/paste over. Is the docstring currently incomplete? |
help?> ValueBoundaryCondition
search: ValueBoundaryCondition
No documentation found.
Oceananigans.BoundaryConditions.ValueBoundaryCondition is a Function.
# 1 method for generic function "ValueBoundaryCondition" from Oceananigans.BoundaryConditions:
[1] ValueBoundaryCondition(val; kwargs...)
@ ~/.julia/packages/Oceananigans/r4zuV/src/BoundaryConditions/boundary_condition.jl:109so maybe it would be helpful to put something there just pointing to the |
|
Output of gaussian_pulse_open_boundaries.mp4 |
This PR implements open boundary conditions for the hydrostatic free surface model compatible with the split explicit free surface. The boundary conditions follow what discussed in #5229, meaning
Flatherboundary conditions for the barotropic component and "Orlanski" (Radiation) boundary conditions for the three-dimensional evolution.I need to clean up a bit the PR (for example Flather now stores the external values inside its own struct, but it would be probably better to store it in the
conditionof theboundary_conditionstruct.Since the flow of the algorithm has to change, because the barotropic correction needs to be done after filling up the boundary conditions for the 3d velocities, such that the barotropic components of the boundaries is consistent with the 2d evolution, some refactor is necessary and I would like to open a PR specifically for this (this is actually a positive because it means we can compute the entire
wvelocity in theupdate_statein distributed computations).There is an example that showcases the use of these boundary conditions which we can remove later on.
A part from all the changes that need to be done to clean up the code, this feature should be already fully functional and testable, so if you want to test it @vtamsitt you can give it a try
cc @tomchor