MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / MakeBoxArray

Function MakeBoxArray

Tools/AMRProfParser/TestCodes/SendTest0.cpp:33–64  ·  view source on GitHub ↗

-------------------------------------------------------------

Source from the content-addressed store, hash-verified

31
32// -------------------------------------------------------------
33BoxArray 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// -------------------------------------------------------------

Callers

nothing calls this directly

Calls 2

shiftMethod · 0.80
setMethod · 0.45

Tested by

no test coverage detected