Skip to content

Commit c11e6c9

Browse files
committed
Send 'failed' state back to propagation applier
1 parent ccea451 commit c11e6c9

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

src/celeritas/alongstep/detail/PropagationApplier.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,11 @@ PropagationApplierBaseImpl<MP>::operator()(CoreTrackView& track)
114114
#endif
115115
auto propagate = make_propagator(track);
116116
p = propagate(sim.step_length());
117+
if (CELER_UNLIKELY(p.failed))
118+
{
119+
track.apply_errored();
120+
return;
121+
}
117122
tracks_can_loop = propagate.tracks_can_loop();
118123
CELER_ASSERT(p.distance > 0);
119124
#if CELERITAS_DEBUG

src/celeritas/field/FieldPropagator.hh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,13 @@ FieldPropagator<SubstepperT, GTV>::operator()(real_type step) -> result_type
197197
real_type const update_length = substep.length * linear_step.distance
198198
/ chord.length;
199199

200-
if (!linear_step.boundary)
200+
if (CELER_UNLIKELY(geo_.failed()))
201+
{
202+
// Time to die
203+
result.failed = true;
204+
return result;
205+
}
206+
else if (!linear_step.boundary)
201207
{
202208
// No boundary intersection along the chord: accept substep
203209
// movement inside the current volume and reset the remaining

src/celeritas/field/LinearPropagator.hh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//---------------------------------------------------------------------------//
77
#pragma once
88

9+
#include "corecel/Macros.hh"
910
#include "corecel/math/Algorithms.hh"
1011
#include "geocel/Types.hh"
1112

@@ -78,7 +79,11 @@ CELER_FUNCTION auto LinearPropagator<GTV>::operator()(real_type dist)
7879

7980
result_type result = geo_.find_next_step(dist);
8081

81-
if (result.boundary)
82+
if (CELER_UNLIKELY(geo_.failed()))
83+
{
84+
result.failed = true;
85+
}
86+
else if (result.boundary)
8287
{
8388
geo_.move_to_boundary();
8489
}

src/geocel/Types.hh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,17 @@ struct GeoTrackInitializer
109109
*
110110
* The boundary flag means that the geometry is step limiting, but the surface
111111
* crossing must be called externally.
112+
*
113+
* \todo Change to a status type, or have separate "propagation" and "next
114+
* step" result types. Currently this is copied from the geometry state to the
115+
* propagation result because the track view failure flags are ephemeral.
112116
*/
113117
struct Propagation
114118
{
115119
real_type distance{0}; //!< Distance traveled
116120
bool boundary{false}; //!< True if hit a boundary before given distance
117121
bool looping{false}; //!< True if track is looping in the field propagator
122+
bool failed{false}; //!< True if a failure state occurred
118123
};
119124

120125
//---------------------------------------------------------------------------//

0 commit comments

Comments
 (0)