diff --git a/include/openmc/output.h b/include/openmc/output.h index 385ef08a9..e2387dd27 100644 --- a/include/openmc/output.h +++ b/include/openmc/output.h @@ -5,7 +5,6 @@ #define OPENMC_OUTPUT_H #include -#include // for pair #include "openmc/particle.h" @@ -57,8 +56,5 @@ void print_runtime(); //! Display results for global tallies including k-effective estimators void print_results(); -//! Calculate the mean and standard deviation for a tally result -std::pair mean_stdev(const double* x, int n); - } // namespace openmc #endif // OPENMC_OUTPUT_H diff --git a/src/output.cpp b/src/output.cpp index 567a588fa..2acd50efd 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -2,11 +2,12 @@ #include // for std::transform #include // for strlen -#include // for setw, setprecision +#include // for time, localtime +#include // for setw, setprecision, put_time #include // for fixed, scientific, left #include #include -#include +#include // for pair #include #include "xtensor/xview.hpp" @@ -414,16 +415,20 @@ void print_batch_keff() //============================================================================== -void show_time(const char* label, double value) +void show_time(const char* label, double secs, int indent_level=0) { - std::cout << " " << std::setw(33) << std::left << label << " = " - << std::setw(10) << std::right << value << " seconds\n"; + for (int i = 0; i < indent_level; ++i) { + std::cout << " "; + } + int width = 33 - indent_level*2; + std::cout << " " << std::setw(width) << std::left << label << " = " + << std::setw(10) << std::right << secs << " seconds\n"; } -void show_rate(const char* label, double value) +void show_rate(const char* label, double particles_per_sec) { std::cout << " " << std::setw(33) << std::left << label << " = " << - value << " particles/second\n"; + particles_per_sec << " particles/second\n"; } void print_runtime() @@ -439,20 +444,20 @@ void print_runtime() // display time elapsed for various sections std::cout << std::scientific << std::setprecision(4); show_time("Total time for initialization", time_initialize.elapsed()); - show_time(" Reading cross sections", time_read_xs.elapsed()); + show_time("Reading cross sections", time_read_xs.elapsed(), 1); show_time("Total time in simulation", time_inactive.elapsed() + time_active.elapsed()); - show_time(" Time in transport only", time_transport.elapsed()); + show_time("Time in transport only", time_transport.elapsed(), 1); if (settings::run_mode == RUN_MODE_EIGENVALUE) { - show_time(" Time in inactive batches", time_inactive.elapsed()); + show_time("Time in inactive batches", time_inactive.elapsed(), 1); } - show_time(" Time in active batches", time_active.elapsed()); + show_time("Time in active batches", time_active.elapsed(), 1); if (settings::run_mode == RUN_MODE_EIGENVALUE) { - show_time(" Time synchronizing fission bank", time_bank.elapsed()); - show_time(" Sampling source sites", time_bank_sample.elapsed()); - show_time(" SEND/RECV source sites", time_bank_sendrecv.elapsed()); + show_time("Time synchronizing fission bank", time_bank.elapsed(), 1); + show_time("Sampling source sites", time_bank_sample.elapsed(), 2); + show_time("SEND/RECV source sites", time_bank_sendrecv.elapsed(), 2); } - show_time(" Time accumulating tallies", time_tallies.elapsed()); + show_time("Time accumulating tallies", time_tallies.elapsed(), 1); show_time("Total time for finalization", time_finalize.elapsed()); show_time("Total time elapsed", time_total.elapsed()); @@ -499,6 +504,16 @@ void print_runtime() //============================================================================== +std::pair mean_stdev(const double* x, int n) +{ + double mean = x[RESULT_SUM] / n; + double stdev = n > 1 ? std::sqrt((x[RESULT_SUM_SQ]/n + - mean*mean)/(n - 1)) : 0.0; + return {mean, stdev}; +} + +//============================================================================== + void print_results() { // Save state of cout @@ -567,14 +582,4 @@ void print_results() std::cout.flags(f); } -//============================================================================== - -std::pair mean_stdev(const double* x, int n) -{ - double mean = x[RESULT_SUM] / n; - double stdev = n > 1 ? std::sqrt((x[RESULT_SUM_SQ]/n - - mean*mean)/(n - 1)) : 0.0; - return {mean, stdev}; -} - } // namespace openmc diff --git a/src/state_point.cpp b/src/state_point.cpp index 6dc8eafdd..6ed26dda4 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -114,11 +114,9 @@ openmc_statepoint_write(const char* filename, bool* write_source) if (!settings::reduce_tallies) { // If using the no-tally-reduction method, we need to collect tally // results before writing them to the state point file. - write_tally_results_nr(file_id); } else if (mpi::master) { - // Write number of global realizations write_dataset(file_id, "n_realizations", n_realizations);