| 1075 | } |
| 1076 | |
| 1077 | void ca_derdivu(const Box& bx, FArrayBox& derfab, int /*dcomp*/, int /*ncomp*/, |
| 1078 | const FArrayBox& datfab, const Geometry& geom, |
| 1079 | Real /*time*/, const int* /*bcrec*/, int /*level*/) |
| 1080 | { |
| 1081 | |
| 1082 | auto const dat = datfab.array(); |
| 1083 | auto const der = derfab.array(); |
| 1084 | |
| 1085 | auto dx = geom.CellSizeArray(); |
| 1086 | |
| 1087 | auto problo = geom.ProbLoArray(); |
| 1088 | |
| 1089 | const int coord_type = geom.Coord(); |
| 1090 | |
| 1091 | amrex::ParallelFor(bx, |
| 1092 | [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept |
| 1093 | { |
| 1094 | |
| 1095 | Real uhi = dat(i+1,j,k,1) / dat(i+1,j,k,0); |
| 1096 | Real ulo = dat(i-1,j,k,1) / dat(i-1,j,k,0); |
| 1097 | |
| 1098 | #if AMREX_SPACEDIM >= 2 |
| 1099 | Real vhi = dat(i,j+dg1,k,2) / dat(i,j+dg1,k,0); |
| 1100 | Real vlo = dat(i,j-dg1,k,2) / dat(i,j-dg1,k,0); |
| 1101 | #endif |
| 1102 | |
| 1103 | #if AMREX_SPACEDIM == 3 |
| 1104 | Real whi = dat(i,j,k+dg2,3) / dat(i,j,k+dg2,0); |
| 1105 | Real wlo = dat(i,j,k-dg2,3) / dat(i,j,k-dg2,0); |
| 1106 | #endif |
| 1107 | |
| 1108 | if (coord_type == 0) { |
| 1109 | // Cartesian divergence |
| 1110 | |
| 1111 | der(i,j,k,0) = 0.5_rt * (uhi - ulo) / dx[0]; |
| 1112 | #if AMREX_SPACEDIM >= 2 |
| 1113 | der(i,j,k,0) += 0.5_rt * (vhi - vlo) / dx[1]; |
| 1114 | #endif |
| 1115 | #if AMREX_SPACEDIM == 3 |
| 1116 | der(i,j,k,0) += 0.5_rt * (whi - wlo) / dx[2]; |
| 1117 | #endif |
| 1118 | } else if (coord_type == 1) { |
| 1119 | // axisymmetric divergence -- defined only for 2-d axisymmetric |
| 1120 | |
| 1121 | Real r = (static_cast<Real>(i) + 0.5_rt)*dx[0] + problo[0]; |
| 1122 | Real rm1 = (static_cast<Real>(i) - 0.5_rt)*dx[0] + problo[0]; |
| 1123 | Real rp1 = (static_cast<Real>(i) + 1.5_rt)*dx[0] + problo[0]; |
| 1124 | |
| 1125 | der(i,j,k,0) = 0.5_rt * (rp1*uhi - rm1*ulo) / (r*dx[0]); |
| 1126 | #if AMREX_SPACEDIM >= 2 |
| 1127 | der(i,j,k,0) += 0.5_rt * (vhi - vlo) / dx[1]; |
| 1128 | #endif |
| 1129 | |
| 1130 | } else if (coord_type == 2) { |
| 1131 | // Spherical geometry |
| 1132 | |
| 1133 | Real r = (static_cast<Real>(i) + 0.5_rt)*dx[0] + problo[0]; |
| 1134 | Real rm1 = (static_cast<Real>(i) - 0.5_rt)*dx[0] + problo[0]; |
nothing calls this directly
no outgoing calls
no test coverage detected