Skip to content

Commit c84fbf1

Browse files
committed
show global percentage counter for monte carlo simulations
1 parent 2ceb298 commit c84fbf1

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/RadiativeTransfer.cpp

+7-14
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,8 @@ bool CRadiativeTransfer::calcMonteCarloRadiationField(uint command,
435435
// Init variables
436436
ullong nr_of_photons = 0;
437437
uint nr_used_wavelengths = 1;
438+
ullong per_counter = 0;
439+
float last_percentage = 0;
438440
ullong kill_counter = 0;
439441
ullong no_interaction_counter = 0;
440442
uint mrw_counter = 0;
@@ -443,10 +445,6 @@ bool CRadiativeTransfer::calcMonteCarloRadiationField(uint command,
443445
// A loop for each source
444446
for(uint s = 0; s < max_source; s++)
445447
{
446-
// Init variables
447-
ullong per_counter = 0;
448-
float last_percentage = 0;
449-
450448
// Init source from sources list
451449
CSourceBasic * tm_source = sources_mc[s];
452450

@@ -497,7 +495,6 @@ bool CRadiativeTransfer::calcMonteCarloRadiationField(uint command,
497495
#endif
498496

499497
// Init progress visualization
500-
per_counter = 0;
501498
cout << CLR_LINE;
502499
switch(command)
503500
{
@@ -545,7 +542,7 @@ bool CRadiativeTransfer::calcMonteCarloRadiationField(uint command,
545542
per_counter++;
546543

547544
// Calculate percentage of total progress per source
548-
float percentage = 100 * float(per_counter) / float(nr_of_photons * nr_used_wavelengths);
545+
float percentage = 100 * float(per_counter) / float(nr_of_photons * nr_used_wavelengths * max_source);
549546

550547
// Show only new percentage number if it changed
551548
if((percentage - last_percentage) > PERCENTAGE_STEP)
@@ -1322,9 +1319,9 @@ void CRadiativeTransfer::rayThroughCellForLvlPop(photon_package * pp,
13221319
bool CRadiativeTransfer::calcPolMapsViaMC()
13231320
{
13241321
// Init variables
1325-
ullong nr_of_photons;
1326-
ullong per_counter, nr_of_wavelength;
1327-
float last_percentage;
1322+
ullong nr_of_photons, nr_of_wavelength;
1323+
ullong per_counter = 0;
1324+
float last_percentage = 0;
13281325
uint mrw_counter = 0;
13291326
ullong kill_counter = 0;
13301327
ullong no_interaction_counter = 0;
@@ -1388,10 +1385,6 @@ bool CRadiativeTransfer::calcPolMapsViaMC()
13881385
cout << "-> MC pol. map(s) (source ID: " << s + 1 << ", wavelength: " << dust->getWavelength(wID)
13891386
<< " [m], photons: " << float(nr_of_photons) << ") 0 [%] \r" << flush;
13901387

1391-
// Init counter and percentage to show progress
1392-
per_counter = 0;
1393-
last_percentage = 0;
1394-
13951388
CRandomGenerator rand_gen = CRandomGenerator();
13961389
// just an arbitrary, random number for the RNG seed
13971390
// this is NOT the seed for KISS
@@ -1417,7 +1410,7 @@ bool CRadiativeTransfer::calcPolMapsViaMC()
14171410
per_counter++;
14181411

14191412
// Calculate percentage of total progress per source
1420-
float percentage = 100.0 * float(per_counter) / float(nr_of_photons);
1413+
float percentage = 100.0 * float(per_counter) / float(nr_of_photons * nr_of_wavelength * max_source);
14211414

14221415
// Show only new percentage number if it changed
14231416
if((percentage - last_percentage) >= PERCENTAGE_STEP)

0 commit comments

Comments
 (0)