diff --git a/include/openmc/tallies/tally.h b/include/openmc/tallies/tally.h index 554d302ac..f411e6560 100644 --- a/include/openmc/tallies/tally.h +++ b/include/openmc/tallies/tally.h @@ -37,6 +37,8 @@ public: void set_active(bool active) { active_ = active; } + void set_writable(bool writable) { writable_ = writable; } + void set_scores(pugi::xml_node node); void set_scores(const std::vector& scores); @@ -55,6 +57,8 @@ public: int32_t n_filter_bins() const {return n_filter_bins_;} + bool get_writable() const { return writable_;} + //---------------------------------------------------------------------------- // Other methods. diff --git a/src/output.cpp b/src/output.cpp index 439fc1558..d3262cc4d 100644 --- a/src/output.cpp +++ b/src/output.cpp @@ -643,7 +643,7 @@ write_tallies() if (!tally.name_.empty()) tally_header += ": " + tally.name_; tallies_out << header(tally_header) << "\n\n"; - if (!tally.writeable_) { + if (!tally.writable_) { tallies_out << " Internal\n\n"; continue; } diff --git a/src/state_point.cpp b/src/state_point.cpp index a550748a5..cd2c475d8 100644 --- a/src/state_point.cpp +++ b/src/state_point.cpp @@ -171,7 +171,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) write_dataset(tally_group, "name", tally->name_); - if (tally->writeable_) { + if (tally->writable_) { write_attribute(tally_group, "internal", 0); } else { write_attribute(tally_group, "internal", 1); @@ -239,7 +239,7 @@ openmc_statepoint_write(const char* filename, bool* write_source) // Write all tally results for (const auto& tally : model::tallies) { - if (!tally->writeable_) continue; + if (!tally->writable_) continue; // Write sum and sum_sq for each bin std::string name = "tally " + std::to_string(tally->id_); hid_t tally_group = open_group(tallies_group, name.c_str()); @@ -434,14 +434,12 @@ void load_state_point() std::string name = "tally " + std::to_string(tally->id_); hid_t tally_group = open_group(tallies_group, name.c_str()); - int internal; + int internal=0; if (attribute_exists(tally_group, "internal")) { read_attribute(tally_group, "internal", internal); - } else { - internal = 0; } if (internal) { - tally->writeable_ = false; + tally->writable_ = false; } else { auto& results = tally->results_; @@ -717,7 +715,7 @@ void write_tally_results_nr(hid_t file_id) for (const auto& t : model::tallies) { // Skip any tallies that are not active if (!t->active_) continue; - if (!t->writeable_) continue; + if (!t->writable_) continue; if (mpi::master && !object_exists(file_id, "tallies_present")) { write_attribute(file_id, "tallies_present", 1); diff --git a/src/tallies/tally.cpp b/src/tallies/tally.cpp index 96253285e..3e9de83b1 100644 --- a/src/tallies/tally.cpp +++ b/src/tallies/tally.cpp @@ -1221,25 +1221,25 @@ openmc_tally_set_active(int32_t index, bool active) } extern "C" int -openmc_tally_get_writeable(int32_t index, bool* writeable) +openmc_tally_get_writable(int32_t index, bool* writable) { if (index < 0 || index >= model::tallies.size()) { set_errmsg("Index in tallies array is out of bounds."); return OPENMC_E_OUT_OF_BOUNDS; } - *writeable = model::tallies[index]->writeable_; + *writable = model::tallies[index]->get_writable(); return 0; } extern "C" int -openmc_tally_set_writeable(int32_t index, bool writeable) +openmc_tally_set_writable(int32_t index, bool writable) { if (index < 0 || index >= model::tallies.size()) { set_errmsg("Index in tallies array is out of bounds."); return OPENMC_E_OUT_OF_BOUNDS; } - model::tallies[index]->writeable_ = writeable; + model::tallies[index]->set_writable(writable); return 0; } diff --git a/tests/unit_tests/test_lib.py b/tests/unit_tests/test_lib.py index 7f992cb09..ad198f255 100644 --- a/tests/unit_tests/test_lib.py +++ b/tests/unit_tests/test_lib.py @@ -256,13 +256,13 @@ def test_tally_activate(lib_simulation_init): assert t.active -def test_tally_writeable(lib_simulation_init): +def test_tally_writable(lib_simulation_init): t = openmc.lib.tallies[1] - assert t.writeable - t.writeable = False - assert not t.writeable - # Revert tally to writeable state for lib_run fixtures - t.writeable = True + assert t.writable + t.writable = False + assert not t.writable + # Revert tally to writable state for lib_run fixtures + t.writable = True def test_tally_results(lib_run):