Actual source code: isltog.h
2: /*
3: This is a terrible way of doing "templates" in C.
4: */
5: #define PETSCMAPNAME(a) PetscConcat(a,GTOLNAME)
6: #define PETSCMAPTYPE(a) PetscConcat(a,GTOLTYPE)
8: static PetscErrorCode PETSCMAPNAME(ISGlobalToLocalMappingApply)(ISLocalToGlobalMapping mapping,ISGlobalToLocalMappingMode type,
9: PetscInt n,const PetscInt idx[],PetscInt *nout,PetscInt idxout[])
10: {
11: PetscInt i,nf = 0,tmp,start,end,bs;
12: PETSCMAPTYPE(ISLocalToGlobalMapping) *map = (PETSCMAPTYPE(ISLocalToGlobalMapping)*)mapping->data;
15: if (!map) {
16: ISGlobalToLocalMappingSetUp(mapping);
17: map = (PETSCMAPTYPE(ISLocalToGlobalMapping) *)mapping->data;
18: }
19: start = mapping->globalstart;
20: end = mapping->globalend;
21: bs = GTOLBS;
23: if (type == IS_GTOLM_MASK) {
24: if (idxout) {
25: for (i=0; i<n; i++) {
26: if (idx[i] < 0) idxout[i] = idx[i];
27: else if (idx[i] < bs*start) idxout[i] = -1;
28: else if (idx[i] > bs*(end+1)-1) idxout[i] = -1;
29: else GTOL(idx[i], idxout[i]);
30: }
31: }
32: if (nout) *nout = n;
33: } else {
34: if (idxout) {
35: for (i=0; i<n; i++) {
36: if (idx[i] < 0) continue;
37: if (idx[i] < bs*start) continue;
38: if (idx[i] > bs*(end+1)-1) continue;
39: GTOL(idx[i], tmp);
40: if (tmp < 0) continue;
41: idxout[nf++] = tmp;
42: }
43: } else {
44: for (i=0; i<n; i++) {
45: if (idx[i] < 0) continue;
46: if (idx[i] < bs*start) continue;
47: if (idx[i] > bs*(end+1)-1) continue;
48: GTOL(idx[i], tmp);
49: if (tmp < 0) continue;
50: nf++;
51: }
52: }
53: if (nout) *nout = nf;
54: }
55: return 0;
56: }
58: #undef PETSCMAPTYPE
59: #undef PETSCMAPNAME
60: #undef GTOLTYPE
61: #undef GTOLNAME
62: #undef GTOLBS
63: #undef GTOL