![]() |
|
|||
File indexing completed on 2025-09-15 08:54:44
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/inp/Grid.hh 0006 //---------------------------------------------------------------------------// 0007 #pragma once 0008 0009 #include <vector> 0010 0011 #include "corecel/Types.hh" 0012 #include "corecel/cont/EnumArray.hh" 0013 #include "corecel/grid/GridTypes.hh" 0014 #include "celeritas/Types.hh" 0015 0016 namespace celeritas 0017 { 0018 namespace inp 0019 { 0020 //---------------------------------------------------------------------------// 0021 /*! 0022 * Interpolation options for the physics grids. 0023 * 0024 * \c order is only used for \c poly_spline interpolation and \c bc is only 0025 * used for \c cubic_spline interpolation. 0026 */ 0027 struct Interpolation 0028 { 0029 using BC = SplineBoundaryCondition; 0030 0031 InterpolationType type{InterpolationType::linear}; 0032 //! Polynomial order for spline interpolation 0033 size_type order{1}; 0034 //! Boundary conditions for calculating cubic spline second derivatives 0035 BC bc{BC::geant}; 0036 }; 0037 0038 //---------------------------------------------------------------------------// 0039 /*! 0040 * A grid of increasing, sorted 1D data. 0041 * 0042 * This is used to store tabulated physics data such as cross sections or 0043 * energy loss. 0044 */ 0045 struct Grid 0046 { 0047 using VecDbl = std::vector<double>; 0048 0049 VecDbl x; 0050 VecDbl y; 0051 Interpolation interpolation{}; 0052 0053 explicit operator bool() const 0054 { 0055 return !y.empty() && x.size() == y.size(); 0056 } 0057 }; 0058 0059 //---------------------------------------------------------------------------// 0060 /*! 0061 * A uniform grid of increasing, sorted 1D data. 0062 */ 0063 struct UniformGrid 0064 { 0065 using GridBound = EnumArray<Bound, double>; 0066 using VecDbl = std::vector<double>; 0067 0068 GridBound x{}; 0069 VecDbl y; 0070 Interpolation interpolation{}; 0071 0072 explicit operator bool() const 0073 { 0074 return !y.empty() && x[Bound::hi] > x[Bound::lo]; 0075 } 0076 }; 0077 0078 //---------------------------------------------------------------------------// 0079 /*! 0080 * An increasing, sorted 2D grid with node-centered data. 0081 * 0082 * Data is interpolated linearly and indexed as '[x][y]'. 0083 */ 0084 struct TwodGrid 0085 { 0086 using VecDbl = std::vector<double>; 0087 0088 VecDbl x; 0089 VecDbl y; 0090 VecDbl value; 0091 0092 explicit operator bool() const 0093 { 0094 return !value.empty() && value.size() == x.size() * y.size(); 0095 } 0096 }; 0097 0098 //---------------------------------------------------------------------------// 0099 // HELPER FUNCTIONS 0100 //---------------------------------------------------------------------------// 0101 /*! 0102 * Equality operator, mainly for debugging. 0103 */ 0104 inline bool operator==(TwodGrid const& a, TwodGrid const& b) 0105 { 0106 return a.x == b.x && a.y == b.y && a.value == b.value; 0107 } 0108 0109 //---------------------------------------------------------------------------// 0110 } // namespace inp 0111 } // 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 |
![]() ![]() |