Move code related to k_generation to C++

This commit is contained in:
Paul Romano 2018-10-12 08:01:23 -05:00
parent d7da87ca1d
commit 8ebd26b160
11 changed files with 126 additions and 102 deletions

View file

@ -1,6 +1,7 @@
#include "openmc/simulation.h"
#include "openmc/capi.h"
#include "openmc/eigenvalue.h"
#include "openmc/message_passing.h"
#include "openmc/settings.h"
#include "openmc/tallies/tally.h"
@ -62,7 +63,7 @@ int thread_id; //!< ID of a given thread
} // namespace simulation
//==============================================================================
// Functions
// Non-member functions
//==============================================================================
void openmc_simulation_init_c()
@ -71,6 +72,20 @@ void openmc_simulation_init_c()
calculate_work();
}
void initialize_generation()
{
if (settings::run_mode == RUN_MODE_EIGENVALUE) {
// Reset number of fission bank sites
n_bank = 0;
// Count source sites if using uniform fission source weighting
if (settings::ufs_on) ufs_count_sites();
// Store current value of tracklength k
keff_generation = global_tallies()(K_TRACKLENGTH, RESULT_VALUE);
}
}
int overall_generation()
{
using namespace simulation;
@ -139,4 +154,13 @@ void broadcast_triggers()
}
#endif
//==============================================================================
// Fortran compatibility
//==============================================================================
extern "C" double k_generation(int i) { return simulation::k_generation.at(i - 1); }
extern "C" int k_generation_size() { return simulation::k_generation.size(); }
extern "C" void k_generation_clear() { simulation::k_generation.clear(); }
extern "C" void k_generation_reserve(int i) { simulation::k_generation.reserve(i); }
} // namespace openmc