Skip to content

Commit

Permalink
Merge pull request CEED#1297 from CEED/jed/fix-fluids-petsc-stage-log
Browse files Browse the repository at this point in the history
examples/fluids: fix deprecated/dysfunctional PetscLogGetStageLog
  • Loading branch information
jedbrown authored Aug 18, 2023
2 parents 4da3b05 + 711a423 commit 15642ec
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions examples/fluids/src/setupts.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q
PetscCall(TSGetTime(*ts, &start_time));
PetscCall(TSGetStepNumber(*ts, &start_step));

PetscCall(PetscLogDefaultBegin()); // So we can use PetscLogStageGetPerfInfo without -log_view
PetscPreLoadBegin(PETSC_FALSE, "Fluids Solve");
PetscCall(TSSetTime(*ts, start_time));
PetscCall(TSSetStepNumber(*ts, start_step));
Expand Down Expand Up @@ -547,12 +548,12 @@ PetscErrorCode TSSolve_NS(DM dm, User user, AppCtx app_ctx, Physics phys, Vec *Q
PetscCall(WriteOutput(user, *Q, step_no, final_time));
}

PetscLogStage stage_id;
PetscStageLog stage_log;
PetscLogStage stage_id;
PetscEventPerfInfo stage_perf;

PetscCall(PetscLogStageGetId("Fluids Solve", &stage_id));
PetscCall(PetscLogGetStageLog(&stage_log));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Time taken for solution (sec): %g\n", stage_log->stageInfo[stage_id].perfInfo.time));
PetscCall(PetscLogStageGetPerfInfo(stage_id, &stage_perf));
PetscCall(PetscPrintf(PETSC_COMM_WORLD, "Time taken for solution (sec): %g\n", stage_perf.time));
}
PetscFunctionReturn(PETSC_SUCCESS);
}

0 comments on commit 15642ec

Please sign in to comment.