mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Updating name VolumeCalculation attribute.
This commit is contained in:
parent
b2c064cc35
commit
eeb8b3cbb3
2 changed files with 14 additions and 14 deletions
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
namespace openmc {
|
||||
|
||||
enum class ThresholdType {
|
||||
enum class VolumeTriggerMetric {
|
||||
NONE = 0,
|
||||
VARIANCE = 1,
|
||||
STD_DEV = 2,
|
||||
|
|
@ -56,7 +56,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 trigger_type_ {ThresholdType::NONE};
|
||||
VolumeTriggerMetric trigger_type_ {VolumeTriggerMetric::NONE}; //!< Trigger metric for the volume calculation
|
||||
Position lower_left_; //!< Lower-left position of bounding box
|
||||
Position upper_right_; //!< Upper-right position of bounding box
|
||||
std::vector<int> domain_ids_; //!< IDs of domains to find volumes of
|
||||
|
|
|
|||
|
|
@ -80,11 +80,11 @@ VolumeCalculation::VolumeCalculation(pugi::xml_node node)
|
|||
|
||||
std::string tmp = get_node_value(threshold_node, "type");
|
||||
if (tmp == "variance") {
|
||||
trigger_type_ = ThresholdType::VARIANCE;
|
||||
trigger_type_ = VolumeTriggerMetric::VARIANCE;
|
||||
} else if (tmp == "std_dev") {
|
||||
trigger_type_ = ThresholdType::STD_DEV;
|
||||
trigger_type_ = VolumeTriggerMetric::STD_DEV;
|
||||
} else if ( tmp == "rel_err") {
|
||||
trigger_type_ = ThresholdType::REL_ERR;
|
||||
trigger_type_ = VolumeTriggerMetric::REL_ERR;
|
||||
} else {
|
||||
std::stringstream msg;
|
||||
msg << "Invalid volume calculation trigger type '" << tmp << "' provided.";
|
||||
|
|
@ -292,16 +292,16 @@ std::vector<VolumeCalculation::Result> VolumeCalculation::execute() const
|
|||
result.iterations = iterations;
|
||||
|
||||
// update threshold value if needed
|
||||
if (trigger_type_ != ThresholdType::NONE) {
|
||||
if (trigger_type_ != VolumeTriggerMetric::NONE) {
|
||||
double val = 0.0;
|
||||
switch (trigger_type_) {
|
||||
case ThresholdType::STD_DEV:
|
||||
case VolumeTriggerMetric::STD_DEV:
|
||||
val = result.volume[1];
|
||||
break;
|
||||
case ThresholdType::REL_ERR:
|
||||
case VolumeTriggerMetric::REL_ERR:
|
||||
val = result.volume[1] / result.volume[0];
|
||||
break;
|
||||
case ThresholdType::VARIANCE:
|
||||
case VolumeTriggerMetric::VARIANCE:
|
||||
val = result.volume[1] * result.volume[1];
|
||||
break;
|
||||
}
|
||||
|
|
@ -337,7 +337,7 @@ std::vector<VolumeCalculation::Result> VolumeCalculation::execute() const
|
|||
#endif
|
||||
|
||||
// return results of the calculation
|
||||
if (trigger_type_ == ThresholdType::NONE || max_vol_err < threshold_) {
|
||||
if (trigger_type_ == VolumeTriggerMetric::NONE || max_vol_err < threshold_) {
|
||||
return results;
|
||||
}
|
||||
|
||||
|
|
@ -374,18 +374,18 @@ void VolumeCalculation::to_hdf5(const std::string& filename,
|
|||
write_attribute(file_id, "lower_left", lower_left_);
|
||||
write_attribute(file_id, "upper_right", upper_right_);
|
||||
// Write trigger info
|
||||
if (trigger_type_ != ThresholdType::NONE) {
|
||||
if (trigger_type_ != VolumeTriggerMetric::NONE) {
|
||||
write_attribute(file_id, "iterations", results[0].iterations);
|
||||
write_attribute(file_id, "threshold", threshold_);
|
||||
std::string trigger_str;
|
||||
switch(trigger_type_) {
|
||||
case ThresholdType::VARIANCE:
|
||||
case VolumeTriggerMetric::VARIANCE:
|
||||
trigger_str = "variance";
|
||||
break;
|
||||
case ThresholdType::STD_DEV:
|
||||
case VolumeTriggerMetric::STD_DEV:
|
||||
trigger_str = "std_dev";
|
||||
break;
|
||||
case ThresholdType::REL_ERR:
|
||||
case VolumeTriggerMetric::REL_ERR:
|
||||
trigger_str = "rel_err";
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue