Skip to content

Commit

Permalink
fluids: Stats don't overwrite solution on first-step failure
Browse files Browse the repository at this point in the history
- 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.
  • Loading branch information
jrwrigh committed Jan 27, 2024
1 parent b698cfb commit 6852f6f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion examples/fluids/src/turb_spanstats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 6852f6f

Please sign in to comment.