A point on documentation of MatSetValuesBlocked

Matthew Knepley knepley at gmail.com
Thu Aug 6 07:59:55 CDT 2009

I have pushed a fix for the documentation that explains the need for
MatSetBlockSize(). It will appear
in the next patch release, and the next nightly build of the online



On Thu, Aug 6, 2009 at 5:05 AM, Umut Tabak <u.tabak at tudelft.nl> wrote:

> 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

What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20090806/e32338e3/attachment.htm>

More information about the petsc-users mailing list