mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
General import of event-based model from old branch. Seems to work, but need to test then work on cleaning up some more.
This commit is contained in:
parent
8f52e04735
commit
8c884a17de
6 changed files with 355 additions and 0 deletions
84
include/openmc/event.h
Normal file
84
include/openmc/event.h
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
#ifndef OPENMC_EVENT_H
|
||||
#define OPENMC_EVENT_H
|
||||
|
||||
#include "openmc/particle.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
#include <vector>
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
||||
//==============================================================================
|
||||
// Structs
|
||||
//==============================================================================
|
||||
|
||||
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;
|
||||
bool operator<(const QueueItem& rhs) const
|
||||
{
|
||||
// First, compare by 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;
|
||||
*/
|
||||
|
||||
// At this point, we have the same particle type, in the same material.
|
||||
// Now, compare by energy
|
||||
return (E < rhs.E);
|
||||
}
|
||||
};
|
||||
|
||||
//==============================================================================
|
||||
// Global variable declarations
|
||||
//==============================================================================
|
||||
//
|
||||
namespace simulation {
|
||||
|
||||
extern std::unique_ptr<QueueItem[]> calculate_fuel_xs_queue;
|
||||
extern std::unique_ptr<QueueItem[]> calculate_nonfuel_xs_queue;
|
||||
extern std::unique_ptr<QueueItem[]> advance_particle_queue;
|
||||
extern std::unique_ptr<QueueItem[]> surface_crossing_queue;
|
||||
extern std::unique_ptr<QueueItem[]> collision_queue;
|
||||
extern std::unique_ptr<Particle[]> particles;
|
||||
extern int64_t calculate_fuel_xs_queue_length;
|
||||
extern int64_t calculate_nonfuel_xs_queue_length;
|
||||
extern int64_t advance_particle_queue_length;
|
||||
extern int64_t surface_crossing_queue_length;
|
||||
extern int64_t collision_queue_length;
|
||||
extern int64_t max_particles_in_flight;
|
||||
|
||||
} // namespace simulation
|
||||
|
||||
//==============================================================================
|
||||
// Functions
|
||||
//==============================================================================
|
||||
|
||||
void init_event_queues(int64_t n_particles);
|
||||
void free_event_queues(void);
|
||||
void dispatch_xs_event(int64_t i);
|
||||
void process_calculate_xs_events(QueueItem* queue, int64_t n);
|
||||
void process_advance_particle_events();
|
||||
void process_surface_crossing_events();
|
||||
void process_collision_events();
|
||||
void process_death_events(int64_t n_particles);
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_EVENT_H
|
||||
|
|
@ -95,6 +95,9 @@ void transport_history_based_single_particle(Particle& p);
|
|||
//! Simulate all particle histories using history-based parallelism
|
||||
void transport_history_based();
|
||||
|
||||
//! Simulate all particle histories using event-based parallelism
|
||||
void transport_event_based();
|
||||
|
||||
} // namespace openmc
|
||||
|
||||
#endif // OPENMC_SIMULATION_H
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue