Skip to content

Commit

Permalink
cleaned up some useless comments. Now writing (i,j,k) and face boxes …
Browse files Browse the repository at this point in the history
…locations in using PrintToFile in AMReX_EB2_3D_C.cpp file. Also, most importantly, I fixed a stupid if-condition mistake in AMReX_EB2_Level.H: line 502. We should not abort the code when no multicuts present but plt_multiple_cuts = true
  • Loading branch information
ejyoo921 committed Aug 26, 2024
1 parent 1a7edb3 commit 5fe3c8e
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 33 deletions.
20 changes: 13 additions & 7 deletions Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include <AMReX_EB2_C.H>
//EY

#include <AMReX_MultiFab.H>
#include <AMReX_PlotFileUtil.H>

Expand Down Expand Up @@ -468,7 +468,9 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
mt_fcx(i,j,k,0) = 10.0;

#ifndef AMREX_USE_GPU
amrex::PrintToFile("loc_multicuts") << "fx: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
amrex::PrintToFile("loc_multicuts") << "xbx = " << xbx << "\n";
amrex::PrintToFile("loc_multicuts") << "-> fx: (i,j,k) = (" << i << ","<< j << "," << k << ") / "
<< "(x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
#endif
}
}
Expand Down Expand Up @@ -583,7 +585,9 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
mt_fcy(i,j,k,0) = 10.0;

#ifndef AMREX_USE_GPU
amrex::PrintToFile("loc_multicuts") << "fy: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
amrex::PrintToFile("loc_multicuts") << "ybx = " << ybx << "\n";
amrex::PrintToFile("loc_multicuts") << "-> fy: (i,j,k) = (" << i << ","<< j << "," << k << ") / "
<< "(x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
#endif
}
}
Expand Down Expand Up @@ -698,7 +702,9 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
mt_fcz(i,j,k,0) = 10.0;

#ifndef AMREX_USE_GPU
amrex::PrintToFile("loc_multicuts") << "fz: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
amrex::PrintToFile("loc_multicuts") << "zbx = " << zbx << "\n";
amrex::PrintToFile("loc_multicuts") << "-> fz: (i,j,k) = (" << i << ","<< j << "," << k << ") / "
<< "(x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n";
#endif
}
}
Expand Down Expand Up @@ -791,14 +797,14 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
}
});
} else {
//EY: Let's see the location of multicuts before aborting!
// Passing now to plot the location of multicuts before aborting!
amrex::Print() << "Total number of multicut cells = " << *hp << "\n";

if (plt_multiple_cuts){
amrex::Print() << "Creating outputs for multicut locations." << "\n";
amrex::Print() << "Creating outputs for multicut locations..." << "\n";
}
else{
amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported");
amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported!");
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions 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, Array4<Real> const& mt_fcx, Array4<Real> const& mt_fcy, Array4<Real> const& mt_fcz) noexcept; //EY
bool plt_multiple_cuts, Array4<Real> const& mt_fcx, Array4<Real> const& mt_fcy, Array4<Real> const& mt_fcz) noexcept;

void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Type_t> const& fx, Array4<Type_t> const& fy,
Expand All @@ -70,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 plt_multiple_cuts, //EY
bool extend_domain_face, bool cover_multiple_cuts, bool plt_multiple_cuts,
int& nsmallcells, int& nmulticuts) noexcept;

void set_connection_flags(Box const& bx, Box const& bxg1,
Expand Down
29 changes: 5 additions & 24 deletions Src/EB/AMReX_EB2_Level.H
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ protected:
bool m_has_eb_info = true;
IndexSpace const* m_parent;

//EY
Vector<MultiFab> multicut_mf; // test in progress
Array<MultiFab,AMREX_SPACEDIM> multicut_face; // store on face-centered

MultiFab multicut_fcx;
MultiFab multicut_fcy;
MultiFab multicut_fcz;
Expand Down Expand Up @@ -303,10 +299,6 @@ 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
// amrex::Print() << "MAKE VECTOR MULTIFAB MF" << "\n";
// multicut_mf[0].define(m_grids, m_dmap, 1, 0, mf_info, MultiCutFab()); // this should be a leveldata
// amrex::Print() << "AFTER VECTOR MULTIFAB MF" << "\n";

multicut_fcx.define(m_grids, m_dmap, 1, ng, mf_info); //this is cell-centered values storage
multicut_fcy.define(m_grids, m_dmap, 1, ng, mf_info); // need to be fora similar to m_areafrac
Expand All @@ -317,10 +309,6 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
m_dmap, 1, ng, mf_info);
m_facecent[idim].define(amrex::convert(m_grids, IntVect::TheDimensionVector(idim)),
m_dmap, AMREX_SPACEDIM-1, ng, mf_info);
// EY: multicuts------------------------------------------------------------------------
multicut_face[idim].define(amrex::convert(m_grids, IntVect::TheDimensionVector(idim)),
m_dmap, AMREX_SPACEDIM-1, ng, mf_info);
//--------------------------------------------------------------------------------------
IntVect edge_type{1}; edge_type[idim] = 0;
m_edgecent[idim].define(amrex::convert(m_grids, edge_type), m_dmap, 1, ng, mf_info);
}
Expand Down Expand Up @@ -380,16 +368,10 @@ 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: multicuts-------------------------------------------------------
//Individual MFs

Array4<Real> const& multicut_arr_x = multicut_fcx.array(mfi);
Array4<Real> const& multicut_arr_y = multicut_fcy.array(mfi);
Array4<Real> const& multicut_arr_z = multicut_fcz.array(mfi);
//face center MF
AMREX_D_TERM(Array4<Real> const& mt_fcx = multicut_face[0].array(mfi);,
Array4<Real> const& mt_fcy = multicut_face[1].array(mfi);,
Array4<Real> const& mt_fcz = multicut_face[2].array(mfi););
//----------------------------------------------------------------------

AMREX_D_TERM(Array4<Real> const& apx = m_areafrac[0].array(mfi);,
Array4<Real> const& apy = m_areafrac[1].array(mfi);,
Expand Down Expand Up @@ -516,12 +498,11 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
}

ParallelAllReduce::Sum<int>({nsmallcells,nmulticuts}, ParallelContext::CommunicatorSub());
// EY: Here -> make plot file
if (plt_multiple_cuts)

if (plt_multiple_cuts && nmulticuts > 0)
{
int finest_level = 0;
int lev = finest_level;
amrex::Print() << "MAKE PLOT FILE FOR MULTICUTS" << "\n";
amrex::Print() << "Total number of multicuts = " << nmulticuts << "\n";
amrex::Print() << "plotting multicut locations..." << "\n";

WriteSingleLevelPlotfile("plt.x", multicut_fcx, {"multicut_x"}, geom, 0.0, 0);
WriteSingleLevelPlotfile("plt.y", multicut_fcy, {"multicut_y"}, geom, 0.0, 0);
Expand Down

0 comments on commit 5fe3c8e

Please sign in to comment.