diff --git a/corsika/detail/framework/core/Cascade.inl b/corsika/detail/framework/core/Cascade.inl index d5bad336eb001ad25c03ef221a55aacb86d171dd..93b8d7d685fb547f07121cdb74fad27fa665a0bc 100644 --- a/corsika/detail/framework/core/Cascade.inl +++ b/corsika/detail/framework/core/Cascade.inl @@ -204,17 +204,20 @@ namespace corsika { CORSIKA_LOG_DEBUG("step limit reached (e.g. deflection). nothing further happens."); - [[maybe_unused]] auto const assertion = [&] { + { auto const* numericalNodeAfterStep = environment_.getUniverse()->getContainingNode(vParticle.getPosition()); CORSIKA_LOG_TRACE( "Geometry check: numericalNodeAfterStep={} currentLogicalNode={}", fmt::ptr(numericalNodeAfterStep), fmt::ptr(currentLogicalNode)); - return numericalNodeAfterStep == currentLogicalNode; - }; - - assert(assertion()); // numerical and logical nodes should match, since - // we did not cross any volume boundary + if (numericalNodeAfterStep != currentLogicalNode) { + CORSIKA_LOG_ERROR( + "expect to be in node currentLogicalNode={} but are in " + "numericalNodeAfterStep={}. Continue, but without guarantee.", + fmt::ptr(currentLogicalNode), fmt::ptr(numericalNodeAfterStep)); + } + } + // we did not cross any volume boundary // step length limit return; @@ -253,7 +256,7 @@ namespace corsika { sequence_.doSecondaries(secondaries); vParticle.erase(); - } + } // namespace corsika template <typename TTracking, typename TProcessList, typename TOutput, typename TStack> inline ProcessReturn Cascade<TTracking, TProcessList, TOutput, TStack>::decay( diff --git a/corsika/detail/modules/tracking/Intersect.inl b/corsika/detail/modules/tracking/Intersect.inl index e627213515fcae2c97635931cd7e3a338afaa6ad..6888f09a0607673cb82ae87d58a5ed6c67db11ce 100644 --- a/corsika/detail/modules/tracking/Intersect.inl +++ b/corsika/detail/modules/tracking/Intersect.inl @@ -60,15 +60,11 @@ namespace corsika { for (auto const& node : volumeNode.getChildNodes()) { Intersections const time_intersections = TDerived::intersect(particle, *node); - CORSIKA_LOG_TRACE("intersection times with child volume {}", fmt::ptr(node)); + CORSIKA_LOG_DEBUG("intersection times with child volume {}", fmt::ptr(node)); if (!time_intersections.hasIntersections()) { continue; } - CORSIKA_LOG_TRACE(" : enter {} s, exit {} s", - time_intersections.getEntry() / 1_s, - time_intersections.getExit() / 1_s); - auto const t_entry = time_intersections.getEntry(); auto const t_exit = time_intersections.getExit(); - CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, + CORSIKA_LOG_DEBUG("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, t_entry <= minTime); // note, theoretically t can even be smaller than 0 since we // KNOW we can't yet be in this volume yet, so we HAVE TO @@ -96,7 +92,7 @@ namespace corsika { time_intersections.getExit() / 1_s); auto const t_entry = time_intersections.getEntry(); auto const t_exit = time_intersections.getExit(); - CORSIKA_LOG_TRACE("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, + CORSIKA_LOG_DEBUG("children t-entry: {}, t-exit: {}, smaller? {} ", t_entry, t_exit, t_entry <= minTime); // note, theoretically t can even be smaller than 0 since we // KNOW we can't yet be in this volume yet, so we HAVE TO @@ -106,7 +102,18 @@ namespace corsika { minNode = node; } } - CORSIKA_LOG_TRACE("t-intersect: {}, node {} ", minTime, fmt::ptr(minNode)); + CORSIKA_LOG_DEBUG("next time-intersect: {}, node {} ", minTime, fmt::ptr(minNode)); + // this branch cannot be unit-testes. This is malfunction: LCOV_EXCL_START + if (minTime < 0_s) { + if (minTime < 1e-8_s) { + CORSIKA_LOG_ERROR( + "There is a very negative time step detected: {}. This is not physical and " + "may " + "easily crash subsequent modules. Set to 0_s, but CHECK AND FIX.", + minTime); + } + minTime = 0_s; // LCOV_EXCL_STOP + } return std::make_tuple(minTime, minNode); }