[petsc-users] MATSBAIJ set up
Matthew Knepley
knepley at gmail.com
Thu Mar 31 11:11:32 CDT 2016
On Thu, Mar 31, 2016 at 11:03 AM, Matthew Overholt <overholt at capesim.com>
wrote:
> 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,NULL,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.
>
I would start by making AIJ work in parallel. The switch to SBAIJ is then
fairly easy.
The error appears to say that you have incorrectly allocated the number of
nonzeros in the diagonal block.
Matt
> Thanks,
>
> Matt Overholt
>
> CapeSym, Inc.
>
>
>
>
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2115-v2-b> Virus-free.
> www.avast.com
> <https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient&utm_term=oa-2115-v2-b>
>
--
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/20160331/b356eb2a/attachment.html>
More information about the petsc-users
mailing list