Skip to content

Commit 2f93525

Browse files
authored
Fix L2 norms in C_util/Convergence codes (#4009)
## 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
1 parent 463bdf4 commit 2f93525

File tree

7 files changed

+7
-7
lines changed

7 files changed

+7
-7
lines changed

Tools/C_util/Convergence/DiffSameDomainRefined.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ main (int argc,
245245

246246
if (norm != 0)
247247
{
248-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
248+
norms[iComp] = norms[iComp] + grdL2;
249249
}
250250
else
251251
{

Tools/C_util/Convergence/DiffSameDomainRefinedComposite.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ main (int argc,
269269

270270
if (norm != 0)
271271
{
272-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
272+
norms[iComp] = norms[iComp] + grdL2;
273273
}
274274
else
275275
{

Tools/C_util/Convergence/DiffSameDomainRefinedFD.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ main (int argc,
245245

246246
if (norm != 0)
247247
{
248-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
248+
norms[iComp] = norms[iComp] + grdL2;
249249
}
250250
else
251251
{

Tools/C_util/Convergence/DiffSameDomainRefinedStag.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ main (int argc,
272272

273273
if (norm != 0)
274274
{
275-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
275+
norms[iComp] = norms[iComp] + grdL2;
276276
}
277277
else
278278
{

Tools/C_util/Convergence/DiffSameGridRefined.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ main (int argc,
238238

239239
if (norm != 0)
240240
{
241-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
241+
norms[iComp] = norms[iComp] + grdL2;
242242
}
243243
else
244244
{

Tools/C_util/Convergence/PltFileNormB.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ main (int argc,
131131

132132
if (norm != 0)
133133
{
134-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
134+
norms[iComp] = norms[iComp] + grdL2;
135135
}
136136
else
137137
{

Tools/C_util/Convergence/RichardsonConvergenceTest.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ getErrorNorms(Vector<Real>& a_norms, //one for each comp
306306

307307
if (norm != 0)
308308
{
309-
norms[iComp] = norms[iComp] + pow(grdL2, norm);
309+
norms[iComp] = norms[iComp] + grdL2;
310310
}
311311
else
312312
{

0 commit comments

Comments
 (0)