[petsc-users] Problems on creating matrices based on different communicators other than MPI_COMM_WORLD.
Fangbo Wang
fangbowa at buffalo.edu
Tue Jan 17 11:39:58 CST 2017
Hi,
I know how to define groups and communicators in MPI.
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.
2. Also, there is one more question, how can I use MatSetValues to insert
values to a matrix not based on MPI_COMM_WORLD?
Can anyone help me on this? Thank you very much!
--
Fangbo Wang, PhD student
Stochastic Geomechanics Research Group
Department of Civil, Structural and Environmental Engineering
University at Buffalo
Email: *fangbowa at buffalo.edu <fangbowa at buffalo.edu>*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20170117/390f4e49/attachment.html>
More information about the petsc-users
mailing list