adaptive mesh refinement in 3D

Hi.

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 (refine_experiment.py) 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,
Kevin
https://ngsolve.org/media/kunena/attachments/772/refine_experiment.py

Attachment: refine_experiment.py

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,

Joachim

Hi Joachim,

Thank you very much! This works.

Thanks,
Kevin