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;
37: AO ao;
41: DAGetAO(da,&ao);
43: /* create the scatter context */
44: VecGetSize(da->global,&m);
45: ISCreateStride(da->comm,m,0,1,&to);
46: AOPetscToApplicationIS(ao,to);
47: ISCreateStride(da->comm,m,0,1,&from);
48: VecCreateSeq(PETSC_COMM_SELF,m,&tmplocal);
49: VecScatterCreate(da->global,from,tmplocal,to,scatter);
50: VecDestroy(tmplocal);
51: ISDestroy(from);
52: ISDestroy(to);
53: return(0);
54: }
56: /*
57: DANaturalAllToGlobalCreate - Creates a scatter context that maps from a copy
58: of the entire vector on each processor to its local part in the global vector.
60: Collective on DA
62: Input Parameter:
63: . da - the distributed array context
65: Output Parameter:
66: . scatter - the scatter context
68: Level: advanced
70: .keywords: distributed array, global to local, begin, coarse problem
72: .seealso: DAGlobalToNaturalEnd(), DALocalToGlobal(), DACreate2d(),
73: DAGlobalToLocalBegin(), DAGlobalToLocalEnd(), DACreateNaturalVector()
74: */
75: int DANaturalAllToGlobalCreate(DA da,VecScatter *scatter)
76: {
77: int ierr,M,m,start;
78: IS from,to;
79: Vec tmplocal;
80: AO ao;
84: DAGetAO(da,&ao);
86: /* create the scatter context */
87: VecGetSize(da->global,&M);
88: VecGetLocalSize(da->global,&m);
89: VecGetOwnershipRange(da->global,&start,PETSC_NULL);
90: ISCreateStride(da->comm,m,start,1,&from);
91: AOPetscToApplicationIS(ao,from);
92: ISCreateStride(da->comm,m,start,1,&to);
93: VecCreateSeq(PETSC_COMM_SELF,M,&tmplocal);
94: VecScatterCreate(tmplocal,from,da->global,to,scatter);
95: VecDestroy(tmplocal);
96: ISDestroy(from);
97: ISDestroy(to);
98: return(0);
99: }