diff --git a/include/openmc/event.h b/include/openmc/event.h index 9a9615d73..44c08b27b 100644 --- a/include/openmc/event.h +++ b/include/openmc/event.h @@ -28,30 +28,13 @@ struct QueueItem{ int64_t material; //!< material that particle is in double E; //!< particle energy - // Comparator sorts by particle type, then by material type, then by energy + // Compare by particle type, then by material type, then by energy + // 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 material type instead. bool operator<(const QueueItem& rhs) const { - // First, compare by particle type - if (type < rhs.type) { - return true; - } else if (type > rhs.type) { - 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 material type instead. - 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. - return (E < rhs.E); + return std::tie(type, material, E) < std::tie(rhs.type, rhs.material, rhs.E); } }; @@ -102,7 +85,7 @@ void free_event_queues(void); //! \param length A reference to the length variable for the queue //! \param p A pointer to the particle //! \param buffer_idx The particle's actual index in the particle buffer -void enqueue_particle(QueueItem* queue, int64_t& length, Particle* p, +void enqueue_particle(QueueItem* queue, int64_t& length, const Particle* p, int64_t buffer_idx); //! Enqueues a particle based on if it is in fuel or a non-fuel material diff --git a/src/event.cpp b/src/event.cpp index 2d94234e7..d3dde9c71 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -52,7 +52,7 @@ void free_event_queues(void) simulation::particles.reset(); } -void enqueue_particle(QueueItem* queue, int64_t& length, Particle* p, +void enqueue_particle(QueueItem* queue, int64_t& length, const Particle* p, int64_t buffer_idx) { int64_t idx; @@ -73,8 +73,8 @@ void dispatch_xs_event(int64_t buffer_idx) enqueue_particle(simulation::calculate_nonfuel_xs_queue.get(), simulation::calculate_nonfuel_xs_queue_length, p, buffer_idx); } else { - enqueue_particle(simulation::calculate_fuel_xs_queue.get(), - simulation::calculate_fuel_xs_queue_length, p, buffer_idx); + enqueue_particle(simulation::calculate_fuel_xs_queue.get(), + simulation::calculate_fuel_xs_queue_length, p, buffer_idx); } } diff --git a/src/settings.cpp b/src/settings.cpp index acd635047..e942ed2df 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -132,7 +132,8 @@ void get_run_parameters(pugi::xml_node node_base) // Get maximum number of in flight particles for event-based mode if (check_for_node(node_base, "max_in_flight_particles")) { - max_in_flight_particles = std::stoll(get_node_value(node_base, "max_in_flight_particles")); + max_in_flight_particles = std::stoll(get_node_value(node_base, + "max_in_flight_particles")); } // Get number of basic batches