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

Computing CFL number

0 votes

Hello

I would like to compute the CFL number for a Navier-Stokes computation. How can I do this in fenics, say for Taylor-Hood elements (P2-P1).

Thanks

asked Nov 19, 2014 by praveen FEniCS User (2,760 points)

1 Answer

+3 votes
 
Best answer

The following code computes an approximate CFL-number:

from dolfin import *
from numpy import random

# Set up dummy data
mesh = UnitSquareMesh(8,8)
V = VectorFunctionSpace(mesh, "CG", 2)
Q = FunctionSpace(mesh, "CG", 1)
W=V*Q
U = Function(W)
U.vector()[:] = 10*random.random(W.dim())
u,p = split(U)

# Cell size and timestep
h = CellSize(mesh)
dt = Constant(0.01)

# Compute the CFL number cell wise
DG = FunctionSpace(mesh, "DG", 0)
CFL = project(sqrt(inner(u,u))*dt/h, DG)
plot(CFL)
interactive()
answered Nov 24, 2014 by Øyvind Evju FEniCS Expert (17,700 points)
selected Nov 24, 2014 by praveen
...