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