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