<div dir="ltr"><div dir="ltr">On Wed, Mar 27, 2019 at 8:33 AM Eda Oktay via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div>Hello,</div><div><br></div><div>I am trying to permute a matrix A(of size 2n*2n) according to a sorted eigenvector vr (of size 2n) in parallel using 2 processors (processor number can change). However, I get an error in MatPermute line stating that arguments are out of range and a new nonzero caused a malloc even if I used MatSetOption. </div><div><br></div><div>I discovered that this may be because of the unequality of local sizes of is (and newIS) and local size of A. </div><div><br></div><div>Since I allocate index set idx according to size of the vector vr, global size of is becomes 2n and the local size is also 2n (I think it should be n since both A and vr has local sizes n because of the number of processors). If I change the size of idx, then because of VecGetArrayRead, I think is is created wrongly.</div><div><br></div><div>So, how can I make both global and local sizes of is,newIS and A?</div><div><br></div><div>Below, you can see the part of my program.</div><div><br></div><div>Thanks,</div><div><br></div><div>Eda</div><div> </div><div> ierr = VecGetSize(vr,&siz);CHKERRQ(ierr); </div></div></div></blockquote><div><br></div><div>Here siz is the length of the parallel Vec.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div> ierr = PetscMalloc1(siz,&idx);CHKERRQ(ierr);</div><div> for (i=0; i<siz;i++) idx[i] = i;</div><div> ierr = VecGetArrayRead(vr,&avr);CHKERRQ(ierr);</div><div> ierr = PetscSortRealWithPermutation(siz,avr,idx);CHKERRQ(ierr); </div><div> ierr = ISCreateGeneral(PETSC_COMM_SELF,siz,idx,PETSC_COPY_VALUES,&is);CHKERRQ(ierr); </div></div></div></blockquote><div><br></div><div>Here siz is the length of the _serial_ IS. You want the local size of the Vec here.</div><div><br></div><div> Matt</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div dir="ltr"><div> ierr = ISSetPermutation(is);CHKERRQ(ierr);</div><div> ierr = ISDuplicate(is,&newIS);CHKERRQ(ierr);</div><div>MatSetOption(A,MAT_NEW_NONZERO_ALLOCATION_ERR,PETSC_FALSE);CHKERRQ(ierr); <br></div><div> ierr = MatPermute(A,is,newIS,&PL);CHKERRQ(ierr); </div></div></div>
</blockquote></div><br clear="all"><div><br></div>-- <br><div dir="ltr" class="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>