Skip to content
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

Issue with refine_grid_layout #3459

Closed
tesari opened this issue Jul 31, 2023 · 5 comments · Fixed by #3460
Closed

Issue with refine_grid_layout #3459

tesari opened this issue Jul 31, 2023 · 5 comments · Fixed by #3460

Comments

@tesari
Copy link

tesari commented Jul 31, 2023

Hi,

I have problem to make refine_grid_layout to work as expected. The attached snippets illustrate the issue.

I use MakeBaseGrids() to create a box array with four elements. When run on (up to) four ranks, it works as expected:

(BoxArray maxbox(4)
m_ref->m_hash_sig(0)
((0,0,0) (7,7,0) (0,0,0)) ((8,0,0) (15,7,0) (0,0,0)) ((0,8,0) (7,15,0) (0,0,0)) ((8,8,0) (15,15,0) (0,0,0)) )

When run on eight ranks it fails with:
Assertion `! boxes.empty()' failed, file "/Users/tsar/PROJECTS/amex/amrex/Src/Base/AMReX_DistributionMapping.cpp", line 1460 !!!

I also try refine_grid_layout_dim = IntVec{2,2,1} to no avil. I have no clue what I am doing wrong. Could you advice, please?

Thanks,
Ted

======= main.cpp ========
#include
#include "AMReX.H"
#include "AMReX_BLProfiler.H"
#include "AMReX_ParallelDescriptor.H"
#include "PPlane_.H"

using namespace amrex;
using std::endl;

int main(int argc, char *argv[])
{
amrex::Initialize(argc, argv);
AmrInfo st;
st.max_level = 0;
int nlevs = st.max_level + 1;
st.blocking_factor.resize(nlevs);
st.max_grid_size.resize(nlevs);
st.ref_ratio.resize(nlevs);
// st.verbose = 1;
st.max_grid_size[0] = IntVect{AMREX_D_DECL(8, 8, 1)};
st.blocking_factor[0] = IntVect{AMREX_D_DECL(8, 8, 1)};
st.ref_ratio[0] = IntVect{2, 2, 1};
st.refine_grid_layout = true;

IntVect lo(AMREX_D_DECL(0, 0, 0));
IntVect hi(AMREX_D_DECL(15, 15, 0));
IndexType typ({AMREX_D_DECL(1, 1, 1)});
Box dom(lo, hi);
double x_lo = -10, y_lo = -10, z_lo = -0.000001, x_hi = 10, y_hi = 10, z_hi = 0;
RealBox real_box({AMREX_D_DECL(Real(x_lo), Real(y_lo), Real(z_lo))},
{AMREX_D_DECL(Real(x_hi), Real(y_hi), Real(z_hi))});
amrex::Array<int, AMREX_SPACEDIM> is_per{AMREX_D_DECL(1, 1, 1)};
int coord = CoordSys::cartesian;
Geometry level_0_geom(dom, real_box, coord, is_per);

PPlane pp(level_0_geom, st);

amrex::Finalize();
}

==============
PPlane::PPlane(amrex::Geometry const &level_0_geom,
amrex::AmrInfo const &amr_info) : AmrCore(level_0_geom, amr_info)
{
Vector new_grids(max_level + 1);
new_grids[0] = grids[0];
finest_level = 0;
const BoxArray &ba = MakeBaseGrids();
SetBoxArray(0, ba);
DistributionMapping dm(ba);
SetDistributionMap(0, dm);
Print() << grids[0] << "\n";
}

WeiqunZhang added a commit that referenced this issue Jul 31, 2023
Fix a corner case for AmrMesh::ChopGrids when there is only one cell in
one dimension.

Close #3459
@tesari
Copy link
Author

tesari commented Jul 31, 2023 via email

@WeiqunZhang
Copy link
Member

Something is not right. The snippet I sent yesterday now doesn’t segfault, but it doesn’t increase the number of grids either – the size of the BoxArray is always 4 (see below).

It has a total of 16 x 16 x 1 cells and the blocking factor is 8 x 8 x 1. So the maximal number of boxes is 4. If you change the blocking factor to 4 x 4 x 1, you should be able to get 8 boxes.

Besides, the original code I extracted the snippet from still segfaulsts. Could you advice, please?

We need more detail.

@tesari
Copy link
Author

tesari commented Jul 31, 2023 via email

@WeiqunZhang
Copy link
Member

It's constrained by the blocking factor, which is the minimal box size.

@tesari
Copy link
Author

tesari commented Aug 3, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants