From a32645120a8c563f3a256d3c5dca0d801027a1db Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 7 May 2025 11:54:30 -0400 Subject: [PATCH 1/4] psc: inline particle inject --- src/include/psc.hxx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/include/psc.hxx b/src/include/psc.hxx index c96ba36c4..d5f750070 100644 --- a/src/include/psc.hxx +++ b/src/include/psc.hxx @@ -486,7 +486,7 @@ struct Psc // === particle injection prof_start(pr_inject_prts); - inject_particles(); + inject_particles_(grid(), mprts_); prof_stop(pr_inject_prts); if (checks_.continuity.should_do_check(timestep)) { @@ -591,11 +591,6 @@ struct Psc #endif } - // ---------------------------------------------------------------------- - // inject_particles - - void inject_particles() { return this->inject_particles_(grid(), mprts_); } - private: // ---------------------------------------------------------------------- // print_profiling From fe11556056b7621f0cf677393414c8f584c05c53 Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 7 May 2025 12:26:51 -0400 Subject: [PATCH 2/4] psc: mv particle injection after push --- src/include/psc.hxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/include/psc.hxx b/src/include/psc.hxx index d5f750070..77499da7d 100644 --- a/src/include/psc.hxx +++ b/src/include/psc.hxx @@ -484,11 +484,6 @@ struct Psc prof_stop(pr_collision); } - // === particle injection - prof_start(pr_inject_prts); - inject_particles_(grid(), mprts_); - prof_stop(pr_inject_prts); - if (checks_.continuity.should_do_check(timestep)) { mpi_printf(comm, "***** Checking continuity...\n"); prof_start(pr_checks); @@ -503,6 +498,11 @@ struct Psc prof_stop(pr_push_prts); // state is now: x^{n+3/2}, p^{n+1}, E^{n+1/2}, B^{n+1/2}, j^{n+1} + // === particle injection + prof_start(pr_inject_prts); + inject_particles_(grid(), mprts_); + prof_stop(pr_inject_prts); + // === field propagation B^{n+1/2} -> B^{n+1} mpi_printf(comm, "***** Pushing B...\n"); prof_start(pr_push_flds); From ca39b731be4623b28cadf59655f7dbb9a70dec94 Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 7 May 2025 12:33:08 -0400 Subject: [PATCH 3/4] psc: change args to inject_particles_ --- src/include/psc.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/include/psc.hxx b/src/include/psc.hxx index 77499da7d..3da1eddca 100644 --- a/src/include/psc.hxx +++ b/src/include/psc.hxx @@ -500,7 +500,7 @@ struct Psc // === particle injection prof_start(pr_inject_prts); - inject_particles_(grid(), mprts_); + inject_particles_(mprts_, mflds_); prof_stop(pr_inject_prts); // === field propagation B^{n+1/2} -> B^{n+1} From e226fa0deef9681bd457278a53f7b9341b6b33a0 Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 7 May 2025 12:33:48 -0400 Subject: [PATCH 4/4] *: fixes to match new inject_particles_ signature --- src/include/psc.hxx | 4 ++-- src/psc_2d_shock.cxx | 4 +++- src/psc_flatfoil_yz.cxx | 4 +++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/include/psc.hxx b/src/include/psc.hxx index 3da1eddca..de7e386be 100644 --- a/src/include/psc.hxx +++ b/src/include/psc.hxx @@ -748,8 +748,8 @@ protected: class InjectParticlesNone { public: - template - void operator()(const Grid_t& grid, Mparticles& mprts) + template + void operator()(Mparticles& mprts, MfieldsState& mflds) {} }; diff --git a/src/psc_2d_shock.cxx b/src/psc_2d_shock.cxx index 58eaeef73..e5dc8485a 100644 --- a/src/psc_2d_shock.cxx +++ b/src/psc_2d_shock.cxx @@ -548,7 +548,9 @@ void run() double inject_fac = (g.inject_interval * grid.dt / inject_tau) / (1. + g.inject_interval * grid.dt / inject_tau); - auto lf_inject_heat = [&](const Grid_t& grid, Mparticles& mprts) { + auto lf_inject_heat = [&](Mparticles& mprts, MfieldsState& mflds) { + const Grid_t& grid = mprts.grid(); + static int pr_inject, pr_heating; if (!pr_inject) { pr_inject = prof_register("inject", 1., 0, 0); diff --git a/src/psc_flatfoil_yz.cxx b/src/psc_flatfoil_yz.cxx index 1f2469e9d..37c92ce9e 100644 --- a/src/psc_flatfoil_yz.cxx +++ b/src/psc_flatfoil_yz.cxx @@ -617,7 +617,9 @@ void run() double inject_fac = (g.inject_interval * grid.dt / inject_tau) / (1. + g.inject_interval * grid.dt / inject_tau); - auto lf_inject_heat = [&](const Grid_t& grid, Mparticles& mprts) { + auto lf_inject_heat = [&](Mparticles& mprts, MfieldsState& mflds) { + const Grid_t& grid = mprts.grid(); + static int pr_inject, pr_heating; if (!pr_inject) { pr_inject = prof_register("inject", 1., 0, 0);