moved transport functions in simulation to be more consistent

This commit is contained in:
John Tramm 2020-01-14 02:48:27 +00:00
parent e1abbe6fcb
commit b05dedb179
3 changed files with 34 additions and 28 deletions

View file

@ -7,7 +7,7 @@
#include <vector>
#include "openmc/particle.h"
//#include "openmc/tallies/filter.h"
#include "openmc/tallies/filter.h"
namespace openmc {

View file

@ -65,8 +65,6 @@ void initialize_generation();
void initialize_history(Particle* p, int64_t index_source);
void transport_history_based_single_particle(Particle& p);
//! Finalize a batch
//!
//! Handles synchronization and accumulation of tallies, calculation of Shannon
@ -86,6 +84,13 @@ void broadcast_results();
void free_memory_simulation();
//! Simulate a single particle history (and all generated secondary particles,
//! if enabled), from birth to death
void transport_history_based_single_particle(Particle& p);
//! Simulate all particle histories using history-based parallelism
void transport_history_based();
} // namespace openmc
#endif // OPENMC_SIMULATION_H

View file

@ -37,31 +37,6 @@
namespace openmc {
void transport_history_based_single_particle(Particle& p)
{
while(true) {
p.event_calculate_xs();
p.event_advance();
if( p.collision_distance_ > p.boundary_.distance )
p.event_cross_surface();
else
p.event_collide();
p.event_revive_from_secondary();
if(!p.alive_)
break;
}
p.event_death();
}
void transport_history_based()
{
#pragma omp parallel for schedule(runtime)
for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) {
Particle p;
initialize_history(&p, i_work);
transport_history_based_single_particle(p);
}
}
} // namespace openmc
@ -590,4 +565,30 @@ void free_memory_simulation()
simulation::entropy.clear();
}
void transport_history_based_single_particle(Particle& p)
{
while(true) {
p.event_calculate_xs();
p.event_advance();
if( p.collision_distance_ > p.boundary_.distance )
p.event_cross_surface();
else
p.event_collide();
p.event_revive_from_secondary();
if(!p.alive_)
break;
}
p.event_death();
}
void transport_history_based()
{
#pragma omp parallel for schedule(runtime)
for (int64_t i_work = 1; i_work <= simulation::work_per_rank; ++i_work) {
Particle p;
initialize_history(&p, i_work);
transport_history_based_single_particle(p);
}
}
} // namespace openmc