Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:59:30

0001 /*
0002 # <<BEGIN-copyright>>
0003 # <<END-copyright>>
0004 */
0005 
0006 #define GIDI_USE_BDFLS 0
0007 
0008 #ifndef GIDI_settings_hpp_included
0009 #define GIDI_settings_hpp_included 1
0010 
0011 #include <string>
0012 #include <vector>
0013 #include <map>
0014 
0015 #include <ptwX.h>
0016 #include <ptwXY.h>
0017 #include <statusMessageReporting.h>
0018 
0019 /* Disable Effective C++ warnings in GIDI header files. */
0020 #if defined( __INTEL_COMPILER )
0021 #pragma warning( push )
0022 
0023 #if   __INTEL_COMPILER > 1399
0024 #pragma warning( disable:2021 )
0025 #elif __INTEL_COMPILER > 1199
0026 #pragma warning( disable:2304 )
0027 #endif
0028 
0029 #endif
0030 
0031 #define GIDI_settings_projectileEnergyMode_continuousEnergy 1
0032 #define GIDI_settings_projectileEnergyMode_grouped ( 1 << 1 )
0033 #define GIDI_settings_projectileEnergyMode_fixedGrid ( 1 << 2 )
0034 
0035 class GIDI_settings_group {
0036 
0037     private:
0038         std::string mLabel;
0039         std::vector<double> mBoundaries;
0040 
0041     public:
0042         GIDI_settings_group( std::string const &label = "empty", int size = 0 );
0043         GIDI_settings_group( std::string const &label, int length, double const *values );
0044         GIDI_settings_group( std::string const &label, std::vector<double> const &boundaries );
0045         GIDI_settings_group( GIDI_settings_group const &group );
0046         GIDI_settings_group& operator=( const GIDI_settings_group &group );
0047         ~GIDI_settings_group( );
0048 
0049         inline double operator[]( int const index ) const { return( mBoundaries[index] ); }
0050         inline int size( void ) const { return( (int) mBoundaries.size( ) ); }
0051         inline int getNumberOfGroups( void ) const { return( (int) ( mBoundaries.size( ) - 1 ) ); }
0052         inline double const *pointer( void ) const { return( &(mBoundaries[0]) ); }
0053 
0054         void setFromCDoubleArray( int length, double *values );
0055         inline std::string getLabel( ) const { return( mLabel ); }
0056         int getGroupIndexFromEnergy( double energy, bool encloseOutOfRange ) const;
0057         inline bool isLabel( std::string &label ) const { return( label == mLabel ); }
0058         void print( bool outline = false, int valuesPerLine = 10 ) const;
0059 
0060     private:
0061         void initialize( std::string const &label, int size, int length, double const *values );
0062 };
0063 
0064 #if GIDI_USE_BDFLS
0065 #include <cbdfls.h>
0066 
0067 class GIDI_settings_groups_from_bdfls {
0068 
0069     private:
0070         std::vector<GIDI_settings_group> mGroups;
0071 
0072     public:
0073         GIDI_settings_groups_from_bdfls( std::string const &fileName );
0074         GIDI_settings_groups_from_bdfls( char const *fileName );
0075         GIDI_settings_groups_from_bdfls( cbdfls_file const *bdfls );
0076         ~GIDI_settings_groups_from_bdfls( );
0077 
0078         GIDI_settings_group getViaGID( int gid ) const;
0079         std::vector<std::string> getLabels( void ) const;
0080         std::vector<int> getGIDs( void ) const;
0081         void print( bool outline = true, int valuesPerLine = 10 ) const;
0082 
0083     private:
0084         void initialize( char const *fileName );
0085         void initialize2( cbdfls_file const *bdfls );
0086 };
0087 #endif
0088 
0089 /**
0090     This class stores the flux for one Legendre order (see class GIDI_settings_flux).
0091 */
0092 class GIDI_settings_flux_order {
0093 
0094     private:
0095         int mOrder;                 /**< The Legendre order of the flux. */
0096         std::vector<double> mEnergies;   /**< List of flux energies. */
0097         std::vector<double> mFluxes;     /**< List of flux values - one for each element of mEnergies. */
0098 
0099     public:
0100         GIDI_settings_flux_order( int order     /**< The Legendre order for this flux data. */ );
0101         GIDI_settings_flux_order( int           order       /**< The Legendre order for this flux data. */,
0102                                   int           length      /**< The number or values in energies and fluxes. */,
0103                                   double const  *energies   /**< List of energies where flux is given. */,
0104                                   double const  *fluxes     /**< List of flux value for each energies value. */ );
0105         GIDI_settings_flux_order( int                   order       /**< The Legendre order for this flux data. */,
0106                                   std::vector<double> const  &energies   /**< List of energies where flux is given. */,
0107                                   std::vector<double> const  &fluxes     /**< List of flux value for each energies value. */ );
0108         GIDI_settings_flux_order( GIDI_settings_flux_order const &fluxOrder /**< Legendre flux order to copy. */ );
0109         GIDI_settings_flux_order& operator=( const GIDI_settings_flux_order &fluxOrder );
0110         ~GIDI_settings_flux_order( );
0111 
0112         inline int getOrder( void ) const { return( mOrder ); }
0113         inline int size( void ) const { return( (int) mEnergies.size( ) ); }
0114         inline double const *getEnergies( void ) const { return( &(mEnergies[0]) ); }
0115         inline double const *getFluxes( void ) const { return( &(mFluxes[0]) ); }
0116         void print( int valuesPerLine = 10 ) const;
0117 
0118     private:
0119         void initialize( int order, int length, double const *energies, double const *fluxes );
0120 };
0121 
0122 class GIDI_settings_flux {
0123 
0124     private:
0125         std::string mLabel;                                  /**< Label for the flux. */
0126         double mTemperature;
0127         std::vector<GIDI_settings_flux_order> mFluxOrders;   /**< List of fluxes for each Legendre order, l, sorted by Legendre order starting with l = 0. */
0128 
0129     public:
0130         GIDI_settings_flux( std::string const &label, double temperature_MeV );
0131         GIDI_settings_flux( char const *label, double temperature_MeV );
0132         GIDI_settings_flux( GIDI_settings_flux const &flux );
0133         GIDI_settings_flux& operator=( const GIDI_settings_flux &flux );
0134         ~GIDI_settings_flux( );
0135 
0136         GIDI_settings_flux_order const *operator[]( int order ) const;
0137         inline int getMaxOrder( void ) const { return( (int) mFluxOrders.size( ) - 1 ); }
0138         inline int size( void ) const { return( (int) mFluxOrders.size( ) ); }
0139 
0140         inline std::string getLabel( ) const { return( mLabel ); }
0141         inline bool isLabel( std::string const &label ) const { return( label == mLabel ); }
0142         inline bool isLabel( char const *label ) const { return( label == mLabel ); }
0143         inline double getTemperature( ) const { return( mTemperature ); }
0144         void addFluxOrder( GIDI_settings_flux_order const &fluxOrder );
0145         void print( bool outline = true, int valuesPerLine = 10 ) const;
0146 };
0147 
0148 #if GIDI_USE_BDFLS
0149 class GIDI_settings_fluxes_from_bdfls {
0150 
0151     private:
0152         std::vector<GIDI_settings_flux> mFluxes;
0153 
0154     public:
0155         GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV );
0156         GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV );
0157         GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV );
0158         ~GIDI_settings_fluxes_from_bdfls( );
0159 
0160         GIDI_settings_flux getViaFID( int fid );
0161         std::vector<std::string> getLabels( void );
0162         std::vector<int> getFIDs( void );
0163         void print( bool outline = true, int valuesPerLine = 10 );
0164 
0165     private:
0166         void initialize( char const *fileName, double temperature_MeV );
0167         void initialize2( cbdfls_file const *bdfls, double temperature_MeV );
0168 };
0169 #endif
0170 
0171 class GIDI_settings_processedFlux {
0172 
0173     private:
0174         GIDI_settings_flux mFlux;
0175         std::vector<GIDI::ptwXYPoints *> mFluxXY;          /* Same as mFlux but stored as ptwXYPoints for each l-order. */
0176         std::vector<GIDI::ptwXPoints *> mGroupedFlux;      /* mFlux grouped using mGroupX, and stored as ptwXPoints for each l-order. */
0177 
0178     public:
0179         GIDI_settings_processedFlux( GIDI_settings_flux const &flux, GIDI::ptwXPoints *groupX );
0180         GIDI_settings_processedFlux( GIDI_settings_processedFlux const &flux );
0181         GIDI_settings_processedFlux& operator=( const GIDI_settings_processedFlux &flux );
0182         ~GIDI_settings_processedFlux( );
0183 
0184         inline double getTemperature( ) const { return( mFlux.getTemperature( ) ); }
0185         GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXPoints *groupX, GIDI::ptwXYPoints *ptwXY1, int order ) const;
0186 };
0187 
0188 class GIDI_settings_particle {
0189 
0190     private:
0191         int mPoPId;
0192         bool mTransporting;
0193         int mEnergyMode;
0194         GIDI_settings_group mGroup;
0195         GIDI::ptwXPoints *mGroupX;                    /* Same as mGroup but stored as ptwXPoints. */
0196         std::vector<GIDI_settings_processedFlux> mProcessedFluxes;
0197 
0198     public:
0199         GIDI_settings_particle( int PoPId, bool transporting, int energyMode );
0200         GIDI_settings_particle( GIDI_settings_particle const &particle );
0201         int initialize( int PoPId, bool transporting, int energyMode );
0202         ~GIDI_settings_particle( );
0203 
0204         int addFlux( GIDI::statusMessageReporting *smr, GIDI_settings_flux const &flux );
0205         GIDI_settings_processedFlux const *nearestFluxToTemperature( double temperature ) const;
0206         inline int getGroupIndexFromEnergy( double e_in, bool encloseOutOfRange ) const { return( mGroup.getGroupIndexFromEnergy( e_in, encloseOutOfRange ) ); };
0207         inline int getNumberOfGroups( void ) const { return( mGroup.getNumberOfGroups( ) ); };
0208         inline int getPoPId( void ) const { return( mPoPId ); }
0209         inline int getEnergyMode( void ) const { return( mEnergyMode ); }
0210         inline bool getTransporting( void ) const { return( mTransporting ); }
0211         inline GIDI_settings_group getGroup( void ) const { return( mGroup ); }
0212         GIDI_settings_flux const *getFlux( double temperature ) const;
0213         GIDI::ptwXPoints *groupFunction( GIDI::statusMessageReporting *smr, GIDI::ptwXYPoints *ptwXY1, double temperature, int order ) const;
0214         void setGroup( GIDI_settings_group const &group );
0215 
0216         inline bool isEnergyMode_continuous( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_continuousEnergy ); }
0217         inline bool isEnergyMode_grouped( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_grouped ); }
0218         inline bool isEnergyMode_fixedGrid( void ) const { return( this->mEnergyMode & GIDI_settings_projectileEnergyMode_fixedGrid ); }
0219 
0220     private:
0221         GIDI_settings_flux const *getProcessedFlux( double temperature ) const;
0222 };
0223 
0224 class GIDI_settings {
0225 
0226     private:
0227         std::map<int, GIDI_settings_particle> mParticles;
0228 
0229     public:
0230         GIDI_settings( );
0231         ~GIDI_settings( );
0232 
0233         int addParticle( GIDI_settings_particle const &particle );
0234         GIDI_settings_particle const *getParticle( int PoPId ) const;
0235         int eraseParticle( int PoPId );
0236         void releaseMemory( ) { mParticles.clear( ); }
0237 };
0238 
0239 #if defined( __INTEL_COMPILER )
0240 #pragma warning( pop )
0241 #endif
0242 
0243 #endif      // End of GIDI_settings_hpp_included