[petsc-dev] MatSetValues with v=0

Eric Chamberland Eric.Chamberland at giref.ulaval.ca
Wed Apr 16 08:38:27 CDT 2014


On 04/12/2014 06:10 PM, Barry Smith wrote:
>     Patrick,
>
>       Currently it is supported for MatSetValues_SeqAIJ() and MatSetValues_MPIAIJ(). It is not handled for BAIJ and SBAIJ, the code while crash with segv in those cases (since we don’t check for a valid v pointer before use :-).   But support could easily be added for BAIJ and SBAIJ with just a few lines of code.
>
>       MatSetValuesBlocked() does not have this kind of support and adding it would be cumbersome.
>
>       So I guess the question is does this “feature” add useful functionality that makes the slightly more complex code worthwhile? Or is it an oddball thing that should be removed? As the cool kids would say “what is the use case for this feature?”.
>
>        I’m fine with adding support for BAIJ and SBAIJ and documenting it but then I am also fine with removing it though I suspect it is used somewhere in PETSc and thus that code would need to be located and changed if it is removed.
Hi Barry,

I was writing (new) code which do the firsts MatSetValues after the 
MatXAIJSetPreallocation.  We have to do this because the "real" 
non-zeros will be added later by a mix of ADD_VALUES and 
INSERT_VALUES... which would prevent us to "lock" the matrix 
(MatSetOption(aMatricePETSc, MAT_NEW_NONZERO_LOCATION_ERR, PETSC_TRUE) 
because this option must be passed after the first MatAssemblyEnd()... 
but all the non-zeros are "triggered" only after this "mixed" assembly...

In other words, we have to do a "fake" assembly with all "0" to cover 
all non-zeros that will be in fact added later... So we have to create 
many "fake" elementary matrices to pass for assembly... that is why 
Patrick was asking if the feature was supported... It would save us from 
creating the fake matrices...  Or maybe there is a better solution?...

Thanks,

Eric

>
>     Barry
>
>
>
> On Apr 11, 2014, at 12:51 PM, Patrick Lacasse <patrick.m.lacasse at gmail.com> wrote:
>
>> Hi,
>>
>>     I see that implementation of MatSetValues handles a special case when one passes a null pointer v=0.
>> In this case, it is considered that all values are 0.
>> But the documentation doesn't seems to talk about it :
>> http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/MatSetValues.html
>>
>> Is it a feature that we can use?
>> Should it be added to the doc?
>>
>> Patrick Lacasse




More information about the petsc-dev mailing list