Gideon Simpson <[email protected]> writes: > I had two questions on time stepping routines: > > 1. What’s the proper usage of TSMonitorSolutionBinary? As near as I can > tell from source, I need to call: > > PetscViewerBinaryOpen(PETSC_COMM_WORLD, "sim.bin",FILE_MODE_WRITE, &viewer); > > TSMonitorSet(ts, TSMonitorSolutionBinary, viewer,(PetscErrorCode > (*)(void**))PetscViewerDestroy); > > I’m guessing it’s necessary to include the PetscViewerDestroy command?
If you created a viewer, you need to destroy it.
> Also, is there a reason why I’m not passing a pointer to the viewer,
> but rather just the view itself?
All PETSc objects are pointers.
ierr = PetscOptionsString("-ts_monitor_solution_binary","Save each solution
to a binary
file","TSMonitorSolutionBinary",0,monfilename,PETSC_MAX_PATH_LEN,&flg);CHKERRQ(ierr);
if (flg) {
PetscViewer ctx;
if (monfilename[0]) {
ierr =
PetscViewerBinaryOpen(PetscObjectComm((PetscObject)ts),monfilename,FILE_MODE_WRITE,&ctx);CHKERRQ(ierr);
ierr = TSMonitorSet(ts,TSMonitorSolutionBinary,ctx,(PetscErrorCode
(*)(void**))PetscViewerDestroy);CHKERRQ(ierr);
} else {
ctx = PETSC_VIEWER_BINARY_(PetscObjectComm((PetscObject)ts));
ierr = TSMonitorSet(ts,TSMonitorSolutionBinary,ctx,(PetscErrorCode
(*)(void**))NULL);CHKERRQ(ierr);
}
}
> 2. Is there a built in way to track the time steps that the TS solver takes?
> Assuming it’s using adaptivity, this could be variable. I imagine I could
> use a TSMonitor routine to print it to the screen, but is there some way to
> get it into a file?
Do you want output from -ts_monitor or -ts_adapt_monitor? The former
takes a filename argument and the latter probably should (instead of
just beeing a boolean).
signature.asc
Description: PGP signature
