Skip to content

Commit

Permalink
Only rank0 writes energy timings
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed Dec 16, 2024
1 parent 502e99a commit 547c5a3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion inputs/exacb_turbulence.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ problem_id = turbulence

<exacb/power>
cycle_start = 50
cycle_end = 250
cycle_stop = 250

<parthenon/time>
cfl = 0.3 # The Courant, Friedrichs, & Lewy (CFL) Number
Expand Down
8 changes: 4 additions & 4 deletions src/hydro/hydro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,14 +681,14 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
// EXACB custom modifications for power measurements
if (pin->DoesBlockExist("exacb/power")) {
const auto start = pin->GetOrAddInteger("exacb/power", "cycle_start", 50);
const auto end = pin->GetOrAddInteger("exacb/power", "cycle_stop", 250);
PARTHENON_REQUIRE_THROWS(end > start, "Measuring backwards does not make sense.");
const auto stop = pin->GetOrAddInteger("exacb/power", "cycle_stop", 250);
PARTHENON_REQUIRE_THROWS(stop > start, "Measuring backwards does not make sense.");

const auto nlim = pin->GetInteger("parthenon/time", "nlim");
PARTHENON_REQUIRE_THROWS(nlim < 0 || nlim >= end, "end must be within nlim");
PARTHENON_REQUIRE_THROWS(nlim < 0 || nlim >= stop, "stop must be within nlim");

pkg->AddParam<int>("exacb/power/start", start);
pkg->AddParam<int>("exacb/power/end", end);
pkg->AddParam<int>("exacb/power/stop", stop);
}

if (ProblemInitPackageData != nullptr) {
Expand Down
8 changes: 5 additions & 3 deletions src/hydro/hydro_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// Parthenon headers
#include "amr_criteria/refinement_package.hpp"
#include "bvals/comms/bvals_in_one.hpp"
#include "globals.hpp"
#include "prolong_restrict/prolong_restrict.hpp"
#include <parthenon/parthenon.hpp>
// AthenaPK headers
Expand Down Expand Up @@ -396,15 +397,16 @@ TaskCollection HydroDriver::MakeTaskCollection(BlockList_t &blocks, int stage) {
const int num_partitions = pmesh->DefaultNumPartitions();

// EXACB custom modifications for power measurements
if (stage == 1 && hydro_pkg->AllParams().hasKey("exacb/power/start")) {
if (stage == 1 && parthenon::Globals::my_rank == 0 &&
hydro_pkg->AllParams().hasKey("exacb/power/start")) {
const auto start = hydro_pkg->Param<int>("exacb/power/start");
const auto end = hydro_pkg->Param<int>("exacb/power/end");
const auto stop = hydro_pkg->Param<int>("exacb/power/stop");
std::ofstream outfile;
if (start == tm.ncycle) {
outfile.open("energy.times");
outfile << "energy_start:";
}
if (end == tm.ncycle) {
if (stop == tm.ncycle) {
outfile.open("energy.times", std::ios_base::app);
outfile << "energy_stop:";
}
Expand Down

0 comments on commit 547c5a3

Please sign in to comment.