Skip to content

Commit

Permalink
Merge branch 'main' into eschnett/interpolator
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Dec 23, 2024
2 parents 8395217 + 4844efa commit 34e8e0b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 27 deletions.
17 changes: 17 additions & 0 deletions CarpetX/src/io_openpmd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@

#include <openPMD/openPMD.hpp>

#ifdef HAVE_CAPABILITY_ADIOS2
#include <adios2.h>
#endif

#if defined _OPENMP
#include <omp.h>
#elif defined __HIPCC__
Expand Down Expand Up @@ -116,6 +120,7 @@ constexpr openPMD::IterationEncoding iterationEncoding =
openPMD::IterationEncoding::fileBased;

// TODO: Set number of threads?
#ifdef ADIOS2_HAVE_BLOSC2
const std::string options = R"EOS(
{
"adios2": {
Expand All @@ -133,6 +138,18 @@ const std::string options = R"EOS(
}
}
)EOS";
#else
const std::string options = R"EOS(
{
"adios2": {
"dataset": {
"operators": [
]
}
}
}
)EOS";
#endif

constexpr bool input_ghosts = false;
constexpr bool output_ghosts = false;
Expand Down
56 changes: 30 additions & 26 deletions CarpetX/src/schedule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1369,41 +1369,45 @@ int Initialise(tFleshConfig *config) {
bool EvolutionIsDone(cGH *restrict const cctkGH) {
DECLARE_CCTK_PARAMETERS;

if (terminate_next || CCTK_TerminationReached(cctkGH))
return true;

if (CCTK_Equals(terminate, "never"))
return false;

const bool max_iteration_reached = cctkGH->cctk_iteration >= cctk_itlast;

const bool max_simulation_time_reached =
cctk_initial_time < cctk_final_time
? cctkGH->cctk_time >= cctk_final_time
: cctkGH->cctk_time <= cctk_final_time;

int runtime = CCTK_RunTime();
MPI_Bcast(&runtime, 1, MPI_INT, 0, MPI_COMM_WORLD);
const int runtime = CCTK_RunTime();
const bool max_runtime_reached = runtime >= 60 * max_runtime;

if (CCTK_Equals(terminate, "iteration"))
return max_iteration_reached;
if (CCTK_Equals(terminate, "time"))
return max_simulation_time_reached;
if (CCTK_Equals(terminate, "runtime"))
return max_runtime_reached;
if (CCTK_Equals(terminate, "any"))
return max_iteration_reached || max_simulation_time_reached ||
max_runtime_reached;
if (CCTK_Equals(terminate, "all"))
return max_iteration_reached && max_simulation_time_reached &&
max_runtime_reached;
if (CCTK_Equals(terminate, "either"))
return max_iteration_reached || max_simulation_time_reached;
if (CCTK_Equals(terminate, "both"))
return max_iteration_reached && max_simulation_time_reached;

assert(0);
bool we_are_done;
if (terminate_next || CCTK_TerminationReached(cctkGH))
we_are_done = true;
else if (CCTK_Equals(terminate, "never"))
we_are_done = false;
else if (CCTK_Equals(terminate, "iteration"))
we_are_done = max_iteration_reached;
else if (CCTK_Equals(terminate, "time"))
we_are_done = max_simulation_time_reached;
else if (CCTK_Equals(terminate, "runtime"))
we_are_done = max_runtime_reached;
else if (CCTK_Equals(terminate, "any"))
we_are_done = max_iteration_reached || max_simulation_time_reached ||
max_runtime_reached;
else if (CCTK_Equals(terminate, "all"))
we_are_done = max_iteration_reached && max_simulation_time_reached &&
max_runtime_reached;
else if (CCTK_Equals(terminate, "either"))
we_are_done = max_iteration_reached || max_simulation_time_reached;
else if (CCTK_Equals(terminate, "both"))
we_are_done = max_iteration_reached && max_simulation_time_reached;
else
CCTK_ERROR("internal error");

// Ensure all processes make the same decision
MPI_Allreduce(MPI_IN_PLACE, &we_are_done, 1, MPI_CXX_BOOL, MPI_LOR,
MPI_COMM_WORLD);

return we_are_done;
}

void InvalidateTimelevels(cGH *restrict const cctkGH) {
Expand Down
3 changes: 2 additions & 1 deletion Loop/src/loop.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,9 @@ public:
// Outward boundary normal (if on outermost interior point), else 0
const vect<int, dim> BI =
vect<int, dim>(I == bnd_max - 1) - vect<int, dim>(I == bnd_min);
const vect<bool, dim> CI1{CI, CJ, CK};
const PointDesc p =
point_desc({CI, CJ, CK}, I, iter, NI, I0, BI, bnd_min, bnd_max,
point_desc(CI1, I, iter, NI, I0, BI, bnd_min, bnd_max,
loop_min, loop_max);
f(p);
}
Expand Down

0 comments on commit 34e8e0b

Please sign in to comment.