diff --git a/include/openmc/capi.h b/include/openmc/capi.h index 0c0f18bae..11c90ff3a 100644 --- a/include/openmc/capi.h +++ b/include/openmc/capi.h @@ -86,6 +86,7 @@ extern "C" { int openmc_id_map(const void* slice, int32_t* data_out); int openmc_property_map(const void* slice, double* data_out); int openmc_reset(); + int openmc_reset_timers(); int openmc_run(); void openmc_set_seed(int64_t new_seed); int openmc_simulation_finalize(); diff --git a/openmc/deplete/operator.py b/openmc/deplete/operator.py index ce7e709d9..c57d9b163 100644 --- a/openmc/deplete/operator.py +++ b/openmc/deplete/operator.py @@ -289,6 +289,7 @@ class Operator(TransportOperator): # Run OpenMC openmc.lib.reset() openmc.lib.run() + openmc.lib.reset_timers() # Extract results op_result = self._unpack_tallies_and_normalize(power) diff --git a/openmc/lib/core.py b/openmc/lib/core.py index 77187b727..3fe75dccf 100644 --- a/openmc/lib/core.py +++ b/openmc/lib/core.py @@ -60,6 +60,8 @@ _dll.openmc_run.restype = c_int _dll.openmc_run.errcheck = _error_handler _dll.openmc_reset.restype = c_int _dll.openmc_reset.errcheck = _error_handler +_dll.openmc_reset_timers.restype = c_int +_dll.openmc_reset_timers.errcheck = _error_handler _run_linsolver_argtypes = [_array_1d_dble, _array_1d_dble, _array_1d_dble, c_double] _dll.openmc_run_linsolver.argtypes = _run_linsolver_argtypes @@ -299,10 +301,15 @@ def plot_geometry(): def reset(): - """Reset tallies and timers.""" + """Reset tally results""" _dll.openmc_reset() +def reset_timers(): + """Reset timers.""" + _dll.openmc_reset_timers() + + def run(): """Run simulation""" _dll.openmc_run() diff --git a/src/finalize.cpp b/src/finalize.cpp index 74f02cc64..b5d5eb038 100644 --- a/src/finalize.cpp +++ b/src/finalize.cpp @@ -165,6 +165,12 @@ int openmc_reset() return 0; } +int openmc_reset_timers() +{ + reset_timers(); + return 0; +} + int openmc_hard_reset() { // Reset all tallies and timers diff --git a/src/initialize.cpp b/src/initialize.cpp index 10d86ee80..3c2cc03ac 100644 --- a/src/initialize.cpp +++ b/src/initialize.cpp @@ -78,6 +78,7 @@ int openmc_init(int argc, char* argv[], const void* intracomm) // Stop initialization timer simulation::time_initialize.stop(); + simulation::time_total.stop(); return 0; } diff --git a/src/simulation.cpp b/src/simulation.cpp index 64a7d0e80..0a234e53f 100644 --- a/src/simulation.cpp +++ b/src/simulation.cpp @@ -47,6 +47,7 @@ int openmc_run() { + openmc::simulation::time_total.start(); openmc_simulation_init(); int err = 0; @@ -56,6 +57,7 @@ int openmc_run() } openmc_simulation_finalize(); + openmc::simulation::time_total.stop(); return err; } @@ -422,8 +424,8 @@ void finalize_generation() } global_tally_leakage = 0.0; - if (settings::run_mode == RunMode::EIGENVALUE) { - // If using shared memory, stable sort the fission bank (by parent IDs) + if (settings::run_mode == RunMode::EIGENVALUE) { + // If using shared memory, stable sort the fission bank (by parent IDs) // so as to allow for reproducibility regardless of which order particles // are run in. sort_fission_bank(); @@ -525,7 +527,7 @@ void initialize_history_partial(Particle* p) 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()); } @@ -669,7 +671,7 @@ void transport_event_based() process_collision_events(); } } - + // Execute death event for all particles process_death_events(n_particles);