Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-16 08:52:21

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/geo/GeoMaterialView.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "GeoMaterialData.hh"
0010 
0011 namespace celeritas
0012 {
0013 //---------------------------------------------------------------------------//
0014 /*!
0015  * Access geometry-to-material conversion.
0016  */
0017 class GeoMaterialView
0018 {
0019   public:
0020     //!@{
0021     //! \name Type aliases
0022     using GeoMaterialData = NativeCRef<GeoMaterialParamsData>;
0023     //!@}
0024 
0025   public:
0026     // Construct from shared data
0027     inline CELER_FUNCTION GeoMaterialView(GeoMaterialData const& params);
0028 
0029     // Return material for the given volume
0030     inline CELER_FUNCTION PhysMatId material_id(VolumeId volume) const;
0031 
0032   private:
0033     GeoMaterialData const& params_;
0034 };
0035 
0036 //---------------------------------------------------------------------------//
0037 // INLINE DEFINITIONS
0038 //---------------------------------------------------------------------------//
0039 /*!
0040  * Construct from shared data.
0041  */
0042 CELER_FUNCTION
0043 GeoMaterialView::GeoMaterialView(GeoMaterialData const& params)
0044     : params_(params)
0045 {
0046 }
0047 
0048 //---------------------------------------------------------------------------//
0049 /*!
0050  * Return material for the given volume.
0051  *
0052  * Note that this will *fail* if the particle is outside -- the volume ID will
0053  * be false.
0054  */
0055 CELER_FUNCTION PhysMatId GeoMaterialView::material_id(VolumeId volume) const
0056 {
0057     CELER_EXPECT(volume < params_.materials.size());
0058     return params_.materials[volume];
0059 }
0060 
0061 //---------------------------------------------------------------------------//
0062 }  // namespace celeritas