<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> Sounds correct.<br id="lineBreakAtBeginningOfMessage"><div><br><blockquote type="cite"><div>On Apr 10, 2025, at 2:04 PM, Anton Popov <popov@uni-mainz.de> wrote:</div><br class="Apple-interchange-newline"><div><meta charset="UTF-8"><div class="Singleton"><div style="margin-bottom: 0.1in; line-height: 20.700001px; background: none;"><br class="webkit-block-placeholder"></div><p style="margin-bottom: 0in; line-height: 18px; background: none;">Hi guys,</p><p style="margin-bottom: 0in; line-height: 18px; background: none;">I have a custom multigrid preconditioner that uses Galerkin coarsening for the staggered grid finite difference. Now I want to replace a few top level operators with the matrix-free shell matrices.</p><p style="margin-bottom: 0in; line-height: 18px; background: none;">Here is my plan:</p><p style="margin-bottom: 0in; line-height: 18px; background: none;">1. Set PC_MG_GALERKIN_NONE</p><p style="margin-bottom: 0in; line-height: 18px; background: none;">2. Call PCMGSetRestriction and PCMGSetInterpolation on all levels as I do it already</p><p style="margin-bottom: 0in; line-height: 18px; background: none;">3. Use a combination of PCMGGetSmoother and KSPSetOperators to communicate my operators with PCMG</p><p style="margin-bottom: 0in; line-height: 18px; background: none;"> a. On the top levels just set the shell matrices minimalistically equipped with<span class="Apple-converted-space"> </span><span style="font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal;"><font><span style="letter-spacing: normal;"><span style="font-style: normal;"><span style="font-weight: normal;">MATOP_GET_DIAGONAL<span class="Apple-converted-space"> </span></span></span></span></font></span><span style="font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal;"><font><span style="letter-spacing: normal;"><span style="font-style: normal;"><span style="font-weight: normal;">and MATOP_MULT.</span></span></span></font></span></p><p style="margin-bottom: 0in; line-height: 18px; background: none;"> b. On the bottom levels generate the operators by explicitly calling MatMatMatMult (R is not the same as P in my case).</p><div style="margin-bottom: 0in; line-height: 18px; background: none;"><br class="webkit-block-placeholder"></div><p style="margin-bottom: 0in; line-height: 18px; background: none;"> Use MAT_INITIAL_MATRIX for the first time<span class="Apple-converted-space"> </span></p><p style="margin-bottom: 0in; line-height: 18px; background: none;"> Use MAT_REUSE_MATRIX for the subsequent calls</p><div style="margin-bottom: 0in; line-height: 18px; background: none;"><br class="webkit-block-placeholder"></div><p style="margin-bottom: 0in; line-height: 18px; background: none;">Is this a proper way to do it, or there is something wrong?<span class="Apple-converted-space"> </span></p><p style="margin-bottom: 0in; line-height: 18px; background: none;">If I want the restriction/interpolation matrices to be matrix-free on the top levels as well, I would need to set<span class="Apple-converted-space"> </span><span style="font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal;"><font><span style="letter-spacing: normal;"><span style="font-style: normal;"><span style="font-weight: normal;">MATOP_MULT_ADD<span class="Apple-converted-space"> </span></span></span></span></font></span><span style="font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal;"><font><span style="letter-spacing: normal;"><span style="font-style: normal;"><span style="font-weight: normal;">for them. Is this enough, or do I need something else?</span></span></span></font></span></p><p style="margin-bottom: 0in; line-height: 18px; background: none; font-weight: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; letter-spacing: normal; font-style: normal;"><font>Thanks!</font></p><p style="margin-bottom: 0in; line-height: 18px; background: none; letter-spacing: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-variant-alternates: normal; font-variant-numeric: normal; font-variant-east-asian: normal; font-variant-position: normal; font-variant-emoji: normal; font-style: normal; font-weight: normal;"><font>Anton</font></p><div style="margin-bottom: 0.1in; line-height: 20.700001px; background: none;"><br class="webkit-block-placeholder"></div></div></div></blockquote></div><br></div></body></html>