moved shared fission bank and event based functions around. Created new event files for event-based logic.

This commit is contained in:
John Tramm 2020-01-08 17:09:41 +00:00
parent 8aaa97a0bd
commit e60dd30079
10 changed files with 324 additions and 279 deletions

View file

@ -14,6 +14,7 @@ extern template class std::vector<openmc::Particle::Bank>;
namespace openmc {
//==============================================================================
// Global variables
//==============================================================================
@ -23,6 +24,10 @@ namespace simulation {
extern std::vector<Particle::Bank> source_bank;
extern std::vector<Particle::Bank> fission_bank;
extern Particle::Bank* shared_fission_bank;
extern int shared_fission_bank_length;
extern int shared_fission_bank_max;
} // namespace simulation
//==============================================================================
@ -31,6 +36,9 @@ extern std::vector<Particle::Bank> fission_bank;
void free_memory_bank();
void init_shared_fission_bank(int max);
void free_shared_fission_bank(void);
} // namespace openmc
#endif // OPENMC_BANK_H

82
include/openmc/event.h Normal file
View file

@ -0,0 +1,82 @@
#ifndef OPENMC_EVENT_H
#define OPENMC_EVENT_H
#include "openmc/particle.h"
#include "openmc/tallies/filter.h"
#include <vector>
namespace openmc {
//==============================================================================
// Structs
//==============================================================================
struct QueueItem{
int 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;
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 QueueItem * calculate_fuel_xs_queue;
extern QueueItem * calculate_nonfuel_xs_queue;
extern QueueItem * advance_particle_queue;
extern QueueItem * surface_crossing_queue;
extern QueueItem * collision_queue;
extern Particle * particles;
extern int calculate_fuel_xs_queue_length;
extern int calculate_nonfuel_xs_queue_length;
extern int advance_particle_queue_length;
extern int surface_crossing_queue_length;
extern int collision_queue_length;
extern int max_particles_in_flight;
} // namespace simulation
//==============================================================================
// Functions
//==============================================================================
void init_event_queues(int n_particles);
void free_event_queues(void);
void dispatch_xs_event(int i);
void process_calculate_xs_events(QueueItem * queue, int n);
void process_advance_particle_events();
void process_surface_crossing_events();
void process_collision_events();
} // namespace openmc
#endif // OPENMC_EVENT_H

View file

@ -16,10 +16,6 @@ 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
//==============================================================================
@ -49,11 +45,6 @@ extern const RegularMesh* ufs_mesh;
extern std::vector<double> k_generation;
extern std::vector<int64_t> work_index;
//// Threadprivate variables
//extern "C" bool trace; //!< flag to show debug information
//#pragma omp threadprivate(trace)
} // namespace simulation
//==============================================================================
@ -74,7 +65,7 @@ void initialize_generation();
void initialize_history(Particle* p, int64_t index_source);
void transport_history_based_inner(Particle& p);
void transport_history_based_single_particle(Particle& p);
//! Finalize a batch
//!