[petsc-dev] Fwd: MatSetValues with v=0
Barry Smith
bsmith at mcs.anl.gov
Wed Apr 16 14:11:04 CDT 2014
Do we then remove the current functionality? Which is a little weird as currently partly supporting one matrix format and only one of the set values calls
Barry
Begin forwarded message:
> From: Jed Brown <jed at jedbrown.org>
> Subject: Re: [petsc-dev] MatSetValues with v=0
> Date: April 16, 2014 at 8:44:02 AM CDT
> To: Eric Chamberland <Eric.Chamberland at giref.ulaval.ca>, Barry Smith <bsmith at mcs.anl.gov>, Patrick Lacasse <patrick.m.lacasse at gmail.com>
> Cc: For users of the development version of PETSc <petsc-dev at mcs.anl.gov>
>
> Eric Chamberland <Eric.Chamberland at giref.ulaval.ca> writes:
>> 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?...
>
> Just create one large-enough buffer containing all zeros. For example,
>
> PetscScalar *values;
> PetscCalloc1(1000,&values);
>
> for (...) {
> MatSetValues(...,values,INSERT_VALUES);
> }
> PetscFree(values);
>
> Is this okay?
More information about the petsc-dev
mailing list