<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>  I appreciate the clarification. I would call 3) preconditioning. <div><br></div><div>   To increase my understanding, you are already using Newton's method? That is, you compute the Jacobian of the function and use  - J^{-1}(u^n) F(u^n) as your update direction? </div><div><br></div><div>    When you switch the inner product (or precondition) how will the search direction be different?</div><div><br></div><div>   Thanks</div><div><br></div><div>   Barry</div><div><br></div><div>The case you need support for is becoming important to PETSc so we need to understand it well and support it well which is why I am asking these (perhaps to you) trivial questions.</div><div><br></div><div><br></div><div><div><br><blockquote type="cite"><div>On Jun 13, 2025, at 4:55 AM, Ali ALI AHMAD <ali.ali_ahmad@utt.fr> wrote:</div><br class="Apple-interchange-newline"><div><div><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt;"><div><div style="margin: 0px;">Thank you for your message.</div><div style="margin: 0px;"><br data-mce-bogus="1"></div><div style="margin: 0px;">To answer your question: I would like to use the <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span> norm in the sense of Lebesgue for <strong data-start="318" data-end="340">all three purposes</strong>, especially the <strong data-start="357" data-end="370">third one</strong>.</div><div style="margin: 0px;"><strong data-start="376" data-end="404"><br data-mce-bogus="1"></strong></div><div style="margin: 0px;"><strong data-start="376" data-end="404">1- For displaying residuals</strong> during the nonlinear iterations, I would like to observe the convergence behavior using a norm that better reflects the physical properties of the problem.</div><div style="margin: 0px;"><strong data-start="565" data-end="592"><br data-mce-bogus="1"></strong></div><div style="margin: 0px;"><strong data-start="565" data-end="592">2- For convergence testing</strong>, I would like the stopping criterion to be based on a weighted <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span> norm that accounts for the geometry of the mesh (since I am working with unstructured, anisotropic triangular meshes).</div><div style="margin: 0px;"><strong data-start="789" data-end="809"><br data-mce-bogus="1"></strong></div><div style="margin: 0px;"><strong data-start="789" data-end="809">3 - Most importantly</strong>, I would like to modify the <strong data-start="838" data-end="855">inner product</strong> used in the algorithm so that it aligns with the weighted <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span> norm (since I am working with unstructured, anisotropic triangular meshes).</div><div style="margin: 0px;"><br data-mce-bogus="1"></div></div><div><div><div style="margin: 0px;" data-mce-style="margin: 0px;">Best regards,</div></div><div>Ali ALI AHMAD</div></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>De: </b>"Barry Smith" <bsmith@petsc.dev><br><b>À: </b>"Ali ALI AHMAD" <ali.ali_ahmad@utt.fr><br><b>Cc: </b>"petsc-users" <petsc-users@mcs.anl.gov>, "petsc-maint" <petsc-maint@mcs.anl.gov><br><b>Envoyé: </b>Vendredi 13 Juin 2025 03:14:06<br><b>Objet: </b>Re: [petsc-maint] norm L2 problemQuestion about changing the norm used in nonlinear solvers (L2 Euclidean vs. L2 Lebesgue)<br></div><div><br></div><div data-marker="__QUOTED_TEXT__">You haven't answered my question. Where (conceptually) and for what purpose do you want to use the L2 norm.<br><div>    1) displaying norms to observe the convergence behavior</div><br><div>     2) in the convergence testing to determine when to stop</div><br><div>     3) changing the "inner product" in the algorithm which amounts to preconditioning.</div><br><div>  Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote><div>On Jun 12, 2025, at 9:42 AM, Ali ALI AHMAD <ali.ali_ahmad@utt.fr> wrote:</div><br class="Apple-interchange-newline"><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div><div>Thank you for your answer.<div style="margin:0px"><br></div><div style="margin:0px">I am currently working with the nonlinear solvers <strong><code>newtonls</code></strong> (with <code>bt</code>, <code>l2</code>, etc.) and <strong><code>newtontr</code></strong> (using <code>newton</code>, <code>cauchy</code>, and <code>dogleg</code> strategies) combined with the linear solver <strong><code>gmres</code></strong> and the <strong>ILU</strong> preconditioner, since my Jacobian matrix is nonsymmetric.</div><div style="margin:0px"><br></div><div style="margin:0px">I also use the Eisenstat-Walker method for <code>newtonls</code>, as my initial guess is often very far from the exact solution.</div><div style="margin:0px"><br></div><div style="margin:0px">What I would like to do now is to <strong>replace the standard Euclidean <span class="katex"><span class="katex-html"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span> norm</strong> with the <strong><span class="katex"><span class="katex-html"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span> norm in the Lebesgue sense in the above numerical algorithm</strong>, because my problem is defined on an <strong>unstructured, anisotropic triangular mesh</strong> where a weighted norm would be more physically appropriate.</div><div style="margin:0px"><br></div><div style="margin:0px">Would you be able to advise me on how to implement this change properly?</div><div style="margin:0px"><br>I would deeply appreciate any guidance or suggestions you could provide.</div><div style="margin:0px"><br></div><div style="margin:0px">Thank you in advance for your help.</div><div style="margin:0px"><br></div><div style="margin:0px">Best regards,</div></div><div>Ali ALI AHMAD</div></div><br><hr id="zwchr"><div><b>De: </b>"Ali ALI AHMAD" <ali.ali_ahmad@utt.fr><br><b>À: </b>"Barry Smith" <bsmith@petsc.dev><br><b>Cc: </b>"petsc-users" <petsc-users@mcs.anl.gov>, "petsc-maint" <petsc-maint@mcs.anl.gov><br><b>Envoyé: </b>Jeudi 12 Juin 2025 15:28:02<br><b>Objet: </b>Re: [petsc-maint] norm L2 problemQuestion about changing the norm used in nonlinear solvers (L2 Euclidean vs. L2 Lebesgue)<br></div><br><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div>Thank you for your answer.<div style="margin:0px"><br></div><div style="margin:0px">I am currently working with the nonlinear solvers <strong><code>newtonls</code></strong> (with <code>bt</code>, <code>l2</code>, etc.) and <strong><code>newtontr</code></strong> (using <code>newton</code>, <code>cauchy</code>, and <code>dogleg</code> strategies) combined with the linear solver <strong><code>gmres</code></strong> and the <strong>ILU</strong> preconditioner, since my Jacobian matrix is nonsymmetric.</div><div style="margin:0px"><br></div><div style="margin:0px">I also use the Eisenstat-Walker method for <code>newtonls</code>, as my initial guess is often very far from the exact solution.</div><div style="margin:0px"><br></div><div style="margin:0px">What I would like to do now is to <strong>replace the standard Euclidean <span class="katex"><span class="katex-html"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span> norm</strong> with the <strong><span class="katex"><span class="katex-html"><span class="base"><span class="strut"></span><span class="mord"><span class="mord mathnormal">L</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist"><span class="pstrut"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span> norm in the Lebesgue sense</strong>, because my problem is defined on an <strong>unstructured, anisotropic triangular mesh</strong> where a weighted norm would be more physically appropriate.</div><div style="margin:0px"><br></div><div style="margin:0px">Would you be able to advise me on how to implement this change properly?</div><div style="margin:0px"><br>I would deeply appreciate any guidance or suggestions you could provide.</div><div style="margin:0px"><br></div><div style="margin:0px">Thank you in advance for your help.</div><div style="margin:0px"><br></div><div style="margin:0px">Best regards,</div></div><div>Ali ALI AHMAD</div><hr id="zwchr"><div><b>De: </b>"Barry Smith" <bsmith@petsc.dev><br><b>À: </b>"Ali ALI AHMAD" <ali.ali_ahmad@utt.fr><br><b>Cc: </b>"petsc-users" <petsc-users@mcs.anl.gov>, "petsc-maint" <petsc-maint@mcs.anl.gov><br><b>Envoyé: </b>Jeudi 12 Juin 2025 14:57:40<br><b>Objet: </b>Re: [petsc-maint] norm L2 problemQuestion about changing the norm used in nonlinear solvers (L2 Euclidean vs. L2 Lebesgue)<br></div><br><div><div>  Do you wish to use a different norm </div><br><div>   1) ONLY for displaying (printing out) the residual norms to track progress</div><br><div>   2) in the convergence testing</div><br><div>   3) to change the numerical algorithm (for example using the L2 inner product instead of the usual linear algebra R^N l2 inner product).</div><br><div>   For 1) use SNESMonitorSet() and in your monitor function use SNESGetSolution() to grab the solution and then VecGetArray(). Now you can compute any weighted norm you want on the solution.</div><br><div>   For 2) similar but you need to use SNESSetConvergenceTest</div><br><div>   For 3) yes, but you need to ask us specifically.</div><br><div>  Barry</div><div><br id="lineBreakAtBeginningOfMessage"><div><br><blockquote><div>On Jun 11, 2025, at 4:45 AM, Ali ALI AHMAD <ali.ali_ahmad@utt.fr> wrote:</div><br class="Apple-interchange-newline"><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div><div>Dear PETSc team,<br><br>I hope this message finds you well.<br><br>I am currently using PETSc in a C++, where I rely on the nonlinear solvers `SNES` with either `newtonls` or `newtontr` methods. I would like to ask if it is possible to change the default norm used (typically the L2 Euclidean norm) to a custom norm, specifically the L2 norm in the sense of Lebesgue (e.g., involving cell-wise weighted integrals over the domain).<br><br>My main goal is to define a custom residual norm that better reflects the physical quantities of interest in my simulation.<br><br>Would this be feasible within the PETSc framework? If so, could you point me to the recommended approach (e.g., redefining the norm manually, using specific PETSc hooks or options)?<br><br>Thank you very much in advance for your help and for the great work on PETSc!<br><br>Best regards,  <br><br><hr></div><div><span style="font-family:'georgia' , serif">Ali ALI AHMAD</span><br><span style="font-family:'georgia' , serif">PhD Student</span><br><span style="font-family:'georgia' , serif">University of Technology of Troyes - UTT - France</span><br><span style="font-family:'georgia' , serif">GAMMA3 Project - Office H008 - Phone No: +33 7 67 44 68 18</span><br><span style="font-family:'georgia' , serif">12 rue Marie Curie - CS 42060 10004 TROYES Cedex</span></div></div></div></div></div></div></div></div></blockquote></div></div></div></div><br></div></div></div></div></blockquote></div></div><br></div></div></div></div></blockquote></div><br></div></body></html>