[petsc-users] MatCreateSubMatrix

Emmanuel Ayala juaneah at gmail.com
Mon Aug 12 13:37:08 CDT 2019


Hello, I have some doubts.

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:

1. I defined the sub-matrix (submat, specifying the size)
2. I created the IS for the rows, in this case taking into account the
MatGetOwnershipRange(A,&row_low,&row_high);
ISCreateGeneral(COMMUNICATOR,n_rows,arr_rows,PETSC_COPY_VALUES,&is_rows);.
This consider all the rows owned by the process.
2. I created the IS for columns:
ISCreateGeneral(COMMUNICATOR,n_cols,arr_col,PETSC_COPY_VALUES,&is_col);
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);
3. I create the submatrix:
MatCreateSubMatrix(A,is_row,is_col,MAT_INITIAL_MATRIX,&submat);

Questions:

a. Which communicator i need to use, MPI_COMM_SELF or PETSC_COMM_WORLD? and
why?
b. Moreover, my approach to create the submatrix is ok?
c. In the example:
https://www.mcs.anl.gov/petsc/petsc-current/src/ksp/ksp/examples/tutorials/ex49.c.html
there is a line
1239:   ISSetBlockSize(is,2);
what is the meaning of this line?

Best regards.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20190812/056cfeb1/attachment.html>


More information about the petsc-users mailing list