@@ -24,7 +24,6 @@ struct PushParticlesVb
2424 static void push_mprts (Mparticles& mprts, MfieldsState& mflds)
2525 {
2626 const auto & grid = mprts.grid ();
27- PI <real_t > pi (grid);
2827 Real3 dxi = Real3{1 ., 1 ., 1 .} / Real3 (grid.domain .dx );
2928 real_t dq_kind[MAX_NR_KINDS ];
3029 auto & kinds = grid.kinds ;
@@ -46,13 +45,8 @@ struct PushParticlesVb
4645 flds.storage ().view (_all, _all, _all, _s (JXI , JXI + 3 )) = real_t (0 );
4746
4847 for (auto prt : prts) {
49- Real3& x = prt.x ();
50-
51- real_t xm[3 ];
52- for (int d = 0 ; d < 3 ; d++) {
53- xm[d] = x[d] * dxi[d];
54- }
55- ip.set_coeffs (xm);
48+ Real3 initial_pos_normalized = prt.x () * dxi;
49+ ip.set_coeffs (initial_pos_normalized);
5650
5751 // FIELD INTERPOLATION
5852 Real3 E = {ip.ex (EM ), ip.ey (EM ), ip.ez (EM )};
@@ -64,11 +58,12 @@ struct PushParticlesVb
6458
6559 // x^(n+0.5), p^(n+1.0) -> x^(n+1.5), p^(n+1.0)
6660 auto v = advance.calc_v (prt.u ());
67- advance.push_x (x , v);
61+ advance.push_x (prt. x () , v);
6862
69- int lf[3 ];
70- real_t of[3 ], xp[3 ];
71- pi.find_idx_off_pos_1st_rel (x, lf, of, xp, real_t (0 .));
63+ Int3 final_index;
64+ Real3 final_pos_normalized;
65+ find_idx_pos_1st_rel (prt.x (), dxi, final_index, final_pos_normalized,
66+ real_t (0 .));
7267
7368 // CURRENT DENSITY BETWEEN (n+.5)*dt and (n+1.5)*dt
7469 int lg[3 ];
@@ -81,7 +76,8 @@ struct PushParticlesVb
8176 if (!Dim::InvarZ::value) {
8277 lg[2 ] = ip.cz .g .l ;
8378 }
84- current.calc_j (J, xm, xp, lf, lg, prt.qni_wni (), v);
79+ current.calc_j (J, initial_pos_normalized, final_pos_normalized,
80+ final_index, lg, prt.qni_wni (), v);
8581 }
8682 }
8783 }
@@ -112,14 +108,14 @@ struct PushParticlesVb
112108 // field interpolation
113109 real_t * x = prt.x ;
114110
115- real_t xm [3 ];
111+ real_t initial_pos_normalized [3 ];
116112 for (int d = 0 ; d < 3 ; d++) {
117- xm [d] = x[d] * dxi[d];
113+ initial_pos_normalized [d] = x[d] * dxi[d];
118114 }
119115
120116 // FIELD INTERPOLATION
121117
122- ip.set_coeffs (xm );
118+ ip.set_coeffs (initial_pos_normalized );
123119 // FIXME, we're not using EM instead flds_em
124120 real_t E[3 ] = {ip.ex (EM ), ip.ey (EM ), ip.ez (EM )};
125121 real_t H[3 ] = {ip.hx (EM ), ip.hy (EM ), ip.hz (EM )};
0 commit comments