Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:11:39

0001 //------------------------------- -*- C++ -*- -------------------------------//
0002 // Copyright Celeritas contributors: see top-level COPYRIGHT file for details
0003 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0004 //---------------------------------------------------------------------------//
0005 //! \file celeritas/optical/surface/model/ReflectivityApplier.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "celeritas/optical/CoreTrackView.hh"
0010 
0011 namespace celeritas
0012 {
0013 namespace optical
0014 {
0015 //---------------------------------------------------------------------------//
0016 /*!
0017  * Wrap a reflectivity executor and apply it to a track.
0018  *
0019  * The functor \c F must take a \c CoreTrackView and return a \c
0020  * ReflectivityAction.
0021  */
0022 template<class F>
0023 struct ReflectivityApplier
0024 {
0025     F sample_reflectivity;
0026 
0027     inline CELER_FUNCTION void operator()(CoreTrackView const&) const;
0028 };
0029 
0030 //---------------------------------------------------------------------------//
0031 // DEDUCTION GUIDES
0032 //---------------------------------------------------------------------------//
0033 template<class F>
0034 CELER_CTAD_FUNCTION ReflectivityApplier(F&&) -> ReflectivityApplier<F>;
0035 
0036 //---------------------------------------------------------------------------//
0037 // INLINE DEFINITIONS
0038 //---------------------------------------------------------------------------//
0039 /*!
0040  * Apply sampled reflectivity result to the track.
0041  */
0042 template<class F>
0043 CELER_FUNCTION void ReflectivityApplier<F>::operator()(
0044     CoreTrackView const& track) const
0045 {
0046     // Sample reflectivity and set it
0047     auto action = this->sample_reflectivity(track);
0048 
0049     auto s_phys = track.surface_physics();
0050     s_phys.reflectivity_action(action);
0051 
0052     if (action == ReflectivityAction::absorb)
0053     {
0054         // Mark particle as killed
0055         track.sim().status(TrackStatus::killed);
0056     }
0057     else if (action == ReflectivityAction::transmit)
0058     {
0059         // Move across the boundary
0060         auto traverse = s_phys.traversal();
0061         traverse.cross_interface(traverse.dir());
0062         if (traverse.is_exiting())
0063         {
0064             // End boundary crossing if exiting
0065             track.sim().post_step_action(s_phys.scalars().post_boundary_action);
0066         }
0067     }
0068 }
0069 
0070 //---------------------------------------------------------------------------//
0071 }  // namespace optical
0072 }  // namespace celeritas