![]() |
|
|||
File indexing completed on 2025-02-21 09:57:02
0001 //----------------------------------*-C++-*----------------------------------// 0002 // Copyright 2020-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 celeritas/Types.hh 0007 //! \brief Type definitions for simulation management 0008 //---------------------------------------------------------------------------// 0009 #pragma once 0010 0011 #include <cstdint> 0012 0013 #include "corecel/Config.hh" 0014 // IWYU pragma: begin_exports 0015 #include "corecel/Assert.hh" 0016 #include "corecel/Macros.hh" 0017 #include "corecel/OpaqueId.hh" 0018 #include "corecel/Types.hh" 0019 #include "corecel/sys/ThreadId.hh" 0020 #include "geocel/Types.hh" 0021 // IWYU pragma: end_exports 0022 0023 namespace celeritas 0024 { 0025 //---------------------------------------------------------------------------// 0026 // TYPE ALIASES 0027 //---------------------------------------------------------------------------// 0028 0029 //! Opaque index to ElementRecord in the global vector of elements 0030 using ElementId = OpaqueId<struct ElementRecord>; 0031 0032 //! Counter for the initiating event for a track 0033 using EventId = OpaqueId<struct Event_>; 0034 0035 //! Opaque index to IsotopeRecord in a vector 0036 using IsotopeId = OpaqueId<struct IsotopeRecord>; 0037 0038 //! Opaque index of a material modified by physics options 0039 // TODO: rename to PhysMatId; equivalent to "material cuts couple" 0040 using MaterialId = OpaqueId<class Material_>; 0041 0042 //! Opaque index of model in the list of physics processes 0043 using ModelId = OpaqueId<class Model>; 0044 0045 //! Opaque index to a material with optical properties 0046 using OpticalMaterialId = OpaqueId<struct OpticalMaterial_>; 0047 0048 //! Opaque index to ParticleRecord in a vector: represents a particle type 0049 using ParticleId = OpaqueId<struct Particle_>; 0050 0051 //! Opaque index of physics process 0052 using ProcessId = OpaqueId<class Process>; 0053 0054 //! Unique ID (for an event) of a track among all primaries and secondaries 0055 using TrackId = OpaqueId<struct Track_>; 0056 0057 //---------------------------------------------------------------------------// 0058 // (detailed type aliases) 0059 //---------------------------------------------------------------------------// 0060 0061 //! Opaque index for mapping volume-specific "sensitive detector" objects 0062 using DetectorId = OpaqueId<struct Detector_>; 0063 0064 //! Opaque index to one elemental component datum in a particular material 0065 using ElementComponentId = OpaqueId<struct MatElementComponent>; 0066 0067 //! Opaque index to one isotopic component datum in a particular element 0068 using IsotopeComponentId = OpaqueId<struct ElIsotopeComponent>; 0069 0070 //! Opaque index of a process applicable to a single particle type 0071 using ParticleProcessId = OpaqueId<ProcessId>; 0072 0073 //! Opaque index of a model applicable to a single particle type 0074 using ParticleModelId = OpaqueId<ModelId>; 0075 0076 //! Opaque index of electron subshell 0077 using SubshellId = OpaqueId<struct Subshell_>; 0078 0079 //! Opaque index of particle-nucleon cascade channel 0080 using ChannelId = OpaqueId<struct Channel_>; 0081 0082 //---------------------------------------------------------------------------// 0083 // ENUMERATIONS 0084 //---------------------------------------------------------------------------// 0085 //! Physical state of matter 0086 enum class MatterState 0087 { 0088 unspecified = 0, 0089 solid, 0090 liquid, 0091 gas, 0092 size_ 0093 }; 0094 0095 //---------------------------------------------------------------------------// 0096 /*! 0097 * Whether a track slot is alive, inactive, or dying inside a step iteration. 0098 * 0099 * Each track slot has a state marking its transition between death and life. 0100 * 0101 * - A track slot starts as \c inactive . If not filled with a new track, it is 0102 * inactive for the rest of the step iteration. 0103 * - When it is populated with a new particle, it is \c initializing . If an 0104 * error occurs during initialization it is \c errored . 0105 * - During the pre-step setup, a non-errored active track slot is marked as \c 0106 * alive . 0107 * - During along-step or post-step a track can be marked as \c errored or 0108 * \c killed . 0109 */ 0110 enum class TrackStatus : std::uint_least8_t 0111 { 0112 inactive = 0, //!< No tracking in this thread slot 0113 initializing, //!< Before pre-step, after initialization 0114 alive, //!< Track is active and alive 0115 begin_dying_, 0116 errored = begin_dying_, //!< Track failed during this step 0117 killed, //!< Killed physically inside the step 0118 size_ 0119 }; 0120 0121 //---------------------------------------------------------------------------// 0122 //! Differentiate between result data at the beginning and end of a step. 0123 enum class StepPoint 0124 { 0125 pre, 0126 post, 0127 size_ 0128 }; 0129 0130 //---------------------------------------------------------------------------// 0131 /*! 0132 * Change the ordering or thread mapping of track slots. 0133 * 0134 * There are three categories of track sorting: 0135 * 1. No sorting is performed and new tracks are inserted in the nearest empty 0136 * track slot. (\c none ) 0137 * 2. The location of new track slots is biased during track initialization: 0138 * charged and neutral tracks are inserted at opposite sides of the track 0139 * slot vacancies. (\c init_charge ) 0140 * 3. Tracks are \em reindexed one or more times per step so that the layout 0141 * in memory is unchanged but an additional indirection maps threads onto 0142 * different track slots based on particle attributes (\c reindex_status, 0143 * \c reindex_particle_type ), actions (\c reindex_along_step_action, 0144 * \c reindex_step_limit_action, \c reindex_both_action ). 0145 * 4. As a control to measure the cost of indirection, the track slots can be 0146 * reindexed randomly at the beginning of execution (\c reindex_shuffle ). 0147 */ 0148 enum class TrackOrder 0149 { 0150 none, //!< Don't do any sorting: tracks are in an arbitrary order 0151 begin_layout_, 0152 //! Partition data layout of new tracks by charged vs neutral 0153 init_charge = begin_layout_, 0154 end_layout_, 0155 begin_reindex_ = end_layout_, 0156 //!< Shuffle at the start of the simulation 0157 reindex_shuffle = begin_reindex_, 0158 reindex_status, //!< Partition by active/inactive status 0159 reindex_particle_type, //!< Sort by particle type 0160 begin_reindex_action_, 0161 //! Sort only by the along-step action id 0162 reindex_along_step_action = begin_reindex_action_, 0163 reindex_step_limit_action, //!< Sort only by the step limit action id 0164 reindex_both_action, //!< Sort by along-step id, then post-step ID 0165 end_reindex_action_, 0166 end_reindex_ = end_reindex_action_, 0167 size_ = end_reindex_ 0168 }; 0169 0170 //---------------------------------------------------------------------------// 0171 //! Algorithm used to calculate the multiple scattering step limit 0172 enum class MscStepLimitAlgorithm 0173 { 0174 minimal, 0175 safety, 0176 safety_plus, 0177 distance_to_boundary, 0178 size_, 0179 }; 0180 0181 //---------------------------------------------------------------------------// 0182 //! Nuclear form factor model for Coulomb scattering 0183 enum class NuclearFormFactorType 0184 { 0185 none, 0186 flat, 0187 exponential, 0188 gaussian, 0189 size_ 0190 }; 0191 0192 //---------------------------------------------------------------------------// 0193 // HELPER STRUCTS 0194 //---------------------------------------------------------------------------// 0195 //! Step length and limiting action to take 0196 struct StepLimit 0197 { 0198 real_type step{}; 0199 ActionId action{}; 0200 0201 //! Whether a step limit has been determined 0202 explicit CELER_FUNCTION operator bool() const 0203 { 0204 CELER_ASSERT(step >= 0); 0205 return static_cast<bool>(action); 0206 } 0207 }; 0208 0209 //---------------------------------------------------------------------------// 0210 // HELPER FUNCTIONS 0211 //---------------------------------------------------------------------------// 0212 0213 //! Whether a track is in a consistent, valid state 0214 CELER_CONSTEXPR_FUNCTION bool is_track_valid(TrackStatus status) 0215 { 0216 return status != TrackStatus::inactive && status != TrackStatus::errored; 0217 } 0218 0219 //---------------------------------------------------------------------------// 0220 // HELPER FUNCTIONS (HOST) 0221 //---------------------------------------------------------------------------// 0222 0223 // Get a string corresponding to an interpolation 0224 char const* to_cstring(Interp); 0225 0226 // Get a string corresponding to a material state 0227 char const* to_cstring(MatterState); 0228 0229 // Get a string corresponding to a track stats 0230 char const* to_cstring(TrackStatus); 0231 0232 // Get a string corresponding to a track ordering policy 0233 char const* to_cstring(TrackOrder); 0234 0235 // Get a string corresponding to the MSC step limit algorithm 0236 char const* to_cstring(MscStepLimitAlgorithm value); 0237 0238 // Get a string corresponding to the nuclear form factor model 0239 char const* to_cstring(NuclearFormFactorType value); 0240 0241 //---------------------------------------------------------------------------// 0242 } // 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 |
![]() ![]() |