From 165f5795847b607e71b747f556992f7f125d8b71 Mon Sep 17 00:00:00 2001 From: James McClung Date: Fri, 20 Mar 2026 13:00:00 -0400 Subject: [PATCH 1/2] boundary_injector: fix injected particle pos again this was "fixed" previously, but that fix failed to consider that the prt position was used for getting the final/initial indices, which must be patch-local --- src/include/boundary_injector.hxx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/include/boundary_injector.hxx b/src/include/boundary_injector.hxx index 81748ec23..69cf4fea4 100644 --- a/src/include/boundary_injector.hxx +++ b/src/include/boundary_injector.hxx @@ -121,8 +121,7 @@ public: typename Current::fields_t J(flds); for (Int3 initial_idx : VecRange(ilo, ihi)) { - Real3 cell_corner = - Double3(initial_idx) * grid.domain.dx + grid.patches[p].xb; + Real3 cell_corner = Double3(initial_idx) * grid.domain.dx; int n_prts_to_try_inject = get_n_in_cell(1.0, prts_per_unit_density_, true); @@ -139,7 +138,11 @@ public: continue; } - injector(prt); + // GOTCHA: currently, injectors expect particle positions to be + // global, but current deposition expects patch-local + psc::particle::Inject prt_with_global_x = prt; + prt_with_global_x.x += grid.patches[p].xb; + injector(prt_with_global_x); // Update currents // Taken from push_particles_1vb.hxx PushParticlesVb::push_mprts() From 386c725e3bb7fa740c1cc4ab30eb982f377ef65f Mon Sep 17 00:00:00 2001 From: James McClung Date: Wed, 25 Mar 2026 07:08:20 -0400 Subject: [PATCH 2/2] setup_particles: warn only on rank 0 --- src/include/setup_particles.hxx | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/include/setup_particles.hxx b/src/include/setup_particles.hxx index 8846148cb..f335c289a 100644 --- a/src/include/setup_particles.hxx +++ b/src/include/setup_particles.hxx @@ -276,15 +276,20 @@ struct SetupParticles std::vector> offset_rngs; if (random_offsets) { - LOG_WARN( - "SetupParticles: enabled random offsets. Initial particle positions " - "will be randomized in each cell, instead of all at cell centers. Each " - "species uses the same rng seed, so if there are the same number of " - "particles of each species in each cell, each species will have the " - "exact same initial position distribution. This results in a charge " - "density of 0 if there are two species with opposite charges, but the " - "resulting charge density is nonzero in general. In the latter, case, " - "take special care to ensure Gauss' law isn't violated."); + int rank; + MPI_Comm_rank(grid.comm(), &rank); + if (rank == 0) { + LOG_WARN( + "SetupParticles: enabled random offsets. Initial particle positions " + "will be randomized in each cell, instead of all at cell centers. " + "Each species uses the same rng seed, so if there are the same " + "number of particles of each species in each cell, each species will " + "have the exact same initial position distribution. This results in " + "a charge density of 0 if there are two species with opposite " + "charges, but the resulting charge density is nonzero in general. In " + "the latter, case, take special care to ensure Gauss' law isn't " + "violated."); + } int seed = rng::detail::get_process_seed(); for (int species_count = 0; species_count < grid.kinds.size();