[petsc-users] MAT_NEW_NONZERO_LOCATION_ERR
Zhang, Hong
hzhang at mcs.anl.gov
Tue Oct 8 10:18:09 CDT 2019
Thibaut :
Sorry, I did not explain it clearly. You call
MatSetOption(A,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE);
AFTER matrix is assembled. Then no more new zero is allowed to add/insert. For example, I add following in
petsc/src/ksp/ksp/examples/tutorials/ex1.c:
ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+ ierr = MatSetOption(A,MAT_NEW_NONZERO_LOCATION_ERR,PETSC_TRUE);CHKERRQ(ierr);
+ i = 0; col[0] = 2;
+ ierr = MatSetValues(A,1,&i,2,col,value,INSERT_VALUES);CHKERRQ(ierr);
+ ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+ ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
+
Then the code crashes with
0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Inserting a new nonzero at (0,2) in the matrix.
Adding entries to the tridiagonal works.
Hong
Well, try and create a small SEQAIJ/MPIAIJ matrix and preallocate memory for the diagonal.
When I try to call MatSetValues to fill the diagonal, on the first row I get
[0]PETSC ERROR: Argument out of range
[0]PETSC ERROR: Inserting a new nonzero at (0,0) in the matrix
Which is within my preallocated non-zero structure.
This is why I'm confused.
Thibaut
On 08/10/2019 15:31, Zhang, Hong wrote:
Thibaut:
Hi,
Just out of curiosity, I'm a bit confused by the parameter option
MAT_NEW_NONZERO_LOCATION_ERR.
It triggers an error if you try to insert/add a value in the non-zero
structure, regardless of the matrix preallocation status. In what case
would such an option be useful?
It triggers an error if you try to insert/add a NEW value outside of your preallocated non-zero structure.
Hong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20191008/1ae015bf/attachment.html>
More information about the petsc-users
mailing list