@@ -1667,9 +1667,25 @@ void Ray::trace()
16671667 // After phase one is done, we can starting tracing from cell to cell within
16681668 // the model. This step can use neighbor lists to accelerate the ray tracing.
16691669
1670- // Attempt to initialize the particle. We may have to enter a loop to move
1671- // it up to the edge of the model.
1672- bool inside_cell = exhaustive_find_cell (*this , settings::verbosity >= 10 );
1670+ bool inside_cell;
1671+ // Check for location if the particle is already known
1672+ if (lowest_coord ().cell () == C_NONE) {
1673+ // The geometry position of the particle is either unknown or outside of the
1674+ // edge of the model.
1675+ if (lowest_coord ().universe () == C_NONE) {
1676+ // Attempt to initialize the particle. We may have to
1677+ // enter a loop to move it up to the edge of the model.
1678+ inside_cell = exhaustive_find_cell (*this , settings::verbosity >= 10 );
1679+ } else {
1680+ // It has been already calculated that the current position is outside of
1681+ // the edge of the model.
1682+ inside_cell = false ;
1683+ }
1684+ } else {
1685+ // Availability of the cell means that the particle is located inside the
1686+ // edge.
1687+ inside_cell = true ;
1688+ }
16731689
16741690 // Advance to the boundary of the model
16751691 while (!inside_cell) {
@@ -1750,6 +1766,11 @@ void Ray::trace()
17501766 coord (lev).r () += boundary ().distance () * coord (lev).u ();
17511767 }
17521768 surface () = boundary ().surface ();
1769+ // Initialize last cells from the current cell, because the cell() variable
1770+ // does not contain the data for the case of a single-segment ray
1771+ for (int j = 0 ; j < n_coord (); ++j) {
1772+ cell_last (j) = coord (j).cell ();
1773+ }
17531774 n_coord_last () = n_coord ();
17541775 n_coord () = boundary ().coord_level ();
17551776 if (boundary ().lattice_translation ()[0 ] != 0 ||
0 commit comments