This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

Calculating vorticity/enstrophy in fenics

0 votes

Hi,

I'm very new to FEniCS and was running the 2D NS flow around a cylinder program given in section 3.4 of the FEniCS tutorial vol1. In addition to the velocity and pressure want to plot the some quantities like vorticity or enstrophy ( 0.5*(u_x^2 + v_y^2) where the solution is U = U(u,v,t) ). I tried adding

 #calculate enstrophy
n_y = Expression(('0.0','1.0'),degree = 0)
uy = dot(grad(u_),n_y)
n_x = Expression(('1.0','0.0'),degree = 0)
ux = dot(grad(u_),n_x)
ens = dolfin.project(dot(ux,ux) + dot(uy,uy))
# Save to file (.pvd)
vfile << ens

to the time-stepping loop.

This does not cause an error and I was almost able to plot it in Paraview but not quite (only the first frame had color, values on the scale looked too large).

Any advice on how to properly calculate such quantities would be greatly appreciated.

Thanks,

Eric

asked Dec 8, 2016 by rickford94 FEniCS Novice (210 points)

If you have incompressible flow (which I assume you do for flow over a cylinder) why not just integrate (1/2)*curl(u_)^2? If you want to calculate it from the gradient you should realise that you need to take the Frobenius norm of the gradient of u (which is a rank 2 tensor), i.e. your formula is incorrect. Have a look at this question which should help you with the latter.

1 Answer

0 votes

The reason you only see the first frame is that you have to intialize ens and write

ens.assign(dolfin.project(dot(ux,ux) + dot(uy,uy)))
vfile << ens
answered Dec 14, 2016 by KristianE FEniCS Expert (12,900 points)
...