Skip to content

Commit e0f31ed

Browse files
authored
Adding a new overload for MultiFab::norm2 (int comp, int numcomp) (#4509)
1 parent 65bf80d commit e0f31ed

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

Src/Base/AMReX_MultiFab.H

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,11 @@ public:
225225
*/
226226
[[nodiscard]] Real norm2 (int comp = 0) const;
227227
/**
228+
* \brief Returns the L2 norm of \p numcomp components starting from \p comp component over the MultiFab.
229+
* No ghost cells are used.
230+
*/
231+
[[nodiscard]] Real norm2 (int comp, int numcomp) const;
232+
/**
228233
* \brief Returns the L2 norm of component \p comp over the MultiFab.
229234
* No ghost cells are used. This version has no double counting for nodal data.
230235
*/

Src/Base/AMReX_MultiFab.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,16 @@ MultiFab::norm2 (int comp) const
10711071
return nm2;
10721072
}
10731073

1074+
Real
1075+
MultiFab::norm2 (int comp, int numcomp) const
1076+
{
1077+
BL_ASSERT(ixType().cellCentered());
1078+
1079+
Real nm2 = MultiFab::Dot(*this, comp, numcomp, 0);
1080+
nm2 = std::sqrt(nm2);
1081+
return nm2;
1082+
}
1083+
10741084
Real
10751085
MultiFab::norm2 (int comp, const Periodicity& period) const
10761086
{

0 commit comments

Comments
 (0)