diff --git a/include/openmc/constants.h b/include/openmc/constants.h index fa2251b84d..eadff1726f 100644 --- a/include/openmc/constants.h +++ b/include/openmc/constants.h @@ -339,6 +339,11 @@ enum class RunMode { enum class GeometryType { CSG, DAG }; +//============================================================================== +// Volume Calculation Constants + +constexpr size_t SIZE_T_MAX {std::numeric_limits::max()}; + } // namespace openmc #endif // OPENMC_CONSTANTS_H diff --git a/src/volume_calc.cpp b/src/volume_calc.cpp index 002171d497..56134f367a 100644 --- a/src/volume_calc.cpp +++ b/src/volume_calc.cpp @@ -225,6 +225,13 @@ vector VolumeCalculation::execute() const iterations++; size_t total_samples = iterations * n_samples_; + // warn user if total sample size is greater than what the size_t type can + // represent + if (total_samples > SIZE_T_MAX) { + warning("The number of samples has exceeded the size_t type. Volume " + "results may be inaccurate."); + } + // reset double trigger_val = -INFTY;