Skip to content

Commit

Permalink
1) Created a multicut called 'multicut_bx'.
Browse files Browse the repository at this point in the history
2) This is used as an input for build_faces.
3) Simply set value - multicut_arr(i,j,k) = 10.0 -  whenever we detect multicut.
4) In AMReX_EB2_Level.H (line 494 - ), we first check if multicut_arr stored the multicut locations (value 10.0).
 - this will be removed once we get right plot file.
5) The hope is that we get "volume" of multicut location when we read the plt file.
6) We probably do not need anything in this line, except the line 508 (WriteSingleLevelPlotfile).
 - The question is: Is this enought to see the multicuts?
  • Loading branch information
ejyoo921 committed Jul 29, 2024
1 parent 92c65fa commit 4b4b890
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
6 changes: 5 additions & 1 deletion Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
GpuArray<Real,AMREX_SPACEDIM> const& dx,
GpuArray<Real,AMREX_SPACEDIM> const& problo,
bool cover_multiple_cuts,
bool plt_multiple_cuts) noexcept
bool plt_multiple_cuts, Array4<Real> const& multicut_arr) noexcept
{
Gpu::Buffer<int> nmulticuts = {0};
int* hp = nmulticuts.hostData();
Expand Down Expand Up @@ -465,6 +465,8 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
if (ncuts > 2) {
Gpu::Atomic::Add(dp,1);
if (plt_multiple_cuts){
multicut_arr(i,j,k) = 10.0;
amrex::Print() << "Multicut array (i,j,k) = (" << i << ", " << j << ", " << k << ") " << "\n";
// Not GPU friendly
amrex::PrintToFile("loc_multicuts") << "fx: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
}
Expand Down Expand Up @@ -577,6 +579,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
if (ncuts > 2) {
Gpu::Atomic::Add(dp,1);
if (plt_multiple_cuts){
multicut_arr(i,j,k) = 10.0;
// Not GPU friendly
amrex::PrintToFile("loc_multicuts") << "fy: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
}
Expand Down Expand Up @@ -689,6 +692,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
if (ncuts > 2) {
Gpu::Atomic::Add(dp,1);
if (plt_multiple_cuts){
multicut_arr(i,j,k) = 10.0;
// Not GPU friendly
amrex::PrintToFile("loc_multicuts") << "fz: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
}
Expand Down
2 changes: 1 addition & 1 deletion Src/EB/AMReX_EB2_C.H
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
GpuArray<Real,AMREX_SPACEDIM> const& dx,
GpuArray<Real,AMREX_SPACEDIM> const& problo,
bool cover_multiple_cuts,
bool plt_multiple_cuts) noexcept; //EY
bool plt_multiple_cuts, Array4<Real> const& multicut_arr) noexcept; //EY

void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Type_t> const& fx, Array4<Type_t> const& fy,
Expand Down
42 changes: 24 additions & 18 deletions Src/EB/AMReX_EB2_Level.H
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,9 @@ protected:
bool m_has_eb_info = true;
IndexSpace const* m_parent;

//EY
MultiFab multicut_bx;

private:
template <typename G> friend class GShopLevel;

Expand Down Expand Up @@ -295,6 +298,9 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
m_bndryarea.define(m_grids, m_dmap, 1, ng, mf_info);
m_bndrycent.define(m_grids, m_dmap, AMREX_SPACEDIM, ng, mf_info);
m_bndrynorm.define(m_grids, m_dmap, AMREX_SPACEDIM, ng, mf_info);
//EY
multicut_bx.define(m_grids, m_dmap, 1, ng, mf_info);

for (int idim = 0; idim < AMREX_SPACEDIM; ++idim) {
m_areafrac[idim].define(amrex::convert(m_grids, IntVect::TheDimensionVector(idim)),
m_dmap, 1, ng, mf_info);
Expand Down Expand Up @@ -360,6 +366,9 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
Array4<Real> const& bar = m_bndryarea.array(mfi);
Array4<Real> const& bct = m_bndrycent.array(mfi);
Array4<Real> const& bnm = m_bndrynorm.array(mfi);
//EY:
Array4<Real> const& multicut_arr = multicut_bx.array(mfi);

AMREX_D_TERM(Array4<Real> const& apx = m_areafrac[0].array(mfi);,
Array4<Real> const& apy = m_areafrac[1].array(mfi);,
Array4<Real> const& apz = m_areafrac[2].array(mfi););
Expand Down Expand Up @@ -421,7 +430,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, plt_multiple_cuts);
xm2, ym2, zm2, dx, problo, cover_multiple_cuts, plt_multiple_cuts, multicut_arr);

cellflagtmp.resize(m_cellflag[mfi].box());
Elixir cellflagtmp_eli = cellflagtmp.elixir();
Expand Down Expand Up @@ -484,24 +493,21 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
}
// EY: Here -> make plot file
if (plt_multiple_cuts){
amrex::Print() << "Nmulticuts = " << nmulticuts << "\n";
for (MFIter mfi(m_mgf); mfi.isValid(); ++mfi)
{
AMREX_HOST_DEVICE_FOR_3D ( domain_grown, i, j, k,
{
Array4<Real> const& multicut_arr = multicut_bx.array(mfi);
if (multicut_arr(i,j,k) > 1) // Need to fix this condition
{
amrex::Print() << "Multicut array = (" << i << ", " << j << ", " << k << ") \n";
}
});
}
// Output: plotfiles
int i = 1; int j = 1; int k = 1;
RealBox real_box({AMREX_D_DECL(problo[0]+(i)*dx[0], problo[1]+(j)*dx[1], problo[2]+(k)*dx[2])},
{AMREX_D_DECL(problo[0]+(i+1)*dx[0], problo[1]+(j+1)*dx[1], problo[2]+(k+1)*dx[2])});

Geometry geom(domain, real_box, CoordSys::cartesian,{0,0,0});
BoxArray ba(domain);
BoxArray nodal_ba = amrex::convert(ba, IntVect::TheNodeVector());
DistributionMapping dm(ba);

int nghost = 1;
MultiFab flag_xbx;
flag_xbx.define(nodal_ba, dm, 1, nghost);
const std::string& plotfilename = amrex::Concatenate("plt", total_multicuts);
WriteSingleLevelPlotfile(plotfilename, flag_xbx, {"marker_x"}, geom, 0.0, 0);

amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported"); // move this
WriteSingleLevelPlotfile("plt", multicut_bx, {"multicut"}, geom, 0.0, 0);

amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported");
}
}

Expand Down

0 comments on commit 4b4b890

Please sign in to comment.