Open hdrake opened 3 months ago
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)?
The documentation about how
GradientBoundaryCondition
s 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
GradientBoundaryCondition
s 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}$.
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: