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