Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
GIDI_settings_flux.cc
이 파일의 문서화 페이지로 가기
1 /*
2 # <<BEGIN-copyright>>
3 # <<END-copyright>>
4 */
5 
6 #include <iostream>
7 #include <stdlib.h>
8 
9 #include "GIDI_settings.hh"
10 
11 /* ---- GIDI_settings_flux_order ---- */
12 /*
13 =========================================================
14 */
16 
17  if( order < 0 ) throw 1;
18  mOrder = order;
19 }
20 /*
21 =========================================================
22 */
23 GIDI_settings_flux_order::GIDI_settings_flux_order( int order, int length, double const *energies, double const *fluxes ) {
24 
25  initialize( order, length, energies, fluxes );
26 }
27 /*
28 =========================================================
29 */
30 GIDI_settings_flux_order::GIDI_settings_flux_order( int order, std::vector<double> const &energies, std::vector<double> const &fluxes ) {
31 
32  int length = (int) energies.size( );
33 
34  if( length != (int) fluxes.size( ) ) throw 1;
35  initialize( order, length, &(energies[0]), &(fluxes[0]) );
36 }
37 /*
38 =========================================================
39 */
41 
42  initialize( fluxOrder.mOrder, fluxOrder.size( ), &(fluxOrder.mEnergies[0]), &(fluxOrder.mFluxes[0]) );
43 }
44 /*
45 =========================================================
46 */
47 void GIDI_settings_flux_order::initialize( int order, int length, double const *energies, double const *fluxes ) {
48 
49  if( order < 0 ) throw 1;
50  mOrder = order;
51  mEnergies.resize( length, 0 );
52  mFluxes.resize( length, 0 );
53  for( int i1 = 0; i1 < length; ++i1 ) mEnergies[i1] = energies[i1];
54  for( int i1 = 0; i1 < length; ++i1 ) mFluxes[i1] = fluxes[i1];
55 }
56 /*
57 =========================================================
58 */
60 
61 }
62 /*
63 =========================================================
64 */
65 void GIDI_settings_flux_order::print( int valuesPerLine ) const {
66 
67  int nE = (int) mEnergies.size( );
68  bool printIndent = true;
69  char buffer[2 * 128];
70 
71  std::cout << " ORDER: " << mOrder << std::endl;
72  for( int iE = 0; iE < nE; ++iE ) {
73  if( printIndent ) std::cout << " ";
74  printIndent = false;
75  sprintf( buffer, " %15.8e %15.8e", mEnergies[iE], mFluxes[iE] );
76  std::cout << buffer;
77  if( ( ( iE + 1 ) % valuesPerLine ) == 0 ) {
78  std::cout << std::endl;
79  printIndent = true;
80  }
81  }
82  if( nE % valuesPerLine ) std::cout << std::endl;
83 }
84 
85 /* ---- GIDI_settings_flux ---- */
86 /*
87 =========================================================
88 */
89 GIDI_settings_flux::GIDI_settings_flux( std::string const &label, double temperature ) {
90 
91  mLabel = label;
92  mTemperature = temperature;
93 }
94 /*
95 =========================================================
96 */
97 GIDI_settings_flux::GIDI_settings_flux( char const *label, double temperature ) {
98 
99  mLabel = label;
100  mTemperature = temperature;
101 }
102 /*
103 =========================================================
104 */
106 
107  mLabel = flux.getLabel( );
108  mTemperature = flux.mTemperature;
109  for( std::vector<GIDI_settings_flux_order>::const_iterator iter = flux.mFluxOrders.begin( ); iter < flux.mFluxOrders.end( ); ++iter ) addFluxOrder( *iter );
110 }
111 /*
112 =========================================================
113 */
115 
116 }
117 /*
118 =========================================================
119 */
121 
122  return( &(mFluxOrders[index]) );
123 }
124 /*
125 =========================================================
126 */
128 /*
129 * Orders can only be added in sequence (e.g., 0 first, then 1, ...).
130 */
131  int order = fluxOrder.getOrder( );
132 
133  if( order > (int) mFluxOrders.size( ) ) throw 1;
134  mFluxOrders.push_back( fluxOrder );
135 }
136 /*
137 =========================================================
138 */
139 void GIDI_settings_flux::print( bool outline, int valuesPerLine ) const {
140 
141  std::cout << "FLUX: label = '" << mLabel << "': maximum order = " << ( size( ) + 1 ) << std::endl;
142  if( outline ) return;
143  for( std::vector<GIDI_settings_flux_order>::const_iterator iter = mFluxOrders.begin( ); iter < mFluxOrders.end( ); ++iter ) iter->print( valuesPerLine );
144 }
145 
146 #if 0
147 /* ---- GIDI_settings_fluxes_from_bdfls ---- */
148 /*
149 =========================================================
150 */
151 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV = 0 ) {
152 
153  initialize( fileName.c_str( ), temperature_MeV );
154 }
155 /*
156 =========================================================
157 */
158 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV = 0 ) {
159 
160  initialize( fileName, temperature_MeV );
161 }
162 /*
163 =========================================================
164 */
165 GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV = 0 ) {
166 
167  initialize2( bdfls, temperature_MeV );
168 }
169 /*
170 =========================================================
171 */
172 void GIDI_settings_fluxes_from_bdfls::initialize( char const *fileName, double temperature_MeV ) {
173 
174  cbdfls_file *bdfls;
175  cbdflsErrors Error;
176 
177  if( ( bdfls = cbdflsOpen( fileName, &Error ) ) == NULL ) throw Error;
178  initialize2( bdfls, temperature_MeV );
179  cbdflsRelease( bdfls );
180 }
181 /*
182 =========================================================
183 */
184 void GIDI_settings_fluxes_from_bdfls::initialize2( cbdfls_file const *bdfls, double temperature_MeV ) {
185 
186  int nf, length, *fids, order;
187  double *energies, *fluxes;
188  char label[100];
189 
190  nf = cbdflsFIDs( (cbdfls_file *) bdfls, &fids );
191  for( int if1 = 0; if1 < nf; ++if1 ) {
192  sprintf( label, "LLNL_fid_%.3d", fids[if1] );
193  GIDI_settings_flux flux = GIDI_settings_flux( label, temperature_MeV );
194  order = cbdflsGetFluxOrder( (cbdfls_file *) bdfls, fids[if1] );
195  for( int io = 0; io <= order; ++io ) {
196  length = cbdflsGetFlux( (cbdfls_file *) bdfls, fids[if1], io, &energies, &fluxes );
197  GIDI_settings_flux_order flux_order = GIDI_settings_flux_order( io, length, energies, fluxes );
198  flux.addFluxOrder( flux_order );
199  }
200  mFluxes.push_back( flux );
201  }
202  return;
203 }
204 /*
205 =========================================================
206 */
207 GIDI_settings_fluxes_from_bdfls::~GIDI_settings_fluxes_from_bdfls( ) {
208 
209 }
210 /*
211 =========================================================
212 */
213 GIDI_settings_flux GIDI_settings_fluxes_from_bdfls::getViaFID( int fid ) {
214 
215  char label[100];
216 
217  sprintf( label, "LLNL_fid_%.3d", fid );
218  for( int if1 = 0; if1 < (int) mFluxes.size( ); ++if1 ) {
219  if( mFluxes[if1].isLabel( label ) ) return( mFluxes[if1] );
220  }
221  throw 1;
222 }
223 /*
224 =========================================================
225 */
226 std::vector<std::string> GIDI_settings_fluxes_from_bdfls::getLabels( void ) {
227 
228  int size = (int) mFluxes.size( );
229  std::vector<std::string> labels( size );
230 
231  for( int if1 = 0; if1 < size; ++if1 ) labels[if1] = mFluxes[if1].getLabel( );
232  return( labels );
233 }
234 /*
235 =========================================================
236 */
237 std::vector<int> GIDI_settings_fluxes_from_bdfls::getFIDs( void ) {
238 
239  int size = (int) mFluxes.size( );
240  std::vector<int> fids( size );
241  char *e;
242 
243  for( int if1 = 0; if1 < size; ++if1 ) {
244  fids[if1] = (int) strtol( &(mFluxes[if1].getLabel( ).c_str( )[9]), &e, 10 );
245  }
246  return( fids );
247 }
248 /*
249 =========================================================
250 */
251 void GIDI_settings_fluxes_from_bdfls::print( bool outline, int valuesPerLine ) {
252 
253  int nfs = (int) mFluxes.size( );
254 
255  std::cout << "BDFLS FLUXes: number of fluxes = " << nfs << std::endl;
256  for( int if1 = 0; if1 < nfs ; ++if1 ) mFluxes[if1].print( outline, valuesPerLine );
257 }
258 #endif
void print(G4double elem)
void print(int valuesPerLine=10) const
#define buffer
Definition: xmlparse.cc:628
std::vector< GIDI_settings_flux_order > mFluxOrders
static const G4int nE
void print(bool outline=true, int valuesPerLine=10) const
int getOrder(void) const
void initialize(int order, int length, double const *energies, double const *fluxes)
std::vector< double > mFluxes
void addFluxOrder(GIDI_settings_flux_order const &fluxOrder)
void initialize(Config const *const theConfig)
Initialize the clustering model based on the Config object.
typedef int(XMLCALL *XML_NotStandaloneHandler)(void *userData)
GIDI_settings_flux(std::string const &label, double temperature_MeV)
int size(void) const
std::vector< double > mEnergies
GIDI_settings_flux_order const * operator[](int order) const
std::string getLabel() const