![]() |
|
|||
File indexing completed on 2025-09-13 08:58:36
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 geocel/Types.hh 0006 //! Shared (VecGeom + ORANGE) geometry type definitions. 0007 //---------------------------------------------------------------------------// 0008 #pragma once 0009 0010 #include "corecel/OpaqueId.hh" 0011 #include "corecel/Types.hh" 0012 #include "corecel/cont/Array.hh" 0013 0014 namespace celeritas 0015 { 0016 //---------------------------------------------------------------------------// 0017 // TYPE ALIASES 0018 //---------------------------------------------------------------------------// 0019 0020 //! Three-dimensional cartesian coordinates 0021 using Real3 = Array<real_type, 3>; 0022 0023 //! Two-dimensional cartesian coordinates 0024 using Real2 = Array<real_type, 2>; 0025 0026 //! Two-dimensional extents 0027 using Size2 = Array<size_type, 2>; 0028 0029 //! Alias for a small square dense matrix 0030 template<class T, size_type N> 0031 using SquareMatrix = Array<Array<T, N>, N>; 0032 0033 //! Alias for a small square dense matrix 0034 using SquareMatrixReal3 = SquareMatrix<real_type, 3>; 0035 0036 //---------------------------------------------------------------------------// 0037 0038 //! Type-safe "level", i.e., depth of embedded unit/scene/volume 0039 using LevelId = OpaqueId<struct Level_>; 0040 0041 //! Identifier for a material fill 0042 using GeoMatId = OpaqueId<struct GeoMaterial_>; 0043 0044 //! Identifier for a surface (for surface-based geometries) 0045 using SurfaceId = OpaqueId<struct Surface_>; 0046 0047 //! Identifier for a geometry volume that may be repeated 0048 using VolumeId = OpaqueId<struct Volume_>; 0049 0050 //! Identifier for an instance of a geometry volume (aka physical/placed) 0051 using VolumeInstanceId = OpaqueId<struct VolumeInstance_>; 0052 0053 //---------------------------------------------------------------------------// 0054 // ENUMERATIONS 0055 //---------------------------------------------------------------------------// 0056 /*! 0057 * Enumeration for cartesian axes. 0058 */ 0059 enum class Axis 0060 { 0061 x, //!< X axis/I index coordinate 0062 y, //!< Y axis/J index coordinate 0063 z, //!< Z axis/K index coordinate 0064 size_ //!< Sentinel value for looping over axes 0065 }; 0066 0067 //---------------------------------------------------------------------------// 0068 // STRUCTS 0069 //---------------------------------------------------------------------------// 0070 /*! 0071 * Data required to initialize a geometry state. 0072 */ 0073 struct GeoTrackInitializer 0074 { 0075 Real3 pos{0, 0, 0}; 0076 Real3 dir{0, 0, 0}; 0077 0078 //! True if assigned 0079 explicit CELER_FUNCTION operator bool() const 0080 { 0081 return dir[0] != 0 || dir[1] != 0 || dir[2] != 0; 0082 } 0083 }; 0084 0085 //---------------------------------------------------------------------------// 0086 /*! 0087 * Result of a propagation step. 0088 * 0089 * The boundary flag means that the geometry is step limiting, but the surface 0090 * crossing must be called externally. 0091 */ 0092 struct Propagation 0093 { 0094 real_type distance{0}; //!< Distance traveled 0095 bool boundary{false}; //!< True if hit a boundary before given distance 0096 bool looping{false}; //!< True if track is looping in the field propagator 0097 }; 0098 0099 //---------------------------------------------------------------------------// 0100 // HELPER FUNCTIONS 0101 //---------------------------------------------------------------------------// 0102 //! Convert Axis enum value to int 0103 CELER_CONSTEXPR_FUNCTION int to_int(Axis a) 0104 { 0105 return static_cast<int>(a); 0106 } 0107 0108 //---------------------------------------------------------------------------// 0109 //! Convert int to Axis enum value 0110 inline CELER_FUNCTION Axis to_axis(int a) 0111 { 0112 CELER_EXPECT(a >= 0 && a < 3); 0113 return static_cast<Axis>(a); 0114 } 0115 0116 //---------------------------------------------------------------------------// 0117 //! Get the lowercase name of the axis. 0118 inline constexpr char to_char(Axis ax) 0119 { 0120 return "xyz\a"[static_cast<int>(ax)]; 0121 } 0122 0123 //---------------------------------------------------------------------------// 0124 } // 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 |
![]() ![]() |