Hi
Nils, thank you for your reply.
Currently I am computing the divergence right after calling the solvePressure function. I still have not found why I obtain these results. Now I think I'm computing the divergence
in a wrong way.
This is what I'm currently doing:
1. After calling the solvePressure function I copy the velocity field to a numpy array and then I obtain the corresponding X and Y components. (npVel is a numpy array previously defined as: "npVel = np.ones( [width, height, 3], dtype=np.float32 )" to contain the velocity field where width and heigh correspond to the grid resolution).
# Pass vel to npVel array
copyGridToArrayMAC( target=npVel, source=vel )
# Divergence Computation
npU = npVel[:, :, 0]
npV = npVel[:, :, 1]
2. I call my divergence function and print the colormap:
g = divergence([npU, npV])
# Graphics
plt.pcolormesh(g)
plt.colorbar()
plt.show()
The divegence function is pretty simple, it takes advantage of the np.gradient function in Numpy. Explicitly the funciton is:
def divergence(f):
num_dims = len(f)
return np.ufunc.reduce(np.add, [np.gradient(f[i], axis=i) for i in range(num_dims)])
The default delta x and delta y in the np.gradient computation is 1. It uses a first order one sided forwar/backward difference approximation at the boundaries and a second order accurate central difference in the rest of the points.
I will gladly explain in more details any of the previous points.
Finally, can you tell me what RHS stands for? I habe been searching in the web with no success.
Really grateful
Jorge