mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 21:55:41 -04:00
change particle to using accessor methods
This commit is contained in:
parent
711c60ea15
commit
d5d2072266
38 changed files with 1234 additions and 1031 deletions
|
|
@ -464,51 +464,52 @@ void initialize_history(Particle& p, int64_t index_source)
|
|||
auto site = sample_external_source(&seed);
|
||||
p.from_source(&site);
|
||||
}
|
||||
p.current_work_ = index_source;
|
||||
p.current_work() = index_source;
|
||||
|
||||
// set identifier for particle
|
||||
p.id_ = simulation::work_index[mpi::rank] + index_source;
|
||||
p.id() = simulation::work_index[mpi::rank] + index_source;
|
||||
|
||||
// set progeny count to zero
|
||||
p.n_progeny_ = 0;
|
||||
p.n_progeny() = 0;
|
||||
|
||||
// Reset particle event counter
|
||||
p.n_event_ = 0;
|
||||
p.n_event() = 0;
|
||||
|
||||
// set random number seed
|
||||
int64_t particle_seed = (simulation::total_gen + overall_generation() - 1)
|
||||
* settings::n_particles + p.id_;
|
||||
init_particle_seeds(particle_seed, p.seeds_);
|
||||
int64_t particle_seed =
|
||||
(simulation::total_gen + overall_generation() - 1) * settings::n_particles +
|
||||
p.id();
|
||||
init_particle_seeds(particle_seed, p.seeds());
|
||||
|
||||
// set particle trace
|
||||
p.trace_ = false;
|
||||
p.trace() = false;
|
||||
if (simulation::current_batch == settings::trace_batch &&
|
||||
simulation::current_gen == settings::trace_gen &&
|
||||
p.id_ == settings::trace_particle) p.trace_ = true;
|
||||
p.id() == settings::trace_particle)
|
||||
p.trace() = true;
|
||||
|
||||
// Set particle track.
|
||||
p.write_track_ = false;
|
||||
p.write_track() = false;
|
||||
if (settings::write_all_tracks) {
|
||||
p.write_track_ = true;
|
||||
p.write_track() = true;
|
||||
} else if (settings::track_identifiers.size() > 0) {
|
||||
for (const auto& t : settings::track_identifiers) {
|
||||
if (simulation::current_batch == t[0] &&
|
||||
simulation::current_gen == t[1] &&
|
||||
p.id_ == t[2]) {
|
||||
p.write_track_ = true;
|
||||
simulation::current_gen == t[1] && p.id() == t[2]) {
|
||||
p.write_track() = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Display message if high verbosity or trace is on
|
||||
if (settings::verbosity >= 9 || p.trace_) {
|
||||
write_message("Simulating Particle {}", p.id_);
|
||||
if (settings::verbosity >= 9 || p.trace()) {
|
||||
write_message("Simulating Particle {}", p.id());
|
||||
}
|
||||
|
||||
// Add paricle's starting weight to count for normalizing tallies later
|
||||
#pragma omp atomic
|
||||
simulation::total_weight += p.wgt_;
|
||||
simulation::total_weight += p.wgt();
|
||||
|
||||
initialize_history_partial(p);
|
||||
}
|
||||
|
|
@ -517,21 +518,22 @@ void initialize_history_partial(Particle& p)
|
|||
{
|
||||
// Force calculation of cross-sections by setting last energy to zero
|
||||
if (settings::run_CE) {
|
||||
for (auto& micro : p.neutron_xs_) micro.last_E = 0.0;
|
||||
p.invalidate_neutron_xs();
|
||||
}
|
||||
|
||||
// Prepare to write out particle track.
|
||||
if (p.write_track_) add_particle_track(p);
|
||||
if (p.write_track())
|
||||
add_particle_track(p);
|
||||
|
||||
// Every particle starts with no accumulated flux derivative.
|
||||
if (!model::active_tallies.empty())
|
||||
{
|
||||
p.flux_derivs_.resize(model::tally_derivs.size(), 0.0);
|
||||
std::fill(p.flux_derivs_.begin(), p.flux_derivs_.end(), 0.0);
|
||||
p.flux_derivs().resize(model::tally_derivs.size(), 0.0);
|
||||
std::fill(p.flux_derivs().begin(), p.flux_derivs().end(), 0.0);
|
||||
}
|
||||
|
||||
// Allocate space for tally filter matches
|
||||
p.filter_matches_.resize(model::tally_filters.size());
|
||||
p.filter_matches().resize(model::tally_filters.size());
|
||||
}
|
||||
|
||||
int overall_generation()
|
||||
|
|
@ -678,13 +680,13 @@ void transport_history_based_single_particle(Particle& p)
|
|||
while (true) {
|
||||
p.event_calculate_xs();
|
||||
p.event_advance();
|
||||
if (p.collision_distance_ > p.boundary_.distance) {
|
||||
if (p.collision_distance() > p.boundary().distance) {
|
||||
p.event_cross_surface();
|
||||
} else {
|
||||
p.event_collide();
|
||||
}
|
||||
p.event_revive_from_secondary();
|
||||
if (!p.alive_)
|
||||
if (!p.alive())
|
||||
break;
|
||||
}
|
||||
p.event_death();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue