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

Function to get particle cell index. #5118

Merged
merged 30 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a7d358f
Add particle cell id function
archermarx Aug 7, 2024
89216c6
Add header
archermarx Aug 7, 2024
a71fad0
Rewrite in header
archermarx Aug 7, 2024
1a8a045
Remove commented-out code
archermarx Aug 7, 2024
68459d8
Merge branch 'development' into particle_cell_id
archermarx Aug 7, 2024
ccde01d
better ignoring of unused variables
archermarx Aug 7, 2024
7b80c85
Const decls for clang-tidy
archermarx Aug 7, 2024
fcfbb45
Add overload for getParticleCellIndex using SuperParticleType
archermarx Aug 7, 2024
68f278a
Use ignore_unsued for index variables to appease clang-tidy
archermarx Aug 7, 2024
cd4cd15
Update Source/Utils/ParticleUtils.cpp
archermarx Aug 8, 2024
2eed9cd
Merge branch 'ECP-WarpX:development' into particle_cell_id
archermarx Aug 8, 2024
8d1d32f
Remove unused variable 'lo'
archermarx Aug 8, 2024
737d2cf
Update Source/Utils/ParticleUtils.H
archermarx Aug 12, 2024
002e8ce
Add use of function to ParticleReductionFunctor.cpp
archermarx Aug 12, 2024
de86103
Update Source/Utils/ParticleUtils.H
archermarx Aug 12, 2024
6c7b222
Update Source/Utils/ParticleUtils.H
archermarx Aug 12, 2024
bc28bde
Merge branch 'particle_cell_id' of github.com:archermarx/WarpX into p…
archermarx Aug 12, 2024
15b7670
Revert use of new function in ParticleUtils.cpp to get CI to pass
archermarx Aug 14, 2024
9bda9dd
Merge branch 'development' into particle_cell_id
archermarx Aug 14, 2024
b5059c4
Remove parameter
archermarx Aug 14, 2024
25111a4
fix typo
archermarx Aug 14, 2024
c177530
Use new overload of amrex::getParticleCell
archermarx Aug 14, 2024
970f8a6
remove particleutils.h header include in ParticleReductionFunctor
archermarx Aug 14, 2024
513bd14
Update ParticleUtils.H
archermarx Aug 20, 2024
8e13732
Merge branch 'ECP-WarpX:development' into particle_cell_id
archermarx Aug 20, 2024
055776b
Fix structured bindings
archermarx Aug 21, 2024
b248dc0
Remove new function entirely and rely on getParticleCell
archermarx Aug 21, 2024
4e8f688
Try using amrex::getParticleCell in ParticleUtils.cpp
archermarx Aug 21, 2024
fef22fe
Revert "Try using amrex::getParticleCell in ParticleUtils.cpp"
archermarx Aug 21, 2024
b20c5ce
remove unnecessary include
archermarx Aug 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,7 @@ ParticleReductionFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp,
get_particle_position(p, xw, yw, zw);

// Get position in AMReX convention to calculate corresponding index.
// Ideally this will be replaced with the AMReX NGP interpolator
// Always do x direction. No RZ case because it's not implemented, and code
// will have aborted
int ii = 0, jj = 0, kk = 0;
const amrex::ParticleReal x = p.pos(0);
const amrex::Real lx = (x - plo[0]) * dxi[0];
ii = static_cast<int>(amrex::Math::floor(lx));
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
const amrex::ParticleReal y = p.pos(1);
const amrex::Real ly = (y - plo[1]) * dxi[1];
jj = static_cast<int>(amrex::Math::floor(ly));
#endif
#if defined(WARPX_DIM_3D)
const amrex::ParticleReal z = p.pos(2);
const amrex::Real lz = (z - plo[2]) * dxi[2];
kk = static_cast<int>(amrex::Math::floor(lz));
#endif
const auto [ii, jj, kk] = amrex::getParticleCell(p, plo, dxi).dim3();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, there is another branch, m_do_average, below that can use the same functionality.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up in #5557


