<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Mar 16, 2016 at 2:40 PM, Barry Smith <span dir="ltr"><<a href="mailto:bsmith@mcs.anl.gov" target="_blank">bsmith@mcs.anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><br>
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.<br>
<br>
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.<br>
<br>
I need to think about a way to fix this that results in less cluttered code, nor more cluttered code.</blockquote><div><br></div><div>To me it seems like this PushFormat is occurring in completely the wrong place. For example</div><div><br></div><div><div>PetscErrorCode KSPMonitorSetFromOptions(KSP ksp,const char name[],const char help[], const char manual[],PetscErrorCode (*monitor)(KSP,PetscInt,PetscReal,void*))</div><div>{</div><div> ierr = PetscOptionsGetViewer(PetscObjectComm((PetscObject)ksp),((PetscObject)ksp)->prefix,name,&viewer,&format,&flg);CHKERRQ(ierr);<br></div><div> if (flg) {</div><div> ierr = PetscViewerPushFormat(viewer,format);CHKERRQ(ierr);</div><div> ierr = KSPMonitorSet(ksp,monitor,viewer,(PetscErrorCode (*)(void**))PetscViewerDestroy);CHKERRQ(ierr);</div><div> }</div><div>}<br></div></div><div><br></div><div>This clearly cannot be what we want because two monitors of different formats cannot coexist on the same Viewer,</div><div>even if its a shared Viewer like PETSC_VIEWER_ASCII_WORLD. I think the format should be passed to MonitorSet,</div><div>and put into the monitor struct (someone likes arrays more then structs):</div><div><br></div><div> ksp->monitorformats[ksp->numbermonitors] = format;</div><div><br></div><div>and then the monitor call should push and pop the format around the monitor routine.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class=""><font color="#888888"><br>
Barry<br>
</font></span><div class=""><div class="h5"><br>
<br>
<br>
> On Mar 16, 2016, at 2:18 PM, Lawrence Mitchell <<a href="mailto:lawrence.mitchell@imperial.ac.uk">lawrence.mitchell@imperial.ac.uk</a>> wrote:<br>
><br>
><br>
><br>
> On 16/03/16 18:56, Barry Smith wrote:<br>
>><br>
>> Please send me a command line option and example (one in the repository?) where this problem happens.<br>
><br>
> I had slightly misread the code (MG setup doesn't call<br>
> KSPSetFromOptions more than once even when PCSetUP_MG is called<br>
> again), but here is an example:<br>
><br>
> cd src/ts/examples/tutorials<br>
> make ex26<br>
> ./ex26 -da_refine 1 -ts_max_steps 10 -ts_rtol 1e-3 -ts_atol 1e-3<br>
> -ts_type beuler -pc_type asm -pc_asm_blocks 30 -sub_ksp_type<br>
> richardson -sub_ksp_monitor<br>
><br>
> Cheers,<br>
><br>
> Lawrence<br>
><br>
><br>
<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature">What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div>
</div></div>