[petsc-users] time stepping questions
Jed Brown
jed at jedbrown.org
Tue Mar 10 09:30:03 CDT 2015
Gideon Simpson <gideon.simpson at gmail.com> 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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20150310/1c359e08/attachment.pgp>
More information about the petsc-users
mailing list