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/SmearRoughnessExecutor.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "celeritas/optical/CoreTrackView.hh"
0010 #include "celeritas/optical/surface/SmearRoughnessSampler.hh"
0011 #include "celeritas/optical/surface/SurfacePhysicsUtils.hh"
0012 
0013 #include "SmearRoughnessData.hh"
0014 
0015 namespace celeritas
0016 {
0017 namespace optical
0018 {
0019 //---------------------------------------------------------------------------//
0020 /*!
0021  * Sample and save a facet normal for the smear roughness model.
0022  *
0023  * TODO: refactor into roughness applier and SmearNormalCalculator
0024  */
0025 struct SmearRoughnessExecutor
0026 {
0027     NativeCRef<SmearRoughnessData> data;
0028 
0029     //! Apply smear roughness executor
0030     CELER_FUNCTION void operator()(CoreTrackView& track) const
0031     {
0032         auto s_phys = track.surface_physics();
0033         auto sub_model_id
0034             = s_phys.interface(SurfacePhysicsOrder::roughness).internal_surface_id();
0035         CELER_ASSERT(sub_model_id < data.roughness.size());
0036         EnteringSurfaceNormalSampler<SmearRoughnessSampler> sample_facet{
0037             track.geometry().dir(),
0038             s_phys.global_normal(),
0039             data.roughness[sub_model_id]};
0040         auto rng = track.rng();
0041         s_phys.facet_normal(sample_facet(rng));
0042     }
0043 };
0044 
0045 //---------------------------------------------------------------------------//
0046 }  // namespace optical
0047 }  // namespace celeritas