AMReX-Codes / amrex

AMReX: Software Framework for Block Structured AMR
https://amrex-codes.github.io/amrex
Other
503 stars 336 forks source link

Fix L2 norms in C_util/Convergence codes #4009

Closed ajnonaka closed 1 week ago

ajnonaka commented 1 week ago

Summary

The multifab L2 norm routines simply return sum(a dot a). Thus, when you sum up norms from each grid you do NOT need to take them to the ^NORM power. The cell count (i.e. volume) scaling is performed lower

The formula is now implemented correctly, for p!=0:

L^p = ( 1/Ncell sum (phi_f - phi_c)^p ) ^(1/p)

(note that using cell volume instead of 1/Ncell accomplishes the proper scaling as well, which is what the code does)

Additional background

Checklist

The proposed changes:

zingale commented 1 week ago

note that it also worked for p =1

zingale commented 1 week ago

this is a nice catch. L2 never behaved well for me