Fix for inefficient hierarchies during problem initialization.

#182 Merged at a33a5d2
  1. Nathan Goldbaum

This fixes a corner case in the AMR hierarchy generation that is triggered while initializing a problem in memory.

Since the hierarchy does not exist yet in these situations, NumberOfCells[i+1] will always be zero. This causes the SubgridSizeAutoAdjust machinery to always choose the least efficient allowed choices for grid sizes on all level above level 0. For my galaxy simulation problems, I then quickly run out of memory due to the poor surface to volume ratios of these tiny grids.

The fix I offer here is to use the number of cells on the parent level as a guess for the number of cells that will ultimately fill out the level we are constructing. This guess will be corrected the next time we call RebuildHierarchy. In my tests, this produces much more efficient initial hierarchies.

All credit to @samskillman for identifying the bug and suggesting the fix.

Comments (2)

  1. Greg Bryan

    Sounds good to me -- the other option that Yuan Li experimented with is having default values for the subgrid parameters in this case (of not knowing the cell count); however, I don't think the exact solution matters as long as we get away from using the very small values that result if the cell count is zero.