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 10.5 ] [ 10.5.p1 ] [ 10.6 ] [ 10.6.p1 ] [ 10.6.p2 ] [ 10.6.p3 ] [ 10.7 ] [ 10.7.p1 ] [ 10.7.p2 ] [ 10.7.p3 ] [ 10.7.p4 ] [ 11.0 ] [ 11.0.p1 ] [ 11.0.p2 ] [ 11.0.p3, ] [ 11.0.p4 ] [ 11.1 ] [ 11.1.1 ] [ 11.1.2 ] [ 11.1.3 ] [ 11.2 ] [ 11.2.1 ] [ 11.2.2 ] [ 11.3.0 ]

Diff markup

Differences between /processes/hadronic/models/lend/src/GIDI_settings_flux.cc (Version 11.3.0) and /processes/hadronic/models/lend/src/GIDI_settings_flux.cc (Version 10.4.p3)


  1 /*                                                  1 /*
  2 # <<BEGIN-copyright>>                               2 # <<BEGIN-copyright>>
  3 # <<END-copyright>>                                 3 # <<END-copyright>>
  4 */                                                  4 */
  5                                                     5 
  6 #include <iostream>                                 6 #include <iostream>
  7 #include <stdlib.h>                                 7 #include <stdlib.h>
  8                                                     8 
  9 #include "GIDI_settings.hh"                         9 #include "GIDI_settings.hh"
 10                                                    10 
 11 /*  ---- GIDI_settings_flux_order ----  */         11 /*  ---- GIDI_settings_flux_order ----  */
 12 /*                                                 12 /*
 13 ==============================================     13 =========================================================
 14 */                                                 14 */
 15 GIDI_settings_flux_order::GIDI_settings_flux_o     15 GIDI_settings_flux_order::GIDI_settings_flux_order( int order ) {
 16                                                    16 
 17     if( order < 0 ) throw 1;                       17     if( order < 0 ) throw 1;
 18     mOrder = order;                                18     mOrder = order;
 19 }                                                  19 }
 20 /*                                                 20 /*
 21 ==============================================     21 =========================================================
 22 */                                                 22 */
 23 GIDI_settings_flux_order::GIDI_settings_flux_o     23 GIDI_settings_flux_order::GIDI_settings_flux_order( int order, int length, double const *energies, double const *fluxes ) {
 24                                                    24 
 25     initialize( order, length, energies, fluxe     25     initialize( order, length, energies, fluxes );
 26 }                                                  26 }
 27 /*                                                 27 /*
 28 ==============================================     28 =========================================================
 29 */                                                 29 */
 30 GIDI_settings_flux_order::GIDI_settings_flux_o     30 GIDI_settings_flux_order::GIDI_settings_flux_order( int order, std::vector<double> const &energies, std::vector<double> const &fluxes ) {
 31                                                    31 
 32     int length = (int) energies.size( );           32     int length = (int) energies.size( );
 33                                                    33 
 34     if( length != (int) fluxes.size( ) ) throw     34     if( length != (int) fluxes.size( ) ) throw 1;
 35     initialize( order, length, &(energies[0]),     35     initialize( order, length, &(energies[0]), &(fluxes[0]) );
 36 }                                                  36 }
 37 /*                                                 37 /*
 38 ==============================================     38 =========================================================
 39 */                                                 39 */
 40 GIDI_settings_flux_order::GIDI_settings_flux_o     40 GIDI_settings_flux_order::GIDI_settings_flux_order( GIDI_settings_flux_order const &fluxOrder ) {
 41                                                    41 
 42     initialize( fluxOrder.mOrder, fluxOrder.si     42     initialize( fluxOrder.mOrder, fluxOrder.size( ), &(fluxOrder.mEnergies[0]), &(fluxOrder.mFluxes[0]) );
 43 }                                                  43 }
 44 /*                                                 44 /*
 45 ==============================================     45 =========================================================
 46 */                                                 46 */
 47 void GIDI_settings_flux_order::initialize( int     47 void GIDI_settings_flux_order::initialize( int order, int length, double const *energies, double const *fluxes ) {
 48                                                    48 
 49     if( order < 0 ) throw 1;                       49     if( order < 0 ) throw 1;
 50     mOrder = order;                                50     mOrder = order;
 51     mEnergies.resize( length, 0 );                 51     mEnergies.resize( length, 0 );
 52     mFluxes.resize( length, 0 );                   52     mFluxes.resize( length, 0 );
 53     for( int i1 = 0; i1 < length; ++i1 ) mEner     53     for( int i1 = 0; i1 < length; ++i1 ) mEnergies[i1] = energies[i1];
 54     for( int i1 = 0; i1 < length; ++i1 ) mFlux     54     for( int i1 = 0; i1 < length; ++i1 ) mFluxes[i1] = fluxes[i1];
 55 }                                                  55 }
 56 /*                                                 56 /*
 57 ==============================================     57 =========================================================
 58 */                                                 58 */
 59 GIDI_settings_flux_order& GIDI_settings_flux_o << 
 60   if ( this != &fluxOrder ) {                  << 
 61     initialize( fluxOrder.mOrder, fluxOrder.si << 
 62   }                                            << 
 63   return *this;                                << 
 64 }                                              << 
 65 /*                                             << 
 66 ============================================== << 
 67 */                                             << 
 68 GIDI_settings_flux_order::~GIDI_settings_flux_     59 GIDI_settings_flux_order::~GIDI_settings_flux_order( ) {
 69                                                    60 
 70 }                                                  61 }
 71 /*                                                 62 /*
 72 ==============================================     63 =========================================================
 73 */                                                 64 */
 74 void GIDI_settings_flux_order::print( int valu     65 void GIDI_settings_flux_order::print( int valuesPerLine ) const {
 75                                                    66 
 76     int nE = (int) mEnergies.size( );              67     int nE = (int) mEnergies.size( );
 77     bool printIndent = true;                       68     bool printIndent = true;
 78     char buffer[2 * 128];                          69     char buffer[2 * 128];
 79                                                    70 
 80     std::cout << "    ORDER: " << mOrder << st     71     std::cout << "    ORDER: " << mOrder << std::endl;
 81     for( int iE = 0; iE < nE; ++iE ) {             72     for( int iE = 0; iE < nE; ++iE ) {
 82         if( printIndent ) std::cout << "    ";     73         if( printIndent ) std::cout << "    ";
 83         printIndent = false;                       74         printIndent = false;
 84         snprintf( buffer, sizeof buffer, "   % <<  75         sprintf( buffer, "   %15.8e %15.8e", mEnergies[iE], mFluxes[iE] );
 85         std::cout << buffer;                       76         std::cout << buffer;
 86         if( ( ( iE + 1 ) % valuesPerLine ) ==      77         if( ( ( iE + 1 ) % valuesPerLine ) == 0 ) {
 87             std::cout << std::endl;                78             std::cout << std::endl;
 88             printIndent = true;                    79             printIndent = true;
 89         }                                          80         }
 90     }                                              81     }
 91     if( nE % valuesPerLine ) std::cout << std:     82     if( nE % valuesPerLine ) std::cout << std::endl;
 92 }                                                  83 }
 93                                                    84 
 94 /*  ---- GIDI_settings_flux ----  */               85 /*  ---- GIDI_settings_flux ----  */
 95 /*                                                 86 /*
 96 ==============================================     87 =========================================================
 97 */                                                 88 */
 98 GIDI_settings_flux::GIDI_settings_flux( std::s     89 GIDI_settings_flux::GIDI_settings_flux( std::string const &label, double temperature ) {
 99                                                    90 
100     mLabel = label;                                91     mLabel = label;
101     mTemperature = temperature;                    92     mTemperature = temperature;
102 }                                                  93 }
103 /*                                                 94 /*
104 ==============================================     95 =========================================================
105 */                                                 96 */
106 GIDI_settings_flux::GIDI_settings_flux( char c     97 GIDI_settings_flux::GIDI_settings_flux( char const *label, double temperature ) {
107                                                    98 
108     mLabel = label;                                99     mLabel = label;
109     mTemperature = temperature;                   100     mTemperature = temperature;
110 }                                                 101 }
111 /*                                                102 /*
112 ==============================================    103 =========================================================
113 */                                                104 */
114 GIDI_settings_flux::GIDI_settings_flux( GIDI_s    105 GIDI_settings_flux::GIDI_settings_flux( GIDI_settings_flux const &flux ) {
115                                                   106 
116     mLabel = flux.getLabel( );                    107     mLabel = flux.getLabel( );
117     mTemperature = flux.mTemperature;             108     mTemperature = flux.mTemperature;
118     for( std::vector<GIDI_settings_flux_order>    109     for( std::vector<GIDI_settings_flux_order>::const_iterator iter = flux.mFluxOrders.begin( ); iter < flux.mFluxOrders.end( ); ++iter ) addFluxOrder( *iter );
119 }                                                 110 }
120 /*                                                111 /*
121 ==============================================    112 =========================================================
122 */                                                113 */
123 GIDI_settings_flux& GIDI_settings_flux::operat << 
124   if ( this != &flux ) {                       << 
125     mLabel = flux.getLabel();                  << 
126     mTemperature = flux.mTemperature;          << 
127     for( std::vector<GIDI_settings_flux_order> << 
128   }                                            << 
129   return *this;                                << 
130 }                                              << 
131 /*                                             << 
132 ============================================== << 
133 */                                             << 
134 GIDI_settings_flux::~GIDI_settings_flux( ) {      114 GIDI_settings_flux::~GIDI_settings_flux( ) {
135                                                   115 
136 }                                                 116 }
137 /*                                                117 /*
138 ==============================================    118 =========================================================
139 */                                                119 */
140 GIDI_settings_flux_order const *GIDI_settings_    120 GIDI_settings_flux_order const *GIDI_settings_flux::operator[]( int index ) const {
141                                                   121 
142     return( &(mFluxOrders[index]) );              122     return( &(mFluxOrders[index]) );
143 }                                                 123 }
144 /*                                                124 /*
145 ==============================================    125 =========================================================
146 */                                                126 */
147 void GIDI_settings_flux::addFluxOrder( GIDI_se    127 void GIDI_settings_flux::addFluxOrder( GIDI_settings_flux_order const &fluxOrder ) {
148 /*                                                128 /*
149 *   Orders can only be added in sequence (e.g.    129 *   Orders can only be added in sequence (e.g., 0 first, then 1, ...).
150 */                                                130 */
151     int order = fluxOrder.getOrder( );            131     int order = fluxOrder.getOrder( );
152                                                   132 
153     if( order > (int) mFluxOrders.size( ) ) th    133     if( order > (int) mFluxOrders.size( ) ) throw 1;
154     mFluxOrders.push_back( fluxOrder );           134     mFluxOrders.push_back( fluxOrder );
155 }                                                 135 }
156 /*                                                136 /*
157 ==============================================    137 =========================================================
158 */                                                138 */
159 void GIDI_settings_flux::print( bool outline,     139 void GIDI_settings_flux::print( bool outline, int valuesPerLine ) const {
160                                                   140 
161     std::cout << "FLUX: label = '" << mLabel <    141     std::cout << "FLUX: label = '" << mLabel << "': maximum order = " << ( size( ) + 1 ) << std::endl;
162     if( outline ) return;                         142     if( outline ) return;
163     for( std::vector<GIDI_settings_flux_order>    143     for( std::vector<GIDI_settings_flux_order>::const_iterator iter = mFluxOrders.begin( ); iter < mFluxOrders.end( ); ++iter ) iter->print( valuesPerLine );
164 }                                                 144 }
165                                                   145 
166 #if 0                                             146 #if 0
167 /*  ---- GIDI_settings_fluxes_from_bdfls ----     147 /*  ---- GIDI_settings_fluxes_from_bdfls ----  */
168 /*                                                148 /*
169 ==============================================    149 =========================================================
170 */                                                150 */
171 GIDI_settings_fluxes_from_bdfls::GIDI_settings    151 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV = 0 ) {
172                                                   152 
173     initialize( fileName.c_str( ), temperature    153     initialize( fileName.c_str( ), temperature_MeV );
174 }                                                 154 }
175 /*                                                155 /*
176 ==============================================    156 =========================================================
177 */                                                157 */
178 GIDI_settings_fluxes_from_bdfls::GIDI_settings    158 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV = 0 ) {
179                                                   159 
180     initialize( fileName, temperature_MeV );      160     initialize( fileName, temperature_MeV );
181 }                                                 161 }
182 /*                                                162 /*
183 ==============================================    163 =========================================================
184 */                                                164 */
185 GIDI_settings_fluxes_from_bdfls::GIDI_settings    165 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV = 0 ) {
186                                                   166 
187     initialize2( bdfls, temperature_MeV );        167     initialize2( bdfls, temperature_MeV );
188 }                                                 168 }
189 /*                                                169 /*
190 ==============================================    170 =========================================================
191 */                                                171 */
192 void GIDI_settings_fluxes_from_bdfls::initiali    172 void GIDI_settings_fluxes_from_bdfls::initialize( char const *fileName, double temperature_MeV ) {
193                                                   173 
194     cbdfls_file *bdfls;                           174     cbdfls_file *bdfls;
195     cbdflsErrors Error;                           175     cbdflsErrors Error;
196                                                   176 
197     if( ( bdfls = cbdflsOpen( fileName, &Error    177     if( ( bdfls = cbdflsOpen( fileName, &Error ) ) == NULL ) throw Error;
198     initialize2( bdfls, temperature_MeV );        178     initialize2( bdfls, temperature_MeV );
199     cbdflsRelease( bdfls );                       179     cbdflsRelease( bdfls );
200 }                                                 180 }
201 /*                                                181 /*
202 ==============================================    182 =========================================================
203 */                                                183 */
204 void GIDI_settings_fluxes_from_bdfls::initiali    184 void GIDI_settings_fluxes_from_bdfls::initialize2( cbdfls_file const *bdfls, double temperature_MeV ) {
205                                                   185 
206     int nf, length, *fids, order;                 186     int nf, length, *fids, order;
207     double *energies, *fluxes;                    187     double *energies, *fluxes;
208     char label[100];                              188     char label[100];
209                                                   189 
210     nf = cbdflsFIDs( (cbdfls_file *) bdfls, &f    190     nf = cbdflsFIDs( (cbdfls_file *) bdfls, &fids );
211     for( int if1 = 0; if1 < nf; ++if1 ) {         191     for( int if1 = 0; if1 < nf; ++if1 ) {
212         snprintf( label, sizeof label, "LLNL_f << 192         sprintf( label, "LLNL_fid_%.3d", fids[if1] );
213         GIDI_settings_flux flux = GIDI_setting    193         GIDI_settings_flux flux = GIDI_settings_flux( label, temperature_MeV );
214         order = cbdflsGetFluxOrder( (cbdfls_fi    194         order = cbdflsGetFluxOrder( (cbdfls_file *) bdfls, fids[if1] );
215         for( int io = 0; io <= order; ++io ) {    195         for( int io = 0; io <= order; ++io ) {
216             length = cbdflsGetFlux( (cbdfls_fi    196             length = cbdflsGetFlux( (cbdfls_file *) bdfls, fids[if1], io, &energies, &fluxes );
217             GIDI_settings_flux_order flux_orde    197             GIDI_settings_flux_order flux_order = GIDI_settings_flux_order( io, length, energies, fluxes );
218             flux.addFluxOrder( flux_order );      198             flux.addFluxOrder( flux_order );
219         }                                         199         }
220         mFluxes.push_back( flux );                200         mFluxes.push_back( flux );
221     }                                             201     }
222     return;                                       202     return;
223 }                                                 203 }
224 /*                                                204 /*
225 ==============================================    205 =========================================================
226 */                                                206 */
227 GIDI_settings_fluxes_from_bdfls::~GIDI_setting    207 GIDI_settings_fluxes_from_bdfls::~GIDI_settings_fluxes_from_bdfls( ) {
228                                                   208 
229 }                                                 209 }
230 /*                                                210 /*
231 ==============================================    211 =========================================================
232 */                                                212 */
233 GIDI_settings_flux GIDI_settings_fluxes_from_b    213 GIDI_settings_flux GIDI_settings_fluxes_from_bdfls::getViaFID( int fid ) {
234                                                   214 
235     char label[100];                              215     char label[100];
236                                                   216 
237     snprintf( label, sizeof label, "LLNL_fid_% << 217     sprintf( label, "LLNL_fid_%.3d", fid );
238     for( int if1 = 0; if1 < (int) mFluxes.size    218     for( int if1 = 0; if1 < (int) mFluxes.size( ); ++if1 ) {
239         if( mFluxes[if1].isLabel( label ) ) re    219         if( mFluxes[if1].isLabel( label ) ) return( mFluxes[if1] );
240     }                                             220     }
241     throw 1;                                      221     throw 1;
242 }                                                 222 }
243 /*                                                223 /*
244 ==============================================    224 =========================================================
245 */                                                225 */
246 std::vector<std::string> GIDI_settings_fluxes_    226 std::vector<std::string> GIDI_settings_fluxes_from_bdfls::getLabels( void ) {
247                                                   227 
248     int size = (int) mFluxes.size( );             228     int size = (int) mFluxes.size( );
249     std::vector<std::string> labels( size );      229     std::vector<std::string> labels( size );
250                                                   230 
251     for( int if1 = 0; if1 < size; ++if1 ) labe    231     for( int if1 = 0; if1 < size; ++if1 ) labels[if1] = mFluxes[if1].getLabel( );
252     return( labels );                             232     return( labels );
253 }                                                 233 }
254 /*                                                234 /*
255 ==============================================    235 =========================================================
256 */                                                236 */
257 std::vector<int> GIDI_settings_fluxes_from_bdf    237 std::vector<int> GIDI_settings_fluxes_from_bdfls::getFIDs( void ) {
258                                                   238 
259     int size = (int) mFluxes.size( );             239     int size = (int) mFluxes.size( );
260     std::vector<int> fids( size );                240     std::vector<int> fids( size );
261     char *e;                                      241     char *e;
262                                                   242 
263     for( int if1 = 0; if1 < size; ++if1 ) {       243     for( int if1 = 0; if1 < size; ++if1 ) {
264         fids[if1] = (int) strtol( &(mFluxes[if    244         fids[if1] = (int) strtol( &(mFluxes[if1].getLabel( ).c_str( )[9]), &e, 10 );
265     }                                             245     }
266     return( fids );                               246     return( fids );
267 }                                                 247 }
268 /*                                                248 /*
269 ==============================================    249 =========================================================
270 */                                                250 */
271 void GIDI_settings_fluxes_from_bdfls::print( b    251 void GIDI_settings_fluxes_from_bdfls::print( bool outline, int valuesPerLine ) {
272                                                   252 
273     int nfs = (int) mFluxes.size( );              253     int nfs = (int) mFluxes.size( );
274                                                   254 
275     std::cout << "BDFLS FLUXes: number of flux    255     std::cout << "BDFLS FLUXes: number of fluxes = " << nfs << std::endl;
276     for( int if1 = 0; if1 < nfs ; ++if1 ) mFlu    256     for( int if1 = 0; if1 < nfs ; ++if1 ) mFluxes[if1].print( outline, valuesPerLine );
277 }                                                 257 }
278 #endif                                            258 #endif
279                                                   259