From 6852f6f6cfb647134a2f70cbd6cc571acbeea4cb Mon Sep 17 00:00:00 2001 From: James Wright Date: Sat, 27 Jan 2024 10:06:59 -0700 Subject: [PATCH] fluids: Stats don't overwrite solution on first-step failure - When you have an initial condition from a previous problem, it might fail on the first step. This will cause `reason != TS_CONVERGED_ITERATING` and thus it will continue on with the rest of the TSMonitor routine. If you have a stats file from that initial condition, it will be overwritten. Regardless of the overwriting behavior, it *never* makes sense to write out a stats file on the first step; Using left-rectangle rule for the time averaging integration, the initial step should *never* be used, thus there is nothing to collect or write. --- examples/fluids/src/turb_spanstats.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/fluids/src/turb_spanstats.c b/examples/fluids/src/turb_spanstats.c index 5bd38732eb..9c12d59fbc 100644 --- a/examples/fluids/src/turb_spanstats.c +++ b/examples/fluids/src/turb_spanstats.c @@ -597,7 +597,7 @@ PetscErrorCode TSMonitor_TurbulenceStatistics(TS ts, PetscInt steps, PetscReal s PetscFunctionBeginUser; PetscCall(TSGetConvergedReason(ts, &reason)); // Do not collect or process on the first step of the run (ie. on the initial condition) - if (steps == user->app_ctx->cont_steps && reason == TS_CONVERGED_ITERATING) PetscFunctionReturn(PETSC_SUCCESS); + if (steps == user->app_ctx->cont_steps) PetscFunctionReturn(PETSC_SUCCESS); PetscBool run_processing_and_viewer = (steps % viewer_interval == 0 && viewer_interval != -1) || reason != TS_CONVERGED_ITERATING;