4
$\begingroup$

I'm having a problem with multigrid code I wrote. If I solve Laplace's equation in 2D and use more than 5 grid levels, the V-cycles stop converging after a few cycles (see below, convergence factor > 1). At grid level 3, you can see that the recursive V-cycle actually increases the error (L2 norm of the defect). If I use fewer grid levels, my code converges as expected. I suspect it's an issue with the boundary conditions, because the defect is very high close to the boundaries after V-cycle 2.

For Dirichlet boundaries I added ghost points to the finest grid to hold the boundary values. When I restrict the defect, I set the values of the defect at the coarse-grid ghost points to zero. Is there something more I need to worry about?

V-CYCLE 1
LEVEL   ACTION                  ERROR
1       Initial                 4.566101e-01
1       Relaxation sweep 1      1.375412e-01
2       Initial                 4.264610e-02
2       Relaxation sweep 1      2.082439e-02
3       Initial                 1.580465e-02
3       Relaxation sweep 1      9.881322e-03
4       Initial                 8.008788e-03
4       Relaxation sweep 1      5.150501e-03
5       Initial                 4.121322e-03
5       Relaxation sweep 1      2.643638e-03
5       Relaxation sweep 400    1.525026e-18
5       Coarse grid corr.       4.253979e-03
5       Relaxation sweep 1      1.356265e-03
4       Coarse grid corr.       1.301027e-02
4       Relaxation sweep 1      4.956990e-03
3       Coarse grid corr.       3.427880e-02
3       Relaxation sweep 1      1.421168e-02
2       Coarse grid corr.       8.532111e-02
2       Relaxation sweep 1      3.721634e-02
1       Coarse grid corr.       2.409762e-01
1       Relaxation sweep 1      1.022146e-01
CONVERGENCE FACTOR: 0.223855

V-CYCLE 2
LEVEL   ACTION                  ERROR
1       Initial                 1.022146e-01
1       Relaxation sweep 1      6.796567e-02
2       Initial                 5.807979e-02
2       Relaxation sweep 1      4.311037e-02
3       Initial                 3.733848e-02
3       Relaxation sweep 1      2.717026e-02
4       Initial                 2.302219e-02
4       Relaxation sweep 1      1.627633e-02
5       Initial                 1.341552e-02
5       Relaxation sweep 1      9.233742e-03
5       Relaxation sweep 400    5.981442e-18
5       Coarse grid corr.       1.660509e-02
5       Relaxation sweep 1      5.472094e-03
4       Coarse grid corr.       4.952103e-02
4       Relaxation sweep 1      1.951415e-02
3       Coarse grid corr.       1.255826e-01
3       Relaxation sweep 1      5.395197e-02
2       Coarse grid corr.       2.973566e-01
2       Relaxation sweep 1      1.349677e-01
1       Coarse grid corr.       6.812406e-01
1       Relaxation sweep 1      3.210040e-01
CONVERGENCE FACTOR: 3.140491
$\endgroup$
  • $\begingroup$ It sounds like a bug, but because you are so unspecific when you say "stops converging", there is little we can say here. What makes you think that it's an issue with boundary conditions? How does the solution look like? On which nodes is the residual largest? What else have you already tried? $\endgroup$ – Wolfgang Bangerth Dec 3 '13 at 12:47
  • $\begingroup$ Thanks for your suggestion, I added some error data to the original post. I examined the defect after the failed V-CYCLE 2, and it is very large close to the boundary nodes. I have been successfully solving PDE's with this code, but the solutions are not strongly dependent on the BC's. Perhaps I still have a bug somewhere... $\endgroup$ – Dan Dec 3 '13 at 16:17
  • $\begingroup$ I tried the other poster's suggestion of using a relaxation factor, and found that this combined with an extra pass over the boundary points during each relaxation seems to have solved the problem. However, I am still confused about why there is so much error at the boundaries. Is it possible my initial guess is not great, and a full mulitigrid iteration might help? $\endgroup$ – Dan Dec 3 '13 at 21:07
  • 1
    $\begingroup$ I still think it's a bug, but I can't tell at a distance where, of course. If you look at the solution after a couple of cycles, does it look correct in the interior? Does it look correct at the boundary? If you use zero boundary conditions, does it work? if you use non-zero boundary conditions, does the solution after a couple of cycles have the correct values at the boundaries? This is my mental checklist trying to debug these sorts of things. $\endgroup$ – Wolfgang Bangerth Dec 4 '13 at 1:55
3
$\begingroup$

Thank you to the posters for encouraging me to look for a bug. I found one, a subtle issue related to restriction and interpolation. I am using ghost points to treat the boundaries, and so the first interior point is at index (0,0) (boundary points are stored on negative indices). This can work, but you have to remember that the interior coarse grid points must be centered on the fine gridpoints (1,1), (3,1), (1,3), (3,3), etc. My mistake was centering them on (0,0), (2,0), (0,2), (2,2) etc, which are points immediately adjacent to the boundary. This slight shift causes problems at the boundaries.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.