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/OnlyReflectionExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/math/Algorithms.hh"
0010 #include "corecel/math/ArrayOperators.hh"
0011 #include "celeritas/optical/CoreTrackView.hh"
0012 
0013 #include "OnlyReflectionData.hh"
0014 #include "ReflectionFormCalculator.hh"
0015 #include "SurfaceInteraction.hh"
0016 
0017 namespace celeritas
0018 {
0019 namespace optical
0020 {
0021 //---------------------------------------------------------------------------//
0022 /*!
0023  * Return only a reflection interaction based on the \c ReflectionMode.
0024  *
0025  * This applies the \c ReflectionFormCalculator directly to the track for the
0026  * given mode.
0027  */
0028 struct OnlyReflectionExecutor
0029 {
0030     NativeCRef<OnlyReflectionData> data;
0031 
0032     inline CELER_FUNCTION SurfaceInteraction operator()(
0033         CoreTrackView const&) const;
0034 };
0035 
0036 //---------------------------------------------------------------------------//
0037 // INLINE DEFINITIONS
0038 //---------------------------------------------------------------------------//
0039 /*!
0040  * Calculate surface interaction based on the reflection mode.
0041  */
0042 CELER_FUNCTION SurfaceInteraction OnlyReflectionExecutor::operator()(
0043     CoreTrackView const& track) const
0044 {
0045     auto sub_model_id = track.surface_physics()
0046                             .interface(SurfacePhysicsOrder::interaction)
0047                             .internal_surface_id();
0048     CELER_ASSERT(sub_model_id < data.modes.size());
0049 
0050     ReflectionFormCalculator calc_reflection{
0051         track.geometry().dir(), track.particle(), track.surface_physics()};
0052 
0053     switch (data.modes[sub_model_id])
0054     {
0055         case ReflectionMode::specular_spike:
0056             return calc_reflection.calc_specular_spike();
0057         case ReflectionMode::specular_lobe:
0058             return calc_reflection.calc_specular_lobe();
0059         case ReflectionMode::backscatter:
0060             return calc_reflection.calc_backscatter();
0061         case ReflectionMode::diffuse_lobe: {
0062             auto rng = track.rng();
0063             return calc_reflection.sample_lambertian_reflection(rng);
0064         }
0065         default:
0066             CELER_ASSERT_UNREACHABLE();
0067     }
0068 }
0069 
0070 //---------------------------------------------------------------------------//
0071 }  // namespace optical
0072 }  // namespace celeritas