<div dir="ltr"><div class="gmail_quote"><div dir="ltr">On Tue, Nov 27, 2018 at 10:17 AM Florian Lindner via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hello,<br>
<br>
I have a range of local input data indices that I want to use for row indexing, say { 3, 4, 6}.<br>
<br>
For that, I create a matrix with a local number of rows of 3 and map the indices {3, 4, 5} to these rows.<br></blockquote><div><br></div><div>It seems like you are trying to create a mapping and its inverse. We do that in <div><br></div><div> <a href="https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/AO/AOCreateMapping.html">https://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/AO/AOCreateMapping.html</a></div></div><div><br></div><div>Note that this is not really scalable. Usually there is a way to restructure the code to avoid this.</div><div><br></div><div> Thanks,</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I create an index set:<br>
<br>
ISCreateGeneral(comm, myIndizes.size(), myIndizes.data(), PETSC_COPY_VALUES, &ISlocal);<br>
ISSetPermutation(ISlocal);<br>
ISInvertPermutation(ISlocal, myIndizes.size(), &ISlocalInv);<br>
ISAllGather(ISlocalInv, &ISglobal); // Gather the IS from all processors<br>
ISLocalToGlobalMappingCreateIS(ISglobal, &ISmapping); // Make it a mapping<br>
<br>
MatSetLocalToGlobalMapping(matrix, ISmapping, ISmapping); // Set mapping for rows and cols<br>
<br>
The InvertPermutation is required because, well, it seems that the direction the mapping stuff works in PETSc.<br>
<br>
Now I can use MatSetValues local to set rows {3, 4, 5} and actually set the local rows {1, 2, 3}.<br>
<br>
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.<br>
<br>
How can I still create such a mapping, so that:<br>
<br>
3 -> 1<br>
4 -> 2<br>
6 -> 6<br>
<br>
row 5 is unassigned and will never be addressed.<br>
<br>
Thanks!<br>
Florian<br>
<br>
<br>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div>What most experimenters take for granted before they begin their experiments is infinitely more interesting than any results to which their experiments lead.<br>-- Norbert Wiener</div><div><br></div><div><a href="http://www.cse.buffalo.edu/~knepley/" target="_blank">https://www.cse.buffalo.edu/~knepley/</a><br></div></div></div></div></div></div></div></div>