![]() |
|
|||
File indexing completed on 2025-09-17 08:53:44
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/Interaction.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Macros.hh" 0010 #include "corecel/cont/Span.hh" 0011 #include "geocel/Types.hh" 0012 0013 #include "TrackInitializer.hh" 0014 0015 namespace celeritas 0016 { 0017 namespace optical 0018 { 0019 //---------------------------------------------------------------------------// 0020 /*! 0021 * The result of a discrete optical interaction. 0022 * 0023 * All optical interactions are discrete. The wavelength of a photon is only 0024 * changed through absorption re-emission processes. 0025 */ 0026 struct Interaction 0027 { 0028 //! Interaction result category 0029 enum class Action 0030 { 0031 scattered, //!< Still alive, state has changed 0032 absorbed, //!< Absorbed by the material 0033 unchanged, //!< No state change, no secondaries 0034 failed, //!< Ran out of memory during sampling 0035 }; 0036 0037 Real3 direction; //!< Post-interaction direction 0038 Real3 polarization; //!< Post-interaction polarization 0039 Span<TrackInitializer> secondaries; //!< Emitted secondaries 0040 Action action{Action::scattered}; //!< Flags for interaction result 0041 0042 //! Return an interaction respresenting an absorbed process 0043 static inline CELER_FUNCTION Interaction from_absorption(); 0044 0045 //! Return an interaction with no change in the track state 0046 static inline CELER_FUNCTION Interaction from_unchanged(); 0047 0048 // Return an interaction representing a recoverable error 0049 static inline CELER_FUNCTION Interaction from_failure(); 0050 0051 //! Whether the state changed but did not fail 0052 CELER_FUNCTION bool changed() const 0053 { 0054 return static_cast<int>(action) < static_cast<int>(Action::unchanged); 0055 } 0056 }; 0057 0058 //---------------------------------------------------------------------------// 0059 // INLINE DEFINITIONS 0060 //---------------------------------------------------------------------------// 0061 /*! 0062 * Construct an interaction for an absorbed optical photon. 0063 */ 0064 CELER_FUNCTION Interaction Interaction::from_absorption() 0065 { 0066 Interaction result; 0067 result.action = Action::absorbed; 0068 return result; 0069 } 0070 0071 //---------------------------------------------------------------------------// 0072 /*! 0073 * Construct an interaction for edge cases where this is no state change. 0074 */ 0075 CELER_FUNCTION Interaction Interaction::from_unchanged() 0076 { 0077 Interaction result; 0078 result.action = Action::unchanged; 0079 return result; 0080 } 0081 0082 //---------------------------------------------------------------------------// 0083 /*! 0084 * Indicate a failure to allocate memory for secondaries. 0085 */ 0086 CELER_FUNCTION Interaction Interaction::from_failure() 0087 { 0088 Interaction result; 0089 result.action = Action::failed; 0090 return result; 0091 } 0092 0093 //---------------------------------------------------------------------------// 0094 } // namespace optical 0095 } // 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 |
![]() ![]() |