Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-10 10:05:50

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/phys/SurfacePhysicsMapView.hh
0006 //---------------------------------------------------------------------------//
0007 #pragma once
0008 
0009 #include "corecel/Types.hh"
0010 
0011 #include "SurfacePhysicsMapData.hh"
0012 
0013 namespace celeritas
0014 {
0015 //---------------------------------------------------------------------------//
0016 /*!
0017  * Access surface physics mappings for a particular surface.
0018  *
0019  * This simply encapsulates the \c SurfaceParamsData class.
0020  */
0021 class SurfacePhysicsMapView
0022 {
0023   public:
0024     //!@{
0025     //! \name Type aliases
0026     using SurfaceParamsRef = NativeCRef<SurfacePhysicsMapData>;
0027     using ModelSurfaceId = SurfaceModel::ModelSurfaceId;
0028     //!@}
0029 
0030   public:
0031     // Construct from data and current surface
0032     CELER_FUNCTION
0033     SurfacePhysicsMapView(SurfaceParamsRef const& params, SurfaceId surface);
0034 
0035     // Get the action ID for the current surface, if any
0036     CELER_FUNCTION ActionId action_id() const;
0037 
0038     // Get the subindex inside that model
0039     CELER_FUNCTION ModelSurfaceId model_surface_id() const;
0040 
0041   private:
0042     SurfaceParamsRef const& params_;
0043     SurfaceId surface_;
0044 };
0045 
0046 //---------------------------------------------------------------------------//
0047 // INLINE DEFINITIONS
0048 //---------------------------------------------------------------------------//
0049 /*!
0050  * Construct from data and current surface.
0051  */
0052 CELER_FUNCTION
0053 SurfacePhysicsMapView::SurfacePhysicsMapView(SurfaceParamsRef const& params,
0054                                              SurfaceId surface)
0055     : params_{params}, surface_{surface}
0056 {
0057     CELER_EXPECT(params_);
0058     CELER_EXPECT(surface_ < params.action_ids.size());
0059 }
0060 
0061 //---------------------------------------------------------------------------//
0062 /*!
0063  * Get the action ID for the current surface, if any.
0064  */
0065 CELER_FUNCTION ActionId SurfacePhysicsMapView::action_id() const
0066 {
0067     return params_.action_ids[surface_];
0068 }
0069 
0070 //---------------------------------------------------------------------------//
0071 /*!
0072  * Get the subindex inside that model.
0073  */
0074 CELER_FUNCTION auto SurfacePhysicsMapView::model_surface_id() const
0075     -> ModelSurfaceId
0076 {
0077     return params_.model_surface_ids[surface_];
0078 }
0079 
0080 //---------------------------------------------------------------------------//
0081 }  // namespace celeritas