You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The documentation about how GradientBoundaryConditions are implemented suggests that the user specifies a value $\gamma$ as the boundary-normal component of the gradient vector (with an implied outward-normal orientation), $\gamma = \hat{\mathbf{n}} \cdot \nabla c = \gamma$.
By contrast, my reading of the source code is that the GradientBoundaryConditions are used to specify $\hat{\mathbf{x}}_{i} \cdot \nabla c = \gamma$.
Because the outward unit normal vector at the right boundaries point in the same directions as the coordinate unit vectors, the two implementations give the same answer anyway: $\hat{\mathbf{x}}_{i} \cdot \nabla c = \hat{\mathbf{n}} \cdot \nabla c$.
The problem arises for the left boundary, where the gradient is implemented with as $\hat{\mathbf{x}}_{i} \cdot \nabla c = \gamma$, which has the opposite sign of $\hat{\mathbf{n}} \cdot \nabla c$ because the outward vector at the left boundaries point in the direction of $-\hat{\mathbf{x}}_{i}$.
##### Very Important Note: For FluxBoundaryCondition,##### we assume fluxes are directed along the "inward-facing normal".##### For example, east_immersed_flux = - user_flux.##### With this convention, positive fluxes _increase_ boundary-adjacent##### cell values, and negative fluxes _decrease_ them.#####
The text was updated successfully, but these errors were encountered:
Contributing to my confusion is that I think the documentation has a typo in that there is a sign error between equations (3) and (4) of the description of the implementation of the Gradient Boundary Condition. I think $c_{i,j,0}$ and $c_{i,j,1}$ should maybe be swapped in eq. (3)?
hdrake
added a commit
to hdrake/internal-tide-mixing
that referenced
this issue
Jul 10, 2024
- See discussion in CliMA/Oceananigans.jl#3651
for why I think the BCs need to be changed.
- Removed unnecessary comments.
- Renamed some variables to be more human-readable
- Added some comments where I thought it would be useful
The documentation about how$\gamma$ as the boundary-normal component of the gradient vector (with an implied outward-normal orientation), $\gamma = \hat{\mathbf{n}} \cdot \nabla c = \gamma$ .
GradientBoundaryCondition
s are implemented suggests that the user specifies a valueBy contrast, my reading of the source code is that the$\hat{\mathbf{x}}_{i} \cdot \nabla c = \gamma$ .
GradientBoundaryCondition
s are used to specifyBecause the outward unit normal vector at the right boundaries point in the same directions as the coordinate unit vectors, the two implementations give the same answer anyway:$\hat{\mathbf{x}}_{i} \cdot \nabla c = \hat{\mathbf{n}} \cdot \nabla c$ .
The problem arises for the left boundary, where the gradient is implemented with as$\hat{\mathbf{x}}_{i} \cdot \nabla c = \gamma$ , which has the opposite sign of $\hat{\mathbf{n}} \cdot \nabla c$ because the outward vector at the left boundaries point in the direction of $-\hat{\mathbf{x}}_{i}$ .
A similar subtlety applies to the sign convention of user-specified fluxes, as explained in the documentation:
and commented in a relevant part of the source code:
The text was updated successfully, but these errors were encountered: