[petsc-users] Output question for ex29.

zhenglun.wei at gmail.com zhenglun.wei at gmail.com
Thu Jun 9 18:01:30 CDT 2011


Dear Sir/Madam,
I'm still studying on the ex29 of /src/ksp/ksp/example/tutorial. Before I  
met a problem on VecView_VTK in parallel computation. I'm trying to modify  
it in order to output some data from the computation.

1) My first questions is that what does this section do in VecView_VTK:

272: MPI_Comm_rank(comm, &rank);
273: MPI_Comm_size(comm, &size);
274: MPI_Reduce(&n, &maxn, 1, MPIU_INT, MPI_MAX, 0, comm);
275: tag = ((PetscObject) viewer)->tag;
276: if (!rank) {
277: PetscMalloc((maxn+1) * sizeof(PetscScalar), &values);
278: for(i = 0; i < n; i++) {
279: PetscViewerASCIIPrintf(viewer, "%G\n", PetscRealPart(array[i]));
280: }
281: for(p = 1; p < size; p++) {
282: MPI_Recv(values, (PetscMPIInt) n, MPIU_SCALAR, p, tag, comm, &status);
283: MPI_Get_count(&status, MPIU_SCALAR, &nn);
284: for(i = 0; i < nn; i++) {
285: PetscViewerASCIIPrintf(viewer, "%G\n", PetscRealPart(array[i]));
286: }
287: }
288: PetscFree(values);
289: } else {
290: MPI_Send(array, n, MPIU_SCALAR, 0, tag, comm);
291: }

What I understand is: it gather all the data from different process in  
parallel computation, and output it to the 'viewer'. I comment out  
everything in VecView_VTK except this part, there is no error message  
coming up in my parallel computation so far.

2) however, I really don't know how did it split the domain for parallel  
computation. For example, if I use 4 processes, is the domain split like:

a)
|
0 | 1
|
---------------|--------------
|
2 | 3
|

b)
|
0 | 2
|
---------------|--------------
|
1 | 3
|

c)
| | | |
| | | |
0 | | 2 | |
| 1 | | 3 |
| | | |
| | | |

d)
0
------------------------
1
------------------------
2
------------------------
3

thanks in advance,
Alan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-users/attachments/20110609/5757476b/attachment.htm>


More information about the petsc-users mailing list