mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Added a function for converting score integers to strings instead of storing them.
This commit is contained in:
parent
5d18ea67c6
commit
01efd1ef59
3 changed files with 181 additions and 4 deletions
|
|
@ -72,6 +72,8 @@ public:
|
|||
|
||||
void accumulate();
|
||||
|
||||
std::string score_name(int i) const;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Major public data members.
|
||||
|
||||
|
|
@ -92,8 +94,6 @@ public:
|
|||
|
||||
std::vector<int> scores_; //!< Filter integrands (e.g. flux, fission)
|
||||
|
||||
std::vector<std::string> score_strs_; //!< Score names
|
||||
|
||||
//! Index of each nuclide to be tallied. -1 indicates total material.
|
||||
std::vector<int> nuclides_ {-1};
|
||||
|
||||
|
|
|
|||
|
|
@ -722,7 +722,7 @@ void write_unstructured_mesh_results() {
|
|||
nuclide_name = data::nuclides[tally->nuclides_[i_nuc]]->name_;
|
||||
}
|
||||
|
||||
std::string score_name = tally->score_strs_[i_score];
|
||||
std::string score_name = tally->score_name(i_score);
|
||||
|
||||
auto score_str = fmt::format("{0}_{1}",
|
||||
score_name,
|
||||
|
|
|
|||
|
|
@ -65,6 +65,175 @@ double global_tally_collision;
|
|||
double global_tally_tracklength;
|
||||
double global_tally_leakage;
|
||||
|
||||
std::string
|
||||
score_int_to_str(int score_int) {
|
||||
if (score_int == SCORE_FLUX)
|
||||
return "flux";
|
||||
|
||||
if (score_int == SCORE_SCATTER)
|
||||
return "scatter";
|
||||
|
||||
if (score_int == SCORE_TOTAL)
|
||||
return "total";
|
||||
|
||||
if (score_int == SCORE_SCATTER)
|
||||
return "scatter";
|
||||
|
||||
if (score_int == SCORE_NU_SCATTER)
|
||||
return "nu-scatter";
|
||||
|
||||
if (score_int == SCORE_ABSORPTION)
|
||||
return "absorption";
|
||||
|
||||
if (score_int == SCORE_FISSION)
|
||||
return "fission";
|
||||
|
||||
if (score_int == SCORE_NU_FISSION)
|
||||
return "nu-fission";
|
||||
|
||||
if (score_int == SCORE_DECAY_RATE)
|
||||
return "decay-rate";
|
||||
|
||||
if (score_int == SCORE_DELAYED_NU_FISSION)
|
||||
return "delayed-nu-fission";
|
||||
|
||||
if (score_int == SCORE_PROMPT_NU_FISSION)
|
||||
return "prompt-nu-fission";
|
||||
|
||||
if (score_int == SCORE_KAPPA_FISSION)
|
||||
return "kappa-fission";
|
||||
|
||||
if (score_int == SCORE_INVERSE_VELOCITY)
|
||||
return "inverse-velocity";
|
||||
|
||||
if (score_int == SCORE_FISS_Q_PROMPT)
|
||||
return "fission-q-prompt";
|
||||
|
||||
if (score_int == SCORE_FISS_Q_RECOV)
|
||||
return "fission-q-recoverable";
|
||||
|
||||
if (score_int == HEATING)
|
||||
return "heating";
|
||||
|
||||
if (score_int == HEATING_LOCAL)
|
||||
return "heating-local";
|
||||
|
||||
if (score_int == SCORE_CURRENT)
|
||||
return "current";
|
||||
|
||||
if (score_int == SCORE_EVENTS)
|
||||
return "events";
|
||||
|
||||
if (score_int == ELASTIC)
|
||||
return "(n,elastic)";
|
||||
|
||||
if (score_int == N_2N)
|
||||
return "(n,2n)";
|
||||
|
||||
if (score_int == N_3N)
|
||||
return "(n,3n)";
|
||||
|
||||
if (score_int == N_4N)
|
||||
return "(n,4n)";
|
||||
|
||||
if (score_int == N_2ND)
|
||||
return "(n,2nd)";
|
||||
|
||||
if (score_int == N_2NA)
|
||||
return "(n,na)";
|
||||
if (score_int == N_N3A)
|
||||
return "(n,n3a)";
|
||||
if (score_int == N_2NA)
|
||||
return "(n,2na)";
|
||||
if (score_int == N_3NA)
|
||||
return "(n,3na)";
|
||||
if (score_int == N_NP)
|
||||
return "(n,np)";
|
||||
if (score_int == N_N2A)
|
||||
return "(n,n2a)";
|
||||
if (score_int == N_2N2A)
|
||||
return "(n,2n2a)";
|
||||
if (score_int == N_ND)
|
||||
return "(n,nd)";
|
||||
if (score_int == N_NT)
|
||||
return "(n,nt)";
|
||||
if (score_int == N_N3HE)
|
||||
return "(n,nHe-3)";
|
||||
if (score_int == N_ND2A)
|
||||
return "(n,nd2a)";
|
||||
if (score_int == N_NT2A)
|
||||
return "(n,nt2a)";
|
||||
if (score_int == N_3NF)
|
||||
return "(n,3nf)";
|
||||
if (score_int == N_2NP)
|
||||
return "(n,2np)";
|
||||
if (score_int == N_3NP)
|
||||
return "(n,3np)";
|
||||
if (score_int == N_N2P)
|
||||
return "(n,n2p)";
|
||||
if (score_int == N_NPA)
|
||||
return "(n,npa)";
|
||||
if (score_int == N_N1)
|
||||
return "(n,n1)";
|
||||
if (score_int == N_NC)
|
||||
return "(n,nc)";
|
||||
if (score_int == N_GAMMA)
|
||||
return "(n,gamma)";
|
||||
if (score_int == N_P)
|
||||
return "(n,p)";
|
||||
if (score_int == N_D)
|
||||
return "(n,d)";
|
||||
if (score_int == N_T)
|
||||
return "(n,t)";
|
||||
if (score_int == N_3HE)
|
||||
return "(n,3He)";
|
||||
if (score_int == N_A)
|
||||
return "(n,a)";
|
||||
if (score_int == N_2A)
|
||||
return "(n,2a)";
|
||||
if (score_int == N_3A)
|
||||
return "(n,3a)";
|
||||
if (score_int == N_2P)
|
||||
return "(n,2p)";
|
||||
if (score_int == N_PA)
|
||||
return "(n,pa)";
|
||||
if (score_int == N_T2A)
|
||||
return "(n,t2a)";
|
||||
if (score_int == N_D2A)
|
||||
return "(n,d2a)";
|
||||
if (score_int == N_PD)
|
||||
return "(n,pd)";
|
||||
if (score_int == N_PT)
|
||||
return "(n,pt)";
|
||||
if (score_int == N_DA)
|
||||
return "(n,da)";
|
||||
if (score_int == N_XP)
|
||||
return "H1-production";
|
||||
if (score_int == N_XD)
|
||||
return "H2-production";
|
||||
if (score_int == N_XT)
|
||||
return "H3-production";
|
||||
if (score_int == N_X3HE)
|
||||
return "He3-production";
|
||||
if (score_int == N_XA)
|
||||
return "He4-production";
|
||||
if (score_int == DAMAGE_ENERGY)
|
||||
return "damage-energy";
|
||||
|
||||
// Assume the given int is a reaction MT number. Make sure it's a natural
|
||||
// number then return.
|
||||
std::string score_as_str = std::to_string(score_int);
|
||||
int MT;
|
||||
try {
|
||||
MT = std::stoi(score_as_str);
|
||||
} catch (const std::invalid_argument& ex) {
|
||||
throw std::invalid_argument("Invalid tally score \"" + score_as_str + "\"");
|
||||
}
|
||||
if (MT < 1)
|
||||
throw std::invalid_argument("Invalid tally score \"" + score_as_str + "\"");
|
||||
return "MT" + score_as_str;
|
||||
}
|
||||
|
||||
int
|
||||
score_str_to_int(std::string score_str)
|
||||
{
|
||||
|
|
@ -650,7 +819,6 @@ Tally::set_scores(const std::vector<std::string>& scores)
|
|||
break;
|
||||
}
|
||||
|
||||
score_strs_.push_back(score_str);
|
||||
scores_.push_back(score);
|
||||
}
|
||||
|
||||
|
|
@ -834,6 +1002,15 @@ void Tally::accumulate()
|
|||
}
|
||||
}
|
||||
|
||||
std::string
|
||||
Tally::score_name(int score_idx) const {
|
||||
if (score_idx < 0 || score_idx >= scores_.size()) {
|
||||
warning("Index in scores array is out of bounds.");
|
||||
return "";
|
||||
}
|
||||
return score_int_to_str(scores_[score_idx]);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
// Non-member functions
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue