Adaptive refinement goes wrong for 3D periodic boundary problems

3d_adapt_simplest.py (3.9 KB)

Hello,

I am trying to solve a nonlinear Poisson problem with a point source on the right-hand side, which is
-div(grad gfu) = alpha * exp(-beta * gfu) - gamma * delta_{center}, on a cube.

The boundary conditions are Dirichlet on the top and the bottom sides and periodic boundary conditions for the back-front and left-right sides.

I chose to refine the mesh adaptively with an L2 error estimator and solve the PDE using Newton’s method in the SolveBVP().

However, I get the following error message after the MARKING step:

Traceback (most recent call last):
  File "/home/wan01937/Workspace/GaN/3d_adapt_simplest.py", line 140, in <module>
    mesh.Refine()
netgen.libngpy._meshing.NgException: Ask for unused hash-value

When I turn the periodic boundary condition to the Neumann boundary condition by changing line 55 to

mesh,fes = MakeSpace(isPeriodic=False)

the program works.

Am I implementing things wrong? How can I fix it? Thanks in advance for any help!

If I add some plotting functions involving the evaluation of gfu at some points, the Neumann case also gives a Segmentation Fault.

When I use breakpoint, I find the code crashes at the step of mesh.Refine().

It seems that the codes do not like me using gfu in between solving and refining the mesh. Would anyone have any clue on this issue?