mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 21:25:36 -04:00
Respond to @smharper and @pshriwise comments on #1154
This commit is contained in:
parent
a99b732592
commit
20fa6fa5da
3 changed files with 30 additions and 31 deletions
|
|
@ -5,7 +5,6 @@
|
|||
#define OPENMC_OUTPUT_H
|
||||
|
||||
#include <string>
|
||||
#include <utility> // 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<double, double> mean_stdev(const double* x, int n);
|
||||
|
||||
} // namespace openmc
|
||||
#endif // OPENMC_OUTPUT_H
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include <algorithm> // for std::transform
|
||||
#include <cstring> // for strlen
|
||||
#include <iomanip> // for setw, setprecision
|
||||
#include <ctime> // for time, localtime
|
||||
#include <iomanip> // for setw, setprecision, put_time
|
||||
#include <ios> // for fixed, scientific, left
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <ctime>
|
||||
#include <utility> // for pair
|
||||
|
||||
#include <omp.h>
|
||||
#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<double, double> 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<double, double> 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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue