Skip to content

Commit

Permalink
CarpetX: allow subcycling if regridding happens when levels align
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Jul 25, 2024
1 parent f57d251 commit 83bd43f
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions CarpetX/src/driver.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1774,20 +1774,29 @@ void CactusAmrCore::MakeNewLevelFromCoarse(
#pragma omp critical
CCTK_VINFO("MakeNewLevelFromCoarse patch %d level %d", patch, level);

assert(!use_subcycling_wip);
assert(level > 0);

SetupLevel(level, ba, dm, []() { return "MakeNewLevelFromCoarse"; });

// Prolongate
assert(!use_subcycling_wip);
auto &patchdata = ghext->patchdata.at(patch);
auto &leveldata = patchdata.leveldata.at(level);
auto &coarseleveldata = patchdata.leveldata.at(level - 1);
const active_levels_t active_levels(level, level + 1, patch, patch + 1);
const active_levels_t active_coarse_levels(level - 1, level, patch,
patch + 1);

// only allow creation of new levels when the source and target are aligned
// in time
if (leveldata.iteration != coarseleveldata.iteration) {
ostringstream msg;
msg << "Coarse (rl=" << (level-1) <<", it=" << coarseleveldata.iteration <<
") and fine (rl=" << level << ", it=" << leveldata.iteration <<
") grid do not align in time when regridding";
#pragma omp critical
CCTK_VERROR(msg.str().c_str());
}

const int num_groups = CCTK_NumGroups();
for (int gi = 0; gi < num_groups; ++gi) {
cGroup group;
Expand Down Expand Up @@ -1883,8 +1892,16 @@ void CactusAmrCore::RemakeLevel(const int level, const amrex::Real time,
const active_levels_t active_coarse_levels(level - 1, level, patch,
patch + 1);

// Copy or prolongate
assert(!use_subcycling_wip);
// only allow modfication of levels when the source and target are aligned in
// time
if (leveldata.iteration != coarseleveldata.iteration) {
ostringstream msg;
msg << "Coarse (rl=" << (level-1) <<", it=" << coarseleveldata.iteration <<
") and fine (rl=" << level << ", it=" << leveldata.iteration <<
") grid do not align in time when regridding";
#pragma omp critical
CCTK_VERROR(msg.str().c_str());
}

// Check old level
const int num_groups = CCTK_NumGroups();
Expand Down

0 comments on commit 83bd43f

Please sign in to comment.