Skip to content

Commit

Permalink
Reset EB Fab Type (AMReX-Codes#3552)
Browse files Browse the repository at this point in the history
This is a follow-up on AMReX-Codes#3549. After extending EB data outside the
domain, we need to update the EB Fab type.
  • Loading branch information
WeiqunZhang authored Sep 17, 2023
1 parent 1aea95c commit 48b3ec7
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
8 changes: 1 addition & 7 deletions Src/EB/AMReX_EB2_Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,7 @@ Level::fillEBCellFlag (FabArray<EBCellFlagFab>& cellflag, const Geometry& geom)
}

// fix type for each fab
fab.setType(FabType::undefined);
auto typ = fab.getType(bx);
fab.setType(typ);
for (int nshrink = 1; nshrink < ng; ++nshrink) {
const Box& b = amrex::grow(bx,-nshrink);
fab.getType(b);
}
fab.resetType(ng);
}
}
}
Expand Down
5 changes: 5 additions & 0 deletions Src/EB/AMReX_EBCellFlag.H
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,11 @@ public:
*/
FabType getType (const Box& bx) const noexcept;

/**
* \brief Reset FabType
*/
void resetType (int ng);

/**
* \brief Returns the number of regular cells in the given Box.
*/
Expand Down
15 changes: 15 additions & 0 deletions Src/EB/AMReX_EBCellFlag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,21 @@ EBCellFlagFab::getType (const Box& bx_in) const noexcept
}
}

void
EBCellFlagFab::resetType (int ng)
{
this->setType(FabType::undefined);
m_typemap.clear();

Box const& bx = this->box();
auto typ = this->getType(bx);
this->setType(typ);
for (int nshrink = 1; nshrink < ng; ++nshrink) {
const Box& b = amrex::grow(bx,-nshrink);
this->getType(b);
}
}

int
EBCellFlagFab::getNumRegularCells (const Box& bx_in) const noexcept
{
Expand Down
11 changes: 11 additions & 0 deletions Src/EB/AMReX_EBDataCollection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,11 @@ void EBDataCollection::extendDataOutsideDomain (IntVect const& level_ng)
#pragma omp parallel if (Gpu::notInLaunchRegion())
#endif
for (MFIter mfi(*m_cellflags); mfi.isValid(); ++mfi) {
auto const current_type = (*m_cellflags)[mfi].getType();
// Because the default value for EBCellFlagFab is regular cell, we
// can skip a regular fab.
if (current_type == FabType::regular) { continue; }

Box const& bx = mfi.fabbox();
if (! level_domain.contains(bx)) {
Box const& nbx = amrex::surroundingNodes(bx);
Expand Down Expand Up @@ -218,6 +223,12 @@ void EBDataCollection::extendDataOutsideDomain (IntVect const& level_ng)
});
}
}

if ((*m_cellflags)[mfi].getType(mfi.validbox()) != FabType::singlevalued) {
// If it's already a cut fab in the valid region, the change in
// ghost cells will not change the fab types.
(*m_cellflags)[mfi].resetType(ngrow);
}
}
}
}
Expand Down

0 comments on commit 48b3ec7

Please sign in to comment.