Skip to content

Commit

Permalink
Modify the neighbor particles test to also test selectActualNeighbors. (
Browse files Browse the repository at this point in the history
AMReX-Codes#3118)

The proposed changes:
- [ ] fix a bug or incorrect behavior in AMReX
- [ ] add new capabilities to AMReX
- [ ] changes answers in the test suite to more than roundoff level
- [ ] are likely to significantly affect the results of downstream AMReX
users
- [ ] include documentation in the code and/or rst files, if appropriate
  • Loading branch information
atmyers authored Feb 1, 2023
1 parent c09ed7d commit 78dd7a0
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
6 changes: 3 additions & 3 deletions Src/Particle/AMReX_NeighborParticlesI.H
Original file line number Diff line number Diff line change
Expand Up @@ -1023,9 +1023,9 @@ selectActualNeighbors (CheckPair&& check_pair, int num_cells)
bins.build(np_total, pstruct, grownBox,
[=] AMREX_GPU_DEVICE (const ParticleType& p) noexcept -> IntVect
{
int i = static_cast<int>(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0]) - lo.x);
int j = static_cast<int>(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1]) - lo.y);
int k = static_cast<int>(amrex::Math::floor((p.pos(2)-plo[2])*dxi[2]) - lo.z);
AMREX_D_TERM(int i = static_cast<int>(amrex::Math::floor((p.pos(0)-plo[0])*dxi[0]) - lo.x);,
int j = static_cast<int>(amrex::Math::floor((p.pos(1)-plo[1])*dxi[1]) - lo.y);,
int k = static_cast<int>(amrex::Math::floor((p.pos(2)-plo[2])*dxi[2]) - lo.z));
AMREX_D_TERM(AMREX_ASSERT(i >= 0);, AMREX_ASSERT(j >= 0);, AMREX_ASSERT(k >= 0));

return IntVect(AMREX_D_DECL(i, j, k));
Expand Down
2 changes: 1 addition & 1 deletion Tests/Particles/NeighborParticles/MDParticleContainer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ std::pair<Real, Real> MDParticleContainer::minAndMaxDistance()
}
});

// Gpu::Device::streamSynchronize();
Gpu::Device::streamSynchronize();

min_d = std::min(min_d, min_d_gpu.dataValue());
max_d = std::max(max_d, max_d_gpu.dataValue());
Expand Down
3 changes: 2 additions & 1 deletion Tests/Particles/NeighborParticles/inputs
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,5 @@ nbor_list.size = (24, 24, 24)
nbor_list.max_grid_size = 8
nbor_list.is_periodic = 1
nbor_list.num_ppc = 1

nbor_list.do_plotfile = 1
nbor_list.check_answer = 1
35 changes: 29 additions & 6 deletions Tests/Particles/NeighborParticles/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ struct TestParams
int max_grid_size;
int num_ppc;
int is_periodic;
int do_plotfile;
int check_answer;
};

void testNeighborParticles();
Expand All @@ -43,6 +45,12 @@ void get_test_params(TestParams& params, const std::string& prefix)
pp.get("max_grid_size", params.max_grid_size);
pp.get("num_ppc", params.num_ppc);
pp.get("is_periodic", params.is_periodic);

params.do_plotfile = true;
pp.query("do_plotfile", params.do_plotfile);

params.check_answer = true;
pp.query("check_answer", params.check_answer);
}

void testNeighborParticles ()
Expand Down Expand Up @@ -183,11 +191,26 @@ void testNeighborList ()

pc.buildNeighborList(CheckPair());

pc.checkNeighborList();
if (params.check_answer) {
pc.checkNeighborList();
}

MultiFab dummy_mf(ba, dm, 1, 0);
dummy_mf.setVal(0.0);
WriteSingleLevelPlotfile("NeighborParticles_plt00001", dummy_mf,
{"dummy"}, geom, 0.0, 0);
pc.WritePlotFile("NeighborParticles_plt00001", "neighbors");
#ifdef AMREX_USE_GPU
pc.clearNeighbors();
pc.fillNeighbors();
pc.selectActualNeighbors(CheckPair());
pc.updateNeighbors();
pc.buildNeighborList(CheckPair());
if (params.check_answer) {
pc.checkNeighborList();
}
#endif

if (params.do_plotfile) {
MultiFab dummy_mf(ba, dm, 1, 0);
dummy_mf.setVal(0.0);
WriteSingleLevelPlotfile("NeighborParticles_plt00001", dummy_mf,
{"dummy"}, geom, 0.0, 0);
pc.WritePlotFile("NeighborParticles_plt00001", "neighbors");
}
}

0 comments on commit 78dd7a0

Please sign in to comment.