// Fix dimensions since parser assumes u = gamma * v / c
const amrex::ParticleReal ux = p.rdata(PIdx::ux) / PhysConst::c;
Expand Down
39 changes: 5 additions & 34 deletions Source/Diagnostics/ComputeDiagFunctors/TemperatureFunctor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,7 @@ TemperatureFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp, const
amrex::GpuArray<amrex::Real,AMREX_SPACEDIM> const& dxi)
{
// Get position in AMReX convention to calculate corresponding index.
// Ideally this will be replaced with the AMReX NGP interpolator
// Always do x direction.
int ii = 0, jj = 0, kk = 0;
const amrex::ParticleReal x = p.pos(0);
const amrex::Real lx = (x - plo[0]) * dxi[0];
ii = static_cast<int>(amrex::Math::floor(lx));
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_3D) || defined(WARPX_DIM_RZ)
const amrex::ParticleReal y = p.pos(1);
const amrex::Real ly = (y - plo[1]) * dxi[1];
jj = static_cast<int>(amrex::Math::floor(ly));
#endif
#if defined(WARPX_DIM_3D)
const amrex::ParticleReal z = p.pos(2);
const amrex::Real lz = (z - plo[2]) * dxi[2];
kk = static_cast<int>(amrex::Math::floor(lz));
#endif
const auto [ii, jj, kk] = amrex::getParticleCell(p, plo, dxi).dim3();

const amrex::ParticleReal w = p.rdata(PIdx::w);
const amrex::ParticleReal ux = p.rdata(PIdx::ux);
Expand Down Expand Up @@ -103,34 +88,20 @@ TemperatureFunctor::operator() (amrex::MultiFab& mf_dst, const int dcomp, const
for (WarpXParIter pti(pc, m_lev); pti.isValid(); ++pti)
{
const long np = pti.numParticles();
auto& tile = pti.GetParticleTile();
auto ptd = tile.getParticleTileData();
amrex::ParticleReal* wp = pti.GetAttribs(PIdx::w).dataPtr();
amrex::ParticleReal* uxp = pti.GetAttribs(PIdx::ux).dataPtr();
amrex::ParticleReal* uyp = pti.GetAttribs(PIdx::uy).dataPtr();
amrex::ParticleReal* uzp = pti.GetAttribs(PIdx::uz).dataPtr();

auto const GetPosition = GetParticlePosition<PIdx>(pti);

amrex::Array4<amrex::Real> const& out_array = sum_mf.array(pti);

amrex::ParallelFor(np,
[=] AMREX_GPU_DEVICE (long ip) {
// --- Get particle quantities
amrex::ParticleReal xp, yp, zp;
GetPosition.AsStored(ip, xp, yp, zp);

// Get position in AMReX convention to calculate corresponding index.
int ii = 0, jj = 0, kk = 0;
const amrex::Real lx = (xp - plo[0]) * dxi[0];
ii = static_cast<int>(amrex::Math::floor(lx));
#if defined(WARPX_DIM_XZ) || defined(WARPX_DIM_RZ)
const amrex::Real lz = (zp - plo[1]) * dxi[1];
jj = static_cast<int>(amrex::Math::floor(lz));
#elif defined(WARPX_DIM_3D)
const amrex::Real ly = (yp - plo[1]) * dxi[1];
jj = static_cast<int>(amrex::Math::floor(ly));
const amrex::Real lz = (zp - plo[2]) * dxi[2];
kk = static_cast<int>(amrex::Math::floor(lz));
#endif
const auto p = WarpXParticleContainer::ParticleType(ptd, ip);
const auto [ii, jj, kk] = getParticleCell(p, plo, dxi).dim3();

const amrex::ParticleReal w = wp[ip];
const amrex::ParticleReal ux = uxp[ip] - out_array(ii, jj, kk, 1);
Expand Down
Loading