-
Notifications
You must be signed in to change notification settings - Fork 0
Eyoo/multicuts #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: test-pr
Are you sure you want to change the base?
Changes from 11 commits
df6b6d0
734f7aa
fb5c787
ac65ec6
70b5111
b35cba5
5c7561e
92c65fa
4b4b890
823e97f
4007d81
8e67650
1a7edb3
5fe3c8e
2fd9f4d
11e7ddd
1b1a970
cc0af83
436bb3f
0536861
9b63533
427d166
df35481
bb08807
3c0b9ce
7db7054
3aeff0e
b8179f1
0023869
0f19915
fb47a1a
a0dc9c6
048d390
8b4c582
75b419a
766e8a9
0ba88b9
2304763
8eb29d8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,7 @@ | ||
| #include <AMReX_EB2_C.H> | ||
| //EY | ||
| #include <AMReX_MultiFab.H> | ||
| #include <AMReX_PlotFileUtil.H> | ||
|
|
||
| namespace amrex::EB2 { | ||
|
|
||
|
|
@@ -368,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, Array4<Real> const& multicut_arr) noexcept | ||
| { | ||
| Gpu::Buffer<int> nmulticuts = {0}; | ||
| int* hp = nmulticuts.hostData(); | ||
|
|
@@ -460,6 +464,11 @@ 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") << "fx: (x,y,z) = (" << problo[0]+(i)*dx[0] << ","<< problo[1]+(j)*dx[1] << "," << problo[2]+(k)*dx[2] << ") \n"; | ||
| } | ||
| } | ||
|
|
||
| if ((ncuts > 2) || (lym <= small && lyp <= small && lzm <= small && lzp <= small)) { | ||
|
|
@@ -568,6 +577,11 @@ 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"; | ||
| } | ||
| } | ||
|
|
||
| if ((ncuts > 2) || (lxm <= small && lxp <= small && lzm <= small && lzp <= small)) { | ||
|
|
@@ -676,6 +690,11 @@ 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; | ||
|
ejyoo921 marked this conversation as resolved.
Outdated
|
||
| // 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"; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. surround the PrintToFile bit with an
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let me try to run things. |
||
| } | ||
| } | ||
|
|
||
| if ((ncuts > 2) || (lxm <= small && lxp <= small && lym <= small && lyp <= small)) { | ||
|
|
@@ -766,7 +785,16 @@ int build_faces (Box const& bx, Array4<EBCellFlag> const& cell, | |
| } | ||
| }); | ||
| } else { | ||
| amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported"); | ||
| //EY: Let's see the location of multicuts before aborting! | ||
| amrex::Print() << "dx = " << dx[0] << ", dy = " << dx[1] << ", dz = " << dx[2] << "\n"; | ||
|
ejyoo921 marked this conversation as resolved.
Outdated
|
||
| amrex::Print() << "Total number of multicut cells = " << *hp << "\n"; | ||
|
|
||
| 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"); | ||
| } | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -785,7 +813,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}; | ||
|
|
@@ -930,7 +958,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"; | ||
|
ejyoo921 marked this conversation as resolved.
Outdated
|
||
| } | ||
| else{ | ||
| amrex::Abort("amrex::EB2::build_cells: multi-cuts not supported"); | ||
| } | ||
| } | ||
| return; | ||
| } else { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -15,6 +15,9 @@ | |
| #include <AMReX_EB2_C.H> | ||
| #include <AMReX_EB2_IF_AllRegular.H> | ||
|
|
||
| //EY: Plotting | ||
| #include <AMReX_PlotFileUtil.H> | ||
|
|
||
| #ifdef AMREX_USE_OMP | ||
| #include <omp.h> | ||
| #endif | ||
|
|
@@ -98,6 +101,9 @@ protected: | |
| bool m_has_eb_info = true; | ||
| IndexSpace const* m_parent; | ||
|
|
||
| //EY | ||
| MultiFab multicut_bx; | ||
|
ejyoo921 marked this conversation as resolved.
Outdated
|
||
|
|
||
| private: | ||
| template <typename G> friend class GShopLevel; | ||
|
|
||
|
|
@@ -167,12 +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 | ||
| 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); | ||
|
|
||
|
|
@@ -290,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); | ||
|
|
@@ -354,6 +365,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);); | ||
|
|
@@ -415,7 +429,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, multicut_arr); | ||
|
|
||
| cellflagtmp.resize(m_cellflag[mfi].box()); | ||
| Elixir cellflagtmp_eli = cellflagtmp.elixir(); | ||
|
|
@@ -424,7 +438,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 | ||
|
|
@@ -476,6 +490,12 @@ GShopLevel<G>::define_fine (G const& gshop, const Geometry& geom, | |
| nsmallcells += nsm; | ||
| nmulticuts += nmc; | ||
| } | ||
| // EY: Here -> make plot file | ||
| if (plt_multiple_cuts) | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move after the ParallelAllReduce for |
||
| { | ||
| WriteSingleLevelPlotfile("plt", multicut_bx, {"multicut"}, geom, 0.0, 0); | ||
| amrex::Abort("amrex::EB2::build_faces: more than 2 cuts not supported"); | ||
| } | ||
| } | ||
|
|
||
| ParallelAllReduce::Sum<int>({nsmallcells,nmulticuts}, ParallelContext::CommunicatorSub()); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.