Skip to content

Commit

Permalink
Fix L2 norms in C_util/Convergence codes (#4009)
Browse files Browse the repository at this point in the history
## 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:
- [x] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
ajnonaka authored Jun 26, 2024
1 parent 463bdf4 commit 2f93525
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/DiffSameDomainRefined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/DiffSameDomainRefinedFD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/DiffSameDomainRefinedStag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/DiffSameGridRefined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/PltFileNormB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ main (int argc,

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion Tools/C_util/Convergence/RichardsonConvergenceTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ getErrorNorms(Vector<Real>& a_norms, //one for each comp

if (norm != 0)
{
norms[iComp] = norms[iComp] + pow(grdL2, norm);
norms[iComp] = norms[iComp] + grdL2;
}
else
{
Expand Down

0 comments on commit 2f93525

Please sign in to comment.