From 1a55de802493eef4c515be0e198e4ddb23e5cda9 Mon Sep 17 00:00:00 2001 From: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> Date: Fri, 30 Jun 2023 12:09:13 -0700 Subject: 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 --- Source/WarpX.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'Source/WarpX.cpp') 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::lowest()); dt.resize(nlevs_max, std::numeric_limits::max()); - // Particle Container + // Loop over species and set current injection position per species mypc = std::make_unique(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; iGetParticleContainer(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); } } -- cgit v1.2.3