Skip to content

Commit

Permalink
CarpetX: Simplify determining whether a group has ghost zones
Browse files Browse the repository at this point in the history
  • Loading branch information
eschnett committed Aug 23, 2023
1 parent 0907b1b commit 90b2d43
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions CarpetX/src/io_openpmd.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,9 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,
CCTK_VINFO("Reading %d variables with %d components...", numvars,
num_local_components);

bool group_has_no_ghosts = true;
const bool group_has_no_ghosts = groupdata.nghostzones[0] == 0 &&
groupdata.nghostzones[1] == 0 &&
groupdata.nghostzones[2] == 0;

// Loop over components (AMReX boxes)
for (int local_component = 0; local_component < num_local_components;
Expand All @@ -895,7 +897,6 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,
validbox.smallEnd(2)},
.hi = {validbox.bigEnd(0) + 1, validbox.bigEnd(1) + 1,
validbox.bigEnd(2) + 1}};
group_has_no_ghosts &= extbox == intbox;
const box_t<int, 3> &box = input_ghosts ? extbox : intbox;

const openPMD::Offset start =
Expand Down Expand Up @@ -1078,6 +1079,10 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,
if (io_verbose)
CCTK_VINFO("Reading %d variables...", numvars);

const bool group_has_no_ghosts = groupdata.nghostzones[0] == 0 &&
groupdata.nghostzones[1] == 0 &&
groupdata.nghostzones[2] == 0;

// exterior (with ghosts)
for (int d = 0; d < dim; ++d)
assert(groupdata.lsh[d] == groupdata.gsh[d]);
Expand Down Expand Up @@ -1177,8 +1182,8 @@ void carpetx_openpmd_t::InputOpenPMD(const cGH *const cctkGH,

// Mark read variables as valid
groupdata.valid.at(tl).at(vi).set_all(
input_ghosts || intbox == extbox ? make_valid_all()
: make_valid_int(),
input_ghosts || group_has_no_ghosts ? make_valid_all()
: make_valid_int(),
[]() { return "read from openPMD file"; });

} // for vi
Expand Down

0 comments on commit 90b2d43

Please sign in to comment.