Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions src/include/boundary_injector.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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()
Expand Down
23 changes: 14 additions & 9 deletions src/include/setup_particles.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -276,15 +276,20 @@ struct SetupParticles

std::vector<rng::Uniform<real_t>> 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();
Expand Down
Loading