mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
Localize variables total_surf_banks and max_bank_size
This commit is contained in:
parent
3be475836b
commit
3ab5568ac7
4 changed files with 16 additions and 17 deletions
|
|
@ -45,8 +45,6 @@ extern const RegularMesh* ufs_mesh;
|
|||
extern std::vector<double> k_generation;
|
||||
extern std::vector<int64_t> work_index;
|
||||
|
||||
extern int64_t total_surf_banks; //!< Total number of surface source banks
|
||||
extern int64_t max_bank_size; //!< Maximum bank size from a process
|
||||
extern std::vector<int64_t> surf_src_index;
|
||||
|
||||
} // namespace simulation
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace openmc {
|
||||
|
||||
void load_state_point();
|
||||
void query_surf_src_size();
|
||||
int* query_surf_src_size();
|
||||
void write_source_point(const char* filename, bool surf_src_bank);
|
||||
void write_source_bank(hid_t group_id, bool surf_src_bank);
|
||||
void read_source_bank(hid_t group_id, std::vector<Particle::Bank>& sites, bool distribute);
|
||||
|
|
|
|||
|
|
@ -271,8 +271,6 @@ const RegularMesh* ufs_mesh {nullptr};
|
|||
std::vector<double> k_generation;
|
||||
std::vector<int64_t> work_index;
|
||||
|
||||
int64_t total_surf_banks {0};
|
||||
int64_t max_bank_size {0};
|
||||
std::vector<int64_t> surf_src_index;
|
||||
|
||||
} // namespace simulation
|
||||
|
|
|
|||
|
|
@ -525,8 +525,11 @@ hid_t h5banktype() {
|
|||
return banktype;
|
||||
}
|
||||
|
||||
void query_surf_src_size()
|
||||
int* query_surf_src_size()
|
||||
{
|
||||
// total_surf_banks, max_bank_size
|
||||
static int qsize[2] = {0, 0};
|
||||
|
||||
int64_t total;
|
||||
if (mpi::master) {
|
||||
simulation::surf_src_index.resize(mpi::n_procs + 1);
|
||||
|
|
@ -551,17 +554,16 @@ void query_surf_src_size()
|
|||
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];
|
||||
qsize[1] = *std::max_element(bank_size.begin(), bank_size.end());
|
||||
qsize[0] = simulation::surf_src_index[mpi::n_procs];
|
||||
}
|
||||
#else
|
||||
total = simulation::surf_src_bank.size();
|
||||
simulation::surf_src_index[mpi::n_procs] = total;
|
||||
qsize[0] = simulation::surf_src_bank.size();
|
||||
simulation::surf_src_index[mpi::n_procs] = simulation::surf_src_bank.size();
|
||||
qsize[1] = simulation::work_per_rank;
|
||||
#endif
|
||||
// Set total number of surface source banks
|
||||
simulation::total_surf_banks = total;
|
||||
|
||||
return qsize;
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -610,7 +612,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
int64_t count_size = simulation::work_per_rank;
|
||||
|
||||
// Set maximum bank size
|
||||
simulation::max_bank_size = simulation::work_per_rank;
|
||||
int64_t max_bank_size = simulation::work_per_rank;
|
||||
|
||||
// Set vectors for source bank and starting bank index of each process
|
||||
std::vector<int64_t> bank_index = simulation::work_index;
|
||||
|
|
@ -618,9 +620,9 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
|
||||
// Reset dataspace sizes and vectors for surface source bank
|
||||
if (surf_src_bank) {
|
||||
query_surf_src_size();
|
||||
int* qsize = query_surf_src_size();
|
||||
|
||||
dims_size = simulation::total_surf_banks;
|
||||
dims_size = qsize[0];
|
||||
count_size = simulation::surf_src_bank.size();
|
||||
|
||||
bank_index.clear();
|
||||
|
|
@ -630,6 +632,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
src_bank.assign(simulation::surf_src_bank.data(),
|
||||
simulation::surf_src_bank.data()
|
||||
+ simulation::surf_src_bank.size());
|
||||
max_bank_size = qsize[1];
|
||||
}
|
||||
|
||||
#ifdef PHDF5
|
||||
|
|
@ -671,7 +674,7 @@ write_source_bank(hid_t group_id, bool surf_src_bank)
|
|||
|
||||
// Set new bank sites to avoid the src_bank being overwritten on MPI_Recv
|
||||
std::vector<Particle::Bank> src_to_save;
|
||||
src_to_save.reserve(simulation::max_bank_size);
|
||||
src_to_save.reserve(max_bank_size);
|
||||
std::copy(src_bank.begin(), src_bank.end(), src_to_save.begin());
|
||||
|
||||
for (int i = 0; i < mpi::n_procs; ++i) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue