Gideon Simpson <[email protected]> writes: >> If you created a viewer, you need to destroy it. > > But the destruction of the viewer is handled by the TSMonitor routine, and > not done manually, with a PetscViewerDestroy routine?
TS monitoring calls the destroy function that you passed to TSMonitorSet. > What I find confusing about that, though, is that you call > PetscViewerBinaryOpen with &ctx, a pointer to the viewer object, and this > makes sense, because the command is: > > PetscErrorCode PetscViewerBinaryOpen(MPI_Comm comm,const char > name[],PetscFileMode type,PetscViewer *binv) You're creating the PetscViewer. C has pass-by-value semantics, so if you want to change the handle, you have to &viewer. > but for TSMonitorSet and TSMonitorSolutionBinary, it’s written as: > PetscErrorCode TSMonitorSet(TS ts,PetscErrorCode > (*monitor)(TS,PetscInt,PetscReal,Vec,void*),void *mctx,PetscErrorCode > (*mdestroy)(void**)) > PetscErrorCode TSMonitorSolutionBinary(TS ts,PetscInt step,PetscReal > ptime,Vec u,void *viewer) > which makes it look like i should be passing an &ctx, and not the ct. itself. > But this is a minor point. One works, and one doesn't The context can be any (pointer) type, so we write void*. In this case, it's a typedef struct _p_PetscViewer *PetscViewer; > I was more interested in -ts_monitor. I suppose I just need to do string > processing on that to get the actual times. Sure, or have your own monitor print whatever information you want. I like -ts_adapt_monitor for debugging -- lots more information.
signature.asc
Description: PGP signature
