mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 22:26:08 -04:00
Teach openmc_statepoint_write about internal tallies
If a tally is marked as not writeable, a tally group will still be added to the statepoint file. However, no filter, score, nuclide, or results data will be written to this tally group. A new attribute is introduced to this tally group "internal" that is an integer flag: 0 if the tally is not internal (i.e. is writeable) and 1 if the tally is internal (i.e. is not writeable). The internal attribute has been added to the statepoint io format in the documentation. Other changes: use ``` const auto& tally : model::tallies tally->X ``` to iterate over tallies during the writing process
This commit is contained in:
parent
0fc57b207b
commit
2ead24e172
2 changed files with 28 additions and 16 deletions
|
|
@ -109,6 +109,10 @@ The current version of the statepoint file format is 17.0.
|
|||
|
||||
**/tallies/tally <uid>/**
|
||||
|
||||
:Attributes: - **internal** (*int*) -- Flag indicating the presence of tally
|
||||
data (0) or absence of tally data (1). All user defined
|
||||
tallies will have a value of 0 unless otherwise instructed.
|
||||
|
||||
:Datasets: - **n_realizations** (*int*) -- Number of realizations.
|
||||
- **n_filters** (*int*) -- Number of filters used.
|
||||
- **filters** (*int[]*) -- User-defined unique IDs of the filters on
|
||||
|
|
|
|||
|
|
@ -165,36 +165,43 @@ openmc_statepoint_write(const char* filename, bool* write_source)
|
|||
write_attribute(tallies_group, "ids", tally_ids);
|
||||
|
||||
// Write all tally information except results
|
||||
for (const auto& tally_ptr : model::tallies) {
|
||||
const auto& tally {*tally_ptr};
|
||||
for (const auto& tally : model::tallies) {
|
||||
hid_t tally_group = create_group(tallies_group,
|
||||
"tally " + std::to_string(tally.id_));
|
||||
"tally " + std::to_string(tally->id_));
|
||||
|
||||
write_dataset(tally_group, "name", tally.name_);
|
||||
write_dataset(tally_group, "name", tally->name_);
|
||||
|
||||
if (tally.estimator_ == ESTIMATOR_ANALOG) {
|
||||
if (tally->writeable_) {
|
||||
write_attribute(tally_group, "internal", 0);
|
||||
} else {
|
||||
write_attribute(tally_group, "internal", 1);
|
||||
close_group(tally_group);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (tally->estimator_ == ESTIMATOR_ANALOG) {
|
||||
write_dataset(tally_group, "estimator", "analog");
|
||||
} else if (tally.estimator_ == ESTIMATOR_TRACKLENGTH) {
|
||||
} else if (tally->estimator_ == ESTIMATOR_TRACKLENGTH) {
|
||||
write_dataset(tally_group, "estimator", "tracklength");
|
||||
} else if (tally.estimator_ == ESTIMATOR_COLLISION) {
|
||||
} else if (tally->estimator_ == ESTIMATOR_COLLISION) {
|
||||
write_dataset(tally_group, "estimator", "collision");
|
||||
}
|
||||
|
||||
write_dataset(tally_group, "n_realizations", tally.n_realizations_);
|
||||
write_dataset(tally_group, "n_realizations", tally->n_realizations_);
|
||||
|
||||
// Write the ID of each filter attached to this tally
|
||||
write_dataset(tally_group, "n_filters", tally.filters().size());
|
||||
if (!tally.filters().empty()) {
|
||||
write_dataset(tally_group, "n_filters", tally->filters().size());
|
||||
if (!tally->filters().empty()) {
|
||||
std::vector<int32_t> filter_ids;
|
||||
filter_ids.reserve(tally.filters().size());
|
||||
for (auto i_filt : tally.filters())
|
||||
filter_ids.reserve(tally->filters().size());
|
||||
for (auto i_filt : tally->filters())
|
||||
filter_ids.push_back(model::tally_filters[i_filt]->id());
|
||||
write_dataset(tally_group, "filters", filter_ids);
|
||||
}
|
||||
|
||||
// Write the nuclides this tally scores
|
||||
std::vector<std::string> nuclides;
|
||||
for (auto i_nuclide : tally.nuclides_) {
|
||||
for (auto i_nuclide : tally->nuclides_) {
|
||||
if (i_nuclide == -1) {
|
||||
nuclides.push_back("total");
|
||||
} else {
|
||||
|
|
@ -207,12 +214,12 @@ openmc_statepoint_write(const char* filename, bool* write_source)
|
|||
}
|
||||
write_dataset(tally_group, "nuclides", nuclides);
|
||||
|
||||
if (tally.deriv_ != C_NONE) write_dataset(tally_group, "derivative",
|
||||
model::tally_derivs[tally.deriv_].id);
|
||||
if (tally->deriv_ != C_NONE) write_dataset(tally_group, "derivative",
|
||||
model::tally_derivs[tally->deriv_].id);
|
||||
|
||||
// Write the tally score bins
|
||||
std::vector<std::string> scores;
|
||||
for (auto sc : tally.scores_) scores.push_back(reaction_name(sc));
|
||||
for (auto sc : tally->scores_) scores.push_back(reaction_name(sc));
|
||||
write_dataset(tally_group, "n_score_bins", scores.size());
|
||||
write_dataset(tally_group, "score_bins", scores);
|
||||
|
||||
|
|
@ -232,6 +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;
|
||||
// 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());
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue