-
Notifications
You must be signed in to change notification settings - Fork 193
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
(v0.85.0) Switching cells where fluxes are applied in ImmersedBoundaryCondition
to match FieldBoundaryConditions
' kwargs
#3142
Conversation
ImmersedBoundaryCondition
to match FieldBoundaryConditions
' kwargsImmersedBoundaryCondition
to match FieldBoundaryConditions
' kwargs
Wasn't immersed Couette flow doing the right thing previously? Which one is old and which is new? |
Those are
Effectively putting an immersed boundary on both the immersed top and the immersed bottom.
|
I'm confused. How does it get the right result in the first case? |
In main: since we write the immersed boundary condition as c_immersed_bc = ValueBoundaryCondition(1)
c_top_bc = ValueBoundaryCondition(-1)
c_bcs = FieldBoundaryConditions(immersed=c_immersed_bc, top=c_top_bc) immersed boundary conditions are defined on all facets, and in particular, what is important in this case, is that bc are assigned both at the I am here referring to the internals of the code (not the API) where we have a divergence of immersed fluxes defined as @inline Base.div(i, j, k, grid::AbstractGrid, loc, q_west, q_east, q_south, q_north, q_bottom, q_top) =
1 / volume(i, j, k, grid, loc...) * (δx_Ax_q(i, j, k, grid, loc, q_west, q_east) +
δy_Ay_q(i, j, k, grid, loc, q_south, q_north) +
δz_Az_q(i, j, k, grid, loc, q_bottom, q_top)) and by top and bottom I refer at The heavy lifting is done by the c_imm_bc = ValueBoundaryCondition(1)
c_top_bc = ValueBoundaryCondition(-1)
c_immersed_bc = ImmersedBoundaryCondition(bottom = c_imm_bc)
c_bcs = FieldBoundaryConditions(immersed=c_immersed_bc, top=c_top_bc) The simulation would not have had the intended outcome since in this case julia> c_immersed_bc = ImmersedBoundaryCondition(bottom = c_imm_bc)
ImmersedBoundaryCondition:
├── west: Nothing
├── east: Nothing
├── south: Nothing
├── north: Nothing
├── bottom: ValueBoundaryCondition: 1
└── top: Nothing with the |
on main in case of
and
this is the result immersed_couette_flow.mp4while
and
gives immersed_couette_flow.mp4 |
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.
Nice catch @Yixiao-Zhang and @simone-silvestri!
IMO this is kind of a serious bug. It affected several of my simulations, for example, and I'm just now finding out. So can we release a patch version with this fix soon please?
Should we discourage using |
I think it is good to use it in hydrostatic simulations where the aspect ratio is very high (for example drag on the sides should not be equal to drag on the bottom) |
Yes, I see now that it is basically a convenience feature (ie friendly), which allows users to build models that satisfy global constraints without having to, for example, compute the bottom surface area of their discrete geometry. More discussion on #3141 . My only misgiving is that I think it obscures the physics of a problem and can lead to confusion or modeling choices that don't make sense. That said, it's very difficult to achieve convenience without also allowing wrong modeling choices. |
@simone-silvestri @tomchor @Yixiao-Zhang I updated the docs on |
Probably makes sense to add a test to make sure this doesn't get reverted in the future too |
Also if we use a Monin-Obukhov-based drag law the drag coefficients will depend on the grid-spacing in that direction, meaning they'd need to be applied separately if the spacing is different in different directions. |
That's an interesting example. This wouldn't generalize to cut cells, right? Perhaps we need an abstraction that represents the distances to the boundary, for use within boundary conditions. That way we can ensure the distance to the boundary is computed correctly regardless of how the boundary is represented. As an aside, hasn't it been shown that MOST is not valid in complex terrain? (That wouldn't prevent it from still somehow improving model fidelity, at least in principle.) |
Agreed. Although I think that's for another PR, right?
Yes, although the discrepancy is less severe for neutral stability, which I suspect encompasses most of the simulations people have been using Oceananigans for. Interestingly, there's been a very recent attempt at generalization that looks pretty promising! |
For sure but if that case actually requires another abstraction that would mean we can safely recommend not using |
Co-authored-by: Tomas Chor <tomaschor@gmail.com>
@simone-silvestri bump patch version and merge? |
Actually now that I think about it, this is a breaking release. Idk how many people use this feature, but I wonder if we should do something similar to #2990 and throw a warning whenever |
I'd be in favor of always emitting a warning for |
ImmersedBoundaryCondition
to match FieldBoundaryConditions
' kwargsImmersedBoundaryCondition
to match FieldBoundaryConditions
' kwargs
see #3141
closes #3141
The results from
validation/immersed_boundaries/immersed_couette_flow.jl
from this branchimmersed_couette_flow.mp4