File: | dm/impls/stag/stagda.c |
Warning: | line 360, column 44 The right operand of '+' is a garbage value |
[?] Use j/k keys for keyboard navigation
1 | /* Routines to convert between a (subset of) DMStag and DMDA */ | |||
2 | ||||
3 | #include <petscdmda.h> | |||
4 | #include <petsc/private/dmstagimpl.h> | |||
5 | #include <petscdmdatypes.h> | |||
6 | ||||
7 | static PetscErrorCode DMStagCreateCompatibleDMDA(DM dm,DMStagStencilLocation loc,PetscInt c,DM *dmda) | |||
8 | { | |||
9 | PetscErrorCode ierr; | |||
10 | DM_Stag * const stag = (DM_Stag*) dm->data; | |||
11 | PetscInt dim,i,j,stencilWidth,dof,N[DMSTAG_MAX_DIM3]; | |||
12 | DMDAStencilType stencilType; | |||
13 | PetscInt *l[DMSTAG_MAX_DIM3]; | |||
14 | ||||
15 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 15; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
16 | PetscValidHeaderSpecificType(dm,DM_CLASSID,1,DMSTAG)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),16,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dm,"stag",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"stag",((PetscObject)dm)->type_name); } while (0); | |||
17 | ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),17,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
18 | ||||
19 | /* Create grid decomposition (to be adjusted later) */ | |||
20 | for (i=0; i<dim; ++i) { | |||
21 | ierr = PetscMalloc1(stag->nRanks[i],&l[i])PetscMallocA(1,PETSC_FALSE,21,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,(size_t)(stag->nRanks[i])*sizeof(**(&l[i])),(&l[i ]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),21,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
22 | for (j=0; j<stag->nRanks[i]; ++j) l[i][j] = stag->l[i][j]; | |||
23 | N[i] = stag->N[i]; | |||
24 | } | |||
25 | ||||
26 | /* dof */ | |||
27 | dof = c < 0 ? -c : 1; | |||
28 | ||||
29 | /* Determine/adjust sizes */ | |||
30 | switch (loc) { | |||
31 | case DMSTAG_ELEMENT: | |||
32 | break; | |||
33 | case DMSTAG_LEFT: | |||
34 | case DMSTAG_RIGHT: | |||
35 | #if defined(PETSC_USE_DEBUG1) | |||
36 | if (dim<1) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),36,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
37 | #endif | |||
38 | l[0][stag->nRanks[0]-1] += 1; /* extra vertex in direction 0 on last rank in dimension 0 */ | |||
39 | N[0] += 1; | |||
40 | break; | |||
41 | case DMSTAG_UP: | |||
42 | case DMSTAG_DOWN: | |||
43 | #if defined(PETSC_USE_DEBUG1) | |||
44 | if (dim < 2) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),44,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
45 | #endif | |||
46 | l[1][stag->nRanks[1]-1] += 1; /* extra vertex in direction 1 on last rank in dimension 1 */ | |||
47 | N[1] += 1; | |||
48 | break; | |||
49 | case DMSTAG_BACK: | |||
50 | case DMSTAG_FRONT: | |||
51 | #if defined(PETSC_USE_DEBUG1) | |||
52 | if (dim < 3) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),52,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
53 | #endif | |||
54 | l[2][stag->nRanks[2]-1] += 1; /* extra vertex in direction 2 on last rank in dimension 2 */ | |||
55 | N[2] += 1; | |||
56 | break; | |||
57 | case DMSTAG_DOWN_LEFT : | |||
58 | case DMSTAG_DOWN_RIGHT : | |||
59 | case DMSTAG_UP_LEFT : | |||
60 | case DMSTAG_UP_RIGHT : | |||
61 | #if defined(PETSC_USE_DEBUG1) | |||
62 | if (dim < 2) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),62,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
63 | #endif | |||
64 | for (i=0; i<2; ++i) { /* extra vertex in direction i on last rank in dimension i = 0,1 */ | |||
65 | l[i][stag->nRanks[i]-1] += 1; | |||
66 | N[i] += 1; | |||
67 | } | |||
68 | break; | |||
69 | case DMSTAG_BACK_LEFT: | |||
70 | case DMSTAG_BACK_RIGHT: | |||
71 | case DMSTAG_FRONT_LEFT: | |||
72 | case DMSTAG_FRONT_RIGHT: | |||
73 | #if defined(PETSC_USE_DEBUG1) | |||
74 | if (dim < 3) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),74,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
75 | #endif | |||
76 | for (i=0; i<3; i+=2) { /* extra vertex in direction i on last rank in dimension i = 0,2 */ | |||
77 | l[i][stag->nRanks[i]-1] += 1; | |||
78 | N[i] += 1; | |||
79 | } | |||
80 | break; | |||
81 | case DMSTAG_BACK_DOWN: | |||
82 | case DMSTAG_BACK_UP: | |||
83 | case DMSTAG_FRONT_DOWN: | |||
84 | case DMSTAG_FRONT_UP: | |||
85 | #if defined(PETSC_USE_DEBUG1) | |||
86 | if (dim < 3) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),86,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
87 | #endif | |||
88 | for (i=1; i<3; ++i) { /* extra vertex in direction i on last rank in dimension i = 1,2 */ | |||
89 | l[i][stag->nRanks[i]-1] += 1; | |||
90 | N[i] += 1; | |||
91 | } | |||
92 | break; | |||
93 | case DMSTAG_BACK_DOWN_LEFT: | |||
94 | case DMSTAG_BACK_DOWN_RIGHT: | |||
95 | case DMSTAG_BACK_UP_LEFT: | |||
96 | case DMSTAG_BACK_UP_RIGHT: | |||
97 | case DMSTAG_FRONT_DOWN_LEFT: | |||
98 | case DMSTAG_FRONT_DOWN_RIGHT: | |||
99 | case DMSTAG_FRONT_UP_LEFT: | |||
100 | case DMSTAG_FRONT_UP_RIGHT: | |||
101 | #if defined(PETSC_USE_DEBUG1) | |||
102 | if (dim < 3) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Incompatible dim (%d) and loc(%s) combination",dim,DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),102,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Incompatible dim (%d) and loc(%s) combination" ,dim,DMStagStencilLocations[loc]); | |||
103 | #endif | |||
104 | for (i=0; i<3; ++i) { /* extra vertex in direction i on last rank in dimension i = 0,1,2 */ | |||
105 | l[i][stag->nRanks[i]-1] += 1; | |||
106 | N[i] += 1; | |||
107 | } | |||
108 | break; | |||
109 | break; | |||
110 | default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Not implemented for location %s",DMStagStencilLocations[loc])return PetscError(PetscObjectComm((PetscObject)dm),110,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Not implemented for location %s",DMStagStencilLocations [loc]); | |||
111 | } | |||
112 | ||||
113 | /* Use the same stencil type */ | |||
114 | switch (stag->stencilType) { | |||
115 | case DMSTAG_STENCIL_STAR: stencilType = DMDA_STENCIL_STAR; stencilWidth = stag->stencilWidth; break; | |||
116 | case DMSTAG_STENCIL_BOX : stencilType = DMDA_STENCIL_BOX ; stencilWidth = stag->stencilWidth; break; | |||
117 | default: SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Unsupported Stencil Type %d",stag->stencilType)return PetscError(PETSC_COMM_WORLD,117,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,56,PETSC_ERROR_INITIAL,"Unsupported Stencil Type %d",stag-> stencilType); | |||
118 | } | |||
119 | ||||
120 | /* Create DMDA, using same boundary type */ | |||
121 | switch (dim) { | |||
122 | case 1: | |||
123 | ierr = DMDACreate1d(PetscObjectComm((PetscObject)dm),stag->boundaryType[0],N[0],dof,stencilWidth,l[0],dmda);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),123,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
124 | break; | |||
125 | case 2: | |||
126 | ierr = DMDACreate2d(PetscObjectComm((PetscObject)dm),stag->boundaryType[0],stag->boundaryType[1],stencilType,N[0],N[1],stag->nRanks[0],stag->nRanks[1],dof,stencilWidth,l[0],l[1],dmda);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),126,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
127 | break; | |||
128 | case 3: | |||
129 | ierr = DMDACreate3d(PetscObjectComm((PetscObject)dm),stag->boundaryType[0],stag->boundaryType[1],stag->boundaryType[2],stencilType,N[0],N[1],N[2],stag->nRanks[0],stag->nRanks[1],stag->nRanks[2],dof,stencilWidth,l[0],l[1],l[2],dmda);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
130 | break; | |||
131 | default: SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_SUP,"not implemented for dim %d",dim)return PetscError(PETSC_COMM_WORLD,131,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,56,PETSC_ERROR_INITIAL,"not implemented for dim %d",dim); | |||
132 | } | |||
133 | for (i=0; i<dim; ++i) { | |||
134 | ierr = PetscFree(l[i])((*PetscTrFree)((void*)(l[i]),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ) || ((l[i]) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
135 | } | |||
136 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
137 | } | |||
138 | ||||
139 | /* | |||
140 | Helper function to get the number of extra points in a DMDA representation for a given canonical location. | |||
141 | */ | |||
142 | static PetscErrorCode DMStagDMDAGetExtraPoints(DM dm,DMStagStencilLocation locCanonical,PetscInt *extraPoint) | |||
143 | { | |||
144 | PetscErrorCode ierr; | |||
145 | PetscInt dim,d,nExtra[DMSTAG_MAX_DIM3]; | |||
146 | ||||
147 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 147; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
148 | PetscValidHeaderSpecificType(dm,DM_CLASSID,1,DMSTAG)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),148,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dm,"stag",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"stag",((PetscObject)dm)->type_name); } while (0); | |||
149 | ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),149,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
150 | if (dim > DMSTAG_MAX_DIM3) SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Not implemented for %D dimensions",dim)return PetscError(PetscObjectComm((PetscObject)dm),150,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Not implemented for %D dimensions",dim); | |||
151 | ierr = DMStagGetCorners(dm,NULL((void*)0),NULL((void*)0),NULL((void*)0),NULL((void*)0),NULL((void*)0),NULL((void*)0),&nExtra[0],&nExtra[1],&nExtra[2]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),151,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
152 | for(d=0; d<dim; ++d) extraPoint[d] = 0; | |||
153 | switch (locCanonical) { | |||
154 | case DMSTAG_ELEMENT: | |||
155 | break; /* no extra points */ | |||
156 | case DMSTAG_LEFT: | |||
157 | extraPoint[0] = nExtra[0]; break; /* only extra point in x */ | |||
158 | case DMSTAG_DOWN: | |||
159 | extraPoint[1] = nExtra[1]; break; /* only extra point in y */ | |||
160 | case DMSTAG_BACK: | |||
161 | extraPoint[2] = nExtra[2]; break; /* only extra point in z */ | |||
162 | case DMSTAG_DOWN_LEFT: | |||
163 | extraPoint[0] = nExtra[0]; extraPoint[1] = nExtra[1]; break; /* extra point in both x and y */ | |||
164 | case DMSTAG_BACK_LEFT: | |||
165 | extraPoint[0] = nExtra[0]; extraPoint[2] = nExtra[2]; break; /* extra point in both x and z */ | |||
166 | case DMSTAG_BACK_DOWN: | |||
167 | extraPoint[1] = nExtra[1]; extraPoint[2] = nExtra[2]; break; /* extra point in both y and z */ | |||
168 | case DMSTAG_BACK_DOWN_LEFT: | |||
169 | extraPoint[0] = nExtra[0]; extraPoint[1] = nExtra[1]; extraPoint[2] = nExtra[2]; break; /* extra points in x,y,z */ | |||
170 | default : SETERRQ1(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"Not implemented for location (perhaps not canonical) %s",DMStagStencilLocations[locCanonical])return PetscError(PetscObjectComm((PetscObject)dm),170,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Not implemented for location (perhaps not canonical) %s" ,DMStagStencilLocations[locCanonical]); | |||
171 | } | |||
172 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
173 | } | |||
174 | ||||
175 | /* | |||
176 | Function much like DMStagMigrateVec(), but which accepts an additional position argument to disambiguate which | |||
177 | type of DMDA to migrate to. | |||
178 | */ | |||
179 | ||||
180 | static PetscErrorCode DMStagMigrateVecDMDA(DM dm,Vec vec,DMStagStencilLocation loc,PetscInt c,DM dmTo,Vec vecTo) | |||
181 | { | |||
182 | PetscErrorCode ierr; | |||
183 | PetscInt i,j,k,d,dim,dof,dofToMax,start[DMSTAG_MAX_DIM3],n[DMSTAG_MAX_DIM3],extraPoint[DMSTAG_MAX_DIM3]; | |||
184 | Vec vecLocal; | |||
185 | ||||
186 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 186; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
187 | PetscValidHeaderSpecificType(dm,DM_CLASSID,1,DMSTAG)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),187,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dm,"stag",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"stag",((PetscObject)dm)->type_name); } while (0); | |||
188 | PetscValidHeaderSpecific(vec,VEC_CLASSID,2)do { if (!vec) return PetscError(((MPI_Comm)0x44000001),188,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",85 ,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if (!PetscCheckPointer (vec,PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001), 188,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(vec))->classid != VEC_CLASSID) { if (((PetscObject)(vec))->classid == -1) return PetscError(( (MPI_Comm)0x44000001),188,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),188,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",2 ); } } while (0); | |||
189 | PetscValidHeaderSpecificType(dmTo,DM_CLASSID,4,DMDA)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dmTo ) return PetscError(((MPI_Comm)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",4); if ( !PetscCheckPointer(dmTo,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,4); if (((PetscObject)(dmTo))->classid != DM_CLASSID) { if (((PetscObject)(dmTo))->classid == -1) return PetscError( ((MPI_Comm)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,4); else return PetscError(((MPI_Comm)0x44000001),189,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",4 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dmTo,"da",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,4,"da",((PetscObject)dmTo)->type_name); } while (0); | |||
190 | PetscValidHeaderSpecific(vecTo,VEC_CLASSID,5)do { if (!vecTo) return PetscError(((MPI_Comm)0x44000001),190 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",5); if ( !PetscCheckPointer(vecTo,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,5); if (((PetscObject)(vecTo))->classid != VEC_CLASSID) { if (((PetscObject)(vecTo))->classid == -1) return PetscError (((MPI_Comm)0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,5); else return PetscError(((MPI_Comm)0x44000001),190,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",5 ); } } while (0); | |||
191 | ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),191,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
192 | ierr = DMDAGetDof(dmTo,&dofToMax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),192,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
193 | #if defined(PETSC_USE_DEBUG1) | |||
194 | if (-c > dofToMax) SETERRQ1(PetscObjectComm((PetscObject)dmTo),PETSC_ERR_ARG_OUTOFRANGE,"Invalid negative component value. Must be >= -%D",dofToMax)return PetscError(PetscObjectComm((PetscObject)dmTo),194,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",63 ,PETSC_ERROR_INITIAL,"Invalid negative component value. Must be >= -%D" ,dofToMax); | |||
195 | #endif | |||
196 | ierr = DMStagGetCorners(dm,&start[0],&start[1],&start[2],&n[0],&n[1],&n[2],NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),196,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
197 | ierr = DMStagDMDAGetExtraPoints(dm,loc,extraPoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),197,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
198 | ierr = DMStagGetLocationDOF(dm,loc,&dof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),198,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
199 | ierr = DMGetLocalVector(dm,&vecLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),199,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
200 | ierr = DMGlobalToLocalBegin(dm,vec,INSERT_VALUES,vecLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),200,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
201 | ierr = DMGlobalToLocalEnd(dm,vec,INSERT_VALUES,vecLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),201,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
202 | if (dim == 1) { | |||
203 | PetscScalar **arrTo; | |||
204 | ierr = DMDAVecGetArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),204,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
205 | if (c < 0) { | |||
206 | const PetscInt dofTo = -c; | |||
207 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
208 | for (d=0; d<PetscMin(dof,dofTo)(((dof)<(dofTo)) ? (dof) : (dofTo)); ++d) { | |||
209 | DMStagStencil pos; | |||
210 | pos.i = i; pos.loc = loc; pos.c = d; | |||
211 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[i][d]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),211,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
212 | } | |||
213 | for (;d<dofTo; ++d) { | |||
214 | arrTo[i][d] = 0.0; /* Pad extra dof with zeros */ | |||
215 | } | |||
216 | } | |||
217 | } else { | |||
218 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
219 | DMStagStencil pos; | |||
220 | pos.i = i; pos.loc = loc; pos.c = c; | |||
221 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[i][0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),221,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
222 | } | |||
223 | } | |||
224 | ierr = DMDAVecRestoreArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),224,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
225 | } else if (dim == 2) { | |||
226 | PetscScalar ***arrTo; | |||
227 | ierr = DMDAVecGetArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),227,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
228 | if (c < 0) { | |||
229 | const PetscInt dofTo = -c; | |||
230 | for (j=start[1]; j<start[1] + n[1] + extraPoint[1]; ++j) { | |||
231 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
232 | for (d=0; d<PetscMin(dof,dofTo)(((dof)<(dofTo)) ? (dof) : (dofTo)); ++d) { | |||
233 | DMStagStencil pos; | |||
234 | pos.i = i; pos.j = j; pos.loc = loc; pos.c = d; | |||
235 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[j][i][d]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),235,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
236 | } | |||
237 | for (;d<dofTo; ++d) { | |||
238 | arrTo[j][i][d] = 0.0; /* Pad extra dof with zeros */ | |||
239 | } | |||
240 | } | |||
241 | } | |||
242 | } else { | |||
243 | for (j=start[1]; j<start[1] + n[1] + extraPoint[1]; ++j) { | |||
244 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
245 | DMStagStencil pos; | |||
246 | pos.i = i; pos.j = j; pos.loc = loc; pos.c = c; | |||
247 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[j][i][0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
248 | } | |||
249 | } | |||
250 | } | |||
251 | ierr = DMDAVecRestoreArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),251,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
252 | } else if (dim == 3) { | |||
253 | PetscScalar ****arrTo; | |||
254 | ierr = DMDAVecGetArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
255 | if (c < 0) { | |||
256 | const PetscInt dofTo = -c; | |||
257 | for (k=start[2]; k<start[2] + n[2] + extraPoint[2]; ++k) { | |||
258 | for (j=start[1]; j<start[1] + n[1] + extraPoint[1]; ++j) { | |||
259 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
260 | for (d=0; d<PetscMin(dof,dofTo)(((dof)<(dofTo)) ? (dof) : (dofTo)); ++d) { | |||
261 | DMStagStencil pos; | |||
262 | pos.i = i; pos.j = j; pos.k = k; pos.loc = loc; pos.c = d; | |||
263 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[k][j][i][d]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),263,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
264 | } | |||
265 | for (;d<dofTo; ++d) { | |||
266 | arrTo[k][j][i][d] = 0.0; /* Pad extra dof with zeros */ | |||
267 | } | |||
268 | } | |||
269 | } | |||
270 | } | |||
271 | } else { | |||
272 | for (k=start[2]; k<start[2] + n[2] + extraPoint[2]; ++k) { | |||
273 | for (j=start[1]; j<start[1] + n[1] + extraPoint[1]; ++j) { | |||
274 | for (i=start[0]; i<start[0] + n[0] + extraPoint[0]; ++i) { | |||
275 | DMStagStencil pos; | |||
276 | pos.i = i; pos.j = j; pos.k = k; pos.loc = loc; pos.c = c; | |||
277 | ierr = DMStagVecGetValuesStencil(dm,vecLocal,1,&pos,&arrTo[k][j][i][0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),277,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
278 | } | |||
279 | } | |||
280 | } | |||
281 | } | |||
282 | ierr = DMDAVecRestoreArrayDOF(dmTo,vecTo,&arrTo);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),282,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
283 | } else SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Unsupported dimension %d",dim)return PetscError(PETSC_COMM_WORLD,283,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,56,PETSC_ERROR_INITIAL,"Unsupported dimension %d",dim); | |||
284 | ierr = DMRestoreLocalVector(dm,&vecLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
285 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
286 | } | |||
287 | ||||
288 | /* Transfer coordinates from a DMStag to a DMDA, specifying which location */ | |||
289 | static PetscErrorCode DMStagTransferCoordinatesToDMDA(DM dmstag,DMStagStencilLocation loc,DM dmda) | |||
290 | { | |||
291 | PetscErrorCode ierr; | |||
292 | PetscInt dim,start[DMSTAG_MAX_DIM3],n[DMSTAG_MAX_DIM3],extraPoint[DMSTAG_MAX_DIM3],d; | |||
293 | DM dmstagCoord,dmdaCoord; | |||
294 | DMType dmstagCoordType; | |||
295 | Vec stagCoord,daCoord; | |||
296 | PetscBool daCoordIsStag,daCoordIsProduct; | |||
297 | ||||
298 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 298; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
299 | PetscValidHeaderSpecificType(dmstag,DM_CLASSID,1,DMSTAG)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dmstag ) return PetscError(((MPI_Comm)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dmstag,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dmstag))->classid != DM_CLASSID) { if (((PetscObject)(dmstag))->classid == -1) return PetscError (((MPI_Comm)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),299,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dmstag,"stag",&_7_same);do {if (__builtin_expect(!!(_7_ierr ),0)) return PetscError(((MPI_Comm)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"stag",((PetscObject)dmstag)->type_name); } while (0); | |||
300 | PetscValidHeaderSpecificType(dmda,DM_CLASSID,3,DMDA)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dmda ) return PetscError(((MPI_Comm)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",3); if ( !PetscCheckPointer(dmda,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,3); if (((PetscObject)(dmda))->classid != DM_CLASSID) { if (((PetscObject)(dmda))->classid == -1) return PetscError( ((MPI_Comm)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,3); else return PetscError(((MPI_Comm)0x44000001),300,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",3 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dmda,"da",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,3,"da",((PetscObject)dmda)->type_name); } while (0); | |||
301 | ierr = DMGetDimension(dmstag,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
302 | ierr = DMGetCoordinateDM(dmstag,&dmstagCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),302,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
303 | ierr = DMGetCoordinatesLocal(dmstag,&stagCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),303,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); /* Note local */ | |||
304 | ierr = DMGetCoordinateDM(dmda,&dmdaCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),304,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
305 | daCoord = NULL((void*)0); | |||
306 | ierr = DMGetCoordinates(dmda,&daCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),306,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
307 | if (!daCoord) { | |||
| ||||
308 | ierr = DMCreateGlobalVector(dmdaCoord,&daCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),308,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
309 | ierr = DMSetCoordinates(dmda,daCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),309,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
310 | ierr = VecDestroy(&daCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),310,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
311 | ierr = DMGetCoordinates(dmda,&daCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),311,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
312 | } | |||
313 | ierr = DMGetType(dmstagCoord,&dmstagCoordType);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),313,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
314 | ierr = PetscStrcmp(dmstagCoordType,DMSTAG"stag",&daCoordIsStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),314,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
315 | ierr = PetscStrcmp(dmstagCoordType,DMPRODUCT"product",&daCoordIsProduct);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),315,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
316 | ierr = DMStagGetCorners(dmstag,&start[0],&start[1],&start[2],&n[0],&n[1],&n[2],NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),316,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
317 | ierr = DMStagDMDAGetExtraPoints(dmstag,loc,extraPoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),317,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
318 | if (dim == 1) { | |||
319 | PetscInt ex; | |||
320 | PetscScalar **cArrDa; | |||
321 | ierr = DMDAVecGetArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),321,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
322 | if (daCoordIsStag) { | |||
323 | PetscInt slot; | |||
324 | PetscScalar **cArrStag; | |||
325 | ierr = DMStagGetLocationSlot(dmstagCoord,loc,0,&slot);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),325,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
326 | ierr = DMStagVecGetArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),326,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
327 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
328 | cArrDa[ex][0] = cArrStag[ex][slot]; | |||
329 | } | |||
330 | ierr = DMStagVecRestoreArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),330,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
331 | } else if (daCoordIsProduct) { | |||
332 | PetscScalar **cArrX; | |||
333 | ierr = DMStagGet1dCoordinateArraysDOFRead(dmstag,&cArrX,NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),333,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
334 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
335 | cArrDa[ex][0] = cArrX[ex][0]; | |||
336 | } | |||
337 | ierr = DMStagRestore1dCoordinateArraysDOFRead(dmstag,&cArrX,NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
338 | } else SETERRQ(PetscObjectComm((PetscObject)dmstag),PETSC_ERR_SUP,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct")return PetscError(PetscObjectComm((PetscObject)dmstag),338,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct" ); | |||
339 | ierr = DMDAVecRestoreArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),339,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
340 | } else if (dim == 2) { | |||
341 | PetscInt ex,ey; | |||
342 | PetscScalar ***cArrDa; | |||
343 | ierr = DMDAVecGetArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),343,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
344 | if (daCoordIsStag) { | |||
345 | PetscInt slot; | |||
346 | PetscScalar ***cArrStag; | |||
347 | ierr = DMStagGetLocationSlot(dmstagCoord,loc,0,&slot);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
348 | ierr = DMStagVecGetArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),348,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
349 | for (ey=start[1]; ey<start[1] + n[1] + extraPoint[1]; ++ey) { | |||
350 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
351 | for (d=0; d<2; ++d) { | |||
352 | cArrDa[ey][ex][d] = cArrStag[ey][ex][slot+d]; | |||
353 | } | |||
354 | } | |||
355 | } | |||
356 | ierr = DMStagVecRestoreArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),356,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
357 | } else if (daCoordIsProduct) { | |||
358 | PetscScalar **cArrX,**cArrY; | |||
359 | ierr = DMStagGet1dCoordinateArraysDOFRead(dmstag,&cArrX,&cArrY,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
360 | for (ey=start[1]; ey<start[1] + n[1] + extraPoint[1]; ++ey) { | |||
| ||||
361 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
362 | cArrDa[ey][ex][0] = cArrX[ex][0]; | |||
363 | cArrDa[ey][ex][1] = cArrY[ey][0]; | |||
364 | } | |||
365 | } | |||
366 | ierr = DMStagRestore1dCoordinateArraysDOFRead(dmstag,&cArrX,&cArrY,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),366,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
367 | } else SETERRQ(PetscObjectComm((PetscObject)dmstag),PETSC_ERR_SUP,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct")return PetscError(PetscObjectComm((PetscObject)dmstag),367,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct" ); | |||
368 | ierr = DMDAVecRestoreArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),368,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
369 | } else if (dim == 3) { | |||
370 | PetscInt ex,ey,ez; | |||
371 | PetscScalar ****cArrDa; | |||
372 | ierr = DMDAVecGetArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),372,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
373 | if (daCoordIsStag) { | |||
374 | PetscInt slot; | |||
375 | PetscScalar ****cArrStag; | |||
376 | ierr = DMStagGetLocationSlot(dmstagCoord,loc,0,&slot);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),376,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
377 | ierr = DMStagVecGetArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),377,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
378 | for (ez=start[2]; ez<start[2] + n[2] + extraPoint[2]; ++ez) { | |||
379 | for (ey=start[1]; ey<start[1] + n[1] + extraPoint[1]; ++ey) { | |||
380 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
381 | for (d=0; d<3; ++d) { | |||
382 | cArrDa[ez][ey][ex][d] = cArrStag[ez][ey][ex][slot+d]; | |||
383 | } | |||
384 | } | |||
385 | } | |||
386 | } | |||
387 | ierr = DMStagVecRestoreArrayDOFRead(dmstagCoord,stagCoord,&cArrStag);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),387,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
388 | } else if (daCoordIsProduct) { | |||
389 | PetscScalar **cArrX,**cArrY,**cArrZ; | |||
390 | ierr = DMStagGet1dCoordinateArraysDOFRead(dmstag,&cArrX,&cArrY,&cArrZ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),390,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
391 | for (ez=start[2]; ez<start[2] + n[2] + extraPoint[2]; ++ez) { | |||
392 | for (ey=start[1]; ey<start[1] + n[1] + extraPoint[1]; ++ey) { | |||
393 | for (ex=start[0]; ex<start[0] + n[0] + extraPoint[0]; ++ex) { | |||
394 | cArrDa[ez][ey][ex][0] = cArrX[ex][0]; | |||
395 | cArrDa[ez][ey][ex][1] = cArrY[ey][0]; | |||
396 | cArrDa[ez][ey][ex][2] = cArrZ[ez][0]; | |||
397 | } | |||
398 | } | |||
399 | } | |||
400 | ierr = DMStagRestore1dCoordinateArraysDOFRead(dmstag,&cArrX,&cArrY,&cArrZ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),400,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
401 | } else SETERRQ(PetscObjectComm((PetscObject)dmstag),PETSC_ERR_SUP,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct")return PetscError(PetscObjectComm((PetscObject)dmstag),401,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",56 ,PETSC_ERROR_INITIAL,"Stag to DA coordinate transfer only supported for DMStag coordinate DM of type DMstag or DMProduct" ); | |||
402 | ierr = DMDAVecRestoreArrayDOF(dmdaCoord,daCoord,&cArrDa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),402,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
403 | } else SETERRQ1(PETSC_COMM_WORLD,PETSC_ERR_SUP,"Unsupported dimension %d",dim)return PetscError(PETSC_COMM_WORLD,403,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,56,PETSC_ERROR_INITIAL,"Unsupported dimension %d",dim); | |||
404 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
405 | } | |||
406 | ||||
407 | /* | |||
408 | Convert to a location value with only BACK, DOWN, LEFT, and ELEMENT involved (makes looping easier) | |||
409 | */ | |||
410 | static PetscErrorCode DMStagStencilLocationCanonicalize(DMStagStencilLocation loc,DMStagStencilLocation *locCanonical) | |||
411 | { | |||
412 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 412; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
413 | switch (loc) { | |||
414 | case DMSTAG_ELEMENT: | |||
415 | *locCanonical = DMSTAG_ELEMENT; | |||
416 | break; | |||
417 | case DMSTAG_LEFT: | |||
418 | case DMSTAG_RIGHT: | |||
419 | *locCanonical = DMSTAG_LEFT; | |||
420 | break; | |||
421 | case DMSTAG_DOWN: | |||
422 | case DMSTAG_UP: | |||
423 | *locCanonical = DMSTAG_DOWN; | |||
424 | break; | |||
425 | case DMSTAG_BACK: | |||
426 | case DMSTAG_FRONT: | |||
427 | *locCanonical = DMSTAG_BACK; | |||
428 | break; | |||
429 | case DMSTAG_DOWN_LEFT : | |||
430 | case DMSTAG_DOWN_RIGHT : | |||
431 | case DMSTAG_UP_LEFT : | |||
432 | case DMSTAG_UP_RIGHT : | |||
433 | *locCanonical = DMSTAG_DOWN_LEFT; | |||
434 | break; | |||
435 | case DMSTAG_BACK_LEFT: | |||
436 | case DMSTAG_BACK_RIGHT: | |||
437 | case DMSTAG_FRONT_LEFT: | |||
438 | case DMSTAG_FRONT_RIGHT: | |||
439 | *locCanonical = DMSTAG_BACK_LEFT; | |||
440 | break; | |||
441 | case DMSTAG_BACK_DOWN: | |||
442 | case DMSTAG_BACK_UP: | |||
443 | case DMSTAG_FRONT_DOWN: | |||
444 | case DMSTAG_FRONT_UP: | |||
445 | *locCanonical = DMSTAG_BACK_DOWN; | |||
446 | break; | |||
447 | case DMSTAG_BACK_DOWN_LEFT: | |||
448 | case DMSTAG_BACK_DOWN_RIGHT: | |||
449 | case DMSTAG_BACK_UP_LEFT: | |||
450 | case DMSTAG_BACK_UP_RIGHT: | |||
451 | case DMSTAG_FRONT_DOWN_LEFT: | |||
452 | case DMSTAG_FRONT_DOWN_RIGHT: | |||
453 | case DMSTAG_FRONT_UP_LEFT: | |||
454 | case DMSTAG_FRONT_UP_RIGHT: | |||
455 | *locCanonical = DMSTAG_BACK_DOWN_LEFT; | |||
456 | break; | |||
457 | default : | |||
458 | *locCanonical = DMSTAG_NULL_LOCATION; | |||
459 | break; | |||
460 | } | |||
461 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
462 | } | |||
463 | ||||
464 | /*@C | |||
465 | DMStagVecSplitToDMDA - create a DMDA and Vec from a DMStag and Vec | |||
466 | ||||
467 | Logically Collective | |||
468 | ||||
469 | High-level helper function which accepts a DMStag, a global vector, and location/dof, | |||
470 | and generates a corresponding DMDA and Vec. | |||
471 | ||||
472 | Input Parameters: | |||
473 | + dm - the DMStag object | |||
474 | . vec- Vec object associated with dm | |||
475 | . loc - which subgrid to extract (see DMStagStencilLocation) | |||
476 | - c - which component to extract (see note below) | |||
477 | ||||
478 | Output Parameters: | |||
479 | + pda - the new DMDA | |||
480 | - pdavec - the new Vec | |||
481 | ||||
482 | Notes: | |||
483 | If a c value of -k is provided, the first k dof for that position are extracted, | |||
484 | padding with zero values if needbe. If a non-negative value is provided, a single | |||
485 | dof is extracted. | |||
486 | ||||
487 | The caller is responsible for destroying the created DMDA and Vec. | |||
488 | ||||
489 | Level: advanced | |||
490 | ||||
491 | .seealso: DMSTAG, DMStagMigrateVec(), DMStagCreateCompatibleDMStag() | |||
492 | @*/ | |||
493 | PetscErrorCode DMStagVecSplitToDMDA(DM dm,Vec vec,DMStagStencilLocation loc,PetscInt c,DM *pda,Vec *pdavec) | |||
494 | { | |||
495 | PetscErrorCode ierr; | |||
496 | PetscInt dim,locdof; | |||
497 | DM da,coordDM; | |||
498 | Vec davec; | |||
499 | DMStagStencilLocation locCanonical; | |||
500 | ||||
501 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ; petscstack->line[petscstack->currentsize] = 501; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
502 | PetscValidHeaderSpecificType(dm,DM_CLASSID,1,DMSTAG)do { PetscErrorCode _7_ierr; PetscBool _7_same; do { if (!dm) return PetscError(((MPI_Comm)0x44000001),502,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),502,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,1); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),502,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),502,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",1 ); } } while (0); _7_ierr = PetscObjectTypeCompare((PetscObject )dm,"stag",&_7_same);do {if (__builtin_expect(!!(_7_ierr) ,0)) return PetscError(((MPI_Comm)0x44000001),502,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!_7_same) return PetscError(((MPI_Comm)0x44000001),502,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,62,PETSC_ERROR_INITIAL,"Wrong subtype object:Parameter # %d must have implementation %s it is %s" ,1,"stag",((PetscObject)dm)->type_name); } while (0); | |||
503 | PetscValidHeaderSpecific(vec,VEC_CLASSID,2)do { if (!vec) return PetscError(((MPI_Comm)0x44000001),503,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",85 ,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if (!PetscCheckPointer (vec,PETSC_OBJECT)) return PetscError(((MPI_Comm)0x44000001), 503,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(vec))->classid != VEC_CLASSID) { if (((PetscObject)(vec))->classid == -1) return PetscError(( (MPI_Comm)0x44000001),503,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),503,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",62 ,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d",2 ); } } while (0); | |||
504 | ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),504,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
505 | ierr = DMStagGetLocationDOF(dm,loc,&locdof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),505,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
506 | if (c >= locdof) SETERRQ3(PetscObjectComm((PetscObject)dm),PETSC_ERR_ARG_OUTOFRANGE,"Location %s has %D dof, but component %D requested\n",DMStagStencilLocations[loc],locdof,c)return PetscError(PetscObjectComm((PetscObject)dm),506,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c",63 ,PETSC_ERROR_INITIAL,"Location %s has %D dof, but component %D requested\n" ,DMStagStencilLocations[loc],locdof,c); | |||
507 | ierr = DMStagStencilLocationCanonicalize(loc,&locCanonical);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),507,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
508 | ierr = DMStagCreateCompatibleDMDA(dm,locCanonical,c,pda);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),508,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
509 | da = *pda; | |||
510 | ierr = DMSetUp(*pda);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),510,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
511 | ierr = DMGetCoordinateDM(dm,&coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),511,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
512 | if (coordDM) { | |||
513 | ierr = DMStagTransferCoordinatesToDMDA(dm,locCanonical,da);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),513,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
514 | } | |||
515 | ierr = DMCreateGlobalVector(da,pdavec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),515,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
516 | davec = *pdavec; | |||
517 | ierr = DMStagMigrateVecDMDA(dm,vec,locCanonical,c,da,davec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),517,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/stag/stagda.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
518 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
519 | } |