[petsc-users] How to write and load a SEQSBAIJ matrix?

Barry Smith bsmith at mcs.anl.gov
Mon Mar 1 10:50:57 CST 2010


On Mar 1, 2010, at 5:21 AM, Zhifeng Sheng - EWI wrote:

> Dear all
>
> I am trying to generate a system and save it for later usage... I  
> used the function MatView and Matload. they work perfectly with  
> SEQAIJ  matrix
>
> but when comes to symmetric SEQSBAIJ matrix, they do work. It seems  
> that MatView does not put any information into the *.info file..
>

    Sorry, this is our mistake. If you edit src/mat/impls/sbaij/seq/ 
sbaij.c and replace the function
#undef __FUNCT__
#define __FUNCT__ "MatView_SeqSBAIJ"
PetscErrorCode MatView_SeqSBAIJ(Mat A,PetscViewer viewer)
{
   PetscErrorCode ierr;
   PetscTruth     iascii,isdraw;
   FILE           *file = 0;

   PetscFunctionBegin;
   ierr =  
PetscTypeCompare 
((PetscObject)viewer,PETSC_VIEWER_ASCII,&iascii);CHKERRQ(ierr);
   ierr =  
PetscTypeCompare 
((PetscObject)viewer,PETSC_VIEWER_DRAW,&isdraw);CHKERRQ(ierr);
   if (iascii){
     ierr = MatView_SeqSBAIJ_ASCII(A,viewer);CHKERRQ(ierr);
   } else if (isdraw) {
     ierr = MatView_SeqSBAIJ_Draw(A,viewer);CHKERRQ(ierr);
   } else {
     Mat B;
     ierr = MatConvert(A,MATSEQAIJ,MAT_INITIAL_MATRIX,&B);CHKERRQ(ierr);
     ierr = MatView(B,viewer);CHKERRQ(ierr);
     ierr = MatDestroy(B);CHKERRQ(ierr);
     ierr = PetscViewerBinaryGetInfoPointer(viewer,&file);CHKERRQ(ierr);
     if (file) {
       fprintf(file,"-matload_block_size %d\n",(int)A->rmap->bs);
     }
   }
   PetscFunctionReturn(0);
}
and run make in that directory it will now save the block size.

    Thanks for pointing out the problem,

    Barry


>
> Does any know how to write and load a SEQSBAIJ matrix?
>
> Thanks and best regards
> Zhifeng
>



More information about the petsc-users mailing list