| 1128 | } |
| 1129 | |
| 1130 | void |
| 1131 | Gravity::test_level_grad_phi_curr(int level) |
| 1132 | { |
| 1133 | BL_PROFILE("Gravity::test_level_grad_phi_curr()"); |
| 1134 | |
| 1135 | // Fill the RHS for the solve |
| 1136 | const MultiFab& S_new = LevelData[level]->get_new_data(State_Type); |
| 1137 | MultiFab Rhs(grids[level],dmap[level],1,0); |
| 1138 | MultiFab::Copy(Rhs,S_new, URHO, 0,1,0); |
| 1139 | |
| 1140 | const Geometry& geom = parent->Geom(level); |
| 1141 | |
| 1142 | // This is a correction for fully periodic domains only |
| 1143 | if ( geom.isAllPeriodic() ) |
| 1144 | { |
| 1145 | if (gravity::verbose > 1 && ParallelDescriptor::IOProcessor() && mass_offset != 0.0) { |
| 1146 | std::cout << " ... subtracting average density from RHS in solve ... " << mass_offset << std::endl; |
| 1147 | } |
| 1148 | Rhs.plus(-mass_offset,0,1,0); |
| 1149 | } |
| 1150 | |
| 1151 | Rhs.mult(Ggravity); |
| 1152 | |
| 1153 | if (gravity::verbose > 1) { |
| 1154 | Real rhsnorm = Rhs.norm0(); |
| 1155 | if (ParallelDescriptor::IOProcessor()) { |
| 1156 | std::cout << "... test_level_grad_phi_curr at level " << level << std::endl; |
| 1157 | std::cout << " norm of RHS " << rhsnorm << std::endl; |
| 1158 | } |
| 1159 | } |
| 1160 | |
| 1161 | auto dx = geom.CellSizeArray(); |
| 1162 | auto problo = geom.ProbLoArray(); |
| 1163 | const int coord_type = geom.Coord(); |
| 1164 | |
| 1165 | #ifdef _OPENMP |
| 1166 | #pragma omp parallel |
| 1167 | #endif |
| 1168 | for (MFIter mfi(Rhs, TilingIfNotGPU()); mfi.isValid(); ++mfi) |
| 1169 | { |
| 1170 | const Box& bx = mfi.tilebox(); |
| 1171 | |
| 1172 | test_residual(bx, |
| 1173 | Rhs.array(mfi), |
| 1174 | (*grad_phi_curr[level][0]).array(mfi), |
| 1175 | #if AMREX_SPACEDIM >= 2 |
| 1176 | (*grad_phi_curr[level][1]).array(mfi), |
| 1177 | #endif |
| 1178 | #if AMREX_SPACEDIM == 3 |
| 1179 | (*grad_phi_curr[level][2]).array(mfi), |
| 1180 | #endif |
| 1181 | dx, problo, coord_type); |
| 1182 | } |
| 1183 | |
| 1184 | if (gravity::verbose > 1) { |
| 1185 | Real resnorm = Rhs.norm0(); |
| 1186 | amrex::Print() << " norm of residual " << resnorm << std::endl; |
| 1187 | } |
no test coverage detected