Skip to content

Commit

Permalink
Fix plane norm with multilevel.
Browse files Browse the repository at this point in the history
  • Loading branch information
AMLattanzi committed Dec 20, 2024
1 parent b80c2b2 commit d2ce0d4
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions Source/BoundaryConditions/ERF_MOSTAverage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,30 +310,46 @@ MOSTAverage::set_plane_normalization ()
m_plane_average.resize(m_maxlev);

for (int lev(0); lev < m_maxlev; lev++) {
// True domain not used for normalization
Box domain = m_geom[lev].Domain();

// NOTE: Level 0 spans the whole domain, but finer
// levels do not have such a restriction.
// For now, use the bounding box of the boxArray
// for normalization, consistent with avg routine.

// Bounded box of CC data used for normalization
Box bnd_bx = (m_fields[lev][0]->boxArray()).minimalBox();

// NOTE: Bounding box must lie on the periodic boundaries
// in order to trip the is_per flag

// Num components, plane avg, cells per plane
Array<int,AMREX_SPACEDIM> is_per = {0,0,0};
for (int idim(0); idim < AMREX_SPACEDIM-1; ++idim) {
if (m_geom[lev].isPeriodic(idim)) is_per[idim] = 1;
if ( m_geom[lev].isPeriodic(idim) &&
bnd_bx.bigEnd(idim)==domain.bigEnd(idim) &&
bnd_bx.smallEnd(idim)==domain.smallEnd(idim) ) { is_per[idim] = 1; }
}
Box domain = m_geom[lev].Domain();

m_ncell_plane[lev].resize(m_navg);
m_plane_average[lev].resize(m_navg);
for (int iavg(0); iavg < m_navg; ++iavg) {
// Convert domain to current index type
// Convert bnd_bx to current index type
IndexType ixt = m_averages[lev][iavg]->boxArray().ixType();
domain.convert(ixt);
IntVect dom_lo(domain.loVect());
IntVect dom_hi(domain.hiVect());
bnd_bx.convert(ixt);
IntVect bnd_bx_lo(bnd_bx.loVect());
IntVect bnd_bx_hi(bnd_bx.hiVect());

m_plane_average[lev][iavg] = 0.0;

m_ncell_plane[lev][iavg] = 1;
for (int idim(0); idim < AMREX_SPACEDIM; ++idim) {
if (idim != 2) {
if (ixt.nodeCentered(idim) && is_per[idim]) {
m_ncell_plane[lev][iavg] *= (dom_hi[idim] - dom_lo[idim]);
m_ncell_plane[lev][iavg] *= (bnd_bx_hi[idim] - bnd_bx_lo[idim]);
} else {
m_ncell_plane[lev][iavg] *= (dom_hi[idim] - dom_lo[idim] + 1);
m_ncell_plane[lev][iavg] *= (bnd_bx_hi[idim] - bnd_bx_lo[idim] + 1);
}
}
} // idim
Expand Down

0 comments on commit d2ce0d4

Please sign in to comment.