AMReX-Astro / AMReX-Astro/Castro
RadSolve::levelFluxFaceToCenter uses wrong neighbor metric indexing and wrong denominator for `idim==1`
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 340
- Forks
- 105
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 8
Description
Location
Source/radiation/RadSolve.cpp:672, Source/radiation/RadSolve.cpp:678
Problem
r_rightis always computed from(i+1,j,k)regardless of direction (idim), which is incorrect for y/z fluxes.- In the
idim == 1branch, both terms divide byr_left; the second should divide byr_right.
Impact
- Incorrect geometry-weighted flux averaging in non-x directions.
- Potential directional bias / numerical error in radiation updates.
Steps to Reproduce
- Run a spherical/cylindrical radiation case where y/z fluxes are significant.
- Compare against a corrected implementation or symmetry expectation.
- Observe discrepancies in flux-centered quantities.
Expected Behavior
Neighbor metrics should be computed in the active dimension, and each face term should use its corresponding metric.
Actual Behavior
Right-face metric indexing is hardcoded to x-neighbor; y-branch uses r_left for both terms.
Proposed Fix
int in = i, jn = j, kn = k;
if (idim == 0) ++in;
else if (idim == 1) ++jn;
else ++kn;
edge_center_metric(i, j, k, idim, geomdata, r_left, s_left);
edge_center_metric(in, jn, kn, idim, geomdata, r_right, s_right);
if (idim == 0) {
t(i,j,k,it) = (f(i,j,k) / (r_left + 1.e-50_rt) + f(i+1,j,k) / r_right) * 0.5_rt;
} else if (idim == 1) {
t(i,j,k,it) = (f(i,j,k) / r_left + f(i,j+1,k) / r_right) * 0.5_rt;
} else {
t(i,j,k,it) = (f(i,j,k) + f(i,j,k+1)) * 0.5_rt;
}
Prepared by Codex.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Source/radiation/RadSolve.cpp:672 and :678 in RadSolve::levelFluxFaceToCenter. Check the neighbor metric indexing for each idim and the denominators used by the y branch, then compare a spherical or cylindrical radiation case against symmetry expectations. Done means the active-direction metrics and corresponding face denominators are used without directional bias.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100