mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
Change data::elements to a vector of unique_ptr
This commit is contained in:
parent
5ff8dca372
commit
ea9ff22805
6 changed files with 12 additions and 11 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <hdf5.h>
|
||||
#include "xtensor/xtensor.hpp"
|
||||
|
||||
#include <memory> // for unique_ptr
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <utility> // for pair
|
||||
|
|
@ -119,7 +120,7 @@ namespace data {
|
|||
extern xt::xtensor<double, 1> compton_profile_pz; //! Compton profile momentum grid
|
||||
|
||||
//! Photon interaction data for each element
|
||||
extern std::vector<PhotonInteraction> elements;
|
||||
extern std::vector<std::unique_ptr<PhotonInteraction>> elements;
|
||||
extern std::unordered_map<std::string, int> element_map;
|
||||
|
||||
} // namespace data
|
||||
|
|
|
|||
|
|
@ -475,7 +475,7 @@ void Material::collision_stopping_power(double* s_col, bool positron)
|
|||
std::vector<double> e_b_sq;
|
||||
|
||||
for (int i = 0; i < element_.size(); ++i) {
|
||||
const auto& elm = data::elements[element_[i]];
|
||||
const auto& elm = *data::elements[element_[i]];
|
||||
double awr = data::nuclides[nuclide_[i]]->awr_;
|
||||
|
||||
// Get atomic density of nuclide given atom/weight percent
|
||||
|
|
@ -589,7 +589,7 @@ void Material::init_bremsstrahlung()
|
|||
// Bragg's additivity rule.
|
||||
for (int i = 0; i < n; ++i) {
|
||||
// Get pointer to current element
|
||||
const auto& elm = data::elements[element_[i]];
|
||||
const auto& elm = *data::elements[element_[i]];
|
||||
double awr = data::nuclides[nuclide_[i]]->awr_;
|
||||
|
||||
// Get atomic density and mass density of nuclide given atom/weight percent
|
||||
|
|
@ -838,7 +838,7 @@ void Material::calculate_photon_xs(Particle& p) const
|
|||
// Calculate microscopic cross section for this nuclide
|
||||
const auto& micro {p.photon_xs_[i_element]};
|
||||
if (p.E_ != micro.last_E) {
|
||||
data::elements[i_element].calculate_xs(p);
|
||||
data::elements[i_element]->calculate_xs(p);
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
|
|
|
|||
|
|
@ -982,7 +982,7 @@ extern "C" int openmc_load_nuclide(const char* name, const double* temps, int n)
|
|||
|
||||
// Read element data from HDF5
|
||||
hid_t group = open_group(file_id, element.c_str());
|
||||
data::elements.emplace_back(group);
|
||||
data::elements.push_back(std::make_unique<PhotonInteraction>(group));
|
||||
|
||||
close_group(group);
|
||||
file_close(file_id);
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace data {
|
|||
|
||||
xt::xtensor<double, 1> compton_profile_pz;
|
||||
|
||||
std::vector<PhotonInteraction> elements;
|
||||
std::vector<std::unique_ptr<PhotonInteraction>> elements;
|
||||
std::unordered_map<std::string, int> element_map;
|
||||
|
||||
} // namespace data
|
||||
|
|
|
|||
|
|
@ -258,7 +258,7 @@ void sample_photon_reaction(Particle& p)
|
|||
// Sample element within material
|
||||
int i_element = sample_element(p);
|
||||
const auto& micro {p.photon_xs_[i_element]};
|
||||
const auto& element {data::elements[i_element]};
|
||||
const auto& element {*data::elements[i_element]};
|
||||
|
||||
// Calculate photon energy over electron rest mass equivalent
|
||||
double alpha = p.E_/MASS_ELECTRON_EV;
|
||||
|
|
|
|||
|
|
@ -578,13 +578,13 @@ void initialize_data()
|
|||
|
||||
if (settings::photon_transport) {
|
||||
for (const auto& elem : data::elements) {
|
||||
if (elem.energy_.size() >= 1) {
|
||||
if (elem->energy_.size() >= 1) {
|
||||
int photon = static_cast<int>(Particle::Type::photon);
|
||||
int n = elem.energy_.size();
|
||||
int n = elem->energy_.size();
|
||||
data::energy_min[photon] = std::max(data::energy_min[photon],
|
||||
std::exp(elem.energy_(1)));
|
||||
std::exp(elem->energy_(1)));
|
||||
data::energy_max[photon] = std::min(data::energy_max[photon],
|
||||
std::exp(elem.energy_(n - 1)));
|
||||
std::exp(elem->energy_(n - 1)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue