mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
moved transport functions in simulation to be more consistent
This commit is contained in:
parent
e1abbe6fcb
commit
b05dedb179
3 changed files with 34 additions and 28 deletions
|
|
@ -7,7 +7,7 @@
|
|||
#include <vector>
|
||||
|
||||
#include "openmc/particle.h"
|
||||
//#include "openmc/tallies/filter.h"
|
||||
#include "openmc/tallies/filter.h"
|
||||
|
||||
|
||||
namespace openmc {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue