Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ordered history output #1209

Merged
merged 6 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading