From 85e25d79eafd65a064c3afeea3a77e30e50b0047 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Sat, 5 Oct 2019 13:12:31 -0500 Subject: [PATCH] Finishing addition of a trigger type. --- include/openmc/volume_calc.h | 2 +- src/volume_calc.cpp | 21 +++++++++++++++++---- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/include/openmc/volume_calc.h b/include/openmc/volume_calc.h index e2cf1b3ef..a7dd75009 100644 --- a/include/openmc/volume_calc.h +++ b/include/openmc/volume_calc.h @@ -95,7 +95,7 @@ public: int domain_type_; //!< Type of domain (cell, material, etc.) size_t n_samples_; //!< Number of samples to use double threshold_ {-1.0}; //!< Error threshold for domain volumes - ThresholdType threshold_type_; + ThresholdType trigger_type_; Position lower_left_; //!< Lower-left position of bounding box Position upper_right_; //!< Upper-right position of bounding box std::vector domain_ids_; //!< IDs of domains to find volumes of diff --git a/src/volume_calc.cpp b/src/volume_calc.cpp index 870721f3e..f352e71f8 100644 --- a/src/volume_calc.cpp +++ b/src/volume_calc.cpp @@ -79,11 +79,11 @@ VolumeCalculation::VolumeCalculation(pugi::xml_node node) pugi::xml_node threshold_node = node.child("threshold"); std::string tmp = get_node_value(threshold_node, "type"); if (tmp == "variance") { - threshold_type_ = ThresholdType::VARIANCE; + trigger_type_ = ThresholdType::VARIANCE; } else if (tmp == "std_dev") { - threshold_type_ = ThresholdType::STD_DEV; + trigger_type_ = ThresholdType::STD_DEV; } else if ( tmp == "rel_err") { - threshold_type_ = ThresholdType::REL_ERR; + trigger_type_ = ThresholdType::REL_ERR; } else { std::stringstream msg; msg << "Invalid volume calculation trigger type '" << tmp << "' provided."; @@ -118,7 +118,7 @@ std::vector VolumeCalculation::execute() const { max_val = -INFTY; for (const auto& result : results) { double val; - switch (threshold_type_) { + switch (trigger_type_) { case ThresholdType::STD_DEV: val = result.volume[1]; break; @@ -372,6 +372,19 @@ void VolumeCalculation::to_hdf5(const std::string& filename, write_attribute(file_id, "upper_right", upper_right_); if (threshold_ != -1.0) { write_attribute(file_id, "threshold", threshold_); + + switch(trigger_type_) { + case ThresholdType::VARIANCE: + write_attribute(file_id, "trigger_type", "variance"); + break; + case ThresholdType::STD_DEV: + write_attribute(file_id, "trigger_type", "std_dev"); + break; + case ThresholdType::REL_ERR: + write_attribute(file_id, "trigger_type", "rel_err"); + break; + } + } if (domain_type_ == FILTER_CELL) {