From d165f1a9d885e830de26f817a953aedcf49ecba5 Mon Sep 17 00:00:00 2001 From: nscepi Date: Thu, 27 Aug 2026 10:31:24 +0200 Subject: [PATCH 1/2] Move CheckNan to end of loop on stages in timeIntegrator CheckNan was previously located after EvolveStage. However, EvolveStage updates the conservative variables and CheckNan checks the primitive variables. This reports the detection of a NaN to the next cycle. By moving CheckNan to the end of the loop on stages in timeIntegrator, so after the ConsToPrim, this PR ensures that we detect the NaN at the right cycle. --- src/timeIntegrator.cpp | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/timeIntegrator.cpp b/src/timeIntegrator.cpp index 6ffb6acfb..6471887f4 100644 --- a/src/timeIntegrator.cpp +++ b/src/timeIntegrator.cpp @@ -301,14 +301,6 @@ void TimeIntegrator::Cycle(DataBlock &data) { // evolve dt accordingly data.t += data.dt; - // Look for Nans every now and then (this actually cost a lot of time on GPUs - // because streams are divergent) - if(ncycles%checkNanPeriodicity==0) { - if(data.CheckNan()>0) { - throw std::runtime_error(std::string("Nan found after integration cycle")); - } - } - // Compute next time_step during first stage if(stage==0) { if(!haveFixedDt) { @@ -347,7 +339,15 @@ void TimeIntegrator::Cycle(DataBlock &data) { // Add back fargo velocity so that boundary conditions are applied on the total V if(data.haveFargo) data.fargo->AddVelocity(data.t); - } + + // Look for Nans every now and then (this actually cost a lot of time on GPUs + // because streams are divergent) + if(ncycles%checkNanPeriodicity==0) { + if(data.CheckNan()>0) { + throw std::runtime_error(std::string("Nan found after integration cycle")); + } + } + } ///////////////////////////////////////////////// // END STAGES LOOP // ///////////////////////////////////////////////// From 9c6021b736e52a9f3fab02805667ec62f25ce322 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Thu, 27 Aug 2026 11:47:28 +0000 Subject: [PATCH 2/2] [pre-commit.ci lite] apply automatic fixes --- src/timeIntegrator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/timeIntegrator.cpp b/src/timeIntegrator.cpp index 6471887f4..9d940feec 100644 --- a/src/timeIntegrator.cpp +++ b/src/timeIntegrator.cpp @@ -339,7 +339,7 @@ void TimeIntegrator::Cycle(DataBlock &data) { // Add back fargo velocity so that boundary conditions are applied on the total V if(data.haveFargo) data.fargo->AddVelocity(data.t); - + // Look for Nans every now and then (this actually cost a lot of time on GPUs // because streams are divergent) if(ncycles%checkNanPeriodicity==0) {