Thank you for the iTutorials! They are very helpful to me.
I think there may be an issue with the Navier Stokes tutorial, though. When I copied the code into Jupyter and ran it, I did not see any velocity or pressure output in Netgen. I think the iTutorial code breaks because there is something wrong with the inverse 'inv_stokes' -- perhaps the matrix generated from 'stokes' is not invertible as defined. When I added
after
Code:
u.vec.data += inv_stokes * res
I saw many entries with value -nan.
After comparing the code to the code in py_tutorials/navierstokes.py, I noticed one important difference: In input block [5], the definition of the stokes function passed to the integrator is like this
Code:
stokes = nu*grad(ux)*grad(vx)+nu*grad(uy)*grad(vy) - div_u*q - div_v*p
When I changed it to the corresponding line in navierstokes.py
Code:
stokes = nu*grad(ux)*grad(vx)+nu*grad(uy)*grad(vy) + div_u*q + div_v*p - 1e-10*p*q
the example worked correctly.
But the code in 'navierstokes.py' has the opposite signs for the divergence terms and an additional p*q term so it doesn't seem to match the derivation presented in the iTutorial. I'm not sure what to make of this...?
Also, it may be helpful to others to change the iTutorial code from
Code:
Draw(velocity,mesh,"u")
to
Code:
Draw(Norm(velocity),mesh,"velocity", sd=3)
as in 'navierstokes.py' and have norm(velocity) display by default (instead of pressure) for consistency.
Edit: After making the code change above, I can see the pressure distribution, but it seems that the values may have the wrong sign. My intuition is that the pressure should be higher upstream of the obstruction. I confirmed this at the 'featflow' site.