Skip to content

Commit

Permalink
1) Added parmparse called "plt_multiple_cuts" which is false by defau…
Browse files Browse the repository at this point in the history
…lt and you may choose 'true' in your input file if you want to see the multicut locations.

-> eb2.plt_multiple_cuts = 'true'
2) If (plt_multiple_cuts), we delay aborting the code until finishing up the loop, including the build_cells part.
3) I just made the int total_multicuts to get the final number of multicuts -- to make sure in case it is not the same number as nmulticuts.
  • Loading branch information
ejyoo921 committed Jul 3, 2024
1 parent ac65ec6 commit 70b5111
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
20 changes: 16 additions & 4 deletions Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Real> const& m2z,
GpuArray<Real,AMREX_SPACEDIM> const& dx,
GpuArray<Real,AMREX_SPACEDIM> const& problo,
bool cover_multiple_cuts) noexcept
bool cover_multiple_cuts,
bool plt_multiple_cuts) noexcept
{
Gpu::Buffer<int> nmulticuts = {0};
int* hp = nmulticuts.hostData();
Expand Down Expand Up @@ -823,7 +824,13 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
//EY: Let's see the location of multicuts before aborting!
amrex::Print() << "dx = " << dx[0] << ", dy = " << dx[1] << ", dz = " << dx[2] << "\n";
amrex::Print() << "Total number of multicut cells = " << *hp << "\n";
amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported");

if (plt_multiple_cuts){
amrex::Print() << "Creating outputs for multicut locations." << "\n";
}
else{
amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported");
}
}
}

Expand All @@ -842,7 +849,7 @@ void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Real> const& barea, Array4<Real> const& bcent,
Array4<Real> const& bnorm, Array4<EBCellFlag> const& ctmp,
Array4<Real> const& levset, Real small_volfrac, Geometry const& geom,
bool extend_domain_face, bool cover_multiple_cuts,
bool extend_domain_face, bool cover_multiple_cuts, bool plt_multiple_cuts,
int& nsmallcells, int& nmulticuts) noexcept
{
Gpu::Buffer<int> n_smallcell_multicuts = {0,0};
Expand Down Expand Up @@ -987,7 +994,12 @@ void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,

if (nsmallcells > 0 || nmulticuts > 0) {
if (!cover_multiple_cuts && nmulticuts > 0) {
amrex::Abort("amrex::EB2::build_cells: multi-cuts not supported");
if (plt_multiple_cuts){
amrex::Print() << "Passing EB2::build_cells" << "\n";
}
else{
amrex::Abort("amrex::EB2::build_cells: multi-cuts not supported");
}
}
return;
} else {
Expand Down
5 changes: 3 additions & 2 deletions Src/EB/AMReX_EB2_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Real> const& m2z,
GpuArray<Real,AMREX_SPACEDIM> const& dx,
GpuArray<Real,AMREX_SPACEDIM> const& problo,
bool cover_multiple_cuts) noexcept;
bool cover_multiple_cuts,
bool plt_multiple_cuts) noexcept; //EY

void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Type_t> const& fx, Array4<Type_t> const& fy,
Expand All @@ -69,7 +70,7 @@ void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Real> const& barea, Array4<Real> const& bcent,
Array4<Real> const& bnorm, Array4<EBCellFlag> const& ctmp,
Array4<Real> const& levset, Real small_volfrac, Geometry const& geom,
bool extend_domain_face, bool cover_multiple_cuts,
bool extend_domain_face, bool cover_multiple_cuts, bool plt_multiple_cuts, //EY
int& nsmallcells, int& nmulticuts) noexcept;

void set_connection_flags(Box const& bx, Box const& bxg1,
Expand Down
12 changes: 10 additions & 2 deletions Src/EB/AMReX_EB2_Level.H
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,14 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
Real small_volfrac = 1.e-14;
#endif
bool cover_multiple_cuts = false;
bool plt_multiple_cuts = false; //EY
int maxiter = 32;
{
ParmParse pp("eb2");
pp.queryAdd("small_volfrac", small_volfrac);
pp.queryAdd("cover_multiple_cuts", cover_multiple_cuts);
pp.queryAdd("maxiter", maxiter);
pp.queryAdd("plt_multiple_cuts", plt_multiple_cuts); //EY
}
maxiter = std::min(100000, maxiter);

Expand Down Expand Up @@ -315,6 +317,7 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
amrex::ignore_unused(hybrid);

int iter = 0;
int total_multicuts = 0; //EY
for (; iter < maxiter; ++iter)
{
int nsmallcells = 0;
Expand Down Expand Up @@ -415,7 +418,7 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,

nmc = build_faces(vbx, cfg, ftx, fty, ftz, xdg, ydg, zdg, lst,
xip, yip, zip, apx, apy, apz, fcx, fcy, fcz,
xm2, ym2, zm2, dx, problo, cover_multiple_cuts);
xm2, ym2, zm2, dx, problo, cover_multiple_cuts, plt_multiple_cuts);

cellflagtmp.resize(m_cellflag[mfi].box());
Elixir cellflagtmp_eli = cellflagtmp.elixir();
Expand All @@ -424,7 +427,7 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
build_cells(vbx, cfg, ftx, fty, ftz, apx, apy, apz,
fcx, fcy, fcz, xm2, ym2, zm2, dx, vfr, ctr,
bar, bct, bnm, cfgtmp, lst,
small_volfrac, geom, extend_domain_face, cover_multiple_cuts,
small_volfrac, geom, extend_domain_face, cover_multiple_cuts, plt_multiple_cuts,
nsm, nmc);

// Because it is used in a synchronous reduction kernel in
Expand Down Expand Up @@ -496,6 +499,11 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
}
}
}
total_multicuts = total_multicuts + nmulticuts;
}
if (plt_multiple_cuts){
amrex::Print() << "Grand total multicuts = " << total_multicuts << "\n";
amrex::Abort("EY: amrex::EB2::build_faces: more than 2 cuts not supported"); // move this
}

AMREX_ALWAYS_ASSERT_WITH_MESSAGE(iter < maxiter, "EB: failed to fix small cells");
Expand Down

0 comments on commit 70b5111

Please sign in to comment.