Skip to content

Commit

Permalink
Fixed up progress bar and a few output issues; more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin D. Weinberg committed Feb 9, 2024
1 parent dc7e9c5 commit 53ca45b
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions utils/ICs/ZangICs.cc
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ main(int ac, char **av)
#pragma omp parallel
{
nomp = omp_get_num_threads();
if (omp_get_thread_num()==0)
if (omp_get_thread_num()==0) {
progress = std::make_shared<progress::progress_display>(N/nomp);
}
}

// Create an orbit grid
Expand Down Expand Up @@ -149,21 +150,25 @@ main(int ac, char **av)
std::uniform_real_distribution<> uniform(0.0, 1.0);

// Save the position and velocity vectors
//
std::vector<std::array<double, 3>> pos(N), vel(N);

// Maximum number rejection-method iterations
int itmax = 100000;
int tid = 0;

// Track number of iteration overflows
int over = 0;

// Generation loop
// Generation loop with OpenMP
//
#pragma omp parallel for reduction(+:over)
for (int n=0; n<N; n++) {
tid = omp_get_thread_num();
// Thread id
int tid = omp_get_thread_num();

// Loop variables
double E, K, R;
int j;

for (j=0; j<itmax; j++) {

E = Emin + (Emax - Emin)*uniform(gen);
Expand Down Expand Up @@ -202,15 +207,15 @@ main(int ac, char **av)
vel[n][2] = 0.0;

// Print progress bar
if (progress) ++(*progress);
if (tid==0) ++(*progress);
}
std::cout << std::endl << "** Main loop complete" << std::endl;

// Compute the particle mass
//
double mass = (model->get_mass(Rmax) - model->get_mass(Rmin))/N;

std::cout << "** " << over << " particles failed iteration" << std::endl
std::cout << "** " << over << " particles failed acceptance" << std::endl
<< "** Particle mass=" << mass << std::endl;

out << std::setw(8) << N << std::setw(8) << 0 << std::setw(8) << 0
Expand Down

0 comments on commit 53ca45b

Please sign in to comment.