[petsc-users] petscviewerduplicate?
Nachiket Gokhale
gokhalen at gmail.com
Wed Mar 20 13:28:53 CDT 2013
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
More information about the petsc-users
mailing list