Matrix blocks

Michel Cancelliere fernandez858 at gmail.com
Tue Sep 9 07:05:38 CDT 2008


Ok, I'm using MatGetSubMatrix() with the following piece of code

PetscErrorCode SampleShellPCSetUp(SampleShellPC *shell,Mat pmat,Vec x)
{
  Mat            *submat[4];
  PetscErrorCode ierr;
  PetscInt       N;
  IS             set1[4],set2[4];



  ierr = VecGetSize(x,&N);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set1[0]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set2[0]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set1[1]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set2[1]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set1[2]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,0,1,&set2[2]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set1[3]);CHKERRQ(ierr);
  ierr = ISCreateStride(PETSC_COMM_SELF,N/2,N/2,1,&set2[3]);CHKERRQ(ierr);
  ierr =
MatGetSubMatrices(pmat,4,set1,set2,MAT_INITIAL_MATRIX,submat);CHKERRQ(ierr);

but it seems to get only the first of the subblocks,

am I using the correct syntax for the MatGetSubMatrices function?

Thank you

On Fri, Sep 5, 2008 at 2:42 PM, Matthew Knepley <knepley at gmail.com> wrote:

> You can extract matrix blocks using MatGetSubMatrix().
>
>   Matt
>
> On Fri, Sep 5, 2008 at 6:50 AM, Michel Cancelliere
> <fernandez858 at gmail.com> wrote:
> > Hi All,
> >
> > I am building a shell preconditioner, for implement that I should divide
> a
> > sparse matrix into four blocks of dimension N/2xN/2 (N size of the
> Matrix),
> > I took a look to src/mat/examples/tutorials/ex2 but it is for dense
> matrix.
> > There is a function for do that in Petsc? or another method for
> efficiently
> > implementation?
> >
> > Thank you,
> >
> > Michel Cancelliere
> >
>
>
>
> --
> 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-users/attachments/20080909/5a28972f/attachment.htm>


More information about the petsc-users mailing list