Adaptive mesh refinement: code crashes when using a multigrid preconditioner

Dear NGSolve developers,

I am trying to use adaptive mesh refinement for a mixed form of the elastodynamic equations. If I use a “multigrid” preconditioner the code goes through the first solve on the original mesh. When the selected elements are refined after the first solve and the bilinear form is reassembled, the code crashes with a segmentation fault. The code works fine with the other preconditioners.

I’ve attached a python script for a toy problem in elasticity (the solution is within the space of the basis functions - so there is no need for mesh refinement, but this is just for illustration). I use a compound space of functions in HDiv and H1. The preconditioner is defined on line 215. The code goes through one solve with the original mesh and then two solves with adaptively refined meshes. The code works fine with other preconditioners and does not crash. If I use a “multigrid” preconditioner the code crashes after the first solve.

For the original problem that I am trying to solve, unfortunately, none of the other preconditioners help the iterative solver to converge. Of course, the “direct” preconditioner works but I cannot use that for large problems. Only the multigrid preconditioner works - but crashes soon after the first mesh refinement! Is there a fix to this problem?

Thank you,
Anand

https://ngsolve.org/media/kunena/attachments/1281/unit_cube_mod1_amr.py

Attachment: unit_cube_mod1_amr.py

I’m having the same problem! were you able to find what was happening?

with the attached file? When I change pc to multigrid everything runs through…