aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/WarpXParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Andrew Myers <atmyers@lbl.gov> 2019-09-12 15:48:32 -0700
committerGravatar GitHub <noreply@github.com> 2019-09-12 15:48:32 -0700
commit569c9a98c3cbaffe418ce094c74e760e9ba216d6 (patch)
treefa5172edcbf40bb823a901507cc2f7488c631405 /Source/Particles/WarpXParticleContainer.cpp
parent74f9d3b9611561317812bf4ae3d7b842437b54f0 (diff)
parent0acb8ea5b9278c79d5d2eb697c94acc794bf8bad (diff)
downloadWarpX-569c9a98c3cbaffe418ce094c74e760e9ba216d6.tar.gz
WarpX-569c9a98c3cbaffe418ce094c74e760e9ba216d6.tar.zst
WarpX-569c9a98c3cbaffe418ce094c74e760e9ba216d6.zip
Merge branch 'dev' into pml_exchange_gpu
Diffstat (limited to 'Source/Particles/WarpXParticleContainer.cpp')
-rw-r--r--Source/Particles/WarpXParticleContainer.cpp78
1 files changed, 44 insertions, 34 deletions
diff --git a/Source/Particles/WarpXParticleContainer.cpp b/Source/Particles/WarpXParticleContainer.cpp
index 4e80374d8..ee606aadb 100644
--- a/Source/Particles/WarpXParticleContainer.cpp
+++ b/Source/Particles/WarpXParticleContainer.cpp
@@ -108,7 +108,7 @@ WarpXParticleContainer::ReadParameters ()
static bool initialized = false;
if (!initialized)
{
- ParmParse pp("particles");
+ ParmParse pp("particles");
#ifdef AMREX_USE_GPU
do_tiling = false; // By default, tiling is off on GPU
@@ -118,7 +118,7 @@ WarpXParticleContainer::ReadParameters ()
pp.query("do_tiling", do_tiling);
pp.query("do_not_push", do_not_push);
- initialized = true;
+ initialized = true;
}
}
@@ -136,7 +136,7 @@ WarpXParticleContainer::AddOneParticle (int lev, int grid, int tile,
Real x, Real y, Real z,
std::array<Real,PIdx::nattribs>& attribs)
{
- auto& particle_tile = GetParticles(lev)[std::make_pair(grid,tile)];
+ auto& particle_tile = DefineAndReturnParticleTile(lev, grid, tile);
AddOneParticle(particle_tile, x, y, z, attribs);
}
@@ -163,39 +163,44 @@ WarpXParticleContainer::AddOneParticle (ParticleTileType& particle_tile,
particle_tile.push_back(p);
particle_tile.push_back_real(attribs);
+
+ for (int i = PIdx::nattribs; i < NumRealComps(); ++i)
+ {
+ particle_tile.push_back_real(i, 0.0);
+ }
}
void
WarpXParticleContainer::AddNParticles (int lev,
int n, const Real* x, const Real* y, const Real* z,
- const Real* vx, const Real* vy, const Real* vz,
- int nattr, const Real* attr, int uniqueparticles, int id)
+ const Real* vx, const Real* vy, const Real* vz,
+ int nattr, const Real* attr, int uniqueparticles, int id)
{
BL_ASSERT(nattr == 1);
const Real* weight = attr;
int ibegin, iend;
if (uniqueparticles) {
- ibegin = 0;
- iend = n;
+ ibegin = 0;
+ iend = n;
} else {
- int myproc = ParallelDescriptor::MyProc();
- int nprocs = ParallelDescriptor::NProcs();
- int navg = n/nprocs;
- int nleft = n - navg * nprocs;
- if (myproc < nleft) {
- ibegin = myproc*(navg+1);
- iend = ibegin + navg+1;
- } else {
- ibegin = myproc*navg + nleft;
- iend = ibegin + navg;
- }
+ int myproc = ParallelDescriptor::MyProc();
+ int nprocs = ParallelDescriptor::NProcs();
+ int navg = n/nprocs;
+ int nleft = n - navg * nprocs;
+ if (myproc < nleft) {
+ ibegin = myproc*(navg+1);
+ iend = ibegin + navg+1;
+ } else {
+ ibegin = myproc*navg + nleft;
+ iend = ibegin + navg;
+ }
}
// Add to grid 0 and tile 0
// Redistribute() will move them to proper places.
std::pair<int,int> key {0,0};
- auto& particle_tile = GetParticles(lev)[key];
+ auto& particle_tile = DefineAndReturnParticleTile(0, 0, 0);
std::size_t np = iend-ibegin;
@@ -206,12 +211,12 @@ WarpXParticleContainer::AddNParticles (int lev,
for (int i = ibegin; i < iend; ++i)
{
ParticleType p;
- if (id==-1)
- {
- p.id() = ParticleType::NextID();
- } else {
- p.id() = id;
- }
+ if (id==-1)
+ {
+ p.id() = ParticleType::NextID();
+ } else {
+ p.id() = id;
+ }
p.cpu() = ParallelDescriptor::MyProc();
#if (AMREX_SPACEDIM == 3)
p.pos(0) = x[i];
@@ -228,7 +233,7 @@ WarpXParticleContainer::AddNParticles (int lev,
#endif
if ( (NumRuntimeRealComps()>0) || (NumRuntimeIntComps()>0) ){
- auto& ptile = DefineAndReturnParticleTile(0, 0, 0);
+ auto& ptile = DefineAndReturnParticleTile(0, 0, 0);
}
particle_tile.push_back(p);
@@ -242,7 +247,7 @@ WarpXParticleContainer::AddNParticles (int lev,
particle_tile.push_back_real(PIdx::uz, vz + ibegin, vz + iend);
if ( (NumRuntimeRealComps()>0) || (NumRuntimeIntComps()>0) ){
- auto& ptile = DefineAndReturnParticleTile(0, 0, 0);
+ auto& ptile = DefineAndReturnParticleTile(0, 0, 0);
}
for (int comp = PIdx::uz+1; comp < PIdx::nattribs; ++comp)
@@ -258,6 +263,11 @@ WarpXParticleContainer::AddNParticles (int lev,
particle_tile.push_back_real(comp, np, 0.0);
#endif
}
+
+ for (int i = PIdx::nattribs; i < NumRealComps(); ++i)
+ {
+ particle_tile.push_back_real(i, 0.0);
+ }
}
Redistribute();
@@ -289,7 +299,7 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti,
const long offset, const long np_to_depose,
int thread_num, int lev, int depos_lev,
Real dt)
-{
+{
AMREX_ALWAYS_ASSERT_WITH_MESSAGE((depos_lev==(lev-1)) ||
(depos_lev==(lev )),
"Deposition buffers only work for lev-1");
@@ -316,7 +326,7 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti,
const IntVect& ref_ratio = WarpX::RefRatio(depos_lev);
tilebox = amrex::coarsen(pti.tilebox(),ref_ratio);
}
-
+
// Staggered tile boxes (different in each direction)
Box tbx = convert(tilebox, WarpX::jx_nodal_flag);
Box tby = convert(tilebox, WarpX::jy_nodal_flag);
@@ -360,11 +370,11 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti,
// Lower corner of tile box physical domain
// Note that this includes guard cells since it is after tilebox.ngrow
const std::array<Real, 3>& xyzmin = WarpX::LowerCorner(tilebox, depos_lev);
- // xyzmin is built on pti.tilebox(), so it does
+ // xyzmin is built on pti.tilebox(), so it does
// not include staggering, so the stagger_shift has to be done by hand.
- // Alternatively, we could define xyzminx from tbx (and the same for 3
+ // Alternatively, we could define xyzminx from tbx (and the same for 3
// directions and for jx, jy, jz). This way, sx0 would not be needed.
- // Better for memory? worth trying?
+ // Better for memory? worth trying?
const Dim3 lo = lbound(tilebox);
BL_PROFILE_VAR_START(blp_deposit);
@@ -431,7 +441,7 @@ WarpXParticleContainer::DepositCurrent(WarpXParIter& pti,
ion_lev is a null pointer.
* \param rho : Full array of charge density
* \param icomp : Component of rho into which charge is deposited.
- 0: old value (before particle push).
+ 0: old value (before particle push).
1: new value (after particle push).
* \param offset : Index of first particle for which charge is deposited
* \param np_to_depose: Number of particles for which charge is deposited.
@@ -471,7 +481,7 @@ WarpXParticleContainer::DepositCharge (WarpXParIter& pti, RealVector& wp,
const IntVect& ref_ratio = WarpX::RefRatio(depos_lev);
tilebox = amrex::coarsen(pti.tilebox(),ref_ratio);
}
-
+
tilebox.grow(ngRho);
const int nc = (rho->nComp() == 1 ? 1 : rho->nComp()/2);