![]() |
|
|||
File indexing completed on 2025-02-22 10:31:22
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2023-2024 UT-Battelle, LLC, and other Celeritas developers. 0003 // See the top-level COPYRIGHT file for details. 0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT) 0005 //---------------------------------------------------------------------------// 0006 //! \file celeritas/global/alongstep/detail/TrackUpdater.hh 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "celeritas/global/CoreTrackView.hh" 0011 0012 namespace celeritas 0013 { 0014 namespace detail 0015 { 0016 //---------------------------------------------------------------------------// 0017 /*! 0018 * Finish the step. 0019 * 0020 * TODO: we may need to save the pre-step speed and apply the time update using 0021 * an average here. 0022 */ 0023 //---------------------------------------------------------------------------// 0024 struct TrackUpdater 0025 { 0026 inline CELER_FUNCTION void operator()(CoreTrackView const& track); 0027 }; 0028 0029 //---------------------------------------------------------------------------// 0030 // INLINE DEFINITIONS 0031 //---------------------------------------------------------------------------// 0032 CELER_FUNCTION void TrackUpdater::operator()(CoreTrackView const& track) 0033 { 0034 auto sim = track.make_sim_view(); 0035 0036 // The track errored within the along-step kernel 0037 if (sim.status() == TrackStatus::errored) 0038 return; 0039 0040 if (sim.status() == TrackStatus::alive) 0041 { 0042 CELER_ASSERT(sim.step_length() > 0 0043 || track.make_particle_view().is_stopped()); 0044 CELER_ASSERT(sim.post_step_action()); 0045 auto phys = track.make_physics_view(); 0046 if (sim.post_step_action() != phys.scalars().discrete_action() 0047 && (!CELERITAS_DEBUG 0048 || sim.post_step_action() != track.tracking_cut_action())) 0049 { 0050 // Reduce remaining mean free paths to travel. The 'discrete 0051 // action' case is launched separately and resets the 0052 // interaction MFP itself. In the unlikely case that a track is 0053 // about to be killed because it's looping (it's reached its 0054 // collision point but has undergone too many steps), it's OK to 0055 // set the interaction MFP to zero (but avoid during debug mode due 0056 // to the additional error checking). 0057 auto step = track.make_physics_step_view(); 0058 real_type mfp = phys.interaction_mfp() 0059 - sim.step_length() * step.macro_xs(); 0060 CELER_ASSERT(mfp > 0); 0061 phys.interaction_mfp(mfp); 0062 } 0063 } 0064 0065 // Increment the step counter 0066 sim.increment_num_steps(); 0067 } 0068 0069 //---------------------------------------------------------------------------// 0070 } // namespace detail 0071 } // namespace celeritas
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |