Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-30 10:09:32

0001 //----------------------------------*-C++-*----------------------------------//
0002 // Copyright 2024 UT-Battelle, LLC, and other Celeritas developers.
0003 // See the top-level COPYRIGHT file for details.
0004 // SPDX-License-Identifier: (Apache-2.0 OR MIT)
0005 //---------------------------------------------------------------------------//
0006 //! \file geocel/rasterize/RaytraceImager.hh
0007 //---------------------------------------------------------------------------//
0008 #pragma once
0009 
0010 #include <memory>
0011 
0012 #include "geocel/GeoTraits.hh"
0013 
0014 #include "ImageInterface.hh"
0015 
0016 namespace celeritas
0017 {
0018 //---------------------------------------------------------------------------//
0019 template<Ownership, MemSpace>
0020 struct ImageParamsData;
0021 template<Ownership, MemSpace>
0022 struct ImageStateData;
0023 
0024 //---------------------------------------------------------------------------//
0025 /*!
0026  * Generate one or more images from a geometry by raytracing.
0027  */
0028 template<class G>
0029 class RaytraceImager final : public ImagerInterface
0030 {
0031   public:
0032     //!@{
0033     //! \name Type aliases
0034     using SPGeometry = std::shared_ptr<G const>;
0035     //!@}
0036 
0037   public:
0038     // Construct with geometry
0039     explicit RaytraceImager(SPGeometry geo);
0040 
0041     // Raytrace an image on host or device
0042     void operator()(Image<MemSpace::host>* image) final;
0043     void operator()(Image<MemSpace::device>* image) final;
0044 
0045   private:
0046     //// TYPES ////
0047 
0048     using GTraits = GeoTraits<G>;
0049     template<Ownership W, MemSpace M>
0050     using GeoStateData = typename GTraits::template StateData<W, M>;
0051     template<Ownership W, MemSpace M>
0052     using GeoParamsData = typename GTraits::template ParamsData<W, M>;
0053     using GeoTrackView = typename GTraits::TrackView;
0054 
0055     template<MemSpace M>
0056     using GeoParamsCRef = GeoParamsData<Ownership::const_reference, M>;
0057     template<MemSpace M>
0058     using GeoStateRef = GeoStateData<Ownership::reference, M>;
0059     template<MemSpace M>
0060     using ImageParamsCRef = ImageParamsData<Ownership::const_reference, M>;
0061     template<MemSpace M>
0062     using ImageStateRef = ImageStateData<Ownership::reference, M>;
0063 
0064     struct CachedStates;
0065 
0066     //// DATA ////
0067 
0068     SPGeometry geo_;
0069     std::shared_ptr<CachedStates> cache_;
0070 
0071     //// MEMBER FUNCTIONS ////
0072 
0073     CELER_DEFAULT_MOVE_DELETE_COPY(RaytraceImager);
0074 
0075     template<MemSpace M>
0076     void raytrace_impl(Image<M>* image);
0077 
0078     void
0079     launch_raytrace_kernel(GeoParamsCRef<MemSpace::host> const& geo_params,
0080                            GeoStateRef<MemSpace::host> const& geo_states,
0081                            ImageParamsCRef<MemSpace::host> const& img_params,
0082                            ImageStateRef<MemSpace::host> const& img_state) const;
0083 
0084     void launch_raytrace_kernel(
0085         GeoParamsCRef<MemSpace::device> const& geo_params,
0086         GeoStateRef<MemSpace::device> const& geo_states,
0087         ImageParamsCRef<MemSpace::device> const& img_params,
0088         ImageStateRef<MemSpace::device> const& img_state) const;
0089 };
0090 
0091 //---------------------------------------------------------------------------//
0092 }  // namespace celeritas