adaptive mesh refinement in 3D


I am trying to do adaptive mesh refinement in 3D, but the refinement process appears to be inefficient in that more elements are being refined than appear necessary. The attached script ( is an example of what I mean. The initial mesh has only 54 elements. However, when I mark only the first element for refinement, the refined mesh has 384 elements (global refinement produces 432 elements). Are there additional settings I need to obtain better adaptive refinement?

Thank you,


Hi Kevin,

NGSolve uses refinement markers for 3D elements and 2D elements. Per default, all elements are marked for refinement, so you have to unmark all surface elements first:

for el in mesh.Elements(BND):
mesh.SetRefinementFlag(el, False)

then I get 82 elements after refinement,


Hi Joachim,

Thank you very much! This works.