[petsc-users] a quick question about index out of range in MatSetValues

Barry Smith bsmith at mcs.anl.gov
Sun Sep 18 18:50:48 CDT 2011


On Sep 18, 2011, at 11:51 AM, Panruo Wu wrote:

> Dear list,
> 
> I read in the MatSetValues documentation and found that 
> 
> Negative indices may be passed in idxm and idxn, these rows and columns are simply ignored
> 
> I wonder if it's still the case when passing row or column indices larger than matrix dimensions.   
> If it's true it's very handy to assemble matrix of homogeneous dirichlet boundary condition.

  No, you need to label those nodes with negative indices to get them ignored; larger than N will generate an error. 

  Note if you provide your own local to global mapping to the matrix you can map the "extra" large values to negative values and thus have them ignored. But I recommend since labeling all nodes you want ignored with negative indices.

   Barry

> 
> Thanks,
> Robb



More information about the petsc-users mailing list