[petsc-users] Problems on creating matrices based on different communicators other than MPI_COMM_WORLD.

Hong hzhang at mcs.anl.gov
Tue Jan 17 12:02:47 CST 2017


Fangbo :
>
>
> 1.   My question is how can I define matices on small communicators (not
> MPI_COMM_WORLD)?
> I tried something like this but does not work:
>
>     for (int i=0; i<6; i++) {
>           MatCreate(comm1,&general_detM[i]);
>           MatSetSizes(general_detM[i],PETSC_DECIDE,PETSC_DECIDE,
> General_Dofs, General_Dofs);
>           MatSetFromOptions(general_detM[i]);
>           MatMPIAIJSetPreallocation(general_detM[i],300,NULL,300,NULL);
>           MatSeqAIJSetPreallocation(general_detM[i],600,NULL);
>           MatSetOption(general_detM[i], MAT_NEW_NONZERO_ALLOCATION_ERR,
> PETSC_FALSE);   //to extend the preallocatted memory for more values
>     }
>
> If I change MatCreate(comm1,&general_detM[i]) to
> MatCreate(MPI_COMM_WORLD,&general_detM[i]), the code works.
>
> Only processors that belong to comm1 can call this block of code.

>
> 2. Also, there is one more question, how can I use MatSetValues to insert
> values to a matrix not based on MPI_COMM_WORLD?
>
Again, processors in comm1 can call  MatSetValues().

Hong

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170117/85711549/attachment.html>


More information about the petsc-users mailing list