Skip to content

Commit

Permalink
CarpetX: only regrid those fine levels that already catch up
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Aug 20, 2024
1 parent 6789e10 commit 6ce19ce
Showing 1 changed file with 39 additions and 1 deletion.
40 changes: 39 additions & 1 deletion CarpetX/src/schedule.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1612,6 +1612,44 @@ int Evolve(tFleshConfig *config) {
for (const auto &leveldata : patchdata.leveldata)
iteration = min(iteration, leveldata.iteration);

int min_active_level = 0;

if (use_subcycling_wip) {
// Loop over all levels, in batches that combine levels that don't
// subcycle. The level range is [min_level, max_level).
for (int min_level = 0, max_level = min_level + 1;
min_level < ghext->num_levels();
min_level = max_level, max_level = min_level + 1) {
// Find end of batch
while (max_level < ghext->num_levels()) {

This comment has been minimized.

Copy link
@rhaas80

rhaas80 Aug 21, 2024

Collaborator

that condition may actually be wrong since max_level is exclusive so the "all levels" is min_level=0 and max_level=ghext->num_levels().

bool level_is_subcycling_level = false;
for (const auto &patchdata : ghext->patchdata)
if (max_level < int(patchdata.leveldata.size()))
level_is_subcycling_level |=
patchdata.leveldata.at(max_level).is_subcycling_level;
if (level_is_subcycling_level)
break;
++max_level;
}
// Skip this batch of levels if it is not active at the current
// iteration
rat64 level_iteration = -1;
for (const auto &patchdata : ghext->patchdata) {
if (min_level < int(patchdata.leveldata.size())) {
level_iteration = patchdata.leveldata.at(min_level).iteration;
break;
}
}
assert(level_iteration != -1);
// Skip those evolved coarse levels when evolving fine levels to catch
// up
if (level_iteration == iteration) {
min_active_level = min_level;
break;

This comment has been minimized.

Copy link
@rhaas80

rhaas80 Aug 21, 2024

Collaborator

given the logic here I am not sure why you need to compute max_level for this.

}
};
}

// TODO: Move regridding into a function
if (regrid_every > 0 && cctkGH->cctk_iteration % regrid_every == 0) {
#pragma omp critical
Expand Down Expand Up @@ -1644,7 +1682,7 @@ int Evolve(tFleshConfig *config) {
}
patchdata.amrcore->SetMaxGridSize(max_grid_sizes_vec);

patchdata.amrcore->regrid(0, time);
patchdata.amrcore->regrid(min_active_level, time);

This comment has been minimized.

Copy link
@rhaas80

rhaas80 Aug 21, 2024

Collaborator

one could put in a check that all finer levels are indeed at the same time.


const int new_numlevels = patchdata.amrcore->finestLevel() + 1;
const int max_numlevels = patchdata.amrcore->maxLevel() + 1;
Expand Down

0 comments on commit 6ce19ce

Please sign in to comment.