mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
initial SHM fission bank has been implemented. Needs debugging.
This commit is contained in:
parent
3dc5b2ce3e
commit
8c1ebbd7fb
3 changed files with 54 additions and 3 deletions
|
|
@ -16,6 +16,10 @@ constexpr int STATUS_EXIT_NORMAL {0};
|
|||
constexpr int STATUS_EXIT_MAX_BATCH {1};
|
||||
constexpr int STATUS_EXIT_ON_TRIGGER {2};
|
||||
|
||||
extern Particle::Bank * shared_fission_bank;
|
||||
extern int shared_fission_bank_length;
|
||||
extern int shared_fission_bank_max;
|
||||
|
||||
//==============================================================================
|
||||
// Global variable declarations
|
||||
//==============================================================================
|
||||
|
|
@ -51,6 +55,7 @@ extern std::vector<int64_t> work_index;
|
|||
// Threadprivate variables
|
||||
extern "C" bool trace; //!< flag to show debug information
|
||||
|
||||
|
||||
#pragma omp threadprivate(current_work, work_per_thread, trace)
|
||||
|
||||
} // namespace simulation
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
|
|||
|
||||
p->fission_ = true;
|
||||
for (int i = 0; i < nu; ++i) {
|
||||
/*
|
||||
// Create new bank site and get reference to last element
|
||||
bank.emplace_back();
|
||||
auto& site {bank.back()};
|
||||
|
|
@ -183,12 +184,22 @@ create_fission_sites(Particle* p, int i_nuclide, const Reaction* rx,
|
|||
site.r = p->r();
|
||||
site.particle = Particle::Type::neutron;
|
||||
site.wgt = 1. / weight;
|
||||
*/
|
||||
int idx;
|
||||
#pragma omp atomic capture
|
||||
idx = shared_fission_bank_length++;
|
||||
Particle::Bank * site = shared_fission_bank + idx;
|
||||
site->r = p->r();
|
||||
site->particle = Particle::Type::neutron;
|
||||
site->wgt = 1. / weight;
|
||||
|
||||
// Sample delayed group and angle/energy for fission reaction
|
||||
sample_fission_neutron(i_nuclide, rx, p->E_, &site);
|
||||
//sample_fission_neutron(i_nuclide, rx, p->E_, &site);
|
||||
sample_fission_neutron(i_nuclide, rx, p->E_, site);
|
||||
|
||||
// Set the delayed group on the particle as well
|
||||
p->delayed_group_ = site.delayed_group;
|
||||
//p->delayed_group_ = site.delayed_group;
|
||||
p->delayed_group_ = site->delayed_group;
|
||||
|
||||
// Increment the number of neutrons born delayed
|
||||
if (p->delayed_group_ > 0) {
|
||||
|
|
|
|||
|
|
@ -92,6 +92,22 @@ void free_event_queues(void)
|
|||
|
||||
constexpr size_t MAX_PARTICLES_PER_THREAD {100};
|
||||
|
||||
Particle::Bank * shared_fission_bank;
|
||||
int shared_fission_bank_length = 0;
|
||||
int shared_fission_bank_max;
|
||||
|
||||
void init_shared_fission_bank(int max)
|
||||
{
|
||||
shared_fission_bank_max = max;
|
||||
shared_fission_bank = new Particle::Bank[max];
|
||||
}
|
||||
|
||||
void free_shared_fission_bank(void)
|
||||
{
|
||||
delete[] shared_fission_bank;
|
||||
shared_fission_bank_length = 0;
|
||||
}
|
||||
|
||||
// TODO: What is going on here?
|
||||
void revive_particle_from_secondary(Particle* p)
|
||||
{
|
||||
|
|
@ -536,6 +552,9 @@ void transport()
|
|||
{
|
||||
int remaining_work = simulation::work_per_rank;
|
||||
int source_offset = 0;
|
||||
|
||||
|
||||
|
||||
// Subiterations to complete sets of particles
|
||||
while (remaining_work > 0) {
|
||||
|
||||
|
|
@ -621,6 +640,7 @@ void transport()
|
|||
free_event_queues();
|
||||
std::cout << "Event kernels retired: " << event_kernel_executions << std::endl;
|
||||
}
|
||||
shared_fission_bank_length = 0;
|
||||
}
|
||||
|
||||
} // namespace openmc
|
||||
|
|
@ -639,10 +659,12 @@ int openmc_run()
|
|||
|
||||
int err = 0;
|
||||
int status = 0;
|
||||
|
||||
while (status == 0 && err == 0) {
|
||||
err = openmc_next_batch(&status);
|
||||
}
|
||||
|
||||
|
||||
openmc_simulation_finalize();
|
||||
return err;
|
||||
}
|
||||
|
|
@ -653,6 +675,12 @@ int openmc_simulation_init()
|
|||
|
||||
// Skip if simulation has already been initialized
|
||||
if (simulation::initialized) return 0;
|
||||
|
||||
// We assume that the number of fission sites will be at most
|
||||
// 10x the number of neutrons run on this rank
|
||||
int shared_fission_bank_size = 10 * simulation::work_per_rank;
|
||||
// Initializes the shared fission bank
|
||||
init_shared_fission_bank(shared_fission_bank_size);
|
||||
|
||||
// Determine how much work each process should do
|
||||
calculate_work();
|
||||
|
|
@ -717,6 +745,8 @@ int openmc_simulation_finalize()
|
|||
|
||||
// Skip if simulation was never run
|
||||
if (!simulation::initialized) return 0;
|
||||
|
||||
free_shared_fission_bank();
|
||||
|
||||
// Stop active batch timer and start finalization timer
|
||||
simulation::time_active.stop();
|
||||
|
|
@ -1049,7 +1079,12 @@ void finalize_generation()
|
|||
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
|
||||
#ifdef _OPENMP
|
||||
// Join the fission bank from each thread into one global fission bank
|
||||
join_bank_from_threads();
|
||||
//join_bank_from_threads();
|
||||
|
||||
// We need to move all the stuff from the shared_fission_bank into the real one.
|
||||
//std::vector<Particle::Bank> shared_fission_bank_vector(shared_fission_bank, shared_fission_bank_length);
|
||||
std::vector<Particle::Bank> shared_fission_bank_vector(shared_fission_bank, shared_fission_bank + shared_fission_bank_length);
|
||||
simulation::fission_bank = shared_fission_bank_vector;
|
||||
#endif
|
||||
|
||||
// Distribute fission bank across processors evenly
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue