Geant4 Cross Reference |
1 /* 2 # <<BEGIN-copyright>> 3 # <<END-copyright>> 4 */ 5 6 #define GIDI_USE_BDFLS 0 7 8 #ifndef GIDI_settings_hpp_included 9 #define GIDI_settings_hpp_included 1 10 11 #include <string> 12 #include <vector> 13 #include <map> 14 15 #include <ptwX.h> 16 #include <ptwXY.h> 17 #include <statusMessageReporting.h> 18 19 /* Disable Effective C++ warnings in GIDI header files. */ 20 #if defined( __INTEL_COMPILER ) 21 #pragma warning( push ) 22 23 #if __INTEL_COMPILER > 1399 24 #pragma warning( disable:2021 ) 25 #elif __INTEL_COMPILER > 1199 26 #pragma warning( disable:2304 ) 27 #endif 28 29 #endif 30 31 #define GIDI_settings_projectileEnergyMode_continuousEnergy 1 32 #define GIDI_settings_projectileEnergyMode_grouped ( 1 << 1 ) 33 #define GIDI_settings_projectileEnergyMode_fixedGrid ( 1 << 2 ) 34 35 class GIDI_settings_group { 36 37 private: 38 std::string mLabel; 39 std::vector<double> mBoundaries; 40 41 public: 42 GIDI_settings_group( std::string const &label = "empty", int size = 0 ); 43 GIDI_settings_group( std::string const &label, int length, double const *values ); 44 GIDI_settings_group( std::string const &label, std::vector<double> const &boundaries ); 45 GIDI_settings_group( GIDI_settings_group const &group ); 46 GIDI_settings_group& operator=( const GIDI_settings_group &group ); 47 ~GIDI_settings_group( ); 48 49 inline double operator[]( int const index ) const { return( mBoundaries[index] ); } 50 inline int size( void ) const { return( (int) mBoundaries.size( ) ); } 51 inline int getNumberOfGroups( void ) const { return( (int) ( mBoundaries.size( ) - 1 ) ); } 52 inline double const *pointer( void ) const { return( &(mBoundaries[0]) ); } 53 54 void setFromCDoubleArray( int length, double *values ); 55 inline std::string getLabel( ) const { return( mLabel ); } 56 int getGroupIndexFromEnergy( double energy, bool encloseOutOfRange ) const; 57 inline bool isLabel( std::string &label ) const { return( label == mLabel ); } 58 void print( bool outline = false, int valuesPerLine = 10 ) const; 59 60 private: 61 void initialize( std::string const &label, int size, int length, double const *values ); 62 }; 63 64 #if GIDI_USE_BDFLS 65 #include <cbdfls.h> 66 67 class GIDI_settings_groups_from_bdfls { 68 69 private: 70 std::vector<GIDI_settings_group> mGroups; 71 72 public: 73 GIDI_settings_groups_from_bdfls( std::string const &fileName ); 74 GIDI_settings_groups_from_bdfls( char const *fileName ); 75 GIDI_settings_groups_from_bdfls( cbdfls_file const *bdfls ); 76 ~GIDI_settings_groups_from_bdfls( ); 77 78 GIDI_settings_group getViaGID( int gid ) const; 79 std::vector<std::string> getLabels( void ) const; 80 std::vector<int> getGIDs( void ) const; 81 void print( bool outline = true, int valuesPerLine = 10 ) const; 82 83 private: 84 void initialize( char const *fileName ); 85 void initialize2( cbdfls_file const *bdfls ); 86 }; 87 #endif 88 89 /** 90 This class stores the flux for one Legendre order (see class GIDI_settings_flux). 91 */ 92 class GIDI_settings_flux_order { 93 94 private: 95 int mOrder; /**< The Legendre order of the flux. */ 96 std::vector<double> mEnergies; /**< List of flux energies. */ 97 std::vector<double> mFluxes; /**< List of flux values - one for each element of mEnergies. */ 98 99 public: 100 GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */ ); 101 GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */, 102 int length /**< The number or values in energies and fluxes. */, 103 double const *energies /**< List of energies where flux is given. */, 104 double const *fluxes /**< List of flux value for each energies value. */ ); 105 GIDI_settings_flux_order( int order /**< The Legendre order for this flux data. */, 106 std::vector<double> const &energies /**< List of energies where flux is given. */, 107 std::vector<double> const &fluxes /**< List of flux value for each energies value. */ ); 108 GIDI_settings_flux_order( GIDI_settings_flux_order const &fluxOrder /**< Legendre flux order to copy. */ ); 109 GIDI_settings_flux_order& operator=( const GIDI_settings_flux_order &fluxOrder ); 110 ~GIDI_settings_flux_order( ); 111 112 inline int getOrder( void ) const { return( mOrder ); } 113 inline int size( void ) const { return( (int) mEnergies.size( ) ); } 114 inline double const *getEnergies( void ) const { return( &(mEnergies[0]) ); } 115 inline double const *getFluxes( void ) const { return( &(mFluxes[0]) ); } 116 void print( int valuesPerLine = 10 ) const; 117 118 private: 119 void initialize( int order, int length, double const *energies, double const *fluxes ); 120 }; 121 122 class GIDI_settings_flux { 123 124 private: 125 std::string mLabel; /**< Label for the flux. */ 126 double mTemperature; 127 std::vector<GIDI_settings_flux_order> mFluxOrders; /**< List of fluxes for each Legendre order, l, sorted by Legendre order starting with l = 0. */ 128 129 public: 130 GIDI_settings_flux( std::string const &label, double temperature_MeV ); 131 GIDI_settings_flux( char const *label, double temperature_MeV ); 132 GIDI_settings_flux( GIDI_settings_flux const &flux ); 133 GIDI_settings_flux& operator=( const GIDI_settings_flux &flux ); 134 ~GIDI_settings_flux( ); 135 136 GIDI_settings_flux_order const *operator[]( int order ) const; 137 inline int getMaxOrder( void ) const { return( (int) mFluxOrders.size( ) - 1 ); } 138 inline int size( void ) const { return( (int) mFluxOrders.size( ) ); } 139 140 inline std::string getLabel( ) const { return( mLabel ); } 141 inline bool isLabel( std::string const &label ) const { return( label == mLabel ); } 142 inline bool isLabel( char const *label ) const { return( label == mLabel ); } 143 inline double getTemperature( ) const { return( mTemperature ); } 144 void addFluxOrder( GIDI_settings_flux_order const &fluxOrder ); 145 void print( bool outline = true, int valuesPerLine = 10 ) const; 146 }; 147 148 #if GIDI_USE_BDFLS 149 class GIDI_settings_fluxes_from_bdfls { 150 151 private: 152 std::vector<GIDI_settings_flux> mFluxes; 153 154 public: 155 GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV ); 156 GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV ); 157 GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV ); 158 ~GIDI_settings_fluxes_from_bdfls( ); 159 160 GIDI_settings_flux getViaFID( int fid ); 161 std::vector<std::string> getLabels( void ); 162 std::vector<int> getFIDs( void ); 163 void print( bool outline = true, int valuesPerLine = 10 ); 164 165 private: 166 void initialize( char const *fileName, double temperature_MeV ); 167 void initialize2( cbdfls_file const *bdfls, double temperature_MeV ); 168 }; 169 #endif 170 171 class GIDI_settings_processedFlux { 172 173 private: 174 GIDI_settings_flux mFlux; 175 std::vector<GIDI::ptwXYPoints *> mFluxXY; /* Same as mFlux but stored as ptwXYPoints for each l-order. */ 176 std::vector<GIDI::ptwXPoints *> mGroupedFlux; /* mFlux grouped using mGroupX, and stored as ptwXPoints for each l-order. */ 177 178 public: 179 GIDI_settings_processedFlux( GIDI_settings_flux const &flux, GIDI::ptwXPoints *groupX ); 180 GIDI_settings_processedFlux( GIDI_settings_processedFlux const &flux ); 181 GIDI_settings_processedFlux& operator=( const GIDI_settings_processedFlux &flux ); 182 ~GIDI_settings_processedFlux( ); 183 184 inline double getTemperature( ) const { return( mFlux.getTemperature( ) ); } 185 GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXPoints *groupX, GIDI::ptwXYPoints *ptwXY1, int order ) const; 186 }; 187 188 class GIDI_settings_particle { 189 190 private: 191 int mPoPId; 192 bool mTransporting; 193 int mEnergyMode; 194 GIDI_settings_group mGroup; 195 GIDI::ptwXPoints *mGroupX; /* Same as mGroup but stored as ptwXPoints. */ 196 std::vector<GIDI_settings_processedFlux> mProcessedFluxes; 197 198 public: 199 GIDI_settings_particle( int PoPId, bool transporting, int energyMode ); 200 GIDI_settings_particle( GIDI_settings_particle const &particle ); 201 int initialize( int PoPId, bool transporting, int energyMode ); 202 ~GIDI_settings_particle( ); 203 204 int addFlux( GIDI::statusMessageReporting *smr, GIDI_settings_flux const &flux ); 205 GIDI_settings_processedFlux const *nearestFluxToTemperature( double temperature ) const; 206 inline int getGroupIndexFromEnergy( double e_in, bool encloseOutOfRange ) const { return( mGroup.getGroupIndexFromEnergy( e_in, encloseOutOfRange ) ); }; 207 inline int getNumberOfGroups( void ) const { return( mGroup.getNumberOfGroups( ) ); }; 208 inline int getPoPId( void ) const { return( mPoPId ); } 209 inline int getEnergyMode( void ) const { return( mEnergyMode ); } 210 inline bool getTransporting( void ) const { return( mTransporting ); } 211 inline GIDI_settings_group getGroup( void ) const { return( mGroup ); } 212 GIDI_settings_flux const *getFlux( double temperature ) const; 213 GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXYPoints *ptwXY1, double temperature, int order ) const; 214 void setGroup( GIDI_settings_group const &group ); 215 216 inline bool isEnergyMode_continuous( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_continuousEnergy ); } 217 inline bool isEnergyMode_grouped( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_grouped ); } 218 inline bool isEnergyMode_fixedGrid( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_fixedGrid ); } 219 220 private: 221 GIDI_settings_flux const *getProcessedFlux( double temperature ) const; 222 }; 223 224 class GIDI_settings { 225 226 private: 227 std::map<int, GIDI_settings_particle> mParticles; 228 229 public: 230 GIDI_settings( ); 231 ~GIDI_settings( ); 232 233 int addParticle( GIDI_settings_particle const &particle ); 234 GIDI_settings_particle const *getParticle( int PoPId ) const; 235 int eraseParticle( int PoPId ); 236 void releaseMemory( ) { mParticles.clear( ); } 237 }; 238 239 #if defined( __INTEL_COMPILER ) 240 #pragma warning( pop ) 241 #endif 242 243 #endif // End of GIDI_settings_hpp_included 244