| 139 | } |
| 140 | |
| 141 | void set_grids_nested (Vector<Box>& domains, |
| 142 | Vector<BoxArray>& grids, |
| 143 | Vector<IntVect>& ref_ratio) |
| 144 | { |
| 145 | int ncells, max_grid_size, nlevs; |
| 146 | |
| 147 | ParmParse pp; |
| 148 | pp.get("ncells", ncells); |
| 149 | pp.get("max_grid_size", max_grid_size); |
| 150 | pp.get("nlevs", nlevs); |
| 151 | |
| 152 | AMREX_ALWAYS_ASSERT(nlevs < 2); // relax this later |
| 153 | |
| 154 | IntVect domain_lo(AMREX_D_DECL(0, 0, 0)); |
| 155 | IntVect domain_hi(AMREX_D_DECL(ncells-1, ncells-1, ncells-1)); |
| 156 | |
| 157 | domains.resize(nlevs); |
| 158 | domains[0].setSmall(domain_lo); |
| 159 | domains[0].setBig(domain_hi); |
| 160 | |
| 161 | ref_ratio.resize(nlevs-1); |
| 162 | for (int lev = 1; lev < nlevs; lev++) { |
| 163 | ref_ratio[lev-1] = IntVect(AMREX_D_DECL(2, 2, 2)); |
| 164 | } |
| 165 | |
| 166 | grids.resize(nlevs); |
| 167 | grids[0].define(domains[0]); |
| 168 | |
| 169 | // Now we make the refined level be the center eighth of the domain |
| 170 | if (nlevs > 1) { |
| 171 | int n_fine = ncells*ref_ratio[0][0]; |
| 172 | IntVect refined_lo(AMREX_D_DECL(n_fine/4,n_fine/4,n_fine/4)); |
| 173 | IntVect refined_hi(AMREX_D_DECL(3*n_fine/4-1,3*n_fine/4-1,3*n_fine/4-1)); |
| 174 | |
| 175 | // Build a box for the level 1 domain |
| 176 | Box refined_patch(refined_lo, refined_hi); |
| 177 | grids[1].define(refined_patch); |
| 178 | } |
| 179 | |
| 180 | // break the BoxArrays at both levels into max_grid_size^3 boxes |
| 181 | for (int lev = 0; lev < nlevs; lev++) { |
| 182 | grids[lev].maxSize(max_grid_size); |
| 183 | } |
| 184 | |
| 185 | for (int lev = 1; lev < nlevs; lev++) { |
| 186 | domains[lev] = amrex::refine(domains[lev-1], ref_ratio[lev-1]); |
| 187 | } |
| 188 | } |