Skip to content

Commit

Permalink
Account for grid stretching with subsidence term.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Lattanzi committed Nov 13, 2024
1 parent 50fc1a5 commit ad1f84d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
12 changes: 8 additions & 4 deletions Source/SourceTerms/ERF_make_mom_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,37 +342,41 @@ void make_mom_sources (int level,
const int nr = Rho_comp;
ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real met_h_zeta = (z_nd_arr) ? Compute_h_zeta_AtIface(i,j,k,dxInv,z_nd_arr) : 1.0;
Real rho_on_u_face = 0.5 * ( cell_data(i,j,k,nr) + cell_data(i-1,j,k,nr) );
Real U_hi = dptr_u_plane(k+1) / dptr_r_plane(k+1);
Real U_lo = dptr_u_plane(k-1) / dptr_r_plane(k-1);
Real wbar_xf = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
xmom_src_arr(i, j, k) -= rho_on_u_face * wbar_xf *
xmom_src_arr(i, j, k) -= rho_on_u_face * wbar_xf * met_h_zeta *
0.5 * (U_hi - U_lo) * dxInv[2];
});
ParallelFor(tby, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real met_h_zeta = (z_nd_arr) ? Compute_h_zeta_AtJface(i,j,k,dxInv,z_nd_arr) : 1.0;
Real rho_on_v_face = 0.5 * ( cell_data(i,j,k,nr) + cell_data(i,j-1,k,nr) );
Real V_hi = dptr_v_plane(k+1) / dptr_r_plane(k+1);
Real V_lo = dptr_v_plane(k-1) / dptr_r_plane(k-1);
Real wbar_yf = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
ymom_src_arr(i, j, k) -= rho_on_v_face * wbar_yf *
ymom_src_arr(i, j, k) -= rho_on_v_face * wbar_yf * met_h_zeta *
0.5 * (V_hi - V_lo) * dxInv[2];
});
} else {
ParallelFor(tbx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real met_h_zeta = (z_nd_arr) ? Compute_h_zeta_AtIface(i,j,k,dxInv,z_nd_arr) : 1.0;
Real U_hi = dptr_u_plane(k+1) / dptr_r_plane(k+1);
Real U_lo = dptr_u_plane(k-1) / dptr_r_plane(k-1);
Real wbar_xf = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
xmom_src_arr(i, j, k) -= wbar_xf *
xmom_src_arr(i, j, k) -= wbar_xf * met_h_zeta *
0.5 * (U_hi - U_lo) * dxInv[2];
});
ParallelFor(tby, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real met_h_zeta = (z_nd_arr) ? Compute_h_zeta_AtJface(i,j,k,dxInv,z_nd_arr) : 1.0;
Real V_hi = dptr_v_plane(k+1) / dptr_r_plane(k+1);
Real V_lo = dptr_v_plane(k-1) / dptr_r_plane(k-1);
Real wbar_yf = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
ymom_src_arr(i, j, k) -= wbar_yf *
ymom_src_arr(i, j, k) -= wbar_yf * met_h_zeta *
0.5 * (V_hi - V_lo) * dxInv[2];
});
}
Expand Down
22 changes: 10 additions & 12 deletions Source/SourceTerms/ERF_make_sources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,20 +274,20 @@ void make_sources (int level,
const int nr = Rho_comp;
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real dzInv = (z_cc_arr) ? 1.0/ (z_cc_arr(i,j,k+1) - z_cc_arr(i,j,k-1)) : 0.5*dxInv[2];
Real T_hi = dptr_t_plane(k+1) / dptr_r_plane(k+1);
Real T_lo = dptr_t_plane(k-1) / dptr_r_plane(k-1);
Real wbar_cc = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
cell_src(i, j, k, n) -= cell_data(i,j,k,nr) * wbar_cc *
0.5 * (T_hi - T_lo) * dxInv[2];
cell_src(i, j, k, n) -= cell_data(i,j,k,nr) * wbar_cc * (T_hi - T_lo) * dzInv;
});
} else {
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real dzInv = (z_cc_arr) ? 1.0/ (z_cc_arr(i,j,k+1) - z_cc_arr(i,j,k-1)) : 0.5*dxInv[2];
Real T_hi = dptr_t_plane(k+1) / dptr_r_plane(k+1);
Real T_lo = dptr_t_plane(k-1) / dptr_r_plane(k-1);
Real wbar_cc = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
cell_src(i, j, k, n) -= wbar_cc *
0.5 * (T_hi - T_lo) * dxInv[2];
cell_src(i, j, k, n) -= wbar_cc * (T_hi - T_lo) * dzInv;
});
}
}
Expand All @@ -301,28 +301,26 @@ void make_sources (int level,
const int nr = Rho_comp;
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real dzInv = (z_cc_arr) ? 1.0/ (z_cc_arr(i,j,k+1) - z_cc_arr(i,j,k-1)) : 0.5*dxInv[2];
Real Qv_hi = dptr_qv_plane(k+1) / dptr_r_plane(k+1);
Real Qv_lo = dptr_qv_plane(k-1) / dptr_r_plane(k-1);
Real Qc_hi = dptr_qc_plane(k+1) / dptr_r_plane(k+1);
Real Qc_lo = dptr_qc_plane(k-1) / dptr_r_plane(k-1);
Real wbar_cc = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
cell_src(i, j, k, nv ) -= cell_data(i,j,k,nr) * wbar_cc *
0.5 * (Qv_hi - Qv_lo) * dxInv[2];
cell_src(i, j, k, nv+1) -= cell_data(i,j,k,nr) * wbar_cc *
0.5 * (Qc_hi - Qc_lo) * dxInv[2];
cell_src(i, j, k, nv ) -= cell_data(i,j,k,nr) * wbar_cc * (Qv_hi - Qv_lo) * dzInv;
cell_src(i, j, k, nv+1) -= cell_data(i,j,k,nr) * wbar_cc * (Qc_hi - Qc_lo) * dzInv;
});
} else {
ParallelFor(bx, [=] AMREX_GPU_DEVICE (int i, int j, int k) noexcept
{
Real dzInv = (z_cc_arr) ? 1.0/ (z_cc_arr(i,j,k+1) - z_cc_arr(i,j,k-1)) : 0.5*dxInv[2];
Real Qv_hi = dptr_qv_plane(k+1) / dptr_r_plane(k+1);
Real Qv_lo = dptr_qv_plane(k-1) / dptr_r_plane(k-1);
Real Qc_hi = dptr_qc_plane(k+1) / dptr_r_plane(k+1);
Real Qc_lo = dptr_qc_plane(k-1) / dptr_r_plane(k-1);
Real wbar_cc = 0.5 * (dptr_wbar_sub[k] + dptr_wbar_sub[k+1]);
cell_src(i, j, k, nv ) -= wbar_cc *
0.5 * (Qv_hi - Qv_lo) * dxInv[2];
cell_src(i, j, k, nv+1) -= wbar_cc *
0.5 * (Qc_hi - Qc_lo) * dxInv[2];
cell_src(i, j, k, nv ) -= wbar_cc * (Qv_hi - Qv_lo) * dzInv;
cell_src(i, j, k, nv+1) -= wbar_cc * (Qc_hi - Qc_lo) * dzInv;
});
}
}
Expand Down

0 comments on commit ad1f84d

Please sign in to comment.