Skip to content

Commit

Permalink
Cleanup more no useful comments && using now std::ofstream for text f…
Browse files Browse the repository at this point in the history
…ile with data multicuts. See AMReX_EB2_3D_C.cpp
  • Loading branch information
ejyoo921 committed Aug 27, 2024
1 parent 11e7ddd commit 1b1a970
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 21 deletions.
43 changes: 32 additions & 11 deletions Src/EB/AMReX_EB2_3D_C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,10 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
Gpu::Buffer<int> nmulticuts = {0};
int* hp = nmulticuts.hostData();
int* dp = nmulticuts.data();
// delete the previous dat_multicuts.txt file
std::ofstream ofs;
ofs.open("dat_multicuts.txt", std::ofstream::out | std::ofstream::trunc);
ofs.close();

#ifdef AMREX_USE_FLOAT
constexpr Real small = 1.e-5_rt;
Expand Down Expand Up @@ -468,9 +472,16 @@ 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") << "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";
std::ofstream fout("dat_multicuts.txt", std::ios::app);
fout << "xbx = " << xbx << std::endl;
fout << "-> 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] << ")"
<< std::endl;

// 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 @@ -585,9 +596,15 @@ 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") << "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";
std::ofstream fout("dat_multicuts.txt", std::ios::app);
fout << "ybx = " << ybx << std::endl;
fout << "-> 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] << ")"
<< std::endl;
// 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 @@ -702,9 +719,15 @@ 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") << "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";
std::ofstream fout("dat_multicuts.txt", std::ios::app);
fout << "zbx = " << zbx << std::endl;
fout << "-> 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] << ")"
<< std::endl;
// 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 @@ -798,8 +821,6 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell,
});
} else {
// 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";
}
Expand Down
15 changes: 5 additions & 10 deletions Src/EB/AMReX_EB2_Level.H
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include <AMReX_EB2_C.H>
#include <AMReX_EB2_IF_AllRegular.H>

//EY: Plotting
#include <AMReX_PlotFileUtil.H>

#ifdef AMREX_USE_OMP
Expand Down Expand Up @@ -174,14 +173,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
bool plt_multiple_cuts = false;
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
pp.queryAdd("plt_multiple_cuts", plt_multiple_cuts);
}
maxiter = std::min(100000, maxiter);

Expand Down Expand Up @@ -300,19 +299,15 @@ 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);

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
multicut_fcx.define(m_grids, m_dmap, 1, ng, mf_info);
multicut_fcy.define(m_grids, m_dmap, 1, ng, mf_info);
multicut_fcz.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);
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

0 comments on commit 1b1a970

Please sign in to comment.