aboutsummaryrefslogtreecommitdiff
path: root/Source/Particles/PhysicalParticleContainer.cpp
diff options
context:
space:
mode:
authorGravatar Andrew Myers <atmyers2@gmail.com> 2020-01-28 11:22:19 -0800
committerGravatar Andrew Myers <atmyers2@gmail.com> 2020-01-28 11:22:19 -0800
commit8f83efe141c2f766372ab33e0d9685c29fedeb26 (patch)
tree70a0a4543e9a147a5d10fc58f6b3b990becba2b7 /Source/Particles/PhysicalParticleContainer.cpp
parenteb7180e3ff24b247f95c3100842e97fa60c70e5b (diff)
downloadWarpX-8f83efe141c2f766372ab33e0d9685c29fedeb26.tar.gz
WarpX-8f83efe141c2f766372ab33e0d9685c29fedeb26.tar.zst
WarpX-8f83efe141c2f766372ab33e0d9685c29fedeb26.zip
use get / set position in the external E and B field getter
Diffstat (limited to 'Source/Particles/PhysicalParticleContainer.cpp')
-rw-r--r--Source/Particles/PhysicalParticleContainer.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/Source/Particles/PhysicalParticleContainer.cpp b/Source/Particles/PhysicalParticleContainer.cpp
index 1430df6a0..1a1c720a3 100644
--- a/Source/Particles/PhysicalParticleContainer.cpp
+++ b/Source/Particles/PhysicalParticleContainer.cpp
@@ -989,8 +989,7 @@ PhysicalParticleContainer::AssignExternalFieldOnParticles(WarpXParIter& pti,
Bzp.assign(np,mypc.m_B_external_particle[2]);
}
if (mypc.m_E_ext_particle_s=="parse_e_ext_particle_function") {
- const auto& aos = pti.GetArrayOfStructs();
- const ParticleType* const AMREX_RESTRICT pstruct = aos().dataPtr();
+ const auto get_position = GetPosition(pti);
Real* const AMREX_RESTRICT Exp_data = Exp.dataPtr();
Real* const AMREX_RESTRICT Eyp_data = Eyp.dataPtr();
Real* const AMREX_RESTRICT Ezp_data = Ezp.dataPtr();
@@ -999,19 +998,20 @@ PhysicalParticleContainer::AssignExternalFieldOnParticles(WarpXParIter& pti,
ParserWrapper *zfield_partparser = mypc.m_Ez_particle_parser.get();
Real time = warpx.gett_new(lev);
amrex::ParallelFor(pti.numParticles(),
- [=] AMREX_GPU_DEVICE (long i) {
- Exp_data[i] = xfield_partparser->getField(pstruct[i],time);
- Eyp_data[i] = yfield_partparser->getField(pstruct[i],time);
- Ezp_data[i] = zfield_partparser->getField(pstruct[i],time);
- },
+ [=] AMREX_GPU_DEVICE (long i) {
+ Real x, y, z;
+ get_position(i, x, y, z);
+ Exp_data[i] = xfield_partparser->getField(x, y, z, time);
+ Eyp_data[i] = yfield_partparser->getField(x, y, z, time);
+ Ezp_data[i] = zfield_partparser->getField(x, y, z, time);
+ },
/* To allocate shared memory for the GPU threads. */
/* But, for now only 4 doubles (x,y,z,t) are allocated. */
amrex::Gpu::numThreadsPerBlockParallelFor() * sizeof(double) * 4
);
}
if (mypc.m_B_ext_particle_s=="parse_b_ext_particle_function") {
- const auto& aos = pti.GetArrayOfStructs();
- const ParticleType* const AMREX_RESTRICT pstruct = aos().dataPtr();
+ const auto get_position = GetPosition(pti);
Real* const AMREX_RESTRICT Bxp_data = Bxp.dataPtr();
Real* const AMREX_RESTRICT Byp_data = Byp.dataPtr();
Real* const AMREX_RESTRICT Bzp_data = Bzp.dataPtr();
@@ -1021,10 +1021,12 @@ PhysicalParticleContainer::AssignExternalFieldOnParticles(WarpXParIter& pti,
Real time = warpx.gett_new(lev);
amrex::ParallelFor(pti.numParticles(),
[=] AMREX_GPU_DEVICE (long i) {
- Bxp_data[i] = xfield_partparser->getField(pstruct[i],time);
- Byp_data[i] = yfield_partparser->getField(pstruct[i],time);
- Bzp_data[i] = zfield_partparser->getField(pstruct[i],time);
- },
+ Real x, y, z;
+ get_position(i, x, y, z);
+ Bxp_data[i] = xfield_partparser->getField(x, y, z, time);
+ Byp_data[i] = yfield_partparser->getField(x, y, z, time);
+ Bzp_data[i] = zfield_partparser->getField(x, y, z, time);
+ },
/* To allocate shared memory for the GPU threads. */
/* But, for now only 4 doubles (x,y,z,t) are allocated. */
amrex::Gpu::numThreadsPerBlockParallelFor() * sizeof(double) * 4