> On Mar 16, 2016, at 9:35 PM, Matthew Knepley <[email protected]> wrote: > > On Wed, Mar 16, 2016 at 2:40 PM, Barry Smith <[email protected]> wrote: > > Thanks. This is definitely a bug, but very different from my understanding > of what was reported (which is why one should always tell someone how to > reproduce a problem in a bug report). It is because the PushFormat is done > regardless of whether it is a new viewer or just the same viewer being set > again. > > Absolutely needs to be fixed. I don't like the idea of cluttering up the > object landscape of PETSc even more by adding new objects such as "viewer > plus format" as was suggested. > > I need to think about a way to fix this that results in less cluttered > code, nor more cluttered code. > > To me it seems like this PushFormat is occurring in completely the wrong > place. For example > > PetscErrorCode KSPMonitorSetFromOptions(KSP ksp,const char name[],const char > help[], const char manual[],PetscErrorCode > (*monitor)(KSP,PetscInt,PetscReal,void*)) > { > ierr = > PetscOptionsGetViewer(PetscObjectComm((PetscObject)ksp),((PetscObject)ksp)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr); > if (flg) { > ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr); > ierr = KSPMonitorSet(ksp,monitor,viewer,(PetscErrorCode > (*)(void**))PetscViewerDestroy);CHKERRQ(ierr); > } > } > > This clearly cannot be what we want because two monitors of different formats > cannot coexist on the same Viewer, > even if its a shared Viewer like PETSC_VIEWER_ASCII_WORLD. I think the format > should be passed to MonitorSet, > and put into the monitor struct (someone likes arrays more then structs): > > ksp->monitorformats[ksp->numbermonitors] = format; > > and then the monitor call should push and pop the format around the monitor > routine.
Sure, it is just a question of writing the simplest clean code that does this. > > Matt > > > Barry > > > > > On Mar 16, 2016, at 2:18 PM, Lawrence Mitchell > > <[email protected]> wrote: > > > > > > > > On 16/03/16 18:56, Barry Smith wrote: > >> > >> Please send me a command line option and example (one in the repository?) > >> where this problem happens. > > > > I had slightly misread the code (MG setup doesn't call > > KSPSetFromOptions more than once even when PCSetUP_MG is called > > again), but here is an example: > > > > cd src/ts/examples/tutorials > > make ex26 > > ./ex26 -da_refine 1 -ts_max_steps 10 -ts_rtol 1e-3 -ts_atol 1e-3 > > -ts_type beuler -pc_type asm -pc_asm_blocks 30 -sub_ksp_type > > richardson -sub_ksp_monitor > > > > Cheers, > > > > Lawrence > > > > > > > > > -- > What most experimenters take for granted before they begin their experiments > is infinitely more interesting than any results to which their experiments > lead. > -- Norbert Wiener
