<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div dir="auto" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 26, 2017, at 7:52 PM, Matthew Knepley <<a href="mailto:knepley@gmail.com" class="">knepley@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Mon, Jun 26, 2017 at 8:37 PM, Jason Lefley <span dir="ltr" class=""><<a href="mailto:jason.lefley@aclectic.com" target="_blank" class="">jason.lefley@aclectic.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div dir="auto" style="word-wrap:break-word" class=""><div class=""><blockquote type="cite" class=""><div dir="ltr" style="font-family:Helvetica;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">Okay, when you say a Poisson problem, I assumed you meant</div><div class=""><br class=""></div><div class=""> div grad phi = f</div><div class=""><br class=""></div><div class="">However, now it appears that you have</div><div class=""><br class=""></div><div class=""> div D grad phi = f</div><div class=""><br class=""></div><div class="">Is this true? It would explain your results. Your coarse operator is inaccurate. AMG makes the coarse operator directly</div><div class="">from the matrix, so it incorporates coefficient variation. Galerkin projection makes the coarse operator using R A P</div><div class="">from your original operator A, and this is accurate enough to get good convergence. So your coefficient representation</div><div class="">on the coarse levels is really bad. If you want to use GMG, you need to figure out how to represent the coefficient on</div><div class="">coarser levels, which is sometimes called "renormalization".</div><div class=""><br class=""></div><div class=""> Matt</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">I believe we are solving the first one. The discretized form we are using is equation 13 in this document: <a href="https://www.rsmas.miami.edu/users/miskandarani/Courses/MSC321/Projects/prjpoisson.pdf" target="_blank" class="">https://www.rsmas.<wbr class="">miami.edu/users/miskandarani/<wbr class="">Courses/MSC321/Projects/<wbr class="">prjpoisson.pdf</a> Would you clarify why you think we are solving the second equation?</div></div></div></div></blockquote><div class=""><br class=""></div><div class=""> Something is wrong. The writeup is just showing the FD Laplacian. Can you take a look at SNES ex5, and let</div><div class="">me know how your problem differs from that one? There were use GMG and can converge is a few (5-6) iterates,</div><div class="">and if you use FMG you converge in 1 iterate. In fact, that is in my class notes on the CAAM 519 website. Its possible</div><div class="">that you have badly scaled boundary values, which can cause convergence to deteriorate.</div><div class=""><br class=""></div><div class=""> Thanks,</div><div class=""><br class=""></div><div class=""> Matt</div><div class=""> </div></div></div></div></div></blockquote><br class=""></div><div>I went through ex5 and some of the other Poisson/multigrid examples again and noticed that they arrange the coefficients in a particular way.</div><div><div class=""><br class=""></div><div class="">Our original attempt (solver_test.c) and some related codes that solve similar problems use an arrangement like this:</div><div class=""><br class=""></div><div class=""><font face="Consolas" class=""><br class=""></font></div><div class=""><font face="Consolas" class=""> u(i-1,j,k) - 2u(i,j,k) + u(i+1,j,k) u(i,j-1,k) - 2u(i,j,k) + u(i,j+1,k) u(i,j,k-1) - 2u(i,j,k) + u(i,j,k+1) </font></div><div class=""><font face="Consolas" class="">---------------------------------------- + ---------------------------------------- + ---------------------------------------- = f</font></div><div class=""><font face="Consolas" class=""> dx^2 dy^2 dz^2</font></div><div class=""><br class=""></div><div class="">That results in the coefficient matrix containing -2 * (1/dx^2 + 1/dy^2 + 1/dz^2) on the diagonal and 1/dx^2, 1/dy^2 and 1/dz^2 on the off-diagonals. I’ve also looked at some codes that assume h = dx = dy = dz, multiply f by h^2 and then use -6 and 1 for the coefficients in the matrix.</div><div class=""><br class=""></div><div class="">It looks like snes ex5, ksp ex32, and ksp ex34 rearrange the terms like this:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class=""><font face="Consolas" class=""> dy dz (u(i-1,j,k) - 2u(i,j,k) + u(i+1,j,k)) dx dz (u(i,j-1,k) - 2u(i,j,k) + u(i,j+1,k)) dx dy (u(i,j,k-1) - 2u(i,j,k) + u(i,j,k+1))</font></div><div class=""><font face="Consolas" class="">--------------------------------------------------- + --------------------------------------------------- + --------------------------------------------------- = f dx dy dz</font></div><div class=""><font face="Consolas" class=""> dx dy dz</font></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">I changed our code to use this approach and we observe much better convergence with the mg pre-conditioner. Is this renormalization? Can anyone explain why this change has such an impact on convergence with geometric multigrid as a pre-conditioner? It does not appear that the arrangement of coefficients affects convergence when using conjugate gradient without a pre-conditioner. Here’s output from some runs with the coefficients and right hand side modified as described above:</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">$ mpirun -n 16 ./solver_test -da_grid_x 128 -da_grid_y 128 -da_grid_z 128 -ksp_monitor_true_residual -pc_type mg -ksp_type cg -pc_mg_levels 5 -mg_levels_ksp_type richardson -mg_levels_ksp_richardson_self_scale -mg_levels_ksp_max_it 5</div><div class="">right hand side 2 norm: 0.000244141</div><div class="">right hand side infinity norm: 4.76406e-07</div><div class=""> 0 KSP preconditioned resid norm 3.578255383614e+00 true resid norm 2.441406250000e-04 ||r(i)||/||b|| 1.000000000000e+00</div><div class=""> 1 KSP preconditioned resid norm 1.385321366208e-01 true resid norm 4.207234652404e-05 ||r(i)||/||b|| 1.723283313625e-01</div><div class=""> 2 KSP preconditioned resid norm 4.459925861922e-03 true resid norm 1.480495515589e-06 ||r(i)||/||b|| 6.064109631854e-03</div><div class=""> 3 KSP preconditioned resid norm 4.311025848794e-04 true resid norm 1.021041953365e-07 ||r(i)||/||b|| 4.182187840984e-04</div><div class=""> 4 KSP preconditioned resid norm 1.619865162873e-05 true resid norm 5.438265013849e-09 ||r(i)||/||b|| 2.227513349673e-05</div><div class="">Linear solve converged due to CONVERGED_RTOL iterations 4</div><div class="">KSP final norm of residual 5.43827e-09</div><div class="">Residual 2 norm 5.43827e-09</div><div class="">Residual infinity norm 6.25328e-11</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">$ mpirun -n 16 ./solver_test -da_grid_x 128 -da_grid_y 128 -da_grid_z 128 -ksp_monitor_true_residual -pc_type mg -ksp_type cg -pc_mg_levels 5 -mg_levels_ksp_type richardson -mg_levels_ksp_richardson_self_scale -mg_levels_ksp_max_it 5 -pc_mg_type full</div><div class=""> 0 KSP preconditioned resid norm 3.459879233358e+00 true resid norm 2.441406250000e-04 ||r(i)||/||b|| 1.000000000000e+00</div><div class=""> 1 KSP preconditioned resid norm 1.169574216505e-02 true resid norm 4.856676267753e-06 ||r(i)||/||b|| 1.989294599272e-02</div><div class=""> 2 KSP preconditioned resid norm 1.158728408668e-04 true resid norm 1.603345697667e-08 ||r(i)||/||b|| 6.567303977645e-05</div><div class=""> 3 KSP preconditioned resid norm 6.035498575583e-07 true resid norm 1.613378731540e-10 ||r(i)||/||b|| 6.608399284389e-07</div><div class="">Linear solve converged due to CONVERGED_RTOL iterations 3</div><div class="">KSP final norm of residual 1.61338e-10</div><div class="">Residual 2 norm 1.61338e-10</div><div class="">Residual infinity norm 1.95499e-12</div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">$ mpirun -n 64 ./solver_test -da_grid_x 512 -da_grid_y 512 -da_grid_z 512 -ksp_monitor_true_residual -pc_type mg -ksp_type cg -pc_mg_levels 8 -mg_levels_ksp_type richardson -mg_levels_ksp_richardson_self_scale -mg_levels_ksp_max_it 5 -pc_mg_type full -bc_type neumann</div><div class="">right hand side 2 norm: 3.05176e-05</div><div class="">right hand side infinity norm: 7.45016e-09</div><div class=""> 0 KSP preconditioned resid norm 5.330711358065e+01 true resid norm 3.051757812500e-05 ||r(i)||/||b|| 1.000000000000e+00</div><div class=""> 1 KSP preconditioned resid norm 4.687628546610e-04 true resid norm 2.452752396888e-08 ||r(i)||/||b|| 8.037179054124e-04</div><div class="">Linear solve converged due to CONVERGED_RTOL iterations 1</div><div class="">KSP final norm of residual 2.45275e-08</div><div class="">Residual 2 norm 2.45275e-08</div><div class="">Residual infinity norm 8.41572e-10</div></div></div></div></div></div></body></html>