Bug Summary

File:dm/impls/plex/plexgeometry.c
Warning:line 540, column 30
The right operand of '*' is a garbage value

Annotated Source Code

[?] Use j/k keys for keyboard navigation

/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c

1#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
2#include <petsc/private/petscfeimpl.h> /*I "petscfe.h" I*/
3#include <petscblaslapack.h>
4#include <petsctime.h>
5
6/*@
7 DMPlexFindVertices - Try to find DAG points based on their coordinates.
8
9 Not Collective (provided DMGetCoordinatesLocalSetUp() has been called already)
10
11 Input Parameters:
12+ dm - The DMPlex object
13. npoints - The number of sought points
14. coords - The array of coordinates of the sought points
15- eps - The tolerance or PETSC_DEFAULT
16
17 Output Parameters:
18. dagPoints - The array of found DAG points, or -1 if not found
19
20 Level: intermediate
21
22 Notes:
23 The length of the array coords must be npoints * dim where dim is the spatial dimension returned by DMGetDimension().
24
25 The output array dagPoints is NOT newly allocated; the user must pass an array of length npoints.
26
27 Each rank does the search independently; a nonnegative value is returned only if this rank's local DMPlex portion contains the point.
28
29 The tolerance is interpreted as the maximum Euclidean (L2) distance of the sought point from the specified coordinates.
30
31.seealso: DMPlexCreate(), DMGetCoordinates()
32@*/
33PetscErrorCode DMPlexFindVertices(DM dm, PetscInt npoints, const PetscReal coord[], PetscReal eps, PetscInt dagPoints[])
34{
35 PetscInt c, dim, i, j, ndof, o, p, vStart, vEnd;
36 PetscSection cs;
37 Vec allCoordsVec;
38 const PetscScalar *allCoords;
39 PetscReal norm;
40 PetscErrorCode ierr;
41
42 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 42; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
43 if (eps < 0) eps = PETSC_SQRT_MACHINE_EPSILON1.490116119384766e-08;
44 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),44,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
45 ierr = DMGetCoordinateSection(dm, &cs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),45,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
46 ierr = DMGetCoordinatesLocal(dm, &allCoordsVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),46,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
47 ierr = VecGetArrayRead(allCoordsVec, &allCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),47,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
48 ierr = DMPlexGetDepthStratum(dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),48,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
49 for (i=0,j=0; i < npoints; i++,j+=dim) {
50 dagPoints[i] = -1;
51 for (p = vStart; p < vEnd; p++) {
52 ierr = PetscSectionGetOffset(cs, p, &o);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),52,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
53 ierr = PetscSectionGetDof(cs, p, &ndof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),53,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
54 if (PetscUnlikely(ndof != dim)__builtin_expect(!!(ndof != dim),0)) SETERRQ3(PETSC_COMM_SELF, PETSC_ERR_PLIB, "point %D: ndof = %D != %D = dim", p, ndof, dim)return PetscError(((MPI_Comm)0x44000001),54,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"point %D: ndof = %D != %D = dim",p,ndof
,dim)
;
55 norm = 0.0;
56 for (c = 0; c < dim; c++) {
57 norm += PetscSqr(coord[j+c] - PetscRealPart(allCoords[o+c]))((coord[j+c] - (allCoords[o+c]))*(coord[j+c] - (allCoords[o+c
])))
;
58 }
59 norm = PetscSqrtReal(norm)sqrt(norm);
60 if (norm <= eps) {
61 dagPoints[i] = p;
62 break;
63 }
64 }
65 }
66 ierr = VecRestoreArrayRead(allCoordsVec, &allCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
67 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)
;
68}
69
70static PetscErrorCode DMPlexGetLineIntersection_2D_Internal(const PetscReal segmentA[], const PetscReal segmentB[], PetscReal intersection[], PetscBool *hasIntersection)
71{
72 const PetscReal p0_x = segmentA[0*2+0];
73 const PetscReal p0_y = segmentA[0*2+1];
74 const PetscReal p1_x = segmentA[1*2+0];
75 const PetscReal p1_y = segmentA[1*2+1];
76 const PetscReal p2_x = segmentB[0*2+0];
77 const PetscReal p2_y = segmentB[0*2+1];
78 const PetscReal p3_x = segmentB[1*2+0];
79 const PetscReal p3_y = segmentB[1*2+1];
80 const PetscReal s1_x = p1_x - p0_x;
81 const PetscReal s1_y = p1_y - p0_y;
82 const PetscReal s2_x = p3_x - p2_x;
83 const PetscReal s2_y = p3_y - p2_y;
84 const PetscReal denom = (-s2_x * s1_y + s1_x * s2_y);
85
86 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 86; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
87 *hasIntersection = PETSC_FALSE;
88 /* Non-parallel lines */
89 if (denom != 0.0) {
90 const PetscReal s = (-s1_y * (p0_x - p2_x) + s1_x * (p0_y - p2_y)) / denom;
91 const PetscReal t = ( s2_x * (p0_y - p2_y) - s2_y * (p0_x - p2_x)) / denom;
92
93 if (s >= 0 && s <= 1 && t >= 0 && t <= 1) {
94 *hasIntersection = PETSC_TRUE;
95 if (intersection) {
96 intersection[0] = p0_x + (t * s1_x);
97 intersection[1] = p0_y + (t * s1_y);
98 }
99 }
100 }
101 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)
;
102}
103
104static PetscErrorCode DMPlexLocatePoint_Simplex_2D_Internal(DM dm, const PetscScalar point[], PetscInt c, PetscInt *cell)
105{
106 const PetscInt embedDim = 2;
107 const PetscReal eps = PETSC_SQRT_MACHINE_EPSILON1.490116119384766e-08;
108 PetscReal x = PetscRealPart(point[0])(point[0]);
109 PetscReal y = PetscRealPart(point[1])(point[1]);
110 PetscReal v0[2], J[4], invJ[4], detJ;
111 PetscReal xi, eta;
112 PetscErrorCode ierr;
113
114 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 114; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
115 ierr = DMPlexComputeCellGeometryFEM(dm, c, NULL((void*)0), v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),115,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
116 xi = invJ[0*embedDim+0]*(x - v0[0]) + invJ[0*embedDim+1]*(y - v0[1]);
117 eta = invJ[1*embedDim+0]*(x - v0[0]) + invJ[1*embedDim+1]*(y - v0[1]);
118
119 if ((xi >= -eps) && (eta >= -eps) && (xi + eta <= 2.0+eps)) *cell = c;
120 else *cell = DMLOCATEPOINT_POINT_NOT_FOUND-367;
121 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)
;
122}
123
124static PetscErrorCode DMPlexClosestPoint_Simplex_2D_Internal(DM dm, const PetscScalar point[], PetscInt c, PetscReal cpoint[])
125{
126 const PetscInt embedDim = 2;
127 PetscReal x = PetscRealPart(point[0])(point[0]);
128 PetscReal y = PetscRealPart(point[1])(point[1]);
129 PetscReal v0[2], J[4], invJ[4], detJ;
130 PetscReal xi, eta, r;
131 PetscErrorCode ierr;
132
133 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 133; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
134 ierr = DMPlexComputeCellGeometryFEM(dm, c, NULL((void*)0), v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),134,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
135 xi = invJ[0*embedDim+0]*(x - v0[0]) + invJ[0*embedDim+1]*(y - v0[1]);
136 eta = invJ[1*embedDim+0]*(x - v0[0]) + invJ[1*embedDim+1]*(y - v0[1]);
137
138 xi = PetscMax(xi, 0.0)(((xi)<(0.0)) ? (0.0) : (xi));
139 eta = PetscMax(eta, 0.0)(((eta)<(0.0)) ? (0.0) : (eta));
140 if (xi + eta > 2.0) {
141 r = (xi + eta)/2.0;
142 xi /= r;
143 eta /= r;
144 }
145 cpoint[0] = J[0*embedDim+0]*xi + J[0*embedDim+1]*eta + v0[0];
146 cpoint[1] = J[1*embedDim+0]*xi + J[1*embedDim+1]*eta + v0[1];
147 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)
;
148}
149
150static PetscErrorCode DMPlexLocatePoint_General_2D_Internal(DM dm, const PetscScalar point[], PetscInt c, PetscInt *cell)
151{
152 PetscSection coordSection;
153 Vec coordsLocal;
154 PetscScalar *coords = NULL((void*)0);
155 const PetscInt faces[8] = {0, 1, 1, 2, 2, 3, 3, 0};
156 PetscReal x = PetscRealPart(point[0])(point[0]);
157 PetscReal y = PetscRealPart(point[1])(point[1]);
158 PetscInt crossings = 0, f;
159 PetscErrorCode ierr;
160
161 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 161; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
162 ierr = DMGetCoordinatesLocal(dm, &coordsLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),162,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
163 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),163,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
164 ierr = DMPlexVecGetClosure(dm, coordSection, coordsLocal, c, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),164,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
165 for (f = 0; f < 4; ++f) {
166 PetscReal x_i = PetscRealPart(coords[faces[2*f+0]*2+0])(coords[faces[2*f+0]*2+0]);
167 PetscReal y_i = PetscRealPart(coords[faces[2*f+0]*2+1])(coords[faces[2*f+0]*2+1]);
168 PetscReal x_j = PetscRealPart(coords[faces[2*f+1]*2+0])(coords[faces[2*f+1]*2+0]);
169 PetscReal y_j = PetscRealPart(coords[faces[2*f+1]*2+1])(coords[faces[2*f+1]*2+1]);
170 PetscReal slope = (y_j - y_i) / (x_j - x_i);
171 PetscBool cond1 = (x_i <= x) && (x < x_j) ? PETSC_TRUE : PETSC_FALSE;
172 PetscBool cond2 = (x_j <= x) && (x < x_i) ? PETSC_TRUE : PETSC_FALSE;
173 PetscBool above = (y < slope * (x - x_i) + y_i) ? PETSC_TRUE : PETSC_FALSE;
174 if ((cond1 || cond2) && above) ++crossings;
175 }
176 if (crossings % 2) *cell = c;
177 else *cell = DMLOCATEPOINT_POINT_NOT_FOUND-367;
178 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordsLocal, c, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),178,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
179 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)
;
180}
181
182static PetscErrorCode DMPlexLocatePoint_Simplex_3D_Internal(DM dm, const PetscScalar point[], PetscInt c, PetscInt *cell)
183{
184 const PetscInt embedDim = 3;
185 PetscReal v0[3], J[9], invJ[9], detJ;
186 PetscReal x = PetscRealPart(point[0])(point[0]);
187 PetscReal y = PetscRealPart(point[1])(point[1]);
188 PetscReal z = PetscRealPart(point[2])(point[2]);
189 PetscReal xi, eta, zeta;
190 PetscErrorCode ierr;
191
192 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 192; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
193 ierr = DMPlexComputeCellGeometryFEM(dm, c, NULL((void*)0), v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),193,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
194 xi = invJ[0*embedDim+0]*(x - v0[0]) + invJ[0*embedDim+1]*(y - v0[1]) + invJ[0*embedDim+2]*(z - v0[2]);
195 eta = invJ[1*embedDim+0]*(x - v0[0]) + invJ[1*embedDim+1]*(y - v0[1]) + invJ[1*embedDim+2]*(z - v0[2]);
196 zeta = invJ[2*embedDim+0]*(x - v0[0]) + invJ[2*embedDim+1]*(y - v0[1]) + invJ[2*embedDim+2]*(z - v0[2]);
197
198 if ((xi >= 0.0) && (eta >= 0.0) && (zeta >= 0.0) && (xi + eta + zeta <= 2.0)) *cell = c;
199 else *cell = DMLOCATEPOINT_POINT_NOT_FOUND-367;
200 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)
;
201}
202
203static PetscErrorCode DMPlexLocatePoint_General_3D_Internal(DM dm, const PetscScalar point[], PetscInt c, PetscInt *cell)
204{
205 PetscSection coordSection;
206 Vec coordsLocal;
207 PetscScalar *coords = NULL((void*)0);
208 const PetscInt faces[24] = {0, 3, 2, 1, 5, 4, 7, 6, 3, 0, 4, 5,
209 1, 2, 6, 7, 3, 5, 6, 2, 0, 1, 7, 4};
210 PetscBool found = PETSC_TRUE;
211 PetscInt f;
212 PetscErrorCode ierr;
213
214 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 214; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
215 ierr = DMGetCoordinatesLocal(dm, &coordsLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),215,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
216 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),216,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
217 ierr = DMPlexVecGetClosure(dm, coordSection, coordsLocal, c, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
218 for (f = 0; f < 6; ++f) {
219 /* Check the point is under plane */
220 /* Get face normal */
221 PetscReal v_i[3];
222 PetscReal v_j[3];
223 PetscReal normal[3];
224 PetscReal pp[3];
225 PetscReal dot;
226
227 v_i[0] = PetscRealPart(coords[faces[f*4+3]*3+0]-coords[faces[f*4+0]*3+0])(coords[faces[f*4+3]*3+0]-coords[faces[f*4+0]*3+0]);
228 v_i[1] = PetscRealPart(coords[faces[f*4+3]*3+1]-coords[faces[f*4+0]*3+1])(coords[faces[f*4+3]*3+1]-coords[faces[f*4+0]*3+1]);
229 v_i[2] = PetscRealPart(coords[faces[f*4+3]*3+2]-coords[faces[f*4+0]*3+2])(coords[faces[f*4+3]*3+2]-coords[faces[f*4+0]*3+2]);
230 v_j[0] = PetscRealPart(coords[faces[f*4+1]*3+0]-coords[faces[f*4+0]*3+0])(coords[faces[f*4+1]*3+0]-coords[faces[f*4+0]*3+0]);
231 v_j[1] = PetscRealPart(coords[faces[f*4+1]*3+1]-coords[faces[f*4+0]*3+1])(coords[faces[f*4+1]*3+1]-coords[faces[f*4+0]*3+1]);
232 v_j[2] = PetscRealPart(coords[faces[f*4+1]*3+2]-coords[faces[f*4+0]*3+2])(coords[faces[f*4+1]*3+2]-coords[faces[f*4+0]*3+2]);
233 normal[0] = v_i[1]*v_j[2] - v_i[2]*v_j[1];
234 normal[1] = v_i[2]*v_j[0] - v_i[0]*v_j[2];
235 normal[2] = v_i[0]*v_j[1] - v_i[1]*v_j[0];
236 pp[0] = PetscRealPart(coords[faces[f*4+0]*3+0] - point[0])(coords[faces[f*4+0]*3+0] - point[0]);
237 pp[1] = PetscRealPart(coords[faces[f*4+0]*3+1] - point[1])(coords[faces[f*4+0]*3+1] - point[1]);
238 pp[2] = PetscRealPart(coords[faces[f*4+0]*3+2] - point[2])(coords[faces[f*4+0]*3+2] - point[2]);
239 dot = normal[0]*pp[0] + normal[1]*pp[1] + normal[2]*pp[2];
240
241 /* Check that projected point is in face (2D location problem) */
242 if (dot < 0.0) {
243 found = PETSC_FALSE;
244 break;
245 }
246 }
247 if (found) *cell = c;
248 else *cell = DMLOCATEPOINT_POINT_NOT_FOUND-367;
249 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordsLocal, c, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),249,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
250 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)
;
251}
252
253static PetscErrorCode PetscGridHashInitialize_Internal(PetscGridHash box, PetscInt dim, const PetscScalar point[])
254{
255 PetscInt d;
256
257 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 257; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
258 box->dim = dim;
259 for (d = 0; d < dim; ++d) box->lower[d] = box->upper[d] = PetscRealPart(point[d])(point[d]);
260 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)
;
261}
262
263PetscErrorCode PetscGridHashCreate(MPI_Comm comm, PetscInt dim, const PetscScalar point[], PetscGridHash *box)
264{
265 PetscErrorCode ierr;
266
267 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 267; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
268 ierr = PetscMalloc1(1, box)PetscMallocA(1,PETSC_FALSE,268,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(1)*sizeof(**(box)),(box))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 ierr = PetscGridHashInitialize_Internal(*box, dim, point);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),269,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
270 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)
;
271}
272
273PetscErrorCode PetscGridHashEnlarge(PetscGridHash box, const PetscScalar point[])
274{
275 PetscInt d;
276
277 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 277; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
278 for (d = 0; d < box->dim; ++d) {
279 box->lower[d] = PetscMin(box->lower[d], PetscRealPart(point[d]))(((box->lower[d])<((point[d]))) ? (box->lower[d]) : (
(point[d])))
;
280 box->upper[d] = PetscMax(box->upper[d], PetscRealPart(point[d]))(((box->upper[d])<((point[d]))) ? ((point[d])) : (box->
upper[d]))
;
281 }
282 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)
;
283}
284
285/*
286 PetscGridHashSetGrid - Divide the grid into boxes
287
288 Not collective
289
290 Input Parameters:
291+ box - The grid hash object
292. n - The number of boxes in each dimension, or PETSC_DETERMINE
293- h - The box size in each dimension, only used if n[d] == PETSC_DETERMINE
294
295 Level: developer
296
297.seealso: PetscGridHashCreate()
298*/
299PetscErrorCode PetscGridHashSetGrid(PetscGridHash box, const PetscInt n[], const PetscReal h[])
300{
301 PetscInt d;
302
303 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 303; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
304 for (d = 0; d < box->dim; ++d) {
305 box->extent[d] = box->upper[d] - box->lower[d];
306 if (n[d] == PETSC_DETERMINE-1) {
307 box->h[d] = h[d];
308 box->n[d] = PetscCeilReal(box->extent[d]/h[d])ceil(box->extent[d]/h[d]);
309 } else {
310 box->n[d] = n[d];
311 box->h[d] = box->extent[d]/n[d];
312 }
313 }
314 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)
;
315}
316
317/*
318 PetscGridHashGetEnclosingBox - Find the grid boxes containing each input point
319
320 Not collective
321
322 Input Parameters:
323+ box - The grid hash object
324. numPoints - The number of input points
325- points - The input point coordinates
326
327 Output Parameters:
328+ dboxes - An array of numPoints*dim integers expressing the enclosing box as (i_0, i_1, ..., i_dim)
329- boxes - An array of numPoints integers expressing the enclosing box as single number, or NULL
330
331 Level: developer
332
333.seealso: PetscGridHashCreate()
334*/
335PetscErrorCode PetscGridHashGetEnclosingBox(PetscGridHash box, PetscInt numPoints, const PetscScalar points[], PetscInt dboxes[], PetscInt boxes[])
336{
337 const PetscReal *lower = box->lower;
338 const PetscReal *upper = box->upper;
339 const PetscReal *h = box->h;
340 const PetscInt *n = box->n;
341 const PetscInt dim = box->dim;
342 PetscInt d, p;
343
344 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 344; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
345 for (p = 0; p < numPoints; ++p) {
346 for (d = 0; d < dim; ++d) {
347 PetscInt dbox = PetscFloorReal((PetscRealPart(points[p*dim+d]) - lower[d])/h[d])floor(((points[p*dim+d]) - lower[d])/h[d]);
348
349 if (dbox == n[d] && PetscAbsReal(PetscRealPart(points[p*dim+d]) - upper[d])fabs((points[p*dim+d]) - upper[d]) < 1.0e-9) dbox = n[d]-1;
350 if (dbox == -1 && PetscAbsReal(PetscRealPart(points[p*dim+d]) - lower[d])fabs((points[p*dim+d]) - lower[d]) < 1.0e-9) dbox = 0;
351 if (dbox < 0 || dbox >= n[d]) SETERRQ4(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Input point %d (%g, %g, %g) is outside of our bounding box",return PetscError(((MPI_Comm)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Input point %d (%g, %g, %g) is outside of our bounding box"
,p,(points[p*dim+0]),dim > 1 ? (points[p*dim+1]) : 0.0,dim
> 2 ? (points[p*dim+2]) : 0.0)
352 p, PetscRealPart(points[p*dim+0]), dim > 1 ? PetscRealPart(points[p*dim+1]) : 0.0, dim > 2 ? PetscRealPart(points[p*dim+2]) : 0.0)return PetscError(((MPI_Comm)0x44000001),352,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Input point %d (%g, %g, %g) is outside of our bounding box"
,p,(points[p*dim+0]),dim > 1 ? (points[p*dim+1]) : 0.0,dim
> 2 ? (points[p*dim+2]) : 0.0)
;
353 dboxes[p*dim+d] = dbox;
354 }
355 if (boxes) for (d = 1, boxes[p] = dboxes[p*dim]; d < dim; ++d) boxes[p] += dboxes[p*dim+d]*n[d-1];
356 }
357 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)
;
358}
359
360/*
361 PetscGridHashGetEnclosingBoxQuery - Find the grid boxes containing each input point
362
363 Not collective
364
365 Input Parameters:
366+ box - The grid hash object
367. numPoints - The number of input points
368- points - The input point coordinates
369
370 Output Parameters:
371+ dboxes - An array of numPoints*dim integers expressing the enclosing box as (i_0, i_1, ..., i_dim)
372. boxes - An array of numPoints integers expressing the enclosing box as single number, or NULL
373- found - Flag indicating if point was located within a box
374
375 Level: developer
376
377.seealso: PetscGridHashGetEnclosingBox()
378*/
379PetscErrorCode PetscGridHashGetEnclosingBoxQuery(PetscGridHash box, PetscInt numPoints, const PetscScalar points[], PetscInt dboxes[], PetscInt boxes[],PetscBool *found)
380{
381 const PetscReal *lower = box->lower;
382 const PetscReal *upper = box->upper;
383 const PetscReal *h = box->h;
384 const PetscInt *n = box->n;
385 const PetscInt dim = box->dim;
386 PetscInt d, p;
387
388 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 388; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
389 *found = PETSC_FALSE;
390 for (p = 0; p < numPoints; ++p) {
391 for (d = 0; d < dim; ++d) {
392 PetscInt dbox = PetscFloorReal((PetscRealPart(points[p*dim+d]) - lower[d])/h[d])floor(((points[p*dim+d]) - lower[d])/h[d]);
393
394 if (dbox == n[d] && PetscAbsReal(PetscRealPart(points[p*dim+d]) - upper[d])fabs((points[p*dim+d]) - upper[d]) < 1.0e-9) dbox = n[d]-1;
395 if (dbox < 0 || dbox >= n[d]) {
396 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)
;
397 }
398 dboxes[p*dim+d] = dbox;
399 }
400 if (boxes) for (d = 1, boxes[p] = dboxes[p*dim]; d < dim; ++d) boxes[p] += dboxes[p*dim+d]*n[d-1];
401 }
402 *found = PETSC_TRUE;
403 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)
;
404}
405
406PetscErrorCode PetscGridHashDestroy(PetscGridHash *box)
407{
408 PetscErrorCode ierr;
409
410 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 410; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
411 if (*box) {
412 ierr = PetscSectionDestroy(&(*box)->cellSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
413 ierr = ISDestroy(&(*box)->cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),413,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
414 ierr = DMLabelDestroy(&(*box)->cellsSparse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),414,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
415 }
416 ierr = PetscFree(*box)((*PetscTrFree)((void*)(*box),416,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((*box) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),416,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
417 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)
;
418}
419
420PetscErrorCode DMPlexLocatePoint_Internal(DM dm, PetscInt dim, const PetscScalar point[], PetscInt cellStart, PetscInt *cell)
421{
422 PetscInt coneSize;
423 PetscErrorCode ierr;
424
425 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 425; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
426 switch (dim) {
427 case 2:
428 ierr = DMPlexGetConeSize(dm, cellStart, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),428,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
429 switch (coneSize) {
430 case 3:
431 ierr = DMPlexLocatePoint_Simplex_2D_Internal(dm, point, cellStart, cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),431,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
432 break;
433 case 4:
434 ierr = DMPlexLocatePoint_General_2D_Internal(dm, point, cellStart, cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),434,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
435 break;
436 default:
437 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No point location for cell with cone size %D", coneSize)return PetscError(PetscObjectComm((PetscObject)dm),437,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No point location for cell with cone size %D"
,coneSize)
;
438 }
439 break;
440 case 3:
441 ierr = DMPlexGetConeSize(dm, cellStart, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),441,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
442 switch (coneSize) {
443 case 4:
444 ierr = DMPlexLocatePoint_Simplex_3D_Internal(dm, point, cellStart, cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),444,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
445 break;
446 case 6:
447 ierr = DMPlexLocatePoint_General_3D_Internal(dm, point, cellStart, cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
448 break;
449 default:
450 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No point location for cell with cone size %D", coneSize)return PetscError(PetscObjectComm((PetscObject)dm),450,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No point location for cell with cone size %D"
,coneSize)
;
451 }
452 break;
453 default:
454 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No point location for mesh dimension %D", dim)return PetscError(PetscObjectComm((PetscObject)dm),454,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No point location for mesh dimension %D"
,dim)
;
455 }
456 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)
;
457}
458
459/*
460 DMPlexClosestPoint_Internal - Returns the closest point in the cell to the given point
461*/
462PetscErrorCode DMPlexClosestPoint_Internal(DM dm, PetscInt dim, const PetscScalar point[], PetscInt cell, PetscReal cpoint[])
463{
464 PetscInt coneSize;
465 PetscErrorCode ierr;
466
467 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 467; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
468 switch (dim) {
469 case 2:
470 ierr = DMPlexGetConeSize(dm, cell, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),470,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
471 switch (coneSize) {
472 case 3:
473 ierr = DMPlexClosestPoint_Simplex_2D_Internal(dm, point, cell, cpoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),473,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
474 break;
475#if 0
476 case 4:
477 ierr = DMPlexClosestPoint_General_2D_Internal(dm, point, cell, cpoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),477,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
478 break;
479#endif
480 default:
481 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No closest point location for cell with cone size %D", coneSize)return PetscError(PetscObjectComm((PetscObject)dm),481,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No closest point location for cell with cone size %D"
,coneSize)
;
482 }
483 break;
484#if 0
485 case 3:
486 ierr = DMPlexGetConeSize(dm, cell, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),486,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
487 switch (coneSize) {
488 case 4:
489 ierr = DMPlexClosestPoint_Simplex_3D_Internal(dm, point, cell, cpoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),489,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
490 break;
491 case 6:
492 ierr = DMPlexClosestPoint_General_3D_Internal(dm, point, cell, cpoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),492,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
493 break;
494 default:
495 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No closest point location for cell with cone size %D", coneSize)return PetscError(PetscObjectComm((PetscObject)dm),495,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No closest point location for cell with cone size %D"
,coneSize)
;
496 }
497 break;
498#endif
499 default:
500 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_OUTOFRANGE, "No closest point location for mesh dimension %D", dim)return PetscError(PetscObjectComm((PetscObject)dm),500,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No closest point location for mesh dimension %D"
,dim)
;
501 }
502 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)
;
503}
504
505/*
506 DMPlexComputeGridHash_Internal - Create a grid hash structure covering the Plex
507
508 Collective on dm
509
510 Input Parameter:
511. dm - The Plex
512
513 Output Parameter:
514. localBox - The grid hash object
515
516 Level: developer
517
518.seealso: PetscGridHashCreate(), PetscGridHashGetEnclosingBox()
519*/
520PetscErrorCode DMPlexComputeGridHash_Internal(DM dm, PetscGridHash *localBox)
521{
522 MPI_Comm comm;
523 PetscGridHash lbox;
524 Vec coordinates;
525 PetscSection coordSection;
526 Vec coordsLocal;
527 const PetscScalar *coords;
528 PetscInt *dboxes, *boxes;
529 PetscInt n[3] = {10, 10, 10};
530 PetscInt dim, N, cStart, cEnd, cMax, c, i;
531 PetscErrorCode ierr;
532
533 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 533; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
534 ierr = PetscObjectGetComm((PetscObject) dm, &comm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),534,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
535 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),535,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
536 ierr = DMGetCoordinateDim(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),536,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
537 if (dim != 2) SETERRQ(comm, PETSC_ERR_SUP, "I have only coded this for 2D")return PetscError(comm,537,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"I have only coded this for 2D")
;
538 ierr = VecGetLocalSize(coordinates, &N);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),538,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
539 ierr = VecGetArrayRead(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),539,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
540 ierr = PetscGridHashCreate(comm, dim, coords, &lbox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),540,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
541 for (i = 0; i < N; i += dim) {ierr = PetscGridHashEnlarge(lbox, &coords[i]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),541,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
542 ierr = VecRestoreArrayRead(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),542,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
543 ierr = PetscOptionsGetInt(NULL((void*)0),NULL((void*)0),"-dm_plex_hash_box_nijk",&n[0],NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),543,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
544 n[1] = n[0];
545 n[2] = n[0];
546 ierr = PetscGridHashSetGrid(lbox, n, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),546,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
547#if 0
548 /* Could define a custom reduction to merge these */
549 ierr = MPIU_Allreduce(lbox->lower, gbox->lower, 3, MPIU_REAL, MPI_MIN, comm)(PetscAllreduceBarrierCheck(comm,3,549,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) ||
MPI_Allreduce((lbox->lower),(gbox->lower),(3),(((MPI_Datatype
)0x4c00080b)),((MPI_Op)(0x58000002)),(comm))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),549,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
550 ierr = MPIU_Allreduce(lbox->upper, gbox->upper, 3, MPIU_REAL, MPI_MAX, comm)(PetscAllreduceBarrierCheck(comm,3,550,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) ||
MPI_Allreduce((lbox->upper),(gbox->upper),(3),(((MPI_Datatype
)0x4c00080b)),((MPI_Op)(0x58000001)),(comm))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),550,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
551#endif
552 /* Is there a reason to snap the local bounding box to a division of the global box? */
553 /* Should we compute all overlaps of local boxes? We could do this with a rendevouz scheme partitioning the global box */
554 /* Create label */
555 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),555,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
556 ierr = DMPlexGetHybridBounds(dm, &cMax, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),556,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
557 if (cMax >= 0) cEnd = PetscMin(cEnd, cMax)(((cEnd)<(cMax)) ? (cEnd) : (cMax));
558 ierr = DMLabelCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), "cells", &lbox->cellsSparse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),558,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
559 ierr = DMLabelCreateIndex(lbox->cellsSparse, cStart, cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),559,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
560 /* Compute boxes which overlap each cell: https://stackoverflow.com/questions/13790208/triangle-square-intersection-test-in-2d */
561 ierr = DMGetCoordinatesLocal(dm, &coordsLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),561,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
562 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),562,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
563 ierr = PetscCalloc2(16 * dim, &dboxes, 16, &boxes)PetscMallocA(2,PETSC_TRUE,563,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(16 * dim)*sizeof(**(&dboxes)),(&dboxes),(size_t
)(16)*sizeof(**(&boxes)),(&boxes))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),563,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
564 for (c = cStart; c < cEnd; ++c) {
565 const PetscReal *h = lbox->h;
566 PetscScalar *ccoords = NULL((void*)0);
567 PetscInt csize = 0;
568 PetscScalar point[3];
569 PetscInt dlim[6], d, e, i, j, k;
570
571 /* Find boxes enclosing each vertex */
572 ierr = DMPlexVecGetClosure(dm, coordSection, coordsLocal, c, &csize, &ccoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),572,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
573 ierr = PetscGridHashGetEnclosingBox(lbox, csize/dim, ccoords, dboxes, boxes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),573,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
574 /* Mark cells containing the vertices */
575 for (e = 0; e < csize/dim; ++e) {ierr = DMLabelSetValue(lbox->cellsSparse, c, boxes[e]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),575,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
576 /* Get grid of boxes containing these */
577 for (d = 0; d < dim; ++d) {dlim[d*2+0] = dlim[d*2+1] = dboxes[d];}
578 for (d = dim; d < 3; ++d) {dlim[d*2+0] = dlim[d*2+1] = 0;}
579 for (e = 1; e < dim+1; ++e) {
580 for (d = 0; d < dim; ++d) {
581 dlim[d*2+0] = PetscMin(dlim[d*2+0], dboxes[e*dim+d])(((dlim[d*2+0])<(dboxes[e*dim+d])) ? (dlim[d*2+0]) : (dboxes
[e*dim+d]))
;
582 dlim[d*2+1] = PetscMax(dlim[d*2+1], dboxes[e*dim+d])(((dlim[d*2+1])<(dboxes[e*dim+d])) ? (dboxes[e*dim+d]) : (
dlim[d*2+1]))
;
583 }
584 }
585 /* Check for intersection of box with cell */
586 for (k = dlim[2*2+0], point[2] = lbox->lower[2] + k*h[2]; k <= dlim[2*2+1]; ++k, point[2] += h[2]) {
587 for (j = dlim[1*2+0], point[1] = lbox->lower[1] + j*h[1]; j <= dlim[1*2+1]; ++j, point[1] += h[1]) {
588 for (i = dlim[0*2+0], point[0] = lbox->lower[0] + i*h[0]; i <= dlim[0*2+1]; ++i, point[0] += h[0]) {
589 const PetscInt box = (k*lbox->n[1] + j)*lbox->n[0] + i;
590 PetscScalar cpoint[3];
591 PetscInt cell, edge, ii, jj, kk;
592
593 /* Check whether cell contains any vertex of these subboxes TODO vectorize this */
594 for (kk = 0, cpoint[2] = point[2]; kk < (dim > 2 ? 2 : 1); ++kk, cpoint[2] += h[2]) {
595 for (jj = 0, cpoint[1] = point[1]; jj < (dim > 1 ? 2 : 1); ++jj, cpoint[1] += h[1]) {
596 for (ii = 0, cpoint[0] = point[0]; ii < 2; ++ii, cpoint[0] += h[0]) {
597
598 ierr = DMPlexLocatePoint_Internal(dm, dim, cpoint, c, &cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),598,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
599 if (cell >= 0) { ierr = DMLabelSetValue(lbox->cellsSparse, c, box);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),599,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; ii = jj = kk = 2;}
600 }
601 }
602 }
603 /* Check whether cell edge intersects any edge of these subboxes TODO vectorize this */
604 for (edge = 0; edge < dim+1; ++edge) {
605 PetscReal segA[6], segB[6];
606
607 if (PetscUnlikely(dim > 3)__builtin_expect(!!(dim > 3),0)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Unexpected dim %d > 3",dim)return PetscError(((MPI_Comm)0x44000001),607,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Unexpected dim %d > 3",dim)
;
608 for (d = 0; d < dim; ++d) {segA[d] = PetscRealPart(ccoords[edge*dim+d])(ccoords[edge*dim+d]); segA[dim+d] = PetscRealPart(ccoords[((edge+1)%(dim+1))*dim+d])(ccoords[((edge+1)%(dim+1))*dim+d]);}
609 for (kk = 0; kk < (dim > 2 ? 2 : 1); ++kk) {
610 if (dim > 2) {segB[2] = PetscRealPart(point[2])(point[2]);
611 segB[dim+2] = PetscRealPart(point[2])(point[2]) + kk*h[2];}
612 for (jj = 0; jj < (dim > 1 ? 2 : 1); ++jj) {
613 if (dim > 1) {segB[1] = PetscRealPart(point[1])(point[1]);
614 segB[dim+1] = PetscRealPart(point[1])(point[1]) + jj*h[1];}
615 for (ii = 0; ii < 2; ++ii) {
616 PetscBool intersects;
617
618 segB[0] = PetscRealPart(point[0])(point[0]);
619 segB[dim+0] = PetscRealPart(point[0])(point[0]) + ii*h[0];
620 ierr = DMPlexGetLineIntersection_2D_Internal(segA, segB, NULL((void*)0), &intersects);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),620,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
621 if (intersects) { ierr = DMLabelSetValue(lbox->cellsSparse, c, box);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),621,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; edge = ii = jj = kk = dim+1;}
622 }
623 }
624 }
625 }
626 }
627 }
628 }
629 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordsLocal, c, NULL((void*)0), &ccoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),629,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
630 }
631 ierr = PetscFree2(dboxes, boxes)PetscFreeA(2,631,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,&(dboxes),&(boxes))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),631,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
632 ierr = DMLabelConvertToSection(lbox->cellsSparse, &lbox->cellSection, &lbox->cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),632,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
633 ierr = DMLabelDestroy(&lbox->cellsSparse);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),633,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
634 *localBox = lbox;
635 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)
;
636}
637
638PetscErrorCode DMLocatePoints_Plex(DM dm, Vec v, DMPointLocationType ltype, PetscSF cellSF)
639{
640 DM_Plex *mesh = (DM_Plex *) dm->data;
641 PetscBool hash = mesh->useHashLocation, reuse = PETSC_FALSE;
642 PetscInt bs, numPoints, p, numFound, *found = NULL((void*)0);
643 PetscInt dim, cStart, cEnd, cMax, numCells, c, d;
644 const PetscInt *boxCells;
645 PetscSFNode *cells;
646 PetscScalar *a;
647 PetscMPIInt result;
648 PetscLogDouble t0,t1;
649 PetscReal gmin[3],gmax[3];
650 PetscInt terminating_query_type[] = { 0, 0, 0 };
651 PetscErrorCode ierr;
652
653 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 653; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
654 ierr = PetscTime(&t0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),654,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
655 if (ltype == DM_POINTLOCATION_NEAREST && !hash) SETERRQ(PetscObjectComm((PetscObject) dm), PETSC_ERR_SUP, "Nearest point location only supported with grid hashing. Use -dm_plex_hash_location to enable it.")return PetscError(PetscObjectComm((PetscObject) dm),655,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Nearest point location only supported with grid hashing. Use -dm_plex_hash_location to enable it."
)
;
656 ierr = DMGetCoordinateDim(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),656,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
657 ierr = VecGetBlockSize(v, &bs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),657,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
658 ierr = MPI_Comm_compare(PetscObjectComm((PetscObject)cellSF),PETSC_COMM_SELF((MPI_Comm)0x44000001),&result);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),658,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
659 if (result != MPI_IDENT0 && result != MPI_CONGRUENT1) SETERRQ(PetscObjectComm((PetscObject)cellSF),PETSC_ERR_SUP, "Trying parallel point location: only local point location supported")return PetscError(PetscObjectComm((PetscObject)cellSF),659,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Trying parallel point location: only local point location supported"
)
;
660 if (bs != dim) SETERRQ2(PetscObjectComm((PetscObject)dm), PETSC_ERR_ARG_WRONG, "Block size for point vector %D must be the mesh coordinate dimension %D", bs, dim)return PetscError(PetscObjectComm((PetscObject)dm),660,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Block size for point vector %D must be the mesh coordinate dimension %D"
,bs,dim)
;
661 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),661,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
662 ierr = DMPlexGetHybridBounds(dm, &cMax, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),662,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
663 if (cMax >= 0) cEnd = PetscMin(cEnd, cMax)(((cEnd)<(cMax)) ? (cEnd) : (cMax));
664 ierr = VecGetLocalSize(v, &numPoints);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),664,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
665 ierr = VecGetArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),665,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
666 numPoints /= bs;
667 {
668 const PetscSFNode *sf_cells;
669
670 ierr = PetscSFGetGraph(cellSF,NULL((void*)0),NULL((void*)0),NULL((void*)0),&sf_cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),670,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
671 if (sf_cells) {
672 ierr = PetscInfo(dm,"[DMLocatePoints_Plex] Re-using existing StarForest node list\n")PetscInfo_Private(__func__,dm,"[DMLocatePoints_Plex] Re-using existing StarForest node list\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),672,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
673 cells = (PetscSFNode*)sf_cells;
674 reuse = PETSC_TRUE;
675 } else {
676 ierr = PetscInfo(dm,"[DMLocatePoints_Plex] Creating and initializing new StarForest node list\n")PetscInfo_Private(__func__,dm,"[DMLocatePoints_Plex] Creating and initializing new StarForest node list\n"
)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),676,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
677 ierr = PetscMalloc1(numPoints, &cells)PetscMallocA(1,PETSC_FALSE,677,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(numPoints)*sizeof(**(&cells)),(&cells))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),677,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
678 /* initialize cells if created */
679 for (p=0; p<numPoints; p++) {
680 cells[p].rank = 0;
681 cells[p].index = DMLOCATEPOINT_POINT_NOT_FOUND-367;
682 }
683 }
684 }
685 /* define domain bounding box */
686 {
687 Vec coorglobal;
688
689 ierr = DMGetCoordinates(dm,&coorglobal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),689,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
690 ierr = VecStrideMaxAll(coorglobal,NULL((void*)0),gmax);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),690,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
691 ierr = VecStrideMinAll(coorglobal,NULL((void*)0),gmin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),691,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
692 }
693 if (hash) {
694 if (!mesh->lbox) {ierr = PetscInfo(dm, "Initializing grid hashing")PetscInfo_Private(__func__,dm,"Initializing grid hashing");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),694,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;ierr = DMPlexComputeGridHash_Internal(dm, &mesh->lbox);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),694,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
695 /* Designate the local box for each point */
696 /* Send points to correct process */
697 /* Search cells that lie in each subbox */
698 /* Should we bin points before doing search? */
699 ierr = ISGetIndices(mesh->lbox->cells, &boxCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),699,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
700 }
701 for (p = 0, numFound = 0; p < numPoints; ++p) {
702 const PetscScalar *point = &a[p*bs];
703 PetscInt dbin[3] = {-1,-1,-1}, bin, cell = -1, cellOffset;
704 PetscBool point_outside_domain = PETSC_FALSE;
705
706 /* check bounding box of domain */
707 for (d=0; d<dim; d++) {
708 if (PetscRealPart(point[d])(point[d]) < gmin[d]) { point_outside_domain = PETSC_TRUE; break; }
709 if (PetscRealPart(point[d])(point[d]) > gmax[d]) { point_outside_domain = PETSC_TRUE; break; }
710 }
711 if (point_outside_domain) {
712 cells[p].rank = 0;
713 cells[p].index = DMLOCATEPOINT_POINT_NOT_FOUND-367;
714 terminating_query_type[0]++;
715 continue;
716 }
717
718 /* check initial values in cells[].index - abort early if found */
719 if (cells[p].index != DMLOCATEPOINT_POINT_NOT_FOUND-367) {
720 c = cells[p].index;
721 cells[p].index = DMLOCATEPOINT_POINT_NOT_FOUND-367;
722 ierr = DMPlexLocatePoint_Internal(dm, dim, point, c, &cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),722,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
723 if (cell >= 0) {
724 cells[p].rank = 0;
725 cells[p].index = cell;
726 numFound++;
727 }
728 }
729 if (cells[p].index != DMLOCATEPOINT_POINT_NOT_FOUND-367) {
730 terminating_query_type[1]++;
731 continue;
732 }
733
734 if (hash) {
735 PetscBool found_box;
736
737 /* allow for case that point is outside box - abort early */
738 ierr = PetscGridHashGetEnclosingBoxQuery(mesh->lbox, 1, point, dbin, &bin,&found_box);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),738,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
739 if (found_box) {
740 /* TODO Lay an interface over this so we can switch between Section (dense) and Label (sparse) */
741 ierr = PetscSectionGetDof(mesh->lbox->cellSection, bin, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),741,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
742 ierr = PetscSectionGetOffset(mesh->lbox->cellSection, bin, &cellOffset);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),742,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
743 for (c = cellOffset; c < cellOffset + numCells; ++c) {
744 ierr = DMPlexLocatePoint_Internal(dm, dim, point, boxCells[c], &cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),744,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
745 if (cell >= 0) {
746 cells[p].rank = 0;
747 cells[p].index = cell;
748 numFound++;
749 terminating_query_type[2]++;
750 break;
751 }
752 }
753 }
754 } else {
755 for (c = cStart; c < cEnd; ++c) {
756 ierr = DMPlexLocatePoint_Internal(dm, dim, point, c, &cell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),756,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
757 if (cell >= 0) {
758 cells[p].rank = 0;
759 cells[p].index = cell;
760 numFound++;
761 terminating_query_type[2]++;
762 break;
763 }
764 }
765 }
766 }
767 if (hash) {ierr = ISRestoreIndices(mesh->lbox->cells, &boxCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),767,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
768 if (ltype == DM_POINTLOCATION_NEAREST && hash && numFound < numPoints) {
769 for (p = 0; p < numPoints; p++) {
770 const PetscScalar *point = &a[p*bs];
771 PetscReal cpoint[3], diff[3], dist, distMax = PETSC_MAX_REAL1.7976931348623157e+308;
772 PetscInt dbin[3] = {-1,-1,-1}, bin, cellOffset, d;
773
774 if (cells[p].index < 0) {
775 ++numFound;
776 ierr = PetscGridHashGetEnclosingBox(mesh->lbox, 1, point, dbin, &bin);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),776,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
777 ierr = PetscSectionGetDof(mesh->lbox->cellSection, bin, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),777,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
778 ierr = PetscSectionGetOffset(mesh->lbox->cellSection, bin, &cellOffset);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),778,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
779 for (c = cellOffset; c < cellOffset + numCells; ++c) {
780 ierr = DMPlexClosestPoint_Internal(dm, dim, point, boxCells[c], cpoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),780,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
781 for (d = 0; d < dim; ++d) diff[d] = cpoint[d] - PetscRealPart(point[d])(point[d]);
782 dist = DMPlex_NormD_Internal(dim, diff);
783 if (dist < distMax) {
784 for (d = 0; d < dim; ++d) a[p*bs+d] = cpoint[d];
785 cells[p].rank = 0;
786 cells[p].index = boxCells[c];
787 distMax = dist;
788 break;
789 }
790 }
791 }
792 }
793 }
794 /* This code is only be relevant when interfaced to parallel point location */
795 /* Check for highest numbered proc that claims a point (do we care?) */
796 if (ltype == DM_POINTLOCATION_REMOVE && numFound < numPoints) {
797 ierr = PetscMalloc1(numFound,&found)PetscMallocA(1,PETSC_FALSE,797,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(numFound)*sizeof(**(&found)),(&found))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),797,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
798 for (p = 0, numFound = 0; p < numPoints; p++) {
799 if (cells[p].rank >= 0 && cells[p].index >= 0) {
800 if (numFound < p) {
801 cells[numFound] = cells[p];
802 }
803 found[numFound++] = p;
804 }
805 }
806 }
807 ierr = VecRestoreArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),807,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
808 if (!reuse) {
809 ierr = PetscSFSetGraph(cellSF, cEnd - cStart, numFound, found, PETSC_OWN_POINTER, cells, PETSC_OWN_POINTER);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),809,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
810 }
811 ierr = PetscTime(&t1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),811,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
812 if (hash) {
813 ierr = PetscInfo3(dm,"[DMLocatePoints_Plex] terminating_query_type : %D [outside domain] : %D [inside intial cell] : %D [hash]\n",terminating_query_type[0],terminating_query_type[1],terminating_query_type[2])PetscInfo_Private(__func__,dm,"[DMLocatePoints_Plex] terminating_query_type : %D [outside domain] : %D [inside intial cell] : %D [hash]\n"
,terminating_query_type[0],terminating_query_type[1],terminating_query_type
[2])
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),813,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
814 } else {
815 ierr = PetscInfo3(dm,"[DMLocatePoints_Plex] terminating_query_type : %D [outside domain] : %D [inside intial cell] : %D [brute-force]\n",terminating_query_type[0],terminating_query_type[1],terminating_query_type[2])PetscInfo_Private(__func__,dm,"[DMLocatePoints_Plex] terminating_query_type : %D [outside domain] : %D [inside intial cell] : %D [brute-force]\n"
,terminating_query_type[0],terminating_query_type[1],terminating_query_type
[2])
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),815,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
816 }
817 ierr = PetscInfo3(dm,"[DMLocatePoints_Plex] npoints %D : time(rank0) %1.2e (sec): points/sec %1.4e\n",numPoints,t1-t0,(double)((double)numPoints/(t1-t0)))PetscInfo_Private(__func__,dm,"[DMLocatePoints_Plex] npoints %D : time(rank0) %1.2e (sec): points/sec %1.4e\n"
,numPoints,t1-t0,(double)((double)numPoints/(t1-t0)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),817,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
818 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)
;
819}
820
821/*@C
822 DMPlexComputeProjection2Dto1D - Rewrite coordinates to be the 1D projection of the 2D coordinates
823
824 Not collective
825
826 Input Parameter:
827. coords - The coordinates of a segment
828
829 Output Parameters:
830+ coords - The new y-coordinate, and 0 for x
831- R - The rotation which accomplishes the projection
832
833 Level: developer
834
835.seealso: DMPlexComputeProjection3Dto1D(), DMPlexComputeProjection3Dto2D()
836@*/
837PetscErrorCode DMPlexComputeProjection2Dto1D(PetscScalar coords[], PetscReal R[])
838{
839 const PetscReal x = PetscRealPart(coords[2] - coords[0])(coords[2] - coords[0]);
840 const PetscReal y = PetscRealPart(coords[3] - coords[1])(coords[3] - coords[1]);
841 const PetscReal r = PetscSqrtReal(x*x + y*y)sqrt(x*x + y*y), c = x/r, s = y/r;
842
843 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 843; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
844 R[0] = c; R[1] = -s;
845 R[2] = s; R[3] = c;
846 coords[0] = 0.0;
847 coords[1] = r;
848 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)
;
849}
850
851/*@C
852 DMPlexComputeProjection3Dto1D - Rewrite coordinates to be the 1D projection of the 3D coordinates
853
854 Not collective
855
856 Input Parameter:
857. coords - The coordinates of a segment
858
859 Output Parameters:
860+ coords - The new y-coordinate, and 0 for x and z
861- R - The rotation which accomplishes the projection
862
863 Note: This uses the basis completion described by Frisvad in http://www.imm.dtu.dk/~jerf/papers/abstracts/onb.html, DOI:10.1080/2165347X.2012.689606
864
865 Level: developer
866
867.seealso: DMPlexComputeProjection2Dto1D(), DMPlexComputeProjection3Dto2D()
868@*/
869PetscErrorCode DMPlexComputeProjection3Dto1D(PetscScalar coords[], PetscReal R[])
870{
871 PetscReal x = PetscRealPart(coords[3] - coords[0])(coords[3] - coords[0]);
872 PetscReal y = PetscRealPart(coords[4] - coords[1])(coords[4] - coords[1]);
873 PetscReal z = PetscRealPart(coords[5] - coords[2])(coords[5] - coords[2]);
874 PetscReal r = PetscSqrtReal(x*x + y*y + z*z)sqrt(x*x + y*y + z*z);
875 PetscReal rinv = 1. / r;
876 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 876; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
877
878 x *= rinv; y *= rinv; z *= rinv;
879 if (x > 0.) {
880 PetscReal inv1pX = 1./ (1. + x);
881
882 R[0] = x; R[1] = -y; R[2] = -z;
883 R[3] = y; R[4] = 1. - y*y*inv1pX; R[5] = -y*z*inv1pX;
884 R[6] = z; R[7] = -y*z*inv1pX; R[8] = 1. - z*z*inv1pX;
885 }
886 else {
887 PetscReal inv1mX = 1./ (1. - x);
888
889 R[0] = x; R[1] = z; R[2] = y;
890 R[3] = y; R[4] = -y*z*inv1mX; R[5] = 1. - y*y*inv1mX;
891 R[6] = z; R[7] = 1. - z*z*inv1mX; R[8] = -y*z*inv1mX;
892 }
893 coords[0] = 0.0;
894 coords[1] = r;
895 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)
;
896}
897
898/*@
899 DMPlexComputeProjection3Dto2D - Rewrite coordinates to be the 2D projection of the 3D coordinates
900
901 Not collective
902
903 Input Parameter:
904. coords - The coordinates of a segment
905
906 Output Parameters:
907+ coords - The new y- and z-coordinates, and 0 for x
908- R - The rotation which accomplishes the projection
909
910 Level: developer
911
912.seealso: DMPlexComputeProjection2Dto1D(), DMPlexComputeProjection3Dto1D()
913@*/
914PetscErrorCode DMPlexComputeProjection3Dto2D(PetscInt coordSize, PetscScalar coords[], PetscReal R[])
915{
916 PetscReal x1[3], x2[3], n[3], norm;
917 PetscReal x1p[3], x2p[3], xnp[3];
918 PetscReal sqrtz, alpha;
919 const PetscInt dim = 3;
920 PetscInt d, e, p;
921
922 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 922; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
923 /* 0) Calculate normal vector */
924 for (d = 0; d < dim; ++d) {
925 x1[d] = PetscRealPart(coords[1*dim+d] - coords[0*dim+d])(coords[1*dim+d] - coords[0*dim+d]);
926 x2[d] = PetscRealPart(coords[2*dim+d] - coords[0*dim+d])(coords[2*dim+d] - coords[0*dim+d]);
927 }
928 n[0] = x1[1]*x2[2] - x1[2]*x2[1];
929 n[1] = x1[2]*x2[0] - x1[0]*x2[2];
930 n[2] = x1[0]*x2[1] - x1[1]*x2[0];
931 norm = PetscSqrtReal(n[0]*n[0] + n[1]*n[1] + n[2]*n[2])sqrt(n[0]*n[0] + n[1]*n[1] + n[2]*n[2]);
932 n[0] /= norm;
933 n[1] /= norm;
934 n[2] /= norm;
935 /* 1) Take the normal vector and rotate until it is \hat z
936
937 Let the normal vector be <nx, ny, nz> and alpha = 1/sqrt(1 - nz^2), then
938
939 R = / alpha nx nz alpha ny nz -1/alpha \
940 | -alpha ny alpha nx 0 |
941 \ nx ny nz /
942
943 will rotate the normal vector to \hat z
944 */
945 sqrtz = PetscSqrtReal(1.0 - n[2]*n[2])sqrt(1.0 - n[2]*n[2]);
946 /* Check for n = z */
947 if (sqrtz < 1.0e-10) {
948 const PetscInt s = PetscSign(n[2])(((n[2]) >= 0) ? ((n[2]) == 0 ? 0 : 1) : -1);
949 /* If nz < 0, rotate 180 degrees around x-axis */
950 for (p = 3; p < coordSize/3; ++p) {
951 coords[p*2+0] = PetscRealPart(coords[p*dim+0] - coords[0*dim+0])(coords[p*dim+0] - coords[0*dim+0]);
952 coords[p*2+1] = (PetscRealPart(coords[p*dim+1] - coords[0*dim+1])(coords[p*dim+1] - coords[0*dim+1])) * s;
953 }
954 coords[0] = 0.0;
955 coords[1] = 0.0;
956 coords[2] = x1[0];
957 coords[3] = x1[1] * s;
958 coords[4] = x2[0];
959 coords[5] = x2[1] * s;
960 R[0] = 1.0; R[1] = 0.0; R[2] = 0.0;
961 R[3] = 0.0; R[4] = 1.0 * s; R[5] = 0.0;
962 R[6] = 0.0; R[7] = 0.0; R[8] = 1.0 * s;
963 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)
;
964 }
965 alpha = 1.0/sqrtz;
966 R[0] = alpha*n[0]*n[2]; R[1] = alpha*n[1]*n[2]; R[2] = -sqrtz;
967 R[3] = -alpha*n[1]; R[4] = alpha*n[0]; R[5] = 0.0;
968 R[6] = n[0]; R[7] = n[1]; R[8] = n[2];
969 for (d = 0; d < dim; ++d) {
970 x1p[d] = 0.0;
971 x2p[d] = 0.0;
972 for (e = 0; e < dim; ++e) {
973 x1p[d] += R[d*dim+e]*x1[e];
974 x2p[d] += R[d*dim+e]*x2[e];
975 }
976 }
977 if (PetscAbsReal(x1p[2])fabs(x1p[2]) > 10. * PETSC_SMALL1.e-10) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid rotation calculated")return PetscError(((MPI_Comm)0x44000001),977,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Invalid rotation calculated")
;
978 if (PetscAbsReal(x2p[2])fabs(x2p[2]) > 10. * PETSC_SMALL1.e-10) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid rotation calculated")return PetscError(((MPI_Comm)0x44000001),978,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Invalid rotation calculated")
;
979 /* 2) Project to (x, y) */
980 for (p = 3; p < coordSize/3; ++p) {
981 for (d = 0; d < dim; ++d) {
982 xnp[d] = 0.0;
983 for (e = 0; e < dim; ++e) {
984 xnp[d] += R[d*dim+e]*PetscRealPart(coords[p*dim+e] - coords[0*dim+e])(coords[p*dim+e] - coords[0*dim+e]);
985 }
986 if (d < dim-1) coords[p*2+d] = xnp[d];
987 }
988 }
989 coords[0] = 0.0;
990 coords[1] = 0.0;
991 coords[2] = x1p[0];
992 coords[3] = x1p[1];
993 coords[4] = x2p[0];
994 coords[5] = x2p[1];
995 /* Output R^T which rotates \hat z to the input normal */
996 for (d = 0; d < dim; ++d) {
997 for (e = d+1; e < dim; ++e) {
998 PetscReal tmp;
999
1000 tmp = R[d*dim+e];
1001 R[d*dim+e] = R[e*dim+d];
1002 R[e*dim+d] = tmp;
1003 }
1004 }
1005 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)
;
1006}
1007
1008PETSC_UNUSED__attribute((unused))
1009PETSC_STATIC_INLINEstatic inline void Volume_Triangle_Internal(PetscReal *vol, PetscReal coords[])
1010{
1011 /* Signed volume is 1/2 the determinant
1012
1013 | 1 1 1 |
1014 | x0 x1 x2 |
1015 | y0 y1 y2 |
1016
1017 but if x0,y0 is the origin, we have
1018
1019 | x1 x2 |
1020 | y1 y2 |
1021 */
1022 const PetscReal x1 = coords[2] - coords[0], y1 = coords[3] - coords[1];
1023 const PetscReal x2 = coords[4] - coords[0], y2 = coords[5] - coords[1];
1024 PetscReal M[4], detM;
1025 M[0] = x1; M[1] = x2;
1026 M[2] = y1; M[3] = y2;
1027 DMPlex_Det2D_Internal(&detM, M);
1028 *vol = 0.5*detM;
1029 (void)PetscLogFlops(5.0);
1030}
1031
1032PETSC_STATIC_INLINEstatic inline void Volume_Triangle_Origin_Internal(PetscReal *vol, PetscReal coords[])
1033{
1034 DMPlex_Det2D_Internal(vol, coords);
1035 *vol *= 0.5;
1036}
1037
1038PETSC_UNUSED__attribute((unused))
1039PETSC_STATIC_INLINEstatic inline void Volume_Tetrahedron_Internal(PetscReal *vol, PetscReal coords[])
1040{
1041 /* Signed volume is 1/6th of the determinant
1042
1043 | 1 1 1 1 |
1044 | x0 x1 x2 x3 |
1045 | y0 y1 y2 y3 |
1046 | z0 z1 z2 z3 |
1047
1048 but if x0,y0,z0 is the origin, we have
1049
1050 | x1 x2 x3 |
1051 | y1 y2 y3 |
1052 | z1 z2 z3 |
1053 */
1054 const PetscReal x1 = coords[3] - coords[0], y1 = coords[4] - coords[1], z1 = coords[5] - coords[2];
1055 const PetscReal x2 = coords[6] - coords[0], y2 = coords[7] - coords[1], z2 = coords[8] - coords[2];
1056 const PetscReal x3 = coords[9] - coords[0], y3 = coords[10] - coords[1], z3 = coords[11] - coords[2];
1057 const PetscReal onesixth = ((PetscReal)1./(PetscReal)6.);
1058 PetscReal M[9], detM;
1059 M[0] = x1; M[1] = x2; M[2] = x3;
1060 M[3] = y1; M[4] = y2; M[5] = y3;
1061 M[6] = z1; M[7] = z2; M[8] = z3;
1062 DMPlex_Det3D_Internal(&detM, M);
1063 *vol = -onesixth*detM;
1064 (void)PetscLogFlops(10.0);
1065}
1066
1067PETSC_STATIC_INLINEstatic inline void Volume_Tetrahedron_Origin_Internal(PetscReal *vol, PetscReal coords[])
1068{
1069 const PetscReal onesixth = ((PetscReal)1./(PetscReal)6.);
1070 DMPlex_Det3D_Internal(vol, coords);
17
Calling 'DMPlex_Det3D_Internal'
1071 *vol *= -onesixth;
1072}
1073
1074static PetscErrorCode DMPlexComputePointGeometry_Internal(DM dm, PetscInt e, PetscReal v0[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1075{
1076 PetscSection coordSection;
1077 Vec coordinates;
1078 const PetscScalar *coords;
1079 PetscInt dim, d, off;
1080 PetscErrorCode ierr;
1081
1082 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1082; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1083 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1083,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1084 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1084,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1085 ierr = PetscSectionGetDof(coordSection,e,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1085,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1086 if (!dim) 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)
;
1087 ierr = PetscSectionGetOffset(coordSection,e,&off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1087,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1088 ierr = VecGetArrayRead(coordinates,&coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1088,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1089 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[off + d])(coords[off + d]);}
1090 ierr = VecRestoreArrayRead(coordinates,&coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1090,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1091 *detJ = 1.;
1092 if (J) {
1093 for (d = 0; d < dim * dim; d++) J[d] = 0.;
1094 for (d = 0; d < dim; d++) J[d * dim + d] = 1.;
1095 if (invJ) {
1096 for (d = 0; d < dim * dim; d++) invJ[d] = 0.;
1097 for (d = 0; d < dim; d++) invJ[d * dim + d] = 1.;
1098 }
1099 }
1100 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)
;
1101}
1102
1103static PetscErrorCode DMPlexComputeLineGeometry_Internal(DM dm, PetscInt e, PetscReal v0[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1104{
1105 PetscSection coordSection;
1106 Vec coordinates;
1107 PetscScalar *coords = NULL((void*)0);
1108 PetscInt numCoords, d, pStart, pEnd, numSelfCoords = 0;
1109 PetscErrorCode ierr;
1110
1111 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1111; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1112 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1112,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1113 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1113,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1114 ierr = PetscSectionGetChart(coordSection,&pStart,&pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1115 if (e >= pStart && e < pEnd) {ierr = PetscSectionGetDof(coordSection,e,&numSelfCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1115,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1116 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1116,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1117 numCoords = numSelfCoords ? numSelfCoords : numCoords;
1118 if (invJ && !J) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "In order to compute invJ, J must not be NULL")return PetscError(((MPI_Comm)0x44000001),1118,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"In order to compute invJ, J must not be NULL"
)
;
1119 *detJ = 0.0;
1120 if (numCoords == 6) {
1121 const PetscInt dim = 3;
1122 PetscReal R[9], J0;
1123
1124 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1125 ierr = DMPlexComputeProjection3Dto1D(coords, R);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1125,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1126 if (J) {
1127 J0 = 0.5*PetscRealPart(coords[1])(coords[1]);
1128 J[0] = R[0]*J0; J[1] = R[1]; J[2] = R[2];
1129 J[3] = R[3]*J0; J[4] = R[4]; J[5] = R[5];
1130 J[6] = R[6]*J0; J[7] = R[7]; J[8] = R[8];
1131 DMPlex_Det3D_Internal(detJ, J);
1132 if (invJ) {DMPlex_Invert2D_Internal(invJ, J, *detJ);}
1133 }
1134 } else if (numCoords == 4) {
1135 const PetscInt dim = 2;
1136 PetscReal R[4], J0;
1137
1138 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1139 ierr = DMPlexComputeProjection2Dto1D(coords, R);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1139,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1140 if (J) {
1141 J0 = 0.5*PetscRealPart(coords[1])(coords[1]);
1142 J[0] = R[0]*J0; J[1] = R[1];
1143 J[2] = R[2]*J0; J[3] = R[3];
1144 DMPlex_Det2D_Internal(detJ, J);
1145 if (invJ) {DMPlex_Invert2D_Internal(invJ, J, *detJ);}
1146 }
1147 } else if (numCoords == 2) {
1148 const PetscInt dim = 1;
1149
1150 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1151 if (J) {
1152 J[0] = 0.5*(PetscRealPart(coords[1])(coords[1]) - PetscRealPart(coords[0])(coords[0]));
1153 *detJ = J[0];
1154 ierr = PetscLogFlops(2.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1154,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1155 if (invJ) {invJ[0] = 1.0/J[0]; ierr = PetscLogFlops(1.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1155,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1156 }
1157 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "The number of coordinates for this segment is %D != 2", numCoords)return PetscError(((MPI_Comm)0x44000001),1157,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"The number of coordinates for this segment is %D != 2"
,numCoords)
;
1158 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1158,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1159 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)
;
1160}
1161
1162static PetscErrorCode DMPlexComputeTriangleGeometry_Internal(DM dm, PetscInt e, PetscReal v0[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1163{
1164 PetscSection coordSection;
1165 Vec coordinates;
1166 PetscScalar *coords = NULL((void*)0);
1167 PetscInt numCoords, numSelfCoords = 0, d, f, g, pStart, pEnd;
1168 PetscErrorCode ierr;
1169
1170 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1170; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1171 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1171,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1172 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1172,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1173 ierr = PetscSectionGetChart(coordSection,&pStart,&pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1173,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1174 if (e >= pStart && e < pEnd) {ierr = PetscSectionGetDof(coordSection,e,&numSelfCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1175 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1175,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1176 numCoords = numSelfCoords ? numSelfCoords : numCoords;
1177 *detJ = 0.0;
1178 if (numCoords == 9) {
1179 const PetscInt dim = 3;
1180 PetscReal R[9], J0[9] = {1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0};
1181
1182 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1183 ierr = DMPlexComputeProjection3Dto2D(numCoords, coords, R);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1183,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1184 if (J) {
1185 const PetscInt pdim = 2;
1186
1187 for (d = 0; d < pdim; d++) {
1188 for (f = 0; f < pdim; f++) {
1189 J0[d*dim+f] = 0.5*(PetscRealPart(coords[(f+1)*pdim+d])(coords[(f+1)*pdim+d]) - PetscRealPart(coords[0*pdim+d])(coords[0*pdim+d]));
1190 }
1191 }
1192 ierr = PetscLogFlops(8.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1192,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1193 DMPlex_Det3D_Internal(detJ, J0);
1194 for (d = 0; d < dim; d++) {
1195 for (f = 0; f < dim; f++) {
1196 J[d*dim+f] = 0.0;
1197 for (g = 0; g < dim; g++) {
1198 J[d*dim+f] += R[d*dim+g]*J0[g*dim+f];
1199 }
1200 }
1201 }
1202 ierr = PetscLogFlops(18.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1202,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1203 }
1204 if (invJ) {DMPlex_Invert3D_Internal(invJ, J, *detJ);}
1205 } else if (numCoords == 6) {
1206 const PetscInt dim = 2;
1207
1208 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1209 if (J) {
1210 for (d = 0; d < dim; d++) {
1211 for (f = 0; f < dim; f++) {
1212 J[d*dim+f] = 0.5*(PetscRealPart(coords[(f+1)*dim+d])(coords[(f+1)*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1213 }
1214 }
1215 ierr = PetscLogFlops(8.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1215,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1216 DMPlex_Det2D_Internal(detJ, J);
1217 }
1218 if (invJ) {DMPlex_Invert2D_Internal(invJ, J, *detJ);}
1219 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "The number of coordinates for this triangle is %D != 6 or 9", numCoords)return PetscError(((MPI_Comm)0x44000001),1219,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"The number of coordinates for this triangle is %D != 6 or 9"
,numCoords)
;
1220 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1221 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)
;
1222}
1223
1224static PetscErrorCode DMPlexComputeRectangleGeometry_Internal(DM dm, PetscInt e, PetscInt Nq, const PetscReal points[], PetscReal v[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1225{
1226 PetscSection coordSection;
1227 Vec coordinates;
1228 PetscScalar *coords = NULL((void*)0);
1229 PetscInt numCoords, numSelfCoords = 0, d, f, g, pStart, pEnd;
1230 PetscErrorCode ierr;
1231
1232 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1232; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1233 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1233,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1234 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1234,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1235 ierr = PetscSectionGetChart(coordSection,&pStart,&pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1235,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1236 if (e >= pStart && e < pEnd) {ierr = PetscSectionGetDof(coordSection,e,&numSelfCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1236,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1237 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1237,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1238 numCoords = numSelfCoords ? numSelfCoords : numCoords;
1239 if (!Nq) {
1240 *detJ = 0.0;
1241 if (numCoords == 12) {
1242 const PetscInt dim = 3;
1243 PetscReal R[9], J0[9] = {1.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,1.0};
1244
1245 if (v) {for (d = 0; d < dim; d++) v[d] = PetscRealPart(coords[d])(coords[d]);}
1246 ierr = DMPlexComputeProjection3Dto2D(numCoords, coords, R);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1246,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1247 if (J) {
1248 const PetscInt pdim = 2;
1249
1250 for (d = 0; d < pdim; d++) {
1251 J0[d*dim+0] = 0.5*(PetscRealPart(coords[1*pdim+d])(coords[1*pdim+d]) - PetscRealPart(coords[0*pdim+d])(coords[0*pdim+d]));
1252 J0[d*dim+1] = 0.5*(PetscRealPart(coords[2*pdim+d])(coords[2*pdim+d]) - PetscRealPart(coords[1*pdim+d])(coords[1*pdim+d]));
1253 }
1254 ierr = PetscLogFlops(8.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1255 DMPlex_Det3D_Internal(detJ, J0);
1256 for (d = 0; d < dim; d++) {
1257 for (f = 0; f < dim; f++) {
1258 J[d*dim+f] = 0.0;
1259 for (g = 0; g < dim; g++) {
1260 J[d*dim+f] += R[d*dim+g]*J0[g*dim+f];
1261 }
1262 }
1263 }
1264 ierr = PetscLogFlops(18.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1264,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1265 }
1266 if (invJ) {DMPlex_Invert3D_Internal(invJ, J, *detJ);}
1267 } else if (numCoords == 8) {
1268 const PetscInt dim = 2;
1269
1270 if (v) {for (d = 0; d < dim; d++) v[d] = PetscRealPart(coords[d])(coords[d]);}
1271 if (J) {
1272 for (d = 0; d < dim; d++) {
1273 J[d*dim+0] = 0.5*(PetscRealPart(coords[1*dim+d])(coords[1*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1274 J[d*dim+1] = 0.5*(PetscRealPart(coords[3*dim+d])(coords[3*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1275 }
1276 ierr = PetscLogFlops(8.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1276,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1277 DMPlex_Det2D_Internal(detJ, J);
1278 }
1279 if (invJ) {DMPlex_Invert2D_Internal(invJ, J, *detJ);}
1280 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "The number of coordinates for this quadrilateral is %D != 8 or 12", numCoords)return PetscError(((MPI_Comm)0x44000001),1280,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"The number of coordinates for this quadrilateral is %D != 8 or 12"
,numCoords)
;
1281 } else {
1282 const PetscInt Nv = 4;
1283 const PetscInt dimR = 2;
1284 const PetscInt zToPlex[4] = {0, 1, 3, 2};
1285 PetscReal zOrder[12];
1286 PetscReal zCoeff[12];
1287 PetscInt i, j, k, l, dim;
1288
1289 if (numCoords == 12) {
1290 dim = 3;
1291 } else if (numCoords == 8) {
1292 dim = 2;
1293 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "The number of coordinates for this quadrilateral is %D != 8 or 12", numCoords)return PetscError(((MPI_Comm)0x44000001),1293,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"The number of coordinates for this quadrilateral is %D != 8 or 12"
,numCoords)
;
1294 for (i = 0; i < Nv; i++) {
1295 PetscInt zi = zToPlex[i];
1296
1297 for (j = 0; j < dim; j++) {
1298 zOrder[dim * i + j] = PetscRealPart(coords[dim * zi + j])(coords[dim * zi + j]);
1299 }
1300 }
1301 for (j = 0; j < dim; j++) {
1302 zCoeff[dim * 0 + j] = 0.25 * ( zOrder[dim * 0 + j] + zOrder[dim * 1 + j] + zOrder[dim * 2 + j] + zOrder[dim * 3 + j]);
1303 zCoeff[dim * 1 + j] = 0.25 * (- zOrder[dim * 0 + j] + zOrder[dim * 1 + j] - zOrder[dim * 2 + j] + zOrder[dim * 3 + j]);
1304 zCoeff[dim * 2 + j] = 0.25 * (- zOrder[dim * 0 + j] - zOrder[dim * 1 + j] + zOrder[dim * 2 + j] + zOrder[dim * 3 + j]);
1305 zCoeff[dim * 3 + j] = 0.25 * ( zOrder[dim * 0 + j] - zOrder[dim * 1 + j] - zOrder[dim * 2 + j] + zOrder[dim * 3 + j]);
1306 }
1307 for (i = 0; i < Nq; i++) {
1308 PetscReal xi = points[dimR * i], eta = points[dimR * i + 1];
1309
1310 if (v) {
1311 PetscReal extPoint[4];
1312
1313 extPoint[0] = 1.;
1314 extPoint[1] = xi;
1315 extPoint[2] = eta;
1316 extPoint[3] = xi * eta;
1317 for (j = 0; j < dim; j++) {
1318 PetscReal val = 0.;
1319
1320 for (k = 0; k < Nv; k++) {
1321 val += extPoint[k] * zCoeff[dim * k + j];
1322 }
1323 v[i * dim + j] = val;
1324 }
1325 }
1326 if (J) {
1327 PetscReal extJ[8];
1328
1329 extJ[0] = 0.;
1330 extJ[1] = 0.;
1331 extJ[2] = 1.;
1332 extJ[3] = 0.;
1333 extJ[4] = 0.;
1334 extJ[5] = 1.;
1335 extJ[6] = eta;
1336 extJ[7] = xi;
1337 for (j = 0; j < dim; j++) {
1338 for (k = 0; k < dimR; k++) {
1339 PetscReal val = 0.;
1340
1341 for (l = 0; l < Nv; l++) {
1342 val += zCoeff[dim * l + j] * extJ[dimR * l + k];
1343 }
1344 J[i * dim * dim + dim * j + k] = val;
1345 }
1346 }
1347 if (dim == 3) { /* put the cross product in the third component of the Jacobian */
1348 PetscReal x, y, z;
1349 PetscReal *iJ = &J[i * dim * dim];
1350 PetscReal norm;
1351
1352 x = iJ[1 * dim + 0] * iJ[2 * dim + 1] - iJ[1 * dim + 1] * iJ[2 * dim + 0];
1353 y = iJ[0 * dim + 1] * iJ[2 * dim + 0] - iJ[0 * dim + 0] * iJ[2 * dim + 1];
1354 z = iJ[0 * dim + 0] * iJ[1 * dim + 1] - iJ[0 * dim + 1] * iJ[1 * dim + 0];
1355 norm = PetscSqrtReal(x * x + y * y + z * z)sqrt(x * x + y * y + z * z);
1356 iJ[2] = x / norm;
1357 iJ[5] = y / norm;
1358 iJ[8] = z / norm;
1359 DMPlex_Det3D_Internal(&detJ[i], &J[i * dim * dim]);
1360 if (invJ) {DMPlex_Invert3D_Internal(&invJ[i * dim * dim], &J[i * dim * dim], detJ[i]);}
1361 } else {
1362 DMPlex_Det2D_Internal(&detJ[i], &J[i * dim * dim]);
1363 if (invJ) {DMPlex_Invert2D_Internal(&invJ[i * dim * dim], &J[i * dim * dim], detJ[i]);}
1364 }
1365 }
1366 }
1367 }
1368 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, e, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1368,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1369 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)
;
1370}
1371
1372static PetscErrorCode DMPlexComputeTetrahedronGeometry_Internal(DM dm, PetscInt e, PetscReal v0[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1373{
1374 PetscSection coordSection;
1375 Vec coordinates;
1376 PetscScalar *coords = NULL((void*)0);
1377 const PetscInt dim = 3;
1378 PetscInt d;
1379 PetscErrorCode ierr;
1380
1381 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1381; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1382 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1382,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1383 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1383,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1384 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, e, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1384,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1385 *detJ = 0.0;
1386 if (v0) {for (d = 0; d < dim; d++) v0[d] = PetscRealPart(coords[d])(coords[d]);}
1387 if (J) {
1388 for (d = 0; d < dim; d++) {
1389 /* I orient with outward face normals */
1390 J[d*dim+0] = 0.5*(PetscRealPart(coords[2*dim+d])(coords[2*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1391 J[d*dim+1] = 0.5*(PetscRealPart(coords[1*dim+d])(coords[1*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1392 J[d*dim+2] = 0.5*(PetscRealPart(coords[3*dim+d])(coords[3*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1393 }
1394 ierr = PetscLogFlops(18.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1394,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1395 DMPlex_Det3D_Internal(detJ, J);
1396 }
1397 if (invJ) {DMPlex_Invert3D_Internal(invJ, J, *detJ);}
1398 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, e, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1398,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1399 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)
;
1400}
1401
1402static PetscErrorCode DMPlexComputeHexahedronGeometry_Internal(DM dm, PetscInt e, PetscInt Nq, const PetscReal points[], PetscReal v[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1403{
1404 PetscSection coordSection;
1405 Vec coordinates;
1406 PetscScalar *coords = NULL((void*)0);
1407 const PetscInt dim = 3;
1408 PetscInt d;
1409 PetscErrorCode ierr;
1410
1411 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1411; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1412 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1412,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1413 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1413,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1414 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, e, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1414,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1415 if (!Nq) {
1416 *detJ = 0.0;
1417 if (v) {for (d = 0; d < dim; d++) v[d] = PetscRealPart(coords[d])(coords[d]);}
1418 if (J) {
1419 for (d = 0; d < dim; d++) {
1420 J[d*dim+0] = 0.5*(PetscRealPart(coords[3*dim+d])(coords[3*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1421 J[d*dim+1] = 0.5*(PetscRealPart(coords[1*dim+d])(coords[1*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1422 J[d*dim+2] = 0.5*(PetscRealPart(coords[4*dim+d])(coords[4*dim+d]) - PetscRealPart(coords[0*dim+d])(coords[0*dim+d]));
1423 }
1424 ierr = PetscLogFlops(18.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1424,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1425 DMPlex_Det3D_Internal(detJ, J);
1426 }
1427 if (invJ) {DMPlex_Invert3D_Internal(invJ, J, *detJ);}
1428 } else {
1429 const PetscInt Nv = 8;
1430 const PetscInt zToPlex[8] = {0, 3, 1, 2, 4, 5, 7, 6};
1431 const PetscInt dim = 3;
1432 const PetscInt dimR = 3;
1433 PetscReal zOrder[24];
1434 PetscReal zCoeff[24];
1435 PetscInt i, j, k, l;
1436
1437 for (i = 0; i < Nv; i++) {
1438 PetscInt zi = zToPlex[i];
1439
1440 for (j = 0; j < dim; j++) {
1441 zOrder[dim * i + j] = PetscRealPart(coords[dim * zi + j])(coords[dim * zi + j]);
1442 }
1443 }
1444 for (j = 0; j < dim; j++) {
1445 zCoeff[dim * 0 + j] = 0.125 * ( zOrder[dim * 0 + j] + zOrder[dim * 1 + j] + zOrder[dim * 2 + j] + zOrder[dim * 3 + j] + zOrder[dim * 4 + j] + zOrder[dim * 5 + j] + zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1446 zCoeff[dim * 1 + j] = 0.125 * (- zOrder[dim * 0 + j] + zOrder[dim * 1 + j] - zOrder[dim * 2 + j] + zOrder[dim * 3 + j] - zOrder[dim * 4 + j] + zOrder[dim * 5 + j] - zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1447 zCoeff[dim * 2 + j] = 0.125 * (- zOrder[dim * 0 + j] - zOrder[dim * 1 + j] + zOrder[dim * 2 + j] + zOrder[dim * 3 + j] - zOrder[dim * 4 + j] - zOrder[dim * 5 + j] + zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1448 zCoeff[dim * 3 + j] = 0.125 * ( zOrder[dim * 0 + j] - zOrder[dim * 1 + j] - zOrder[dim * 2 + j] + zOrder[dim * 3 + j] + zOrder[dim * 4 + j] - zOrder[dim * 5 + j] - zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1449 zCoeff[dim * 4 + j] = 0.125 * (- zOrder[dim * 0 + j] - zOrder[dim * 1 + j] - zOrder[dim * 2 + j] - zOrder[dim * 3 + j] + zOrder[dim * 4 + j] + zOrder[dim * 5 + j] + zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1450 zCoeff[dim * 5 + j] = 0.125 * (+ zOrder[dim * 0 + j] - zOrder[dim * 1 + j] + zOrder[dim * 2 + j] - zOrder[dim * 3 + j] - zOrder[dim * 4 + j] + zOrder[dim * 5 + j] - zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1451 zCoeff[dim * 6 + j] = 0.125 * (+ zOrder[dim * 0 + j] + zOrder[dim * 1 + j] - zOrder[dim * 2 + j] - zOrder[dim * 3 + j] - zOrder[dim * 4 + j] - zOrder[dim * 5 + j] + zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1452 zCoeff[dim * 7 + j] = 0.125 * (- zOrder[dim * 0 + j] + zOrder[dim * 1 + j] + zOrder[dim * 2 + j] - zOrder[dim * 3 + j] + zOrder[dim * 4 + j] - zOrder[dim * 5 + j] - zOrder[dim * 6 + j] + zOrder[dim * 7 + j]);
1453 }
1454 for (i = 0; i < Nq; i++) {
1455 PetscReal xi = points[dimR * i], eta = points[dimR * i + 1], theta = points[dimR * i + 2];
1456
1457 if (v) {
1458 PetscReal extPoint[8];
1459
1460 extPoint[0] = 1.;
1461 extPoint[1] = xi;
1462 extPoint[2] = eta;
1463 extPoint[3] = xi * eta;
1464 extPoint[4] = theta;
1465 extPoint[5] = theta * xi;
1466 extPoint[6] = theta * eta;
1467 extPoint[7] = theta * eta * xi;
1468 for (j = 0; j < dim; j++) {
1469 PetscReal val = 0.;
1470
1471 for (k = 0; k < Nv; k++) {
1472 val += extPoint[k] * zCoeff[dim * k + j];
1473 }
1474 v[i * dim + j] = val;
1475 }
1476 }
1477 if (J) {
1478 PetscReal extJ[24];
1479
1480 extJ[0] = 0. ; extJ[1] = 0. ; extJ[2] = 0. ;
1481 extJ[3] = 1. ; extJ[4] = 0. ; extJ[5] = 0. ;
1482 extJ[6] = 0. ; extJ[7] = 1. ; extJ[8] = 0. ;
1483 extJ[9] = eta ; extJ[10] = xi ; extJ[11] = 0. ;
1484 extJ[12] = 0. ; extJ[13] = 0. ; extJ[14] = 1. ;
1485 extJ[15] = theta ; extJ[16] = 0. ; extJ[17] = xi ;
1486 extJ[18] = 0. ; extJ[19] = theta ; extJ[20] = eta ;
1487 extJ[21] = theta * eta; extJ[22] = theta * xi; extJ[23] = eta * xi;
1488
1489 for (j = 0; j < dim; j++) {
1490 for (k = 0; k < dimR; k++) {
1491 PetscReal val = 0.;
1492
1493 for (l = 0; l < Nv; l++) {
1494 val += zCoeff[dim * l + j] * extJ[dimR * l + k];
1495 }
1496 J[i * dim * dim + dim * j + k] = val;
1497 }
1498 }
1499 DMPlex_Det3D_Internal(&detJ[i], &J[i * dim * dim]);
1500 if (invJ) {DMPlex_Invert3D_Internal(&invJ[i * dim * dim], &J[i * dim * dim], detJ[i]);}
1501 }
1502 }
1503 }
1504 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, e, NULL((void*)0), &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1504,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1505 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)
;
1506}
1507
1508static PetscErrorCode DMPlexComputeCellGeometryFEM_Implicit(DM dm, PetscInt cell, PetscQuadrature quad, PetscReal *v, PetscReal *J, PetscReal *invJ, PetscReal *detJ)
1509{
1510 PetscInt depth, dim, coordDim, coneSize, i;
1511 PetscInt Nq = 0;
1512 const PetscReal *points = NULL((void*)0);
1513 DMLabel depthLabel;
1514 PetscReal xi0[3] = {-1.,-1.,-1.}, v0[3], J0[9], detJ0;
1515 PetscBool isAffine = PETSC_TRUE;
1516 PetscErrorCode ierr;
1517
1518 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1518; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1519 ierr = DMPlexGetDepth(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1519,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1520 ierr = DMPlexGetConeSize(dm, cell, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1520,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1521 ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1521,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1522 ierr = DMLabelGetValue(depthLabel, cell, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1522,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1523 if (depth == 1 && dim == 1) {
1524 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1524,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1525 }
1526 ierr = DMGetCoordinateDim(dm, &coordDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1526,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1527 if (coordDim > 3) SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Unsupported coordinate dimension %D > 3", coordDim)return PetscError(PetscObjectComm((PetscObject)dm),1527,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unsupported coordinate dimension %D > 3"
,coordDim)
;
1528 if (quad) {ierr = PetscQuadratureGetData(quad, NULL((void*)0), NULL((void*)0), &Nq, &points, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1528,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1529 switch (dim) {
1530 case 0:
1531 ierr = DMPlexComputePointGeometry_Internal(dm, cell, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1531,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1532 isAffine = PETSC_FALSE;
1533 break;
1534 case 1:
1535 if (Nq) {
1536 ierr = DMPlexComputeLineGeometry_Internal(dm, cell, v0, J0, NULL((void*)0), &detJ0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1536,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1537 } else {
1538 ierr = DMPlexComputeLineGeometry_Internal(dm, cell, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1538,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1539 }
1540 break;
1541 case 2:
1542 switch (coneSize) {
1543 case 3:
1544 if (Nq) {
1545 ierr = DMPlexComputeTriangleGeometry_Internal(dm, cell, v0, J0, NULL((void*)0), &detJ0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1545,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1546 } else {
1547 ierr = DMPlexComputeTriangleGeometry_Internal(dm, cell, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1547,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1548 }
1549 break;
1550 case 4:
1551 ierr = DMPlexComputeRectangleGeometry_Internal(dm, cell, Nq, points, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1551,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1552 isAffine = PETSC_FALSE;
1553 break;
1554 default:
1555 SETERRQ2(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Unsupported number of faces %D in cell %D for element geometry computation", coneSize, cell)return PetscError(PetscObjectComm((PetscObject)dm),1555,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unsupported number of faces %D in cell %D for element geometry computation"
,coneSize,cell)
;
1556 }
1557 break;
1558 case 3:
1559 switch (coneSize) {
1560 case 4:
1561 if (Nq) {
1562 ierr = DMPlexComputeTetrahedronGeometry_Internal(dm, cell, v0, J0, NULL((void*)0), &detJ0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1562,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1563 } else {
1564 ierr = DMPlexComputeTetrahedronGeometry_Internal(dm, cell, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1564,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1565 }
1566 break;
1567 case 6: /* Faces */
1568 case 8: /* Vertices */
1569 ierr = DMPlexComputeHexahedronGeometry_Internal(dm, cell, Nq, points, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1569,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1570 isAffine = PETSC_FALSE;
1571 break;
1572 default:
1573 SETERRQ2(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Unsupported number of faces %D in cell %D for element geometry computation", coneSize, cell)return PetscError(PetscObjectComm((PetscObject)dm),1573,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unsupported number of faces %D in cell %D for element geometry computation"
,coneSize,cell)
;
1574 }
1575 break;
1576 default:
1577 SETERRQ1(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Unsupported dimension %D for element geometry computation", dim)return PetscError(PetscObjectComm((PetscObject)dm),1577,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unsupported dimension %D for element geometry computation"
,dim)
;
1578 }
1579 if (isAffine && Nq) {
1580 if (v) {
1581 for (i = 0; i < Nq; i++) {
1582 CoordinatesRefToReal(coordDim, dim, xi0, v0, J0, &points[dim * i], &v[coordDim * i]);
1583 }
1584 }
1585 if (detJ) {
1586 for (i = 0; i < Nq; i++) {
1587 detJ[i] = detJ0;
1588 }
1589 }
1590 if (J) {
1591 PetscInt k;
1592
1593 for (i = 0, k = 0; i < Nq; i++) {
1594 PetscInt j;
1595
1596 for (j = 0; j < coordDim * coordDim; j++, k++) {
1597 J[k] = J0[j];
1598 }
1599 }
1600 }
1601 if (invJ) {
1602 PetscInt k;
1603 switch (coordDim) {
1604 case 0:
1605 break;
1606 case 1:
1607 invJ[0] = 1./J0[0];
1608 break;
1609 case 2:
1610 DMPlex_Invert2D_Internal(invJ, J0, detJ0);
1611 break;
1612 case 3:
1613 DMPlex_Invert3D_Internal(invJ, J0, detJ0);
1614 break;
1615 }
1616 for (i = 1, k = coordDim * coordDim; i < Nq; i++) {
1617 PetscInt j;
1618
1619 for (j = 0; j < coordDim * coordDim; j++, k++) {
1620 invJ[k] = invJ[j];
1621 }
1622 }
1623 }
1624 }
1625 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)
;
1626}
1627
1628/*@C
1629 DMPlexComputeCellGeometryAffineFEM - Assuming an affine map, compute the Jacobian, inverse Jacobian, and Jacobian determinant for a given cell
1630
1631 Collective on dm
1632
1633 Input Arguments:
1634+ dm - the DM
1635- cell - the cell
1636
1637 Output Arguments:
1638+ v0 - the translation part of this affine transform
1639. J - the Jacobian of the transform from the reference element
1640. invJ - the inverse of the Jacobian
1641- detJ - the Jacobian determinant
1642
1643 Level: advanced
1644
1645 Fortran Notes:
1646 Since it returns arrays, this routine is only available in Fortran 90, and you must
1647 include petsc.h90 in your code.
1648
1649.seealso: DMPlexComputeCellGeometryFEM(), DMGetCoordinateSection(), DMGetCoordinates()
1650@*/
1651PetscErrorCode DMPlexComputeCellGeometryAffineFEM(DM dm, PetscInt cell, PetscReal *v0, PetscReal *J, PetscReal *invJ, PetscReal *detJ)
1652{
1653 PetscErrorCode ierr;
1654
1655 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1655; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1656 ierr = DMPlexComputeCellGeometryFEM_Implicit(dm,cell,NULL((void*)0),v0,J,invJ,detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1656,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1657 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)
;
1658}
1659
1660static PetscErrorCode DMPlexComputeCellGeometryFEM_FE(DM dm, PetscFE fe, PetscInt point, PetscQuadrature quad, PetscReal v[], PetscReal J[], PetscReal invJ[], PetscReal *detJ)
1661{
1662 PetscQuadrature feQuad;
1663 PetscSection coordSection;
1664 Vec coordinates;
1665 PetscScalar *coords = NULL((void*)0);
1666 const PetscReal *quadPoints;
1667 PetscReal *basisDer, *basis, detJt;
1668 PetscInt dim, cdim, pdim, qdim, Nq, numCoords, q;
1669 PetscErrorCode ierr;
1670
1671 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1671; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1672 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1672,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1673 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1673,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1674 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, point, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1674,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1675 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1675,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1676 ierr = DMGetCoordinateDim(dm, &cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1676,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1677 if (!quad) { /* use the first point of the first functional of the dual space */
1678 PetscDualSpace dsp;
1679
1680 ierr = PetscFEGetDualSpace(fe, &dsp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1680,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1681 ierr = PetscDualSpaceGetFunctional(dsp, 0, &quad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1681,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1682 ierr = PetscQuadratureGetData(quad, &qdim, NULL((void*)0), &Nq, &quadPoints, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1682,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1683 Nq = 1;
1684 } else {
1685 ierr = PetscQuadratureGetData(quad, &qdim, NULL((void*)0), &Nq, &quadPoints, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1685,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1686 }
1687 ierr = PetscFEGetDimension(fe, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1687,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1688 ierr = PetscFEGetQuadrature(fe, &feQuad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1688,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1689 if (feQuad == quad) {
1690 ierr = PetscFEGetDefaultTabulation(fe, &basis, J ? &basisDer : NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1690,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1691 if (numCoords != pdim*cdim) SETERRQ4(PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "There are %d coordinates for point %d != %d*%d", numCoords, point, pdim, cdim)return PetscError(((MPI_Comm)0x44000001),1691,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,60,PETSC_ERROR_INITIAL,"There are %d coordinates for point %d != %d*%d"
,numCoords,point,pdim,cdim)
;
1692 } else {
1693 ierr = PetscFEGetTabulation(fe, Nq, quadPoints, &basis, J ? &basisDer : NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1693,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1694 }
1695 if (qdim != dim) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Point dimension %d != quadrature dimension %d", dim, qdim)return PetscError(((MPI_Comm)0x44000001),1695,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,60,PETSC_ERROR_INITIAL,"Point dimension %d != quadrature dimension %d"
,dim,qdim)
;
1696 if (v) {
1697 ierr = PetscArrayzero(v, Nq*cdim)PetscMemzero(v,(Nq*cdim)*sizeof(*(v)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1697,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1698 for (q = 0; q < Nq; ++q) {
1699 PetscInt i, k;
1700
1701 for (k = 0; k < pdim; ++k)
1702 for (i = 0; i < cdim; ++i)
1703 v[q*cdim + i] += basis[q*pdim + k] * PetscRealPart(coords[k*cdim + i])(coords[k*cdim + i]);
1704 ierr = PetscLogFlops(2.0*pdim*cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1704,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1705 }
1706 }
1707 if (J) {
1708 ierr = PetscArrayzero(J, Nq*cdim*cdim)PetscMemzero(J,(Nq*cdim*cdim)*sizeof(*(J)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1708,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1709 for (q = 0; q < Nq; ++q) {
1710 PetscInt i, j, k, c, r;
1711
1712 /* J = dx_i/d\xi_j = sum[k=0,n-1] dN_k/d\xi_j * x_i(k) */
1713 for (k = 0; k < pdim; ++k)
1714 for (j = 0; j < dim; ++j)
1715 for (i = 0; i < cdim; ++i)
1716 J[(q*cdim + i)*cdim + j] += basisDer[(q*pdim + k)*dim + j] * PetscRealPart(coords[k*cdim + i])(coords[k*cdim + i]);
1717 ierr = PetscLogFlops(2.0*pdim*dim*cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1717,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1718 if (cdim > dim) {
1719 for (c = dim; c < cdim; ++c)
1720 for (r = 0; r < cdim; ++r)
1721 J[r*cdim+c] = r == c ? 1.0 : 0.0;
1722 }
1723 if (!detJ && !invJ) continue;
1724 detJt = 0.;
1725 switch (cdim) {
1726 case 3:
1727 DMPlex_Det3D_Internal(&detJt, &J[q*cdim*dim]);
1728 if (invJ) {DMPlex_Invert3D_Internal(&invJ[q*cdim*dim], &J[q*cdim*dim], detJt);}
1729 break;
1730 case 2:
1731 DMPlex_Det2D_Internal(&detJt, &J[q*cdim*dim]);
1732 if (invJ) {DMPlex_Invert2D_Internal(&invJ[q*cdim*dim], &J[q*cdim*dim], detJt);}
1733 break;
1734 case 1:
1735 detJt = J[q*cdim*dim];
1736 if (invJ) invJ[q*cdim*dim] = 1.0/detJt;
1737 }
1738 if (detJ) detJ[q] = detJt;
1739 }
1740 }
1741 else if (detJ || invJ) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_SIZ, "Need J to compute invJ or detJ")return PetscError(((MPI_Comm)0x44000001),1741,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,60,PETSC_ERROR_INITIAL,"Need J to compute invJ or detJ")
;
1742 if (feQuad != quad) {
1743 ierr = PetscFERestoreTabulation(fe, Nq, quadPoints, &basis, J ? &basisDer : NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1743,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1744 }
1745 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, point, &numCoords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1745,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1746 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)
;
1747}
1748
1749/*@C
1750 DMPlexComputeCellGeometryFEM - Compute the Jacobian, inverse Jacobian, and Jacobian determinant at each quadrature point in the given cell
1751
1752 Collective on dm
1753
1754 Input Arguments:
1755+ dm - the DM
1756. cell - the cell
1757- quad - the quadrature containing the points in the reference element where the geometry will be evaluated. If quad == NULL, geometry will be
1758 evaluated at the first vertex of the reference element
1759
1760 Output Arguments:
1761+ v - the image of the transformed quadrature points, otherwise the image of the first vertex in the closure of the reference element
1762. J - the Jacobian of the transform from the reference element at each quadrature point
1763. invJ - the inverse of the Jacobian at each quadrature point
1764- detJ - the Jacobian determinant at each quadrature point
1765
1766 Level: advanced
1767
1768 Fortran Notes:
1769 Since it returns arrays, this routine is only available in Fortran 90, and you must
1770 include petsc.h90 in your code.
1771
1772.seealso: DMGetCoordinateSection(), DMGetCoordinates()
1773@*/
1774PetscErrorCode DMPlexComputeCellGeometryFEM(DM dm, PetscInt cell, PetscQuadrature quad, PetscReal *v, PetscReal *J, PetscReal *invJ, PetscReal *detJ)
1775{
1776 DM cdm;
1777 PetscFE fe = NULL((void*)0);
1778 PetscErrorCode ierr;
1779
1780 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1780; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1781 PetscValidPointer(detJ, 7)do { if (!detJ) return PetscError(((MPI_Comm)0x44000001),1781
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",7); if
(!PetscCheckPointer(detJ,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),1781,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",7);
} while (0)
;
1782 ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1782,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1783 if (cdm) {
1784 PetscClassId id;
1785 PetscInt numFields;
1786 PetscDS prob;
1787 PetscObject disc;
1788
1789 ierr = DMGetNumFields(cdm, &numFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1789,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1790 if (numFields) {
1791 ierr = DMGetDS(cdm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1791,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1792 ierr = PetscDSGetDiscretization(prob,0,&disc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1792,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1793 ierr = PetscObjectGetClassId(disc,&id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1793,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1794 if (id == PETSCFE_CLASSID) {
1795 fe = (PetscFE) disc;
1796 }
1797 }
1798 }
1799 if (!fe) {ierr = DMPlexComputeCellGeometryFEM_Implicit(dm, cell, quad, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1799,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1800 else {ierr = DMPlexComputeCellGeometryFEM_FE(dm, fe, cell, quad, v, J, invJ, detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1800,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1801 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)
;
1802}
1803
1804static PetscErrorCode DMPlexComputeGeometryFVM_1D_Internal(DM dm, PetscInt dim, PetscInt cell, PetscReal *vol, PetscReal centroid[], PetscReal normal[])
1805{
1806 PetscSection coordSection;
1807 Vec coordinates;
1808 PetscScalar *coords = NULL((void*)0);
1809 PetscScalar tmp[2];
1810 PetscInt coordSize;
1811 PetscErrorCode ierr;
1812
1813 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1813; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1814 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1814,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1815 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1815,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1816 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, cell, &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1816,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1817 if (dim != 2) SETERRQ(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "We only support 2D edges right now")return PetscError(PetscObjectComm((PetscObject)dm),1817,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"We only support 2D edges right now")
;
1818 ierr = DMLocalizeCoordinate_Internal(dm, dim, coords, &coords[dim], tmp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1818,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1819 if (centroid) {
1820 centroid[0] = 0.5*PetscRealPart(coords[0] + tmp[0])(coords[0] + tmp[0]);
1821 centroid[1] = 0.5*PetscRealPart(coords[1] + tmp[1])(coords[1] + tmp[1]);
1822 }
1823 if (normal) {
1824 PetscReal norm;
1825
1826 normal[0] = -PetscRealPart(coords[1] - tmp[1])(coords[1] - tmp[1]);
1827 normal[1] = PetscRealPart(coords[0] - tmp[0])(coords[0] - tmp[0]);
1828 norm = PetscSqrtReal(normal[0]*normal[0] + normal[1]*normal[1])sqrt(normal[0]*normal[0] + normal[1]*normal[1]);
1829 normal[0] /= norm;
1830 normal[1] /= norm;
1831 }
1832 if (vol) {
1833 *vol = PetscSqrtReal(PetscSqr(PetscRealPart(coords[0] - tmp[0])) + PetscSqr(PetscRealPart(coords[1] - tmp[1])))sqrt((((coords[0] - tmp[0]))*((coords[0] - tmp[0]))) + (((coords
[1] - tmp[1]))*((coords[1] - tmp[1]))))
;
1834 }
1835 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, cell, &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1835,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1836 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)
;
1837}
1838
1839/* Centroid_i = (\sum_n A_n Cn_i ) / A */
1840static PetscErrorCode DMPlexComputeGeometryFVM_2D_Internal(DM dm, PetscInt dim, PetscInt cell, PetscReal *vol, PetscReal centroid[], PetscReal normal[])
1841{
1842 DMLabel depth;
1843 PetscSection coordSection;
1844 Vec coordinates;
1845 PetscScalar *coords = NULL((void*)0);
1846 PetscReal vsum = 0.0, csum[3] = {0.0, 0.0, 0.0}, vtmp, ctmp[4], v0[3], R[9];
1847 PetscBool isHybrid = PETSC_FALSE;
1848 PetscInt fv[4] = {0, 1, 2, 3};
1849 PetscInt cdepth, pEndInterior[4], tdim = 2, coordSize, numCorners, p, d, e;
1850 PetscErrorCode ierr;
1851
1852 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1852; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1853 /* Must check for hybrid cells because prisms have a different orientation scheme */
1854 ierr = DMPlexGetDepthLabel(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1854,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1855 ierr = DMLabelGetValue(depth, cell, &cdepth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1855,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1856 ierr = DMPlexGetHybridBounds(dm, &pEndInterior[3], &pEndInterior[2], &pEndInterior[1], &pEndInterior[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1856,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1857 if ((pEndInterior[cdepth]) >=0 && (cell >= pEndInterior[cdepth])) isHybrid = PETSC_TRUE;
1858
1859 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1859,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1860 ierr = DMPlexGetConeSize(dm, cell, &numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1860,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1861 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1861,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1862 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, cell, &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1862,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1863 ierr = DMGetCoordinateDim(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1864 /* Side faces for hybrid cells are are stored as tensor products */
1865 if (isHybrid && numCorners == 4) {fv[2] = 3; fv[3] = 2;}
1866
1867 if (dim > 2 && centroid) {
1868 v0[0] = PetscRealPart(coords[0])(coords[0]);
1869 v0[1] = PetscRealPart(coords[1])(coords[1]);
1870 v0[2] = PetscRealPart(coords[2])(coords[2]);
1871 }
1872 if (normal) {
1873 if (dim > 2) {
1874 const PetscReal x0 = PetscRealPart(coords[dim*fv[1]+0] - coords[0])(coords[dim*fv[1]+0] - coords[0]), x1 = PetscRealPart(coords[dim*fv[2]+0] - coords[0])(coords[dim*fv[2]+0] - coords[0]);
1875 const PetscReal y0 = PetscRealPart(coords[dim*fv[1]+1] - coords[1])(coords[dim*fv[1]+1] - coords[1]), y1 = PetscRealPart(coords[dim*fv[2]+1] - coords[1])(coords[dim*fv[2]+1] - coords[1]);
1876 const PetscReal z0 = PetscRealPart(coords[dim*fv[1]+2] - coords[2])(coords[dim*fv[1]+2] - coords[2]), z1 = PetscRealPart(coords[dim*fv[2]+2] - coords[2])(coords[dim*fv[2]+2] - coords[2]);
1877 PetscReal norm;
1878
1879 normal[0] = y0*z1 - z0*y1;
1880 normal[1] = z0*x1 - x0*z1;
1881 normal[2] = x0*y1 - y0*x1;
1882 norm = PetscSqrtReal(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal[2])sqrt(normal[0]*normal[0] + normal[1]*normal[1] + normal[2]*normal
[2])
;
1883 normal[0] /= norm;
1884 normal[1] /= norm;
1885 normal[2] /= norm;
1886 } else {
1887 for (d = 0; d < dim; ++d) normal[d] = 0.0;
1888 }
1889 }
1890 if (dim == 3) {ierr = DMPlexComputeProjection3Dto2D(coordSize, coords, R);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1890,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1891 for (p = 0; p < numCorners; ++p) {
1892 const PetscInt pi = p < 4 ? fv[p] : p;
1893 const PetscInt pin = p < 3 ? fv[(p+1)%numCorners] : (p+1)%numCorners;
1894 /* Need to do this copy to get types right */
1895 for (d = 0; d < tdim; ++d) {
1896 ctmp[d] = PetscRealPart(coords[pi*tdim+d])(coords[pi*tdim+d]);
1897 ctmp[tdim+d] = PetscRealPart(coords[pin*tdim+d])(coords[pin*tdim+d]);
1898 }
1899 Volume_Triangle_Origin_Internal(&vtmp, ctmp);
1900 vsum += vtmp;
1901 for (d = 0; d < tdim; ++d) {
1902 csum[d] += (ctmp[d] + ctmp[tdim+d])*vtmp;
1903 }
1904 }
1905 for (d = 0; d < tdim; ++d) {
1906 csum[d] /= (tdim+1)*vsum;
1907 }
1908 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, cell, &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1908,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1909 if (vol) *vol = PetscAbsReal(vsum)fabs(vsum);
1910 if (centroid) {
1911 if (dim > 2) {
1912 for (d = 0; d < dim; ++d) {
1913 centroid[d] = v0[d];
1914 for (e = 0; e < dim; ++e) {
1915 centroid[d] += R[d*dim+e]*csum[e];
1916 }
1917 }
1918 } else for (d = 0; d < dim; ++d) centroid[d] = csum[d];
1919 }
1920 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)
;
1921}
1922
1923/* Centroid_i = (\sum_n V_n Cn_i ) / V */
1924static PetscErrorCode DMPlexComputeGeometryFVM_3D_Internal(DM dm, PetscInt dim, PetscInt cell, PetscReal *vol, PetscReal centroid[], PetscReal normal[])
1925{
1926 DMLabel depth;
1927 PetscSection coordSection;
1928 Vec coordinates;
1929 PetscScalar *coords = NULL((void*)0);
1930 PetscReal vsum = 0.0, vtmp, coordsTmp[3*3];
1931 const PetscInt *faces, *facesO;
1932 PetscBool isHybrid = PETSC_FALSE;
1933 PetscInt pEndInterior[4], cdepth, numFaces, f, coordSize, numCorners, p, d;
1934 PetscErrorCode ierr;
1935
1936 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 1936; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1937 if (PetscUnlikely(dim > 3)__builtin_expect(!!(dim > 3),0)) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"No support for dim %D > 3",dim)return PetscError(((MPI_Comm)0x44000001),1937,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"No support for dim %D > 3",dim)
;
1
Taking false branch
1938 /* Must check for hybrid cells because prisms have a different orientation scheme */
1939 ierr = DMPlexGetDepthLabel(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1939,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1940 ierr = DMLabelGetValue(depth, cell, &cdepth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1940,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1941 ierr = DMPlexGetHybridBounds(dm, &pEndInterior[3], &pEndInterior[2], &pEndInterior[1], &pEndInterior[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1941,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1942 if ((pEndInterior[cdepth]) >=0 && (cell >= pEndInterior[cdepth])) isHybrid = PETSC_TRUE;
1943
1944 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1944,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1945 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1945,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1946
1947 if (centroid) for (d = 0; d < dim; ++d) centroid[d] = 0.0;
2
Assuming 'centroid' is non-null
3
Taking true branch
4
Assuming 'd' is < 'dim'
5
Loop condition is true. Entering loop body
6
Assuming 'd' is < 'dim'
7
Loop condition is true. Entering loop body
8
Assuming 'd' is >= 'dim'
9
Loop condition is false. Execution continues on line 1948
1948 ierr = DMPlexGetConeSize(dm, cell, &numFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1948,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1949 ierr = DMPlexGetCone(dm, cell, &faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1949,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1950 ierr = DMPlexGetConeOrientation(dm, cell, &facesO);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1950,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1951 for (f = 0; f < numFaces; ++f) {
10
Assuming 'f' is < 'numFaces'
11
Loop condition is true. Entering loop body
1952 PetscBool flip = isHybrid && f == 0 ? PETSC_TRUE : PETSC_FALSE; /* The first hybrid face is reversed */
1953
1954 ierr = DMPlexVecGetClosure(dm, coordSection, coordinates, faces[f], &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1954,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1955 numCorners = coordSize/dim;
1956 switch (numCorners) {
12
Control jumps to 'case 3:' at line 1957
1957 case 3:
1958 for (d = 0; d < dim; ++d) {
13
Loop condition is true. Entering loop body
14
Loop condition is true. Entering loop body
15
Loop condition is false. Execution continues on line 1963
1959 coordsTmp[0*dim+d] = PetscRealPart(coords[0*dim+d])(coords[0*dim+d]);
1960 coordsTmp[1*dim+d] = PetscRealPart(coords[1*dim+d])(coords[1*dim+d]);
1961 coordsTmp[2*dim+d] = PetscRealPart(coords[2*dim+d])(coords[2*dim+d]);
1962 }
1963 Volume_Tetrahedron_Origin_Internal(&vtmp, coordsTmp);
16
Calling 'Volume_Tetrahedron_Origin_Internal'
1964 if (facesO[f] < 0 || flip) vtmp = -vtmp;
1965 vsum += vtmp;
1966 if (centroid) { /* Centroid of OABC = (a+b+c)/4 */
1967 for (d = 0; d < dim; ++d) {
1968 for (p = 0; p < 3; ++p) centroid[d] += coordsTmp[p*dim+d]*vtmp;
1969 }
1970 }
1971 break;
1972 case 4:
1973 {
1974 PetscInt fv[4] = {0, 1, 2, 3};
1975
1976 /* Side faces for hybrid cells are are stored as tensor products */
1977 if (isHybrid && f > 1) {fv[2] = 3; fv[3] = 2;}
1978 /* DO FOR PYRAMID */
1979 /* First tet */
1980 for (d = 0; d < dim; ++d) {
1981 coordsTmp[0*dim+d] = PetscRealPart(coords[fv[0]*dim+d])(coords[fv[0]*dim+d]);
1982 coordsTmp[1*dim+d] = PetscRealPart(coords[fv[1]*dim+d])(coords[fv[1]*dim+d]);
1983 coordsTmp[2*dim+d] = PetscRealPart(coords[fv[3]*dim+d])(coords[fv[3]*dim+d]);
1984 }
1985 Volume_Tetrahedron_Origin_Internal(&vtmp, coordsTmp);
1986 if (facesO[f] < 0 || flip) vtmp = -vtmp;
1987 vsum += vtmp;
1988 if (centroid) {
1989 for (d = 0; d < dim; ++d) {
1990 for (p = 0; p < 3; ++p) centroid[d] += coordsTmp[p*dim+d]*vtmp;
1991 }
1992 }
1993 /* Second tet */
1994 for (d = 0; d < dim; ++d) {
1995 coordsTmp[0*dim+d] = PetscRealPart(coords[fv[1]*dim+d])(coords[fv[1]*dim+d]);
1996 coordsTmp[1*dim+d] = PetscRealPart(coords[fv[2]*dim+d])(coords[fv[2]*dim+d]);
1997 coordsTmp[2*dim+d] = PetscRealPart(coords[fv[3]*dim+d])(coords[fv[3]*dim+d]);
1998 }
1999 Volume_Tetrahedron_Origin_Internal(&vtmp, coordsTmp);
2000 if (facesO[f] < 0 || flip) vtmp = -vtmp;
2001 vsum += vtmp;
2002 if (centroid) {
2003 for (d = 0; d < dim; ++d) {
2004 for (p = 0; p < 3; ++p) centroid[d] += coordsTmp[p*dim+d]*vtmp;
2005 }
2006 }
2007 break;
2008 }
2009 default:
2010 SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Cannot handle faces with %D vertices", numCorners)return PetscError(((MPI_Comm)0x44000001),2010,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"Cannot handle faces with %D vertices"
,numCorners)
;
2011 }
2012 ierr = DMPlexVecRestoreClosure(dm, coordSection, coordinates, faces[f], &coordSize, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2012,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2013 }
2014 if (vol) *vol = PetscAbsReal(vsum)fabs(vsum);
2015 if (normal) for (d = 0; d < dim; ++d) normal[d] = 0.0;
2016 if (centroid) for (d = 0; d < dim; ++d) centroid[d] /= (vsum*4);
2017 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)
;
2018}
2019
2020/*@C
2021 DMPlexComputeCellGeometryFVM - Compute the volume for a given cell
2022
2023 Collective on dm
2024
2025 Input Arguments:
2026+ dm - the DM
2027- cell - the cell
2028
2029 Output Arguments:
2030+ volume - the cell volume
2031. centroid - the cell centroid
2032- normal - the cell normal, if appropriate
2033
2034 Level: advanced
2035
2036 Fortran Notes:
2037 Since it returns arrays, this routine is only available in Fortran 90, and you must
2038 include petsc.h90 in your code.
2039
2040.seealso: DMGetCoordinateSection(), DMGetCoordinates()
2041@*/
2042PetscErrorCode DMPlexComputeCellGeometryFVM(DM dm, PetscInt cell, PetscReal *vol, PetscReal centroid[], PetscReal normal[])
2043{
2044 PetscInt depth, dim;
2045 PetscErrorCode ierr;
2046
2047 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2047; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2048 ierr = DMPlexGetDepth(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2048,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2049 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2049,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2050 if (depth != dim) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Mesh must be interpolated")return PetscError(((MPI_Comm)0x44000001),2050,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Mesh must be interpolated")
;
2051 /* We need to keep a pointer to the depth label */
2052 ierr = DMGetLabelValue(dm, "depth", cell, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2052,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2053 /* Cone size is now the number of faces */
2054 switch (depth) {
2055 case 1:
2056 ierr = DMPlexComputeGeometryFVM_1D_Internal(dm, dim, cell, vol, centroid, normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2056,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2057 break;
2058 case 2:
2059 ierr = DMPlexComputeGeometryFVM_2D_Internal(dm, dim, cell, vol, centroid, normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2059,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2060 break;
2061 case 3:
2062 ierr = DMPlexComputeGeometryFVM_3D_Internal(dm, dim, cell, vol, centroid, normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2062,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2063 break;
2064 default:
2065 SETERRQ2(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Unsupported dimension %D (depth %D) for element geometry computation", dim, depth)return PetscError(PetscObjectComm((PetscObject)dm),2065,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unsupported dimension %D (depth %D) for element geometry computation"
,dim,depth)
;
2066 }
2067 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)
;
2068}
2069
2070/*@
2071 DMPlexComputeGeometryFEM - Precompute cell geometry for the entire mesh
2072
2073 Collective on dm
2074
2075 Input Parameter:
2076. dm - The DMPlex
2077
2078 Output Parameter:
2079. cellgeom - A vector with the cell geometry data for each cell
2080
2081 Level: beginner
2082
2083@*/
2084PetscErrorCode DMPlexComputeGeometryFEM(DM dm, Vec *cellgeom)
2085{
2086 DM dmCell;
2087 Vec coordinates;
2088 PetscSection coordSection, sectionCell;
2089 PetscScalar *cgeom;
2090 PetscInt cStart, cEnd, cMax, c;
2091 PetscErrorCode ierr;
2092
2093 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2093; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2094 ierr = DMClone(dm, &dmCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2094,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2095 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2095,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2096 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2096,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2097 ierr = DMSetCoordinateSection(dmCell, PETSC_DETERMINE-1, coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2097,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2098 ierr = DMSetCoordinatesLocal(dmCell, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2098,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2099 ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), &sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2099,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2100 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2100,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2101 ierr = DMPlexGetHybridBounds(dm, &cMax, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2101,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2102 cEnd = cMax < 0 ? cEnd : cMax;
2103 ierr = PetscSectionSetChart(sectionCell, cStart, cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2103,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2104 /* TODO This needs to be multiplied by Nq for non-affine */
2105 for (c = cStart; c < cEnd; ++c) {ierr = PetscSectionSetDof(sectionCell, c, (PetscInt) PetscCeilReal(((PetscReal) sizeof(PetscFEGeom))/sizeof(PetscScalar))ceil(((PetscReal) sizeof(PetscFEGeom))/sizeof(PetscScalar)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2105,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2106 ierr = PetscSectionSetUp(sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2106,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2107 ierr = DMSetSection(dmCell, sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2107,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2108 ierr = PetscSectionDestroy(&sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2108,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2109 ierr = DMCreateLocalVector(dmCell, cellgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2109,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2110 ierr = VecGetArray(*cellgeom, &cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2110,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2111 for (c = cStart; c < cEnd; ++c) {
2112 PetscFEGeom *cg;
2113
2114 ierr = DMPlexPointLocalRef(dmCell, c, cgeom, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2115 ierr = PetscArrayzero(cg, 1)PetscMemzero(cg,(1)*sizeof(*(cg)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2115,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2116 ierr = DMPlexComputeCellGeometryFEM(dmCell, c, NULL((void*)0), cg->v, cg->J, cg->invJ, cg->detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2116,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2117 if (*cg->detJ <= 0.0) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Invalid determinant %g for element %d", cg->detJ, c)return PetscError(((MPI_Comm)0x44000001),2117,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"Invalid determinant %g for element %d"
,cg->detJ,c)
;
2118 }
2119 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)
;
2120}
2121
2122/*@
2123 DMPlexComputeGeometryFVM - Computes the cell and face geometry for a finite volume method
2124
2125 Input Parameter:
2126. dm - The DM
2127
2128 Output Parameters:
2129+ cellgeom - A Vec of PetscFVCellGeom data
2130. facegeom - A Vec of PetscFVFaceGeom data
2131
2132 Level: developer
2133
2134.seealso: PetscFVFaceGeom, PetscFVCellGeom, DMPlexComputeGeometryFEM()
2135@*/
2136PetscErrorCode DMPlexComputeGeometryFVM(DM dm, Vec *cellgeom, Vec *facegeom)
2137{
2138 DM dmFace, dmCell;
2139 DMLabel ghostLabel;
2140 PetscSection sectionFace, sectionCell;
2141 PetscSection coordSection;
2142 Vec coordinates;
2143 PetscScalar *fgeom, *cgeom;
2144 PetscReal minradius, gminradius;
2145 PetscInt dim, cStart, cEnd, cEndInterior, c, fStart, fEnd, f;
2146 PetscErrorCode ierr;
2147
2148 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2148; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2149 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2149,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2150 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2150,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2151 ierr = DMGetCoordinatesLocal(dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2151,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2152 /* Make cell centroids and volumes */
2153 ierr = DMClone(dm, &dmCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2153,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2154 ierr = DMSetCoordinateSection(dmCell, PETSC_DETERMINE-1, coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2154,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2155 ierr = DMSetCoordinatesLocal(dmCell, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2155,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2156 ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), &sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2156,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2157 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2157,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2158 ierr = DMPlexGetHybridBounds(dm, &cEndInterior, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2158,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2159 ierr = PetscSectionSetChart(sectionCell, cStart, cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2159,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2160 for (c = cStart; c < cEnd; ++c) {ierr = PetscSectionSetDof(sectionCell, c, (PetscInt) PetscCeilReal(((PetscReal) sizeof(PetscFVCellGeom))/sizeof(PetscScalar))ceil(((PetscReal) sizeof(PetscFVCellGeom))/sizeof(PetscScalar
))
);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2160,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2161 ierr = PetscSectionSetUp(sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2161,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2162 ierr = DMSetSection(dmCell, sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2162,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2163 ierr = PetscSectionDestroy(&sectionCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2163,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2164 ierr = DMCreateLocalVector(dmCell, cellgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2164,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2165 if (cEndInterior < 0) {
2166 cEndInterior = cEnd;
2167 }
2168 ierr = VecGetArray(*cellgeom, &cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2168,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2169 for (c = cStart; c < cEndInterior; ++c) {
2170 PetscFVCellGeom *cg;
2171
2172 ierr = DMPlexPointLocalRef(dmCell, c, cgeom, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2172,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2173 ierr = PetscArrayzero(cg, 1)PetscMemzero(cg,(1)*sizeof(*(cg)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2173,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2174 ierr = DMPlexComputeCellGeometryFVM(dmCell, c, &cg->volume, cg->centroid, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2175 }
2176 /* Compute face normals and minimum cell radius */
2177 ierr = DMClone(dm, &dmFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2177,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2178 ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), &sectionFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2178,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2179 ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2179,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2180 ierr = PetscSectionSetChart(sectionFace, fStart, fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2180,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2181 for (f = fStart; f < fEnd; ++f) {ierr = PetscSectionSetDof(sectionFace, f, (PetscInt) PetscCeilReal(((PetscReal) sizeof(PetscFVFaceGeom))/sizeof(PetscScalar))ceil(((PetscReal) sizeof(PetscFVFaceGeom))/sizeof(PetscScalar
))
);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2181,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2182 ierr = PetscSectionSetUp(sectionFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2182,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2183 ierr = DMSetSection(dmFace, sectionFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2183,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2184 ierr = PetscSectionDestroy(&sectionFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2184,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2185 ierr = DMCreateLocalVector(dmFace, facegeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2185,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2186 ierr = VecGetArray(*facegeom, &fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2186,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2187 ierr = DMGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2188 minradius = PETSC_MAX_REAL1.7976931348623157e+308;
2189 for (f = fStart; f < fEnd; ++f) {
2190 PetscFVFaceGeom *fg;
2191 PetscReal area;
2192 PetscInt ghost = -1, d, numChildren;
2193
2194 if (ghostLabel) {ierr = DMLabelGetValue(ghostLabel, f, &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2194,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2195 ierr = DMPlexGetTreeChildren(dm,f,&numChildren,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2195,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2196 if (ghost >= 0 || numChildren) continue;
2197 ierr = DMPlexPointLocalRef(dmFace, f, fgeom, &fg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2197,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2198 ierr = DMPlexComputeCellGeometryFVM(dm, f, &area, fg->centroid, fg->normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2198,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2199 for (d = 0; d < dim; ++d) fg->normal[d] *= area;
2200 /* Flip face orientation if necessary to match ordering in support, and Update minimum radius */
2201 {
2202 PetscFVCellGeom *cL, *cR;
2203 PetscInt ncells;
2204 const PetscInt *cells;
2205 PetscReal *lcentroid, *rcentroid;
2206 PetscReal l[3], r[3], v[3];
2207
2208 ierr = DMPlexGetSupport(dm, f, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2208,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2209 ierr = DMPlexGetSupportSize(dm, f, &ncells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2209,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2210 ierr = DMPlexPointLocalRead(dmCell, cells[0], cgeom, &cL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2210,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2211 lcentroid = cells[0] >= cEndInterior ? fg->centroid : cL->centroid;
2212 if (ncells > 1) {
2213 ierr = DMPlexPointLocalRead(dmCell, cells[1], cgeom, &cR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2213,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2214 rcentroid = cells[1] >= cEndInterior ? fg->centroid : cR->centroid;
2215 }
2216 else {
2217 rcentroid = fg->centroid;
2218 }
2219 ierr = DMLocalizeCoordinateReal_Internal(dm, dim, fg->centroid, lcentroid, l);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2219,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2220 ierr = DMLocalizeCoordinateReal_Internal(dm, dim, fg->centroid, rcentroid, r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2221 DMPlex_WaxpyD_Internal(dim, -1, l, r, v);
2222 if (DMPlex_DotRealD_Internal(dim, fg->normal, v) < 0) {
2223 for (d = 0; d < dim; ++d) fg->normal[d] = -fg->normal[d];
2224 }
2225 if (DMPlex_DotRealD_Internal(dim, fg->normal, v) <= 0) {
2226 if (dim == 2) SETERRQ5(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Direction for face %d could not be fixed, normal (%g,%g) v (%g,%g)", f, (double) fg->normal[0], (double) fg->normal[1], (double) v[0], (double) v[1])return PetscError(((MPI_Comm)0x44000001),2226,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Direction for face %d could not be fixed, normal (%g,%g) v (%g,%g)"
,f,(double) fg->normal[0],(double) fg->normal[1],(double
) v[0],(double) v[1])
;
2227 if (dim == 3) SETERRQ7(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Direction for face %d could not be fixed, normal (%g,%g,%g) v (%g,%g,%g)", f, (double) fg->normal[0], (double) fg->normal[1], (double) fg->normal[2], (double) v[0], (double) v[1], (double) v[2])return PetscError(((MPI_Comm)0x44000001),2227,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Direction for face %d could not be fixed, normal (%g,%g,%g) v (%g,%g,%g)"
,f,(double) fg->normal[0],(double) fg->normal[1],(double
) fg->normal[2],(double) v[0],(double) v[1],(double) v[2])
;
2228 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Direction for face %d could not be fixed", f)return PetscError(((MPI_Comm)0x44000001),2228,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Direction for face %d could not be fixed"
,f)
;
2229 }
2230 if (cells[0] < cEndInterior) {
2231 DMPlex_WaxpyD_Internal(dim, -1, fg->centroid, cL->centroid, v);
2232 minradius = PetscMin(minradius, DMPlex_NormD_Internal(dim, v))(((minradius)<(DMPlex_NormD_Internal(dim, v))) ? (minradius
) : (DMPlex_NormD_Internal(dim, v)))
;
2233 }
2234 if (ncells > 1 && cells[1] < cEndInterior) {
2235 DMPlex_WaxpyD_Internal(dim, -1, fg->centroid, cR->centroid, v);
2236 minradius = PetscMin(minradius, DMPlex_NormD_Internal(dim, v))(((minradius)<(DMPlex_NormD_Internal(dim, v))) ? (minradius
) : (DMPlex_NormD_Internal(dim, v)))
;
2237 }
2238 }
2239 }
2240 ierr = MPIU_Allreduce(&minradius, &gminradius, 1, MPIU_REAL, MPIU_MIN, PetscObjectComm((PetscObject)dm))(PetscAllreduceBarrierCheck(PetscObjectComm((PetscObject)dm),
1,2240,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)dm))),0) || MPI_Allreduce((&minradius),(&
gminradius),(1),(((MPI_Datatype)0x4c00080b)),((MPI_Op)(0x58000002
)),(PetscObjectComm((PetscObject)dm)))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2240,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2241 ierr = DMPlexSetMinRadius(dm, gminradius);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2241,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2242 /* Compute centroids of ghost cells */
2243 for (c = cEndInterior; c < cEnd; ++c) {
2244 PetscFVFaceGeom *fg;
2245 const PetscInt *cone, *support;
2246 PetscInt coneSize, supportSize, s;
2247
2248 ierr = DMPlexGetConeSize(dmCell, c, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2248,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2249 if (coneSize != 1) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Ghost cell %d has cone size %d != 1", c, coneSize)return PetscError(((MPI_Comm)0x44000001),2249,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Ghost cell %d has cone size %d != 1"
,c,coneSize)
;
2250 ierr = DMPlexGetCone(dmCell, c, &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2250,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2251 ierr = DMPlexGetSupportSize(dmCell, cone[0], &supportSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2251,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2252 if (supportSize != 2) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Face %d has support size %d != 2", cone[0], supportSize)return PetscError(((MPI_Comm)0x44000001),2252,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Face %d has support size %d != 2",cone
[0],supportSize)
;
2253 ierr = DMPlexGetSupport(dmCell, cone[0], &support);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2253,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2254 ierr = DMPlexPointLocalRef(dmFace, cone[0], fgeom, &fg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2255 for (s = 0; s < 2; ++s) {
2256 /* Reflect ghost centroid across plane of face */
2257 if (support[s] == c) {
2258 PetscFVCellGeom *ci;
2259 PetscFVCellGeom *cg;
2260 PetscReal c2f[3], a;
2261
2262 ierr = DMPlexPointLocalRead(dmCell, support[(s+1)%2], cgeom, &ci);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2262,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2263 DMPlex_WaxpyD_Internal(dim, -1, ci->centroid, fg->centroid, c2f); /* cell to face centroid */
2264 a = DMPlex_DotRealD_Internal(dim, c2f, fg->normal)/DMPlex_DotRealD_Internal(dim, fg->normal, fg->normal);
2265 ierr = DMPlexPointLocalRef(dmCell, support[s], cgeom, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2265,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2266 DMPlex_WaxpyD_Internal(dim, 2*a, fg->normal, ci->centroid, cg->centroid);
2267 cg->volume = ci->volume;
2268 }
2269 }
2270 }
2271 ierr = VecRestoreArray(*facegeom, &fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2271,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2272 ierr = VecRestoreArray(*cellgeom, &cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2272,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2273 ierr = DMDestroy(&dmCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2273,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2274 ierr = DMDestroy(&dmFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2274,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2275 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)
;
2276}
2277
2278/*@C
2279 DMPlexGetMinRadius - Returns the minimum distance from any cell centroid to a face
2280
2281 Not collective
2282
2283 Input Argument:
2284. dm - the DM
2285
2286 Output Argument:
2287. minradius - the minium cell radius
2288
2289 Level: developer
2290
2291.seealso: DMGetCoordinates()
2292@*/
2293PetscErrorCode DMPlexGetMinRadius(DM dm, PetscReal *minradius)
2294{
2295 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2295; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2296 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2296,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2296,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),2296,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2296,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2297 PetscValidPointer(minradius,2)do { if (!minradius) return PetscError(((MPI_Comm)0x44000001)
,2297,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(minradius,PETSC_CHAR)) return PetscError
(((MPI_Comm)0x44000001),2297,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
2298 *minradius = ((DM_Plex*) dm->data)->minradius;
2299 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)
;
2300}
2301
2302/*@C
2303 DMPlexSetMinRadius - Sets the minimum distance from the cell centroid to a face
2304
2305 Logically collective
2306
2307 Input Arguments:
2308+ dm - the DM
2309- minradius - the minium cell radius
2310
2311 Level: developer
2312
2313.seealso: DMSetCoordinates()
2314@*/
2315PetscErrorCode DMPlexSetMinRadius(DM dm, PetscReal minradius)
2316{
2317 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2317; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2318 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2318,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2318,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),2318,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2318,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2319 ((DM_Plex*) dm->data)->minradius = minradius;
2320 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)
;
2321}
2322
2323static PetscErrorCode BuildGradientReconstruction_Internal(DM dm, PetscFV fvm, DM dmFace, PetscScalar *fgeom, DM dmCell, PetscScalar *cgeom)
2324{
2325 DMLabel ghostLabel;
2326 PetscScalar *dx, *grad, **gref;
2327 PetscInt dim, cStart, cEnd, c, cEndInterior, maxNumFaces;
2328 PetscErrorCode ierr;
2329
2330 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2330; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2331 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2331,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2332 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2332,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2333 ierr = DMPlexGetHybridBounds(dm, &cEndInterior, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2333,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2334 ierr = DMPlexGetMaxSizes(dm, &maxNumFaces, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2334,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2335 ierr = PetscFVLeastSquaresSetMaxFaces(fvm, maxNumFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2335,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2336 ierr = DMGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2336,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2337 ierr = PetscMalloc3(maxNumFaces*dim, &dx, maxNumFaces*dim, &grad, maxNumFaces, &gref)PetscMallocA(3,PETSC_FALSE,2337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(maxNumFaces*dim)*sizeof(**(&dx)),(&dx),(size_t
)(maxNumFaces*dim)*sizeof(**(&grad)),(&grad),(size_t)
(maxNumFaces)*sizeof(**(&gref)),(&gref))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2338 for (c = cStart; c < cEndInterior; c++) {
2339 const PetscInt *faces;
2340 PetscInt numFaces, usedFaces, f, d;
2341 PetscFVCellGeom *cg;
2342 PetscBool boundary;
2343 PetscInt ghost;
2344
2345 ierr = DMPlexPointLocalRead(dmCell, c, cgeom, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2345,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2346 ierr = DMPlexGetConeSize(dm, c, &numFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2346,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2347 ierr = DMPlexGetCone(dm, c, &faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2347,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2348 if (numFaces < dim) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Cell %D has only %D faces, not enough for gradient reconstruction", c, numFaces)return PetscError(((MPI_Comm)0x44000001),2348,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,75,PETSC_ERROR_INITIAL,"Cell %D has only %D faces, not enough for gradient reconstruction"
,c,numFaces)
;
2349 for (f = 0, usedFaces = 0; f < numFaces; ++f) {
2350 PetscFVCellGeom *cg1;
2351 PetscFVFaceGeom *fg;
2352 const PetscInt *fcells;
2353 PetscInt ncell, side;
2354
2355 ierr = DMLabelGetValue(ghostLabel, faces[f], &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2355,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2356 ierr = DMIsBoundaryPoint(dm, faces[f], &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2356,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2357 if ((ghost >= 0) || boundary) continue;
2358 ierr = DMPlexGetSupport(dm, faces[f], &fcells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2358,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2359 side = (c != fcells[0]); /* c is on left=0 or right=1 of face */
2360 ncell = fcells[!side]; /* the neighbor */
2361 ierr = DMPlexPointLocalRef(dmFace, faces[f], fgeom, &fg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2361,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2362 ierr = DMPlexPointLocalRead(dmCell, ncell, cgeom, &cg1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2362,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2363 for (d = 0; d < dim; ++d) dx[usedFaces*dim+d] = cg1->centroid[d] - cg->centroid[d];
2364 gref[usedFaces++] = fg->grad[side]; /* Gradient reconstruction term will go here */
2365 }
2366 if (!usedFaces) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_USER, "Mesh contains isolated cell (no neighbors). Is it intentional?")return PetscError(((MPI_Comm)0x44000001),2366,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,83,PETSC_ERROR_INITIAL,"Mesh contains isolated cell (no neighbors). Is it intentional?"
)
;
2367 ierr = PetscFVComputeGradient(fvm, usedFaces, dx, grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2367,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2368 for (f = 0, usedFaces = 0; f < numFaces; ++f) {
2369 ierr = DMLabelGetValue(ghostLabel, faces[f], &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2369,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2370 ierr = DMIsBoundaryPoint(dm, faces[f], &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2370,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2371 if ((ghost >= 0) || boundary) continue;
2372 for (d = 0; d < dim; ++d) gref[usedFaces][d] = grad[usedFaces*dim+d];
2373 ++usedFaces;
2374 }
2375 }
2376 ierr = PetscFree3(dx, grad, gref)PetscFreeA(3,2376,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,&(dx),&(grad),&(gref))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2376,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2377 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)
;
2378}
2379
2380static PetscErrorCode BuildGradientReconstruction_Internal_Tree(DM dm, PetscFV fvm, DM dmFace, PetscScalar *fgeom, DM dmCell, PetscScalar *cgeom)
2381{
2382 DMLabel ghostLabel;
2383 PetscScalar *dx, *grad, **gref;
2384 PetscInt dim, cStart, cEnd, c, cEndInterior, fStart, fEnd, f, nStart, nEnd, maxNumFaces = 0;
2385 PetscSection neighSec;
2386 PetscInt (*neighbors)[2];
2387 PetscInt *counter;
2388 PetscErrorCode ierr;
2389
2390 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2390; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2391 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2391,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2392 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2392,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2393 ierr = DMPlexGetHybridBounds(dm, &cEndInterior, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2393,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2394 if (cEndInterior < 0) {
2395 cEndInterior = cEnd;
2396 }
2397 ierr = PetscSectionCreate(PetscObjectComm((PetscObject)dm),&neighSec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2397,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2398 ierr = PetscSectionSetChart(neighSec,cStart,cEndInterior);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2398,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2399 ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2399,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2400 ierr = DMGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2400,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2401 for (f = fStart; f < fEnd; f++) {
2402 const PetscInt *fcells;
2403 PetscBool boundary;
2404 PetscInt ghost = -1;
2405 PetscInt numChildren, numCells, c;
2406
2407 if (ghostLabel) {ierr = DMLabelGetValue(ghostLabel, f, &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2407,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2408 ierr = DMIsBoundaryPoint(dm, f, &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2408,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2409 ierr = DMPlexGetTreeChildren(dm, f, &numChildren, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2409,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2410 if ((ghost >= 0) || boundary || numChildren) continue;
2411 ierr = DMPlexGetSupportSize(dm, f, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2411,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2412 if (numCells == 2) {
2413 ierr = DMPlexGetSupport(dm, f, &fcells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2413,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2414 for (c = 0; c < 2; c++) {
2415 PetscInt cell = fcells[c];
2416
2417 if (cell >= cStart && cell < cEndInterior) {
2418 ierr = PetscSectionAddDof(neighSec,cell,1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2418,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2419 }
2420 }
2421 }
2422 }
2423 ierr = PetscSectionSetUp(neighSec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2423,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2424 ierr = PetscSectionGetMaxDof(neighSec,&maxNumFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2424,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2425 ierr = PetscFVLeastSquaresSetMaxFaces(fvm, maxNumFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2425,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2426 nStart = 0;
2427 ierr = PetscSectionGetStorageSize(neighSec,&nEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2427,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2428 ierr = PetscMalloc1((nEnd-nStart),&neighbors)PetscMallocA(1,PETSC_FALSE,2428,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)((nEnd-nStart))*sizeof(**(&neighbors)),(&neighbors
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2428,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2429 ierr = PetscCalloc1((cEndInterior-cStart),&counter)PetscMallocA(1,PETSC_TRUE,2429,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)((cEndInterior-cStart))*sizeof(**(&counter)),(&
counter))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2429,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2430 for (f = fStart; f < fEnd; f++) {
2431 const PetscInt *fcells;
2432 PetscBool boundary;
2433 PetscInt ghost = -1;
2434 PetscInt numChildren, numCells, c;
2435
2436 if (ghostLabel) {ierr = DMLabelGetValue(ghostLabel, f, &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2436,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2437 ierr = DMIsBoundaryPoint(dm, f, &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2437,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2438 ierr = DMPlexGetTreeChildren(dm, f, &numChildren, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2438,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2439 if ((ghost >= 0) || boundary || numChildren) continue;
2440 ierr = DMPlexGetSupportSize(dm, f, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2440,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2441 if (numCells == 2) {
2442 ierr = DMPlexGetSupport(dm, f, &fcells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2442,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2443 for (c = 0; c < 2; c++) {
2444 PetscInt cell = fcells[c], off;
2445
2446 if (cell >= cStart && cell < cEndInterior) {
2447 ierr = PetscSectionGetOffset(neighSec,cell,&off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2447,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2448 off += counter[cell - cStart]++;
2449 neighbors[off][0] = f;
2450 neighbors[off][1] = fcells[1 - c];
2451 }
2452 }
2453 }
2454 }
2455 ierr = PetscFree(counter)((*PetscTrFree)((void*)(counter),2455,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((counter) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2455,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2456 ierr = PetscMalloc3(maxNumFaces*dim, &dx, maxNumFaces*dim, &grad, maxNumFaces, &gref)PetscMallocA(3,PETSC_FALSE,2456,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,(size_t)(maxNumFaces*dim)*sizeof(**(&dx)),(&dx),(size_t
)(maxNumFaces*dim)*sizeof(**(&grad)),(&grad),(size_t)
(maxNumFaces)*sizeof(**(&gref)),(&gref))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2456,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2457 for (c = cStart; c < cEndInterior; c++) {
2458 PetscInt numFaces, f, d, off, ghost = -1;
2459 PetscFVCellGeom *cg;
2460
2461 ierr = DMPlexPointLocalRead(dmCell, c, cgeom, &cg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2461,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2462 ierr = PetscSectionGetDof(neighSec, c, &numFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2462,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2463 ierr = PetscSectionGetOffset(neighSec, c, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2463,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2464 if (ghostLabel) {ierr = DMLabelGetValue(ghostLabel, c, &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2464,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2465 if (ghost < 0 && numFaces < dim) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_ARG_INCOMP,"Cell %D has only %D faces, not enough for gradient reconstruction", c, numFaces)return PetscError(((MPI_Comm)0x44000001),2465,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,75,PETSC_ERROR_INITIAL,"Cell %D has only %D faces, not enough for gradient reconstruction"
,c,numFaces)
;
2466 for (f = 0; f < numFaces; ++f) {
2467 PetscFVCellGeom *cg1;
2468 PetscFVFaceGeom *fg;
2469 const PetscInt *fcells;
2470 PetscInt ncell, side, nface;
2471
2472 nface = neighbors[off + f][0];
2473 ncell = neighbors[off + f][1];
2474 ierr = DMPlexGetSupport(dm,nface,&fcells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2474,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2475 side = (c != fcells[0]);
2476 ierr = DMPlexPointLocalRef(dmFace, nface, fgeom, &fg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2476,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2477 ierr = DMPlexPointLocalRead(dmCell, ncell, cgeom, &cg1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2477,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2478 for (d = 0; d < dim; ++d) dx[f*dim+d] = cg1->centroid[d] - cg->centroid[d];
2479 gref[f] = fg->grad[side]; /* Gradient reconstruction term will go here */
2480 }
2481 ierr = PetscFVComputeGradient(fvm, numFaces, dx, grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2481,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2482 for (f = 0; f < numFaces; ++f) {
2483 for (d = 0; d < dim; ++d) gref[f][d] = grad[f*dim+d];
2484 }
2485 }
2486 ierr = PetscFree3(dx, grad, gref)PetscFreeA(3,2486,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,&(dx),&(grad),&(gref))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2486,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2487 ierr = PetscSectionDestroy(&neighSec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2487,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2488 ierr = PetscFree(neighbors)((*PetscTrFree)((void*)(neighbors),2488,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
) || ((neighbors) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2488,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2489 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)
;
2490}
2491
2492/*@
2493 DMPlexComputeGradientFVM - Compute geometric factors for gradient reconstruction, which are stored in the geometry data, and compute layout for gradient data
2494
2495 Collective on dm
2496
2497 Input Arguments:
2498+ dm - The DM
2499. fvm - The PetscFV
2500. faceGeometry - The face geometry from DMPlexComputeFaceGeometryFVM()
2501- cellGeometry - The face geometry from DMPlexComputeCellGeometryFVM()
2502
2503 Output Parameters:
2504+ faceGeometry - The geometric factors for gradient calculation are inserted
2505- dmGrad - The DM describing the layout of gradient data
2506
2507 Level: developer
2508
2509.seealso: DMPlexGetFaceGeometryFVM(), DMPlexGetCellGeometryFVM()
2510@*/
2511PetscErrorCode DMPlexComputeGradientFVM(DM dm, PetscFV fvm, Vec faceGeometry, Vec cellGeometry, DM *dmGrad)
2512{
2513 DM dmFace, dmCell;
2514 PetscScalar *fgeom, *cgeom;
2515 PetscSection sectionGrad, parentSection;
2516 PetscInt dim, pdim, cStart, cEnd, cEndInterior, c;
2517 PetscErrorCode ierr;
2518
2519 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2519; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2520 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2520,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2521 ierr = PetscFVGetNumComponents(fvm, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2521,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2522 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2522,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2523 ierr = DMPlexGetHybridBounds(dm, &cEndInterior, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2523,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2524 /* Construct the interpolant corresponding to each face from the least-square solution over the cell neighborhood */
2525 ierr = VecGetDM(faceGeometry, &dmFace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2525,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2526 ierr = VecGetDM(cellGeometry, &dmCell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2526,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2527 ierr = VecGetArray(faceGeometry, &fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2527,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2528 ierr = VecGetArray(cellGeometry, &cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2528,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2529 ierr = DMPlexGetTree(dm,&parentSection,NULL((void*)0),NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2529,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2530 if (!parentSection) {
2531 ierr = BuildGradientReconstruction_Internal(dm, fvm, dmFace, fgeom, dmCell, cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2531,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2532 } else {
2533 ierr = BuildGradientReconstruction_Internal_Tree(dm, fvm, dmFace, fgeom, dmCell, cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2533,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2534 }
2535 ierr = VecRestoreArray(faceGeometry, &fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2535,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2536 ierr = VecRestoreArray(cellGeometry, &cgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2536,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2537 /* Create storage for gradients */
2538 ierr = DMClone(dm, dmGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2538,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2539 ierr = PetscSectionCreate(PetscObjectComm((PetscObject) dm), &sectionGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2539,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2540 ierr = PetscSectionSetChart(sectionGrad, cStart, cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2540,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2541 for (c = cStart; c < cEnd; ++c) {ierr = PetscSectionSetDof(sectionGrad, c, pdim*dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2541,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2542 ierr = PetscSectionSetUp(sectionGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2542,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2543 ierr = DMSetSection(*dmGrad, sectionGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2543,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2544 ierr = PetscSectionDestroy(&sectionGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2544,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2545 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)
;
2546}
2547
2548/*@
2549 DMPlexGetDataFVM - Retrieve precomputed cell geometry
2550
2551 Collective on dm
2552
2553 Input Arguments:
2554+ dm - The DM
2555- fvm - The PetscFV
2556
2557 Output Parameters:
2558+ cellGeometry - The cell geometry
2559. faceGeometry - The face geometry
2560- dmGrad - The gradient matrices
2561
2562 Level: developer
2563
2564.seealso: DMPlexComputeGeometryFVM()
2565@*/
2566PetscErrorCode DMPlexGetDataFVM(DM dm, PetscFV fv, Vec *cellgeom, Vec *facegeom, DM *gradDM)
2567{
2568 PetscObject cellgeomobj, facegeomobj;
2569 PetscErrorCode ierr;
2570
2571 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2571; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2572 ierr = PetscObjectQuery((PetscObject) dm, "DMPlex_cellgeom_fvm", &cellgeomobj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2572,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2573 if (!cellgeomobj) {
2574 Vec cellgeomInt, facegeomInt;
2575
2576 ierr = DMPlexComputeGeometryFVM(dm, &cellgeomInt, &facegeomInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2576,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2577 ierr = PetscObjectCompose((PetscObject) dm, "DMPlex_cellgeom_fvm",(PetscObject)cellgeomInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2577,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2578 ierr = PetscObjectCompose((PetscObject) dm, "DMPlex_facegeom_fvm",(PetscObject)facegeomInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2578,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2579 ierr = VecDestroy(&cellgeomInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2579,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2580 ierr = VecDestroy(&facegeomInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2580,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2581 ierr = PetscObjectQuery((PetscObject) dm, "DMPlex_cellgeom_fvm", &cellgeomobj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2581,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2582 }
2583 ierr = PetscObjectQuery((PetscObject) dm, "DMPlex_facegeom_fvm", &facegeomobj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2583,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2584 if (cellgeom) *cellgeom = (Vec) cellgeomobj;
2585 if (facegeom) *facegeom = (Vec) facegeomobj;
2586 if (gradDM) {
2587 PetscObject gradobj;
2588 PetscBool computeGradients;
2589
2590 ierr = PetscFVGetComputeGradients(fv,&computeGradients);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2590,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2591 if (!computeGradients) {
2592 *gradDM = NULL((void*)0);
2593 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)
;
2594 }
2595 ierr = PetscObjectQuery((PetscObject) dm, "DMPlex_dmgrad_fvm", &gradobj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2595,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2596 if (!gradobj) {
2597 DM dmGradInt;
2598
2599 ierr = DMPlexComputeGradientFVM(dm,fv,(Vec) facegeomobj,(Vec) cellgeomobj,&dmGradInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2599,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2600 ierr = PetscObjectCompose((PetscObject) dm, "DMPlex_dmgrad_fvm", (PetscObject)dmGradInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2600,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2601 ierr = DMDestroy(&dmGradInt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2601,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2602 ierr = PetscObjectQuery((PetscObject) dm, "DMPlex_dmgrad_fvm", &gradobj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2602,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2603 }
2604 *gradDM = (DM) gradobj;
2605 }
2606 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)
;
2607}
2608
2609static PetscErrorCode DMPlexCoordinatesToReference_NewtonUpdate(PetscInt dimC, PetscInt dimR, PetscScalar *J, PetscScalar *invJ, PetscScalar *work, PetscReal *resNeg, PetscReal *guess)
2610{
2611 PetscInt l, m;
2612
2613 PetscFunctionBeginHotdo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2613; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0)
;
2614 if (dimC == dimR && dimR <= 3) {
2615 /* invert Jacobian, multiply */
2616 PetscScalar det, idet;
2617
2618 switch (dimR) {
2619 case 1:
2620 invJ[0] = 1./ J[0];
2621 break;
2622 case 2:
2623 det = J[0] * J[3] - J[1] * J[2];
2624 idet = 1./det;
2625 invJ[0] = J[3] * idet;
2626 invJ[1] = -J[1] * idet;
2627 invJ[2] = -J[2] * idet;
2628 invJ[3] = J[0] * idet;
2629 break;
2630 case 3:
2631 {
2632 invJ[0] = J[4] * J[8] - J[5] * J[7];
2633 invJ[1] = J[2] * J[7] - J[1] * J[8];
2634 invJ[2] = J[1] * J[5] - J[2] * J[4];
2635 det = invJ[0] * J[0] + invJ[1] * J[3] + invJ[2] * J[6];
2636 idet = 1./det;
2637 invJ[0] *= idet;
2638 invJ[1] *= idet;
2639 invJ[2] *= idet;
2640 invJ[3] = idet * (J[5] * J[6] - J[3] * J[8]);
2641 invJ[4] = idet * (J[0] * J[8] - J[2] * J[6]);
2642 invJ[5] = idet * (J[2] * J[3] - J[0] * J[5]);
2643 invJ[6] = idet * (J[3] * J[7] - J[4] * J[6]);
2644 invJ[7] = idet * (J[1] * J[6] - J[0] * J[7]);
2645 invJ[8] = idet * (J[0] * J[4] - J[1] * J[3]);
2646 }
2647 break;
2648 }
2649 for (l = 0; l < dimR; l++) {
2650 for (m = 0; m < dimC; m++) {
2651 guess[l] += PetscRealPart(invJ[l * dimC + m])(invJ[l * dimC + m]) * resNeg[m];
2652 }
2653 }
2654 } else {
2655#if defined(PETSC_USE_COMPLEX)
2656 char transpose = 'C';
2657#else
2658 char transpose = 'T';
2659#endif
2660 PetscBLASInt m = dimR;
2661 PetscBLASInt n = dimC;
2662 PetscBLASInt one = 1;
2663 PetscBLASInt worksize = dimR * dimC, info;
2664
2665 for (l = 0; l < dimC; l++) {invJ[l] = resNeg[l];}
2666
2667 PetscStackCallBLAS("LAPACKgels",LAPACKgels_(&transpose,&m,&n,&one,J,&m,invJ,&n,work,&worksize, &info))do { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = "LAPACKgels"; petscstack->file[petscstack->currentsize
] = "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2667; petscstack
->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
dgels_(&transpose,&m,&n,&one,J,&m,invJ,&
n,work,&worksize, &info); do { do {PetscErrorCode _7_ierr
= PetscMallocValidate(2667,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
);do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError(
((MPI_Comm)0x44000001),2667,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); 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); } while (0); } while(0)
;
2668 if (info != 0) SETERRQ(PETSC_COMM_SELF,PETSC_ERR_LIB,"Bad argument to GELS")return PetscError(((MPI_Comm)0x44000001),2668,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,76,PETSC_ERROR_INITIAL,"Bad argument to GELS")
;
2669
2670 for (l = 0; l < dimR; l++) {guess[l] += PetscRealPart(invJ[l])(invJ[l]);}
2671 }
2672 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)
;
2673}
2674
2675static PetscErrorCode DMPlexCoordinatesToReference_Tensor(DM dm, PetscInt cell, PetscInt numPoints, const PetscReal realCoords[], PetscReal refCoords[], Vec coords, PetscInt dimC, PetscInt dimR)
2676{
2677 PetscInt coordSize, i, j, k, l, m, maxIts = 7, numV = (1 << dimR);
2678 PetscScalar *coordsScalar = NULL((void*)0);
2679 PetscReal *cellData, *cellCoords, *cellCoeffs, *extJ, *resNeg;
2680 PetscScalar *J, *invJ, *work;
2681 PetscErrorCode ierr;
2682
2683 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2683; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2684 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2684,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2684,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),2684,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2684,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2685 ierr = DMPlexVecGetClosure(dm, NULL((void*)0), coords, cell, &coordSize, &coordsScalar);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2685,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2686 if (coordSize < dimC * numV) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Expecting at least %D coordinates, got %D",dimC * (1 << dimR), coordSize)return PetscError(((MPI_Comm)0x44000001),2686,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Expecting at least %D coordinates, got %D"
,dimC * (1 << dimR),coordSize)
;
2687 ierr = DMGetWorkArray(dm, 2 * coordSize + dimR + dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &cellData);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2687,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2688 ierr = DMGetWorkArray(dm, 3 * dimR * dimC, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2688,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2689 cellCoords = &cellData[0];
2690 cellCoeffs = &cellData[coordSize];
2691 extJ = &cellData[2 * coordSize];
2692 resNeg = &cellData[2 * coordSize + dimR];
2693 invJ = &J[dimR * dimC];
2694 work = &J[2 * dimR * dimC];
2695 if (dimR == 2) {
2696 const PetscInt zToPlex[4] = {0, 1, 3, 2};
2697
2698 for (i = 0; i < 4; i++) {
2699 PetscInt plexI = zToPlex[i];
2700
2701 for (j = 0; j < dimC; j++) {
2702 cellCoords[dimC * i + j] = PetscRealPart(coordsScalar[dimC * plexI + j])(coordsScalar[dimC * plexI + j]);
2703 }
2704 }
2705 } else if (dimR == 3) {
2706 const PetscInt zToPlex[8] = {0, 3, 1, 2, 4, 5, 7, 6};
2707
2708 for (i = 0; i < 8; i++) {
2709 PetscInt plexI = zToPlex[i];
2710
2711 for (j = 0; j < dimC; j++) {
2712 cellCoords[dimC * i + j] = PetscRealPart(coordsScalar[dimC * plexI + j])(coordsScalar[dimC * plexI + j]);
2713 }
2714 }
2715 } else {
2716 for (i = 0; i < coordSize; i++) {cellCoords[i] = PetscRealPart(coordsScalar[i])(coordsScalar[i]);}
2717 }
2718 /* Perform the shuffling transform that converts values at the corners of [-1,1]^d to coefficients */
2719 for (i = 0; i < dimR; i++) {
2720 PetscReal *swap;
2721
2722 for (j = 0; j < (numV / 2); j++) {
2723 for (k = 0; k < dimC; k++) {
2724 cellCoeffs[dimC * j + k] = 0.5 * (cellCoords[dimC * (2 * j + 1) + k] + cellCoords[dimC * 2 * j + k]);
2725 cellCoeffs[dimC * (j + (numV / 2)) + k] = 0.5 * (cellCoords[dimC * (2 * j + 1) + k] - cellCoords[dimC * 2 * j + k]);
2726 }
2727 }
2728
2729 if (i < dimR - 1) {
2730 swap = cellCoeffs;
2731 cellCoeffs = cellCoords;
2732 cellCoords = swap;
2733 }
2734 }
2735 ierr = PetscArrayzero(refCoords,numPoints * dimR)PetscMemzero(refCoords,(numPoints * dimR)*sizeof(*(refCoords)
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2735,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2736 for (j = 0; j < numPoints; j++) {
2737 for (i = 0; i < maxIts; i++) {
2738 PetscReal *guess = &refCoords[dimR * j];
2739
2740 /* compute -residual and Jacobian */
2741 for (k = 0; k < dimC; k++) {resNeg[k] = realCoords[dimC * j + k];}
2742 for (k = 0; k < dimC * dimR; k++) {J[k] = 0.;}
2743 for (k = 0; k < numV; k++) {
2744 PetscReal extCoord = 1.;
2745 for (l = 0; l < dimR; l++) {
2746 PetscReal coord = guess[l];
2747 PetscInt dep = (k & (1 << l)) >> l;
2748
2749 extCoord *= dep * coord + !dep;
2750 extJ[l] = dep;
2751
2752 for (m = 0; m < dimR; m++) {
2753 PetscReal coord = guess[m];
2754 PetscInt dep = ((k & (1 << m)) >> m) && (m != l);
2755 PetscReal mult = dep * coord + !dep;
2756
2757 extJ[l] *= mult;
2758 }
2759 }
2760 for (l = 0; l < dimC; l++) {
2761 PetscReal coeff = cellCoeffs[dimC * k + l];
2762
2763 resNeg[l] -= coeff * extCoord;
2764 for (m = 0; m < dimR; m++) {
2765 J[dimR * l + m] += coeff * extJ[m];
2766 }
2767 }
2768 }
2769#if 0 && defined(PETSC_USE_DEBUG1)
2770 {
2771 PetscReal maxAbs = 0.;
2772
2773 for (l = 0; l < dimC; l++) {
2774 maxAbs = PetscMax(maxAbs,PetscAbsReal(resNeg[l]))(((maxAbs)<(fabs(resNeg[l]))) ? (fabs(resNeg[l])) : (maxAbs
))
;
2775 }
2776 ierr = PetscInfo4(dm,"cell %D, point %D, iter %D: res %g\n",cell,j,i,maxAbs)PetscInfo_Private(__func__,dm,"cell %D, point %D, iter %D: res %g\n"
,cell,j,i,maxAbs)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2776,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2777 }
2778#endif
2779
2780 ierr = DMPlexCoordinatesToReference_NewtonUpdate(dimC,dimR,J,invJ,work,resNeg,guess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2780,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2781 }
2782 }
2783 ierr = DMRestoreWorkArray(dm, 3 * dimR * dimC, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2783,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2784 ierr = DMRestoreWorkArray(dm, 2 * coordSize + dimR + dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &cellData);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2784,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2785 ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), coords, cell, &coordSize, &coordsScalar);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2785,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2786 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)
;
2787}
2788
2789static PetscErrorCode DMPlexReferenceToCoordinates_Tensor(DM dm, PetscInt cell, PetscInt numPoints, const PetscReal refCoords[], PetscReal realCoords[], Vec coords, PetscInt dimC, PetscInt dimR)
2790{
2791 PetscInt coordSize, i, j, k, l, numV = (1 << dimR);
2792 PetscScalar *coordsScalar = NULL((void*)0);
2793 PetscReal *cellData, *cellCoords, *cellCoeffs;
2794 PetscErrorCode ierr;
2795
2796 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2796; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2797 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2797,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2797,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),2797,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2797,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2798 ierr = DMPlexVecGetClosure(dm, NULL((void*)0), coords, cell, &coordSize, &coordsScalar);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2798,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2799 if (coordSize < dimC * numV) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Expecting at least %D coordinates, got %D",dimC * (1 << dimR), coordSize)return PetscError(((MPI_Comm)0x44000001),2799,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,77,PETSC_ERROR_INITIAL,"Expecting at least %D coordinates, got %D"
,dimC * (1 << dimR),coordSize)
;
2800 ierr = DMGetWorkArray(dm, 2 * coordSize, MPIU_REAL((MPI_Datatype)0x4c00080b), &cellData);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2800,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2801 cellCoords = &cellData[0];
2802 cellCoeffs = &cellData[coordSize];
2803 if (dimR == 2) {
2804 const PetscInt zToPlex[4] = {0, 1, 3, 2};
2805
2806 for (i = 0; i < 4; i++) {
2807 PetscInt plexI = zToPlex[i];
2808
2809 for (j = 0; j < dimC; j++) {
2810 cellCoords[dimC * i + j] = PetscRealPart(coordsScalar[dimC * plexI + j])(coordsScalar[dimC * plexI + j]);
2811 }
2812 }
2813 } else if (dimR == 3) {
2814 const PetscInt zToPlex[8] = {0, 3, 1, 2, 4, 5, 7, 6};
2815
2816 for (i = 0; i < 8; i++) {
2817 PetscInt plexI = zToPlex[i];
2818
2819 for (j = 0; j < dimC; j++) {
2820 cellCoords[dimC * i + j] = PetscRealPart(coordsScalar[dimC * plexI + j])(coordsScalar[dimC * plexI + j]);
2821 }
2822 }
2823 } else {
2824 for (i = 0; i < coordSize; i++) {cellCoords[i] = PetscRealPart(coordsScalar[i])(coordsScalar[i]);}
2825 }
2826 /* Perform the shuffling transform that converts values at the corners of [-1,1]^d to coefficients */
2827 for (i = 0; i < dimR; i++) {
2828 PetscReal *swap;
2829
2830 for (j = 0; j < (numV / 2); j++) {
2831 for (k = 0; k < dimC; k++) {
2832 cellCoeffs[dimC * j + k] = 0.5 * (cellCoords[dimC * (2 * j + 1) + k] + cellCoords[dimC * 2 * j + k]);
2833 cellCoeffs[dimC * (j + (numV / 2)) + k] = 0.5 * (cellCoords[dimC * (2 * j + 1) + k] - cellCoords[dimC * 2 * j + k]);
2834 }
2835 }
2836
2837 if (i < dimR - 1) {
2838 swap = cellCoeffs;
2839 cellCoeffs = cellCoords;
2840 cellCoords = swap;
2841 }
2842 }
2843 ierr = PetscArrayzero(realCoords,numPoints * dimC)PetscMemzero(realCoords,(numPoints * dimC)*sizeof(*(realCoords
)))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2843,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2844 for (j = 0; j < numPoints; j++) {
2845 const PetscReal *guess = &refCoords[dimR * j];
2846 PetscReal *mapped = &realCoords[dimC * j];
2847
2848 for (k = 0; k < numV; k++) {
2849 PetscReal extCoord = 1.;
2850 for (l = 0; l < dimR; l++) {
2851 PetscReal coord = guess[l];
2852 PetscInt dep = (k & (1 << l)) >> l;
2853
2854 extCoord *= dep * coord + !dep;
2855 }
2856 for (l = 0; l < dimC; l++) {
2857 PetscReal coeff = cellCoeffs[dimC * k + l];
2858
2859 mapped[l] += coeff * extCoord;
2860 }
2861 }
2862 }
2863 ierr = DMRestoreWorkArray(dm, 2 * coordSize, MPIU_REAL((MPI_Datatype)0x4c00080b), &cellData);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2864 ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), coords, cell, &coordSize, &coordsScalar);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2864,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2865 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)
;
2866}
2867
2868/* TODO: TOBY please fix this for Nc > 1 */
2869static PetscErrorCode DMPlexCoordinatesToReference_FE(DM dm, PetscFE fe, PetscInt cell, PetscInt numPoints, const PetscReal realCoords[], PetscReal refCoords[], Vec coords, PetscInt Nc, PetscInt dimR)
2870{
2871 PetscInt numComp, pdim, i, j, k, l, m, maxIter = 7, coordSize;
2872 PetscScalar *nodes = NULL((void*)0);
2873 PetscReal *invV, *modes;
2874 PetscReal *B, *D, *resNeg;
2875 PetscScalar *J, *invJ, *work;
2876 PetscErrorCode ierr;
2877
2878 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2878; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2879 ierr = PetscFEGetDimension(fe, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2879,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2880 ierr = PetscFEGetNumComponents(fe, &numComp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2880,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2881 if (numComp != Nc) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"coordinate discretization must have as many components (%D) as embedding dimension (!= %D)",numComp,Nc)return PetscError(PetscObjectComm((PetscObject)dm),2881,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"coordinate discretization must have as many components (%D) as embedding dimension (!= %D)"
,numComp,Nc)
;
2882 ierr = DMPlexVecGetClosure(dm, NULL((void*)0), coords, cell, &coordSize, &nodes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2882,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2883 /* convert nodes to values in the stable evaluation basis */
2884 ierr = DMGetWorkArray(dm,pdim,MPIU_REAL((MPI_Datatype)0x4c00080b),&modes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2884,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2885 invV = fe->invV;
2886 for (i = 0; i < pdim; ++i) {
2887 modes[i] = 0.;
2888 for (j = 0; j < pdim; ++j) {
2889 modes[i] += invV[i * pdim + j] * PetscRealPart(nodes[j])(nodes[j]);
2890 }
2891 }
2892 ierr = DMGetWorkArray(dm,pdim * Nc + pdim * Nc * dimR + Nc,MPIU_REAL((MPI_Datatype)0x4c00080b),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2892,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2893 D = &B[pdim*Nc];
2894 resNeg = &D[pdim*Nc * dimR];
2895 ierr = DMGetWorkArray(dm,3 * Nc * dimR,MPIU_SCALAR((MPI_Datatype)0x4c00080b),&J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2895,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2896 invJ = &J[Nc * dimR];
2897 work = &invJ[Nc * dimR];
2898 for (i = 0; i < numPoints * dimR; i++) {refCoords[i] = 0.;}
2899 for (j = 0; j < numPoints; j++) {
2900 for (i = 0; i < maxIter; i++) { /* we could batch this so that we're not making big B and D arrays all the time */
2901 PetscReal *guess = &refCoords[j * dimR];
2902 ierr = PetscSpaceEvaluate(fe->basisSpace, 1, guess, B, D, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2902,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2903 for (k = 0; k < Nc; k++) {resNeg[k] = realCoords[j * Nc + k];}
2904 for (k = 0; k < Nc * dimR; k++) {J[k] = 0.;}
2905 for (k = 0; k < pdim; k++) {
2906 for (l = 0; l < Nc; l++) {
2907 resNeg[l] -= modes[k] * B[k * Nc + l];
2908 for (m = 0; m < dimR; m++) {
2909 J[l * dimR + m] += modes[k] * D[(k * Nc + l) * dimR + m];
2910 }
2911 }
2912 }
2913#if 0 && defined(PETSC_USE_DEBUG1)
2914 {
2915 PetscReal maxAbs = 0.;
2916
2917 for (l = 0; l < Nc; l++) {
2918 maxAbs = PetscMax(maxAbs,PetscAbsReal(resNeg[l]))(((maxAbs)<(fabs(resNeg[l]))) ? (fabs(resNeg[l])) : (maxAbs
))
;
2919 }
2920 ierr = PetscInfo4(dm,"cell %D, point %D, iter %D: res %g\n",cell,j,i,maxAbs)PetscInfo_Private(__func__,dm,"cell %D, point %D, iter %D: res %g\n"
,cell,j,i,maxAbs)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2920,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2921 }
2922#endif
2923 ierr = DMPlexCoordinatesToReference_NewtonUpdate(Nc,dimR,J,invJ,work,resNeg,guess);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2923,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2924 }
2925 }
2926 ierr = DMRestoreWorkArray(dm,3 * Nc * dimR,MPIU_SCALAR((MPI_Datatype)0x4c00080b),&J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2926,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2927 ierr = DMRestoreWorkArray(dm,pdim * Nc + pdim * Nc * dimR + Nc,MPIU_REAL((MPI_Datatype)0x4c00080b),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2927,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2928 ierr = DMRestoreWorkArray(dm,pdim,MPIU_REAL((MPI_Datatype)0x4c00080b),&modes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2928,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2929 ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), coords, cell, &coordSize, &nodes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2929,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2930 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)
;
2931}
2932
2933/* TODO: TOBY please fix this for Nc > 1 */
2934static PetscErrorCode DMPlexReferenceToCoordinates_FE(DM dm, PetscFE fe, PetscInt cell, PetscInt numPoints, const PetscReal refCoords[], PetscReal realCoords[], Vec coords, PetscInt Nc, PetscInt dimR)
2935{
2936 PetscInt numComp, pdim, i, j, k, l, coordSize;
2937 PetscScalar *nodes = NULL((void*)0);
2938 PetscReal *invV, *modes;
2939 PetscReal *B;
2940 PetscErrorCode ierr;
2941
2942 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 2942; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2943 ierr = PetscFEGetDimension(fe, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2943,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2944 ierr = PetscFEGetNumComponents(fe, &numComp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2944,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2945 if (numComp != Nc) SETERRQ2(PetscObjectComm((PetscObject)dm),PETSC_ERR_SUP,"coordinate discretization must have as many components (%D) as embedding dimension (!= %D)",numComp,Nc)return PetscError(PetscObjectComm((PetscObject)dm),2945,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"coordinate discretization must have as many components (%D) as embedding dimension (!= %D)"
,numComp,Nc)
;
2946 ierr = DMPlexVecGetClosure(dm, NULL((void*)0), coords, cell, &coordSize, &nodes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2946,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2947 /* convert nodes to values in the stable evaluation basis */
2948 ierr = DMGetWorkArray(dm,pdim,MPIU_REAL((MPI_Datatype)0x4c00080b),&modes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2948,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2949 invV = fe->invV;
2950 for (i = 0; i < pdim; ++i) {
2951 modes[i] = 0.;
2952 for (j = 0; j < pdim; ++j) {
2953 modes[i] += invV[i * pdim + j] * PetscRealPart(nodes[j])(nodes[j]);
2954 }
2955 }
2956 ierr = DMGetWorkArray(dm,numPoints * pdim * Nc,MPIU_REAL((MPI_Datatype)0x4c00080b),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2956,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2957 ierr = PetscSpaceEvaluate(fe->basisSpace, numPoints, refCoords, B, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2957,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2958 for (i = 0; i < numPoints * Nc; i++) {realCoords[i] = 0.;}
2959 for (j = 0; j < numPoints; j++) {
2960 PetscReal *mapped = &realCoords[j * Nc];
2961
2962 for (k = 0; k < pdim; k++) {
2963 for (l = 0; l < Nc; l++) {
2964 mapped[l] += modes[k] * B[(j * pdim + k) * Nc + l];
2965 }
2966 }
2967 }
2968 ierr = DMRestoreWorkArray(dm,numPoints * pdim * Nc,MPIU_REAL((MPI_Datatype)0x4c00080b),&B);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2968,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2969 ierr = DMRestoreWorkArray(dm,pdim,MPIU_REAL((MPI_Datatype)0x4c00080b),&modes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2969,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2970 ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), coords, cell, &coordSize, &nodes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2970,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2971 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)
;
2972}
2973
2974/*@
2975 DMPlexCoordinatesToReference - Pull coordinates back from the mesh to the reference element using a single element
2976 map. This inversion will be accurate inside the reference element, but may be inaccurate for mappings that do not
2977 extend uniquely outside the reference cell (e.g, most non-affine maps)
2978
2979 Not collective
2980
2981 Input Parameters:
2982+ dm - The mesh, with coordinate maps defined either by a PetscDS for the coordinate DM (see DMGetCoordinateDM()) or
2983 implicitly by the coordinates of the corner vertices of the cell: as an affine map for simplicial elements, or
2984 as a multilinear map for tensor-product elements
2985. cell - the cell whose map is used.
2986. numPoints - the number of points to locate
2987- realCoords - (numPoints x coordinate dimension) array of coordinates (see DMGetCoordinateDim())
2988
2989 Output Parameters:
2990. refCoords - (numPoints x dimension) array of reference coordinates (see DMGetDimension())
2991
2992 Level: intermediate
2993
2994.seealso: DMPlexReferenceToCoordinates()
2995@*/
2996PetscErrorCode DMPlexCoordinatesToReference(DM dm, PetscInt cell, PetscInt numPoints, const PetscReal realCoords[], PetscReal refCoords[])
2997{
2998 PetscInt dimC, dimR, depth, cStart, cEnd, cEndInterior, i;
2999 DM coordDM = NULL((void*)0);
3000 Vec coords;
3001 PetscFE fe = NULL((void*)0);
3002 PetscErrorCode ierr;
3003
3004 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 3004; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3005 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),3005,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),3005,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),3005,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),3005,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
3006 ierr = DMGetDimension(dm,&dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3006,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3007 ierr = DMGetCoordinateDim(dm,&dimC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3007,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3008 if (dimR <= 0 || dimC <= 0 || numPoints <= 0) 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)
;
3009 ierr = DMPlexGetDepth(dm,&depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3009,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3010 ierr = DMGetCoordinatesLocal(dm,&coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3010,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3011 ierr = DMGetCoordinateDM(dm,&coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3011,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3012 if (coordDM) {
3013 PetscInt coordFields;
3014
3015 ierr = DMGetNumFields(coordDM,&coordFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3015,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3016 if (coordFields) {
3017 PetscClassId id;
3018 PetscObject disc;
3019
3020 ierr = DMGetField(coordDM,0,NULL((void*)0),&disc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3020,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3021 ierr = PetscObjectGetClassId(disc,&id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3021,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3022 if (id == PETSCFE_CLASSID) {
3023 fe = (PetscFE) disc;
3024 }
3025 }
3026 }
3027 ierr = DMPlexGetHeightStratum(dm,0,&cStart,&cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3027,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3028 ierr = DMPlexGetHybridBounds(dm,&cEndInterior,NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3028,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3029 cEnd = cEndInterior > 0 ? cEndInterior : cEnd;
3030 if (cell < cStart || cell >= cEnd) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"point %D not in cell range [%D,%D)",cell,cStart,cEnd)return PetscError(((MPI_Comm)0x44000001),3030,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"point %D not in cell range [%D,%D)",
cell,cStart,cEnd)
;
3031 if (!fe) { /* implicit discretization: affine or multilinear */
3032 PetscInt coneSize;
3033 PetscBool isSimplex, isTensor;
3034
3035 ierr = DMPlexGetConeSize(dm,cell,&coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3035,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3036 isSimplex = (coneSize == (dimR + 1)) ? PETSC_TRUE : PETSC_FALSE;
3037 isTensor = (coneSize == ((depth == 1) ? (1 << dimR) : (2 * dimR))) ? PETSC_TRUE : PETSC_FALSE;
3038 if (isSimplex) {
3039 PetscReal detJ, *v0, *J, *invJ;
3040
3041 ierr = DMGetWorkArray(dm,dimC + 2 * dimC * dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &v0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3041,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3042 J = &v0[dimC];
3043 invJ = &J[dimC * dimC];
3044 ierr = DMPlexComputeCellGeometryAffineFEM(dm, cell, v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3044,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3045 for (i = 0; i < numPoints; i++) { /* Apply the inverse affine transformation for each point */
3046 const PetscReal x0[3] = {-1.,-1.,-1.};
3047
3048 CoordinatesRealToRef(dimC, dimR, x0, v0, invJ, &realCoords[dimC * i], &refCoords[dimR * i]);
3049 }
3050 ierr = DMRestoreWorkArray(dm,dimC + 2 * dimC * dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &v0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3050,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3051 } else if (isTensor) {
3052 ierr = DMPlexCoordinatesToReference_Tensor(coordDM, cell, numPoints, realCoords, refCoords, coords, dimC, dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3052,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3053 } else SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unrecognized cone size %D",coneSize)return PetscError(((MPI_Comm)0x44000001),3053,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unrecognized cone size %D",coneSize)
;
3054 } else {
3055 ierr = DMPlexCoordinatesToReference_FE(coordDM, fe, cell, numPoints, realCoords, refCoords, coords, dimC, dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3055,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3056 }
3057 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)
;
3058}
3059
3060/*@
3061 DMPlexReferenceToCoordinates - Map references coordinates to coordinates in the the mesh for a single element map.
3062
3063 Not collective
3064
3065 Input Parameters:
3066+ dm - The mesh, with coordinate maps defined either by a PetscDS for the coordinate DM (see DMGetCoordinateDM()) or
3067 implicitly by the coordinates of the corner vertices of the cell: as an affine map for simplicial elements, or
3068 as a multilinear map for tensor-product elements
3069. cell - the cell whose map is used.
3070. numPoints - the number of points to locate
3071+ refCoords - (numPoints x dimension) array of reference coordinates (see DMGetDimension())
3072
3073 Output Parameters:
3074. realCoords - (numPoints x coordinate dimension) array of coordinates (see DMGetCoordinateDim())
3075
3076 Level: intermediate
3077
3078.seealso: DMPlexCoordinatesToReference()
3079@*/
3080PetscErrorCode DMPlexReferenceToCoordinates(DM dm, PetscInt cell, PetscInt numPoints, const PetscReal refCoords[], PetscReal realCoords[])
3081{
3082 PetscInt dimC, dimR, depth, cStart, cEnd, cEndInterior, i;
3083 DM coordDM = NULL((void*)0);
3084 Vec coords;
3085 PetscFE fe = NULL((void*)0);
3086 PetscErrorCode ierr;
3087
3088 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
; petscstack->line[petscstack->currentsize] = 3088; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3089 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),3089,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),3089,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.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),3089,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),3089,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
3090 ierr = DMGetDimension(dm,&dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3090,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3091 ierr = DMGetCoordinateDim(dm,&dimC);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3091,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3092 if (dimR <= 0 || dimC <= 0 || numPoints <= 0) 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)
;
3093 ierr = DMPlexGetDepth(dm,&depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3093,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3094 ierr = DMGetCoordinatesLocal(dm,&coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3094,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3095 ierr = DMGetCoordinateDM(dm,&coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3095,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3096 if (coordDM) {
3097 PetscInt coordFields;
3098
3099 ierr = DMGetNumFields(coordDM,&coordFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3099,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3100 if (coordFields) {
3101 PetscClassId id;
3102 PetscObject disc;
3103
3104 ierr = DMGetField(coordDM,0,NULL((void*)0),&disc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3104,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3105 ierr = PetscObjectGetClassId(disc,&id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3105,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3106 if (id == PETSCFE_CLASSID) {
3107 fe = (PetscFE) disc;
3108 }
3109 }
3110 }
3111 ierr = DMPlexGetHeightStratum(dm,0,&cStart,&cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3111,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3112 ierr = DMPlexGetHybridBounds(dm,&cEndInterior,NULL((void*)0),NULL((void*)0),NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3112,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3113 cEnd = cEndInterior > 0 ? cEndInterior : cEnd;
3114 if (cell < cStart || cell >= cEnd) SETERRQ3(PETSC_COMM_SELF,PETSC_ERR_ARG_OUTOFRANGE,"point %D not in cell range [%D,%D)",cell,cStart,cEnd)return PetscError(((MPI_Comm)0x44000001),3114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,63,PETSC_ERROR_INITIAL,"point %D not in cell range [%D,%D)",
cell,cStart,cEnd)
;
3115 if (!fe) { /* implicit discretization: affine or multilinear */
3116 PetscInt coneSize;
3117 PetscBool isSimplex, isTensor;
3118
3119 ierr = DMPlexGetConeSize(dm,cell,&coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3119,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3120 isSimplex = (coneSize == (dimR + 1)) ? PETSC_TRUE : PETSC_FALSE;
3121 isTensor = (coneSize == ((depth == 1) ? (1 << dimR) : (2 * dimR))) ? PETSC_TRUE : PETSC_FALSE;
3122 if (isSimplex) {
3123 PetscReal detJ, *v0, *J;
3124
3125 ierr = DMGetWorkArray(dm,dimC + 2 * dimC * dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &v0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3125,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3126 J = &v0[dimC];
3127 ierr = DMPlexComputeCellGeometryAffineFEM(dm, cell, v0, J, NULL((void*)0), &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3127,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3128 for (i = 0; i < numPoints; i++) { /* Apply the affine transformation for each point */
3129 const PetscReal xi0[3] = {-1.,-1.,-1.};
3130
3131 CoordinatesRefToReal(dimC, dimR, xi0, v0, J, &refCoords[dimR * i], &realCoords[dimC * i]);
3132 }
3133 ierr = DMRestoreWorkArray(dm,dimC + 2 * dimC * dimC, MPIU_REAL((MPI_Datatype)0x4c00080b), &v0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3134 } else if (isTensor) {
3135 ierr = DMPlexReferenceToCoordinates_Tensor(coordDM, cell, numPoints, refCoords, realCoords, coords, dimC, dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3135,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3136 } else SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Unrecognized cone size %D",coneSize)return PetscError(((MPI_Comm)0x44000001),3136,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,56,PETSC_ERROR_INITIAL,"Unrecognized cone size %D",coneSize)
;
3137 } else {
3138 ierr = DMPlexReferenceToCoordinates_FE(coordDM, fe, cell, numPoints, refCoords, realCoords, coords, dimC, dimR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3138,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexgeometry.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3139 }
3140 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)
;
3141}

/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h

1#if !defined(_PLEXIMPL_H)
2#define _PLEXIMPL_H
3
4#include <petscmat.h> /*I "petscmat.h" I*/
5#include <petscdmplex.h> /*I "petscdmplex.h" I*/
6#include <petscbt.h>
7#include <petscsf.h>
8#include <petsc/private/dmimpl.h>
9
10PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Interpolate;
11PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Partition;
12PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_PartSelf;
13PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_PartLabelInvert;
14PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_PartLabelCreateSF;
15PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_PartStratSF;
16PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_CreatePointSF;
17PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Distribute;
18PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeCones;
19PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeLabels;
20PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeSF;
21PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeOverlap;
22PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeField;
23PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_DistributeData;
24PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Migrate;
25PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_InterpolateSF;
26PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_GlobalToNaturalBegin;
27PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_GlobalToNaturalEnd;
28PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_NaturalToGlobalBegin;
29PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_NaturalToGlobalEnd;
30PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Stratify;
31PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Symmetrize;
32PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_Preallocate;
33PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_ResidualFEM;
34PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_JacobianFEM;
35PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_InterpolatorFEM;
36PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_InjectorFEM;
37PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_IntegralFEM;
38PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_CreateGmsh;
39PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscLogEvent DMPLEX_RebalanceSharedPoints;
40
41PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscBool PetscPartitionerRegisterAllCalled;
42PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode PetscPartitionerRegisterAll(void);
43
44PETSC_EXTERNextern __attribute__((visibility ("default"))) const char * const CellRefiners[];
45typedef enum {REFINER_NOOP = 0,
46 REFINER_SIMPLEX_1D,
47 REFINER_SIMPLEX_2D,
48 REFINER_HYBRID_SIMPLEX_2D,
49 REFINER_SIMPLEX_TO_HEX_2D,
50 REFINER_HYBRID_SIMPLEX_TO_HEX_2D,
51 REFINER_HEX_2D,
52 REFINER_HYBRID_HEX_2D,
53 REFINER_SIMPLEX_3D,
54 REFINER_HYBRID_SIMPLEX_3D,
55 REFINER_SIMPLEX_TO_HEX_3D,
56 REFINER_HYBRID_SIMPLEX_TO_HEX_3D,
57 REFINER_HEX_3D,
58 REFINER_HYBRID_HEX_3D} CellRefiner;
59
60typedef struct _PetscPartitionerOps *PetscPartitionerOps;
61struct _PetscPartitionerOps {
62 PetscErrorCode (*setfromoptions)(PetscOptionItems*,PetscPartitioner);
63 PetscErrorCode (*setup)(PetscPartitioner);
64 PetscErrorCode (*view)(PetscPartitioner,PetscViewer);
65 PetscErrorCode (*destroy)(PetscPartitioner);
66 PetscErrorCode (*partition)(PetscPartitioner, DM, PetscInt, PetscInt, PetscInt[], PetscInt[], PetscSection, IS *);
67};
68
69struct _p_PetscPartitioner {
70 PETSCHEADER(struct _PetscPartitionerOps)_p_PetscObject hdr; struct _PetscPartitionerOps ops[1];
71 void *data; /* Implementation object */
72 PetscInt height; /* Height of points to partition into non-overlapping subsets */
73 PetscInt edgeCut; /* The number of edge cut by the partition */
74 PetscReal balance; /* The maximum partition size divided by the minimum size */
75 PetscViewer viewerGraph;
76 PetscViewerFormat formatGraph;
77 PetscBool viewGraph;
78 PetscBool noGraph; /* if true, the partitioner does not need the connectivity graph, only the number of local vertices */
79};
80
81typedef struct {
82 PetscInt dummy;
83} PetscPartitioner_Chaco;
84
85typedef struct {
86 PetscInt ptype;
87 PetscReal imbalanceRatio;
88 PetscInt debugFlag;
89 PetscInt randomSeed;
90} PetscPartitioner_ParMetis;
91
92typedef struct {
93 PetscInt strategy;
94 PetscReal imbalance;
95} PetscPartitioner_PTScotch;
96
97static const char *const
98PTScotchStrategyList[] = {
99 "DEFAULT",
100 "QUALITY",
101 "SPEED",
102 "BALANCE",
103 "SAFETY",
104 "SCALABILITY",
105 "RECURSIVE",
106 "REMAP"
107};
108
109typedef struct {
110 PetscSection section; /* Sizes for each partition */
111 IS partition; /* Points in each partition */
112 PetscBool random; /* Flag for a random partition */
113} PetscPartitioner_Shell;
114
115typedef struct {
116 PetscInt dummy;
117} PetscPartitioner_Simple;
118
119typedef struct {
120 PetscInt dummy;
121} PetscPartitioner_Gather;
122
123/* Utility struct to store the contents of a Fluent file in memory */
124typedef struct {
125 int index; /* Type of section */
126 unsigned int zoneID;
127 unsigned int first;
128 unsigned int last;
129 int type;
130 int nd; /* Either ND or element-type */
131 void *data;
132} FluentSection;
133
134struct _PetscGridHash {
135 PetscInt dim;
136 PetscReal lower[3]; /* The lower-left corner */
137 PetscReal upper[3]; /* The upper-right corner */
138 PetscReal extent[3]; /* The box size */
139 PetscReal h[3]; /* The subbox size */
140 PetscInt n[3]; /* The number of subboxes */
141 PetscSection cellSection; /* Offsets for cells in each subbox*/
142 IS cells; /* List of cells in each subbox */
143 DMLabel cellsSparse; /* Sparse storage for cell map */
144};
145
146typedef struct {
147 PetscInt refct;
148
149 /* Sieve */
150 PetscSection coneSection; /* Layout of cones (inedges for DAG) */
151 PetscInt maxConeSize; /* Cached for fast lookup */
152 PetscInt *cones; /* Cone for each point */
153 PetscInt *coneOrientations; /* Orientation of each cone point, means cone traveral should start on point 'o', and if negative start on -(o+1) and go in reverse */
154 PetscSection supportSection; /* Layout of cones (inedges for DAG) */
155 PetscInt maxSupportSize; /* Cached for fast lookup */
156 PetscInt *supports; /* Cone for each point */
157 PetscBool refinementUniform; /* Flag for uniform cell refinement */
158 PetscReal refinementLimit; /* Maximum volume for refined cell */
159 PetscErrorCode (*refinementFunc)(const PetscReal [], PetscReal *); /* Function giving the maximum volume for refined cell */
160 PetscInt hybridPointMax[8]; /* Allow segregation of some points, each dimension has a divider (used in VTK output and refinement) */
161
162 PetscInt *facesTmp; /* Work space for faces operation */
163
164 /* Hierarchy */
165 PetscBool regularRefinement; /* This flag signals that we are a regular refinement of coarseMesh */
166
167 /* Generation */
168 char *tetgenOpts;
169 char *triangleOpts;
170 PetscPartitioner partitioner;
171 PetscBool partitionBalance; /* Evenly divide partition overlap when distributing */
172 PetscBool remeshBd;
173
174 /* Submesh */
175 DMLabel subpointMap; /* Label each original mesh point in the submesh with its depth, subpoint are the implicit numbering */
176
177 /* Labels and numbering */
178 PetscObjectState depthState; /* State of depth label, so that we can determine if a user changes it */
179 IS globalVertexNumbers;
180 IS globalCellNumbers;
181
182 /* Constraints */
183 PetscSection anchorSection; /* maps constrained points to anchor points */
184 IS anchorIS; /* anchors indexed by the above section */
185 PetscErrorCode (*createanchors)(DM); /* automatically compute anchors (probably from tree constraints) */
186 PetscErrorCode (*computeanchormatrix)(DM,PetscSection,PetscSection,Mat);
187
188 /* Tree: automatically construct constraints for hierarchically non-conforming meshes */
189 PetscSection parentSection; /* dof == 1 if point has parent */
190 PetscInt *parents; /* point to parent */
191 PetscInt *childIDs; /* point to child ID */
192 PetscSection childSection; /* inverse of parent section */
193 PetscInt *children; /* point to children */
194 DM referenceTree; /* reference tree to which child ID's refer */
195 PetscErrorCode (*getchildsymmetry)(DM,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt,PetscInt*,PetscInt*);
196
197 /* MATIS support */
198 PetscSection subdomainSection;
199
200 /* Adjacency */
201 PetscBool useAnchors; /* Replace constrained points with their anchors in adjacency lists */
202 PetscErrorCode (*useradjacency)(DM,PetscInt,PetscInt*,PetscInt[],void*); /* User callback for adjacency */
203 void *useradjacencyctx; /* User context for callback */
204
205 /* Projection */
206 PetscInt maxProjectionHeight; /* maximum height of cells used in DMPlexProject functions */
207
208 /* Output */
209 PetscInt vtkCellHeight; /* The height of cells for output, default is 0 */
210 PetscReal scale[NUM_PETSC_UNITS]; /* The scale for each SI unit */
211
212 /* Geometry */
213 PetscReal minradius; /* Minimum distance from cell centroid to face */
214 PetscBool useHashLocation; /* Use grid hashing for point location */
215 PetscGridHash lbox; /* Local box for searching */
216
217 /* Debugging */
218 PetscBool printSetValues;
219 PetscInt printFEM;
220 PetscInt printL2;
221 PetscReal printTol;
222} DM_Plex;
223
224PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexVTKWriteAll_VTU(DM,PetscViewer);
225PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex_Local(Vec,PetscViewer);
226PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex_Native(Vec,PetscViewer);
227PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex(Vec,PetscViewer);
228PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoad_Plex_Local(Vec,PetscViewer);
229PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoad_Plex_Native(Vec,PetscViewer);
230PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoad_Plex(Vec,PetscViewer);
231PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetFieldType_Internal(DM, PetscSection, PetscInt, PetscInt *, PetscInt *, PetscViewerVTKFieldType *);
232PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexView_GLVis(DM,PetscViewer);
233PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMSetUpGLVisViewer_Plex(PetscObject,PetscViewer);
234#if defined(PETSC_HAVE_HDF5)
235PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex_Local_HDF5(Vec, PetscViewer);
236PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex_HDF5(Vec, PetscViewer);
237PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoad_Plex_HDF5(Vec, PetscViewer);
238PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecView_Plex_HDF5_Native(Vec, PetscViewer);
239PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoad_Plex_HDF5_Native(Vec, PetscViewer);
240PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexView_HDF5(DM, PetscViewer);
241PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexLoad_HDF5(DM, PetscViewer);
242#endif
243
244PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexClosurePoints_Private(DM,PetscInt,const PetscInt[],IS*);
245PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMSetFromOptions_NonRefinement_Plex(PetscOptionItems *, DM);
246PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMCoarsen_Plex(DM, MPI_Comm, DM *);
247PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMCoarsenHierarchy_Plex(DM, PetscInt, DM []);
248PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMRefine_Plex(DM, MPI_Comm, DM *);
249PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMRefineHierarchy_Plex(DM, PetscInt, DM []);
250PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMAdaptLabel_Plex(DM, DMLabel, DM *);
251PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMAdaptMetric_Plex(DM, Vec, DMLabel, DM *);
252PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexInsertBoundaryValues_Plex(DM, PetscBool, Vec, PetscReal, Vec, Vec, Vec);
253PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMProjectFunctionLocal_Plex(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,InsertMode,Vec);
254PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMProjectFunctionLabelLocal_Plex(DM,PetscReal,DMLabel,PetscInt,const PetscInt[],PetscInt,const PetscInt[],PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,InsertMode,Vec);
255PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMProjectFieldLocal_Plex(DM,PetscReal,Vec,void (**)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),InsertMode,Vec);
256PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMProjectFieldLabelLocal_Plex(DM,PetscReal,DMLabel,PetscInt,const PetscInt[],PetscInt,const PetscInt[],Vec,void (**)(PetscInt,PetscInt,PetscInt,const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],const PetscInt[],const PetscInt[],const PetscScalar[],const PetscScalar[],const PetscScalar[],PetscReal,const PetscReal[],PetscInt,const PetscScalar[],PetscScalar[]),InsertMode,Vec);
257PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMComputeL2Diff_Plex(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,Vec,PetscReal *);
258PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMComputeL2GradientDiff_Plex(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[], const PetscReal[],PetscInt,PetscScalar *,void *),void **,Vec,const PetscReal [],PetscReal *);
259PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMComputeL2FieldDiff_Plex(DM,PetscReal,PetscErrorCode(**)(PetscInt,PetscReal,const PetscReal[],PetscInt,PetscScalar *,void *),void **,Vec,PetscReal *);
260PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMLocatePoints_Plex(DM, Vec, DMPointLocationType, PetscSF);
261
262PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBuildFromCellList_Internal(DM, PetscInt, PetscInt, PetscInt, PetscInt, const int[], PetscBool);
263PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBuildFromCellList_Parallel_Internal(DM, PetscInt, PetscInt, PetscInt, PetscInt, const int[], PetscBool, PetscSF *);
264PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBuildCoordinates_Internal(DM, PetscInt, PetscInt, PetscInt, const double[]);
265PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBuildCoordinates_Parallel_Internal(DM, PetscInt, PetscInt, PetscInt, PetscSF, const PetscReal[]);
266PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexLoadLabels_HDF5_Internal(DM, PetscViewer);
267PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexView_HDF5_Internal(DM, PetscViewer);
268PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexLoad_HDF5_Internal(DM, PetscViewer);
269PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexLoad_HDF5_Xdmf_Internal(DM, PetscViewer);
270PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode VecView_Plex_HDF5_Internal(Vec, PetscViewer);
271PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode VecView_Plex_HDF5_Native_Internal(Vec, PetscViewer);
272PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode VecView_Plex_Local_HDF5_Internal(Vec, PetscViewer);
273PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode VecLoad_Plex_HDF5_Internal(Vec, PetscViewer);
274PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode VecLoad_Plex_HDF5_Native_Internal(Vec, PetscViewer);
275/* TODO Make these INTERN */
276PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexView_ExodusII_Internal(DM, int, PetscInt);
277PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecViewPlex_ExodusII_Nodal_Internal(Vec, int, int);
278PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoadPlex_ExodusII_Nodal_Internal(Vec, int, int);
279PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecViewPlex_ExodusII_Zonal_Internal(Vec, int, int);
280PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode VecLoadPlex_ExodusII_Zonal_Internal(Vec, int, int);
281PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexVTKGetCellType_Internal(DM,PetscInt,PetscInt,PetscInt*);
282PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetAdjacency_Internal(DM,PetscInt,PetscBool,PetscBool,PetscBool,PetscInt*,PetscInt*[]);
283PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetFaces_Internal(DM,PetscInt,PetscInt,PetscInt*,PetscInt*,const PetscInt*[]);
284PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetRawFaces_Internal(DM,PetscInt,PetscInt,const PetscInt[], PetscInt*,PetscInt*,const PetscInt*[]);
285PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexRestoreFaces_Internal(DM,PetscInt,PetscInt,PetscInt*,PetscInt*,const PetscInt*[]);
286PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexRefineUniform_Internal(DM,CellRefiner,DM*);
287PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetCellRefiner_Internal(DM,CellRefiner*);
288PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode CellRefinerGetAffineTransforms_Internal(CellRefiner, PetscInt *, PetscReal *[], PetscReal *[], PetscReal *[]);
289PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode CellRefinerGetAffineFaceTransforms_Internal(CellRefiner, PetscInt *, PetscReal *[], PetscReal *[], PetscReal *[], PetscReal *[]);
290PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode CellRefinerRestoreAffineTransforms_Internal(CellRefiner, PetscInt *, PetscReal *[], PetscReal *[], PetscReal *[]);
291PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode CellRefinerInCellTest_Internal(CellRefiner, const PetscReal[], PetscBool *);
292PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexInvertCell_Internal(PetscInt, PetscInt, PetscInt[]);
293PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexVecSetFieldClosure_Internal(DM, PetscSection, Vec, PetscBool[], PetscInt, PetscInt, const PetscInt[], const PetscScalar[], InsertMode);
294PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexProjectConstraints_Internal(DM, Vec, Vec);
295PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexCreateReferenceTree_SetTree(DM, PetscSection, PetscInt[], PetscInt[]);
296PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexCreateReferenceTree_Union(DM,DM,const char *,DM*);
297PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeInterpolatorTree(DM,DM,PetscSF,PetscInt *,Mat);
298PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeInjectorTree(DM,DM,PetscSF,PetscInt *,Mat);
299PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexAnchorsModifyMat(DM,PetscSection,PetscInt,PetscInt,const PetscInt[],const PetscInt ***,const PetscScalar[],PetscInt*,PetscInt*,PetscInt*[],PetscScalar*[],PetscInt[],PetscBool);
300PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode indicesPoint_private(PetscSection,PetscInt,PetscInt,PetscInt *,PetscBool,PetscInt,PetscInt []);
301PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode indicesPointFields_private(PetscSection,PetscInt,PetscInt,PetscInt [],PetscBool,PetscInt,PetscInt []);
302PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexLocatePoint_Internal(DM,PetscInt,const PetscScalar [],PetscInt,PetscInt *);
303PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexOrientCell_Internal(DM,PetscInt,PetscInt,PetscBool);
304PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexOrientInterface(DM);
305
306PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexCreateCellNumbering_Internal(DM, PetscBool, IS *);
307PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexCreateVertexNumbering_Internal(DM, PetscBool, IS *);
308PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexCreateNumbering_Internal(DM, PetscInt, PetscInt, PetscInt, PetscInt *, PetscSF, IS *);
309PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexRefine_Internal(DM, DMLabel, DM *);
310PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexCoarsen_Internal(DM, DMLabel, DM *);
311PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMCreateMatrix_Plex(DM, Mat*);
312
313/* invert dihedral symmetry: return a^-1,
314 * using the representation described in
315 * DMPlexGetConeOrientation() */
316PETSC_STATIC_INLINEstatic inline PetscInt DihedralInvert(PetscInt N, PetscInt a)
317{
318 return (a <= 0) ? a : (N - a);
319}
320
321/* invert dihedral symmetry: return b * a,
322 * using the representation described in
323 * DMPlexGetConeOrientation() */
324PETSC_STATIC_INLINEstatic inline PetscInt DihedralCompose(PetscInt N, PetscInt a, PetscInt b)
325{
326 if (!N) return 0;
327 return (a >= 0) ?
328 ((b >= 0) ? ((a + b) % N) : -(((a - b - 1) % N) + 1)) :
329 ((b >= 0) ? -(((N - b - a - 1) % N) + 1) : ((N + b - a) % N));
330}
331
332/* swap dihedral symmetries: return b * a^-1,
333 * using the representation described in
334 * DMPlexGetConeOrientation() */
335PETSC_STATIC_INLINEstatic inline PetscInt DihedralSwap(PetscInt N, PetscInt a, PetscInt b)
336{
337 return DihedralCompose(N,DihedralInvert(N,a),b);
338}
339
340PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeResidual_Internal(DM, IS , PetscReal, Vec, Vec, PetscReal, Vec, void *);
341PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeJacobian_Internal(DM, IS, PetscReal, PetscReal, Vec, Vec, Mat, Mat, void *);
342PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexReconstructGradients_Internal(DM, PetscFV, PetscInt, PetscInt, Vec, Vec, Vec, Vec);
343
344/* Matvec with A in row-major storage, x and y can be aliased */
345PETSC_STATIC_INLINEstatic inline void DMPlex_Mult2D_Internal(const PetscScalar A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
346{
347 PetscScalar z[2];
348 z[0] = x[0]; z[1] = x[ldx];
349 y[0] = A[0]*z[0] + A[1]*z[1];
350 y[ldx] = A[2]*z[0] + A[3]*z[1];
351 (void)PetscLogFlops(6.0);
352}
353PETSC_STATIC_INLINEstatic inline void DMPlex_Mult3D_Internal(const PetscScalar A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
354{
355 PetscScalar z[3];
356 z[0] = x[0]; z[1] = x[ldx]; z[2] = x[ldx*2];
357 y[0] = A[0]*z[0] + A[1]*z[1] + A[2]*z[2];
358 y[ldx] = A[3]*z[0] + A[4]*z[1] + A[5]*z[2];
359 y[ldx*2] = A[6]*z[0] + A[7]*z[1] + A[8]*z[2];
360 (void)PetscLogFlops(15.0);
361}
362PETSC_STATIC_INLINEstatic inline void DMPlex_MultTranspose2D_Internal(const PetscScalar A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
363{
364 PetscScalar z[2];
365 z[0] = x[0]; z[1] = x[ldx];
366 y[0] = A[0]*z[0] + A[2]*z[1];
367 y[ldx] = A[1]*z[0] + A[3]*z[1];
368 (void)PetscLogFlops(6.0);
369}
370PETSC_STATIC_INLINEstatic inline void DMPlex_MultTranspose3D_Internal(const PetscScalar A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
371{
372 PetscScalar z[3];
373 z[0] = x[0]; z[1] = x[ldx]; z[2] = x[ldx*2];
374 y[0] = A[0]*z[0] + A[3]*z[1] + A[6]*z[2];
375 y[ldx] = A[1]*z[0] + A[4]*z[1] + A[7]*z[2];
376 y[ldx*2] = A[2]*z[0] + A[5]*z[1] + A[8]*z[2];
377 (void)PetscLogFlops(15.0);
378}
379PETSC_STATIC_INLINEstatic inline void DMPlex_Mult2DReal_Internal(const PetscReal A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
380{
381 PetscScalar z[2];
382 z[0] = x[0]; z[1] = x[ldx];
383 y[0] = A[0]*z[0] + A[1]*z[1];
384 y[ldx] = A[2]*z[0] + A[3]*z[1];
385 (void)PetscLogFlops(6.0);
386}
387PETSC_STATIC_INLINEstatic inline void DMPlex_Mult3DReal_Internal(const PetscReal A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
388{
389 PetscScalar z[3];
390 z[0] = x[0]; z[1] = x[ldx]; z[2] = x[ldx*2];
391 y[0] = A[0]*z[0] + A[1]*z[1] + A[2]*z[2];
392 y[ldx] = A[3]*z[0] + A[4]*z[1] + A[5]*z[2];
393 y[ldx*2] = A[6]*z[0] + A[7]*z[1] + A[8]*z[2];
394 (void)PetscLogFlops(15.0);
395}
396PETSC_STATIC_INLINEstatic inline void DMPlex_MultTranspose2DReal_Internal(const PetscReal A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
397{
398 PetscScalar z[2];
399 z[0] = x[0]; z[1] = x[ldx];
400 y[0] = A[0]*z[0] + A[2]*z[1];
401 y[ldx] = A[1]*z[0] + A[3]*z[1];
402 (void)PetscLogFlops(6.0);
403}
404PETSC_STATIC_INLINEstatic inline void DMPlex_MultTranspose3DReal_Internal(const PetscReal A[], PetscInt ldx, const PetscScalar x[], PetscScalar y[])
405{
406 PetscScalar z[3];
407 z[0] = x[0]; z[1] = x[ldx]; z[2] = x[ldx*2];
408 y[0] = A[0]*z[0] + A[3]*z[1] + A[6]*z[2];
409 y[ldx] = A[1]*z[0] + A[4]*z[1] + A[7]*z[2];
410 y[ldx*2] = A[2]*z[0] + A[5]*z[1] + A[8]*z[2];
411 (void)PetscLogFlops(15.0);
412}
413
414PETSC_STATIC_INLINEstatic inline void DMPlex_MatMult2D_Internal(const PetscScalar A[], PetscInt n, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
415{
416 PetscInt j;
417 for (j = 0; j < n; ++j) {
418 PetscScalar z[2];
419 z[0] = B[0+j]; z[1] = B[1*ldb+j];
420 DMPlex_Mult2D_Internal(A, 1, z, z);
421 C[0+j] = z[0]; C[1*ldb+j] = z[1];
422 }
423 (void)PetscLogFlops(8.0*n);
424}
425PETSC_STATIC_INLINEstatic inline void DMPlex_MatMult3D_Internal(const PetscScalar A[], PetscInt n, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
426{
427 PetscInt j;
428 for (j = 0; j < n; ++j) {
429 PetscScalar z[3];
430 z[0] = B[0+j]; z[1] = B[1*ldb+j]; z[2] = B[2*ldb+j];
431 DMPlex_Mult3D_Internal(A, 1, z, z);
432 C[0+j] = z[0]; C[1*ldb+j] = z[1]; C[2*ldb+j] = z[2];
433 }
434 (void)PetscLogFlops(8.0*n);
435}
436PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultTranspose2D_Internal(const PetscScalar A[], PetscInt n, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
437{
438 PetscInt j;
439 for (j = 0; j < n; ++j) {
440 PetscScalar z[2];
441 z[0] = B[0+j]; z[1] = B[1*ldb+j];
442 DMPlex_MultTranspose2D_Internal(A, 1, z, z);
443 C[0+j] = z[0]; C[1*ldb+j] = z[1];
444 }
445 (void)PetscLogFlops(8.0*n);
446}
447PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultTranspose3D_Internal(const PetscScalar A[], PetscInt n, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
448{
449 PetscInt j;
450 for (j = 0; j < n; ++j) {
451 PetscScalar z[3];
452 z[0] = B[0+j]; z[1] = B[1*ldb+j]; z[2] = B[2*ldb+j];
453 DMPlex_MultTranspose3D_Internal(A, 1, z, z);
454 C[0+j] = z[0]; C[1*ldb+j] = z[1]; C[2*ldb+j] = z[2];
455 }
456 (void)PetscLogFlops(8.0*n);
457}
458
459PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultLeft2D_Internal(const PetscScalar A[], PetscInt m, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
460{
461 PetscInt j;
462 for (j = 0; j < m; ++j) {
463 DMPlex_MultTranspose2D_Internal(A, 1, &B[j*ldb], &C[j*ldb]);
464 }
465 (void)PetscLogFlops(8.0*m);
466}
467PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultLeft3D_Internal(const PetscScalar A[], PetscInt m, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
468{
469 PetscInt j;
470 for (j = 0; j < m; ++j) {
471 DMPlex_MultTranspose3D_Internal(A, 1, &B[j*ldb], &C[j*ldb]);
472 }
473 (void)PetscLogFlops(8.0*m);
474}
475PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultTransposeLeft2D_Internal(const PetscScalar A[], PetscInt m, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
476{
477 PetscInt j;
478 for (j = 0; j < m; ++j) {
479 DMPlex_Mult2D_Internal(A, 1, &B[j*ldb], &C[j*ldb]);
480 }
481 (void)PetscLogFlops(8.0*m);
482}
483PETSC_STATIC_INLINEstatic inline void DMPlex_MatMultTransposeLeft3D_Internal(const PetscScalar A[], PetscInt m, PetscInt ldb, const PetscScalar B[], PetscScalar C[])
484{
485 PetscInt j;
486 for (j = 0; j < m; ++j) {
487 DMPlex_Mult3D_Internal(A, 1, &B[j*ldb], &C[j*ldb]);
488 }
489 (void)PetscLogFlops(8.0*m);
490}
491
492PETSC_STATIC_INLINEstatic inline void DMPlex_Transpose2D_Internal(PetscScalar A[])
493{
494 PetscScalar tmp;
495 tmp = A[1]; A[1] = A[2]; A[2] = tmp;
496}
497PETSC_STATIC_INLINEstatic inline void DMPlex_Transpose3D_Internal(PetscScalar A[])
498{
499 PetscScalar tmp;
500 tmp = A[1]; A[1] = A[3]; A[3] = tmp;
501 tmp = A[2]; A[2] = A[6]; A[6] = tmp;
502 tmp = A[5]; A[5] = A[7]; A[7] = tmp;
503}
504
505PETSC_STATIC_INLINEstatic inline void DMPlex_Invert2D_Internal(PetscReal invJ[], PetscReal J[], PetscReal detJ)
506{
507 const PetscReal invDet = 1.0/detJ;
508
509 invJ[0] = invDet*J[3];
510 invJ[1] = -invDet*J[1];
511 invJ[2] = -invDet*J[2];
512 invJ[3] = invDet*J[0];
513 (void)PetscLogFlops(5.0);
514}
515
516PETSC_STATIC_INLINEstatic inline void DMPlex_Invert3D_Internal(PetscReal invJ[], PetscReal J[], PetscReal detJ)
517{
518 const PetscReal invDet = 1.0/detJ;
519
520 invJ[0*3+0] = invDet*(J[1*3+1]*J[2*3+2] - J[1*3+2]*J[2*3+1]);
521 invJ[0*3+1] = invDet*(J[0*3+2]*J[2*3+1] - J[0*3+1]*J[2*3+2]);
522 invJ[0*3+2] = invDet*(J[0*3+1]*J[1*3+2] - J[0*3+2]*J[1*3+1]);
523 invJ[1*3+0] = invDet*(J[1*3+2]*J[2*3+0] - J[1*3+0]*J[2*3+2]);
524 invJ[1*3+1] = invDet*(J[0*3+0]*J[2*3+2] - J[0*3+2]*J[2*3+0]);
525 invJ[1*3+2] = invDet*(J[0*3+2]*J[1*3+0] - J[0*3+0]*J[1*3+2]);
526 invJ[2*3+0] = invDet*(J[1*3+0]*J[2*3+1] - J[1*3+1]*J[2*3+0]);
527 invJ[2*3+1] = invDet*(J[0*3+1]*J[2*3+0] - J[0*3+0]*J[2*3+1]);
528 invJ[2*3+2] = invDet*(J[0*3+0]*J[1*3+1] - J[0*3+1]*J[1*3+0]);
529 (void)PetscLogFlops(37.0);
530}
531
532PETSC_STATIC_INLINEstatic inline void DMPlex_Det2D_Internal(PetscReal *detJ, const PetscReal J[])
533{
534 *detJ = J[0]*J[3] - J[1]*J[2];
535 (void)PetscLogFlops(3.0);
536}
537
538PETSC_STATIC_INLINEstatic inline void DMPlex_Det3D_Internal(PetscReal *detJ, const PetscReal J[])
539{
540 *detJ = (J[0*3+0]*(J[1*3+1]*J[2*3+2] - J[1*3+2]*J[2*3+1]) +
18
The right operand of '*' is a garbage value
541 J[0*3+1]*(J[1*3+2]*J[2*3+0] - J[1*3+0]*J[2*3+2]) +
542 J[0*3+2]*(J[1*3+0]*J[2*3+1] - J[1*3+1]*J[2*3+0]));
543 (void)PetscLogFlops(12.0);
544}
545
546PETSC_STATIC_INLINEstatic inline void DMPlex_Det2D_Scalar_Internal(PetscReal *detJ, const PetscScalar J[])
547{
548 *detJ = PetscRealPart(J[0])(J[0])*PetscRealPart(J[3])(J[3]) - PetscRealPart(J[1])(J[1])*PetscRealPart(J[2])(J[2]);
549 (void)PetscLogFlops(3.0);
550}
551
552PETSC_STATIC_INLINEstatic inline void DMPlex_Det3D_Scalar_Internal(PetscReal *detJ, const PetscScalar J[])
553{
554 *detJ = (PetscRealPart(J[0*3+0])(J[0*3+0])*(PetscRealPart(J[1*3+1])(J[1*3+1])*PetscRealPart(J[2*3+2])(J[2*3+2]) - PetscRealPart(J[1*3+2])(J[1*3+2])*PetscRealPart(J[2*3+1])(J[2*3+1])) +
555 PetscRealPart(J[0*3+1])(J[0*3+1])*(PetscRealPart(J[1*3+2])(J[1*3+2])*PetscRealPart(J[2*3+0])(J[2*3+0]) - PetscRealPart(J[1*3+0])(J[1*3+0])*PetscRealPart(J[2*3+2])(J[2*3+2])) +
556 PetscRealPart(J[0*3+2])(J[0*3+2])*(PetscRealPart(J[1*3+0])(J[1*3+0])*PetscRealPart(J[2*3+1])(J[2*3+1]) - PetscRealPart(J[1*3+1])(J[1*3+1])*PetscRealPart(J[2*3+0])(J[2*3+0])));
557 (void)PetscLogFlops(12.0);
558}
559
560PETSC_STATIC_INLINEstatic inline void DMPlex_WaxpyD_Internal(PetscInt dim, PetscReal a, const PetscReal *x, const PetscReal *y, PetscReal *w) {PetscInt d; for (d = 0; d < dim; ++d) w[d] = a*x[d] + y[d];}
561
562PETSC_STATIC_INLINEstatic inline PetscReal DMPlex_DotD_Internal(PetscInt dim, const PetscScalar *x, const PetscReal *y) {PetscReal sum = 0.0; PetscInt d; for (d = 0; d < dim; ++d) sum += PetscRealPart(x[d])(x[d])*y[d]; return sum;}
563
564PETSC_STATIC_INLINEstatic inline PetscReal DMPlex_DotRealD_Internal(PetscInt dim, const PetscReal *x, const PetscReal *y) {PetscReal sum = 0.0; PetscInt d; for (d = 0; d < dim; ++d) sum += x[d]*y[d]; return sum;}
565
566PETSC_STATIC_INLINEstatic inline PetscReal DMPlex_NormD_Internal(PetscInt dim, const PetscReal *x) {PetscReal sum = 0.0; PetscInt d; for (d = 0; d < dim; ++d) sum += x[d]*x[d]; return PetscSqrtReal(sum)sqrt(sum);}
567
568/* Compare cones of the master and slave face (with the same cone points modulo order), and return relative orientation of the slave. */
569PETSC_STATIC_INLINEstatic inline PetscErrorCode DMPlexFixFaceOrientations_Orient_Private(PetscInt coneSize, PetscInt masterConeSize, const PetscInt masterCone[], const PetscInt slaveCone[], PetscInt *start, PetscBool *reverse)
570{
571 PetscInt i;
572
573 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
; petscstack->line[petscstack->currentsize] = 573; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
574 *start = 0;
575 for (i=0; i<coneSize; i++) {
576 if (slaveCone[i] == masterCone[0]) {
577 *start = i;
578 break;
579 }
580 }
581 if (PetscUnlikely(i==coneSize)__builtin_expect(!!(i==coneSize),0)) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "starting point of master cone not found in slave cone")return PetscError(((MPI_Comm)0x44000001),581,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
,75,PETSC_ERROR_INITIAL,"starting point of master cone not found in slave cone"
)
;
582 *reverse = PETSC_FALSE;
583 for (i=0; i<masterConeSize; i++) {if (slaveCone[((*start)+i)%coneSize] != masterCone[i]) break;}
584 if (i == masterConeSize) 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)
;
585 *reverse = PETSC_TRUE;
586 for (i=0; i<masterConeSize; i++) {if (slaveCone[(coneSize+(*start)-i)%coneSize] != masterCone[i]) break;}
587 if (i < masterConeSize) SETERRQ(PETSC_COMM_SELF, PETSC_ERR_ARG_INCOMP, "master and slave cone have non-conforming order of points")return PetscError(((MPI_Comm)0x44000001),587,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
,75,PETSC_ERROR_INITIAL,"master and slave cone have non-conforming order of points"
)
;
588 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)
;
589}
590
591PETSC_STATIC_INLINEstatic inline PetscErrorCode DMPlexFixFaceOrientations_Translate_Private(PetscInt ornt, PetscInt *start, PetscBool *reverse)
592{
593 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
; petscstack->line[petscstack->currentsize] = 593; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
594 *reverse = (ornt < 0) ? PETSC_TRUE : PETSC_FALSE;
595 *start = *reverse ? -(ornt+1) : ornt;
596 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)
;
597}
598
599PETSC_STATIC_INLINEstatic inline PetscErrorCode DMPlexFixFaceOrientations_Combine_Private(PetscInt coneSize, PetscInt origStart, PetscBool origReverse, PetscInt rotateStart, PetscBool rotateReverse, PetscInt *newStart, PetscBool *newReverse)
600{
601 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
; petscstack->line[petscstack->currentsize] = 601; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
602 *newReverse = (origReverse == rotateReverse) ? PETSC_FALSE : PETSC_TRUE;
603 *newStart = rotateReverse ? (coneSize + rotateStart - origStart) : (coneSize + origStart - rotateStart);
604 *newStart %= coneSize;
605 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)
;
606}
607
608PETSC_STATIC_INLINEstatic inline PetscErrorCode DMPlexFixFaceOrientations_TranslateBack_Private(PetscInt coneSize, PetscInt start, PetscBool reverse, PetscInt *ornt)
609{
610 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
; petscstack->line[petscstack->currentsize] = 610; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
611 if (coneSize < 3) {
612 /* edges just get flipped if start == 1 regardless direction */
613 *ornt = start ? -2 : 0;
614 } else {
615 *ornt = reverse ? -(start+1) : start;
616 }
617 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)
;
618}
619
620PETSC_STATIC_INLINEstatic inline PetscErrorCode DMPlexFixFaceOrientations_Permute_Private(PetscInt n, const PetscInt arr[], PetscInt start, PetscBool reverse, PetscInt newarr[])
621{
622 PetscInt i;
623
624 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/dmpleximpl.h"
; petscstack->line[petscstack->currentsize] = 624; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
625 if (reverse) {for (i=0; i<n; i++) newarr[i] = arr[(n+start-i)%n];}
626 else {for (i=0; i<n; i++) newarr[i] = arr[(start+i)%n];}
627 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)
;
628}
629
630PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetPointDualSpaceFEM(DM,PetscInt,PetscInt,PetscDualSpace *);
631PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetIndicesPoint_Internal(PetscSection,PetscInt,PetscInt,PetscInt *,PetscBool,const PetscInt[],const PetscInt[],PetscInt[]);
632PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetIndicesPointFields_Internal(PetscSection,PetscInt,PetscInt,PetscInt[],PetscBool,const PetscInt***,PetscInt,const PetscInt[],PetscInt[]);
633PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexGetCompressedClosure(DM, PetscSection, PetscInt, PetscInt *, PetscInt **, PetscSection *, IS *, const PetscInt **);
634PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexRestoreCompressedClosure(DM, PetscSection, PetscInt, PetscInt *, PetscInt **, PetscSection *, IS *, const PetscInt **);
635
636PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMSNESGetFEGeom(DMField, IS, PetscQuadrature, PetscBool, PetscFEGeom **);
637PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMSNESRestoreFEGeom(DMField, IS, PetscQuadrature, PetscBool, PetscFEGeom **);
638PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeResidual_Patch_Internal(DM, PetscSection, IS, PetscReal, Vec, Vec, Vec, void *);
639PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexComputeJacobian_Patch_Internal(DM, PetscSection, PetscSection, IS, PetscReal, PetscReal, Vec, Vec, Mat, Mat, void *);
640PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMCreateSubDomainDM_Plex(DM,DMLabel,PetscInt,IS*,DM*);
641PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBasisTransformPoint_Internal(DM, DM, Vec, PetscInt, PetscBool[], PetscBool, PetscScalar *);
642PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMPlexBasisTransformPointTensor_Internal(DM, DM, Vec, PetscInt, PetscBool, PetscInt, PetscScalar *);
643PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBasisTransformApplyReal_Internal(DM, const PetscReal[], PetscBool, PetscInt, const PetscReal *, PetscReal *, void *);
644PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMPlexBasisTransformApply_Internal(DM, const PetscReal[], PetscBool, PetscInt, const PetscScalar *, PetscScalar *, void *);
645
646#endif /* _PLEXIMPL_H */