Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix the subch_planar diag for cylindrical coords #2885

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions Exec/science/subch_planar/Problem_Derive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,15 @@ void ca_dergradpoverp1(const Box& bx, FArrayBox& derfab, int /*dcomp*/, int /*nc
Real vm = dat(i,j-1,k,UMY) / dat(i,j-1,k,URHO);
Real v0 = dat(i,j,k,UMY) / dat(i,j,k,URHO);

Real du_x{};
Real dv_y{};

// construct div{U}
if (coord_type == 0) {

// Cartesian
div_u += 0.5_rt * (up - um) * dxinv;
div_u += 0.5_rt * (vp - vm) * dyinv;
du_x = 0.5_rt * (up - um) * dxinv;
dv_y = 0.5_rt * (vp - vm) * dyinv;

} else if (coord_type == 1) {

Expand All @@ -287,15 +290,17 @@ void ca_dergradpoverp1(const Box& bx, FArrayBox& derfab, int /*dcomp*/, int /*nc
Real rm = (i - 1 + 0.5_rt) * dx[0];
Real rp = (i + 1 + 0.5_rt) * dx[0];

div_u += 0.5_rt * (rp * up - rm * um) / (rc * dx[0]) +
0.5_rt * (vp - vm) * dyinv;
du_x = 0.5_rt * (rp * up - rm * um) / (rc * dx[0]);
dv_y = 0.5_rt * (vp - vm) * dyinv;

#ifndef AMREX_USE_GPU
} else {
amrex::Error("ERROR: invalid coord_type in shock");
#endif
}

div_u = du_x + dv_y;

// we need to compute p in the full stencil

Real p_ip1{};
Expand Down Expand Up @@ -399,12 +404,12 @@ void ca_dergradpoverp1(const Box& bx, FArrayBox& derfab, int /*dcomp*/, int /*nc
Real dP_y = 0.5_rt * (p_jp1 - p_jm1);

//Real gradPdx_over_P = std::sqrt(dP_x * dP_x + dP_y * dP_y + dP_z * dP_z) / dat(i,j,k,QPRES);
Real du_x = std::min(up - um, 0.0);
Real dv_y = std::min(vp - vm, 0.0);
Real cdu_x = std::min(du_x, 0.0);
Real cdv_y = std::min(dv_y, 0.0);

Real divu_mag = std::sqrt(du_x * du_x + dv_y * dv_y + 1.e-30);
Real divu_mag = std::sqrt(cdu_x * cdu_x + cdv_y * cdv_y + 1.e-30);

Real gradPdx_over_P = std::abs(dP_x * du_x + dP_y * dv_y) / divu_mag;
Real gradPdx_over_P = std::abs(dP_x * cdu_x + dP_y * cdv_y) / divu_mag;
gradPdx_over_P /= p_zone;

der(i,j,k,0) = gradPdx_over_P;
Expand Down