<div dir="ltr"><div dir="ltr">On Mon, Aug 12, 2019 at 2:55 PM Emmanuel Ayala 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">Hello, I have some doubts.<br><br>I'm trying to create a submatrix (MatCreateSubMatrix). I have an identity matrix A. Then, in each process, I select some indices (owned in this process but in global numbering) that i need to remove (only columns) from the matrix A. These indices are storage in an PetscInt array (arr_cols), created with PetscMalloc1 (size: n_cols). My goal is to use the index set tool (IS). For this purpose, i did the next:<br><br>1. I defined the sub-matrix (submat, specifying the size)<br>2. I created the IS for the rows, in this case taking into account the MatGetOwnershipRange(A,&row_low,&row_high);<br>ISCreateGeneral(COMMUNICATOR,n_rows,arr_rows,PETSC_COPY_VALUES,&is_rows);. This consider all the rows owned by the process.<br>2. I created the IS for columns: ISCreateGeneral(COMMUNICATOR,n_cols,arr_col,PETSC_COPY_VALUES,&is_col);<br>The range for the is_col, was defined taking into account the the columns that will be in IT's "diagonal part", using MatGetOwnershipRangeColumn(A,&col_low,&col_high);<br>3. I create the submatrix: MatCreateSubMatrix(A,is_row,is_col,MAT_INITIAL_MATRIX,&submat); <br><br>Questions:<br><br>a. Which communicator i need to use, MPI_COMM_SELF or PETSC_COMM_WORLD? and why?<br></div></blockquote><div><br></div><div>You will generally use the same communicator as A. MatGetSubmatrices() makes sequential matrices with SELF.</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">b. Moreover, my approach to create the submatrix is ok?<br></div></blockquote><div><br></div><div>It sounds right.</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">c. In the example:<br><a href="https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex49.c.html" target="_blank">https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex49.c.html</a><br>there is a line <br>1239:   ISSetBlockSize(is,2);<br><div>what is the meaning of this line?</div></div></blockquote><div><br></div><div>If your matrix has a blocksize, you can simplify indexing. I would get everything working right first.</div><div><br></div><div>  Thanks,</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>Best regards.<br></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>