-------------------------------------------------------------
| 31 | |
| 32 | // ------------------------------------------------------------- |
| 33 | BoxArray MakeBoxArray(int maxgrid, int nboxes) { |
| 34 | #if (BL_SPACEDIM == 2) |
| 35 | IntVect ivlo(0, 0); |
| 36 | IntVect ivhi(maxgrid - 1, maxgrid - 1); |
| 37 | #else |
| 38 | IntVect ivlo(0, 0, 0); |
| 39 | IntVect ivhi(maxgrid - 1, maxgrid - 1, maxgrid - 1); |
| 40 | #endif |
| 41 | int iSide(pow(static_cast<Real>(nboxes), 1.0/3.0)); |
| 42 | Box tempBox(ivlo, ivhi); |
| 43 | BoxArray bArray(nboxes); |
| 44 | int ix(0), iy(0), iz(0); |
| 45 | for(int ibox(0); ibox < nboxes; ++ibox) { |
| 46 | Box sBox(tempBox); |
| 47 | sBox.shift(XDIR, ix * maxgrid); |
| 48 | sBox.shift(YDIR, iy * maxgrid); |
| 49 | #if (BL_SPACEDIM == 3) |
| 50 | sBox.shift(ZDIR, iz * maxgrid); |
| 51 | #endif |
| 52 | bArray.set(ibox, sBox); |
| 53 | ++ix; |
| 54 | if(ix > iSide) { |
| 55 | ix = 0; |
| 56 | ++iy; |
| 57 | } |
| 58 | if(iy > iSide) { |
| 59 | iy = 0; |
| 60 | ++iz; |
| 61 | } |
| 62 | } |
| 63 | return bArray; |
| 64 | } |
| 65 | |
| 66 | |
| 67 | // ------------------------------------------------------------- |