| 1069 | } |
| 1070 | |
| 1071 | void |
| 1072 | Gravity::test_level_grad_phi_prev(int level) |
| 1073 | { |
| 1074 | BL_PROFILE("Gravity::test_level_grad_phi_prev()"); |
| 1075 | |
| 1076 | // Fill the RHS for the solve |
| 1077 | const MultiFab& S_old = LevelData[level]->get_old_data(State_Type); |
| 1078 | MultiFab Rhs(grids[level],dmap[level],1,0); |
| 1079 | MultiFab::Copy(Rhs,S_old, URHO,0,1,0); |
| 1080 | |
| 1081 | const Geometry& geom = parent->Geom(level); |
| 1082 | |
| 1083 | // This is a correction for fully periodic domains only |
| 1084 | if ( geom.isAllPeriodic() ) |
| 1085 | { |
| 1086 | if (gravity::verbose > 1 && ParallelDescriptor::IOProcessor() && mass_offset != 0.0) { |
| 1087 | std::cout << " ... subtracting average density from RHS at level ... " |
| 1088 | << level << " " << mass_offset << std::endl; |
| 1089 | } |
| 1090 | Rhs.plus(-mass_offset,0,1,0); |
| 1091 | } |
| 1092 | |
| 1093 | Rhs.mult(Ggravity); |
| 1094 | |
| 1095 | if (gravity::verbose > 1) { |
| 1096 | Real rhsnorm = Rhs.norm0(); |
| 1097 | amrex::Print() << "... test_level_grad_phi_prev at level " << level << std::endl; |
| 1098 | amrex::Print() << " norm of RHS " << rhsnorm << std::endl; |
| 1099 | } |
| 1100 | |
| 1101 | auto dx = parent->Geom(level).CellSizeArray(); |
| 1102 | auto problo = parent->Geom(level).ProbLoArray(); |
| 1103 | const int coord_type = geom.Coord(); |
| 1104 | |
| 1105 | #ifdef _OPENMP |
| 1106 | #pragma omp parallel |
| 1107 | #endif |
| 1108 | for (MFIter mfi(Rhs, TilingIfNotGPU()); mfi.isValid(); ++mfi) |
| 1109 | { |
| 1110 | const Box& bx = mfi.tilebox(); |
| 1111 | |
| 1112 | test_residual(bx, |
| 1113 | Rhs.array(mfi), |
| 1114 | (*grad_phi_prev[level][0]).array(mfi), |
| 1115 | #if AMREX_SPACEDIM >= 2 |
| 1116 | (*grad_phi_prev[level][1]).array(mfi), |
| 1117 | #endif |
| 1118 | #if AMREX_SPACEDIM == 3 |
| 1119 | (*grad_phi_prev[level][2]).array(mfi), |
| 1120 | #endif |
| 1121 | dx, problo, coord_type); |
| 1122 | } |
| 1123 | |
| 1124 | if (gravity::verbose > 1) { |
| 1125 | Real resnorm = Rhs.norm0(); |
| 1126 | amrex::Print() << " norm of residual " << resnorm << std::endl; |
| 1127 | } |
| 1128 | } |
no test coverage detected