Refining surface mesh is not working

Hello,

I want to perform a convergence test for a surface PDE and created a simple surface unit sphere, as described here.
Unfortunately calling Refine() on the mesh does not actually refine the mesh (no vertices are added). In contrast, drawing the mesh after the refinement results in a distorted output.
I have a minimal working example here:
Refine_Problem.ipynb (10.6 KB)

And here is a Screenshot of the problem:

Since I’m new to ngsolve, maybe I’m just doing the refinement in the wrong way and someone can point me in the right direction? I’m using ngsolve 6.2.2401.

Thanks and many greetings
Mathias

Hi Mathias,

you need

mesh.Refine (mark_surface_elements=True)

for uniform refinement, or mark boundary elements for local mesh refinement.

your notebook throws an exception if we execute cell by cell, this might be the related to your screwed up mesh.

Joachim

NameError                                 Traceback (most recent call last)
Cell In[3], line 12
      9 vertex0_solution = np.zeros((n_runs,))  # Solution at convergence_vertex_id for each run
     11 convergence_vertex_id = 0
---> 12 convergence_point = mesh.vertices[convergence_vertex_id].point
     13 convergence_results = []
     15 final_run = False

NameError: name 'mesh' is not defined

Hello Joachim,

thanks for the quick reply! I just gave the refinement with:

mesh.Refine(mark_surface_elements=True)

a try and this seemed to work. So more nodes were added! Unfortunately the mesh still looks distorted in the UI. Is this maybe just an UI issue?
I also just realized, that the last time i (mistakenly) uploaded a wrong script (which was a mixture of my original convergence test and a condensed minimal working example, that’s probably why the assertion was thrown). Here is the correct minimal working example - sorry for the confusion:
Refine_Problem.ipynb (1.3 KB)

And here again a screenshot of the situation:

Thanks again for the help and many greetings
Mathias

The curvature information needs to be recomputed after refinement. Just add a

mesh.Curve(2)

line after it.

Perfect - that solves the issue!
Thanks also to you, Christoper, for the quick help!