Add comments and minor changes

This commit is contained in:
YoungHui Park 2020-07-29 16:29:45 -05:00
parent bdcfff0f0c
commit 09863806df
3 changed files with 47 additions and 37 deletions

View file

@ -570,6 +570,45 @@ void calculate_work()
}
}
void query_surf_src_size()
{
int64_t total;
if (mpi::master) {
simulation::surf_src_index.resize(mpi::n_procs + 1);
simulation::surf_src_index[0] = 0;
}
#ifdef OPENMC_MPI
std::vector<int64_t> bank_size;
bank_size.resize(mpi::n_procs);
// Collect the number of surface source banks from all processes
int64_t size = simulation::surf_src_bank.size();
MPI_Gather(&size, 1, MPI_INT64_T,
bank_size.data(), 1, MPI_INT64_T,
0, mpi::intracomm);
if (mpi::master) {
// Populate the surf_src_index with cumulative sum of the number of
// surface source banks per process
for (int i = 1; i < mpi::n_procs + 1; ++i) {
simulation::surf_src_index[i] = \
simulation::surf_src_index[i - 1] + bank_size[i - 1];
}
// Set maximum bank size
simulation::max_bank_size = *std::max_element(bank_size.begin(),
bank_size.end());
total = simulation::surf_src_index[mpi::n_procs];
}
#else
total = simulation::surf_src_bank.size();
simulation::surf_src_index[mpi::n_procs] = total;
#endif
// Set total number of surface source banks
simulation::total_surf_banks = total;
}
void initialize_data()
{
// Determine minimum/maximum energy for incident neutron/photon data
@ -639,39 +678,6 @@ void initialize_data()
data::energy_min[neutron]) / settings::n_log_bins;
}
void query_surf_src_size()
{
int64_t total;
if (mpi::master) {
simulation::surf_src_index.resize(mpi::n_procs + 1);
simulation::surf_src_index[0] = 0;
}
#ifdef OPENMC_MPI
std::vector<int64_t> bank_size;
bank_size.resize(mpi::n_procs);
int64_t size = simulation::surf_src_bank.size();
MPI_Gather(&size, 1, MPI_INT64_T,
bank_size.data(), 1, MPI_INT64_T,
0, mpi::intracomm);
if (mpi::master) {
for (int i = 1; i < mpi::n_procs + 1; ++i) {
simulation::surf_src_index[i] = simulation::surf_src_index[i - 1] + bank_size[i - 1];
}
simulation::max_bank_size = *std::max_element(bank_size.begin(), bank_size.end());
total = simulation::surf_src_index[mpi::n_procs];
}
#else
total = simulation::surf_src_bank.size();
simulation::surf_src_index[mpi::n_procs] = total;
#endif
simulation::total_surf_banks = total;
}
#ifdef OPENMC_MPI
void broadcast_results() {
// Broadcast tally results so that each process has access to results