A point on documentation of MatSetValuesBlocked

Umut Tabak u.tabak at tudelft.nl
Thu Aug 6 05:05:16 CDT 2009


Dear all,

There is sth which took some time for me to figure out from the 
documentation

http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Mat/MatSetValuesBlocked.html#MatSetValuesBlocked

Or my English is getting worser, In the explanations that are a part of 
this function,

The m and n count the NUMBER of blocks in the row direction and column 
direction, NOT the total number of rows/columns; for example, if the 
block size 
<http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Sys/size.html#size> 
is 2 and you are passing in values for rows 2,3,4,5 then m would be 2 
(not 4). The values in idxm would be 1 2; that is the first index for 
each block divided by the block size 
<http://www.mcs.anl.gov/petsc/petsc-as/snapshots/petsc-current/docs/manualpages/Sys/size.html#size>. 


But the puzzling point is that there are no pointers for the setting of 
the block size and hyperlinks on size also do not direct to the right 
locations in my humble opinion.

However, proper block size setting should be done before using this 
routine with MatSetBlockSize. Am I right?

And this page has no pointers to that function. After reading the 
documetation, I had the idea in the mind that, you decide on the block 
size, and do the computations on paper for m,idxm,n and idxn to be 
supplied to the routine but ,apparently, without a call to the function 
the programs can not know the block size, which is logical.

I felt myself a bit dump, and wanted to notify you about this if someone 
else also experiences the same problem in the future, maybe adding a 
link there for the above mentioned function is a good idea.

   //MatSetBlockSize(A, 3);
   const int idxmNew1[] = {0};
   const int idxnNew1[] = {0};
   PetscScalar vals1[] = { 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0  };
   MatSetValuesBlocked(A, 1, idxmNew1, 1, idxnNew1, vals1, INSERT_VALUES);
   ierr = MatAssemblyBegin(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);
   ierr = MatAssemblyEnd(A,MAT_FINAL_ASSEMBLY);CHKERRQ(ierr);

Running the above piece of code of course sets only M[0][0] with out 
proper setting of the blocks. Or do I still have some misunderstanding 
on the use of this function?

Best regards,
Umut





More information about the petsc-users mailing list