Eric Chamberland <[email protected]> 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?
pgpqvhbDHWM_T.pgp
Description: PGP signature
