# Boundary conditions in fluid simulation

I'm working on a 2D fluid sim using vortex particles/"vortons" as described in Fluid Simulation for Video Games. Which I think is the same things as the "discrete vortex method". Basically you represent the fluid with a collection of particles with defined vorticity, and calculate the fluid velocity at a point by summing up the induced velocities of all the vortons using Biot–Savart's law (eg: $v = \frac{\omega \times (p_2-p_1)}{4\pi r^3}$, where $p_2-p_1$ is the difference in position between the sample point and the vorton, $w$ is the vorticity (a vector quantity in 3D), and $r$ is the Euclidean distance between the vorton and the sample point).

I'm trying to introduce a box in to the fluid and have it move back and forth and influence the fluid. Which means taking in to account the no-slip and no-through boundary conditions for the box. (That is, having the relative fluid velocity be 0 right at the box's boundary).

Right now I'm sampling the relative velocity of the box and the fluid at 80 points around the perimeter of the box. I also have 80 vortons placed near the perimeter of the box but offset a bit outward. I form a large matrix and solve for the vorticity values the vortons need to counteract the fluid's velocity at the sample points (using linear least squares).

This almost works, but I've noticed that the solution I get back is highly dependent on the exact layout of sample points and vortons.

Sometimes I get alternating patterns of vortons that spin in different directions (blue dots are vortons spinning counter clockwise, and red dots are vortons spinning clockwise):

Other times I get all the vorton's on the left side of the box spinning one way, and all the vortons on the other spinning the other way, like in this pic:

I think the second pic is what I actually want. I also think that the two different solutions imply that the system of equations I'm using is too underconstrained. Adding additional sample points sometimes helps, sometimes doesn't.

Are there any other boundary conditions I could add that would help me get the results I'm after? Intuitively I'm not doing anything to take in to account how strongly the fluid is disturbed at some given distance from the box. I'm thinking maybe I could add in conditions for the boundary layer limit. But I'm not sure exactly what that would look like.

Alternatively, is there any relevant literature I could look at for how vortex particle based fluid sims handle these sorts of boundary conditions?

I would try adding some regularization to the system, e.g. if you have an energy formulation, add a small multiple of $\Sigma||v_i||^2$. I think this corresponds to adding a $\lambda I$ term to the matrix you're solving. That should drive the system towards the second configuration.
A more complicated regularization would be a penalty on the "derivative", e.g. $\Sigma w_{ij}||v_i - v_j||^2$ where $w_{ij}$ decays with the distance.