Warning, file /include/Geant4/MCGIDI_sampling.hpp was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef MCGIDI_sampling_hpp_included
0011 #define MCGIDI_sampling_hpp_included 1
0012
0013 #include <LUPI_declareMacro.hpp>
0014 #include <MCGIDI_vector.hpp>
0015 #include <MCGIDI_string.hpp>
0016
0017 namespace MCGIDI {
0018
0019
0020
0021
0022
0023
0024 class DomainHash {
0025
0026 private:
0027 std::size_t m_bins;
0028 double m_domainMin;
0029 double m_domainMax;
0030 double m_u_domainMin;
0031 double m_u_domainMax;
0032 double m_inverse_du;
0033
0034 public:
0035 LUPI_HOST_DEVICE DomainHash( );
0036 LUPI_HOST_DEVICE DomainHash( std::size_t a_bins, double a_domainMin, double a_domainMax );
0037 LUPI_HOST_DEVICE DomainHash( DomainHash const &a_domainHash );
0038
0039 LUPI_HOST_DEVICE std::size_t bins( ) const { return( m_bins ); }
0040 LUPI_HOST_DEVICE double domainMin( ) const { return( m_domainMin ); }
0041 LUPI_HOST_DEVICE double domainMax( ) const { return( m_domainMax ); }
0042 LUPI_HOST_DEVICE double u_domainMin( ) const { return( m_u_domainMin ); }
0043 LUPI_HOST_DEVICE double u_domainMax( ) const { return( m_u_domainMax ); }
0044 LUPI_HOST_DEVICE double inverse_du( ) const { return( m_inverse_du ); }
0045
0046 LUPI_HOST_DEVICE std::size_t index( double a_domain ) const ;
0047 LUPI_HOST_DEVICE Vector<std::size_t > map( Vector<double> const &a_domainValues ) const ;
0048
0049 LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
0050
0051 LUPI_HOST void print( bool a_printValues ) const ;
0052 };
0053
0054 namespace Sampling {
0055
0056 enum class SampledType { firstTwoBody, secondTwoBody, uncorrelatedBody, unspecified, photon };
0057 class ProductHandler;
0058
0059 LUPI_HOST_DEVICE std::size_t evaluationForHashIndex( std::size_t a_hashIndex, Vector<std::size_t> const &a_hashIndices, double a_energy,
0060 Vector<double> const &a_energies, double *a_energyFraction );
0061
0062 namespace Upscatter {
0063
0064 enum class Model { none, A, B, BSnLimits, DBRC };
0065
0066
0067
0068
0069
0070
0071
0072 class ModelDBRC_data {
0073
0074 public:
0075 double m_neutronMass;
0076 double m_targetMass;
0077 Vector<double> m_energies;
0078 Vector<double> m_crossSections;
0079 Vector<std::size_t> m_hashIndices;
0080 MCGIDI::DomainHash m_domainHash;
0081
0082 public:
0083 LUPI_HOST_DEVICE ModelDBRC_data( );
0084 LUPI_HOST ModelDBRC_data( double a_neutronMass, double a_targetMass, Vector<double> const &a_energies, Vector<double> const &a_crossSections,
0085 DomainHash const &a_domainHash );
0086 LUPI_HOST_DEVICE ~ModelDBRC_data( );
0087
0088 LUPI_HOST_DEVICE double evaluate( double a_energy );
0089 LUPI_HOST_DEVICE double targetThermalSpeed( double a_temperature );
0090 LUPI_HOST_DEVICE double crossSectionMax( double a_energy, double a_targetThermalSpeed );
0091
0092 LUPI_HOST_DEVICE void serialize( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode );
0093 };
0094
0095 LUPI_HOST_DEVICE ModelDBRC_data *serializeModelDBRC_data( LUPI::DataBuffer &a_buffer, LUPI::DataBuffer::Mode a_mode, ModelDBRC_data *a_modelDBRC_data );
0096
0097 }
0098
0099
0100
0101
0102
0103
0104 class ClientRandomNumberGenerator {
0105 private:
0106 double (*m_generator)( void * );
0107 void *m_state;
0108
0109 public:
0110 LUPI_HOST_DEVICE ClientRandomNumberGenerator( double (*a_generator)( void * ), void *a_state );
0111
0112 LUPI_HOST_DEVICE double (*generator( ))( void * ) { return( m_generator ); }
0113 LUPI_HOST_DEVICE void *state( ) { return( m_state ); }
0114 LUPI_HOST_DEVICE double Double( ) { return( m_generator( m_state ) ); }
0115
0116
0117 LUPI_HOST_DEVICE double (*rng( ))( void * ) { return( generator( ) ); }
0118 LUPI_HOST_DEVICE void *rngState( ) { return( state( ) ); }
0119 LUPI_HOST_DEVICE double dRng( ) { return( Double( ) ); }
0120 };
0121
0122
0123
0124
0125
0126
0127 class ClientCodeRNGData : public ClientRandomNumberGenerator {
0128
0129 public:
0130 LUPI_HOST_DEVICE ClientCodeRNGData( double (*a_generator)( void * ), void *a_state );
0131 };
0132
0133
0134
0135
0136
0137
0138
0139 class Input {
0140
0141 friend ProtareSingle;
0142 friend Reaction;
0143 friend MCGIDI::Sampling::ProductHandler;
0144 friend GRIN_capture;
0145 friend GRIN_inelastic;
0146
0147 private:
0148 bool m_wantVelocity = true ;
0149
0150 bool m_dataInTargetFrame = false;
0151 double m_modelTemperature = 0.0;
0152 double m_modelEnergy = 0.0;
0153
0154 SampledType m_sampledType = SampledType::uncorrelatedBody;
0155
0156
0157 double m_temperature = 0.0;
0158 double m_energy = 0.0;
0159
0160 public:
0161
0162 Upscatter::Model m_upscatterModel = Upscatter::Model::none;
0163
0164
0165
0166
0167 double m_projectileBeta = 0.0;
0168 double m_muLab = 0.0;
0169 double m_targetBeta = 0.0;
0170 double m_relativeBeta = 0.0;
0171
0172 Reaction const *m_reaction = nullptr;
0173
0174 double m_projectileMass = 0.0;
0175 double m_targetMass = 0.0;
0176
0177 GIDI::Frame m_frame = GIDI::Frame::lab;
0178 int m_numberOfDBRC_rejections = 0;
0179
0180 double m_mu = 0.0;
0181 double m_phi = 0.0;
0182
0183 double m_energyOut1 = 0.0;
0184 double m_px_vx1 = 0.0;
0185 double m_py_vy1 = 0.0;
0186 double m_pz_vz1 = 0.0;
0187
0188 double m_energyOut2 = 0.0;
0189 double m_px_vx2 = 0.0;
0190 double m_py_vy2 = 0.0;
0191 double m_pz_vz2 = 0.0;
0192
0193 int m_delayedNeutronIndex = -1;
0194 double m_delayedNeutronDecayRate = 0.0;
0195
0196 int m_GRIN_intermediateResidual = -1;
0197
0198 LUPI_HOST_DEVICE Input( bool a_wantVelocity, Upscatter::Model a_upscatterModel );
0199
0200 LUPI_HOST_DEVICE bool wantVelocity( ) const { return( m_wantVelocity ); }
0201 LUPI_HOST_DEVICE double temperature( ) const { return( m_temperature ); }
0202 LUPI_HOST_DEVICE double energy( ) const { return( m_energy ); }
0203 LUPI_HOST_DEVICE void setTemperatureAndEnergy( double a_temperature, double a_energy );
0204
0205 LUPI_HOST_DEVICE bool dataInTargetFrame( ) const { return( m_dataInTargetFrame ); }
0206 LUPI_HOST_DEVICE double modelTemperature( ) const { return( m_modelTemperature ); }
0207 LUPI_HOST_DEVICE double modelEnergy( ) const { return( m_modelEnergy ); }
0208
0209 SampledType sampledType( ) const { return( m_sampledType ); }
0210 LUPI_HOST_DEVICE void setSampledType( SampledType a_sampledType ) { m_sampledType = a_sampledType; }
0211 };
0212
0213
0214
0215
0216
0217
0218 class Product {
0219
0220 public:
0221 SampledType m_sampledType;
0222 bool m_isVelocity;
0223 int m_productIntid;
0224 int m_productIndex;
0225 int m_userProductIndex;
0226 int m_numberOfDBRC_rejections;
0227 double m_productMass;
0228 double m_kineticEnergy;
0229 double m_px_vx;
0230 double m_py_vy;
0231 double m_pz_vz;
0232 int m_delayedNeutronIndex;
0233 double m_delayedNeutronDecayRate;
0234 double m_birthTimeSec;
0235 };
0236
0237
0238
0239
0240
0241
0242 class ProductHandler {
0243
0244 public:
0245 LUPI_HOST_DEVICE ProductHandler( ) {}
0246 LUPI_HOST_DEVICE ~ProductHandler( ) {}
0247
0248 template <typename RNG, typename PUSHBACK>
0249 LUPI_HOST_DEVICE void add( double a_projectileEnergy, int a_productIntid, int a_productIndex, int a_userProductIndex, double a_productMass, Input &a_input,
0250 RNG && a_rng, PUSHBACK && push_back, bool isPhoton );
0251 };
0252
0253
0254
0255
0256
0257
0258 #ifdef __CUDACC__
0259
0260 #define MCGIDI_CUDACC_numberOfProducts 1000
0261
0262 class StdVectorProductHandler : public ProductHandler {
0263
0264 private:
0265 std::size_t m_size;
0266 Product m_products[1024];
0267
0268 public:
0269 LUPI_HOST_DEVICE StdVectorProductHandler( ) : m_size( 0 ) { }
0270 LUPI_HOST_DEVICE ~StdVectorProductHandler( ) { }
0271
0272 LUPI_HOST_DEVICE std::size_t size( ) { return( m_size ); }
0273 LUPI_HOST_DEVICE Product &operator[]( long a_index ) { return( m_products[a_index] ); }
0274 LUPI_HOST_DEVICE void push_back( Product &a_product ) {
0275 if( m_size < MCGIDI_CUDACC_numberOfProducts ) {
0276 m_products[m_size] = a_product;
0277 ++m_size;
0278 }
0279 }
0280 LUPI_HOST_DEVICE void clear( ) { m_size = 0; }
0281 };
0282
0283 #else
0284 class StdVectorProductHandler : public ProductHandler {
0285
0286 private:
0287 std::vector<Product> m_products;
0288
0289 public:
0290 LUPI_HOST_DEVICE StdVectorProductHandler( ) : m_products( ) { }
0291 LUPI_HOST_DEVICE ~StdVectorProductHandler( ) { }
0292
0293 LUPI_HOST_DEVICE std::size_t size( ) { return( m_products.size( ) ); }
0294 LUPI_HOST_DEVICE Product &operator[]( std::size_t a_index ) { return( m_products[a_index] ); }
0295 LUPI_HOST_DEVICE std::vector<Product> &products( ) { return( m_products ); }
0296 LUPI_HOST_DEVICE void push_back( Product &a_product ) { m_products.push_back( a_product ); }
0297 LUPI_HOST_DEVICE void clear( ) { m_products.clear( ); }
0298 };
0299 #endif
0300
0301
0302
0303
0304
0305
0306 class MCGIDIVectorProductHandler : public ProductHandler {
0307
0308 private:
0309 Vector<Product> m_products;
0310
0311 public:
0312 LUPI_HOST_DEVICE MCGIDIVectorProductHandler( std::size_t a_size = 20 ) :
0313 m_products( ) {
0314
0315 m_products.reserve( a_size );
0316 }
0317 LUPI_HOST_DEVICE ~MCGIDIVectorProductHandler( ) {}
0318
0319 LUPI_HOST_DEVICE std::size_t size( ) { return( m_products.size( ) ); }
0320 LUPI_HOST_DEVICE Product const &operator[]( std::size_t a_index ) const { return( m_products[a_index] ); }
0321 LUPI_HOST_DEVICE Vector<Product> const &products( ) const { return( m_products ); }
0322 LUPI_HOST_DEVICE void push_back( Product &a_product ) { m_products.push_back( a_product ); }
0323 LUPI_HOST_DEVICE void clear( ) { m_products.clear( ); }
0324 };
0325
0326 }
0327
0328 }
0329
0330 #endif