Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Iterating over all elements

More
4 years 8 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
4 years 8 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.116 seconds