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/SurfaceInteraction.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/math/ArrayUtils.hh"
0010 #include "corecel/math/SoftEqual.hh"
0011 
0012 namespace celeritas
0013 {
0014 namespace optical
0015 {
0016 //---------------------------------------------------------------------------//
0017 /*!
0018  * Result of a surface physics interaction.
0019  */
0020 struct SurfaceInteraction
0021 {
0022     //! Interaction result category
0023     enum class Action
0024     {
0025         absorbed,  //!< Killed on the surface
0026         reflected,  //!< Reflected into original material
0027         refracted,  //!< Refracted into new material, with change
0028         transmitted  //!< Transmitted into new material without change
0029     };
0030 
0031     Action action{Action::absorbed};  //!< Flags for interaction result
0032     Real3 direction;
0033     Real3 polarization;
0034 
0035     // Return an interaction representing an absorbed photon
0036     static inline CELER_FUNCTION SurfaceInteraction from_absorption();
0037 
0038     // Return an interaction representing a transmitted photon
0039     static inline CELER_FUNCTION SurfaceInteraction from_transmission();
0040 
0041     //! Whether data is assigned and valid
0042     CELER_FUNCTION bool is_valid() const
0043     {
0044         return action == Action::absorbed || action == Action::transmitted
0045                || (is_soft_unit_vector(direction)
0046                    && is_soft_unit_vector(polarization)
0047                    && is_soft_orthogonal(direction, polarization));
0048     }
0049 };
0050 
0051 //---------------------------------------------------------------------------//
0052 // INLINE DEFINITIONS
0053 //---------------------------------------------------------------------------//
0054 /*!
0055  * Construct a surface interaction for an optical photon absorbed on the
0056  * surface.
0057  */
0058 CELER_FUNCTION SurfaceInteraction SurfaceInteraction::from_absorption()
0059 {
0060     SurfaceInteraction result;
0061     result.action = Action::absorbed;
0062     return result;
0063 }
0064 
0065 //---------------------------------------------------------------------------//
0066 /*!
0067  * Construct a surface interaction for an optical photon transmitted through
0068  * the surface without change.
0069  */
0070 CELER_FUNCTION SurfaceInteraction SurfaceInteraction::from_transmission()
0071 {
0072     SurfaceInteraction result;
0073     result.action = Action::transmitted;
0074     return result;
0075 }
0076 
0077 //---------------------------------------------------------------------------//
0078 }  // namespace optical
0079 }  // namespace celeritas