Skip to content

Commit

Permalink
Fix output numbering for triggered opmd outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed Nov 29, 2024
1 parent dfbcb27 commit 4769a63
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 3 additions & 1 deletion src/outputs/output_attr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#ifndef OUTPUTS_OUTPUT_ATTR_HPP_
#define OUTPUTS_OUTPUT_ATTR_HPP_

#include <vector>

// JMM: This could probably be done with template magic but I think
// using a macro is honestly the simplest and cleanest solution here.
// Template solution would be to define a variatic class to conain the
Expand All @@ -42,4 +44,4 @@
PARTHENON_ATTR_APPLY(Kokkos::View<T ***, LayoutWrapper, DevMemSpace>); \
PARTHENON_ATTR_APPLY(device_view_t<T>)

#endif // OUTPUTS_OUTPUT_ATTR_HPP_
#endif // OUTPUTS_OUTPUT_ATTR_HPP_
18 changes: 10 additions & 8 deletions src/outputs/parthenon_opmd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,10 +614,10 @@ void OpenPMDOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm,
}
}
} // loop over components
} // out_var->IsAllocated()
} // loop over blocks
} // out_var->IsAllocated()
} // loop over blocks
it.seriesFlush();
} // loop over vars
} // loop over vars
Kokkos::Profiling::popRegion(); // write all variable data

// -------------------------------------------------------------------------------- //
Expand Down Expand Up @@ -660,11 +660,13 @@ void OpenPMDOutput::WriteOutputFile(Mesh *pm, ParameterInput *pin, SimTime *tm,
series.close();
#endif // ifndef PARTHENON_ENABLE_OPENPMD

// advance output parameters
output_params.file_number++;
output_params.next_time += output_params.dt;
pin->SetInteger(output_params.block_name, "file_number", output_params.file_number);
pin->SetReal(output_params.block_name, "next_time", output_params.next_time);
// advance output parameters if this is not a triggered (now or final) output
if (signal == SignalHandler::OutputSignal::none) {
output_params.file_number++;
output_params.next_time += output_params.dt;
pin->SetInteger(output_params.block_name, "file_number", output_params.file_number);
pin->SetReal(output_params.block_name, "next_time", output_params.next_time);
}
}

} // namespace parthenon
4 changes: 2 additions & 2 deletions tst/unit/test_unit_params.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,9 @@ TEMPLATE_LIST_TEST_CASE("A set of params can be dumped to file", "[params][outpu
auto &in_hostarr2d_v = in_hostarr2d.KokkosView();
resfile.RestoreViewAttribute(groupname + delim + prefix + delim + "hostarr2d",
in_hostarr2d_v);
// TODO(pgrete) make this work and also add checks for correctness below
// TODO(pgrete) make this work and also add checks for correctness below
// resfile.RestoreViewAttribute(groupname + delim + prefix + delim + "bool1d",
// in_bool1d);
// in_bool1d);
}
REQUIRE(scalar == in_scalar);

Expand Down

0 comments on commit 4769a63

Please sign in to comment.