Iterating over all elements

More
5 years 3 months ago #1750 by Jon
Hello,

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]
More
5 years 3 months ago #1751 by Guosheng Fu
I will use
Code:
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:
Code:
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)
Time to create page: 0.102 seconds