Wrong indexing in position reference frame transformation
This loop and this one (those are the two I could find) seem to index the position view wrong.
Both look like this:
Kokkos::parallel_for(..., ippl::getRangePolicy(Rview), KOKKOS_LAMBDA(const int i) {
ippl::Vector<double, 3> x({Rview(i)[0],Rview(i)[1],Rview(i)[2]});
ippl::Vector<double, 3> e({Eview(i)[0],Eview(i)[1],Eview(i)[2]});
ippl::Vector<double, 3> b({Bview(i)[0],Bview(i)[1],Bview(i)[2]});
// beamToReferenceCSTrafo.rotateTo
for ( int i = 0; i < 3; ++i ) {
for ( int j = 0; j < 3; ++j ) {
Eview(i) = Rot(i,j) * e(i);
Bview(i) = Rot(i,j) * b(i);
}
}
...
Here are the problems:
-
ippl::getRangePolicy(Rview)iterates also over potential overallocated space, see #25 - Iteration variable name
iis used twice in a nested loop. - In e.g.
Eview(i) = Rot(i,j) * e(i);, only particle 0, 1 and 2 are accessed and overwritten over and over again. Also,Eview(i)is of typeippl::Vector<double, 3>andRot(i,j) * e(i)just a scalar. It should be something likeEview(k)(i) = Rot(i,j) * e(i);(I think), wherekis the outer iteration of the kokkos kernel (use something likeKOKKOS_LAMBDA(const size_t k)).
Edited by liemen_a