Adding function for retrieving the name of a nuclide from a tally.

This commit is contained in:
Patrick Shriwise 2021-01-09 18:37:37 -06:00
parent 02f8804fe3
commit 7b6bf93afd
2 changed files with 15 additions and 0 deletions

View file

@ -75,6 +75,9 @@ public:
//! A string representing the i-th score on this tally
std::string score_name(int score_idx) const;
//! A string representing the i-th nuclide on this tally
std::string nuclide_name(int nuclide_idx) const;
//----------------------------------------------------------------------------
// Major public data members.

View file

@ -677,6 +677,18 @@ Tally::score_name(int score_idx) const {
return reaction_name(scores_[score_idx]);
}
std::string
Tally::nuclide_name(int nuclide_idx) const {
if (nuclide_idx != -1) {
return "total";
} else if (nuclide_idx < 0 || nuclide_idx >= nuclides_.size()) {
fatal_error("Index in nuclides array is out of bounds");
}
int nuclide = nuclides_.at(nuclide_idx);
return data::nuclides.at(nuclide)->name_;
}
//==============================================================================
// Non-member functions
//==============================================================================