Simple 2D fluid flow with viscosity can be simulated via Lattice Boltzmann Methods. These solve for the discrete Boltzmann equation with collision/viscosity models rather than the Navier-Stokes equation (although one can be turned into the other).
LBM models the fluid consisting of fictitious particles, and such particles perform consecutive streaming and collision processes over a discrete lattice mesh. Hence the general algorithm is the following:
For the theory of the method look here, althought many other good resources can be easily found with a google search
Introducing a barrier to a flowing fluid can be simulated, see the two examples below:
2 features of this program that show be mentioned are, firstly the barrier is placed into the flowing fluid so some transient behaviour is expected and secondly it is prone instabilities so simulations must be pick for appropriate parameters (generally by trail and error unfortunately)
The plot shows the velocity component along the x axis
#NAME: Lattice Boltzmann Method
#DESCRIPTION: Fluid dynamics simulation using a Lattice Boltzmann Method.
import LBM
from pycav import display
animation1 = LBM.run(80,200,0.01,0.1,2200,400)
animation1 = display.create_animation(animation1, temp = True)
display.display_animation(animation1)
animation2 = LBM.run(80,200,0.05,0.1,2200,400)
animation2 = display.create_animation(animation2, temp = True)
display.display_animation(animation2)
animation3 = LBM.run(80,200,0.00275,0.1,2200,400,barrier_file='./airfoil.dat')
animation3 = display.create_animation(animation3, temp = True)
display.display_animation(animation3)