fix species flux summing so final Dnp1 isnt double counted#609
fix species flux summing so final Dnp1 isnt double counted#609baperry2 merged 2 commits intoAMReX-Combustion:developmentfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where species fluxes were being double-counted during the final SDC (Spectral Deferred Correction) iteration. The issue occurred because computeDifferentialDiffusionTerms was being called both during the final SDC iteration and again after the SDC loop completed, with the member variable m_sdcIter still equal to m_nSDCmax, causing the flux tracking condition to trigger twice.
Key Changes:
- Modified the SDC iteration loop to use the member variable
m_sdcIterdirectly as the loop counter instead of a local variable - Removed the assignment
m_sdcIter = sdcIterfrom within theoneSDC()function - This ensures that after the loop completes,
m_sdcIterequalsm_nSDCmax + 1, preventing the spurious flux addition in the post-SDCcalcDivU()call
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
drummerdoc
left a comment
There was a problem hiding this comment.
This seems to avoid the observed issue, but I'm concerned about the level of "corporate knowledge" needed to understand what's happening here. Would it be easier to understand if there was a variable a_sdc_diffTerm_weight that was passed in by caller so that the intention is stated clearly?
|
Using |
|
@drummerdoc I implemented your suggestion. |
|
Nice. Thanks! |
|
@d-montgomery and @SreejithNREL: this may slightly impact the mass flow rate calculations for the SATF cases. |
Thanks for the heads up @baperry2 ! |
In$D^n$ and $D^{n+1,k}$ ) in the species diffusion update below).
PeleLM::computeDifferentialDiffusionTermswe do a check on whether we are at the 0th or final SDC iteration to determine whether the species fluxes computed should be added for flux tracking purposes (However,
PeleLM::computeDifferentialDiffusionTermsalso gets called after the SDC iteration loop while computing the final divu for the velocity update. Currently, this trips the check on being at the final SDC iteration, and the flux is spuriously added into the flux trackers for a second time. This PR fixes the issue by changing the SDC iteration loop to directly updatem_sdcIter, so once the SDC iteration loop completes this value exceeds m_nSDCmax and the check does not trip.Hat tip to @wengzf20 for catching this in #608. @wengzf20 please confirm this change addresses the issue you are seeing.