To find my CFL condition I have to iterate over all elements in my domain and I was wondering if there is a more efficient way to do this other than what I have.
for i, en in enumerate(fes.Elements()):
trafo = en.GetTrafo()
id0 = int(i)
value_I_need = gfu.vec[id0][1]
I will use dt = h0/vel_max*cfl
where h0 is your estimated minimal mesh size, and vel_max is the estimated maximum velocity magnitude.
I will use a DG-P0 space to calculate vel_max as follows:
fes_vest = L2(mesh, order=0)
gf_vel = GridFunction(fes_vest)
gf_vel.Set((vel*vel)**0.5) # vel shall be your velocity grid function
vel_max = max(gf_vel.vec)