Skip to content

Commit

Permalink
Merge pull request #1209 from parthenon-hpc-lab/brryan/ordered_histor…
Browse files Browse the repository at this point in the history
…y_output

Ordered history output
  • Loading branch information
pdmullen authored Nov 14, 2024
2 parents b3a2b8d + 817ea62 commit cad5ccd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- [[PR 1161]](https://github.com/parthenon-hpc-lab/parthenon/pull/1161) Make flux field Metadata accessible, add Metadata::CellMemAligned flag, small perfomance upgrades

### Changed (changing behavior/API/variables/...)
- [[PR 1209]](https://github.com/parthenon-hpc-lab/parthenon/pull/1209) Ordered history output
- [[PR 1206]](https://github.com/parthenon-hpc-lab/parthenon/pull/1206) Leapfrog fix
- [[PR1203]](https://github.com/parthenon-hpc-lab/parthenon/pull/1203) Pin Ubuntu CI image
- [[PR1177]](https://github.com/parthenon-hpc-lab/parthenon/pull/1177) Make mesh-level boundary conditions usable without the "user" flag
Expand Down
4 changes: 3 additions & 1 deletion doc/sphinx/src/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ block might look like

This will produce a text file (``.hst``) output file every 1 units of
simulation time. The content of the file is determined by the functions
enrolled by specific packages, see :ref:`state history output`.
enrolled by specific packages, see :ref:`state history output`. Per-package history
outputs will always be in alphabetical order by package name, which may not match
the order in which packages were added to a simulation.

Histograms
----------
Expand Down
14 changes: 11 additions & 3 deletions src/outputs/history.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
// \brief writes history output data, volume-averaged quantities that are output
// frequently in time to trace their history.

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
Expand Down Expand Up @@ -93,9 +94,16 @@ void HistoryOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm,
md_base->Initialize(pm->block_list, pm);
}

// Loop over all packages of the application
for (const auto &pkg : packages) {
const auto &params = pkg.second->AllParams();
// Loop over all packages of the application in alphabetical order to ensure consistency
// of ordering of data in columns.
std::vector<std::string> keys;
for (const auto &pair : packages) {
keys.push_back(pair.first);
}
std::sort(keys.begin(), keys.end());
for (const auto &key : keys) {
const auto &pkg = packages[key];
const auto &params = pkg->AllParams();

// Check if the package has enrolled scalar history functions which are stored in the
// Params under the `hist_param_key` name.
Expand Down

0 comments on commit cad5ccd

Please sign in to comment.