Actual source code: dagtona.c
1: /*$Id: dagtona.c,v 1.10 2001/03/23 23:25:00 balay Exp $*/
2:
3: /*
4: Tools to help solve the coarse grid problem redundantly.
5: Provides two scatter contexts that (1) map from the usual global vector
6: to all processors the entire vector in NATURAL numbering and (2)
7: from the entire vector on each processor in natural numbering extracts
8: out this processors piece in GLOBAL numbering
9: */
11: #include src/dm/da/daimpl.h
13: /*
14: DAGlobalToNaturalAllCreate - Creates a scatter context that maps from the
15: global vector the entire vector to each processor in natural numbering
17: Collective on DA
19: Input Parameter:
20: . da - the distributed array context
22: Output Parameter:
23: . scatter - the scatter context
25: Level: advanced
27: .keywords: distributed array, global to local, begin, coarse problem
29: .seealso: DAGlobalToNaturalEnd(), DALocalToGlobal(), DACreate2d(),
30: DAGlobalToLocalBegin(), DAGlobalToLocalEnd(), DACreateNaturalVector()
31: */
32: int DAGlobalToNaturalAllCreate(DA da,VecScatter *scatter)
33: {
34: int ierr,m;
35: IS from,to;
36: Vec tmplocal;
40: if (!da->ao) {
41: SETERRQ(1,"Cannot use -da_noao with this function");
42: }
44: /* create the scatter context */
45: VecGetSize(da->global,&m);
46: ISCreateStride(da->comm,m,0,1,&to);
47: AOPetscToApplicationIS(da->ao,to);
48: ISCreateStride(da->comm,m,0,1,&from);
49: VecCreateSeq(PETSC_COMM_SELF,m,&tmplocal);
50: VecScatterCreate(da->global,from,tmplocal,to,scatter);
51: VecDestroy(tmplocal);
52: ISDestroy(from);
53: ISDestroy(to);
54: return(0);
55: }
57: /*
58: DANaturalAllToGlobalCreate - Creates a scatter context that maps from a copy
59: of the entire vector on each processor to its local part in the global vector.
61: Collective on DA
63: Input Parameter:
64: . da - the distributed array context
66: Output Parameter:
67: . scatter - the scatter context
69: Level: advanced
71: .keywords: distributed array, global to local, begin, coarse problem
73: .seealso: DAGlobalToNaturalEnd(), DALocalToGlobal(), DACreate2d(),
74: DAGlobalToLocalBegin(), DAGlobalToLocalEnd(), DACreateNaturalVector()
75: */
76: int DANaturalAllToGlobalCreate(DA da,VecScatter *scatter)
77: {
78: int ierr,M,m,start;
79: IS from,to;
80: Vec tmplocal;
84: if (!da->ao) {
85: SETERRQ(1,"Cannot use -da_noao with this function");
86: }
88: /* create the scatter context */
89: VecGetSize(da->global,&M);
90: VecGetLocalSize(da->global,&m);
91: VecGetOwnershipRange(da->global,&start,PETSC_NULL);
92: ISCreateStride(da->comm,m,start,1,&from);
93: AOPetscToApplicationIS(da->ao,from);
94: ISCreateStride(da->comm,m,start,1,&to);
95: VecCreateSeq(PETSC_COMM_SELF,M,&tmplocal);
96: VecScatterCreate(tmplocal,from,da->global,to,scatter);
97: VecDestroy(tmplocal);
98: ISDestroy(from);
99: ISDestroy(to);
100: return(0);
101: }