Jos Stam's "Stable Fluids" boundary conditions
It's Dirichlet boundary condition. The quantities at domain boundaries will take either the same value as its inner neighbor or the negated value, depending on the condition $\mathbf{b}$. Take velocity field for instance, velocity of fluid will either gets reflected or not change at domain boundary. The condition $\mathbf{b}$ is a user option, $\mathbf{b}==1$ is used to set reflected values at the horizonal boundaries, and $\mathbf{b}==2$ is to set reflected values at vertical boundaries. To be more clear:


$\mathbf{b}==1$: field values at horizonal boundaries get reflected, field values at vertical boundaries do not change.
$\mathbf{b}==2$: field values at vertical boundaries get reflected, field values at horizonal boundaries do not change.
$\mathbf{b}== other\ value$: field values at neither vertical nor horizonal boundaries do not change. 


set_bnd could be called multiple times to set desired boundary values.