Skip to content

Commit e5aced4

Browse files
[mini] move position when step size advance fails (#450)
This mini PR fixes a bug reported by code analysis from @dkonst13: The the loop of reducing the step size when stuck on the boundary, the `move` was adjusted, but the position was not changed. As the `move` affects the remains and the stepDone, the position must be also adjusted here, otherwise it is not consistent.
1 parent d5196ee commit e5aced4

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

include/AdePT/magneticfield/fieldPropagatorRungeKutta.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ inline __host__ __device__ double fieldPropagatorRungeKutta<Field_t, RkDriver_t,
282282
if (!continueIteration) {
283283
// Let's move to the other side of this boundary -- this side we cannot progress !!
284284
move = Navigator_t::kBoundaryPush; // curvedStep
285+
position += move * chordDir;
285286
}
286287
#if ADEPT_DEBUG_TRACK > 0
287288
if (verbose)
@@ -302,7 +303,7 @@ inline __host__ __device__ double fieldPropagatorRungeKutta<Field_t, RkDriver_t,
302303
// move = fraction * safeArc; // curvedStep
303304
#ifndef ENDPOINT_ON_CURVE
304305
// Primitive approximation of end direction and linearStep to the crossing point ...
305-
position = position + move * chordDir; // linearStep
306+
position += move * chordDir; // linearStep
306307
direction = direction * (1.0 - fraction) + endDirection * fraction;
307308
direction = direction.Unit();
308309
momentumVec = momentumMag * direction;

0 commit comments

Comments
 (0)