Skip to content

Commit d98255d

Browse files
committed
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
1 parent 55110ec commit d98255d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

src/include/boundary_injector.hxx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,7 @@ public:
121121
typename Current::fields_t J(flds);
122122

123123
for (Int3 initial_idx : VecRange(ilo, ihi)) {
124-
Real3 cell_corner =
125-
Double3(initial_idx) * grid.domain.dx + grid.patches[p].xb;
124+
Real3 cell_corner = Double3(initial_idx) * grid.domain.dx;
126125
int n_prts_to_try_inject =
127126
get_n_in_cell(1.0, prts_per_unit_density_, true);
128127

@@ -139,7 +138,11 @@ public:
139138
continue;
140139
}
141140

142-
injector(prt);
141+
// GOTCHA: currently, injectors expect particle positions to be
142+
// global, but current deposition expects patch-local
143+
psc::particle::Inject prt_with_global_x = prt;
144+
prt_with_global_x.x += grid.patches[p].xb;
145+
injector(prt_with_global_x);
143146

144147
// Update currents
145148
// Taken from push_particles_1vb.hxx PushParticlesVb::push_mprts()

0 commit comments

Comments
 (0)