mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Changed thread_safe_append() to require a value argument, and re-arranged create_fission_sites() in physics.cpp and physics_mg.cpp to use the new interface.
This commit is contained in:
parent
18b1166e67
commit
76e58e7b4c
3 changed files with 49 additions and 51 deletions
|
|
@ -69,7 +69,7 @@ public:
|
|||
//! \return The index in the array written to. In the event that this
|
||||
//! index would be greater than what was allocated for the container,
|
||||
//! return -1.
|
||||
int64_t thread_safe_append(const T& value = {})
|
||||
int64_t thread_safe_append(const T& value)
|
||||
{
|
||||
// Atomically capture the index we want to write to
|
||||
int64_t idx;
|
||||
|
|
|
|||
|
|
@ -179,33 +179,32 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx)
|
|||
bool use_fission_bank = (settings::run_mode == RunMode::EIGENVALUE);
|
||||
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
Particle::Bank* site;
|
||||
// Initialize fission site object with particle data
|
||||
Particle::Bank site;
|
||||
site.r = p->r();
|
||||
site.particle = Particle::Type::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
site.parent_id = p->id_;
|
||||
site.progeny_id = p->n_progeny_++;
|
||||
|
||||
// Sample delayed group and angle/energy for fission reaction
|
||||
sample_fission_neutron(i_nuclide, rx, p->E_, &site, p->current_seed());
|
||||
|
||||
// Store fission site in bank
|
||||
if (use_fission_bank) {
|
||||
int64_t idx = simulation::fission_bank.thread_safe_append();
|
||||
int64_t idx = simulation::fission_bank.thread_safe_append(site);
|
||||
if (idx == -1) {
|
||||
warning("The shared fission bank is full. Additional fission sites created "
|
||||
"in this generation will not be banked.");
|
||||
skipped++;
|
||||
break;
|
||||
}
|
||||
site = &simulation::fission_bank[idx];
|
||||
} else {
|
||||
// Create new bank site and get reference to last element
|
||||
auto& bank = p->secondary_bank_;
|
||||
bank.emplace_back();
|
||||
site = &bank.back();
|
||||
p->secondary_bank_.push_back(site);
|
||||
}
|
||||
site->r = p->r();
|
||||
site->particle = Particle::Type::neutron;
|
||||
site->wgt = 1. / weight;
|
||||
site->parent_id = p->id_;
|
||||
site->progeny_id = p->n_progeny_++;
|
||||
|
||||
// Sample delayed group and angle/energy for fission reaction
|
||||
sample_fission_neutron(i_nuclide, rx, p->E_, site, p->current_seed());
|
||||
|
||||
// Set the delayed group on the particle as well
|
||||
p->delayed_group_ = site->delayed_group;
|
||||
p->delayed_group_ = site.delayed_group;
|
||||
|
||||
// Increment the number of neutrons born delayed
|
||||
if (p->delayed_group_ > 0) {
|
||||
|
|
@ -216,9 +215,9 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx)
|
|||
if (use_fission_bank) {
|
||||
p->nu_bank_.emplace_back();
|
||||
Particle::NuBank* nu_bank_entry = &p->nu_bank_.back();
|
||||
nu_bank_entry->wgt = site->wgt;
|
||||
nu_bank_entry->E = site->E;
|
||||
nu_bank_entry->delayed_group = site->delayed_group;
|
||||
nu_bank_entry->wgt = site.wgt;
|
||||
nu_bank_entry->E = site.E;
|
||||
nu_bank_entry->delayed_group = site.delayed_group;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -125,29 +125,13 @@ create_fission_sites(Particle* p)
|
|||
bool use_fission_bank = (settings::run_mode == RunMode::EIGENVALUE);
|
||||
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
Particle::Bank* site;
|
||||
if (use_fission_bank) {
|
||||
int64_t idx = simulation::fission_bank.thread_safe_append();
|
||||
if (idx == -1) {
|
||||
warning("The shared fission bank is full. Additional fission sites created "
|
||||
"in this generation will not be banked.");
|
||||
skipped++;
|
||||
break;
|
||||
}
|
||||
site = &simulation::fission_bank[idx];
|
||||
} else {
|
||||
// Create new bank site and get reference to last element
|
||||
auto& bank = p->secondary_bank_;
|
||||
bank.emplace_back();
|
||||
site = &bank.back();
|
||||
}
|
||||
|
||||
// Bank source neutrons by copying the particle data
|
||||
site->r = p->r();
|
||||
site->particle = Particle::Type::neutron;
|
||||
site->wgt = 1. / weight;
|
||||
site->parent_id = p->id_;
|
||||
site->progeny_id = p->n_progeny_++;
|
||||
// Initialize fission site object with particle data
|
||||
Particle::Bank site;
|
||||
site.r = p->r();
|
||||
site.particle = Particle::Type::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
site.parent_id = p->id_;
|
||||
site.progeny_id = p->n_progeny_++;
|
||||
|
||||
// Sample the cosine of the angle, assuming fission neutrons are emitted
|
||||
// isotropically
|
||||
|
|
@ -155,20 +139,35 @@ create_fission_sites(Particle* p)
|
|||
|
||||
// Sample the azimuthal angle uniformly in [0, 2.pi)
|
||||
double phi = 2. * PI * prn(p->current_seed() );
|
||||
site->u.x = mu;
|
||||
site->u.y = std::sqrt(1. - mu * mu) * std::cos(phi);
|
||||
site->u.z = std::sqrt(1. - mu * mu) * std::sin(phi);
|
||||
site.u.x = mu;
|
||||
site.u.y = std::sqrt(1. - mu * mu) * std::cos(phi);
|
||||
site.u.z = std::sqrt(1. - mu * mu) * std::sin(phi);
|
||||
|
||||
// Sample secondary energy distribution for the fission reaction
|
||||
int dg;
|
||||
int gout;
|
||||
data::mg.macro_xs_[p->material_].sample_fission_energy(p->g_, dg, gout,
|
||||
p->current_seed());
|
||||
|
||||
// Store the energy and delayed groups on the fission bank
|
||||
site->E = gout;
|
||||
site.E = gout;
|
||||
|
||||
// We add 1 to the delayed_group bc in MG, -1 is prompt, but in the rest
|
||||
// of the code, 0 is prompt.
|
||||
site->delayed_group = dg + 1;
|
||||
site.delayed_group = dg + 1;
|
||||
|
||||
// Store fission site in bank
|
||||
if (use_fission_bank) {
|
||||
int64_t idx = simulation::fission_bank.thread_safe_append(site);
|
||||
if (idx == -1) {
|
||||
warning("The shared fission bank is full. Additional fission sites created "
|
||||
"in this generation will not be banked.");
|
||||
skipped++;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
p->secondary_bank_.push_back(site);
|
||||
}
|
||||
|
||||
// Set the delayed group on the particle as well
|
||||
p->delayed_group_ = dg + 1;
|
||||
|
|
@ -182,9 +181,9 @@ create_fission_sites(Particle* p)
|
|||
if (use_fission_bank) {
|
||||
p->nu_bank_.emplace_back();
|
||||
Particle::NuBank* nu_bank_entry = &p->nu_bank_.back();
|
||||
nu_bank_entry->wgt = site->wgt;
|
||||
nu_bank_entry->E = site->E;
|
||||
nu_bank_entry->delayed_group = site->delayed_group;
|
||||
nu_bank_entry->wgt = site.wgt;
|
||||
nu_bank_entry->E = site.E;
|
||||
nu_bank_entry->delayed_group = site.delayed_group;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue