[petsc-users] petscviewerduplicate?
Jed Brown
jedbrown at mcs.anl.gov
Wed Mar 20 13:35:56 CDT 2013
Just make a function that creates viewers like this, then call it to create
two independent viewers that are configured similarly except for the file
name. I don't think this makes sense in the library.
On Wed, Mar 20, 2013 at 1:28 PM, Nachiket Gokhale <gokhalen at gmail.com>wrote:
> I have this in my code:
>
> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&RightViewer);CHKERRQ(ierr);
> ierr = PetscViewerSetType(RightViewer,PETSCVIEWERASCII);CHKERRQ(ierr);
> ierr = PetscViewerFileSetMode(RightViewer,FILE_MODE_WRITE);CHKERRQ(ierr);
> ierr =
> PetscViewerSetFormat(RightViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
>
> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&LeftViewer);CHKERRQ(ierr);
> ierr = PetscViewerSetType(LeftViewer,PETSCVIEWERASCII);CHKERRQ(ierr);
> ierr = PetscViewerFileSetMode(LeftViewer,FILE_MODE_WRITE);CHKERRQ(ierr);
> ierr =
> PetscViewerSetFormat(LeftViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
>
> It would have been nice to create the LeftViewer from the RightViewer.
> That is what I am trying to do.
>
> At other places I use only one viewer to output left and right matrices:
>
> // projection matrices in ascii
> ierr = PetscViewerCreate(PETSC_COMM_WORLD,&ProjMatViewer);CHKERRQ(ierr);
> ierr = PetscViewerSetType(ProjMatViewer,PETSCVIEWERASCII);CHKERRQ(ierr);
> ierr =
> PetscViewerFileSetMode(ProjMatViewer,FILE_MODE_WRITE);CHKERRQ(ierr);
> ierr =
> PetscViewerSetFormat(ProjMatViewer,PETSC_VIEWER_ASCII_MATLAB);CHKERRQ(ierr);
> // right
> ierr =
> PetscViewerFileSetName(ProjMatViewer,projfileasciiright);CHKERRQ(ierr);
> ierr = MatView(ProjMatRight,ProjMatViewer);CHKERRQ(ierr);
> // left
> ierr =
> PetscViewerFileSetName(ProjMatViewer,projfileasciileft);CHKERRQ(ierr);
> ierr = MatView(ProjMatLeft,ProjMatViewer);CHKERRQ(ierr);
> // destroy
> ierr = PetscViewerDestroy(&ProjMatViewer);CHKERRQ(ierr);
>
> But I think switching the filename is inconvenient - I'd rather create
> a separate viewer Left and Right Matrices and have it copy the same
> parameters from an already created viewer.
>
> -Nachiket
>
> On Wed, Mar 20, 2013 at 2:16 PM, Jed Brown <jedbrown at mcs.anl.gov> wrote:
> > What would it mean to duplicate a viewer? What are you actually trying to
> > do?
> >
> > On Mar 20, 2013 12:59 PM, "Nachiket Gokhale" <gokhalen at gmail.com> wrote:
> >>
> >> Not a show stopper, but would it be possible to add a
> >> PetscViewerDuplicate function? I don't see such a function here -
> >>
> >>
> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Viewer/index.html
> >>
> >> Cheers, -Nachiket
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20130320/ac7672b4/attachment.html>
More information about the petsc-users
mailing list