[petsc-users] IS Invert Not Permutation
Florian Lindner
mailinglists at xgm.de
Tue Nov 27 09:16:43 CST 2018
Hello,
I have a range of local input data indices that I want to use for row indexing, say { 3, 4, 6}.
For that, I create a matrix with a local number of rows of 3 and map the indices {3, 4, 5} to these rows.
I create an index set:
ISCreateGeneral(comm, myIndizes.size(), myIndizes.data(), PETSC_COPY_VALUES, &ISlocal);
ISSetPermutation(ISlocal);
ISInvertPermutation(ISlocal, myIndizes.size(), &ISlocalInv);
ISAllGather(ISlocalInv, &ISglobal); // Gather the IS from all processors
ISLocalToGlobalMappingCreateIS(ISglobal, &ISmapping); // Make it a mapping
MatSetLocalToGlobalMapping(matrix, ISmapping, ISmapping); // Set mapping for rows and cols
The InvertPermutation is required because, well, it seems that the direction the mapping stuff works in PETSc.
Now I can use MatSetValues local to set rows {3, 4, 5} and actually set the local rows {1, 2, 3}.
The problem is that the range of data vertices is not always contiguous, i.e. could be {3, 4, 6}. This seems to be not a permutation of PETSc, therefore ISSetPermutation fails and subsequently ISInvertPermutation.
How can I still create such a mapping, so that:
3 -> 1
4 -> 2
6 -> 6
row 5 is unassigned and will never be addressed.
Thanks!
Florian
More information about the petsc-users
mailing list