<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body style="overflow-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;"><div><br></div><div> Sorry for the long delay in getting back to you. I think there is not directly a problem with the code; rather, with these Q0 elements, Galerkin is not a good approach.</div><div>I went back to src/ksp/ksp/tutorials/ex32.c and ran a little deeper and noticed that when running without Galerkin it gives very good, expected convergence. But with Galerkin it does not. I had to make some fixes in refinement for DMDA to run how I wanted they are in the branch in <a href="https://urldefense.us/v3/__https://gitlab.com/petsc/petsc/-/merge_requests/7940__;!!G_uCfscf7eWS!fXCpNUu10XTTCmVzPF3jsEz72QFuFGPkzeF0He6viicBt934KYfgROb3ncB2BZnfEMWRwJnoelHdOTKlzPHkaiU$">https://gitlab.com/petsc/petsc/-/merge_requests/7940</a></div><div><br></div><div> So I think the correct answer is for you to not use Galerkin but instead discretize on each level the matrix as is done in ex32.c </div><div><br></div><div> For this to work in your code you will need to change how you scale the matrix (and right hand side) you generate, see ComputeMatrix() in ex32.c Note</div><div>how the matrix entries have the scaling HxdHy etc. Similarly the RHS has the scaling by Hx for Hy. Also DMStag uses .25 in the interpolation but DMDA uses 1; I am not sure why the 1 that DMDA uses works, but if you rescale your matrices and right hand side and don't get use Galerkin and still get poor convergence then try different scaling for the interpolation. </div><div><br></div><div>Here is the performance for ex32. Note how fantastic it is, I think you should be virtually the same.</div><div><br></div><div><p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures">/ex32 -pc_type mg -pc_mg_levels 5 -ksp_monitor_true_residual -ksp_rtol 1.e-10 -ksp_type cg -pc_mg_galerkin none -mg_levels_pc_type sor -mg_levels_ksp_type richardson -mg_levels_ksp_max_it 2 -mg_coarse_pc_type svd -da_refine 5</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 0 KSP preconditioned resid norm 8.707575268782e-01 true resid norm 2.842788112864e-03 ||r(i)||/||b|| 1.000000000000e+00</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 1 KSP preconditioned resid norm 5.067478574947e-03 true resid norm 8.807970167024e-05 ||r(i)||/||b|| 3.098356197273e-02</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 2 KSP preconditioned resid norm 5.566700402730e-05 true resid norm 2.014981529883e-06 ||r(i)||/||b|| 7.088046839529e-04</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 3 KSP preconditioned resid norm 2.698851702073e-07 true resid norm 3.013479554557e-08 ||r(i)||/||b|| 1.060043673646e-05</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 4 KSP preconditioned resid norm 2.689594854129e-09 true resid norm 2.536151839771e-10 ||r(i)||/||b|| 8.921353752308e-08</span></p>
<p style="margin: 0px; font-style: normal; font-variant-caps: normal; font-stretch: normal; font-size: 14px; line-height: normal; font-family: Menlo; font-size-adjust: none; font-kerning: auto; font-variant-alternates: normal; font-variant-ligatures: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-feature-settings: normal; font-optical-sizing: auto; font-variation-settings: normal;"><span style="font-variant-ligatures: no-common-ligatures"> 5 KSP preconditioned resid norm 2.232993540537e-11 true resid norm 2.360948191859e-12 ||r(i)||/||b|| 8.305044548259e-10</span></p></div><div><span style="font-variant-ligatures: no-common-ligatures"><br></span></div><div>Barry</div><div><br></div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Oct 8, 2024, at 2:09 PM, Gautam Luhana <gkluhana@cs.ubc.ca> wrote:</div><br class="Apple-interchange-newline"><div><div>Hi Barry,<br><br>Did you get time to look through the code and see where the issue might be?<br><br>Regards,<br>Gautam<br><br>On 2024-10-02 11:58 a.m., Gautam Luhana wrote:<br><blockquote type="cite">Hi Barry,<br><br>I've stripped away the multiphyics functionality and put the remaining stokes part in the repo here:<br><br><a href="https://urldefense.us/v3/__https://github.com/gkluhana/stokesToy__;!!G_uCfscf7eWS!fXCpNUu10XTTCmVzPF3jsEz72QFuFGPkzeF0He6viicBt934KYfgROb3ncB2BZnfEMWRwJnoelHdOTKl4GWg6pc$">https://github.com/gkluhana/stokesToy</a><br><br>Let me know if you have trouble accessing the code.<br><br>I apologize for old routines/multiphysics functionality that may still be there.<br><br>Thanks & Regards,<br>Gautam<br><br></blockquote></div></div></blockquote></div><br></div></body></html>