File indexing completed on 2026-11-07 10:11:39
0001
0002
0003
0004
0005
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
0024
0025
0026
0027
0028 struct OnlyReflectionExecutor
0029 {
0030 NativeCRef<OnlyReflectionData> data;
0031
0032 inline CELER_FUNCTION SurfaceInteraction operator()(
0033 CoreTrackView const&) const;
0034 };
0035
0036
0037
0038
0039
0040
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 }
0072 }