mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 14:15:42 -04:00
address PR comments
This commit is contained in:
parent
f0e1110e01
commit
061156e79a
35 changed files with 110 additions and 114 deletions
10
src/bank.cpp
10
src/bank.cpp
|
|
@ -16,15 +16,15 @@ namespace openmc {
|
|||
|
||||
namespace simulation {
|
||||
|
||||
vector<ParticleBank> source_bank;
|
||||
vector<SourceSite> source_bank;
|
||||
|
||||
SharedArray<ParticleBank> surf_source_bank;
|
||||
SharedArray<SourceSite> surf_source_bank;
|
||||
|
||||
// The fission bank is allocated as a SharedArray, rather than a vector, as it will
|
||||
// be shared by all threads in the simulation. It will be allocated to a fixed
|
||||
// maximum capacity in the init_fission_bank() function. Then, Elements will be
|
||||
// added to it by using SharedArray's special thread_safe_append() function.
|
||||
SharedArray<ParticleBank> fission_bank;
|
||||
SharedArray<SourceSite> fission_bank;
|
||||
|
||||
// Each entry in this vector corresponds to the number of progeny produced
|
||||
// this generation for the particle located at that index. This vector is
|
||||
|
|
@ -80,8 +80,8 @@ void sort_fission_bank()
|
|||
// We need a scratch vector to make permutation of the fission bank into
|
||||
// sorted order easy. Under normal usage conditions, the fission bank is
|
||||
// over provisioned, so we can use that as scratch space.
|
||||
ParticleBank* sorted_bank;
|
||||
vector<ParticleBank> sorted_bank_holder;
|
||||
SourceSite* sorted_bank;
|
||||
vector<SourceSite> sorted_bank_holder;
|
||||
|
||||
// If there is not enough space, allocate a temporary vector and point to it
|
||||
if (simulation::fission_bank.size() > simulation::fission_bank.capacity() / 2) {
|
||||
|
|
|
|||
|
|
@ -181,8 +181,8 @@ void read_cross_sections_xml()
|
|||
}
|
||||
}
|
||||
|
||||
void read_ce_cross_sections(const vector<std::vector<double>>& nuc_temps,
|
||||
const vector<std::vector<double>>& thermal_temps)
|
||||
void read_ce_cross_sections(const vector<vector<double>>& nuc_temps,
|
||||
const vector<vector<double>>& thermal_temps)
|
||||
{
|
||||
std::unordered_set<std::string> already_read;
|
||||
|
||||
|
|
|
|||
|
|
@ -137,7 +137,7 @@ void synchronize_bank()
|
|||
// Allocate temporary source bank -- we don't really know how many fission
|
||||
// sites were created, so overallocate by a factor of 3
|
||||
int64_t index_temp = 0;
|
||||
vector<ParticleBank> temp_sites(3 * simulation::work_per_rank);
|
||||
vector<SourceSite> temp_sites(3 * simulation::work_per_rank);
|
||||
|
||||
for (int64_t i = 0; i < simulation::fission_bank.size(); i++ ) {
|
||||
const auto& site = simulation::fission_bank[i];
|
||||
|
|
|
|||
|
|
@ -191,8 +191,8 @@ assign_temperatures()
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void get_temperatures(vector<std::vector<double>>& nuc_temps,
|
||||
vector<std::vector<double>>& thermal_temps)
|
||||
void get_temperatures(
|
||||
vector<vector<double>>& nuc_temps, vector<vector<double>>& thermal_temps)
|
||||
{
|
||||
for (const auto& cell : model::cells) {
|
||||
// Skip non-material cells.
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ void initialize_mpi(MPI_Comm intracomm)
|
|||
mpi::master = (mpi::rank == 0);
|
||||
|
||||
// Create bank datatype
|
||||
ParticleBank b;
|
||||
SourceSite b;
|
||||
MPI_Aint disp[9];
|
||||
MPI_Get_address(&b.r, &disp[0]);
|
||||
MPI_Get_address(&b.u, &disp[1]);
|
||||
|
|
|
|||
|
|
@ -1144,9 +1144,9 @@ double sternheimer_adjustment(const vector<double>& f,
|
|||
return rho;
|
||||
}
|
||||
|
||||
double density_effect(const vector<double>& f,
|
||||
const std::vector<double>& e_b_sq, double e_p_sq, double n_conduction,
|
||||
double rho, double E, double tol, int max_iter)
|
||||
double density_effect(const vector<double>& f, const vector<double>& e_b_sq,
|
||||
double e_p_sq, double n_conduction, double rho, double E, double tol,
|
||||
int max_iter)
|
||||
{
|
||||
// Get the total number of oscillators
|
||||
int n = f.size();
|
||||
|
|
|
|||
|
|
@ -556,7 +556,7 @@ void calc_zn(int n, double rho, double phi, double zn[]) {
|
|||
// ===========================================================================
|
||||
// Calculate R_pq(rho)
|
||||
// Matrix forms of the coefficients which are easier to work with
|
||||
vector<std::vector<double>> zn_mat(n + 1, std::vector<double>(n + 1));
|
||||
vector<vector<double>> zn_mat(n + 1, vector<double>(n + 1));
|
||||
|
||||
// Fill the main diagonal first (Eq 3.9 in Chong)
|
||||
for (int p = 0; p <= n; p++) {
|
||||
|
|
|
|||
12
src/mesh.cpp
12
src/mesh.cpp
|
|
@ -284,7 +284,7 @@ int StructuredMesh::n_surface_bins() const
|
|||
}
|
||||
|
||||
xt::xtensor<double, 1> StructuredMesh::count_sites(
|
||||
const ParticleBank* bank, int64_t length, bool* outside) const
|
||||
const SourceSite* bank, int64_t length, bool* outside) const
|
||||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t m = this->n_bins();
|
||||
|
|
@ -938,7 +938,7 @@ RegularMesh::surface_bins_crossed(Position r0,
|
|||
}
|
||||
}
|
||||
|
||||
std::pair<vector<double>, std::vector<double>> RegularMesh::plot(
|
||||
std::pair<vector<double>, vector<double>> RegularMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// Figure out which axes lie in the plane of the plot.
|
||||
|
|
@ -988,7 +988,7 @@ void RegularMesh::to_hdf5(hid_t group) const
|
|||
}
|
||||
|
||||
xt::xtensor<double, 1> RegularMesh::count_sites(
|
||||
const ParticleBank* bank, int64_t length, bool* outside) const
|
||||
const SourceSite* bank, int64_t length, bool* outside) const
|
||||
{
|
||||
// Determine shape of array for counts
|
||||
std::size_t m = this->n_bins();
|
||||
|
|
@ -1264,7 +1264,7 @@ int RectilinearMesh::get_index_in_direction(double r, int i) const
|
|||
return lower_bound_index(grid_[i].begin(), grid_[i].end(), r) + 1;
|
||||
}
|
||||
|
||||
std::pair<vector<double>, std::vector<double>> RectilinearMesh::plot(
|
||||
std::pair<vector<double>, vector<double>> RectilinearMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// Figure out which axes lie in the plane of the plot.
|
||||
|
|
@ -1923,7 +1923,7 @@ int MOABMesh::get_index_from_bin(int bin) const
|
|||
return bin;
|
||||
}
|
||||
|
||||
std::pair<vector<double>, std::vector<double>> MOABMesh::plot(
|
||||
std::pair<vector<double>, vector<double>> MOABMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
// TODO: Implement mesh lines
|
||||
|
|
@ -2337,7 +2337,7 @@ LibMesh::get_bin_from_element(const libMesh::Elem* elem) const
|
|||
return bin;
|
||||
}
|
||||
|
||||
std::pair<vector<double>, std::vector<double>> LibMesh::plot(
|
||||
std::pair<vector<double>, vector<double>> LibMesh::plot(
|
||||
Position plot_ll, Position plot_ur) const
|
||||
{
|
||||
return {};
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ namespace openmc {
|
|||
void Mgxs::init(const std::string& in_name, double in_awr,
|
||||
const vector<double>& in_kTs, bool in_fissionable,
|
||||
AngleDistributionType in_scatter_format, bool in_is_isotropic,
|
||||
const vector<double>& in_polar, const std::vector<double>& in_azimuthal)
|
||||
const vector<double>& in_polar, const vector<double>& in_azimuthal)
|
||||
{
|
||||
// Set the metadata
|
||||
name = in_name;
|
||||
|
|
@ -307,7 +307,7 @@ Mgxs::Mgxs(
|
|||
//==============================================================================
|
||||
|
||||
Mgxs::Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
||||
const vector<Mgxs*>& micros, const std::vector<double>& atom_densities,
|
||||
const vector<Mgxs*>& micros, const vector<double>& atom_densities,
|
||||
int num_group, int num_delay)
|
||||
: num_groups(num_group), num_delayed_groups(num_delay)
|
||||
{
|
||||
|
|
@ -415,8 +415,8 @@ Mgxs::Mgxs(const std::string& in_name, const vector<double>& mat_kTs,
|
|||
|
||||
//==============================================================================
|
||||
|
||||
void Mgxs::combine(const vector<Mgxs*>& micros,
|
||||
const std::vector<double>& scalars, const vector<int>& micro_ts, int this_t)
|
||||
void Mgxs::combine(const vector<Mgxs*>& micros, const vector<double>& scalars,
|
||||
const vector<int>& micro_ts, int this_t)
|
||||
{
|
||||
// Build the vector of pointers to the xs objects within micros
|
||||
vector<XsData*> those_xs(micros.size());
|
||||
|
|
|
|||
|
|
@ -29,8 +29,7 @@ namespace data {
|
|||
}
|
||||
|
||||
MgxsInterface::MgxsInterface(const std::string& path_cross_sections,
|
||||
const vector<std::string> xs_to_read,
|
||||
const vector<std::vector<double>> xs_temps)
|
||||
const vector<std::string> xs_to_read, const vector<vector<double>> xs_temps)
|
||||
{
|
||||
read_header(path_cross_sections);
|
||||
set_nuclides_and_temperatures(xs_to_read, xs_temps);
|
||||
|
|
@ -38,7 +37,7 @@ MgxsInterface::MgxsInterface(const std::string& path_cross_sections,
|
|||
}
|
||||
|
||||
void MgxsInterface::set_nuclides_and_temperatures(
|
||||
vector<std::string> xs_to_read, vector<std::vector<double>> xs_temps)
|
||||
vector<std::string> xs_to_read, vector<vector<double>> xs_temps)
|
||||
{
|
||||
// Check to remove all duplicates
|
||||
xs_to_read_ = xs_to_read;
|
||||
|
|
@ -148,9 +147,9 @@ void MgxsInterface::create_macro_xs()
|
|||
|
||||
//==============================================================================
|
||||
|
||||
vector<std::vector<double>> MgxsInterface::get_mat_kTs()
|
||||
vector<vector<double>> MgxsInterface::get_mat_kTs()
|
||||
{
|
||||
vector<std::vector<double>> kTs(model::materials.size());
|
||||
vector<vector<double>> kTs(model::materials.size());
|
||||
|
||||
for (const auto& cell : model::cells) {
|
||||
// Skip non-material cells
|
||||
|
|
@ -246,8 +245,8 @@ void put_mgxs_header_data_to_globals()
|
|||
void set_mg_interface_nuclides_and_temps()
|
||||
{
|
||||
// Get temperatures from global data
|
||||
vector<std::vector<double>> nuc_temps(data::nuclide_map.size());
|
||||
vector<std::vector<double>> dummy;
|
||||
vector<vector<double>> nuc_temps(data::nuclide_map.size());
|
||||
vector<vector<double>> dummy;
|
||||
get_temperatures(nuc_temps, dummy);
|
||||
|
||||
// Build vector of nuclide names which are to be read
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ void Particle::create_secondary(
|
|||
n_bank_second() += 1;
|
||||
}
|
||||
|
||||
void Particle::from_source(const ParticleBank* src)
|
||||
void Particle::from_source(const SourceSite* src)
|
||||
{
|
||||
// Reset some attributes
|
||||
clear();
|
||||
|
|
@ -368,7 +368,7 @@ Particle::cross_surface()
|
|||
}
|
||||
|
||||
if (surf->surf_source_ && simulation::current_batch == settings::n_batches) {
|
||||
ParticleBank site;
|
||||
SourceSite site;
|
||||
site.r = r();
|
||||
site.u = u();
|
||||
site.E = E();
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ create_fission_sites(Particle& p, int i_nuclide, const Reaction& rx)
|
|||
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
// Initialize fission site object with particle data
|
||||
ParticleBank site;
|
||||
SourceSite site;
|
||||
site.r = p.r();
|
||||
site.particle = ParticleType::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
|
|
@ -1015,7 +1015,7 @@ sample_cxs_target_velocity(double awr, double E, Direction u, double kT, uint64_
|
|||
}
|
||||
|
||||
void sample_fission_neutron(int i_nuclide, const Reaction& rx, double E_in,
|
||||
ParticleBank* site, uint64_t* seed)
|
||||
SourceSite* site, uint64_t* seed)
|
||||
{
|
||||
// Sample cosine of angle -- fission neutrons are always emitted
|
||||
// isotropically. Sometimes in ACE data, fission reactions actually have
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ create_fission_sites(Particle& p)
|
|||
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
// Initialize fission site object with particle data
|
||||
ParticleBank site;
|
||||
SourceSite site;
|
||||
site.r = p.r();
|
||||
site.particle = ParticleType::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
|
|
|
|||
|
|
@ -140,9 +140,9 @@ IndependentSource::IndependentSource(pugi::xml_node node)
|
|||
}
|
||||
}
|
||||
|
||||
ParticleBank IndependentSource::sample(uint64_t* seed) const
|
||||
SourceSite IndependentSource::sample(uint64_t* seed) const
|
||||
{
|
||||
ParticleBank site;
|
||||
SourceSite site;
|
||||
|
||||
// Set weight to one by default
|
||||
site.wgt = 1.0;
|
||||
|
|
@ -262,7 +262,7 @@ FileSource::FileSource(std::string path)
|
|||
file_close(file_id);
|
||||
}
|
||||
|
||||
ParticleBank FileSource::sample(uint64_t* seed) const
|
||||
SourceSite FileSource::sample(uint64_t* seed) const
|
||||
{
|
||||
size_t i_site = sites_.size()*prn(seed);
|
||||
return sites_[i_site];
|
||||
|
|
@ -348,7 +348,7 @@ void initialize_source()
|
|||
}
|
||||
}
|
||||
|
||||
ParticleBank sample_external_source(uint64_t* seed)
|
||||
SourceSite sample_external_source(uint64_t* seed)
|
||||
{
|
||||
// Determine total source strength
|
||||
double total_strength = 0.0;
|
||||
|
|
@ -367,7 +367,7 @@ ParticleBank sample_external_source(uint64_t* seed)
|
|||
}
|
||||
|
||||
// Sample source site from i-th source distribution
|
||||
ParticleBank site {model::external_sources[i]->sample(seed)};
|
||||
SourceSite site {model::external_sources[i]->sample(seed)};
|
||||
|
||||
// If running in MG, convert site.E to group
|
||||
if (!settings::run_CE) {
|
||||
|
|
|
|||
|
|
@ -512,17 +512,16 @@ hid_t h5banktype() {
|
|||
// - openmc/statepoint.py
|
||||
// - docs/source/io_formats/statepoint.rst
|
||||
// - docs/source/io_formats/source.rst
|
||||
hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(struct ParticleBank));
|
||||
H5Tinsert(banktype, "r", HOFFSET(ParticleBank, r), postype);
|
||||
H5Tinsert(banktype, "u", HOFFSET(ParticleBank, u), postype);
|
||||
H5Tinsert(banktype, "E", HOFFSET(ParticleBank, E), H5T_NATIVE_DOUBLE);
|
||||
H5Tinsert(banktype, "wgt", HOFFSET(ParticleBank, wgt), H5T_NATIVE_DOUBLE);
|
||||
H5Tinsert(banktype, "delayed_group", HOFFSET(ParticleBank, delayed_group),
|
||||
hid_t banktype = H5Tcreate(H5T_COMPOUND, sizeof(struct SourceSite));
|
||||
H5Tinsert(banktype, "r", HOFFSET(SourceSite, r), postype);
|
||||
H5Tinsert(banktype, "u", HOFFSET(SourceSite, u), postype);
|
||||
H5Tinsert(banktype, "E", HOFFSET(SourceSite, E), H5T_NATIVE_DOUBLE);
|
||||
H5Tinsert(banktype, "wgt", HOFFSET(SourceSite, wgt), H5T_NATIVE_DOUBLE);
|
||||
H5Tinsert(banktype, "delayed_group", HOFFSET(SourceSite, delayed_group),
|
||||
H5T_NATIVE_INT);
|
||||
H5Tinsert(banktype, "surf_id", HOFFSET(SourceSite, surf_id), H5T_NATIVE_INT);
|
||||
H5Tinsert(
|
||||
banktype, "surf_id", HOFFSET(ParticleBank, surf_id), H5T_NATIVE_INT);
|
||||
H5Tinsert(
|
||||
banktype, "particle", HOFFSET(ParticleBank, particle), H5T_NATIVE_INT);
|
||||
banktype, "particle", HOFFSET(SourceSite, particle), H5T_NATIVE_INT);
|
||||
|
||||
H5Tclose(postype);
|
||||
return banktype;
|
||||
|
|
@ -598,9 +597,9 @@ write_source_bank(hid_t group_id, bool surf_source_bank)
|
|||
|
||||
// Set vectors for source bank and starting bank index of each process
|
||||
vector<int64_t>* bank_index = &simulation::work_index;
|
||||
vector<ParticleBank>* source_bank = &simulation::source_bank;
|
||||
vector<SourceSite>* source_bank = &simulation::source_bank;
|
||||
vector<int64_t> surf_source_index_vector;
|
||||
vector<ParticleBank> surf_source_bank_vector;
|
||||
vector<SourceSite> surf_source_bank_vector;
|
||||
|
||||
// Reset dataspace sizes and vectors for surface source bank
|
||||
if (surf_source_bank) {
|
||||
|
|
@ -656,7 +655,7 @@ write_source_bank(hid_t group_id, bool surf_source_bank)
|
|||
|
||||
// Save source bank sites since the array is overwritten below
|
||||
#ifdef OPENMC_MPI
|
||||
vector<ParticleBank> temp_source {source_bank->begin(), source_bank->end()};
|
||||
vector<SourceSite> temp_source {source_bank->begin(), source_bank->end()};
|
||||
#endif
|
||||
|
||||
for (int i = 0; i < mpi::n_procs; ++i) {
|
||||
|
|
@ -714,7 +713,7 @@ std::string dtype_member_names(hid_t dtype_id)
|
|||
}
|
||||
|
||||
void read_source_bank(
|
||||
hid_t group_id, vector<ParticleBank>& sites, bool distribute)
|
||||
hid_t group_id, vector<SourceSite>& sites, bool distribute)
|
||||
{
|
||||
hid_t banktype = h5banktype();
|
||||
|
||||
|
|
|
|||
|
|
@ -98,9 +98,9 @@ vector<VolumeCalculation::Result> VolumeCalculation::execute() const
|
|||
{
|
||||
// Shared data that is collected from all threads
|
||||
int n = domain_ids_.size();
|
||||
vector<std::vector<int>> master_indices(
|
||||
vector<vector<int>> master_indices(
|
||||
n); // List of material indices for each domain
|
||||
vector<std::vector<int>> master_hits(
|
||||
vector<vector<int>> master_hits(
|
||||
n); // Number of hits for each material in each domain
|
||||
int iterations = 0;
|
||||
|
||||
|
|
@ -121,8 +121,8 @@ vector<VolumeCalculation::Result> VolumeCalculation::execute() const
|
|||
#pragma omp parallel
|
||||
{
|
||||
// Variables that are private to each thread
|
||||
vector<std::vector<int>> indices(n);
|
||||
vector<std::vector<int>> hits(n);
|
||||
vector<vector<int>> indices(n);
|
||||
vector<vector<int>> hits(n);
|
||||
Particle p;
|
||||
|
||||
// Sample locations and count hits
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue