Skip to content

Commit

Permalink
Merge pull request #1134 from CEED/jed/fluids-ts-reason-no-error
Browse files Browse the repository at this point in the history
fluids: report TS converged reason and exit cleanly
  • Loading branch information
jedbrown committed Jan 7, 2023
2 parents bada406 + 65fa31e commit 0d157ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
8 changes: 8 additions & 0 deletions examples/fluids/navierstokes.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,14 @@ int main(int argc, char **argv) {
" DM VecType : %s\n"
" Time Stepping Scheme : %s\n",
box_faces_str, mat_type, vec_type, phys_ctx->implicit ? "implicit" : "explicit"));
if (app_ctx->cont_steps) {
PetscCall(PetscPrintf(comm,
" Continue:\n"
" Filename: : %s\n"
" Step: : %" PetscInt_FMT "\n"
" Time: : %g\n",
app_ctx->cont_file, app_ctx->cont_steps, app_ctx->cont_time));
}
// Mesh
const PetscInt num_comp_q = 5;
CeedInt glob_dofs, owned_dofs;
Expand Down
7 changes: 5 additions & 2 deletions examples/fluids/src/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,8 @@ PetscErrorCode GetError_NS(CeedData ceed_data, DM dm, User user, Vec Q, PetscSca

// Post-processing
PetscErrorCode PostProcess_NS(TS ts, CeedData ceed_data, DM dm, ProblemData *problem, User user, Vec Q, PetscScalar final_time) {
PetscInt steps;
PetscInt steps;
TSConvergedReason reason;
PetscFunctionBegin;

// Print relative error
Expand All @@ -174,8 +175,10 @@ PetscErrorCode PostProcess_NS(TS ts, CeedData ceed_data, DM dm, ProblemData *pro

// Print final time and number of steps
PetscCall(TSGetStepNumber(ts, &steps));
PetscCall(TSGetConvergedReason(ts, &reason));
if (!user->app_ctx->test_mode) {
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Time integrator took %" PetscInt_FMT " time steps to reach final time %g\n", steps, (double)final_time));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Time integrator %s on time step %" PetscInt_FMT " with final time %g\n", TSConvergedReasons[reason],
steps, (double)final_time));
}

// Output numerical values from command line
Expand Down
1 change: 1 addition & 0 deletions examples/fluids/src/setupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q
}
PetscCall(TSSetMaxTime(*ts, 500. * user->units->second));
PetscCall(TSSetExactFinalTime(*ts, TS_EXACTFINALTIME_STEPOVER));
PetscCall(TSSetErrorIfStepFails(*ts, PETSC_FALSE));
PetscCall(TSSetTimeStep(*ts, 1.e-2 * user->units->second));
if (app_ctx->test_mode) {
PetscCall(TSSetMaxSteps(*ts, 10));
Expand Down

0 comments on commit 0d157ec

Please sign in to comment.