Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
GIDI_settings_flux.cc
Go to the documentation of this file.
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*/
23GIDI_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*/
30GIDI_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*/
47void 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 if ( this != &fluxOrder ) {
61 initialize( fluxOrder.mOrder, fluxOrder.size(), &(fluxOrder.mEnergies[0]), &(fluxOrder.mFluxes[0]) );
62 }
63 return *this;
64}
65/*
66=========================================================
67*/
69
70}
71/*
72=========================================================
73*/
74void GIDI_settings_flux_order::print( int valuesPerLine ) const {
75
76 int nE = (int) mEnergies.size( );
77 bool printIndent = true;
78 char buffer[2 * 128];
79
80 std::cout << " ORDER: " << mOrder << std::endl;
81 for( int iE = 0; iE < nE; ++iE ) {
82 if( printIndent ) std::cout << " ";
83 printIndent = false;
84 snprintf( buffer, sizeof buffer, " %15.8e %15.8e", mEnergies[iE], mFluxes[iE] );
85 std::cout << buffer;
86 if( ( ( iE + 1 ) % valuesPerLine ) == 0 ) {
87 std::cout << std::endl;
88 printIndent = true;
89 }
90 }
91 if( nE % valuesPerLine ) std::cout << std::endl;
92}
93
94/* ---- GIDI_settings_flux ---- */
95/*
96=========================================================
97*/
98GIDI_settings_flux::GIDI_settings_flux( std::string const &label, double temperature ) {
99
100 mLabel = label;
101 mTemperature = temperature;
102}
103/*
104=========================================================
105*/
106GIDI_settings_flux::GIDI_settings_flux( char const *label, double temperature ) {
107
108 mLabel = label;
109 mTemperature = temperature;
110}
111/*
112=========================================================
113*/
115
116 mLabel = flux.getLabel( );
117 mTemperature = flux.mTemperature;
118 for( std::vector<GIDI_settings_flux_order>::const_iterator iter = flux.mFluxOrders.begin( ); iter < flux.mFluxOrders.end( ); ++iter ) addFluxOrder( *iter );
119}
120/*
121=========================================================
122*/
124 if ( this != &flux ) {
125 mLabel = flux.getLabel();
126 mTemperature = flux.mTemperature;
127 for( std::vector<GIDI_settings_flux_order>::const_iterator iter = flux.mFluxOrders.begin( ); iter < flux.mFluxOrders.end( ); ++iter ) addFluxOrder( *iter );
128 }
129 return *this;
130}
131/*
132=========================================================
133*/
135
136}
137/*
138=========================================================
139*/
141
142 return( &(mFluxOrders[index]) );
143}
144/*
145=========================================================
146*/
148/*
149* Orders can only be added in sequence (e.g., 0 first, then 1, ...).
150*/
151 int order = fluxOrder.getOrder( );
152
153 if( order > (int) mFluxOrders.size( ) ) throw 1;
154 mFluxOrders.push_back( fluxOrder );
155}
156/*
157=========================================================
158*/
159void GIDI_settings_flux::print( bool outline, int valuesPerLine ) const {
160
161 std::cout << "FLUX: label = '" << mLabel << "': maximum order = " << ( size( ) + 1 ) << std::endl;
162 if( outline ) return;
163 for( std::vector<GIDI_settings_flux_order>::const_iterator iter = mFluxOrders.begin( ); iter < mFluxOrders.end( ); ++iter ) iter->print( valuesPerLine );
164}
165
166#if 0
167/* ---- GIDI_settings_fluxes_from_bdfls ---- */
168/*
169=========================================================
170*/
171GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( std::string const &fileName, double temperature_MeV = 0 ) {
172
173 initialize( fileName.c_str( ), temperature_MeV );
174}
175/*
176=========================================================
177*/
178GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( char const *fileName, double temperature_MeV = 0 ) {
179
180 initialize( fileName, temperature_MeV );
181}
182/*
183=========================================================
184*/
185GIDI_settings_fluxes_from_bdfls::GIDI_settings_fluxes_from_bdfls( cbdfls_file const *bdfls, double temperature_MeV = 0 ) {
186
187 initialize2( bdfls, temperature_MeV );
188}
189/*
190=========================================================
191*/
192void GIDI_settings_fluxes_from_bdfls::initialize( char const *fileName, double temperature_MeV ) {
193
194 cbdfls_file *bdfls;
195 cbdflsErrors Error;
196
197 if( ( bdfls = cbdflsOpen( fileName, &Error ) ) == NULL ) throw Error;
198 initialize2( bdfls, temperature_MeV );
199 cbdflsRelease( bdfls );
200}
201/*
202=========================================================
203*/
204void GIDI_settings_fluxes_from_bdfls::initialize2( cbdfls_file const *bdfls, double temperature_MeV ) {
205
206 int nf, length, *fids, order;
207 double *energies, *fluxes;
208 char label[100];
209
210 nf = cbdflsFIDs( (cbdfls_file *) bdfls, &fids );
211 for( int if1 = 0; if1 < nf; ++if1 ) {
212 snprintf( label, sizeof label, "LLNL_fid_%.3d", fids[if1] );
213 GIDI_settings_flux flux = GIDI_settings_flux( label, temperature_MeV );
214 order = cbdflsGetFluxOrder( (cbdfls_file *) bdfls, fids[if1] );
215 for( int io = 0; io <= order; ++io ) {
216 length = cbdflsGetFlux( (cbdfls_file *) bdfls, fids[if1], io, &energies, &fluxes );
217 GIDI_settings_flux_order flux_order = GIDI_settings_flux_order( io, length, energies, fluxes );
218 flux.addFluxOrder( flux_order );
219 }
220 mFluxes.push_back( flux );
221 }
222 return;
223}
224/*
225=========================================================
226*/
227GIDI_settings_fluxes_from_bdfls::~GIDI_settings_fluxes_from_bdfls( ) {
228
229}
230/*
231=========================================================
232*/
233GIDI_settings_flux GIDI_settings_fluxes_from_bdfls::getViaFID( int fid ) {
234
235 char label[100];
236
237 snprintf( label, sizeof label, "LLNL_fid_%.3d", fid );
238 for( int if1 = 0; if1 < (int) mFluxes.size( ); ++if1 ) {
239 if( mFluxes[if1].isLabel( label ) ) return( mFluxes[if1] );
240 }
241 throw 1;
242}
243/*
244=========================================================
245*/
246std::vector<std::string> GIDI_settings_fluxes_from_bdfls::getLabels( void ) {
247
248 int size = (int) mFluxes.size( );
249 std::vector<std::string> labels( size );
250
251 for( int if1 = 0; if1 < size; ++if1 ) labels[if1] = mFluxes[if1].getLabel( );
252 return( labels );
253}
254/*
255=========================================================
256*/
257std::vector<int> GIDI_settings_fluxes_from_bdfls::getFIDs( void ) {
258
259 int size = (int) mFluxes.size( );
260 std::vector<int> fids( size );
261 char *e;
262
263 for( int if1 = 0; if1 < size; ++if1 ) {
264 fids[if1] = (int) strtol( &(mFluxes[if1].getLabel( ).c_str( )[9]), &e, 10 );
265 }
266 return( fids );
267}
268/*
269=========================================================
270*/
271void GIDI_settings_fluxes_from_bdfls::print( bool outline, int valuesPerLine ) {
272
273 int nfs = (int) mFluxes.size( );
274
275 std::cout << "BDFLS FLUXes: number of fluxes = " << nfs << std::endl;
276 for( int if1 = 0; if1 < nfs ; ++if1 ) mFluxes[if1].print( outline, valuesPerLine );
277}
278#endif
void print(G4double elem)
GIDI_settings_flux_order & operator=(const GIDI_settings_flux_order &fluxOrder)
void print(int valuesPerLine=10) const
int getOrder(void) const
GIDI_settings_flux_order const * operator[](int order) const
void print(bool outline=true, int valuesPerLine=10) const
int size(void) const
GIDI_settings_flux(std::string const &label, double temperature_MeV)
void addFluxOrder(GIDI_settings_flux_order const &fluxOrder)
std::string getLabel() const
GIDI_settings_flux & operator=(const GIDI_settings_flux &flux)
void initialize(Config const *const theConfig)
Initialize the clustering model based on the Config object.