aboutsummaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/ParticleContainer.H6
-rw-r--r--Source/ParticleContainer.cpp15
-rw-r--r--Source/PhysicalParticleContainer.H6
-rw-r--r--Source/PhysicalParticleContainer.cpp79
-rw-r--r--Source/WarpXParticleContainer.cpp15
5 files changed, 119 insertions, 2 deletions
diff --git a/Source/ParticleContainer.H b/Source/ParticleContainer.H
index 9f732f355..21eeca395 100644
--- a/Source/ParticleContainer.H
+++ b/Source/ParticleContainer.H
@@ -179,6 +179,11 @@ public:
amrex::Vector<amrex::Array<amrex::Real, nstencilz_fdtd_nci_corr> > fdtd_nci_stencilz_by;
std::vector<std::string> GetSpeciesNames() const { return species_names; }
+
+ // std::unique_ptr<amrex::ParticleContainer<0,0,PIdx::nattribs>> pc_tmp;
+ // std::unique_ptr<WarpXParticleContainer> pc_tmp;
+
+ PhysicalParticleContainer& GetPCtmp () { return *pc_tmp; }
protected:
@@ -195,6 +200,7 @@ private:
// physical particles (+ laser)
amrex::Vector<std::unique_ptr<WarpXParticleContainer> > allcontainers;
+ std::unique_ptr<PhysicalParticleContainer> pc_tmp;
void ReadParameters ();
diff --git a/Source/ParticleContainer.cpp b/Source/ParticleContainer.cpp
index 8aac692d6..8ca6b7614 100644
--- a/Source/ParticleContainer.cpp
+++ b/Source/ParticleContainer.cpp
@@ -28,6 +28,13 @@ MultiParticleContainer::MultiParticleContainer (AmrCore* amr_core)
if (WarpX::use_laser) {
allcontainers[n-1].reset(new LaserParticleContainer(amr_core,n-1));
}
+ // pc_tmp = WarpXParticleContainer(amr_core, 0);
+ // pc_tmp = std::unique_ptr<WarpXParticleContainer> (new WarpXParticleContainer(this));
+ pc_tmp.reset(new PhysicalParticleContainer(amr_core));
+ // pc_tmp = std::unique_ptr<WarpXParticleContainer> (new WarpXParticleContainer(amr_core, 0));
+ // pc_tmp = std::unique_ptr<PhysicalParticleContainer> (new PhysicalParticleContainer(amr_core));
+ // pc_tmp = std::unique_ptr<amrex::ParticleContainer<0,0,PIdx::nattribs>> (new amrex::ParticleContainer<0,0,PIdx::nattribs>);
+
}
void
@@ -81,6 +88,7 @@ MultiParticleContainer::AllocData ()
for (auto& pc : allcontainers) {
pc->AllocData();
}
+ pc_tmp->AllocData();
}
void
@@ -89,6 +97,7 @@ MultiParticleContainer::InitData ()
for (auto& pc : allcontainers) {
pc->InitData();
}
+ pc_tmp->InitData();
}
@@ -274,6 +283,7 @@ MultiParticleContainer::Redistribute ()
for (auto& pc : allcontainers) {
pc->Redistribute();
}
+ pc_tmp->Redistribute();
}
void
@@ -282,6 +292,7 @@ MultiParticleContainer::RedistributeLocal (const int num_ghost)
for (auto& pc : allcontainers) {
pc->Redistribute(0, 0, 0, num_ghost);
}
+ pc_tmp->Redistribute(0, 0, 0, num_ghost);
}
Vector<long>
@@ -305,6 +316,7 @@ MultiParticleContainer::Increment (MultiFab& mf, int lev)
for (auto& pc : allcontainers) {
pc->Increment(mf,lev);
}
+ pc_tmp->Increment(mf,lev);
}
void
@@ -313,6 +325,7 @@ MultiParticleContainer::SetParticleBoxArray (int lev, BoxArray& new_ba)
for (auto& pc : allcontainers) {
pc->SetParticleBoxArray(lev,new_ba);
}
+ pc_tmp->SetParticleBoxArray(lev,new_ba);
}
void
@@ -321,6 +334,7 @@ MultiParticleContainer::SetParticleDistributionMap (int lev, DistributionMapping
for (auto& pc : allcontainers) {
pc->SetParticleDistributionMap(lev,new_dm);
}
+ pc_tmp->SetParticleDistributionMap(lev,new_dm);
}
void
@@ -329,6 +343,7 @@ MultiParticleContainer::PostRestart ()
for (auto& pc : allcontainers) {
pc->PostRestart();
}
+ pc_tmp->PostRestart();
}
void
diff --git a/Source/PhysicalParticleContainer.H b/Source/PhysicalParticleContainer.H
index bd6015437..7bf821ea5 100644
--- a/Source/PhysicalParticleContainer.H
+++ b/Source/PhysicalParticleContainer.H
@@ -15,6 +15,9 @@ public:
PhysicalParticleContainer (amrex::AmrCore* amr_core,
int ispecies,
const std::string& name);
+
+ PhysicalParticleContainer (amrex::AmrCore* amr_core);
+
virtual ~PhysicalParticleContainer () {}
virtual void InitData () override;
@@ -77,6 +80,8 @@ public:
virtual void PostRestart () final {}
+ void SplitParticles(WarpXParIter& pti, int lev);
+
// Inject particles in Box 'part_box'
virtual void AddParticles (int lev);
void AddPlasma(int lev, amrex::RealBox part_realbox = amrex::RealBox());
@@ -108,6 +113,7 @@ protected:
// particle and the time of the boosted frame.
bool boost_adjust_transverse_positions = false;
bool do_backward_propagation = false;
+ bool do_splitting = false;
long NumParticlesToAdd (const amrex::Box& overlap_box,
const amrex::RealBox& overlap_realbox,
diff --git a/Source/PhysicalParticleContainer.cpp b/Source/PhysicalParticleContainer.cpp
index 79f132f4d..3952e48a4 100644
--- a/Source/PhysicalParticleContainer.cpp
+++ b/Source/PhysicalParticleContainer.cpp
@@ -78,9 +78,14 @@ PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core, int isp
ParmParse pp(species_name);
pp.query("boost_adjust_transverse_positions", boost_adjust_transverse_positions);
- pp.query("do_backward_propagation", do_backward_propagation);
+ pp.query("do_backward_propagation", do_backward_propagation);
+ pp.query("do_splitting", do_splitting);
}
+PhysicalParticleContainer::PhysicalParticleContainer (AmrCore* amr_core)
+ : WarpXParticleContainer(amr_core, 0)
+{}
+
void PhysicalParticleContainer::InitData()
{
AddParticles(0); // Note - add on level 0
@@ -1396,9 +1401,12 @@ PhysicalParticleContainer::Evolve (int lev,
//
BL_PROFILE_VAR_START(blp_pxr_pp);
PushPX(pti, m_xp[thread_num], m_yp[thread_num], m_zp[thread_num],
- m_giv[thread_num], dt);
+ m_giv[thread_num], dt);
BL_PROFILE_VAR_STOP(blp_pxr_pp);
+ // Split particles
+ SplitParticles(pti, lev);
+
//
// Current Deposition
//
@@ -1429,6 +1437,73 @@ PhysicalParticleContainer::Evolve (int lev,
}
void
+PhysicalParticleContainer::SplitParticles(WarpXParIter& pti, int lev)
+{
+ auto& mypc = WarpX::GetInstance().GetPartContainer();
+ auto& pctmp_split = mypc.GetPCtmp();
+ // std::unique_ptr<PhysicalParticleContainer> pc_tmp = mypc.pc_tmp;
+ // WarpXParticleContainer ppc_tmp(amr_core, ispecies);
+ Cuda::DeviceVector<Real> xp, yp, zp;
+ pti.GetPosition(xp, yp, zp);
+ auto& attribs = pti.GetAttribs();
+ auto& wp = attribs[PIdx::w ];
+ auto& uxp = attribs[PIdx::ux];
+ auto& uyp = attribs[PIdx::uy];
+ auto& uzp = attribs[PIdx::uz];
+ const long np = pti.numParticles();
+ const std::array<Real,3>& dx = WarpX::CellSize(lev);
+ Print()<< "dx "<<dx[0]<<' '<<dx[1]<<' '<<dx[2]<<' '<<std::endl;
+ const auto& particles = pti.GetArrayOfStructs();
+
+ RealVector psplit_x, psplit_y, psplit_z, psplit_w;
+ RealVector psplit_ux, psplit_uy, psplit_uz;
+ // for (auto& p : particles){
+ for(int i=0; i<np; i++){
+ auto& p = particles[i];
+ if (p.id() == SplitParticleID){
+ Print()<<"splitting particles\n";
+#if (AMREX_SPACEDIM==2)
+ long np_split = 4;
+ for (int ishift = -1; ishift < 2; ishift +=2 ){
+ psplit_x.push_back( xp[i] + ishift*dx[0]/2 );
+ psplit_y.push_back( 0. );
+ psplit_z.push_back( zp[i] + ishift*dx[1]/2 );
+ psplit_ux.push_back( uxp[i] );
+ psplit_uy.push_back( 0. );
+ psplit_uz.push_back( uzp[i] );
+ psplit_w.push_back( wp[i]/4. );
+ }
+ Print()<<"AddNParticles start\n";
+ pctmp_split.AddNParticles(lev,
+ np_split,
+ psplit_x.dataPtr(),
+ psplit_y.dataPtr(),
+ psplit_z.dataPtr(),
+ psplit_ux.dataPtr(),
+ psplit_uy.dataPtr(),
+ psplit_uz.dataPtr(),
+ 1,
+ psplit_w.dataPtr(),
+ 1);
+ Print()<<"AddNParticles end\n";
+#endif
+ }
+ }
+ /*
+ for (auto& p : particles){
+ if (p.id() == SplitParticleID){
+ Print()<<"toto\n";
+
+ }
+ }
+
+ auto& uxp = attribs[PIdx::ux];
+
+ for(int i, i<np, ++i){
+ if
+ }*/
+}
+void
PhysicalParticleContainer::PushPX(WarpXParIter& pti,
Cuda::DeviceVector<Real>& xp,
Cuda::DeviceVector<Real>& yp,
diff --git a/Source/WarpXParticleContainer.cpp b/Source/WarpXParticleContainer.cpp
index e15a73e58..99e794317 100644
--- a/Source/WarpXParticleContainer.cpp
+++ b/Source/WarpXParticleContainer.cpp
@@ -131,14 +131,18 @@ WarpXParticleContainer::AddNParticles (int lev,
const Real* vx, const Real* vy, const Real* vz,
int nattr, const Real* attr, int uniqueparticles)
{
+
+ Print()<<"here -1\n";
BL_ASSERT(nattr == 1);
const Real* weight = attr;
int ibegin, iend;
if (uniqueparticles) {
+ Print()<<"here -2\n";
ibegin = 0;
iend = n;
} else {
+ Print()<<"here -3\n";
int myproc = ParallelDescriptor::MyProc();
int nprocs = ParallelDescriptor::NProcs();
int navg = n/nprocs;
@@ -154,11 +158,15 @@ WarpXParticleContainer::AddNParticles (int lev,
// Add to grid 0 and tile 0
// Redistribute() will move them to proper places.
+ Print()<<"here -4\n";
std::pair<int,int> key {0,0};
+ Print()<<"here -10\n";
auto& particle_tile = GetParticles(lev)[key];
+ Print()<<"here -11\n";
for (int i = ibegin; i < iend; ++i)
{
+ Print()<<"here -5\n";
ParticleType p;
p.id() = ParticleType::NextID();
p.cpu() = ParallelDescriptor::MyProc();
@@ -167,6 +175,7 @@ WarpXParticleContainer::AddNParticles (int lev,
p.pos(1) = y[i];
p.pos(2) = z[i];
#elif (AMREX_SPACEDIM == 2)
+ Print()<<"here -6\n";
p.pos(0) = x[i];
p.pos(1) = z[i];
#endif
@@ -177,18 +186,24 @@ WarpXParticleContainer::AddNParticles (int lev,
if (np > 0)
{
+ Print()<<"here 1\n";
particle_tile.push_back_real(PIdx::w , weight + ibegin, weight + iend);
+ Print()<<"here 2\n";
particle_tile.push_back_real(PIdx::ux, vx + ibegin, vx + iend);
particle_tile.push_back_real(PIdx::uy, vy + ibegin, vy + iend);
particle_tile.push_back_real(PIdx::uz, vz + ibegin, vz + iend);
+ Print()<<"here 3\n";
for (int comp = PIdx::uz+1; comp < PIdx::nattribs; ++comp)
{
+ Print()<<"here 4\n";
particle_tile.push_back_real(comp, np, 0.0);
}
}
+ Print()<<"here 5\n";
Redistribute();
+ Print()<<"here 6\n";
}