|
|
|||
File indexing completed on 2026-06-07 08:23:26
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/TrackInitData.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include "corecel/Types.hh" 0010 #include "corecel/cont/Range.hh" 0011 #include "corecel/data/Collection.hh" 0012 #include "corecel/data/CollectionAlgorithms.hh" 0013 #include "corecel/data/CollectionBuilder.hh" 0014 #include "corecel/sys/Device.hh" 0015 #include "corecel/sys/ThreadId.hh" 0016 #include "celeritas/Types.hh" 0017 0018 #include "TrackInitializer.hh" 0019 0020 namespace celeritas 0021 { 0022 namespace optical 0023 { 0024 //---------------------------------------------------------------------------// 0025 /*! 0026 * Storage for dynamic data used to initialize new optical photon tracks. 0027 * 0028 * - \c initializers stores the data for track initializers and secondaries 0029 * waiting to be turned into new tracks and can be any size up to \c 0030 * capacity. 0031 * - \c vacancies stores the \c TrackSlotid of the tracks that have been 0032 * killed; the size will be <= the number of track states. 0033 */ 0034 template<Ownership W, MemSpace M> 0035 struct TrackInitStateData 0036 { 0037 //// TYPES //// 0038 0039 template<class T> 0040 using StateItems = StateCollection<T, W, M>; 0041 0042 //// DATA //// 0043 0044 StateItems<TrackSlotId> vacancies; 0045 0046 //// METHODS //// 0047 0048 //! Whether the data are assigned 0049 explicit CELER_FUNCTION operator bool() const 0050 { 0051 return !vacancies.empty(); 0052 } 0053 0054 //! Assign from another set of data 0055 template<Ownership W2, MemSpace M2> 0056 TrackInitStateData& operator=(TrackInitStateData<W2, M2>& other) 0057 { 0058 CELER_EXPECT(other); 0059 vacancies = other.vacancies; 0060 return *this; 0061 } 0062 }; 0063 0064 //---------------------------------------------------------------------------// 0065 /*! 0066 * Resize and initialize data. 0067 * 0068 * Here \c size is the number of track states, and the "capacity" is the 0069 * maximum number of initializers that can be buffered. 0070 */ 0071 template<MemSpace M> 0072 void resize(TrackInitStateData<Ownership::value, M>* data, 0073 StreamId stream, 0074 size_type size) 0075 { 0076 CELER_EXPECT(size > 0); 0077 0078 // Initialize vacancies to mark all track slots as empty 0079 resize(&data->vacancies, size); 0080 fill_sequence(&data->vacancies, stream); 0081 0082 CELER_ENSURE(*data); 0083 } 0084 0085 //---------------------------------------------------------------------------// 0086 0087 } // namespace optical 0088 } // namespace celeritas
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|