[petsc-users] IS Invert Not Permutation
Matthew Knepley
knepley at gmail.com
Tue Nov 27 09:33:56 CST 2018
On Tue, Nov 27, 2018 at 10:17 AM Florian Lindner via petsc-users <
petsc-users at mcs.anl.gov> wrote:
> 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.
>
It seems like you are trying to create a mapping and its inverse. We do
that in
https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/AO/AOCreateMapping.html
Note that this is not really scalable. Usually there is a way to
restructure the code to avoid this.
Thanks,
Matt
> 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
>
>
>
--
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
https://www.cse.buffalo.edu/~knepley/ <http://www.cse.buffalo.edu/~knepley/>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20181127/e2f84eaf/attachment.html>
More information about the petsc-users
mailing list