[petsc-users] questions on BAIJ matrix

Xiangdong epscodes at gmail.com
Thu Jun 8 12:34:53 CDT 2017


Hello everyone,

I have a few quick questions on BAIJ matrix in petsc.

1) In the remark of the function MatCreateMPIBAIJWithArrays, it says " bs -
the block size, only a block size of 1 is supported". Why must the block
size be 1? Is this a typo?

http://www.mcs.anl.gov/petsc/petsc-current/docs/manualpages/Mat/
MatCreateMPIBAIJWithArrays.html

2) In the Line 4040 of the implemention of MatCreateMPIBAIJWithArrays,
would the matrix type be matmpibaij instead of matmpiSbaij?

http://www.mcs.anl.gov/petsc/petsc-current/src/mat/impls/
baij/mpi/mpibaij.c.html#MatCreateMPIBAIJWithArrays

4031: PetscErrorCode  MatCreateMPIBAIJWithArrays(MPI_Comm comm,PetscInt
bs,PetscInt m,PetscInt n,PetscInt M,PetscInt N,const PetscInt i[],const
PetscInt j[],const PetscScalar a[],Mat *mat)
4032: {

4036:   if (i[0]) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"i (row
indices) must start with 0");
4037:   if (m < 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"local
number of rows (m) cannot be PETSC_DECIDE, or negative");
4038:   MatCreate(comm,mat);
4039:   MatSetSizes(*mat,m,n,M,N);
4040:   MatSetType(*mat,MATMPISBAIJ);
4041:   MatSetOption(*mat,MAT_ROW_ORIENTED,PETSC_FALSE);
4042:   MatMPIBAIJSetPreallocationCSR(*mat,bs,i,j,a);
4043:   MatSetOption(*mat,MAT_ROW_ORIENTED,PETSC_TRUE);
4044:   return(0);
4045: }

3) I want to create a petsc matrix M equivalent to the sum of two block csr
matrix/array (M1csr, M2csr). What is the best way to achieve it? I am
thinking of created two petsc baij matrix (M1baij and M2baij) by
calling MatCreateMPIBAIJWithArrays
twice and then call MATAXPY to get the sum M=M1baij + M2baij. Is there a
better way to do it?

Thank you.

Best,
Xiangdong
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170608/507e5df9/attachment.html>


More information about the petsc-users mailing list