[petsc-users] MATSBAIJ set up

Matthew Overholt overholt at capesim.com
Thu Mar 31 11:03:30 CDT 2016


Hi,

 

I am just getting started with PETSc and am having difficulty with setting
up my MATSBAIJ matrix.  I'm adapting the ksp/ex23.c example to my 3D FEM
calculation; in my case the equation to solve is K*x = b.

 

For serial execution, the following works fine and gives the correct answer.

   ierr = MatCreate(PETSC_COMM_WORLD,&K);CHKERRQ(ierr);

   ierr = MatSetSizes(K,vlocal,vlocal,neqns,neqns);CHKERRQ(ierr);

   ierr = MatSetType(K,MATSBAIJ);CHKERRQ(ierr);                // symmetric,
block, sparse

   ierr = MatSetOption(K,MAT_SPD,PETSC_TRUE);CHKERRQ(ierr);    // K is
symmetric, positive-definite, sparse

   ierr =
MatSetOption(K,MAT_IGNORE_LOWER_TRIANGULAR,PETSC_TRUE);CHKERRQ(ierr);    //
so only top tri is needed

   ierr = MatSetUp(K);CHKERRQ(ierr);

where  vlocal is the result from the call to  VecGetLocalSize(x,&vlocal) for
the solution vector (obviously the full size in the serial case).

However, for parallel execution the above crashes on a 11 SEGV Segmentation
Violation Error on entry to the function MatSetOption_MPISBAIJ(), according
to TotalView.

 

So instead I have been trying the following for parallel.

   PetscInt blockSize = 1;         // use a block size of 1 since K is NOT
block symmetric

   PetscInt diagNZ = 5;            // # of non-zeros per row in upper
diagonal portion of local submatrix

   PetscInt offdiagNZ = 8;         // max # of non-zeros per row in
off-diagonal portion of local submatrix

   ierr =
MatCreateSBAIJ(PETSC_COMM_WORLD,blockSize,vlocal,vlocal,neqns,neqns,diagNZ,N
ULL,offdiagNZ,NULL,&K);CHKERRQ(ierr);

   ierr = MatSetOption(K,MAT_SPD,PETSC_TRUE);CHKERRQ(ierr);    // K is
symmetric, positive-definite, sparse

   ierr =
MatSetOption(K,MAT_IGNORE_LOWER_TRIANGULAR,PETSC_TRUE);CHKERRQ(ierr);    //
so only top tri is needed

   ierr = MatSetUp(K);CHKERRQ(ierr);

However, this fails during the process of setting matrix values
(MatSetValue()) with the following error:

[0]PETSC ERROR: Argument out of range

[0]PETSC ERROR: new nonzero at (0,26) caused a malloc

.

(Note that in this case the matrix size is 96x96 split over 2 processors
(vlocal = 48).)

 

If someone would please point me to the correct way to set up the (MATSBAIJ)
matrix for a perfectly symmetric, positive-definite, sparse system, I'd
appreciate it.

 

Thanks,

Matt Overholt

CapeSym, Inc.

 



---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20160331/6f36ad81/attachment-0001.html>


More information about the petsc-users mailing list