gather a Petsc Mat matrix onto cpu 0
More...
Go to the source code of this file.
gather a Petsc Mat matrix onto cpu 0
Definition in file MatToSerial.cpp.
◆ MatToSerial()
void MatToSerial |
( |
double ** |
poutmatrix, |
|
|
Mat |
matrix, |
|
|
ISSM_MPI_Comm |
comm |
|
) |
| |
Definition at line 14 of file MatToSerial.cpp.
21 PetscInt lower_row,upper_row;
27 double* local_matrix=NULL;
35 double* outmatrix=NULL;
38 MatGetSize(matrix,&M,&N);
41 MatGetOwnershipRange(matrix,&lower_row,&upper_row);
43 range=upper_row-lower_row+1;
46 if (my_rank==0)outmatrix=xNew<double>(M*N);
49 local_matrix=xNew<double>(N*range);
50 idxm=xNew<int>(range);
56 for (i=0;i<range;i++){
57 *(idxm+i)=lower_row+i;
60 MatGetValues(matrix,range,idxm,N,idxn,local_matrix);
66 for (i=1;i<num_procs;i++){
81 memcpy(outmatrix,local_matrix,N*range*
sizeof(
double));
85 *poutmatrix=outmatrix;
88 xDelete<double>(local_matrix);
int ISSM_MPI_Send(void *buf, int count, ISSM_MPI_Datatype datatype, int dest, int tag, ISSM_MPI_Comm comm)
int ISSM_MPI_Recv(void *buf, int count, ISSM_MPI_Datatype datatype, int source, int tag, ISSM_MPI_Comm comm, ISSM_MPI_Status *status)