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 divu when theta=0 or pi #2975

Merged
merged 1 commit into from
Oct 14, 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
16 changes: 11 additions & 5 deletions Source/hydro/advection_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,12 +310,18 @@ Castro::divu(const Box& bx,
// Finite difference to get divergence. ux = 1/r^2 d/dr(r^2 * u)
ux = (ur * rr * rr - ul * rl * rl) * dxinv / (rc * rc);

// These are transverse averages in the x-direction
Real vb = 0.5_rt * (q_arr(i,j-1,k,QV) + q_arr(i-1,j-1,k,QV));
Real vt = 0.5_rt * (q_arr(i,j,k,QV) + q_arr(i-1,j,k,QV));
// If sinc == 0, then vy goes inf.
// But due to Phi-symmetry, vt*sint = vb*sinb, so set to 0.
if (sinc == 0.0_rt) {
vy = 0.0_rt;
} else {
// These are transverse averages in the x-direction
Real vb = 0.5_rt * (q_arr(i,j-1,k,QV) + q_arr(i-1,j-1,k,QV));
Real vt = 0.5_rt * (q_arr(i,j,k,QV) + q_arr(i-1,j,k,QV));

// Finite difference to get divergence. vy = 1/(r sin) * d/dtheta(v sin)
vy = (vt * sint - vb * sinb) * dyinv / (rc * sinc);
// Finite difference to get divergence. vy = 1/(r sin) * d/dtheta(v sin)
vy = (vt * sint - vb * sinb) * dyinv / (rc * sinc);
}
}

div(i,j,k) = ux + vy;
Expand Down