Function to compute average over local region.
981 const auto & geom =
m_geom[lev];
993 Real d_fact_new, d_fact_old;
1013 for (
int imf(0); imf < 4; ++imf) {
1016 if (!fields[imf])
continue;
1019 #pragma omp parallel if (Gpu::notInLaunchRegion())
1021 for (MFIter mfi(*fields[imf],
TileNoZ()); mfi.isValid(); ++mfi) {
1022 Box pbx = mfi.tilebox(); pbx.setSmall(2,0); pbx.setBig(2,0);
1024 auto mf_arr = (
m_rotate) ? rot_fields[imf]->const_array(mfi) :
1025 fields[imf]->const_array(mfi);
1026 auto ma_arr = averages[imf]->array(mfi);
1029 const auto plo = geom.ProbLoArray();
1030 const auto dx = geom.CellSizeArray();
1031 const auto dxInv = geom.InvCellSizeArray();
1032 const auto z_phys_arr = z_phys->const_array(mfi);
1033 auto x_pos_arr = x_pos->array(mfi);
1034 auto y_pos_arr = y_pos->array(mfi);
1035 auto z_pos_arr = z_pos->array(mfi);
1036 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1038 ma_arr(i,j,k) *= d_fact_old;
1041 for (
int lk(-d_radius); lk <= (d_radius); ++lk) {
1042 for (
int lj(-d_radius); lj <= (d_radius); ++lj) {
1043 for (
int li(-d_radius); li <= (d_radius); ++li) {
1045 Real xp = x_pos_arr(i+li,j+lj,k);
1046 Real yp = y_pos_arr(i+li,j+lj,k);
1047 Real zp = z_pos_arr(i+li,j+lj,k) + met_h_zeta*lk*dx[2];
1049 Real val = denom * interp * d_fact_new;
1050 ma_arr(i,j,k) += val;
1056 auto k_arr = k_indx->const_array(mfi);
1057 auto j_arr = j_indx ? j_indx->const_array(mfi) : Array4<const int> {};
1058 auto i_arr = i_indx ? i_indx->const_array(mfi) : Array4<const int> {};
1059 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1061 ma_arr(i,j,k) *= d_fact_old;
1063 int mk = k_arr(i,j,k);
1064 int mj = j_arr ? j_arr(i,j,k) : j;
1065 int mi = i_arr ? i_arr(i,j,k) : i;
1066 for (
int lk(mk-d_radius); lk <= (mk+d_radius); ++lk) {
1067 for (
int lj(mj-d_radius); lj <= (mj+d_radius); ++lj) {
1068 for (
int li(mi-d_radius); li <= (mi+d_radius); ++li) {
1069 Real val = denom * mf_arr(li, lj, lk) * d_fact_new;
1070 ma_arr(i,j,k) += val;
1080 averages[imf]->FillBoundary(geom.periodicity());
1093 #pragma omp parallel if (Gpu::notInLaunchRegion())
1095 for (MFIter mfi(*averages[iavg],
TileNoZ()); mfi.isValid(); ++mfi) {
1096 Box pbx = mfi.tilebox(); pbx.setSmall(2,0); pbx.setBig(2,0);
1098 const Array4<Real const>& T_mf_arr = fields[2]->const_array(mfi);
1099 const Array4<Real const>& qv_mf_arr = (fields[3])? fields[3]->const_array(mfi) : Array4<const Real>{};
1100 const Array4<Real const>& qr_mf_arr = (fields[4])? fields[4]->const_array(mfi) : Array4<const Real>{};
1101 auto ma_arr = averages[iavg]->array(mfi);
1104 const auto plo = geom.ProbLoArray();
1105 const auto dx = geom.CellSizeArray();
1106 const auto dxInv = geom.InvCellSizeArray();
1107 const auto z_phys_arr = z_phys->const_array(mfi);
1108 auto x_pos_arr = x_pos->array(mfi);
1109 auto y_pos_arr = y_pos->array(mfi);
1110 auto z_pos_arr = z_pos->array(mfi);
1111 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1113 ma_arr(i,j,k) *= d_fact_old;
1116 for (
int lk(-d_radius); lk <= (d_radius); ++lk) {
1117 for (
int lj(-d_radius); lj <= (d_radius); ++lj) {
1118 for (
int li(-d_radius); li <= (d_radius); ++li) {
1121 Real xp = x_pos_arr(i+li,j+lj,k);
1122 Real yp = y_pos_arr(i+li,j+lj,k);
1123 Real zp = z_pos_arr(i+li,j+lj,k) + met_h_zeta*lk*dx[2];
1131 &qr_interp, qr_mf_arr, z_phys_arr, plo, dxInv, 1);
1132 vfac = 1.0 + 0.61*qv_interp - qr_interp;
1134 vfac = 1.0 + 0.61*qv_interp;
1136 const Real mag = T_interp * vfac;
1137 const Real val = denom * mag * d_fact_new;
1138 ma_arr(i,j,k) += val;
1144 auto k_arr = k_indx->const_array(mfi);
1145 auto j_arr = j_indx ? j_indx->const_array(mfi) : Array4<const int> {};
1146 auto i_arr = i_indx ? i_indx->const_array(mfi) : Array4<const int> {};
1147 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1149 ma_arr(i,j,k) *= d_fact_old;
1151 int mk = k_arr(i,j,k);
1152 int mj = j_arr ? j_arr(i,j,k) : j;
1153 int mi = i_arr ? i_arr(i,j,k) : i;
1154 for (
int lk(mk-d_radius); lk <= (mk+d_radius); ++lk) {
1155 for (
int lj(mj-d_radius); lj <= (mj+d_radius); ++lj) {
1156 for (
int li(mi-d_radius); li <= (mi+d_radius); ++li) {
1160 vfac = 1.0 + 0.61*qv_mf_arr(li,lj,lk) - qr_mf_arr(li,lj,lk);
1162 vfac = 1.0 + 0.61*qv_mf_arr(li,lj,lk);
1164 const Real mag = T_mf_arr(li,lj,lk) * vfac;
1165 const Real val = denom * mag * d_fact_new;
1166 ma_arr(i,j,k) += val;
1175 averages[iavg]->FillBoundary(geom.periodicity());
1181 IntVect ng = averages[iavg]->nGrowVect();
1182 MultiFab::Copy(*(averages[iavg]),*(averages[2]),0,0,1,ng);
1194 const Real Vsg =
m_Vsg[lev];
1197 #pragma omp parallel if (Gpu::notInLaunchRegion())
1199 for (MFIter mfi(*averages[iavg],
TileNoZ()); mfi.isValid(); ++mfi) {
1200 Box pbx = mfi.tilebox(); pbx.setSmall(2,0); pbx.setBig(2,0);
1202 auto u_mf_arr = (
m_rotate) ? rot_fields[imf ]->const_array(mfi) :
1203 fields[imf ]->const_array(mfi);
1204 auto v_mf_arr = (
m_rotate) ? rot_fields[imf+1]->const_array(mfi) :
1205 fields[imf+1]->const_array(mfi);
1206 auto ma_arr = averages[iavg]->array(mfi);
1209 const auto plo = geom.ProbLoArray();
1210 const auto dx = geom.CellSizeArray();
1211 const auto dxInv = geom.InvCellSizeArray();
1212 const auto z_phys_arr = z_phys->const_array(mfi);
1213 auto x_pos_arr = x_pos->array(mfi);
1214 auto y_pos_arr = y_pos->array(mfi);
1215 auto z_pos_arr = z_pos->array(mfi);
1216 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1218 ma_arr(i,j,k) *= d_fact_old;
1221 for (
int lk(-d_radius); lk <= (d_radius); ++lk) {
1222 for (
int lj(-d_radius); lj <= (d_radius); ++lj) {
1223 for (
int li(-d_radius); li <= (d_radius); ++li) {
1226 Real xp = x_pos_arr(i+li,j+lj,k);
1227 Real yp = y_pos_arr(i+li,j+lj,k);
1228 Real zp = z_pos_arr(i+li,j+lj,k) + met_h_zeta*lk*dx[2];
1231 const Real mag = std::sqrt(u_interp*u_interp + v_interp*v_interp + Vsg*Vsg);
1232 Real val = denom * mag * d_fact_new;
1233 ma_arr(i,j,k) += val;
1239 auto k_arr = k_indx->const_array(mfi);
1240 auto j_arr = j_indx ? j_indx->const_array(mfi) : Array4<const int> {};
1241 auto i_arr = i_indx ? i_indx->const_array(mfi) : Array4<const int> {};
1242 ParallelFor(pbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1244 ma_arr(i,j,k) *= d_fact_old;
1246 int mk = k_arr(i,j,k);
1247 int mj = j_arr ? j_arr(i,j,k) : j;
1248 int mi = i_arr ? i_arr(i,j,k) : i;
1249 for (
int lk(mk-d_radius); lk <= (mk+d_radius); ++lk) {
1250 for (
int lj(mj-d_radius); lj <= (mj+d_radius); ++lj) {
1251 for (
int li(mi-d_radius); li <= (mi+d_radius); ++li) {
1252 const Real u_val = 0.5 * (u_mf_arr(li,lj,lk) + u_mf_arr(li+1,lj ,lk));
1253 const Real v_val = 0.5 * (v_mf_arr(li,lj,lk) + v_mf_arr(li ,lj+1,lk));
1254 const Real mag = std::sqrt(u_val*u_val + v_val*v_val + Vsg*Vsg);
1255 Real val = denom * mag * d_fact_new;
1256 ma_arr(i,j,k) += val;
1265 averages[iavg]->FillBoundary(geom.periodicity());
1271 bool not_per_x = !(geom.periodicity().isPeriodic(0));
1272 bool not_per_y = !(geom.periodicity().isPeriodic(1));
1273 if (not_per_x || not_per_y) {
1274 Box domain = geom.Domain();
1275 for (
int iavg(0); iavg <
m_navg; ++iavg) {
1276 IndexType ixt = averages[iavg]->boxArray().ixType();
1277 Box ldomain = domain; ldomain.convert(ixt);
1278 IntVect ng = averages[iavg]->nGrowVect(); ng[2]=0;
1280 #pragma omp parallel if (Gpu::notInLaunchRegion())
1282 for (MFIter mfi(*averages[iavg],
TileNoZ()); mfi.isValid(); ++mfi) {
1283 Box gpbx = mfi.growntilebox(ng); gpbx.setSmall(2,0); gpbx.setBig(2,0);
1285 if (ldomain.contains(gpbx))
continue;
1287 auto ma_arr = averages[iavg]->array(mfi);
1289 int i_lo = ldomain.smallEnd(0);
int i_hi = ldomain.bigEnd(0);
1290 int j_lo = ldomain.smallEnd(1);
int j_hi = ldomain.bigEnd(1);
1291 ParallelFor(gpbx, [=] AMREX_GPU_DEVICE(
int i,
int j,
int k) noexcept
1294 li = i < i_lo ? i_lo : i;
1295 li = li > i_hi ? i_hi : li;
1296 lj = j < j_lo ? j_lo : j;
1297 lj = lj > j_hi ? j_hi : lj;
1299 ma_arr(i,j,k) = ma_arr(li,lj,k);
AMREX_FORCE_INLINE AMREX_GPU_DEVICE amrex::Real Compute_h_zeta_AtCellCenter(const int &i, const int &j, const int &k, const amrex::GpuArray< amrex::Real, AMREX_SPACEDIM > &cellSizeInv, const amrex::Array4< const amrex::Real > &z_nd)
Definition: ERF_TerrainMetrics.H:39
int m_radius
Definition: ERF_MOSTAverage.H:198
int m_ncell_region
Definition: ERF_MOSTAverage.H:199