Program crashes when evaluating gfu at points

Hi,

I am trying to evaluate the grid function at points with some highly refined mesh. However, I find that when the mesh is fine enough, the program will crash after evaluating the grid function at several hundred points. You can find example codes showing the problem. Here I have a square with the top boundary replaced by 3 steps of Koch snowflake. And I want to evaluate the grid function on this pre-fractal structure. But the program just crashes when I try to run it.

However, It still works if I replace the mesh with a coarser one.

I wonder if it is that I am not coding it in the right way so it does not work.

Thanks in advance for any help!

There are points outside the mesh, which caused the gfu(…) to crash.
Now we throw an exception.

You can check iff the point is found in the mesh by checking the element-nr:

    pnt = mesh(p[0],p[1],0,BND)
    if pnt.nr != -1:
        val_lst.append(gfu(pnt))

Joachim

Thank you so much! By the way, I checked the points that are not on the boundary and found that they should be very close. Is there any way to project them onto the boundary?

the answer is yes and no.
Yes, there is a function similar to this inside the contact functionality.
No, it is currently not conveniently usable from Python.

Joachim