diff options
author | 2023-06-30 12:09:13 -0700 | |
---|---|---|
committer | 2023-06-30 19:09:13 +0000 | |
commit | 1a55de802493eef4c515be0e198e4ddb23e5cda9 (patch) | |
tree | e7938d009a51a144f46195bf649649ace96dfb58 /Source/WarpX.cpp | |
parent | 5baa09ceadc6291f67839c7842fd1756edfc1186 (diff) | |
download | WarpX-1a55de802493eef4c515be0e198e4ddb23e5cda9.tar.gz WarpX-1a55de802493eef4c515be0e198e4ddb23e5cda9.tar.zst WarpX-1a55de802493eef4c515be0e198e4ddb23e5cda9.zip |
Continuous injection of moving plasma (#3958)
* Continuous injection of moving plasma
* Fix const correctness
* Fix bugs in calculation of v_bulk
* Fix restart
* Use range-based for loops where possible
* Apply suggestions from code review
* Fix bug related to managed memory
* Apply suggestions from code review
* Exclude case with `moving_window_v = 0`
* Add to WarpXParticleContainer virtual function that returns pointer to plasma injector
* Add to WarpXParticleContainer member variable for current injection position
* Fix bugs
* Fix bug: use continue instead of return
Diffstat (limited to 'Source/WarpX.cpp')
-rw-r--r-- | Source/WarpX.cpp | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/Source/WarpX.cpp b/Source/WarpX.cpp index 17601175b..fc37ccc65 100644 --- a/Source/WarpX.cpp +++ b/Source/WarpX.cpp @@ -279,16 +279,25 @@ WarpX::WarpX () t_old.resize(nlevs_max, std::numeric_limits<Real>::lowest()); dt.resize(nlevs_max, std::numeric_limits<Real>::max()); - // Particle Container + // Loop over species and set current injection position per species mypc = std::make_unique<MultiParticleContainer>(this); - warpx_do_continuous_injection = mypc->doContinuousInjection(); - if (warpx_do_continuous_injection){ - if (moving_window_v >= 0){ + const int n_species = mypc->nSpecies(); + for (int i=0; i<n_species; i++) + { + WarpXParticleContainer& pc = mypc->GetParticleContainer(i); + + // Storing injection position for all species, regardless of whether + // they are continuously injected, since it makes looping over the + // elements of current_injection_position easier elsewhere in the code. + if (moving_window_v > 0._rt) + { // Inject particles continuously from the right end of the box - current_injection_position = geom[0].ProbHi(moving_window_dir); - } else { + pc.m_current_injection_position = geom[0].ProbHi(moving_window_dir); + } + else if (moving_window_v < 0._rt) + { // Inject particles continuously from the left end of the box - current_injection_position = geom[0].ProbLo(moving_window_dir); + pc.m_current_injection_position = geom[0].ProbLo(moving_window_dir); } } |