Using global sizes to limit loops:
for (k = lo[2]; k <= hi[2] && k < NZ; ++k)
means only data we expect is used, but likely means that built in functions for handling boundary conditions will look at uninitialised data.
Possible solution: Use global limit on data initialisation, then use FillPatch to interpolate data to fill out grid. Then use validbox sizes only for all loops.
Additionally, consider meaning of boundary conidtions at refined levels. Boxes which cover whole domain are periodic, but smaller boxes on refined grids may not be.
Using global sizes to limit loops:
means only data we expect is used, but likely means that built in functions for handling boundary conditions will look at uninitialised data.
Possible solution: Use global limit on data initialisation, then use FillPatch to interpolate data to fill out grid. Then use validbox sizes only for all loops.
Additionally, consider meaning of boundary conidtions at refined levels. Boxes which cover whole domain are periodic, but smaller boxes on refined grids may not be.