mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
added some comments and cleaned things up
This commit is contained in:
parent
6945d949ed
commit
9d79cdc2d5
4 changed files with 25 additions and 30 deletions
|
|
@ -122,7 +122,6 @@ message(STATUS "OpenMC Linker flags: ${ldflags}")
|
|||
|
||||
endif()
|
||||
|
||||
|
||||
#===============================================================================
|
||||
# Update git submodules as needed
|
||||
#===============================================================================
|
||||
|
|
|
|||
|
|
@ -4,8 +4,6 @@
|
|||
#include "openmc/particle.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
|
|
@ -14,30 +12,30 @@ namespace openmc {
|
|||
//==============================================================================
|
||||
|
||||
struct QueueItem{
|
||||
int64_t idx; // particle index in event-based buffer
|
||||
double E; // particle energy
|
||||
int material; // material that particle is in
|
||||
Particle::Type type;
|
||||
int64_t idx; // particle index in event-based buffer
|
||||
double E; // particle energy
|
||||
int64_t material; // material that particle is in
|
||||
Particle::Type type; // particle type
|
||||
bool operator<(const QueueItem& rhs) const
|
||||
{
|
||||
// First, compare by type
|
||||
// First, compare by particle type
|
||||
if (type < rhs.type) {
|
||||
return true;
|
||||
} else if (type > rhs.type) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// At this point, we have the same particle types.
|
||||
// Now, compare by material
|
||||
|
||||
// TODO: Temporarily disabled as SMR problem has different material IDs for every pin
|
||||
// Need to sort by material type instead...
|
||||
/*
|
||||
if( material < rhs.material)
|
||||
return true;
|
||||
if( material > rhs.material)
|
||||
return false;
|
||||
*/
|
||||
// If we have reached this point, we have the same particle types.
|
||||
|
||||
// Next, compare by material:
|
||||
// TODO: Currently, material IDs are not usually unique to material
|
||||
// types. When unique material type IDs are available, we can alter the
|
||||
// material field in this struct to contain the type ID, and then sort
|
||||
// by that, as below:
|
||||
//if( material < rhs.material)
|
||||
// return true;
|
||||
//if( material > rhs.material)
|
||||
// return false;
|
||||
|
||||
// At this point, we have the same particle type, in the same material.
|
||||
// Now, compare by energy
|
||||
|
|
@ -48,7 +46,7 @@ struct QueueItem{
|
|||
//==============================================================================
|
||||
// Global variable declarations
|
||||
//==============================================================================
|
||||
//
|
||||
|
||||
namespace simulation {
|
||||
|
||||
extern std::unique_ptr<QueueItem[]> calculate_fuel_xs_queue;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
#include "openmc/simulation.h"
|
||||
#include "openmc/timer.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
|
|
@ -52,7 +53,8 @@ void free_event_queues(void)
|
|||
simulation::particles.reset();
|
||||
}
|
||||
|
||||
void enqueue_particle(QueueItem* queue, int64_t& length, Particle* p, int64_t buffer_idx, bool use_atomic)
|
||||
void enqueue_particle(QueueItem* queue, int64_t& length, Particle* p,
|
||||
int64_t buffer_idx, bool use_atomic)
|
||||
{
|
||||
int64_t idx;
|
||||
if (use_atomic) {
|
||||
|
|
@ -102,7 +104,6 @@ void process_calculate_xs_events(QueueItem* queue, int64_t n)
|
|||
// improve cache locality and reduce thread divergence on GPU.
|
||||
//std::sort(queue, queue+n);
|
||||
|
||||
// Save last_ members, find grid index
|
||||
#pragma omp parallel for schedule(runtime)
|
||||
for (int64_t i = 0; i < n; i++) {
|
||||
Particle* p = &simulation::particles[queue[i].idx];
|
||||
|
|
|
|||
|
|
@ -275,7 +275,6 @@ void allocate_banks()
|
|||
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
|
||||
init_fission_bank(3*simulation::work_per_rank);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void initialize_batch()
|
||||
|
|
@ -612,10 +611,10 @@ void transport_event_based()
|
|||
int64_t source_offset = 0;
|
||||
|
||||
// To cap the total amount of memory used to store particle object data, the
|
||||
// number of particles in flight at any point in time can set. In the case
|
||||
// number of particles in flight at any point in time can bet set. In the case
|
||||
// that the maximum in flight particle count is lower than the total number
|
||||
// of particles that need to be run this iteration, the event-based transport
|
||||
// loop is executed using subierations until all particles have been completed.
|
||||
// loop is executed multiple times until all particles have been completed.
|
||||
while (remaining_work > 0) {
|
||||
// Figure out # of particles to run for this subiteration
|
||||
int64_t n_particles = std::min(remaining_work, simulation::max_particles_in_flight);
|
||||
|
|
@ -623,8 +622,6 @@ void transport_event_based()
|
|||
// Initialize all particle histories for this subiteration
|
||||
process_init_events(n_particles, source_offset);
|
||||
|
||||
int events_retired = 0;
|
||||
|
||||
// Event-based transport loop
|
||||
while (true) {
|
||||
// Determine which event kernel has the most particles in its queue
|
||||
|
|
@ -635,6 +632,7 @@ void transport_event_based()
|
|||
simulation::surface_crossing_queue_length,
|
||||
simulation::collision_queue_length});
|
||||
|
||||
// Execute event with the longest queue
|
||||
if (max == 0) {
|
||||
break;
|
||||
} else if (max == simulation::calculate_fuel_xs_queue_length) {
|
||||
|
|
@ -655,13 +653,12 @@ void transport_event_based()
|
|||
process_collision_events();
|
||||
simulation::collision_queue_length = 0;
|
||||
}
|
||||
|
||||
events_retired++;
|
||||
}
|
||||
|
||||
// Execute death events for all particles
|
||||
// Execute death event for all particles
|
||||
process_death_events(n_particles);
|
||||
|
||||
// Adjust remaining work and source offset variables
|
||||
remaining_work -= n_particles;
|
||||
source_offset += n_particles;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue