Do you wish to use a different norm 

   1) ONLY for displaying (printing out) the residual norms to track progress

   2) in the convergence testing

   3) to change the numerical algorithm (for example using the L2 inner product 
instead of the usual linear algebra R^N l2 inner product).

   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.

   For 2) similar but you need to use SNESSetConvergenceTest

   For 3) yes, but you need to ask us specifically.

  Barry


> On Jun 11, 2025, at 4:45 AM, Ali ALI AHMAD <ali.ali_ah...@utt.fr> wrote:
> 
> Dear PETSc team,
> 
> I hope this message finds you well.
> 
> 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).
> 
> My main goal is to define a custom residual norm that better reflects the 
> physical quantities of interest in my simulation.
> 
> 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)?
> 
> Thank you very much in advance for your help and for the great work on PETSc!
> 
> Best regards,  
> 
> Ali ALI AHMAD
> PhD Student
> University of Technology of Troyes - UTT - France
> GAMMA3 Project - Office H008 - Phone No: +33 7 67 44 68 18
> 12 rue Marie Curie - CS 42060 10004 TROYES Cedex

Reply via email to