Skip to content

Commit

Permalink
We now create separate plot files containing multi-cut locations from…
Browse files Browse the repository at this point in the history
… xbx, ybx, and zbx: next step will be plotting face-center multifabs since they are multicut faces we are plotting now.
  • Loading branch information
ejyoo921 committed Aug 15, 2024
1 parent 8e67650 commit 1a7edb3
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 20 deletions.
16 changes: 8 additions & 8 deletions 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, Array4<Real> const& multicut_arr) noexcept
bool plt_multiple_cuts, Array4<Real> const& mt_fcx, Array4<Real> const& mt_fcy, Array4<Real> const& mt_fcz) noexcept
{
Gpu::Buffer<int> nmulticuts = {0};
int* hp = nmulticuts.hostData();
Expand All @@ -388,7 +388,7 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
const Real dzinv = 1.0_rt/dx[2];

const Box& xbx = amrex::grow(amrex::surroundingNodes(bx,0),1);
AMREX_HOST_DEVICE_FOR_3D ( xbx, i, j, k,
AMREX_HOST_DEVICE_FOR_3D ( xbx, i, j, k, // this is face index
{
if (fx(i,j,k) == Type::regular) {
apx(i,j,k) = 1.0_rt;
Expand Down Expand Up @@ -465,9 +465,9 @@ 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) = ncuts;
mt_fcx(i,j,k,0) = 10.0;

#ifdef AMREX_USE_GPU
#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";
#endif
}
Expand Down Expand Up @@ -580,9 +580,9 @@ 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) = ncuts;
mt_fcy(i,j,k,0) = 10.0;

#ifdef AMREX_USE_GPU
#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";
#endif
}
Expand Down Expand Up @@ -695,9 +695,9 @@ 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) = ncuts;
mt_fcz(i,j,k,0) = 10.0;

#ifdef AMREX_USE_GPU
#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";
#endif
}
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, Array4<Real> const& multicut_arr) noexcept; //EY
bool plt_multiple_cuts, Array4<Real> const& mt_fcx, Array4<Real> const& mt_fcy, Array4<Real> const& mt_fcz) noexcept; //EY

void build_cells (Box const& bx, Array4<EBCellFlag> const& cell,
Array4<Type_t> const& fx, Array4<Type_t> const& fy,
Expand Down
53 changes: 42 additions & 11 deletions Src/EB/AMReX_EB2_Level.H
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ protected:
IndexSpace const* m_parent;

//EY
MultiFab multicut_count;
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;

private:
template <typename G> friend class GShopLevel;
Expand Down Expand Up @@ -299,13 +304,23 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
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_count.define(m_grids, m_dmap, 1, ng, mf_info);
// 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
multicut_fcz.define(m_grids, m_dmap, 1, ng, mf_info); // should be a face-centered boxes

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);
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 @@ -365,8 +380,16 @@ 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_count.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 @@ -429,7 +452,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, multicut_arr);
xm2, ym2, zm2, dx, problo, cover_multiple_cuts, plt_multiple_cuts, multicut_arr_x, multicut_arr_y, multicut_arr_z);

cellflagtmp.resize(m_cellflag[mfi].box());
Elixir cellflagtmp_eli = cellflagtmp.elixir();
Expand Down Expand Up @@ -490,15 +513,23 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom,
nsmallcells += nsm;
nmulticuts += nmc;
}
// EY: Here -> make plot file
if (plt_multiple_cuts)
{
WriteSingleLevelPlotfile("plt", multicut_count, {"multicut"}, geom, 0.0, 0);
amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported");
}
}

ParallelAllReduce::Sum<int>({nsmallcells,nmulticuts}, ParallelContext::CommunicatorSub());
// EY: Here -> make plot file
if (plt_multiple_cuts)
{
int finest_level = 0;
int lev = finest_level;
amrex::Print() << "MAKE PLOT FILE FOR MULTICUTS" << "\n";

WriteSingleLevelPlotfile("plt.x", multicut_fcx, {"multicut_x"}, geom, 0.0, 0);
WriteSingleLevelPlotfile("plt.y", multicut_fcy, {"multicut_y"}, geom, 0.0, 0);
WriteSingleLevelPlotfile("plt.z", multicut_fcz, {"multicut_z"}, geom, 0.0, 0);

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

if (nsmallcells == 0 && nmulticuts == 0) {
break;
} else {
Expand Down

0 comments on commit 1a7edb3

Please sign in to comment.