<html><body><div style="font-family: arial, helvetica, sans-serif; font-size: 12pt; color: #000000"><div>* As I mentioned earlier, the weighted norm I am referring to is:</div><div><br data-mce-bogus="1"></div><div>||f||^2_2 = \int_{\Omega} |f(x)|^2 \, dx \approx \sum_{K \in \Omega} \sum_q |f(G_q)|^2 \, area(K)<br><br></div><div><p data-start="518" data-end="619" style="margin: 0px;" data-mce-style="margin: 0px;">where <code data-start="524" data-end="529">G_q</code> is the centroid of triangle <code data-start="558" data-end="561">K</code>, computed using a first-order Gaussian quadrature rule.</p><p data-start="518" data-end="619" style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p data-start="621" data-end="693" style="margin: 0px;" data-mce-style="margin: 0px;">Yes, I am using the inexact Newton method, where the method stops when</p><p data-start="621" data-end="693" style="margin: 0px;" data-mce-style="margin: 0px;"><br></p><p data-start="621" data-end="693" style="margin: 0px;" data-mce-style="margin: 0px;">||F(x_k) + J_{x_k} \, d_k|| \leq \nu_k \, ||F(x_k)||.<br></p><p data-start="621" data-end="693" style="margin: 0px;" data-mce-style="margin: 0px;"><br data-mce-bogus="1"></p><p data-start="759" data-end="1098" style="margin: 0px;" data-mce-style="margin: 0px;">Here, I would also like to change the norm to see whether this modification affects the quality of the descent direction. I know that these norms are theoretically equivalent, but I would like to test them to observe any difference between the two. My initial expectation is that the method may converge faster when using the <code data-start="1085" data-end="1090">L^2</code> norm.</p><p data-start="759" data-end="1098" style="margin: 0px;" data-mce-style="margin: 0px;"><br data-mce-bogus="1"></p><p data-start="1100" data-end="1129" style="margin: 0px;" data-mce-style="margin: 0px;">Best regards,</p><p data-start="621" data-end="693" style="margin: 0px;" data-mce-style="margin: 0px;">Ali ALI AHMAD</p></div><hr id="zwchr" data-marker="__DIVIDER__"><div data-marker="__HEADERS__"><b>De: </b>"Matthew Knepley" <knepley@gmail.com><br><b>À: </b>"Ali ALI AHMAD" <ali.ali_ahmad@utt.fr><br><b>Cc: </b>"Barry Smith" <bsmith@petsc.dev>, "petsc-users" <petsc-users@mcs.anl.gov>, "petsc-maint" <petsc-maint@mcs.anl.gov><br><b>Envoyé: </b>Lundi 28 Juillet 2025 18:55:04<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__"><div dir="ltr"><div dir="ltr">On Mon, Jul 28, 2025 at 11:00 AM Ali ALI AHMAD <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>> wrote:</div><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb( 204 , 204 , 204 );padding-left:1ex"><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )"><p style="margin:0px">I’m sorry for getting back to you so late. Thank you for your patience and understanding.</p><ul><li><p style="margin:0px">For example, when using L2 algorithms where a different norm is applied in the line search, see <em>Line_search_L2.png</em> as an example from this reference: <a rel="noopener nofollow noopener noreferrer" href="https://urldefense.us/v3/__https://arxiv.org/abs/1607.04254__;!!G_uCfscf7eWS!ep85s6aXge00Uc1_kixR9yGEU0FBO9W8HTZ6LsVYzy9n9Jel5_r26mPMP138k1Ilhi2CAN6cR4DGe4kKZG997W1E0q3AIw$" target="_blank">https://arxiv.org/abs/1607.04254</a>. Here, we can change the norm from the L2 Euclidean to the L2 Lebesgue norm.</p></li></ul></div></div></blockquote><div>What does "L2 Lebesgue" mean here? I know what I mean by L_2. It is</div><br><div> ||f||^2_2 = \int_Omega |f(x)|^2 dx \approx \sum_q |f(x_q)|^2 w_q</div><br><div>Oh, from below it seems you want a weight function wt(x) in the norm. So we would have</div><div> </div><div> \sum_q |f(x_q)|^2 wt(x_q) w_q</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb( 204 , 204 , 204 );padding-left:1ex"><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )"><ul><li>For GMRES, we need to replace NORM_2 (L2 Euclidean) in your code with <code>weighted_NormL2</code> (L2 Lebesgue) everywhere, including all the details such as in the Arnoldi algorithm...</li></ul></div></div></blockquote><div>I do not quite understand here, because GMRES does not use the L:_2 norm. It uses the l_2 norm, which is</div><br><div> ||v||^2_2 = \sum |v_i|^2</div><br><div>The things in the vector are coefficients of basis functions. I guess, if you had an interpolatory element, you could interpret this as quadrature rule, meaning you would have</div><br><div> \sum wt(x_i) |v_i|^2</div><br><div>where x_i were the coordinates of the dual basis evaluation functionals.</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb( 204 , 204 , 204 );padding-left:1ex"><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )"><ul><li><p style="margin:0px">For the convergence test as well, in the linear system for finding the direction <strong>d</strong> (A · d = b),</p></li></ul></div></div></blockquote><div>You want to use the inner product that generates your weighted L_2 norm? </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb( 204 , 204 , 204 );padding-left:1ex"><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )"><ul><li><p style="margin:0px"> and also when we search for a good step using the line search formula: xk+1=xk+step×d.</p></li></ul><p style="margin:0px"></p></div></div></blockquote><div>You want to minimize your weighted L_2 norm. That should work in the same way.</div><br><div> Thanks,</div><br><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb( 204 , 204 , 204 );padding-left:1ex"><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt;color:rgb( 0 , 0 , 0 )"><p style="margin:0px">I hope this explanation is clear for you.</p><div><div style="margin:0px"><br></div><div style="margin:0px">Best regards,</div><div style="margin:0px">Ali ALI AHMAD</div></div><br><hr id="m_9025547959178601274zwchr"><div><b>De: </b>"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank" rel="nofollow noopener noreferrer">bsmith@petsc.dev</a>><br><b>À: </b>"Ali ALI AHMAD" <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>><br><b>Cc: </b>"petsc-users" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-users@mcs.anl.gov</a>>, "petsc-maint" <<a href="mailto:petsc-maint@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-maint@mcs.anl.gov</a>><br><b>Envoyé: </b>Vendredi 20 Juin 2025 15:50:17<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><br id="m_9025547959178601274lineBreakAtBeginningOfMessage"><div><br><blockquote><div>On Jun 20, 2025, at 5:10 AM, Ali ALI AHMAD <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>> wrote:</div><br><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><br><div><div style="margin:0px">* Yes, I am indeed using an inexact Newton method in my code. The descent direction is computed by solving a linear system involving the Jacobian, so the update follows the classical formula "J(un)^{-1}d(un)=-F(un)" I'm also trying to use a line search strategy based on a weighted L2 norm (in the Lebesgue sense), which a priori should lead to better accuracy and faster convergence in anisotropic settings.</div></div></div></div></div></blockquote><br> Ok, could you point to sample code (any language) or written algorithms where a different norm is used in the line search?</div><div><br><blockquote><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div><div style="margin:0px"><br></div><div style="margin:0px">* During the subsequent iterations, I apply the Eisenstat–Walker method to adapt the tolerance, which should also involve modifying the norm used in the algorithm.</div><div style="margin:0px"><br></div><div style="margin:0px">* The current implementation still uses the standard Euclidean L2 norm in PETSc's linear solver and in GMRES. I believe this should ideally be replaced by a weighted L2 norm consistent with the discretization. However, I haven't yet succeeded in modifying the norm used internally by the linear solver in PETSc, so, I'm not yet sure how much impact this change would have on the overall convergence, but I suspect it could improve robustness, especially for highly anisotropic problems. I would greatly appreciate any guidance on how to implement this properly in PETSc.</div></div></div></div></div></blockquote><br> Norms are used in multiple ways in GMRES. </div><br><div> 1) defining convergence</div><br><div> 2) as part of preconditioning</div><br><div> Again can you point to sample code (any language) or written algorithms that describe exactly what you would like to accomplish.</div><br><div> Barry</div><div><br><blockquote><div><div><div style="font-family:'arial' , 'helvetica' , sans-serif;font-size:12pt"><div><div style="margin:0px"><br></div><div style="margin:0px">Do not hesitate to contact me again if anything remains unclear or if you need further information.</div><div style="margin:0px"><br></div><div style="margin:0px">Best regards,</div><div style="margin:0px">Ali ALI AHMAD</div><div style="margin:0px"><br></div></div><hr id="m_9025547959178601274zwchr"><div><b>De: </b>"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank" rel="nofollow noopener noreferrer">bsmith@petsc.dev</a>><br><b>À: </b>"Ali ALI AHMAD" <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>><br><b>Cc: </b>"petsc-users" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-users@mcs.anl.gov</a>>, "petsc-maint" <<a href="mailto:petsc-maint@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-maint@mcs.anl.gov</a>><br><b>Envoyé: </b>Samedi 14 Juin 2025 01:06:52<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>I appreciate the clarification. I would call 3) preconditioning. <br><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><br><div> When you switch the inner product (or precondition) how will the search direction be different?</div><br><div> Thanks</div><br><div> Barry</div><br><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><br><br><div><div><br><blockquote><div>On Jun 13, 2025, at 4:55 AM, Ali ALI AHMAD <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>> wrote:</div><br><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></div><div style="margin:0px">To answer your question: I would like to use the L2 norm in the sense of Lebesgue for <strong>all three purposes</strong>, especially the <strong>third one</strong>.</div><div style="margin:0px"><strong><br></strong></div><div style="margin:0px"><strong>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><br></strong></div><div style="margin:0px"><strong>2- For convergence testing</strong>, I would like the stopping criterion to be based on a weighted L2 norm that accounts for the geometry of the mesh (since I am working with unstructured, anisotropic triangular meshes).</div><div style="margin:0px"><strong><br></strong></div><div style="margin:0px"><strong>3 - Most importantly</strong>, I would like to modify the <strong>inner product</strong> used in the algorithm so that it aligns with the weighted L2 norm (since I am working with unstructured, anisotropic triangular meshes).</div><div style="margin:0px"><br></div></div><div><div><div style="margin:0px">Best regards,</div></div><div>Ali ALI AHMAD</div></div><hr id="m_9025547959178601274zwchr"><div><b>De: </b>"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank" rel="nofollow noopener noreferrer">bsmith@petsc.dev</a>><br><b>À: </b>"Ali ALI AHMAD" <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>><br><b>Cc: </b>"petsc-users" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-users@mcs.anl.gov</a>>, "petsc-maint" <<a href="mailto:petsc-maint@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-maint@mcs.anl.gov</a>><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><br><div>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="m_9025547959178601274lineBreakAtBeginningOfMessage"><div><br><blockquote><div>On Jun 12, 2025, at 9:42 AM, Ali ALI AHMAD <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>> wrote:</div><br><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 L2 norm</strong> with the <strong>L2 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="m_9025547959178601274zwchr"><div><b>De: </b>"Ali ALI AHMAD" <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>><br><b>À: </b>"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank" rel="nofollow noopener noreferrer">bsmith@petsc.dev</a>><br><b>Cc: </b>"petsc-users" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-users@mcs.anl.gov</a>>, "petsc-maint" <<a href="mailto:petsc-maint@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-maint@mcs.anl.gov</a>><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 L2 norm</strong> with the <strong>L2 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="m_9025547959178601274zwchr"><div><b>De: </b>"Barry Smith" <<a href="mailto:bsmith@petsc.dev" target="_blank" rel="nofollow noopener noreferrer">bsmith@petsc.dev</a>><br><b>À: </b>"Ali ALI AHMAD" <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>><br><b>Cc: </b>"petsc-users" <<a href="mailto:petsc-users@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-users@mcs.anl.gov</a>>, "petsc-maint" <<a href="mailto:petsc-maint@mcs.anl.gov" target="_blank" rel="nofollow noopener noreferrer">petsc-maint@mcs.anl.gov</a>><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="m_9025547959178601274lineBreakAtBeginningOfMessage"><div><br><blockquote><div>On Jun 11, 2025, at 4:45 AM, Ali ALI AHMAD <<a href="mailto:ali.ali_ahmad@utt.fr" target="_blank" rel="nofollow noopener noreferrer">ali.ali_ahmad@utt.fr</a>> wrote:</div><br><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></div></div></div></div></div></blockquote></div><br></div></div></div></blockquote></div><div><br clear="all"></div><br><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><br><div><a href="https://urldefense.us/v3/__http://www.cse.buffalo.edu/*knepley/__;fg!!G_uCfscf7eWS!fiC1n5vGsbqOyw1uxsDvcoyysDPSuMVX-X60t2a22q6RxvgToFh_JTCqhACBSTB33XlfjUocJoQh741gmrYyKTuWi3OAYA$" target="_blank" rel="nofollow noopener noreferrer">https://www.cse.buffalo.edu/~knepley/</a><br data-mce-bogus="1"></div></div></div></div></div></div></div></div><br></div></div></body></html>