[petsc-dev] PETSc release soon, request for input on needed fixes or enhancements

Matthew Knepley knepley at gmail.com
Wed Mar 16 21:35:25 CDT 2016


On Wed, Mar 16, 2016 at 2:40 PM, Barry Smith <bsmith at mcs.anl.gov> 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.

   Matt


>
>   Barry
>
>
>
> > On Mar 16, 2016, at 2:18 PM, Lawrence Mitchell <
> lawrence.mitchell at imperial.ac.uk> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20160316/94401610/attachment.html>


More information about the petsc-dev mailing list