From 05e1438b61322cfd831e9dea8040852fd6759aaf Mon Sep 17 00:00:00 2001 From: atmyers Date: Mon, 23 Jan 2017 11:25:04 -0800 Subject: Only ParmParse the plasma injection parameters at initialization. --- Source/WarpX.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'Source/WarpX.cpp') diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index bb6509786..fbfc063ac 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -133,6 +133,13 @@ WarpX::ReadParameters () pp.get("moving_window_v", moving_window_v); } + pp.query("do_plasma_injection", do_plasma_injection); + if (do_plasma_injection) { + pp.get("injected_plasma_ppc", injected_plasma_ppc); + pp.get("injected_plasma_species", injected_plasma_species); + pp.get("injected_plasma_density", injected_plasma_density); + } + moving_window_x = geom[0].ProbLo(moving_window_dir); moving_window_v = 0.0; pp.query("moving_window_v", moving_window_v); -- cgit v1.2.3 From ee98feb72d6df609facf18bf448a92ee5e7023a2 Mon Sep 17 00:00:00 2001 From: atmyers Date: Mon, 23 Jan 2017 17:09:03 -0800 Subject: Add ability to inject several species at once. --- Exec/plasma_acceleration/inputs | 7 +- Source/WarpX.H | 7 +- Source/WarpX.cpp | 13 +++- Source/WarpXEvolve.cpp | 150 +++++++++++++++++++++------------------- 4 files changed, 96 insertions(+), 81 deletions(-) (limited to 'Source/WarpX.cpp') diff --git a/Exec/plasma_acceleration/inputs b/Exec/plasma_acceleration/inputs index 28d169e92..ef8729aaa 100644 --- a/Exec/plasma_acceleration/inputs +++ b/Exec/plasma_acceleration/inputs @@ -59,6 +59,7 @@ warpx.moving_window_v = 1.0 # in units of the speed of light # Particle Injection warpx.do_plasma_injection = 1 -warpx.injected_plasma_species = 1 -warpx.injected_plasma_density = 1e22 -warpx.injected_plasma_ppc = 4 +warpx.num_injected_species = 1 +warpx.injected_plasma_species = 1 0 +warpx.injected_plasma_density = 1e22 1e22 +warpx.injected_plasma_ppc = 4 4 diff --git a/Source/WarpX.H b/Source/WarpX.H index 7e21285bf..be290c6f2 100644 --- a/Source/WarpX.H +++ b/Source/WarpX.H @@ -109,9 +109,10 @@ private: // Plasma injection parameters int do_plasma_injection = 0; - int injected_plasma_ppc; - int injected_plasma_species; - Real injected_plasma_density; + int num_injected_species; + Array injected_plasma_ppc; + Array injected_plasma_species; + Array injected_plasma_density; // Other runtime parameters int verbose = 1; diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index fbfc063ac..08d432866 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -135,9 +135,16 @@ WarpX::ReadParameters () pp.query("do_plasma_injection", do_plasma_injection); if (do_plasma_injection) { - pp.get("injected_plasma_ppc", injected_plasma_ppc); - pp.get("injected_plasma_species", injected_plasma_species); - pp.get("injected_plasma_density", injected_plasma_density); + pp.get("num_injected_species", num_injected_species); + injected_plasma_ppc.resize(num_injected_species); + pp.getarr("injected_plasma_ppc", injected_plasma_ppc, + 0, num_injected_species); + injected_plasma_species.resize(num_injected_species); + pp.getarr("injected_plasma_species", injected_plasma_species, + 0, num_injected_species); + injected_plasma_density.resize(num_injected_species); + pp.getarr("injected_plasma_density", injected_plasma_density, + 0, num_injected_species); } moving_window_x = geom[0].ProbLo(moving_window_dir); diff --git a/Source/WarpXEvolve.cpp b/Source/WarpXEvolve.cpp index 3f1001a42..975d54d6a 100644 --- a/Source/WarpXEvolve.cpp +++ b/Source/WarpXEvolve.cpp @@ -272,45 +272,10 @@ WarpX::ComputeDt () } void -WarpX::MoveWindow () -{ - - if (do_moving_window == 0) return; - - // compute the number of cells to shift - int dir = moving_window_dir; - Real new_lo[BL_SPACEDIM]; - Real new_hi[BL_SPACEDIM]; - const Real* current_lo = geom[0].ProbLo(); - const Real* current_hi = geom[0].ProbHi(); - const Real* dx = geom[0].CellSize(); - moving_window_x += moving_window_v * dt[0]; - int num_shift = (moving_window_x - current_lo[dir]) / dx[dir]; - - if (num_shift == 0) return; - - // update the problem domain - for (int i=0; iGetParticleContainer(ispecies); - const BoxArray& ba = myspc.ParticleBoxArray(0); - const DistributionMapping& dm = myspc.ParticleDistributionMap(0); + WarpXParticleContainer* myspc = &(mypc->GetParticleContainer(0)); + const BoxArray& ba = myspc->ParticleBoxArray(0); + const DistributionMapping& dm = myspc->ParticleDistributionMap(0); MultiFab dummy_mf(ba, 1, 0, dm, Fab_noallocate); // For each grid, loop only over the cells in the new region @@ -355,40 +311,90 @@ WarpX::MoveWindow () for (int k = 0; k < nz; k++) { for (int j = 0; j < ny; j++) { for (int i = 0; i < nx; i++) { - for (int i_part=0; i_partGetParticleContainer(ispecies)); + for (int i_part=0; i_part < injected_plasma_ppc[ispec]; i_part++) { + Real particle_shift = (0.5+i_part)/injected_plasma_ppc[ispec]; #if (BL_SPACEDIM == 3) - Real x = intersectRealBox.lo(0) + (i + particle_shift)*dx[0]; - Real y = intersectRealBox.lo(1) + (j + particle_shift)*dx[1]; - Real z = intersectRealBox.lo(2) + (k + particle_shift)*dx[2]; + Real x = intersectRealBox.lo(0) + (i + particle_shift)*dx[0]; + Real y = intersectRealBox.lo(1) + (j + particle_shift)*dx[1]; + Real z = intersectRealBox.lo(2) + (k + particle_shift)*dx[2]; #elif (BL_SPACEDIM == 2) - Real x = intersectRealBox.lo(0) + (i + particle_shift)*dx[0]; - Real y = 0.0; - Real z = intersectRealBox.lo(1) + (k + particle_shift)*dx[1]; + Real x = intersectRealBox.lo(0) + (i + particle_shift)*dx[0]; + Real y = 0.0; + Real z = intersectRealBox.lo(1) + (k + particle_shift)*dx[1]; #endif - int id = ParticleBase::NextID(); - int cpu = ParallelDescriptor::MyProc(); + int id = ParticleBase::NextID(); + int cpu = ParallelDescriptor::MyProc(); - std::vector pos(3, 0.0); + std::vector pos(3, 0.0); #if (BL_SPACEDIM == 3) - pos[0] = x; - pos[1] = y; - pos[2] = z; + pos[0] = x; + pos[1] = y; + pos[2] = z; #elif (BL_SPACEDIM == 2) - pos[0] = x; - pos[1] = z; + pos[0] = x; + pos[1] = z; +#endif + + std::vector attributes(PIdx::nattribs, 0.0); + + Real weight = injected_plasma_density[ispec]; +#if BL_SPACEDIM==3 + weight *= dx[0]*dx[1]*dx[2]/injected_plasma_ppc[ispec]; +#elif BL_SPACEDIM==2 + weight *= dx[0]*dx[1]/injected_plasma_ppc[ispec]; #endif - - std::vector attributes(PIdx::nattribs, 0.0); - attributes[PIdx::w] = weight; - myspc.addOneParticle(id, cpu, pos, attributes); - } - } + attributes[PIdx::w] = weight; + myspc->addOneParticle(id, cpu, pos, attributes); + } + } + } } } } } +} + +void +WarpX::MoveWindow () +{ + + if (do_moving_window == 0) return; + + // compute the number of cells to shift + int dir = moving_window_dir; + Real new_lo[BL_SPACEDIM]; + Real new_hi[BL_SPACEDIM]; + const Real* current_lo = geom[0].ProbLo(); + const Real* current_hi = geom[0].ProbHi(); + const Real* dx = geom[0].CellSize(); + moving_window_x += moving_window_v * dt[0]; + int num_shift = (moving_window_x - current_lo[dir]) / dx[dir]; + + if (num_shift == 0) return; + + // update the problem domain + for (int i=0; iRedistribute(false); -- cgit v1.2.3 From 249a66ffc57f789260b5599322d3f61edc45754c Mon Sep 17 00:00:00 2001 From: atmyers Date: Mon, 23 Jan 2017 17:33:39 -0800 Subject: remove redundant call to FillBoundary. --- Source/WarpX.cpp | 2 -- 1 file changed, 2 deletions(-) (limited to 'Source/WarpX.cpp') diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 08d432866..00453fa5c 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -252,8 +252,6 @@ WarpX::shiftMF(MultiFab& mf, const Geometry& geom, int num_shift, mf[mfi].copy(tmpmf[mfi], srcBox, 0, dstBox, 0, mf.nComp()); mf[mfi].SetBoxType(dst_typ); } - - mf.FillBoundary(geom.periodicity()); } void -- cgit v1.2.3