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