AMReX-Astro / AMReX-Astro/Castro

Saved SDC fluxes omit the endpoint contribution

Open
#3,399 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ai-code-audit sdc
Dominant language
C++
Stars
340
Forks
105
Avg merge
3d 8h
Merged PRs (30d)
8

Description

Locations: Source/driver/Castro_advance_sdc.cpp:86-87 and
Source/hydro/Castro_mol_hydro.cpp:681-711.

Finding

The driver skips the final time node on the final SDC sweep. The MOL routine
saves nonzero-node fluxes only on that final sweep. Thus the last node's flux is
never saved, despite its nonzero quadrature weight for every supported node set.

For SDC2 Lobatto, a constant flux F is stored as dt*F/2, since only node zero
contributes. SDC4 Lobatto stores 5*dt*F/6. The state update still uses the
old-sweep endpoint RHS, so its flux divergence is not represented by the saved
flux data. P_radial uses the same flawed condition.

Scope and evidence

This is a confirmed bookkeeping defect from the stage conditions and weights in
Source/driver/Castro_setup.cpp:1085-1132. True SDC currently rejects AMR, so
it should not be described as a demonstrated AMR conservation failure. It would
corrupt refluxing if those buffers were used for AMR without fixing this
inconsistency. The local state update does not use the incomplete saved flux
sum.

The numerical check script verifies the missing constant-flux weights.

Proposed fix

Retain node fluxes alongside the old and new advective RHS and form the final
integrated flux using the same correction formula as the state update. For a
final sweep, sum the old-sweep quadrature flux and the explicit subinterval
corrections h_m*(F_new[m]-F_old[m]). Apply the identical logic to P_radial.
Merely evaluating the final node once more fills the obvious hole but does not
make arbitrary unconverged sweeps' saved fluxes match their actual updates.

Validation after fixing

First verify that constant flux integrates to dt*F for all node sets. Then
compare the divergence of the saved integrated flux against the source-free
state change, including cases with a small number of sweeps. Validate the
pressure contribution separately in non-Cartesian geometry.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the stage conditions and weights in Source/driver/Castro_setup.cpp:1085-1132, then trace the final-sweep logic at Source/driver/Castro_advance_sdc.cpp:86-87 and Source/hydro/Castro_mol_hydro.cpp:681-711. Compare the saved flux and P_radial calculations with the state-update correction formula. Done means constant flux integrates to dt*F for every node set and the saved-flux divergence matches source-free state changes, including few-sweep and non-Cartesian pressure cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.