static char help[] = "Tests MatIncreaseOverlap() and MatCreateSubmatrices() for the parallel case.\n\ This example is similar to ex40.c; here the index sets used are random.\n\ Input arguments are:\n\ -f : file to load. For example see $PETSC_DIR/share/petsc/datafiles/matrices\n\ -nd : > 0 no of domains per processor \n\ -ov : >=0 amount of overlap between domains\n\n"; #include int main(int argc,char **args) { PetscInt nd = 2,ov=1,i,j,lsize,m,n,*idx,bs; PetscMPIInt rank, size; PetscBool flg; Mat A,B,*submatA,*submatB; char file[PETSC_MAX_PATH_LEN]; PetscViewer fd; IS *is1,*is2; PetscRandom r; PetscBool test_unsorted = PETSC_FALSE; PetscScalar rand; PetscCall(PetscInitialize(&argc,&args,(char*)0,help)); PetscCallMPI(MPI_Comm_size(PETSC_COMM_WORLD,&size)); PetscCallMPI(MPI_Comm_rank(PETSC_COMM_WORLD,&rank)); PetscCall(PetscOptionsGetString(NULL,NULL,"-f",file,sizeof(file),NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-nd",&nd,NULL)); PetscCall(PetscOptionsGetInt(NULL,NULL,"-ov",&ov,NULL)); PetscCall(PetscOptionsGetBool(NULL,NULL,"-test_unsorted",&test_unsorted,NULL)); /* Read matrix A and RHS */ PetscCall(PetscViewerBinaryOpen(PETSC_COMM_WORLD,file,FILE_MODE_READ,&fd)); PetscCall(MatCreate(PETSC_COMM_WORLD,&A)); PetscCall(MatSetType(A,MATAIJ)); PetscCall(MatSetFromOptions(A)); PetscCall(MatLoad(A,fd)); PetscCall(PetscViewerDestroy(&fd)); /* Read the same matrix as a seq matrix B */ PetscCall(PetscViewerBinaryOpen(PETSC_COMM_SELF,file,FILE_MODE_READ,&fd)); PetscCall(MatCreate(PETSC_COMM_SELF,&B)); PetscCall(MatSetType(B,MATSEQAIJ)); PetscCall(MatSetFromOptions(B)); PetscCall(MatLoad(B,fd)); PetscCall(PetscViewerDestroy(&fd)); PetscCall(MatGetBlockSize(A,&bs)); /* Create the Random no generator */ PetscCall(MatGetSize(A,&m,&n)); PetscCall(PetscRandomCreate(PETSC_COMM_SELF,&r)); PetscCall(PetscRandomSetFromOptions(r)); /* Create the IS corresponding to subdomains */ PetscCall(PetscMalloc1(nd,&is1)); PetscCall(PetscMalloc1(nd,&is2)); PetscCall(PetscMalloc1(m ,&idx)); for (i = 0; i < m; i++) {idx[i] = i;} /* Create the random Index Sets */ for (i=0; i