Bug Summary

File:dm/impls/plex/plexcreate.c
Warning:line 196, column 10
Array access (via field 'flags') results in a null pointer dereference

Annotated Source Code

[?] Use j/k keys for keyboard navigation

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

1#define PETSCDM_DLL
2#include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/
3#include <petsc/private/hashseti.h> /*I "petscdmplex.h" I*/
4#include <petscsf.h>
5
6/*@
7 DMPlexCreateDoublet - Creates a mesh of two cells of the specified type, optionally with later refinement.
8
9 Collective on MPI_Comm
10
11 Input Parameters:
12+ comm - The communicator for the DM object
13. dim - The spatial dimension
14. simplex - Flag for simplicial cells, otherwise they are tensor product cells
15. interpolate - Flag to create intermediate mesh pieces (edges, faces)
16. refinementUniform - Flag for uniform parallel refinement
17- refinementLimit - A nonzero number indicates the largest admissible volume for a refined cell
18
19 Output Parameter:
20. dm - The DM object
21
22 Level: beginner
23
24.keywords: DM, create
25.seealso: DMSetType(), DMCreate()
26@*/
27PetscErrorCode DMPlexCreateDoublet(MPI_Comm comm, PetscInt dim, PetscBool simplex, PetscBool interpolate, PetscBool refinementUniform, PetscReal refinementLimit, DM *newdm)
28{
29 DM dm;
30 PetscInt p;
31 PetscMPIInt rank;
32 PetscErrorCode ierr;
33
34 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 34; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
35 ierr = DMCreate(comm, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),35,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
36 ierr = DMSetType(dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),36,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
37 ierr = DMSetDimension(dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),37,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
38 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),38,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
39 switch (dim) {
40 case 2:
41 if (simplex) {ierr = PetscObjectSetName((PetscObject) dm, "triangular");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),41,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
42 else {ierr = PetscObjectSetName((PetscObject) dm, "quadrilateral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),42,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
43 break;
44 case 3:
45 if (simplex) {ierr = PetscObjectSetName((PetscObject) dm, "tetrahedral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),45,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
46 else {ierr = PetscObjectSetName((PetscObject) dm, "hexahedral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),46,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
47 break;
48 default:
49 SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Cannot make meshes for dimension %d", dim)return PetscError(comm,49,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Cannot make meshes for dimension %d"
,dim)
;
50 }
51 if (rank) {
52 PetscInt numPoints[2] = {0, 0};
53 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, 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),53,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
54 } else {
55 switch (dim) {
56 case 2:
57 if (simplex) {
58 PetscInt numPoints[2] = {4, 2};
59 PetscInt coneSize[6] = {3, 3, 0, 0, 0, 0};
60 PetscInt cones[6] = {2, 3, 4, 5, 4, 3};
61 PetscInt coneOrientations[6] = {0, 0, 0, 0, 0, 0};
62 PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5};
63 PetscInt markerPoints[8] = {2, 1, 3, 1, 4, 1, 5, 1};
64
65 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),65,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
66 for (p = 0; p < 4; ++p) {ierr = DMSetLabelValue(dm, "marker", markerPoints[p*2], markerPoints[p*2+1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),66,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
67 } else {
68 PetscInt numPoints[2] = {6, 2};
69 PetscInt coneSize[8] = {4, 4, 0, 0, 0, 0, 0, 0};
70 PetscInt cones[8] = {2, 3, 4, 5, 3, 6, 7, 4};
71 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
72 PetscScalar vertexCoords[12] = {-1.0, -0.5, 0.0, -0.5, 0.0, 0.5, -1.0, 0.5, 1.0, -0.5, 1.0, 0.5};
73
74 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),74,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
75 }
76 break;
77 case 3:
78 if (simplex) {
79 PetscInt numPoints[2] = {5, 2};
80 PetscInt coneSize[7] = {4, 4, 0, 0, 0, 0, 0};
81 PetscInt cones[8] = {4, 3, 5, 2, 5, 3, 4, 6};
82 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
83 PetscScalar vertexCoords[15] = {-1.0, 0.0, 0.0, 0.0, -1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0, 0.0, 1.0, 0.0, 0.0};
84 PetscInt markerPoints[10] = {2, 1, 3, 1, 4, 1, 5, 1, 6, 1};
85
86 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),86,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
87 for (p = 0; p < 5; ++p) {ierr = DMSetLabelValue(dm, "marker", markerPoints[p*2], markerPoints[p*2+1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),87,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
88 } else {
89 PetscInt numPoints[2] = {12, 2};
90 PetscInt coneSize[14] = {8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
91 PetscInt cones[16] = {2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 10, 11, 7, 12, 13, 8};
92 PetscInt coneOrientations[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
93 PetscScalar vertexCoords[36] = {-1.0, -0.5, -0.5, -1.0, 0.5, -0.5, 0.0, 0.5, -0.5, 0.0, -0.5, -0.5,
94 -1.0, -0.5, 0.5, 0.0, -0.5, 0.5, 0.0, 0.5, 0.5, -1.0, 0.5, 0.5,
95 1.0, 0.5, -0.5, 1.0, -0.5, -0.5, 1.0, -0.5, 0.5, 1.0, 0.5, 0.5};
96
97 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),97,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
98 }
99 break;
100 default:
101 SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Cannot make meshes for dimension %d", dim)return PetscError(comm,101,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Cannot make meshes for dimension %d"
,dim)
;
102 }
103 }
104 *newdm = dm;
105 if (refinementLimit > 0.0) {
106 DM rdm;
107 const char *name;
108
109 ierr = DMPlexSetRefinementUniform(*newdm, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),109,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
110 ierr = DMPlexSetRefinementLimit(*newdm, refinementLimit);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),110,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
111 ierr = DMRefine(*newdm, comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),111,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
112 ierr = PetscObjectGetName((PetscObject) *newdm, &name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),112,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
113 ierr = PetscObjectSetName((PetscObject) rdm, name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),113,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
114 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
115 *newdm = rdm;
116 }
117 if (interpolate) {
118 DM idm;
119
120 ierr = DMPlexInterpolate(*newdm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
121 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),121,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
122 *newdm = idm;
123 }
124 {
125 DM refinedMesh = NULL((void*)0);
126 DM distributedMesh = NULL((void*)0);
127
128 /* Distribute mesh over processes */
129 ierr = DMPlexDistribute(*newdm, 0, NULL((void*)0), &distributedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),129,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
130 if (distributedMesh) {
131 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),131,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
132 *newdm = distributedMesh;
133 }
134 if (refinementUniform) {
135 ierr = DMPlexSetRefinementUniform(*newdm, refinementUniform);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),135,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
136 ierr = DMRefine(*newdm, comm, &refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),136,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
137 if (refinedMesh) {
138 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),138,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
139 *newdm = refinedMesh;
140 }
141 }
142 }
143 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)
;
144}
145
146/*@
147 DMPlexCreateSquareBoundary - Creates a 1D mesh the is the boundary of a square lattice.
148
149 Collective on MPI_Comm
150
151 Input Parameters:
152+ comm - The communicator for the DM object
153. lower - The lower left corner coordinates
154. upper - The upper right corner coordinates
155- edges - The number of cells in each direction
156
157 Output Parameter:
158. dm - The DM object
159
160 Note: Here is the numbering returned for 2 cells in each direction:
161$ 18--5-17--4--16
162$ | | |
163$ 6 10 3
164$ | | |
165$ 19-11-20--9--15
166$ | | |
167$ 7 8 2
168$ | | |
169$ 12--0-13--1--14
170
171 Level: beginner
172
173.keywords: DM, create
174.seealso: DMPlexCreateBoxMesh(), DMPlexCreateCubeBoundary(), DMSetType(), DMCreate()
175@*/
176PetscErrorCode DMPlexCreateSquareBoundary(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt edges[])
177{
178 const PetscInt numVertices = (edges[0]+1)*(edges[1]+1);
179 const PetscInt numEdges = edges[0]*(edges[1]+1) + (edges[0]+1)*edges[1];
180 PetscInt markerTop = 1;
181 PetscInt markerBottom = 1;
182 PetscInt markerRight = 1;
183 PetscInt markerLeft = 1;
184 PetscBool markerSeparate = PETSC_FALSE;
185 Vec coordinates;
186 PetscSection coordSection;
187 PetscScalar *coords;
188 PetscInt coordSize;
189 PetscMPIInt rank;
190 PetscInt v, vx, vy;
191 PetscErrorCode ierr;
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/plexcreate.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 ierr = PetscOptionsGetBool(((PetscObject) dm)->options,((PetscObject) dm)->prefix, "-dm_plex_separate_marker", &markerSeparate, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),194,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
195 if (markerSeparate) {
196 markerTop = 3;
197 markerBottom = 1;
198 markerRight = 2;
199 markerLeft = 4;
200 }
201 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),201,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
202 if (!rank) {
203 PetscInt e, ex, ey;
204
205 ierr = DMPlexSetChart(dm, 0, numEdges+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206 for (e = 0; e < numEdges; ++e) {
207 ierr = DMPlexSetConeSize(dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),207,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
208 }
209 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),209,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
210 for (vx = 0; vx <= edges[0]; vx++) {
211 for (ey = 0; ey < edges[1]; ey++) {
212 PetscInt edge = vx*edges[1] + ey + edges[0]*(edges[1]+1);
213 PetscInt vertex = ey*(edges[0]+1) + vx + numEdges;
214 PetscInt cone[2];
215
216 cone[0] = vertex; cone[1] = vertex+edges[0]+1;
217 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
218 if (vx == edges[0]) {
219 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),219,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
220 ierr = DMSetLabelValue(dm, "marker", cone[0], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
221 if (ey == edges[1]-1) {
222 ierr = DMSetLabelValue(dm, "marker", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),222,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
223 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),223,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
224 }
225 } else if (vx == 0) {
226 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),226,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
227 ierr = DMSetLabelValue(dm, "marker", cone[0], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),227,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
228 if (ey == edges[1]-1) {
229 ierr = DMSetLabelValue(dm, "marker", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),229,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
230 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
231 }
232 }
233 }
234 }
235 for (vy = 0; vy <= edges[1]; vy++) {
236 for (ex = 0; ex < edges[0]; ex++) {
237 PetscInt edge = vy*edges[0] + ex;
238 PetscInt vertex = vy*(edges[0]+1) + ex + numEdges;
239 PetscInt cone[2];
240
241 cone[0] = vertex; cone[1] = vertex+1;
242 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),242,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
243 if (vy == edges[1]) {
244 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),244,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
245 ierr = DMSetLabelValue(dm, "marker", cone[0], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),245,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
246 if (ex == edges[0]-1) {
247 ierr = DMSetLabelValue(dm, "marker", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
248 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),248,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
249 }
250 } else if (vy == 0) {
251 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),251,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
252 ierr = DMSetLabelValue(dm, "marker", cone[0], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),252,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
253 if (ex == edges[0]-1) {
254 ierr = DMSetLabelValue(dm, "marker", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
255 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
256 }
257 }
258 }
259 }
260 }
261 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),261,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
262 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),262,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
263 /* Build coordinates */
264 ierr = DMSetCoordinateDim(dm, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
265 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),265,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
266 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),266,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
267 ierr = PetscSectionSetChart(coordSection, numEdges, numEdges + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),267,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
268 ierr = PetscSectionSetFieldComponents(coordSection, 0, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 for (v = numEdges; v < numEdges+numVertices; ++v) {
270 ierr = PetscSectionSetDof(coordSection, v, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),270,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
271 ierr = PetscSectionSetFieldDof(coordSection, v, 0, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),271,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
272 }
273 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),273,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
274 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),274,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
275 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),275,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
276 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),276,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
277 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),277,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
278 ierr = VecSetBlockSize(coordinates, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),278,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
279 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),279,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
280 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),280,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
281 for (vy = 0; vy <= edges[1]; ++vy) {
282 for (vx = 0; vx <= edges[0]; ++vx) {
283 coords[(vy*(edges[0]+1)+vx)*2+0] = lower[0] + ((upper[0] - lower[0])/edges[0])*vx;
284 coords[(vy*(edges[0]+1)+vx)*2+1] = lower[1] + ((upper[1] - lower[1])/edges[1])*vy;
285 }
286 }
287 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),287,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
288 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),288,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
289 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),289,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
290 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)
;
291}
292
293/*@
294 DMPlexCreateCubeBoundary - Creates a 2D mesh that is the boundary of a cubic lattice.
295
296 Collective on MPI_Comm
297
298 Input Parameters:
299+ comm - The communicator for the DM object
300. lower - The lower left front corner coordinates
301. upper - The upper right back corner coordinates
302- edges - The number of cells in each direction
303
304 Output Parameter:
305. dm - The DM object
306
307 Level: beginner
308
309.keywords: DM, create
310.seealso: DMPlexCreateBoxMesh(), DMPlexCreateSquareBoundary(), DMSetType(), DMCreate()
311@*/
312PetscErrorCode DMPlexCreateCubeBoundary(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt faces[])
313{
314 PetscInt vertices[3], numVertices;
315 PetscInt numFaces = 2*faces[0]*faces[1] + 2*faces[1]*faces[2] + 2*faces[0]*faces[2];
316 Vec coordinates;
317 PetscSection coordSection;
318 PetscScalar *coords;
319 PetscInt coordSize;
320 PetscMPIInt rank;
321 PetscInt v, vx, vy, vz;
322 PetscInt voffset, iface=0, cone[4];
323 PetscErrorCode ierr;
324
325 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 325; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
326 if ((faces[0] < 1) || (faces[1] < 1) || (faces[2] < 1)) SETERRQ(PetscObjectComm((PetscObject)dm), PETSC_ERR_SUP, "Must have at least 1 face per side")return PetscError(PetscObjectComm((PetscObject)dm),326,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Must have at least 1 face per side")
;
327 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),327,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
328 vertices[0] = faces[0]+1; vertices[1] = faces[1]+1; vertices[2] = faces[2]+1;
329 numVertices = vertices[0]*vertices[1]*vertices[2];
330 if (!rank) {
331 PetscInt f;
332
333 ierr = DMPlexSetChart(dm, 0, numFaces+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),333,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
334 for (f = 0; f < numFaces; ++f) {
335 ierr = DMPlexSetConeSize(dm, f, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),335,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
336 }
337 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
338
339 /* Side 0 (Top) */
340 for (vy = 0; vy < faces[1]; vy++) {
341 for (vx = 0; vx < faces[0]; vx++) {
342 voffset = numFaces + vertices[0]*vertices[1]*(vertices[2]-1) + vy*vertices[0] + vx;
343 cone[0] = voffset; cone[1] = voffset+1; cone[2] = voffset+vertices[0]+1; cone[3] = voffset+vertices[0];
344 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),344,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
345 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),345,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
346 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),346,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
347 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),347,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
348 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),348,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
349 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),349,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
350 iface++;
351 }
352 }
353
354 /* Side 1 (Bottom) */
355 for (vy = 0; vy < faces[1]; vy++) {
356 for (vx = 0; vx < faces[0]; vx++) {
357 voffset = numFaces + vy*(faces[0]+1) + vx;
358 cone[0] = voffset+1; cone[1] = voffset; cone[2] = voffset+vertices[0]; cone[3] = voffset+vertices[0]+1;
359 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
360 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),360,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
361 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),361,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
362 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),362,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
363 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),363,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
364 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),364,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
365 iface++;
366 }
367 }
368
369 /* Side 2 (Front) */
370 for (vz = 0; vz < faces[2]; vz++) {
371 for (vx = 0; vx < faces[0]; vx++) {
372 voffset = numFaces + vz*vertices[0]*vertices[1] + vx;
373 cone[0] = voffset; cone[1] = voffset+1; cone[2] = voffset+vertices[0]*vertices[1]+1; cone[3] = voffset+vertices[0]*vertices[1];
374 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),374,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
375 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),375,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
376 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),376,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
377 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),377,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
378 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),378,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
379 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),379,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
380 iface++;
381 }
382 }
383
384 /* Side 3 (Back) */
385 for (vz = 0; vz < faces[2]; vz++) {
386 for (vx = 0; vx < faces[0]; vx++) {
387 voffset = numFaces + vz*vertices[0]*vertices[1] + vertices[0]*(vertices[1]-1) + vx;
388 cone[0] = voffset+vertices[0]*vertices[1]; cone[1] = voffset+vertices[0]*vertices[1]+1;
389 cone[2] = voffset+1; cone[3] = voffset;
390 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),390,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
391 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),391,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
392 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),392,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
393 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),393,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
394 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),394,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
395 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),395,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
396 iface++;
397 }
398 }
399
400 /* Side 4 (Left) */
401 for (vz = 0; vz < faces[2]; vz++) {
402 for (vy = 0; vy < faces[1]; vy++) {
403 voffset = numFaces + vz*vertices[0]*vertices[1] + vy*vertices[0];
404 cone[0] = voffset; cone[1] = voffset+vertices[0]*vertices[1];
405 cone[2] = voffset+vertices[0]*vertices[1]+vertices[0]; cone[3] = voffset+vertices[0];
406 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),406,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
407 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),407,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
408 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),408,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
409 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),409,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
410 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),410,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
411 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+vertices[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),411,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
412 iface++;
413 }
414 }
415
416 /* Side 5 (Right) */
417 for (vz = 0; vz < faces[2]; vz++) {
418 for (vy = 0; vy < faces[1]; vy++) {
419 voffset = numFaces + vz*vertices[0]*vertices[1] + vy*vertices[0] + faces[0];
420 cone[0] = voffset+vertices[0]*vertices[1]; cone[1] = voffset;
421 cone[2] = voffset+vertices[0]; cone[3] = voffset+vertices[0]*vertices[1]+vertices[0];
422 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),422,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
423 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),423,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
424 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),424,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
425 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),425,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
426 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),426,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
427 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+vertices[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),427,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
428 iface++;
429 }
430 }
431 }
432 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),432,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
433 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),433,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
434 /* Build coordinates */
435 ierr = DMSetCoordinateDim(dm, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),435,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
436 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),436,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
437 ierr = PetscSectionSetChart(coordSection, numFaces, numFaces + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),437,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
438 for (v = numFaces; v < numFaces+numVertices; ++v) {
439 ierr = PetscSectionSetDof(coordSection, v, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),439,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
440 }
441 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),441,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
442 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),442,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
443 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),443,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
444 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),444,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
445 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),445,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
446 ierr = VecSetBlockSize(coordinates, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),446,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
447 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
448 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),448,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
449 for (vz = 0; vz <= faces[2]; ++vz) {
450 for (vy = 0; vy <= faces[1]; ++vy) {
451 for (vx = 0; vx <= faces[0]; ++vx) {
452 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+0] = lower[0] + ((upper[0] - lower[0])/faces[0])*vx;
453 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+1] = lower[1] + ((upper[1] - lower[1])/faces[1])*vy;
454 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+2] = lower[2] + ((upper[2] - lower[2])/faces[2])*vz;
455 }
456 }
457 }
458 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),458,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
459 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),459,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
460 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),460,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
461 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
462}
463
464static PetscErrorCode DMPlexCreateLineMesh_Internal(MPI_Comm comm,PetscInt segments,PetscReal lower,PetscReal upper,DMBoundaryType bd,DM *dm)
465{
466 PetscInt i,fStart,fEnd,numCells = 0,numVerts = 0;
467 PetscInt numPoints[2],*coneSize,*cones,*coneOrientations;
468 PetscScalar *vertexCoords;
469 PetscReal L,maxCell;
470 PetscBool markerSeparate = PETSC_FALSE;
471 PetscInt markerLeft = 1, faceMarkerLeft = 1;
472 PetscInt markerRight = 1, faceMarkerRight = 2;
473 PetscBool wrap = (bd == DM_BOUNDARY_PERIODIC || bd == DM_BOUNDARY_TWIST) ? PETSC_TRUE : PETSC_FALSE;
474 PetscMPIInt rank;
475 PetscErrorCode ierr;
476
477 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 477; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
478 PetscValidPointer(dm,4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),478,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),478,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
479
480 ierr = DMCreate(comm,dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),480,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
481 ierr = DMSetType(*dm,DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),481,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
482 ierr = DMSetDimension(*dm,1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),482,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
483 ierr = DMCreateLabel(*dm,"marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),483,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
484 ierr = DMCreateLabel(*dm,"Face Sets");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),484,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
485
486 ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),486,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
487 if (!rank) numCells = segments;
488 if (!rank) numVerts = segments + (wrap ? 0 : 1);
489
490 numPoints[0] = numVerts ; numPoints[1] = numCells;
491 ierr = PetscMalloc4(numCells+numVerts,&coneSize,numCells*2,&cones,numCells+numVerts,&coneOrientations,numVerts,&vertexCoords)PetscMallocA(4,PETSC_FALSE,491,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numCells+numVerts)*sizeof(**(&coneSize)),(&
coneSize),(size_t)(numCells*2)*sizeof(**(&cones)),(&cones
),(size_t)(numCells+numVerts)*sizeof(**(&coneOrientations
)),(&coneOrientations),(size_t)(numVerts)*sizeof(**(&
vertexCoords)),(&vertexCoords))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),491,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
492 ierr = PetscMemzero(coneOrientations,(numCells+numVerts)*sizeof(PetscInt));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),492,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
493 for (i = 0; i < numCells; ++i) { coneSize[i] = 2; }
494 for (i = 0; i < numVerts; ++i) { coneSize[numCells+i] = 0; }
495 for (i = 0; i < numCells; ++i) { cones[2*i] = numCells + i%numVerts; cones[2*i+1] = numCells + (i+1)%numVerts; }
496 for (i = 0; i < numVerts; ++i) { vertexCoords[i] = lower + (upper-lower)*((PetscReal)i/(PetscReal)numCells); }
497 ierr = DMPlexCreateFromDAG(*dm,1,numPoints,coneSize,cones,coneOrientations,vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),497,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
498 ierr = PetscFree4(coneSize,cones,coneOrientations,vertexCoords)PetscFreeA(4,498,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,&(coneSize),&(cones),&(coneOrientations),&(vertexCoords
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),498,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
499
500 ierr = PetscOptionsGetBool(((PetscObject)*dm)->options,((PetscObject)*dm)->prefix,"-dm_plex_separate_marker",&markerSeparate,NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),500,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
501 if (markerSeparate) { markerLeft = faceMarkerLeft; markerRight = faceMarkerRight;}
502 if (!wrap && !rank) {
503 ierr = DMPlexGetHeightStratum(*dm,1,&fStart,&fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),503,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
504 ierr = DMSetLabelValue(*dm,"marker",fStart,markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),504,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
505 ierr = DMSetLabelValue(*dm,"marker",fEnd-1,markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),505,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
506 ierr = DMSetLabelValue(*dm,"Face Sets",fStart,faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),506,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
507 ierr = DMSetLabelValue(*dm,"Face Sets",fEnd-1,faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),507,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
508 }
509 if (wrap) {
510 L = upper - lower;
511 maxCell = (PetscReal)1.1*(L/(PetscReal)PetscMax(1,segments)(((1)<(segments)) ? (segments) : (1)));
512 ierr = DMSetPeriodicity(*dm,PETSC_TRUE,&maxCell,&L,&bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),512,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
513 }
514 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)
;
515}
516
517static PetscErrorCode DMPlexCreateBoxMesh_Simplex_Internal(MPI_Comm comm, PetscInt dim, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool interpolate, DM *dm)
518{
519 DM boundary;
520 PetscInt i;
521 PetscErrorCode ierr;
522
523 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 523; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
524 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),524,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),524,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
525 for (i = 0; i < dim; ++i) if (periodicity[i] != DM_BOUNDARY_NONE) SETERRQ(comm, PETSC_ERR_SUP, "Periodicity is not supported for simplex meshes")return PetscError(comm,525,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Periodicity is not supported for simplex meshes"
)
;
526 ierr = DMCreate(comm, &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),526,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
527 PetscValidLogicalCollectiveInt(boundary,dim,2)do { PetscErrorCode _7_ierr; PetscInt b1[2],b2[2]; b1[0] = -dim
; b1[1] = dim; _7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm
((PetscObject)boundary),2,527,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)boundary))),0) || MPI_Allreduce((b1),(b2),(2),(
((MPI_Datatype)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm
((PetscObject)boundary)))));do {if (__builtin_expect(!!(_7_ierr
),0)) return PetscError(((MPI_Comm)0x44000001),527,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)boundary)
,527,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
528 ierr = DMSetType(boundary, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),528,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
529 ierr = DMSetDimension(boundary, dim-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),529,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
530 ierr = DMSetCoordinateDim(boundary, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),530,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
531 switch (dim) {
532 case 2: ierr = DMPlexCreateSquareBoundary(boundary, lower, upper, faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),532,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;
533 case 3: ierr = DMPlexCreateCubeBoundary(boundary, lower, upper, faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),533,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;
534 default: SETERRQ1(comm, PETSC_ERR_SUP, "Dimension not supported: %d", dim)return PetscError(comm,534,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension not supported: %d",dim)
;
535 }
536 ierr = DMPlexGenerate(boundary, NULL((void*)0), interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),536,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
537 ierr = DMDestroy(&boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),537,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
538 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)
;
539}
540
541static PetscErrorCode DMPlexCreateCubeMesh_Internal(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt edges[], DMBoundaryType bdX, DMBoundaryType bdY, DMBoundaryType bdZ)
542{
543 DMLabel cutLabel = NULL((void*)0);
544 PetscInt markerTop = 1, faceMarkerTop = 1;
545 PetscInt markerBottom = 1, faceMarkerBottom = 1;
546 PetscInt markerFront = 1, faceMarkerFront = 1;
547 PetscInt markerBack = 1, faceMarkerBack = 1;
548 PetscInt markerRight = 1, faceMarkerRight = 1;
549 PetscInt markerLeft = 1, faceMarkerLeft = 1;
550 PetscInt dim;
551 PetscBool markerSeparate = PETSC_FALSE, cutMarker = PETSC_FALSE;
552 PetscMPIInt rank;
553 PetscErrorCode ierr;
554
555 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 555; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
556 ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),556,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
557 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),557,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
558 ierr = DMCreateLabel(dm,"marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),558,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
559 ierr = DMCreateLabel(dm,"Face Sets");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),559,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
560 ierr = PetscOptionsGetBool(((PetscObject) dm)->options,((PetscObject) dm)->prefix, "-dm_plex_periodic_cut", &cutMarker, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),560,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
561 if (bdX == DM_BOUNDARY_PERIODIC || bdX == DM_BOUNDARY_TWIST ||
562 bdY == DM_BOUNDARY_PERIODIC || bdY == DM_BOUNDARY_TWIST ||
563 bdZ == DM_BOUNDARY_PERIODIC || bdZ == DM_BOUNDARY_TWIST) {
564
565 if (cutMarker) {ierr = DMCreateLabel(dm, "periodic_cut");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),565,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; ierr = DMGetLabel(dm, "periodic_cut", &cutLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),565,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
566 }
567 switch (dim) {
568 case 2:
569 faceMarkerTop = 3;
570 faceMarkerBottom = 1;
571 faceMarkerRight = 2;
572 faceMarkerLeft = 4;
573 break;
574 case 3:
575 faceMarkerBottom = 1;
576 faceMarkerTop = 2;
577 faceMarkerFront = 3;
578 faceMarkerBack = 4;
579 faceMarkerRight = 5;
580 faceMarkerLeft = 6;
581 break;
582 default:
583 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Dimension %d not supported",dim)return PetscError(((MPI_Comm)0x44000001),583,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension %d not supported",dim)
;
584 break;
585 }
586 ierr = PetscOptionsGetBool(((PetscObject) dm)->options,((PetscObject) dm)->prefix, "-dm_plex_separate_marker", &markerSeparate, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),586,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
587 if (markerSeparate) {
588 markerBottom = faceMarkerBottom;
589 markerTop = faceMarkerTop;
590 markerFront = faceMarkerFront;
591 markerBack = faceMarkerBack;
592 markerRight = faceMarkerRight;
593 markerLeft = faceMarkerLeft;
594 }
595 {
596 const PetscInt numXEdges = !rank ? edges[0] : 0;
597 const PetscInt numYEdges = !rank ? edges[1] : 0;
598 const PetscInt numZEdges = !rank ? edges[2] : 0;
599 const PetscInt numXVertices = !rank ? (bdX == DM_BOUNDARY_PERIODIC || bdX == DM_BOUNDARY_TWIST ? edges[0] : edges[0]+1) : 0;
600 const PetscInt numYVertices = !rank ? (bdY == DM_BOUNDARY_PERIODIC || bdY == DM_BOUNDARY_TWIST ? edges[1] : edges[1]+1) : 0;
601 const PetscInt numZVertices = !rank ? (bdZ == DM_BOUNDARY_PERIODIC || bdZ == DM_BOUNDARY_TWIST ? edges[2] : edges[2]+1) : 0;
602 const PetscInt numCells = numXEdges*numYEdges*numZEdges;
603 const PetscInt numXFaces = numYEdges*numZEdges;
604 const PetscInt numYFaces = numXEdges*numZEdges;
605 const PetscInt numZFaces = numXEdges*numYEdges;
606 const PetscInt numTotXFaces = numXVertices*numXFaces;
607 const PetscInt numTotYFaces = numYVertices*numYFaces;
608 const PetscInt numTotZFaces = numZVertices*numZFaces;
609 const PetscInt numFaces = numTotXFaces + numTotYFaces + numTotZFaces;
610 const PetscInt numTotXEdges = numXEdges*numYVertices*numZVertices;
611 const PetscInt numTotYEdges = numYEdges*numXVertices*numZVertices;
612 const PetscInt numTotZEdges = numZEdges*numXVertices*numYVertices;
613 const PetscInt numVertices = numXVertices*numYVertices*numZVertices;
614 const PetscInt numEdges = numTotXEdges + numTotYEdges + numTotZEdges;
615 const PetscInt firstVertex = (dim == 2) ? numFaces : numCells;
616 const PetscInt firstXFace = (dim == 2) ? 0 : numCells + numVertices;
617 const PetscInt firstYFace = firstXFace + numTotXFaces;
618 const PetscInt firstZFace = firstYFace + numTotYFaces;
619 const PetscInt firstXEdge = numCells + numFaces + numVertices;
620 const PetscInt firstYEdge = firstXEdge + numTotXEdges;
621 const PetscInt firstZEdge = firstYEdge + numTotYEdges;
622 Vec coordinates;
623 PetscSection coordSection;
624 PetscScalar *coords;
625 PetscInt coordSize;
626 PetscInt v, vx, vy, vz;
627 PetscInt c, f, fx, fy, fz, e, ex, ey, ez;
628
629 ierr = DMPlexSetChart(dm, 0, numCells+numFaces+numEdges+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),629,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
630 for (c = 0; c < numCells; c++) {
631 ierr = DMPlexSetConeSize(dm, c, 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),631,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
632 }
633 for (f = firstXFace; f < firstXFace+numFaces; ++f) {
634 ierr = DMPlexSetConeSize(dm, f, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),634,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
635 }
636 for (e = firstXEdge; e < firstXEdge+numEdges; ++e) {
637 ierr = DMPlexSetConeSize(dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),637,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
638 }
639 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),639,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
640 /* Build cells */
641 for (fz = 0; fz < numZEdges; ++fz) {
642 for (fy = 0; fy < numYEdges; ++fy) {
643 for (fx = 0; fx < numXEdges; ++fx) {
644 PetscInt cell = (fz*numYEdges + fy)*numXEdges + fx;
645 PetscInt faceB = firstZFace + (fy*numXEdges+fx)*numZVertices + fz;
646 PetscInt faceT = firstZFace + (fy*numXEdges+fx)*numZVertices + ((fz+1)%numZVertices);
647 PetscInt faceF = firstYFace + (fz*numXEdges+fx)*numYVertices + fy;
648 PetscInt faceK = firstYFace + (fz*numXEdges+fx)*numYVertices + ((fy+1)%numYVertices);
649 PetscInt faceL = firstXFace + (fz*numYEdges+fy)*numXVertices + fx;
650 PetscInt faceR = firstXFace + (fz*numYEdges+fy)*numXVertices + ((fx+1)%numXVertices);
651 /* B, T, F, K, R, L */
652 PetscInt ornt[6] = {-4, 0, 0, -1, 0, -4}; /* ??? */
653 PetscInt cone[6];
654
655 /* no boundary twisting in 3D */
656 cone[0] = faceB; cone[1] = faceT; cone[2] = faceF; cone[3] = faceK; cone[4] = faceR; cone[5] = faceL;
657 ierr = DMPlexSetCone(dm, cell, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),657,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
658 ierr = DMPlexSetConeOrientation(dm, cell, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),658,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
659 if (bdX != DM_BOUNDARY_NONE && fx == numXEdges-1 && cutLabel) {ierr = DMLabelSetValue(cutLabel, cell, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),659,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
660 if (bdY != DM_BOUNDARY_NONE && fy == numYEdges-1 && cutLabel) {ierr = DMLabelSetValue(cutLabel, cell, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),660,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
661 if (bdZ != DM_BOUNDARY_NONE && fz == numZEdges-1 && cutLabel) {ierr = DMLabelSetValue(cutLabel, cell, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),661,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
662 }
663 }
664 }
665 /* Build x faces */
666 for (fz = 0; fz < numZEdges; ++fz) {
667 for (fy = 0; fy < numYEdges; ++fy) {
668 for (fx = 0; fx < numXVertices; ++fx) {
669 PetscInt face = firstXFace + (fz*numYEdges+fy)*numXVertices + fx;
670 PetscInt edgeL = firstZEdge + ( fy* numXVertices+fx)*numZEdges + fz;
671 PetscInt edgeR = firstZEdge + (((fy+1)%numYVertices)*numXVertices+fx)*numZEdges + fz;
672 PetscInt edgeB = firstYEdge + ( fz* numXVertices+fx)*numYEdges + fy;
673 PetscInt edgeT = firstYEdge + (((fz+1)%numZVertices)*numXVertices+fx)*numYEdges + fy;
674 PetscInt ornt[4] = {0, 0, -2, -2};
675 PetscInt cone[4];
676
677 if (dim == 3) {
678 /* markers */
679 if (bdX != DM_BOUNDARY_PERIODIC) {
680 if (fx == numXVertices-1) {
681 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),681,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
682 ierr = DMSetLabelValue(dm, "marker", face, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),682,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
683 }
684 else if (fx == 0) {
685 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),685,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
686 ierr = DMSetLabelValue(dm, "marker", face, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),686,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
687 }
688 }
689 }
690 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
691 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),691,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
692 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),692,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
693 }
694 }
695 }
696 /* Build y faces */
697 for (fz = 0; fz < numZEdges; ++fz) {
698 for (fx = 0; fx < numXEdges; ++fx) {
699 for (fy = 0; fy < numYVertices; ++fy) {
700 PetscInt face = firstYFace + (fz*numXEdges+fx)*numYVertices + fy;
701 PetscInt edgeL = firstZEdge + (fy*numXVertices+ fx )*numZEdges + fz;
702 PetscInt edgeR = firstZEdge + (fy*numXVertices+((fx+1)%numXVertices))*numZEdges + fz;
703 PetscInt edgeB = firstXEdge + ( fz *numYVertices+fy)*numXEdges + fx;
704 PetscInt edgeT = firstXEdge + (((fz+1)%numZVertices)*numYVertices+fy)*numXEdges + fx;
705 PetscInt ornt[4] = {0, 0, -2, -2};
706 PetscInt cone[4];
707
708 if (dim == 3) {
709 /* markers */
710 if (bdY != DM_BOUNDARY_PERIODIC) {
711 if (fy == numYVertices-1) {
712 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),712,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
713 ierr = DMSetLabelValue(dm, "marker", face, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),713,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
714 }
715 else if (fy == 0) {
716 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),716,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
717 ierr = DMSetLabelValue(dm, "marker", face, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),717,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
718 }
719 }
720 }
721 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
722 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),722,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
723 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),723,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
724 }
725 }
726 }
727 /* Build z faces */
728 for (fy = 0; fy < numYEdges; ++fy) {
729 for (fx = 0; fx < numXEdges; ++fx) {
730 for (fz = 0; fz < numZVertices; fz++) {
731 PetscInt face = firstZFace + (fy*numXEdges+fx)*numZVertices + fz;
732 PetscInt edgeL = firstYEdge + (fz*numXVertices+ fx )*numYEdges + fy;
733 PetscInt edgeR = firstYEdge + (fz*numXVertices+((fx+1)%numXVertices))*numYEdges + fy;
734 PetscInt edgeB = firstXEdge + (fz*numYVertices+ fy )*numXEdges + fx;
735 PetscInt edgeT = firstXEdge + (fz*numYVertices+((fy+1)%numYVertices))*numXEdges + fx;
736 PetscInt ornt[4] = {0, 0, -2, -2};
737 PetscInt cone[4];
738
739 if (dim == 2) {
740 if (bdX == DM_BOUNDARY_TWIST && fx == numXEdges-1) {edgeR += numYEdges-1-2*fy; ornt[1] = -2;}
741 if (bdY == DM_BOUNDARY_TWIST && fy == numYEdges-1) {edgeT += numXEdges-1-2*fx; ornt[2] = 0;}
742 if (bdX != DM_BOUNDARY_NONE && fx == numXEdges-1 && cutLabel) {ierr = DMLabelSetValue(cutLabel, face, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),742,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
743 if (bdY != DM_BOUNDARY_NONE && fy == numYEdges-1 && cutLabel) {ierr = DMLabelSetValue(cutLabel, face, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),743,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
744 } else {
745 /* markers */
746 if (bdZ != DM_BOUNDARY_PERIODIC) {
747 if (fz == numZVertices-1) {
748 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),748,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
749 ierr = DMSetLabelValue(dm, "marker", face, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),749,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
750 }
751 else if (fz == 0) {
752 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),752,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
753 ierr = DMSetLabelValue(dm, "marker", face, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),753,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
754 }
755 }
756 }
757 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
758 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),758,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
759 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),759,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
760 }
761 }
762 }
763 /* Build Z edges*/
764 for (vy = 0; vy < numYVertices; vy++) {
765 for (vx = 0; vx < numXVertices; vx++) {
766 for (ez = 0; ez < numZEdges; ez++) {
767 const PetscInt edge = firstZEdge + (vy*numXVertices+vx)*numZEdges + ez;
768 const PetscInt vertexB = firstVertex + ( ez *numYVertices+vy)*numXVertices + vx;
769 const PetscInt vertexT = firstVertex + (((ez+1)%numZVertices)*numYVertices+vy)*numXVertices + vx;
770 PetscInt cone[2];
771
772 if (dim == 3) {
773 if (bdX != DM_BOUNDARY_PERIODIC) {
774 if (vx == numXVertices-1) {
775 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),775,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
776 }
777 else if (vx == 0) {
778 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),778,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
779 }
780 }
781 if (bdY != DM_BOUNDARY_PERIODIC) {
782 if (vy == numYVertices-1) {
783 ierr = DMSetLabelValue(dm, "marker", edge, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),783,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
784 }
785 else if (vy == 0) {
786 ierr = DMSetLabelValue(dm, "marker", edge, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),786,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
787 }
788 }
789 }
790 cone[0] = vertexB; cone[1] = vertexT;
791 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),791,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
792 }
793 }
794 }
795 /* Build Y edges*/
796 for (vz = 0; vz < numZVertices; vz++) {
797 for (vx = 0; vx < numXVertices; vx++) {
798 for (ey = 0; ey < numYEdges; ey++) {
799 const PetscInt nextv = (dim == 2 && bdY == DM_BOUNDARY_TWIST && ey == numYEdges-1) ? (numXVertices-vx-1) : (vz*numYVertices+((ey+1)%numYVertices))*numXVertices + vx;
800 const PetscInt edge = firstYEdge + (vz*numXVertices+vx)*numYEdges + ey;
801 const PetscInt vertexF = firstVertex + (vz*numYVertices+ey)*numXVertices + vx;
802 const PetscInt vertexK = firstVertex + nextv;
803 PetscInt cone[2];
804
805 cone[0] = vertexF; cone[1] = vertexK;
806 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),806,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
807 if (dim == 2) {
808 if ((bdX != DM_BOUNDARY_PERIODIC) && (bdX != DM_BOUNDARY_TWIST)) {
809 if (vx == numXVertices-1) {
810 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),810,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
811 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),811,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
812 ierr = DMSetLabelValue(dm, "marker", cone[0], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),812,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
813 if (ey == numYEdges-1) {
814 ierr = DMSetLabelValue(dm, "marker", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),814,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
815 }
816 } else if (vx == 0) {
817 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),817,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
818 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),818,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
819 ierr = DMSetLabelValue(dm, "marker", cone[0], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),819,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
820 if (ey == numYEdges-1) {
821 ierr = DMSetLabelValue(dm, "marker", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),821,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
822 }
823 }
824 } else {
825 if (vx == 0 && cutLabel) {
826 ierr = DMLabelSetValue(cutLabel, edge, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),826,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
827 ierr = DMLabelSetValue(cutLabel, cone[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),827,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
828 if (ey == numYEdges-1) {
829 ierr = DMLabelSetValue(cutLabel, cone[1], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),829,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
830 }
831 }
832 }
833 } else {
834 if (bdX != DM_BOUNDARY_PERIODIC) {
835 if (vx == numXVertices-1) {
836 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),836,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
837 } else if (vx == 0) {
838 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),838,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
839 }
840 }
841 if (bdZ != DM_BOUNDARY_PERIODIC) {
842 if (vz == numZVertices-1) {
843 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),843,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
844 } else if (vz == 0) {
845 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),845,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
846 }
847 }
848 }
849 }
850 }
851 }
852 /* Build X edges*/
853 for (vz = 0; vz < numZVertices; vz++) {
854 for (vy = 0; vy < numYVertices; vy++) {
855 for (ex = 0; ex < numXEdges; ex++) {
856 const PetscInt nextv = (dim == 2 && bdX == DM_BOUNDARY_TWIST && ex == numXEdges-1) ? (numYVertices-vy-1)*numXVertices : (vz*numYVertices+vy)*numXVertices + (ex+1)%numXVertices;
857 const PetscInt edge = firstXEdge + (vz*numYVertices+vy)*numXEdges + ex;
858 const PetscInt vertexL = firstVertex + (vz*numYVertices+vy)*numXVertices + ex;
859 const PetscInt vertexR = firstVertex + nextv;
860 PetscInt cone[2];
861
862 cone[0] = vertexL; cone[1] = vertexR;
863 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
864 if (dim == 2) {
865 if ((bdY != DM_BOUNDARY_PERIODIC) && (bdY != DM_BOUNDARY_TWIST)) {
866 if (vy == numYVertices-1) {
867 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),867,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
868 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),868,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
869 ierr = DMSetLabelValue(dm, "marker", cone[0], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),869,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
870 if (ex == numXEdges-1) {
871 ierr = DMSetLabelValue(dm, "marker", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),871,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
872 }
873 } else if (vy == 0) {
874 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),874,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
875 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),875,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
876 ierr = DMSetLabelValue(dm, "marker", cone[0], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),876,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
877 if (ex == numXEdges-1) {
878 ierr = DMSetLabelValue(dm, "marker", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),878,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
879 }
880 }
881 } else {
882 if (vy == 0 && cutLabel) {
883 ierr = DMLabelSetValue(cutLabel, edge, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),883,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
884 ierr = DMLabelSetValue(cutLabel, cone[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),884,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
885 if (ex == numXEdges-1) {
886 ierr = DMLabelSetValue(cutLabel, cone[1], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),886,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
887 }
888 }
889 }
890 } else {
891 if (bdY != DM_BOUNDARY_PERIODIC) {
892 if (vy == numYVertices-1) {
893 ierr = DMSetLabelValue(dm, "marker", edge, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),893,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
894 }
895 else if (vy == 0) {
896 ierr = DMSetLabelValue(dm, "marker", edge, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),896,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
897 }
898 }
899 if (bdZ != DM_BOUNDARY_PERIODIC) {
900 if (vz == numZVertices-1) {
901 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),901,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
902 }
903 else if (vz == 0) {
904 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),904,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
905 }
906 }
907 }
908 }
909 }
910 }
911 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),911,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
912 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),912,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
913 /* Build coordinates */
914 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),914,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
915 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),915,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
916 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),916,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
917 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),917,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
918 for (v = firstVertex; v < firstVertex+numVertices; ++v) {
919 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),919,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
920 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),920,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
921 }
922 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),922,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
923 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),923,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
924 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),924,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
925 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),925,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
926 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),926,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
927 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),927,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
928 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),928,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
929 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),929,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
930 for (vz = 0; vz < numZVertices; ++vz) {
931 for (vy = 0; vy < numYVertices; ++vy) {
932 for (vx = 0; vx < numXVertices; ++vx) {
933 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+0] = lower[0] + ((upper[0] - lower[0])/numXEdges)*vx;
934 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+1] = lower[1] + ((upper[1] - lower[1])/numYEdges)*vy;
935 if (dim == 3) {
936 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+2] = lower[2] + ((upper[2] - lower[2])/numZEdges)*vz;
937 }
938 }
939 }
940 }
941 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),941,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
942 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),942,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
943 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),943,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
944 }
945 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)
;
946}
947
948static PetscErrorCode DMPlexCreateBoxMesh_Tensor_Internal(MPI_Comm comm, PetscInt dim, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool interpolate, DM *dm)
949{
950 PetscInt i;
951 PetscErrorCode ierr;
952
953 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 953; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
954 PetscValidPointer(dm, 7)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),954,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",7); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),954,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",7);
} while (0)
;
955 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),955,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
956 PetscValidLogicalCollectiveInt(*dm,dim,2)do { PetscErrorCode _7_ierr; PetscInt b1[2],b2[2]; b1[0] = -dim
; b1[1] = dim; _7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm
((PetscObject)*dm),2,956,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)*dm))),0) || MPI_Allreduce((b1),(b2),(2),(((MPI_Datatype
)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm((PetscObject
)*dm)))));do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError
(((MPI_Comm)0x44000001),956,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),956,
__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
957 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),957,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
958 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),958,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
959 switch (dim) {
960 case 2: {ierr = DMPlexCreateCubeMesh_Internal(*dm, lower, upper, faces, periodicity[0], periodicity[1], DM_BOUNDARY_NONE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),960,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;}
961 case 3: {ierr = DMPlexCreateCubeMesh_Internal(*dm, lower, upper, faces, periodicity[0], periodicity[1], periodicity[2]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),961,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;}
962 default: SETERRQ1(comm, PETSC_ERR_SUP, "Dimension not supported: %d", dim)return PetscError(comm,962,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension not supported: %d",dim)
;
963 }
964 if (periodicity[0] == DM_BOUNDARY_PERIODIC || periodicity[0] == DM_BOUNDARY_TWIST ||
965 periodicity[1] == DM_BOUNDARY_PERIODIC || periodicity[1] == DM_BOUNDARY_TWIST ||
966 (dim > 2 && (periodicity[2] == DM_BOUNDARY_PERIODIC || periodicity[2] == DM_BOUNDARY_TWIST))) {
967 PetscReal L[3];
968 PetscReal maxCell[3];
969
970 for (i = 0; i < dim; i++) {
971 L[i] = upper[i] - lower[i];
972 maxCell[i] = 1.1 * (L[i] / PetscMax(1,faces[i])(((1)<(faces[i])) ? (faces[i]) : (1)));
973 }
974 ierr = DMSetPeriodicity(*dm,PETSC_TRUE,maxCell,L,periodicity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),974,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
975 }
976 if (!interpolate) {
977 DM udm;
978
979 ierr = DMPlexUninterpolate(*dm, &udm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),979,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
980 ierr = DMPlexCopyCoordinates(*dm, udm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),980,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
981 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),981,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
982 *dm = udm;
983 }
984 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)
;
985}
986
987/*@C
988 DMPlexCreateBoxMesh - Creates a mesh on the tensor product of unit intervals (box) using simplices or tensor cells (hexahedra).
989
990 Collective on MPI_Comm
991
992 Input Parameters:
993+ comm - The communicator for the DM object
994. dim - The spatial dimension
995. simplex - PETSC_TRUE for simplices, PETSC_FALSE for tensor cells
996. faces - Number of faces per dimension, or NULL for (1,) in 1D and (2, 2) in 2D and (1, 1, 1) in 3D
997. lower - The lower left corner, or NULL for (0, 0, 0)
998. upper - The upper right corner, or NULL for (1, 1, 1)
999. periodicity - The boundary type for the X,Y,Z direction, or NULL for DM_BOUNDARY_NONE
1000- interpolate - Flag to create intermediate mesh pieces (edges, faces)
1001
1002 Output Parameter:
1003. dm - The DM object
1004
1005 Options Database Keys:
1006+ -dm_plex_box_lower <x,y,z> - Specify lower-left-bottom coordinates for the box
1007- -dm_plex_box_upper <x,y,z> - Specify upper-right-top coordinates for the box
1008
1009 Note: Here is the numbering returned for 2 faces in each direction for tensor cells:
1010$ 10---17---11---18----12
1011$ | | |
1012$ | | |
1013$ 20 2 22 3 24
1014$ | | |
1015$ | | |
1016$ 7---15----8---16----9
1017$ | | |
1018$ | | |
1019$ 19 0 21 1 23
1020$ | | |
1021$ | | |
1022$ 4---13----5---14----6
1023
1024and for simplicial cells
1025
1026$ 14----8---15----9----16
1027$ |\ 5 |\ 7 |
1028$ | \ | \ |
1029$ 13 2 14 3 15
1030$ | 4 \ | 6 \ |
1031$ | \ | \ |
1032$ 11----6---12----7----13
1033$ |\ |\ |
1034$ | \ 1 | \ 3 |
1035$ 10 0 11 1 12
1036$ | 0 \ | 2 \ |
1037$ | \ | \ |
1038$ 8----4----9----5----10
1039
1040 Level: beginner
1041
1042.keywords: DM, create
1043.seealso: DMPlexCreateFromFile(), DMPlexCreateHexCylinderMesh(), DMSetType(), DMCreate()
1044@*/
1045PetscErrorCode DMPlexCreateBoxMesh(MPI_Comm comm, PetscInt dim, PetscBool simplex, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool interpolate, DM *dm)
1046{
1047 PetscInt fac[3] = {0, 0, 0};
1048 PetscReal low[3] = {0, 0, 0};
1049 PetscReal upp[3] = {1, 1, 1};
1050 DMBoundaryType bdt[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
1051 PetscInt i, n;
1052 PetscBool flg;
1053 PetscErrorCode ierr;
1054
1055 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1055; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1056 for (i = 0; i < dim; ++i) fac[i] = faces ? faces[i] : (dim == 1 ? 1 : 4-dim);
1057 if (lower) for (i = 0; i < dim; ++i) low[i] = lower[i];
1058 if (upper) for (i = 0; i < dim; ++i) upp[i] = upper[i];
1059 if (periodicity) for (i = 0; i < dim; ++i) bdt[i] = periodicity[i];
1060 /* Allow bounds to be specified from the command line */
1061 n = 3;
1062 ierr = PetscOptionsGetRealArray(NULL((void*)0), NULL((void*)0), "-dm_plex_box_lower", low, &n, &flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1062,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1063 if (flg && (n != dim)) SETERRQ2(comm, PETSC_ERR_ARG_SIZ, "Lower box point had %D values, should have been %D", n, dim)return PetscError(comm,1063,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,60,PETSC_ERROR_INITIAL,"Lower box point had %D values, should have been %D"
,n,dim)
;
1064 n = 3;
1065 ierr = PetscOptionsGetRealArray(NULL((void*)0), NULL((void*)0), "-dm_plex_box_upper", upp, &n, &flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1065,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1066 if (flg && (n != dim)) SETERRQ2(comm, PETSC_ERR_ARG_SIZ, "Upper box point had %D values, should have been %D", n, dim)return PetscError(comm,1066,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,60,PETSC_ERROR_INITIAL,"Upper box point had %D values, should have been %D"
,n,dim)
;
1067
1068 if (dim == 1) {ierr = DMPlexCreateLineMesh_Internal(comm, fac[0], low[0], upp[0], bdt[0], dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1068,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1069 else if (simplex) {ierr = DMPlexCreateBoxMesh_Simplex_Internal(comm, dim, fac, low, upp, bdt, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1069,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1070 else {ierr = DMPlexCreateBoxMesh_Tensor_Internal(comm, dim, fac, low, upp, bdt, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1070,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1071 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)
;
1072}
1073
1074/*@
1075 DMPlexCreateWedgeBoxMesh - Creates a 3-D mesh tesselating the (x,y) plane and extruding in the third direction using wedge cells.
1076
1077 Collective on MPI_Comm
1078
1079 Input Parameters:
1080+ comm - The communicator for the DM object
1081. faces - Number of faces per dimension, or NULL for (1, 1, 1)
1082. lower - The lower left corner, or NULL for (0, 0, 0)
1083. upper - The upper right corner, or NULL for (1, 1, 1)
1084. periodicity - The boundary type for the X,Y,Z direction, or NULL for DM_BOUNDARY_NONE
1085. ordExt - If PETSC_TRUE, orders the extruded cells in the height first. Otherwise, orders the cell on the layers first
1086- interpolate - Flag to create intermediate mesh pieces (edges, faces)
1087
1088 Output Parameter:
1089. dm - The DM object
1090
1091 Level: beginner
1092
1093.keywords: DM, create
1094.seealso: DMPlexCreateHexCylinderMesh(), DMPlexCreateWedgeCylinderMesh(), DMPlexExtrude(), DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1095@*/
1096PetscErrorCode DMPlexCreateWedgeBoxMesh(MPI_Comm comm, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool ordExt, PetscBool interpolate, DM *dm)
1097{
1098 DM bdm, botdm;
1099 PetscInt i;
1100 PetscInt fac[3] = {0, 0, 0};
1101 PetscReal low[3] = {0, 0, 0};
1102 PetscReal upp[3] = {1, 1, 1};
1103 DMBoundaryType bdt[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
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/plexcreate.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 for (i = 0; i < 3; ++i) fac[i] = faces ? (faces[i] > 0 ? faces[i] : 1) : 1;
1108 if (lower) for (i = 0; i < 3; ++i) low[i] = lower[i];
1109 if (upper) for (i = 0; i < 3; ++i) upp[i] = upper[i];
1110 if (periodicity) for (i = 0; i < 3; ++i) bdt[i] = periodicity[i];
1111 for (i = 0; i < 3; ++i) if (bdt[i] != DM_BOUNDARY_NONE) SETERRQ(comm, PETSC_ERR_SUP, "Periodicity not yet supported")return PetscError(comm,1111,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Periodicity not yet supported")
;
1112
1113 ierr = DMCreate(comm, &bdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1113,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1114 ierr = DMSetType(bdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1115 ierr = DMSetDimension(bdm, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1115,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1116 ierr = DMSetCoordinateDim(bdm, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1116,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1117 ierr = DMPlexCreateSquareBoundary(bdm, low, upp, fac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1117,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1118 ierr = DMPlexGenerate(bdm, NULL((void*)0), PETSC_FALSE, &botdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1118,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1119 ierr = DMDestroy(&bdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1119,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1120 ierr = DMPlexExtrude(botdm, fac[2], upp[2] - low[2], ordExt, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1120,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1121 if (low[2] != 0.0) {
1122 Vec v;
1123 PetscScalar *x;
1124 PetscInt cDim, n;
1125
1126 ierr = DMGetCoordinatesLocal(*dm, &v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1126,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1127 ierr = VecGetBlockSize(v, &cDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1127,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1128 ierr = VecGetLocalSize(v, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1128,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1129 ierr = VecGetArray(v, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1129,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1130 x += cDim;
1131 for (i=0; i<n; i+=cDim) x[i] += low[2];
1132 ierr = VecRestoreArray(v,&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1132,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1133 ierr = DMSetCoordinatesLocal(*dm, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1133,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1134 }
1135 ierr = DMDestroy(&botdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1135,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1136 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)
;
1137}
1138
1139/*@
1140 DMPlexExtrude - Creates a (d+1)-D mesh by extruding a d-D mesh in the normal direction using prismatic cells.
1141
1142 Collective on idm
1143
1144 Input Parameters:
1145+ idm - The mesh to be extruted
1146. layers - The number of layers
1147. height - The height of the extruded layer
1148. ordExt - If PETSC_TRUE, orders the extruded cells in the height first. Otherwise, orders the cell on the layers first
1149- interpolate - Flag to create intermediate mesh pieces (edges, faces)
1150
1151 Output Parameter:
1152. dm - The DM object
1153
1154 Notes: The object created is an hybrid mesh, the vertex ordering in the cone of the cell is that of the prismatic cells
1155
1156 Level: advanced
1157
1158.keywords: DM, create
1159.seealso: DMPlexCreateWedgeCylinderMesh(), DMPlexCreateWedgeBoxMesh(), DMPlexSetHybridBounds(), DMSetType(), DMCreate()
1160@*/
1161PetscErrorCode DMPlexExtrude(DM idm, PetscInt layers, PetscReal height, PetscBool ordExt, PetscBool interpolate, DM* dm)
1162{
1163 PetscScalar *coordsB;
1164 const PetscScalar *coordsA;
1165 PetscReal *normals = NULL((void*)0);
1166 Vec coordinatesA, coordinatesB;
1167 PetscSection coordSectionA, coordSectionB;
1168 PetscInt dim, cDim, cDimB, c, l, v, coordSize, *newCone;
1169 PetscInt cStart, cEnd, vStart, vEnd, cellV, numCells, numVertices;
1170 PetscErrorCode ierr;
1171
1172 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1172; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1173 PetscValidHeaderSpecific(idm, DM_CLASSID, 1)do { if (!idm) return PetscError(((MPI_Comm)0x44000001),1173,
__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(idm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),1173,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d"
,1); if (((PetscObject)(idm))->classid != DM_CLASSID) { if
(((PetscObject)(idm))->classid == -1) return PetscError((
(MPI_Comm)0x44000001),1173,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),1173,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
1174 PetscValidLogicalCollectiveInt(idm, layers, 2)do { PetscErrorCode _7_ierr; PetscInt b1[2],b2[2]; b1[0] = -layers
; b1[1] = layers; _7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm
((PetscObject)idm),2,1174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)idm))),0) || MPI_Allreduce((b1),(b2),(2),(((MPI_Datatype
)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm((PetscObject
)idm)))));do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError
(((MPI_Comm)0x44000001),1174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)idm),1174
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
1175 PetscValidLogicalCollectiveReal(idm, height, 3)do { PetscErrorCode _7_ierr; PetscReal b1[3],b2[3]; if (PetscIsNanReal
(height)) {b1[2] = 1;} else {b1[2] = 0;}; b1[0] = -height; b1
[1] = height; _7_ierr = ((petsc_allreduce_ct += PetscMPIParallelComm
((PetscObjectComm((PetscObject)idm))),0) || MPI_Allreduce((b1
),(b2),(3),(((MPI_Datatype)0x4c00080b)),((MPI_Op)(0x58000001)
),(PetscObjectComm((PetscObject)idm))));do {if (__builtin_expect
(!!(_7_ierr),0)) return PetscError(((MPI_Comm)0x44000001),1175
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (!(b2[2] >
0) && !PetscEqualReal(-b2[0],b2[1])) return PetscError
(PetscObjectComm((PetscObject)idm),1175,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Real value must be same on all processes, argument # %d"
,3); } while (0)
;
1176 PetscValidLogicalCollectiveBool(idm, interpolate, 4)do { PetscErrorCode _7_ierr; PetscMPIInt b1[2],b2[2]; b1[0] =
-(PetscMPIInt)interpolate; b1[1] = (PetscMPIInt)interpolate;
_7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm((PetscObject
)idm),2,1176,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)idm))),0) || MPI_Allreduce((b1),(b2),(2),(((MPI_Datatype
)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm((PetscObject
)idm)))));do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError
(((MPI_Comm)0x44000001),1176,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)idm),1176
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Bool value must be same on all processes, argument # %d"
,4); } while (0)
;
1177 ierr = DMGetDimension(idm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1177,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1178 if (dim < 1 || dim > 3) SETERRQ1(PetscObjectComm((PetscObject)idm), PETSC_ERR_SUP, "Support for dimension %D not coded", dim)return PetscError(PetscObjectComm((PetscObject)idm),1178,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Support for dimension %D not coded",
dim)
;
1179
1180 ierr = DMPlexGetHeightStratum(idm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1180,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1181 ierr = DMPlexGetDepthStratum(idm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1181,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1182 numCells = (cEnd - cStart)*layers;
1183 numVertices = (vEnd - vStart)*(layers+1);
1184 ierr = DMCreate(PetscObjectComm((PetscObject)idm), dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1184,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1185 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1185,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1186 ierr = DMSetDimension(*dm, dim+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1186,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1187 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1187,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1188 for (c = cStart, cellV = 0; c < cEnd; ++c) {
1189 PetscInt *closure = NULL((void*)0);
1190 PetscInt closureSize, numCorners = 0;
1191
1192 ierr = DMPlexGetTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1192,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1193 for (v = 0; v < closureSize*2; v += 2) if ((closure[v] >= vStart) && (closure[v] < vEnd)) numCorners++;
1194 ierr = DMPlexRestoreTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1194,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1195 for (l = 0; l < layers; ++l) {
1196 ierr = DMPlexSetConeSize(*dm, ordExt ? layers*(c - cStart) + l : l*(cEnd - cStart) + c - cStart, 2*numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1196,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1197 }
1198 cellV = PetscMax(numCorners,cellV)(((numCorners)<(cellV)) ? (cellV) : (numCorners));
1199 }
1200 ierr = DMPlexSetHybridBounds(*dm, 0, PETSC_DETERMINE-1, PETSC_DETERMINE-1, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1200,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1201 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1201,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1202
1203 ierr = DMGetCoordinateDim(idm, &cDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1203,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1204 if (dim != cDim) {
1205 ierr = PetscCalloc1(cDim*(vEnd - vStart), &normals)PetscMallocA(1,PETSC_TRUE,1205,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(cDim*(vEnd - vStart))*sizeof(**(&normals)),(&
normals))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1205,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1206 }
1207 ierr = PetscMalloc1(3*cellV,&newCone)PetscMallocA(1,PETSC_FALSE,1207,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(3*cellV)*sizeof(**(&newCone)),(&newCone))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1207,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1208 for (c = cStart; c < cEnd; ++c) {
1209 PetscInt *closure = NULL((void*)0);
1210 PetscInt closureSize, numCorners = 0, l;
1211 PetscReal normal[3] = {0, 0, 0};
1212
1213 if (normals) {
1214 ierr = DMPlexComputeCellGeometryFVM(idm, c, NULL((void*)0), NULL((void*)0), normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1214,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1215 }
1216 ierr = DMPlexGetTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1216,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1217 for (v = 0; v < closureSize*2; v += 2) {
1218 if ((closure[v] >= vStart) && (closure[v] < vEnd)) {
1219 PetscInt d;
1220
1221 newCone[numCorners++] = closure[v] - vStart;
1222 if (normals) { for (d = 0; d < cDim; ++d) normals[cDim*(closure[v]-vStart)+d] += normal[d]; }
1223 }
1224 }
1225 switch (numCorners) {
1226 case 4: /* do nothing */
1227 case 2: /* do nothing */
1228 break;
1229 case 3: /* from counter-clockwise to wedge ordering */
1230 l = newCone[1];
1231 newCone[1] = newCone[2];
1232 newCone[2] = l;
1233 break;
1234 default: SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported number of corners: %D", numCorners)return PetscError(((MPI_Comm)0x44000001),1234,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Unsupported number of corners: %D",numCorners
)
;
1235 }
1236 ierr = DMPlexRestoreTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1236,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1237 for (l = 0; l < layers; ++l) {
1238 PetscInt i;
1239
1240 for (i = 0; i < numCorners; ++i) {
1241 newCone[ numCorners + i] = ordExt ? (layers+1)*newCone[i] + l + numCells : l*(vEnd - vStart) + newCone[i] + numCells;
1242 newCone[2*numCorners + i] = ordExt ? (layers+1)*newCone[i] + l + 1 + numCells : (l+1)*(vEnd - vStart) + newCone[i] + numCells;
1243 }
1244 ierr = DMPlexSetCone(*dm, ordExt ? layers*(c - cStart) + l : l*(cEnd - cStart) + c - cStart, newCone + numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1244,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1245 }
1246 }
1247 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1247,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1248 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1248,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1249 ierr = PetscFree(newCone)((*PetscTrFree)((void*)(newCone),1249,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((newCone) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1249,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1250
1251 cDimB = cDim == dim ? cDim+1 : cDim;
1252 ierr = DMGetCoordinateSection(*dm, &coordSectionB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1252,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1253 ierr = PetscSectionSetNumFields(coordSectionB, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1253,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1254 ierr = PetscSectionSetFieldComponents(coordSectionB, 0, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1254,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1255 ierr = PetscSectionSetChart(coordSectionB, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1255,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1256 for (v = numCells; v < numCells+numVertices; ++v) {
1257 ierr = PetscSectionSetDof(coordSectionB, v, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1257,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1258 ierr = PetscSectionSetFieldDof(coordSectionB, v, 0, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1258,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1259 }
1260 ierr = PetscSectionSetUp(coordSectionB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1260,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1261 ierr = PetscSectionGetStorageSize(coordSectionB, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1261,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1262 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1262,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1263 ierr = PetscObjectSetName((PetscObject) coordinatesB, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1263,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1264 ierr = VecSetSizes(coordinatesB, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1264,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1265 ierr = VecSetBlockSize(coordinatesB, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1265,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1266 ierr = VecSetType(coordinatesB,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1266,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1267
1268 ierr = DMGetCoordinateSection(idm, &coordSectionA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1268,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1269 ierr = DMGetCoordinatesLocal(idm, &coordinatesA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1269,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1270 ierr = VecGetArray(coordinatesB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1270,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1271 ierr = VecGetArrayRead(coordinatesA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1271,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1272 for (v = vStart; v < vEnd; ++v) {
1273 const PetscScalar *cptr;
1274 PetscReal ones2[2] = { 0., 1.}, ones3[3] = { 0., 0., 1.};
1275 PetscReal *normal, norm, h = height/layers;
1276 PetscInt offA, d, cDimA = cDim;
1277
1278 normal = normals ? normals + cDimB*(v - vStart) : (cDim > 1 ? ones3 : ones2);
1279 if (normals) {
1280 for (d = 0, norm = 0.0; d < cDimB; ++d) norm += normal[d]*normal[d];
1281 for (d = 0; d < cDimB; ++d) normal[d] *= 1./PetscSqrtReal(norm)sqrt(norm);
1282 }
1283
1284 ierr = PetscSectionGetOffset(coordSectionA, v, &offA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1284,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1285 cptr = coordsA + offA;
1286 for (l = 0; l < layers+1; ++l) {
1287 PetscInt offB, d, newV;
1288
1289 newV = ordExt ? (layers+1)*(v -vStart) + l + numCells : (vEnd -vStart)*l + (v -vStart) + numCells;
1290 ierr = PetscSectionGetOffset(coordSectionB, newV, &offB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1290,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1291 for (d = 0; d < cDimA; ++d) { coordsB[offB+d] = cptr[d]; }
1292 for (d = 0; d < cDimB; ++d) { coordsB[offB+d] += l ? normal[d]*h : 0.0; }
1293 cptr = coordsB + offB;
1294 cDimA = cDimB;
1295 }
1296 }
1297 ierr = VecRestoreArrayRead(coordinatesA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1297,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1298 ierr = VecRestoreArray(coordinatesB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1298,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1299 ierr = DMSetCoordinatesLocal(*dm, coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1299,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1300 ierr = VecDestroy(&coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1301 ierr = PetscFree(normals)((*PetscTrFree)((void*)(normals),1301,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((normals) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1301,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1302 if (interpolate) {
1303 DM idm;
1304
1305 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1305,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1306 ierr = DMPlexCopyCoordinates(*dm, idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1306,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1307 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1307,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1308 *dm = idm;
1309 }
1310 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)
;
1311}
1312
1313/*@C
1314 DMPlexSetOptionsPrefix - Sets the prefix used for searching for all DM options in the database.
1315
1316 Logically Collective on DM
1317
1318 Input Parameters:
1319+ dm - the DM context
1320- prefix - the prefix to prepend to all option names
1321
1322 Notes:
1323 A hyphen (-) must NOT be given at the beginning of the prefix name.
1324 The first character of all runtime options is AUTOMATICALLY the hyphen.
1325
1326 Level: advanced
1327
1328.seealso: SNESSetFromOptions()
1329@*/
1330PetscErrorCode DMPlexSetOptionsPrefix(DM dm, const char prefix[])
1331{
1332 DM_Plex *mesh = (DM_Plex *) dm->data;
1333 PetscErrorCode ierr;
1334
1335 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1335; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1336 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1336,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),1336,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.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),1336,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),1336,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
1337 ierr = PetscObjectSetOptionsPrefix((PetscObject) dm, prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1338 ierr = PetscObjectSetOptionsPrefix((PetscObject) mesh->partitioner, prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1338,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1339 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)
;
1340}
1341
1342/*@
1343 DMPlexCreateHexCylinderMesh - Creates a mesh on the tensor product of the unit interval with the circle (cylinder) using hexahedra.
1344
1345 Collective on MPI_Comm
1346
1347 Input Parameters:
1348+ comm - The communicator for the DM object
1349. numRefine - The number of regular refinements to the basic 5 cell structure
1350- periodicZ - The boundary type for the Z direction
1351
1352 Output Parameter:
1353. dm - The DM object
1354
1355 Note: Here is the output numbering looking from the bottom of the cylinder:
1356$ 17-----14
1357$ | |
1358$ | 2 |
1359$ | |
1360$ 17-----8-----7-----14
1361$ | | | |
1362$ | 3 | 0 | 1 |
1363$ | | | |
1364$ 19-----5-----6-----13
1365$ | |
1366$ | 4 |
1367$ | |
1368$ 19-----13
1369$
1370$ and up through the top
1371$
1372$ 18-----16
1373$ | |
1374$ | 2 |
1375$ | |
1376$ 18----10----11-----16
1377$ | | | |
1378$ | 3 | 0 | 1 |
1379$ | | | |
1380$ 20-----9----12-----15
1381$ | |
1382$ | 4 |
1383$ | |
1384$ 20-----15
1385
1386 Level: beginner
1387
1388.keywords: DM, create
1389.seealso: DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1390@*/
1391PetscErrorCode DMPlexCreateHexCylinderMesh(MPI_Comm comm, PetscInt numRefine, DMBoundaryType periodicZ, DM *dm)
1392{
1393 const PetscInt dim = 3;
1394 PetscInt numCells, numVertices, r;
1395 PetscMPIInt rank;
1396 PetscErrorCode ierr;
1397
1398 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1398; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1399 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1399,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),1399,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
1400 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1400,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1401 if (numRefine < 0) SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Number of refinements %D cannot be negative", numRefine)return PetscError(comm,1401,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Number of refinements %D cannot be negative"
,numRefine)
;
1402 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1402,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1403 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1403,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1404 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1404,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1405 /* Create topology */
1406 {
1407 PetscInt cone[8], c;
1408
1409 numCells = !rank ? 5 : 0;
1410 numVertices = !rank ? 16 : 0;
1411 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1412 numCells *= 3;
1413 numVertices = !rank ? 24 : 0;
1414 }
1415 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1415,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1416 for (c = 0; c < numCells; c++) {ierr = DMPlexSetConeSize(*dm, c, 8);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1416,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1417 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1417,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1418 if (!rank) {
1419 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1420 cone[0] = 15; cone[1] = 18; cone[2] = 17; cone[3] = 16;
1421 cone[4] = 31; cone[5] = 32; cone[6] = 33; cone[7] = 34;
1422 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1422,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1423 cone[0] = 16; cone[1] = 17; cone[2] = 24; cone[3] = 23;
1424 cone[4] = 32; cone[5] = 36; cone[6] = 37; cone[7] = 33; /* 22 25 26 21 */
1425 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1425,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1426 cone[0] = 18; cone[1] = 27; cone[2] = 24; cone[3] = 17;
1427 cone[4] = 34; cone[5] = 33; cone[6] = 37; cone[7] = 38;
1428 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1428,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1429 cone[0] = 29; cone[1] = 27; cone[2] = 18; cone[3] = 15;
1430 cone[4] = 35; cone[5] = 31; cone[6] = 34; cone[7] = 38;
1431 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1431,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1432 cone[0] = 29; cone[1] = 15; cone[2] = 16; cone[3] = 23;
1433 cone[4] = 35; cone[5] = 36; cone[6] = 32; cone[7] = 31;
1434 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1434,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1435
1436 cone[0] = 31; cone[1] = 34; cone[2] = 33; cone[3] = 32;
1437 cone[4] = 19; cone[5] = 22; cone[6] = 21; cone[7] = 20;
1438 ierr = DMPlexSetCone(*dm, 5, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1438,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1439 cone[0] = 32; cone[1] = 33; cone[2] = 37; cone[3] = 36;
1440 cone[4] = 22; cone[5] = 25; cone[6] = 26; cone[7] = 21;
1441 ierr = DMPlexSetCone(*dm, 6, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1441,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1442 cone[0] = 34; cone[1] = 38; cone[2] = 37; cone[3] = 33;
1443 cone[4] = 20; cone[5] = 21; cone[6] = 26; cone[7] = 28;
1444 ierr = DMPlexSetCone(*dm, 7, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1444,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1445 cone[0] = 35; cone[1] = 38; cone[2] = 34; cone[3] = 31;
1446 cone[4] = 30; cone[5] = 19; cone[6] = 20; cone[7] = 28;
1447 ierr = DMPlexSetCone(*dm, 8, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1447,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1448 cone[0] = 35; cone[1] = 31; cone[2] = 32; cone[3] = 36;
1449 cone[4] = 30; cone[5] = 25; cone[6] = 22; cone[7] = 19;
1450 ierr = DMPlexSetCone(*dm, 9, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1450,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1451
1452 cone[0] = 19; cone[1] = 20; cone[2] = 21; cone[3] = 22;
1453 cone[4] = 15; cone[5] = 16; cone[6] = 17; cone[7] = 18;
1454 ierr = DMPlexSetCone(*dm, 10, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1454,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1455 cone[0] = 22; cone[1] = 21; cone[2] = 26; cone[3] = 25;
1456 cone[4] = 16; cone[5] = 23; cone[6] = 24; cone[7] = 17;
1457 ierr = DMPlexSetCone(*dm, 11, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1457,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1458 cone[0] = 20; cone[1] = 28; cone[2] = 26; cone[3] = 21;
1459 cone[4] = 18; cone[5] = 17; cone[6] = 24; cone[7] = 27;
1460 ierr = DMPlexSetCone(*dm, 12, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1460,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1461 cone[0] = 30; cone[1] = 28; cone[2] = 20; cone[3] = 19;
1462 cone[4] = 29; cone[5] = 15; cone[6] = 18; cone[7] = 27;
1463 ierr = DMPlexSetCone(*dm, 13, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1463,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1464 cone[0] = 30; cone[1] = 19; cone[2] = 22; cone[3] = 25;
1465 cone[4] = 29; cone[5] = 23; cone[6] = 16; cone[7] = 15;
1466 ierr = DMPlexSetCone(*dm, 14, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1466,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1467 } else {
1468 cone[0] = 5; cone[1] = 8; cone[2] = 7; cone[3] = 6;
1469 cone[4] = 9; cone[5] = 12; cone[6] = 11; cone[7] = 10;
1470 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1470,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1471 cone[0] = 6; cone[1] = 7; cone[2] = 14; cone[3] = 13;
1472 cone[4] = 12; cone[5] = 15; cone[6] = 16; cone[7] = 11;
1473 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1473,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1474 cone[0] = 8; cone[1] = 17; cone[2] = 14; cone[3] = 7;
1475 cone[4] = 10; cone[5] = 11; cone[6] = 16; cone[7] = 18;
1476 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1476,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1477 cone[0] = 19; cone[1] = 17; cone[2] = 8; cone[3] = 5;
1478 cone[4] = 20; cone[5] = 9; cone[6] = 10; cone[7] = 18;
1479 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1479,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1480 cone[0] = 19; cone[1] = 5; cone[2] = 6; cone[3] = 13;
1481 cone[4] = 20; cone[5] = 15; cone[6] = 12; cone[7] = 9;
1482 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1482,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1483 }
1484 }
1485 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1485,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1486 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1486,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1487 }
1488 /* Interpolate */
1489 {
1490 DM idm;
1491
1492 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1492,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1493 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1493,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1494 *dm = idm;
1495 }
1496 /* Create cube geometry */
1497 {
1498 Vec coordinates;
1499 PetscSection coordSection;
1500 PetscScalar *coords;
1501 PetscInt coordSize, v;
1502 const PetscReal dis = 1.0/PetscSqrtReal(2.0)sqrt(2.0);
1503 const PetscReal ds2 = dis/2.0;
1504
1505 /* Build coordinates */
1506 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1506,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1507 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1507,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1508 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1508,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1509 ierr = PetscSectionSetChart(coordSection, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1509,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1510 for (v = numCells; v < numCells+numVertices; ++v) {
1511 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1511,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1512 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1512,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1513 }
1514 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1514,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1515 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1515,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1516 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1516,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1517 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1517,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1518 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1518,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1519 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1519,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1520 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1520,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1521 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1521,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1522 if (!rank) {
1523 coords[0*dim+0] = -ds2; coords[0*dim+1] = -ds2; coords[0*dim+2] = 0.0;
1524 coords[1*dim+0] = ds2; coords[1*dim+1] = -ds2; coords[1*dim+2] = 0.0;
1525 coords[2*dim+0] = ds2; coords[2*dim+1] = ds2; coords[2*dim+2] = 0.0;
1526 coords[3*dim+0] = -ds2; coords[3*dim+1] = ds2; coords[3*dim+2] = 0.0;
1527 coords[4*dim+0] = -ds2; coords[4*dim+1] = -ds2; coords[4*dim+2] = 1.0;
1528 coords[5*dim+0] = -ds2; coords[5*dim+1] = ds2; coords[5*dim+2] = 1.0;
1529 coords[6*dim+0] = ds2; coords[6*dim+1] = ds2; coords[6*dim+2] = 1.0;
1530 coords[7*dim+0] = ds2; coords[7*dim+1] = -ds2; coords[7*dim+2] = 1.0;
1531 coords[ 8*dim+0] = dis; coords[ 8*dim+1] = -dis; coords[ 8*dim+2] = 0.0;
1532 coords[ 9*dim+0] = dis; coords[ 9*dim+1] = dis; coords[ 9*dim+2] = 0.0;
1533 coords[10*dim+0] = dis; coords[10*dim+1] = -dis; coords[10*dim+2] = 1.0;
1534 coords[11*dim+0] = dis; coords[11*dim+1] = dis; coords[11*dim+2] = 1.0;
1535 coords[12*dim+0] = -dis; coords[12*dim+1] = dis; coords[12*dim+2] = 0.0;
1536 coords[13*dim+0] = -dis; coords[13*dim+1] = dis; coords[13*dim+2] = 1.0;
1537 coords[14*dim+0] = -dis; coords[14*dim+1] = -dis; coords[14*dim+2] = 0.0;
1538 coords[15*dim+0] = -dis; coords[15*dim+1] = -dis; coords[15*dim+2] = 1.0;
1539 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1540 /* 15 31 19 */ coords[16*dim+0] = -ds2; coords[16*dim+1] = -ds2; coords[16*dim+2] = 0.5;
1541 /* 16 32 22 */ coords[17*dim+0] = ds2; coords[17*dim+1] = -ds2; coords[17*dim+2] = 0.5;
1542 /* 17 33 21 */ coords[18*dim+0] = ds2; coords[18*dim+1] = ds2; coords[18*dim+2] = 0.5;
1543 /* 18 34 20 */ coords[19*dim+0] = -ds2; coords[19*dim+1] = ds2; coords[19*dim+2] = 0.5;
1544 /* 29 35 30 */ coords[20*dim+0] = -dis; coords[20*dim+1] = -dis; coords[20*dim+2] = 0.5;
1545 /* 23 36 25 */ coords[21*dim+0] = dis; coords[21*dim+1] = -dis; coords[21*dim+2] = 0.5;
1546 /* 24 37 26 */ coords[22*dim+0] = dis; coords[22*dim+1] = dis; coords[22*dim+2] = 0.5;
1547 /* 27 38 28 */ coords[23*dim+0] = -dis; coords[23*dim+1] = dis; coords[23*dim+2] = 0.5;
1548 }
1549 }
1550 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1550,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1551 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1551,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1552 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1552,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1553 }
1554 /* Create periodicity */
1555 if (periodicZ == DM_BOUNDARY_PERIODIC || periodicZ == DM_BOUNDARY_TWIST) {
1556 PetscReal L[3];
1557 PetscReal maxCell[3];
1558 DMBoundaryType bdType[3];
1559 PetscReal lower[3] = {0.0, 0.0, 0.0};
1560 PetscReal upper[3] = {1.0, 1.0, 1.5};
1561 PetscInt i, numZCells = 3;
1562
1563 bdType[0] = DM_BOUNDARY_NONE;
1564 bdType[1] = DM_BOUNDARY_NONE;
1565 bdType[2] = periodicZ;
1566 for (i = 0; i < dim; i++) {
1567 L[i] = upper[i] - lower[i];
1568 maxCell[i] = 1.1 * (L[i] / numZCells);
1569 }
1570 ierr = DMSetPeriodicity(*dm, PETSC_TRUE, maxCell, L, bdType);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1570,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1571 }
1572 /* Refine topology */
1573 for (r = 0; r < numRefine; ++r) {
1574 DM rdm = NULL((void*)0);
1575
1576 ierr = DMRefine(*dm, comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1576,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1577 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1577,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1578 *dm = rdm;
1579 }
1580 /* Remap geometry to cylinder
1581 Interior square: Linear interpolation is correct
1582 The other cells all have vertices on rays from the origin. We want to uniformly expand the spacing
1583 such that the last vertex is on the unit circle. So the closest and farthest vertices are at distance
1584
1585 phi = arctan(y/x)
1586 d_close = sqrt(1/8 + 1/4 sin^2(phi))
1587 d_far = sqrt(1/2 + sin^2(phi))
1588
1589 so we remap them using
1590
1591 x_new = x_close + (x - x_close) (1 - d_close) / (d_far - d_close)
1592 y_new = y_close + (y - y_close) (1 - d_close) / (d_far - d_close)
1593
1594 If pi/4 < phi < 3pi/4 or -3pi/4 < phi < -pi/4, then we switch x and y.
1595 */
1596 {
1597 Vec coordinates;
1598 PetscSection coordSection;
1599 PetscScalar *coords;
1600 PetscInt vStart, vEnd, v;
1601 const PetscReal dis = 1.0/PetscSqrtReal(2.0)sqrt(2.0);
1602 const PetscReal ds2 = 0.5*dis;
1603
1604 ierr = DMPlexGetDepthStratum(*dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1604,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1605 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1605,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1606 ierr = DMGetCoordinatesLocal(*dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1606,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1607 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1607,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1608 for (v = vStart; v < vEnd; ++v) {
1609 PetscReal phi, sinp, cosp, dc, df, x, y, xc, yc;
1610 PetscInt off;
1611
1612 ierr = PetscSectionGetOffset(coordSection, v, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1612,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1613 if ((PetscAbsScalar(coords[off+0]) <= ds2) && (PetscAbsScalar(coords[off+1]) <= ds2)) continue;
1614 x = PetscRealPart(coords[off])(coords[off]);
1615 y = PetscRealPart(coords[off+1])(coords[off+1]);
1616 phi = PetscAtan2Real(y, x)atan2(y,x);
1617 sinp = PetscSinReal(phi)sin(phi);
1618 cosp = PetscCosReal(phi)cos(phi);
1619 if ((PetscAbsReal(phi)fabs(phi) > PETSC_PI3.1415926535897932384626433832795029/4.0) && (PetscAbsReal(phi)fabs(phi) < 3.0*PETSC_PI3.1415926535897932384626433832795029/4.0)) {
1620 dc = PetscAbsReal(ds2/sinp)fabs(ds2/sinp);
1621 df = PetscAbsReal(dis/sinp)fabs(dis/sinp);
1622 xc = ds2*x/PetscAbsReal(y)fabs(y);
1623 yc = ds2*PetscSignReal(y)(((y) >= 0.0) ? ((y) == 0.0 ? 0.0 : 1.0) : -1.0);
1624 } else {
1625 dc = PetscAbsReal(ds2/cosp)fabs(ds2/cosp);
1626 df = PetscAbsReal(dis/cosp)fabs(dis/cosp);
1627 xc = ds2*PetscSignReal(x)(((x) >= 0.0) ? ((x) == 0.0 ? 0.0 : 1.0) : -1.0);
1628 yc = ds2*y/PetscAbsReal(x)fabs(x);
1629 }
1630 coords[off+0] = xc + (coords[off+0] - xc)*(1.0 - dc)/(df - dc);
1631 coords[off+1] = yc + (coords[off+1] - yc)*(1.0 - dc)/(df - dc);
1632 }
1633 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1633,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1634 if (periodicZ == DM_BOUNDARY_PERIODIC || periodicZ == DM_BOUNDARY_TWIST) {
1635 ierr = DMLocalizeCoordinates(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1635,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1636 }
1637 }
1638 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)
;
1639}
1640
1641/*@
1642 DMPlexCreateWedgeCylinderMesh - Creates a mesh on the tensor product of the unit interval with the circle (cylinder) using wedges.
1643
1644 Collective on MPI_Comm
1645
1646 Input Parameters:
1647+ comm - The communicator for the DM object
1648. n - The number of wedges around the origin
1649- interpolate - Create edges and faces
1650
1651 Output Parameter:
1652. dm - The DM object
1653
1654 Level: beginner
1655
1656.keywords: DM, create
1657.seealso: DMPlexCreateHexCylinderMesh(), DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1658@*/
1659PetscErrorCode DMPlexCreateWedgeCylinderMesh(MPI_Comm comm, PetscInt n, PetscBool interpolate, DM *dm)
1660{
1661 const PetscInt dim = 3;
1662 PetscInt numCells, numVertices;
1663 PetscMPIInt rank;
1664 PetscErrorCode ierr;
1665
1666 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1666; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1667 PetscValidPointer(dm, 3)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1667,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),1667,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0)
;
1668 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1668,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1669 if (n < 0) SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Number of wedges %D cannot be negative", n)return PetscError(comm,1669,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Number of wedges %D cannot be negative"
,n)
;
1670 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1670,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1671 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1671,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1672 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1672,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1673 /* Create topology */
1674 {
1675 PetscInt cone[6], c;
1676
1677 numCells = !rank ? n : 0;
1678 numVertices = !rank ? 2*(n+1) : 0;
1679 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1679,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1680 ierr = DMPlexSetHybridBounds(*dm, 0, PETSC_DETERMINE-1, PETSC_DETERMINE-1, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1680,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1681 for (c = 0; c < numCells; c++) {ierr = DMPlexSetConeSize(*dm, c, 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1681,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1682 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1682,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1683 for (c = 0; c < numCells; c++) {
1684 cone[0] = c+n*1; cone[1] = (c+1)%n+n*1; cone[2] = 0+3*n;
1685 cone[3] = c+n*2; cone[4] = (c+1)%n+n*2; cone[5] = 1+3*n;
1686 ierr = DMPlexSetCone(*dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1686,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1687 }
1688 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1688,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1689 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1689,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1690 }
1691 /* Interpolate */
1692 if (interpolate) {
1693 DM idm;
1694
1695 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1695,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1696 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1696,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1697 *dm = idm;
1698 }
1699 /* Create cylinder geometry */
1700 {
1701 Vec coordinates;
1702 PetscSection coordSection;
1703 PetscScalar *coords;
1704 PetscInt coordSize, v, c;
1705
1706 /* Build coordinates */
1707 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1707,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1708 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1708,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1709 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1709,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1710 ierr = PetscSectionSetChart(coordSection, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1710,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1711 for (v = numCells; v < numCells+numVertices; ++v) {
1712 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1712,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1713 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1713,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1714 }
1715 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1715,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1716 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1716,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1717 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1717,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1718 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1718,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1719 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1719,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1720 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1720,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1721 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1721,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1722 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1722,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1723 for (c = 0; c < numCells; c++) {
1724 coords[(c+0*n)*dim+0] = PetscCosReal(2.0*c*PETSC_PI/n)cos(2.0*c*3.1415926535897932384626433832795029/n); coords[(c+0*n)*dim+1] = PetscSinReal(2.0*c*PETSC_PI/n)sin(2.0*c*3.1415926535897932384626433832795029/n); coords[(c+0*n)*dim+2] = 1.0;
1725 coords[(c+1*n)*dim+0] = PetscCosReal(2.0*c*PETSC_PI/n)cos(2.0*c*3.1415926535897932384626433832795029/n); coords[(c+1*n)*dim+1] = PetscSinReal(2.0*c*PETSC_PI/n)sin(2.0*c*3.1415926535897932384626433832795029/n); coords[(c+1*n)*dim+2] = 0.0;
1726 }
1727 if (!rank) {
1728 coords[(2*n+0)*dim+0] = 0.0; coords[(2*n+0)*dim+1] = 0.0; coords[(2*n+0)*dim+2] = 1.0;
1729 coords[(2*n+1)*dim+0] = 0.0; coords[(2*n+1)*dim+1] = 0.0; coords[(2*n+1)*dim+2] = 0.0;
1730 }
1731 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1731,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1732 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1732,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1733 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1733,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1734 }
1735 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)
;
1736}
1737
1738PETSC_STATIC_INLINEstatic inline PetscReal DiffNormReal(PetscInt dim, const PetscReal x[], const PetscReal y[])
1739{
1740 PetscReal prod = 0.0;
1741 PetscInt i;
1742 for (i = 0; i < dim; ++i) prod += PetscSqr(x[i] - y[i])((x[i] - y[i])*(x[i] - y[i]));
1743 return PetscSqrtReal(prod)sqrt(prod);
1744}
1745PETSC_STATIC_INLINEstatic inline PetscReal DotReal(PetscInt dim, const PetscReal x[], const PetscReal y[])
1746{
1747 PetscReal prod = 0.0;
1748 PetscInt i;
1749 for (i = 0; i < dim; ++i) prod += x[i]*y[i];
1750 return prod;
1751}
1752
1753/*@
1754 DMPlexCreateSphereMesh - Creates a mesh on the d-dimensional sphere, S^d.
1755
1756 Collective on MPI_Comm
1757
1758 Input Parameters:
1759. comm - The communicator for the DM object
1760. dim - The dimension
1761- simplex - Use simplices, or tensor product cells
1762
1763 Output Parameter:
1764. dm - The DM object
1765
1766 Level: beginner
1767
1768.keywords: DM, create
1769.seealso: DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1770@*/
1771PetscErrorCode DMPlexCreateSphereMesh(MPI_Comm comm, PetscInt dim, PetscBool simplex, DM *dm)
1772{
1773 const PetscInt embedDim = dim+1;
1774 PetscSection coordSection;
1775 Vec coordinates;
1776 PetscScalar *coords;
1777 PetscReal *coordsIn;
1778 PetscInt numCells, numEdges, numVerts, firstVertex, v, firstEdge, coordSize, d, c, e;
1779 PetscMPIInt rank;
1780 PetscErrorCode ierr;
1781
1782 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1782; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1783 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1783,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),1783,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
1784 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1784,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1785 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1785,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1786 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1786,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1787 ierr = DMSetCoordinateDim(*dm, dim+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1787,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1788 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject) *dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1788,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1789 switch (dim) {
1790 case 2:
1791 if (simplex) {
1792 DM idm;
1793 const PetscReal edgeLen = 2.0/(1.0 + PETSC_PHI1.6180339887498948482045868343656381);
1794 const PetscReal vertex[3] = {0.0, 1.0/(1.0 + PETSC_PHI1.6180339887498948482045868343656381), PETSC_PHI1.6180339887498948482045868343656381/(1.0 + PETSC_PHI1.6180339887498948482045868343656381)};
1795 const PetscInt degree = 5;
1796 PetscInt s[3] = {1, 1, 1};
1797 PetscInt cone[3];
1798 PetscInt *graph, p, i, j, k;
1799
1800 numCells = !rank ? 20 : 0;
1801 numVerts = !rank ? 12 : 0;
1802 firstVertex = numCells;
1803 /* Use icosahedron, which for a unit sphere has coordinates which are all cyclic permutations of
1804
1805 (0, \pm 1/\phi+1, \pm \phi/\phi+1)
1806
1807 where \phi^2 - \phi - 1 = 0, meaning \phi is the golden ratio \frac{1 + \sqrt{5}}{2}. The edge
1808 length is then given by 2/\phi = 2 * 2.73606 = 5.47214.
1809 */
1810 /* Construct vertices */
1811 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,1811,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerts * embedDim)*sizeof(**(&coordsIn)),(&
coordsIn))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1811,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1812 for (p = 0, i = 0; p < embedDim; ++p) {
1813 for (s[1] = -1; s[1] < 2; s[1] += 2) {
1814 for (s[2] = -1; s[2] < 2; s[2] += 2) {
1815 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[(d+p)%embedDim]*vertex[(d+p)%embedDim];
1816 ++i;
1817 }
1818 }
1819 }
1820 /* Construct graph */
1821 ierr = PetscCalloc1(numVerts * numVerts, &graph)PetscMallocA(1,PETSC_TRUE,1821,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerts * numVerts)*sizeof(**(&graph)),(&graph
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1821,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1822 for (i = 0; i < numVerts; ++i) {
1823 for (j = 0, k = 0; j < numVerts; ++j) {
1824 if (PetscAbsReal(DiffNormReal(embedDim, &coordsIn[i*embedDim], &coordsIn[j*embedDim]) - edgeLen)fabs(DiffNormReal(embedDim, &coordsIn[i*embedDim], &coordsIn
[j*embedDim]) - edgeLen)
< PETSC_SMALL1.e-10) {graph[i*numVerts+j] = 1; ++k;}
1825 }
1826 if (k != degree) SETERRQ3(comm, PETSC_ERR_PLIB, "Invalid icosahedron, vertex %D degree %D != %D", i, k, degree)return PetscError(comm,1826,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid icosahedron, vertex %D degree %D != %D"
,i,k,degree)
;
1827 }
1828 /* Build Topology */
1829 ierr = DMPlexSetChart(*dm, 0, numCells+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1829,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1830 for (c = 0; c < numCells; c++) {
1831 ierr = DMPlexSetConeSize(*dm, c, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1831,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1832 }
1833 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1833,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
1834 /* Cells */
1835 for (i = 0, c = 0; i < numVerts; ++i) {
1836 for (j = 0; j < i; ++j) {
1837 for (k = 0; k < j; ++k) {
1838 if (graph[i*numVerts+j] && graph[j*numVerts+k] && graph[k*numVerts+i]) {
1839 cone[0] = firstVertex+i; cone[1] = firstVertex+j; cone[2] = firstVertex+k;
1840 /* Check orientation */
1841 {
1842 const PetscInt epsilon[3][3][3] = {{{0, 0, 0}, {0, 0, 1}, {0, -1, 0}}, {{0, 0, -1}, {0, 0, 0}, {1, 0, 0}}, {{0, 1, 0}, {-1, 0, 0}, {0, 0, 0}}};
1843 PetscReal normal[3];
1844 PetscInt e, f;
1845
1846 for (d = 0; d < embedDim; ++d) {
1847 normal[d] = 0.0;
1848 for (e = 0; e < embedDim; ++e) {
1849 for (f = 0; f < embedDim; ++f) {
1850 normal[d] += epsilon[d][e][f]*(coordsIn[j*embedDim+e] - coordsIn[i*embedDim+e])*(coordsIn[k*embedDim+f] - coordsIn[i*embedDim+f]);
1851 }
1852 }
1853 }
1854 if (DotReal(embedDim, normal, &coordsIn[i*embedDim]) < 0) {PetscInt tmp = cone[1]; cone[1] = cone[2]; cone[2] = tmp;}
1855 }
1856 ierr = DMPlexSetCone(*dm, c++, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1856,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1857 }
1858 }
1859 }
1860 }
1861 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1861,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1862 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1862,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1863 ierr = PetscFree(graph)((*PetscTrFree)((void*)(graph),1863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((graph) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1864 /* Interpolate mesh */
1865 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1865,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1866 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1866,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1867 *dm = idm;
1868 } else {
1869 /*
1870 12-21--13
1871 | |
1872 25 4 24
1873 | |
1874 12-25--9-16--8-24--13
1875 | | | |
1876 23 5 17 0 15 3 22
1877 | | | |
1878 10-20--6-14--7-19--11
1879 | |
1880 20 1 19
1881 | |
1882 10-18--11
1883 | |
1884 23 2 22
1885 | |
1886 12-21--13
1887 */
1888 const PetscReal dist = 1.0/PetscSqrtReal(3.0)sqrt(3.0);
1889 PetscInt cone[4], ornt[4];
1890
1891 numCells = !rank ? 6 : 0;
1892 numEdges = !rank ? 12 : 0;
1893 numVerts = !rank ? 8 : 0;
1894 firstVertex = numCells;
1895 firstEdge = numCells + numVerts;
1896 /* Build Topology */
1897 ierr = DMPlexSetChart(*dm, 0, numCells+numEdges+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1897,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1898 for (c = 0; c < numCells; c++) {
1899 ierr = DMPlexSetConeSize(*dm, c, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1899,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1900 }
1901 for (e = firstEdge; e < firstEdge+numEdges; ++e) {
1902 ierr = DMPlexSetConeSize(*dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1902,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1903 }
1904 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1904,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
1905 /* Cell 0 */
1906 cone[0] = 14; cone[1] = 15; cone[2] = 16; cone[3] = 17;
1907 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1907,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1908 ornt[0] = 0; ornt[1] = 0; ornt[2] = 0; ornt[3] = 0;
1909 ierr = DMPlexSetConeOrientation(*dm, 0, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1909,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1910 /* Cell 1 */
1911 cone[0] = 18; cone[1] = 19; cone[2] = 14; cone[3] = 20;
1912 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1912,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1913 ornt[0] = 0; ornt[1] = 0; ornt[2] = -2; ornt[3] = 0;
1914 ierr = DMPlexSetConeOrientation(*dm, 1, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1914,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1915 /* Cell 2 */
1916 cone[0] = 21; cone[1] = 22; cone[2] = 18; cone[3] = 23;
1917 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1917,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1918 ornt[0] = 0; ornt[1] = 0; ornt[2] = -2; ornt[3] = 0;
1919 ierr = DMPlexSetConeOrientation(*dm, 2, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1919,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1920 /* Cell 3 */
1921 cone[0] = 19; cone[1] = 22; cone[2] = 24; cone[3] = 15;
1922 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1922,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1923 ornt[0] = -2; ornt[1] = -2; ornt[2] = 0; ornt[3] = -2;
1924 ierr = DMPlexSetConeOrientation(*dm, 3, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1924,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1925 /* Cell 4 */
1926 cone[0] = 16; cone[1] = 24; cone[2] = 21; cone[3] = 25;
1927 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1927,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1928 ornt[0] = -2; ornt[1] = -2; ornt[2] = -2; ornt[3] = 0;
1929 ierr = DMPlexSetConeOrientation(*dm, 4, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1929,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1930 /* Cell 5 */
1931 cone[0] = 20; cone[1] = 17; cone[2] = 25; cone[3] = 23;
1932 ierr = DMPlexSetCone(*dm, 5, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1932,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1933 ornt[0] = -2; ornt[1] = -2; ornt[2] = -2; ornt[3] = -2;
1934 ierr = DMPlexSetConeOrientation(*dm, 5, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1934,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1935 /* Edges */
1936 cone[0] = 6; cone[1] = 7;
1937 ierr = DMPlexSetCone(*dm, 14, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1937,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1938 cone[0] = 7; cone[1] = 8;
1939 ierr = DMPlexSetCone(*dm, 15, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1939,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1940 cone[0] = 8; cone[1] = 9;
1941 ierr = DMPlexSetCone(*dm, 16, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1941,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1942 cone[0] = 9; cone[1] = 6;
1943 ierr = DMPlexSetCone(*dm, 17, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1943,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1944 cone[0] = 10; cone[1] = 11;
1945 ierr = DMPlexSetCone(*dm, 18, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1945,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1946 cone[0] = 11; cone[1] = 7;
1947 ierr = DMPlexSetCone(*dm, 19, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1947,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1948 cone[0] = 6; cone[1] = 10;
1949 ierr = DMPlexSetCone(*dm, 20, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1949,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1950 cone[0] = 12; cone[1] = 13;
1951 ierr = DMPlexSetCone(*dm, 21, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1951,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1952 cone[0] = 13; cone[1] = 11;
1953 ierr = DMPlexSetCone(*dm, 22, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1953,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1954 cone[0] = 10; cone[1] = 12;
1955 ierr = DMPlexSetCone(*dm, 23, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1955,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1956 cone[0] = 13; cone[1] = 8;
1957 ierr = DMPlexSetCone(*dm, 24, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1957,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1958 cone[0] = 12; cone[1] = 9;
1959 ierr = DMPlexSetCone(*dm, 25, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1959,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1960 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1960,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1961 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1961,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1962 /* Build coordinates */
1963 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,1963,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerts * embedDim)*sizeof(**(&coordsIn)),(&
coordsIn))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1963,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1964 coordsIn[0*embedDim+0] = -dist; coordsIn[0*embedDim+1] = dist; coordsIn[0*embedDim+2] = -dist;
1965 coordsIn[1*embedDim+0] = dist; coordsIn[1*embedDim+1] = dist; coordsIn[1*embedDim+2] = -dist;
1966 coordsIn[2*embedDim+0] = dist; coordsIn[2*embedDim+1] = -dist; coordsIn[2*embedDim+2] = -dist;
1967 coordsIn[3*embedDim+0] = -dist; coordsIn[3*embedDim+1] = -dist; coordsIn[3*embedDim+2] = -dist;
1968 coordsIn[4*embedDim+0] = -dist; coordsIn[4*embedDim+1] = dist; coordsIn[4*embedDim+2] = dist;
1969 coordsIn[5*embedDim+0] = dist; coordsIn[5*embedDim+1] = dist; coordsIn[5*embedDim+2] = dist;
1970 coordsIn[6*embedDim+0] = -dist; coordsIn[6*embedDim+1] = -dist; coordsIn[6*embedDim+2] = dist;
1971 coordsIn[7*embedDim+0] = dist; coordsIn[7*embedDim+1] = -dist; coordsIn[7*embedDim+2] = dist;
1972 }
1973 break;
1974 case 3:
1975 if (simplex) {
1976 DM idm;
1977 const PetscReal edgeLen = 1.0/PETSC_PHI1.6180339887498948482045868343656381;
1978 const PetscReal vertexA[4] = {0.5, 0.5, 0.5, 0.5};
1979 const PetscReal vertexB[4] = {1.0, 0.0, 0.0, 0.0};
1980 const PetscReal vertexC[4] = {0.5, 0.5*PETSC_PHI1.6180339887498948482045868343656381, 0.5/PETSC_PHI1.6180339887498948482045868343656381, 0.0};
1981 const PetscInt degree = 12;
1982 PetscInt s[4] = {1, 1, 1};
1983 PetscInt evenPerm[12][4] = {{0, 1, 2, 3}, {0, 2, 3, 1}, {0, 3, 1, 2}, {1, 0, 3, 2}, {1, 2, 0, 3}, {1, 3, 2, 0},
1984 {2, 0, 1, 3}, {2, 1, 3, 0}, {2, 3, 0, 1}, {3, 0, 2, 1}, {3, 1, 0, 2}, {3, 2, 1, 0}};
1985 PetscInt cone[4];
1986 PetscInt *graph, p, i, j, k, l;
1987
1988 numCells = !rank ? 600 : 0;
1989 numVerts = !rank ? 120 : 0;
1990 firstVertex = numCells;
1991 /* Use the 600-cell, which for a unit sphere has coordinates which are
1992
1993 1/2 (\pm 1, \pm 1, \pm 1, \pm 1) 16
1994 (\pm 1, 0, 0, 0) all cyclic permutations 8
1995 1/2 (\pm 1, \pm phi, \pm 1/phi, 0) all even permutations 96
1996
1997 where \phi^2 - \phi - 1 = 0, meaning \phi is the golden ratio \frac{1 + \sqrt{5}}{2}. The edge
1998 length is then given by 1/\phi = 2.73606.
1999
2000 http://buzzard.pugetsound.edu/sage-practice/ch03s03.html
2001 http://mathworld.wolfram.com/600-Cell.html
2002 */
2003 /* Construct vertices */
2004 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,2004,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerts * embedDim)*sizeof(**(&coordsIn)),(&
coordsIn))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2004,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2005 i = 0;
2006 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2007 for (s[1] = -1; s[1] < 2; s[1] += 2) {
2008 for (s[2] = -1; s[2] < 2; s[2] += 2) {
2009 for (s[3] = -1; s[3] < 2; s[3] += 2) {
2010 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[d]*vertexA[d];
2011 ++i;
2012 }
2013 }
2014 }
2015 }
2016 for (p = 0; p < embedDim; ++p) {
2017 s[1] = s[2] = s[3] = 1;
2018 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2019 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[(d+p)%embedDim]*vertexB[(d+p)%embedDim];
2020 ++i;
2021 }
2022 }
2023 for (p = 0; p < 12; ++p) {
2024 s[3] = 1;
2025 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2026 for (s[1] = -1; s[1] < 2; s[1] += 2) {
2027 for (s[2] = -1; s[2] < 2; s[2] += 2) {
2028 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[evenPerm[p][d]]*vertexC[evenPerm[p][d]];
2029 ++i;
2030 }
2031 }
2032 }
2033 }
2034 if (i != numVerts) SETERRQ2(comm, PETSC_ERR_PLIB, "Invalid 600-cell, vertices %D != %D", i, numVerts)return PetscError(comm,2034,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid 600-cell, vertices %D != %D"
,i,numVerts)
;
2035 /* Construct graph */
2036 ierr = PetscCalloc1(numVerts * numVerts, &graph)PetscMallocA(1,PETSC_TRUE,2036,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerts * numVerts)*sizeof(**(&graph)),(&graph
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2036,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2037 for (i = 0; i < numVerts; ++i) {
2038 for (j = 0, k = 0; j < numVerts; ++j) {
2039 if (PetscAbsReal(DiffNormReal(embedDim, &coordsIn[i*embedDim], &coordsIn[j*embedDim]) - edgeLen)fabs(DiffNormReal(embedDim, &coordsIn[i*embedDim], &coordsIn
[j*embedDim]) - edgeLen)
< PETSC_SMALL1.e-10) {graph[i*numVerts+j] = 1; ++k;}
2040 }
2041 if (k != degree) SETERRQ3(comm, PETSC_ERR_PLIB, "Invalid 600-cell, vertex %D degree %D != %D", i, k, degree)return PetscError(comm,2041,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid 600-cell, vertex %D degree %D != %D"
,i,k,degree)
;
2042 }
2043 /* Build Topology */
2044 ierr = DMPlexSetChart(*dm, 0, numCells+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2044,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2045 for (c = 0; c < numCells; c++) {
2046 ierr = DMPlexSetConeSize(*dm, c, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2046,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2047 }
2048 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2048,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
2049 /* Cells */
2050 for (i = 0, c = 0; i < numVerts; ++i) {
2051 for (j = 0; j < i; ++j) {
2052 for (k = 0; k < j; ++k) {
2053 for (l = 0; l < k; ++l) {
2054 if (graph[i*numVerts+j] && graph[j*numVerts+k] && graph[k*numVerts+i] &&
2055 graph[l*numVerts+i] && graph[l*numVerts+j] && graph[l*numVerts+k]) {
2056 cone[0] = firstVertex+i; cone[1] = firstVertex+j; cone[2] = firstVertex+k; cone[3] = firstVertex+l;
2057 /* Check orientation: https://ef.gy/linear-algebra:normal-vectors-in-higher-dimensional-spaces */
2058 {
2059 const PetscInt epsilon[4][4][4][4] = {{{{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2060 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 1}, { 0, 0, -1, 0}},
2061 {{0, 0, 0, 0}, { 0, 0, 0, -1}, { 0, 0, 0, 0}, { 0, 1, 0, 0}},
2062 {{0, 0, 0, 0}, { 0, 0, 1, 0}, { 0, -1, 0, 0}, { 0, 0, 0, 0}}},
2063
2064 {{{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, -1}, { 0, 0, 1, 0}},
2065 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2066 {{0, 0, 0, 1}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, {-1, 0, 0, 0}},
2067 {{0, 0, -1, 0}, { 0, 0, 0, 0}, { 1, 0, 0, 0}, { 0, 0, 0, 0}}},
2068
2069 {{{0, 0, 0, 0}, { 0, 0, 0, 1}, { 0, 0, 0, 0}, { 0, -1, 0, 0}},
2070 {{0, 0, 0, -1}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 1, 0, 0, 0}},
2071 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2072 {{0, 1, 0, 0}, {-1, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}}},
2073
2074 {{{0, 0, 0, 0}, { 0, 0, -1, 0}, { 0, 1, 0, 0}, { 0, 0, 0, 0}},
2075 {{0, 0, 1, 0}, { 0, 0, 0, 0}, {-1, 0, 0, 0}, { 0, 0, 0, 0}},
2076 {{0, -1, 0, 0}, { 1, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2077 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}}}};
2078 PetscReal normal[4];
2079 PetscInt e, f, g;
2080
2081 for (d = 0; d < embedDim; ++d) {
2082 normal[d] = 0.0;
2083 for (e = 0; e < embedDim; ++e) {
2084 for (f = 0; f < embedDim; ++f) {
2085 for (g = 0; g < embedDim; ++g) {
2086 normal[d] += epsilon[d][e][f][g]*(coordsIn[j*embedDim+e] - coordsIn[i*embedDim+e])*(coordsIn[k*embedDim+f] - coordsIn[i*embedDim+f])*(coordsIn[l*embedDim+f] - coordsIn[i*embedDim+f]);
2087 }
2088 }
2089 }
2090 }
2091 if (DotReal(embedDim, normal, &coordsIn[i*embedDim]) < 0) {PetscInt tmp = cone[1]; cone[1] = cone[2]; cone[2] = tmp;}
2092 }
2093 ierr = DMPlexSetCone(*dm, c++, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2093,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2094 }
2095 }
2096 }
2097 }
2098 }
2099 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2099,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2100 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2100,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2101 ierr = PetscFree(graph)((*PetscTrFree)((void*)(graph),2101,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((graph) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2101,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2102 /* Interpolate mesh */
2103 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2103,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2104 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2104,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2105 *dm = idm;
2106 break;
2107 }
2108 default: SETERRQ1(comm, PETSC_ERR_SUP, "Unsupported dimension for sphere: %D", dim)return PetscError(comm,2108,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Unsupported dimension for sphere: %D"
,dim)
;
2109 }
2110 /* Create coordinates */
2111 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2111,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2112 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2112,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2113 ierr = PetscSectionSetFieldComponents(coordSection, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2113,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2114 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2114,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2115 for (v = firstVertex; v < firstVertex+numVerts; ++v) {
2116 ierr = PetscSectionSetDof(coordSection, v, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2116,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2117 ierr = PetscSectionSetFieldDof(coordSection, v, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2117,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2118 }
2119 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2119,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2120 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2120,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2121 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2121,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2122 ierr = VecSetBlockSize(coordinates, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2122,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2123 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2123,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2124 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2124,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2125 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2125,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2126 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2126,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2127 for (v = 0; v < numVerts; ++v) for (d = 0; d < embedDim; ++d) {coords[v*embedDim+d] = coordsIn[v*embedDim+d];}
2128 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2128,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2129 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2129,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2130 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2130,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2131 ierr = PetscFree(coordsIn)((*PetscTrFree)((void*)(coordsIn),2131,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((coordsIn) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2131,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2132 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)
;
2133}
2134
2135/* External function declarations here */
2136extern PetscErrorCode DMCreateInterpolation_Plex(DM dmCoarse, DM dmFine, Mat *interpolation, Vec *scaling);
2137extern PetscErrorCode DMCreateInjection_Plex(DM dmCoarse, DM dmFine, Mat *mat);
2138extern PetscErrorCode DMCreateMassMatrix_Plex(DM dmCoarse, DM dmFine, Mat *mat);
2139extern PetscErrorCode DMCreateDefaultSection_Plex(DM dm);
2140extern PetscErrorCode DMCreateDefaultConstraints_Plex(DM dm);
2141extern PetscErrorCode DMCreateMatrix_Plex(DM dm, Mat *J);
2142extern PetscErrorCode DMCreateCoordinateDM_Plex(DM dm, DM *cdm);
2143extern PetscErrorCode DMCreateCoordinateField_Plex(DM dm, DMField *field);
2144PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMClone_Plex(DM dm, DM *newdm);
2145extern PetscErrorCode DMSetUp_Plex(DM dm);
2146extern PetscErrorCode DMDestroy_Plex(DM dm);
2147extern PetscErrorCode DMView_Plex(DM dm, PetscViewer viewer);
2148extern PetscErrorCode DMLoad_Plex(DM dm, PetscViewer viewer);
2149extern PetscErrorCode DMCreateSubDM_Plex(DM dm, PetscInt numFields, const PetscInt fields[], IS *is, DM *subdm);
2150extern PetscErrorCode DMCreateSuperDM_Plex(DM dms[], PetscInt len, IS **is, DM *superdm);
2151static PetscErrorCode DMInitialize_Plex(DM dm);
2152
2153/* Replace dm with the contents of dmNew
2154 - Share the DM_Plex structure
2155 - Share the coordinates
2156 - Share the SF
2157*/
2158static PetscErrorCode DMPlexReplace_Static(DM dm, DM dmNew)
2159{
2160 PetscSF sf;
2161 DM coordDM, coarseDM;
2162 Vec coords;
2163 PetscBool isper;
2164 const PetscReal *maxCell, *L;
2165 const DMBoundaryType *bd;
2166 PetscErrorCode ierr;
2167
2168 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2168; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2169 ierr = DMGetPointSF(dmNew, &sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2169,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2170 ierr = DMSetPointSF(dm, sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2170,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2171 ierr = DMGetCoordinateDM(dmNew, &coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2171,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2172 ierr = DMGetCoordinatesLocal(dmNew, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2172,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2173 ierr = DMSetCoordinateDM(dm, coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2173,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2174 ierr = DMSetCoordinatesLocal(dm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2175 ierr = DMGetPeriodicity(dm, &isper, &maxCell, &L, &bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2175,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2176 ierr = DMSetPeriodicity(dmNew, isper, maxCell, L, bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2176,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2177 ierr = DMDestroy_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2177,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2178 ierr = DMInitialize_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2178,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2179 dm->data = dmNew->data;
2180 ((DM_Plex *) dmNew->data)->refct++;
2181 dmNew->labels->refct++;
2182 if (!--(dm->labels->refct)) {
2183 DMLabelLink next = dm->labels->next;
2184
2185 /* destroy the labels */
2186 while (next) {
2187 DMLabelLink tmp = next->next;
2188
2189 ierr = DMLabelDestroy(&next->label);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2190 ierr = PetscFree(next)((*PetscTrFree)((void*)(next),2190,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((next) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2190,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2191 next = tmp;
2192 }
2193 ierr = PetscFree(dm->labels)((*PetscTrFree)((void*)(dm->labels),2193,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((dm->labels) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2193,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2194 }
2195 dm->labels = dmNew->labels;
2196 dm->depthLabel = dmNew->depthLabel;
2197 ierr = DMGetCoarseDM(dmNew,&coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2197,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2198 ierr = DMSetCoarseDM(dm,coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2198,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2199 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)
;
2200}
2201
2202/* Swap dm with the contents of dmNew
2203 - Swap the DM_Plex structure
2204 - Swap the coordinates
2205 - Swap the point PetscSF
2206*/
2207static PetscErrorCode DMPlexSwap_Static(DM dmA, DM dmB)
2208{
2209 DM coordDMA, coordDMB;
2210 Vec coordsA, coordsB;
2211 PetscSF sfA, sfB;
2212 void *tmp;
2213 DMLabelLinkList listTmp;
2214 DMLabel depthTmp;
2215 PetscInt tmpI;
2216 PetscErrorCode ierr;
2217
2218 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2218; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2219 ierr = DMGetPointSF(dmA, &sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2219,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2220 ierr = DMGetPointSF(dmB, &sfB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2221 ierr = PetscObjectReference((PetscObject) sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2221,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2222 ierr = DMSetPointSF(dmA, sfB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2222,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2223 ierr = DMSetPointSF(dmB, sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2223,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2224 ierr = PetscObjectDereference((PetscObject) sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2224,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2225
2226 ierr = DMGetCoordinateDM(dmA, &coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2226,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2227 ierr = DMGetCoordinateDM(dmB, &coordDMB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2227,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2228 ierr = PetscObjectReference((PetscObject) coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2228,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2229 ierr = DMSetCoordinateDM(dmA, coordDMB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2229,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2230 ierr = DMSetCoordinateDM(dmB, coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2230,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2231 ierr = PetscObjectDereference((PetscObject) coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2231,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2232
2233 ierr = DMGetCoordinatesLocal(dmA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2233,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2234 ierr = DMGetCoordinatesLocal(dmB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2234,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2235 ierr = PetscObjectReference((PetscObject) coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2235,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2236 ierr = DMSetCoordinatesLocal(dmA, coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2236,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2237 ierr = DMSetCoordinatesLocal(dmB, coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2237,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2238 ierr = PetscObjectDereference((PetscObject) coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2238,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2239
2240 tmp = dmA->data;
2241 dmA->data = dmB->data;
2242 dmB->data = tmp;
2243 listTmp = dmA->labels;
2244 dmA->labels = dmB->labels;
2245 dmB->labels = listTmp;
2246 depthTmp = dmA->depthLabel;
2247 dmA->depthLabel = dmB->depthLabel;
2248 dmB->depthLabel = depthTmp;
2249 tmpI = dmA->levelup;
2250 dmA->levelup = dmB->levelup;
2251 dmB->levelup = tmpI;
2252 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)
;
2253}
2254
2255static PetscErrorCode DMPlexIsSimplex_Static(DM dm, PetscBool *isSimplex)
2256{
2257 PetscInt dim, cStart, coneSize;
2258 PetscErrorCode ierr;
2259
2260 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2260; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2261 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2261,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2262 ierr = DMPlexGetHeightStratum(dm, 0, &cStart, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2262,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2263 ierr = DMPlexGetConeSize(dm, cStart, &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2263,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2264 *isSimplex = coneSize == dim+1 ? PETSC_TRUE : PETSC_FALSE;
2265 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)
;
2266}
2267
2268PetscErrorCode DMSetFromOptions_NonRefinement_Plex(PetscOptionItems *PetscOptionsObject,DM dm)
2269{
2270 DM_Plex *mesh = (DM_Plex*) dm->data;
2271 PetscErrorCode ierr;
2272
2273 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2273; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2274 /* Handle viewing */
2275 ierr = PetscOptionsBool("-dm_plex_print_set_values", "Output all set values info", "DMPlexMatSetClosure", PETSC_FALSE, &mesh->printSetValues, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_print_set_values"
,"Output all set values info","DMPlexMatSetClosure",PETSC_FALSE
,&mesh->printSetValues,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2275,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2276 ierr = PetscOptionsInt("-dm_plex_print_fem", "Debug output level all fem computations", "DMPlexSNESComputeResidualFEM", 0, &mesh->printFEM, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-dm_plex_print_fem"
,"Debug output level all fem computations","DMPlexSNESComputeResidualFEM"
,0,&mesh->printFEM,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2276,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2277 ierr = PetscOptionsReal("-dm_plex_print_tol", "Tolerance for FEM output", "DMPlexSNESComputeResidualFEM", mesh->printTol, &mesh->printTol, NULL)PetscOptionsReal_Private(PetscOptionsObject,"-dm_plex_print_tol"
,"Tolerance for FEM output","DMPlexSNESComputeResidualFEM",mesh
->printTol,&mesh->printTol,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2277,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2278 ierr = PetscOptionsInt("-dm_plex_print_l2", "Debug output level all L2 diff computations", "DMComputeL2Diff", 0, &mesh->printL2, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-dm_plex_print_l2"
,"Debug output level all L2 diff computations","DMComputeL2Diff"
,0,&mesh->printL2,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2278,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2279 /* Point Location */
2280 ierr = PetscOptionsBool("-dm_plex_hash_location", "Use grid hashing for point location", "DMInterpolate", PETSC_FALSE, &mesh->useHashLocation, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_hash_location"
,"Use grid hashing for point location","DMInterpolate",PETSC_FALSE
,&mesh->useHashLocation,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2280,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2281 /* Partitioning and distribution */
2282 ierr = PetscOptionsBool("-dm_plex_partition_balance", "Attempt to evenly divide points on partition boundary between processes", "DMPlexSetPartitionBalance", PETSC_FALSE, &mesh->partitionBalance, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_partition_balance"
,"Attempt to evenly divide points on partition boundary between processes"
,"DMPlexSetPartitionBalance",PETSC_FALSE,&mesh->partitionBalance
,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2282,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2283 /* Generation and remeshing */
2284 ierr = PetscOptionsBool("-dm_plex_remesh_bd", "Allow changes to the boundary on remeshing", "DMAdapt", PETSC_FALSE, &mesh->remeshBd, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_remesh_bd"
,"Allow changes to the boundary on remeshing","DMAdapt",PETSC_FALSE
,&mesh->remeshBd,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2284,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2285 /* Projection behavior */
2286 ierr = PetscOptionsInt("-dm_plex_max_projection_height", "Maxmimum mesh point height used to project locally", "DMPlexSetMaxProjectionHeight", 0, &mesh->maxProjectionHeight, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-dm_plex_max_projection_height"
,"Maxmimum mesh point height used to project locally","DMPlexSetMaxProjectionHeight"
,0,&mesh->maxProjectionHeight,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2286,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2287 ierr = PetscOptionsBool("-dm_plex_regular_refinement", "Use special nested projection algorithm for regular refinement", "DMPlexSetRegularRefinement", mesh->regularRefinement, &mesh->regularRefinement, NULL)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_regular_refinement"
,"Use special nested projection algorithm for regular refinement"
,"DMPlexSetRegularRefinement",mesh->regularRefinement,&
mesh->regularRefinement,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2287,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2288 /* Checking structure */
2289 {
2290 const char *cellTypes[] = {"simplex", "tensor", "unknown", "DMPlexCellType", "DM_PLEX_CELLTYPE_", NULL((void*)0)};
2291 PetscEnum ct;
2292 PetscBool flg = PETSC_FALSE, flg2 = PETSC_FALSE;
2293
2294 ierr = PetscOptionsBool("-dm_plex_check_symmetry", "Check that the adjacency information in the mesh is symmetric", "DMPlexCheckSymmetry", PETSC_FALSE, &flg, &flg2)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_check_symmetry"
,"Check that the adjacency information in the mesh is symmetric"
,"DMPlexCheckSymmetry",PETSC_FALSE,&flg,&flg2)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2294,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2295 if (flg && flg2) {ierr = DMPlexCheckSymmetry(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2295,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2296 ierr = PetscOptionsEnum("-dm_plex_check_skeleton", "Check that each cell has the correct number of vertices", "DMPlexCheckSkeleton", cellTypes, (PetscEnum) 0, &ct, &flg)PetscOptionsEnum_Private(PetscOptionsObject,"-dm_plex_check_skeleton"
,"Check that each cell has the correct number of vertices","DMPlexCheckSkeleton"
,cellTypes,(PetscEnum) 0,&ct,&flg)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2296,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2297 if (flg) {
2298 PetscBool isSimplex = ct ? PETSC_FALSE : PETSC_TRUE;
2299
2300 if (ct == (PetscEnum) DM_PLEX_CELLTYPE_UNKNOWN) {ierr = DMPlexIsSimplex_Static(dm, &isSimplex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2300,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2301 ierr = DMPlexCheckSkeleton(dm, isSimplex, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2301,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2302 }
2303 ierr = PetscOptionsEnum("-dm_plex_check_faces", "Check that the faces of each cell give a vertex order this is consistent with what we expect from the cell type", "DMPlexCheckFaces", cellTypes, (PetscEnum) 0, &ct, &flg)PetscOptionsEnum_Private(PetscOptionsObject,"-dm_plex_check_faces"
,"Check that the faces of each cell give a vertex order this is consistent with what we expect from the cell type"
,"DMPlexCheckFaces",cellTypes,(PetscEnum) 0,&ct,&flg)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2303,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2304 if (flg) {
2305 PetscBool isSimplex = ct ? PETSC_FALSE : PETSC_TRUE;
2306
2307 if (ct == (PetscEnum) DM_PLEX_CELLTYPE_UNKNOWN) {ierr = DMPlexIsSimplex_Static(dm, &isSimplex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2307,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2308 ierr = DMPlexCheckFaces(dm, isSimplex, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2308,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2309 }
2310 ierr = PetscOptionsBool("-dm_plex_check_geometry", "Check that cells have positive volume", "DMPlexCheckGeometry", PETSC_FALSE, &flg, &flg2)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_check_geometry"
,"Check that cells have positive volume","DMPlexCheckGeometry"
,PETSC_FALSE,&flg,&flg2)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2310,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2311 if (flg && flg2) {ierr = DMPlexCheckGeometry(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2311,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2312 }
2313
2314 ierr = PetscPartitionerSetFromOptions(mesh->partitioner);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2314,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2315 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)
;
2316}
2317
2318static PetscErrorCode DMSetFromOptions_Plex(PetscOptionItems *PetscOptionsObject,DM dm)
2319{
2320 PetscInt refine = 0, coarsen = 0, r;
2321 PetscBool isHierarchy;
2322 PetscErrorCode ierr;
2323
2324 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2324; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2325 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2325,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2325,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.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),2325,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2325,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2326 ierr = PetscOptionsHead(PetscOptionsObject,"DMPlex Options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2326,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2327 /* Handle DMPlex refinement */
2328 ierr = PetscOptionsInt("-dm_refine", "The number of uniform refinements", "DMCreate", refine, &refine, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-dm_refine","The number of uniform refinements"
,"DMCreate",refine,&refine,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2328,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2329 ierr = PetscOptionsInt("-dm_refine_hierarchy", "The number of uniform refinements", "DMCreate", refine, &refine, &isHierarchy)PetscOptionsInt_Private(PetscOptionsObject,"-dm_refine_hierarchy"
,"The number of uniform refinements","DMCreate",refine,&refine
,&isHierarchy)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2329,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2330 if (refine) {ierr = DMPlexSetRefinementUniform(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2330,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2331 if (refine && isHierarchy) {
2332 DM *dms, coarseDM;
2333
2334 ierr = DMGetCoarseDM(dm, &coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2334,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2335 ierr = PetscObjectReference((PetscObject)coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2335,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2336 ierr = PetscMalloc1(refine,&dms)PetscMallocA(1,PETSC_FALSE,2336,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(refine)*sizeof(**(&dms)),(&dms))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2336,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2337 ierr = DMRefineHierarchy(dm, refine, dms);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2337,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2338 /* Total hack since we do not pass in a pointer */
2339 ierr = DMPlexSwap_Static(dm, dms[refine-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2339,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2340 if (refine == 1) {
2341 ierr = DMSetCoarseDM(dm, dms[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2341,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2342 ierr = DMPlexSetRegularRefinement(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2342,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2343 } else {
2344 ierr = DMSetCoarseDM(dm, dms[refine-2]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2344,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2345 ierr = DMPlexSetRegularRefinement(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2345,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2346 ierr = DMSetCoarseDM(dms[0], dms[refine-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2346,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2347 ierr = DMPlexSetRegularRefinement(dms[0], PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2347,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2348 }
2349 ierr = DMSetCoarseDM(dms[refine-1], coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2349,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2350 ierr = PetscObjectDereference((PetscObject)coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2350,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2351 /* Free DMs */
2352 for (r = 0; r < refine; ++r) {
2353 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2353,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2354 ierr = DMDestroy(&dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2354,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2355 }
2356 ierr = PetscFree(dms)((*PetscTrFree)((void*)(dms),2356,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((dms) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2356,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2357 } else {
2358 for (r = 0; r < refine; ++r) {
2359 DM refinedMesh;
2360
2361 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2361,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2362 ierr = DMRefine(dm, PetscObjectComm((PetscObject) dm), &refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2362,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2363 /* Total hack since we do not pass in a pointer */
2364 ierr = DMPlexReplace_Static(dm, refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2364,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2365 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2365,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2366 ierr = DMDestroy(&refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2366,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2367 }
2368 }
2369 /* Handle DMPlex coarsening */
2370 ierr = PetscOptionsInt("-dm_coarsen", "Coarsen the mesh", "DMCreate", coarsen, &coarsen, NULL)PetscOptionsInt_Private(PetscOptionsObject,"-dm_coarsen","Coarsen the mesh"
,"DMCreate",coarsen,&coarsen,((void*)0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2370,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2371 ierr = PetscOptionsInt("-dm_coarsen_hierarchy", "The number of coarsenings", "DMCreate", coarsen, &coarsen, &isHierarchy)PetscOptionsInt_Private(PetscOptionsObject,"-dm_coarsen_hierarchy"
,"The number of coarsenings","DMCreate",coarsen,&coarsen,
&isHierarchy)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2371,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2372 if (coarsen && isHierarchy) {
2373 DM *dms;
2374
2375 ierr = PetscMalloc1(coarsen, &dms)PetscMallocA(1,PETSC_FALSE,2375,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(coarsen)*sizeof(**(&dms)),(&dms))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2375,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2376 ierr = DMCoarsenHierarchy(dm, coarsen, dms);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2376,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2377 /* Free DMs */
2378 for (r = 0; r < coarsen; ++r) {
2379 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2379,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2380 ierr = DMDestroy(&dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2380,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2381 }
2382 ierr = PetscFree(dms)((*PetscTrFree)((void*)(dms),2382,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((dms) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2382,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2383 } else {
2384 for (r = 0; r < coarsen; ++r) {
2385 DM coarseMesh;
2386
2387 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2387,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2388 ierr = DMCoarsen(dm, PetscObjectComm((PetscObject) dm), &coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2388,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2389 /* Total hack since we do not pass in a pointer */
2390 ierr = DMPlexReplace_Static(dm, coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2390,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2391 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2391,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2392 ierr = DMDestroy(&coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2392,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2393 }
2394 }
2395 /* Handle */
2396 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2396,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2397 ierr = PetscOptionsTail()0; {if (PetscOptionsObject->count != 1) 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);}
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2397,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2398 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)
;
2399}
2400
2401static PetscErrorCode DMCreateGlobalVector_Plex(DM dm,Vec *vec)
2402{
2403 PetscErrorCode ierr;
2404
2405 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2405; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2406 ierr = DMCreateGlobalVector_Section_Private(dm,vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2406,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2407 /* ierr = VecSetOperation(*vec, VECOP_DUPLICATE, (void(*)(void)) VecDuplicate_MPI_DM);CHKERRQ(ierr); */
2408 ierr = VecSetOperation(*vec, VECOP_VIEW, (void (*)(void)) VecView_Plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2408,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2409 ierr = VecSetOperation(*vec, VECOP_VIEWNATIVE, (void (*)(void)) VecView_Plex_Native);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2409,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2410 ierr = VecSetOperation(*vec, VECOP_LOAD, (void (*)(void)) VecLoad_Plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2410,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2411 ierr = VecSetOperation(*vec, VECOP_LOADNATIVE, (void (*)(void)) VecLoad_Plex_Native);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2411,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2412 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)
;
2413}
2414
2415static PetscErrorCode DMCreateLocalVector_Plex(DM dm,Vec *vec)
2416{
2417 PetscErrorCode ierr;
2418
2419 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2419; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2420 ierr = DMCreateLocalVector_Section_Private(dm,vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2420,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2421 ierr = VecSetOperation(*vec, VECOP_VIEW, (void (*)(void)) VecView_Plex_Local);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2421,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2422 ierr = VecSetOperation(*vec, VECOP_LOAD, (void (*)(void)) VecLoad_Plex_Local);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2422,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2423 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)
;
2424}
2425
2426static PetscErrorCode DMGetDimPoints_Plex(DM dm, PetscInt dim, PetscInt *pStart, PetscInt *pEnd)
2427{
2428 PetscInt depth, d;
2429 PetscErrorCode ierr;
2430
2431 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2431; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2432 ierr = DMPlexGetDepth(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2432,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2433 if (depth == 1) {
2434 ierr = DMGetDimension(dm, &d);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2434,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2435 if (dim == 0) {ierr = DMPlexGetDepthStratum(dm, dim, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2435,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2436 else if (dim == d) {ierr = DMPlexGetDepthStratum(dm, 1, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2436,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2437 else {*pStart = 0; *pEnd = 0;}
2438 } else {
2439 ierr = DMPlexGetDepthStratum(dm, dim, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2439,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2440 }
2441 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)
;
2442}
2443
2444static PetscErrorCode DMGetNeighors_Plex(DM dm, PetscInt *nranks, const PetscMPIInt *ranks[])
2445{
2446 PetscSF sf;
2447 PetscErrorCode ierr;
2448
2449 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2449; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2450 ierr = DMGetPointSF(dm, &sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2450,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2451 ierr = PetscSFGetRanks(sf, nranks, ranks, NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2451,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.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
2455static PetscErrorCode DMHasCreateInjection_Plex(DM dm, PetscBool *flg)
2456{
2457 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2457; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2458 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2458,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2458,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.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),2458,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2458,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2459 PetscValidPointer(flg,2)do { if (!flg) return PetscError(((MPI_Comm)0x44000001),2459,
__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(flg,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),2459,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
2460 *flg = PETSC_TRUE;
2461 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)
;
2462}
2463
2464static PetscErrorCode DMInitialize_Plex(DM dm)
2465{
2466 PetscErrorCode ierr;
2467
2468 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2468; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2469 dm->ops->view = DMView_Plex;
2470 dm->ops->load = DMLoad_Plex;
2471 dm->ops->setfromoptions = DMSetFromOptions_Plex;
2472 dm->ops->clone = DMClone_Plex;
2473 dm->ops->setup = DMSetUp_Plex;
2474 dm->ops->createdefaultsection = DMCreateDefaultSection_Plex;
2475 dm->ops->createdefaultconstraints = DMCreateDefaultConstraints_Plex;
2476 dm->ops->createglobalvector = DMCreateGlobalVector_Plex;
2477 dm->ops->createlocalvector = DMCreateLocalVector_Plex;
2478 dm->ops->getlocaltoglobalmapping = NULL((void*)0);
2479 dm->ops->createfieldis = NULL((void*)0);
2480 dm->ops->createcoordinatedm = DMCreateCoordinateDM_Plex;
2481 dm->ops->createcoordinatefield = DMCreateCoordinateField_Plex;
2482 dm->ops->getcoloring = NULL((void*)0);
2483 dm->ops->creatematrix = DMCreateMatrix_Plex;
2484 dm->ops->createinterpolation = DMCreateInterpolation_Plex;
2485 dm->ops->createmassmatrix = DMCreateMassMatrix_Plex;
2486 dm->ops->getaggregates = NULL((void*)0);
2487 dm->ops->getinjection = DMCreateInjection_Plex;
2488 dm->ops->hascreateinjection = DMHasCreateInjection_Plex;
2489 dm->ops->refine = DMRefine_Plex;
2490 dm->ops->coarsen = DMCoarsen_Plex;
2491 dm->ops->refinehierarchy = DMRefineHierarchy_Plex;
2492 dm->ops->coarsenhierarchy = DMCoarsenHierarchy_Plex;
2493 dm->ops->adaptlabel = DMAdaptLabel_Plex;
2494 dm->ops->adaptmetric = DMAdaptMetric_Plex;
2495 dm->ops->globaltolocalbegin = NULL((void*)0);
2496 dm->ops->globaltolocalend = NULL((void*)0);
2497 dm->ops->localtoglobalbegin = NULL((void*)0);
2498 dm->ops->localtoglobalend = NULL((void*)0);
2499 dm->ops->destroy = DMDestroy_Plex;
2500 dm->ops->createsubdm = DMCreateSubDM_Plex;
2501 dm->ops->createsuperdm = DMCreateSuperDM_Plex;
2502 dm->ops->getdimpoints = DMGetDimPoints_Plex;
2503 dm->ops->locatepoints = DMLocatePoints_Plex;
2504 dm->ops->projectfunctionlocal = DMProjectFunctionLocal_Plex;
2505 dm->ops->projectfunctionlabellocal = DMProjectFunctionLabelLocal_Plex;
2506 dm->ops->projectfieldlocal = DMProjectFieldLocal_Plex;
2507 dm->ops->projectfieldlabellocal = DMProjectFieldLabelLocal_Plex;
2508 dm->ops->computel2diff = DMComputeL2Diff_Plex;
2509 dm->ops->computel2gradientdiff = DMComputeL2GradientDiff_Plex;
2510 dm->ops->computel2fielddiff = DMComputeL2FieldDiff_Plex;
2511 dm->ops->getneighbors = DMGetNeighors_Plex;
2512 ierr = PetscObjectComposeFunction((PetscObject)dm,"DMPlexInsertBoundaryValues_C",DMPlexInsertBoundaryValues_Plex)PetscObjectComposeFunction_Private((PetscObject)dm,"DMPlexInsertBoundaryValues_C"
,(PetscVoidFunction)(DMPlexInsertBoundaryValues_Plex))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2512,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2513 ierr = PetscObjectComposeFunction((PetscObject)dm,"DMSetUpGLVisViewer_C",DMSetUpGLVisViewer_Plex)PetscObjectComposeFunction_Private((PetscObject)dm,"DMSetUpGLVisViewer_C"
,(PetscVoidFunction)(DMSetUpGLVisViewer_Plex))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2513,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2514 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)
;
2515}
2516
2517PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMClone_Plex(DM dm, DM *newdm)
2518{
2519 DM_Plex *mesh = (DM_Plex *) dm->data;
2520 PetscErrorCode ierr;
2521
2522 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2522; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2523 mesh->refct++;
2524 (*newdm)->data = mesh;
2525 ierr = PetscObjectChangeTypeName((PetscObject) *newdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2525,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2526 ierr = DMInitialize_Plex(*newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2526,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2527 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)
;
2528}
2529
2530/*MC
2531 DMPLEX = "plex" - A DM object that encapsulates an unstructured mesh, or CW Complex, which can be expressed using a Hasse Diagram.
2532 In the local representation, Vecs contain all unknowns in the interior and shared boundary. This is
2533 specified by a PetscSection object. Ownership in the global representation is determined by
2534 ownership of the underlying DMPlex points. This is specified by another PetscSection object.
2535
2536 Options Database Keys:
2537+ -dm_plex_hash_location - Use grid hashing for point location
2538. -dm_plex_partition_balance - Attempt to evenly divide points on partition boundary between processes
2539. -dm_plex_remesh_bd - Allow changes to the boundary on remeshing
2540. -dm_plex_max_projection_height - Maxmimum mesh point height used to project locally
2541. -dm_plex_regular_refinement - Use special nested projection algorithm for regular refinement
2542. -dm_plex_check_symmetry - Check that the adjacency information in the mesh is symmetric
2543. -dm_plex_check_skeleton <celltype> - Check that each cell has the correct number of vertices
2544. -dm_plex_check_faces <celltype> - Check that the faces of each cell give a vertex order this is consistent with what we expect from the cell type
2545. -dm_plex_check_geometry - Check that cells have positive volume
2546. -dm_view :mesh.tex:ascii_latex - View the mesh in LaTeX/TikZ
2547. -dm_plex_view_scale <num> - Scale the TikZ
2548- -dm_plex_print_fem <num> - View FEM assembly information, such as element vectors and matrices
2549
2550
2551 Level: intermediate
2552
2553.seealso: DMType, DMPlexCreate(), DMCreate(), DMSetType()
2554M*/
2555
2556PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMCreate_Plex(DM dm)
2557{
2558 DM_Plex *mesh;
2559 PetscInt unit, d;
2560 PetscErrorCode ierr;
2561
2562 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2562; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2563 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2563,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if (
!PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm
)0x44000001),2563,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.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),2563,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2563,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2564 ierr = PetscNewLog(dm,&mesh)(PetscMallocA(1,PETSC_TRUE,2564,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(1)*sizeof(**(((&mesh)))),(((&mesh)))) || PetscLogObjectMemory
((PetscObject)dm,sizeof(**(&mesh))))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2564,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2565 dm->dim = 0;
2566 dm->data = mesh;
2567
2568 mesh->refct = 1;
2569 ierr = PetscSectionCreate(PetscObjectComm((PetscObject)dm), &mesh->coneSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2569,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2570 mesh->maxConeSize = 0;
2571 mesh->cones = NULL((void*)0);
2572 mesh->coneOrientations = NULL((void*)0);
2573 ierr = PetscSectionCreate(PetscObjectComm((PetscObject)dm), &mesh->supportSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2573,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2574 mesh->maxSupportSize = 0;
2575 mesh->supports = NULL((void*)0);
2576 mesh->refinementUniform = PETSC_TRUE;
2577 mesh->refinementLimit = -1.0;
2578
2579 mesh->facesTmp = NULL((void*)0);
2580
2581 mesh->tetgenOpts = NULL((void*)0);
2582 mesh->triangleOpts = NULL((void*)0);
2583 ierr = PetscPartitionerCreate(PetscObjectComm((PetscObject)dm), &mesh->partitioner);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2583,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2584 mesh->remeshBd = PETSC_FALSE;
2585
2586 mesh->subpointMap = NULL((void*)0);
2587
2588 for (unit = 0; unit < NUM_PETSC_UNITS; ++unit) mesh->scale[unit] = 1.0;
2589
2590 mesh->regularRefinement = PETSC_FALSE;
2591 mesh->depthState = -1;
2592 mesh->globalVertexNumbers = NULL((void*)0);
2593 mesh->globalCellNumbers = NULL((void*)0);
2594 mesh->anchorSection = NULL((void*)0);
2595 mesh->anchorIS = NULL((void*)0);
2596 mesh->createanchors = NULL((void*)0);
2597 mesh->computeanchormatrix = NULL((void*)0);
2598 mesh->parentSection = NULL((void*)0);
2599 mesh->parents = NULL((void*)0);
2600 mesh->childIDs = NULL((void*)0);
2601 mesh->childSection = NULL((void*)0);
2602 mesh->children = NULL((void*)0);
2603 mesh->referenceTree = NULL((void*)0);
2604 mesh->getchildsymmetry = NULL((void*)0);
2605 for (d = 0; d < 8; ++d) mesh->hybridPointMax[d] = PETSC_DETERMINE-1;
2606 mesh->vtkCellHeight = 0;
2607 mesh->useAnchors = PETSC_FALSE;
2608
2609 mesh->maxProjectionHeight = 0;
2610
2611 mesh->printSetValues = PETSC_FALSE;
2612 mesh->printFEM = 0;
2613 mesh->printTol = 1.0e-10;
2614
2615 ierr = DMInitialize_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2615,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2616 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)
;
2617}
2618
2619/*@
2620 DMPlexCreate - Creates a DMPlex object, which encapsulates an unstructured mesh, or CW complex, which can be expressed using a Hasse Diagram.
2621
2622 Collective on MPI_Comm
2623
2624 Input Parameter:
2625. comm - The communicator for the DMPlex object
2626
2627 Output Parameter:
2628. mesh - The DMPlex object
2629
2630 Level: beginner
2631
2632.keywords: DMPlex, create
2633@*/
2634PetscErrorCode DMPlexCreate(MPI_Comm comm, DM *mesh)
2635{
2636 PetscErrorCode ierr;
2637
2638 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2638; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2639 PetscValidPointer(mesh,2)do { if (!mesh) return PetscError(((MPI_Comm)0x44000001),2639
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(mesh,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),2639,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
2640 ierr = DMCreate(comm, mesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2640,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2641 ierr = DMSetType(*mesh, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2641,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2642 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)
;
2643}
2644
2645/*
2646 This takes as input the common mesh generator output, a list of the vertices for each cell, but vertex numbers are global and an SF is built for them
2647*/
2648/* TODO: invertCells and spaceDim arguments could be added also to to DMPlexCreateFromCellListParallel(), DMPlexBuildFromCellList_Internal() and DMPlexCreateFromCellList() */
2649PetscErrorCode DMPlexBuildFromCellList_Parallel_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, const int cells[], PetscBool invertCells, PetscSF *sfVert)
2650{
2651 PetscSF sfPoint;
2652 PetscLayout vLayout;
2653 PetscHSetI vhash;
2654 PetscSFNode *remoteVerticesAdj, *vertexLocal, *vertexOwner, *remoteVertex;
2655 const PetscInt *vrange;
2656 PetscInt numVerticesAdj, off = 0, *verticesAdj, numVerticesGhost = 0, *localVertex, *cone, c, p, v, g;
2657 PetscMPIInt rank, size;
2658 PetscErrorCode ierr;
2659
2660 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2660; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2661 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject) dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2661,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2662 ierr = MPI_Comm_size(PetscObjectComm((PetscObject) dm), &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2662,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2663 /* Partition vertices */
2664 ierr = PetscLayoutCreate(PetscObjectComm((PetscObject) dm), &vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2664,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2665 ierr = PetscLayoutSetLocalSize(vLayout, numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2665,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2666 ierr = PetscLayoutSetBlockSize(vLayout, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2666,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2667 ierr = PetscLayoutSetUp(vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2667,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2668 ierr = PetscLayoutGetRanges(vLayout, &vrange);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2668,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2669 /* Count vertices and map them to procs */
2670 ierr = PetscHSetICreate(&vhash);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2670,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1
Calling 'PetscHSetICreate'
4
Returning from 'PetscHSetICreate'
2671 for (c = 0; c < numCells; ++c) {
5
Assuming 'c' is < 'numCells'
6
Loop condition is true. Entering loop body
2672 for (p = 0; p < numCorners; ++p) {
7
Assuming 'p' is < 'numCorners'
8
Loop condition is true. Entering loop body
2673 ierr = PetscHSetIAdd(vhash, cells[c*numCorners+p]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2673,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
9
Calling 'PetscHSetIAdd'
2674 }
2675 }
2676 ierr = PetscHSetIGetSize(vhash, &numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2676,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2677 ierr = PetscMalloc1(numVerticesAdj, &verticesAdj)PetscMallocA(1,PETSC_FALSE,2677,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerticesAdj)*sizeof(**(&verticesAdj)),(&
verticesAdj))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2677,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2678 ierr = PetscHSetIGetElems(vhash, &off, verticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2678,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2679 ierr = PetscHSetIDestroy(&vhash);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2679,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2680 if (off != numVerticesAdj) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Invalid number of local vertices %D should be %D", off, numVerticesAdj)return PetscError(((MPI_Comm)0x44000001),2680,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Invalid number of local vertices %D should be %D"
,off,numVerticesAdj)
;
2681 ierr = PetscSortInt(numVerticesAdj, verticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2681,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2682 ierr = PetscMalloc1(numVerticesAdj, &remoteVerticesAdj)PetscMallocA(1,PETSC_FALSE,2682,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerticesAdj)*sizeof(**(&remoteVerticesAdj)),
(&remoteVerticesAdj))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2682,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2683 for (v = 0; v < numVerticesAdj; ++v) {
2684 const PetscInt gv = verticesAdj[v];
2685 PetscInt vrank;
2686
2687 ierr = PetscFindInt(gv, size+1, vrange, &vrank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2687,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2688 vrank = vrank < 0 ? -(vrank+2) : vrank;
2689 remoteVerticesAdj[v].index = gv - vrange[vrank];
2690 remoteVerticesAdj[v].rank = vrank;
2691 }
2692 /* Create cones */
2693 ierr = DMPlexSetChart(dm, 0, numCells+numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2693,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2694 for (c = 0; c < numCells; ++c) {ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2694,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2695 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2695,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2696 ierr = DMGetWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2696,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2697 for (c = 0; c < numCells; ++c) {
2698 for (p = 0; p < numCorners; ++p) {
2699 const PetscInt gv = cells[c*numCorners+p];
2700 PetscInt lv;
2701
2702 ierr = PetscFindInt(gv, numVerticesAdj, verticesAdj, &lv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2702,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2703 if (lv < 0) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Could not find global vertex %D in local connectivity", gv)return PetscError(((MPI_Comm)0x44000001),2703,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Could not find global vertex %D in local connectivity"
,gv)
;
2704 cone[p] = lv+numCells;
2705 }
2706 if (invertCells) { ierr = DMPlexInvertCell_Internal(spaceDim, numCorners, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2706,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; }
2707 ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2707,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2708 }
2709 ierr = DMRestoreWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2709,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2710 /* Create SF for vertices */
2711 ierr = PetscSFCreate(PetscObjectComm((PetscObject)dm), sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2711,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2712 ierr = PetscObjectSetName((PetscObject) *sfVert, "Vertex Ownership SF");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2712,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2713 ierr = PetscSFSetFromOptions(*sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2713,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2714 ierr = PetscSFSetGraph(*sfVert, numVertices, numVerticesAdj, NULL((void*)0), PETSC_OWN_POINTER, remoteVerticesAdj, PETSC_OWN_POINTER);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2714,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2715 ierr = PetscFree(verticesAdj)((*PetscTrFree)((void*)(verticesAdj),2715,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((verticesAdj) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2715,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2716 /* Build pointSF */
2717 ierr = PetscMalloc2(numVerticesAdj, &vertexLocal, numVertices, &vertexOwner)PetscMallocA(2,PETSC_FALSE,2717,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerticesAdj)*sizeof(**(&vertexLocal)),(&
vertexLocal),(size_t)(numVertices)*sizeof(**(&vertexOwner
)),(&vertexOwner))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2717,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2718 for (v = 0; v < numVerticesAdj; ++v) {vertexLocal[v].index = v+numCells; vertexLocal[v].rank = rank;}
2719 for (v = 0; v < numVertices; ++v) {vertexOwner[v].index = -1; vertexOwner[v].rank = -1;}
2720 ierr = PetscSFReduceBegin(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexLocal, vertexOwner, MPI_MAXLOC(MPI_Op)(0x5800000c));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2720,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2721 ierr = PetscSFReduceEnd(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexLocal, vertexOwner, MPI_MAXLOC(MPI_Op)(0x5800000c));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2721,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2722 for (v = 0; v < numVertices; ++v) if (vertexOwner[v].rank < 0) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Global vertex %d on rank %d was unclaimed", v + vrange[rank], rank)return PetscError(((MPI_Comm)0x44000001),2722,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Global vertex %d on rank %d was unclaimed"
,v + vrange[rank],rank)
;
2723 ierr = PetscSFBcastBegin(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexOwner, vertexLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2723,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2724 ierr = PetscSFBcastEnd(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexOwner, vertexLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2724,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2725 for (v = 0; v < numVerticesAdj; ++v) if (vertexLocal[v].rank != rank) ++numVerticesGhost;
2726 ierr = PetscMalloc1(numVerticesGhost, &localVertex)PetscMallocA(1,PETSC_FALSE,2726,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerticesGhost)*sizeof(**(&localVertex)),(&
localVertex))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2726,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2727 ierr = PetscMalloc1(numVerticesGhost, &remoteVertex)PetscMallocA(1,PETSC_FALSE,2727,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numVerticesGhost)*sizeof(**(&remoteVertex)),(&
remoteVertex))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2727,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2728 for (v = 0, g = 0; v < numVerticesAdj; ++v) {
2729 if (vertexLocal[v].rank != rank) {
2730 localVertex[g] = v+numCells;
2731 remoteVertex[g].index = vertexLocal[v].index;
2732 remoteVertex[g].rank = vertexLocal[v].rank;
2733 ++g;
2734 }
2735 }
2736 ierr = PetscFree2(vertexLocal, vertexOwner)PetscFreeA(2,2736,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,&(vertexLocal),&(vertexOwner))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2736,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2737 if (g != numVerticesGhost) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Invalid number of vertex ghosts %D should be %D", g, numVerticesGhost)return PetscError(((MPI_Comm)0x44000001),2737,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid number of vertex ghosts %D should be %D"
,g,numVerticesGhost)
;
2738 ierr = DMGetPointSF(dm, &sfPoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2738,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2739 ierr = PetscObjectSetName((PetscObject) sfPoint, "point SF");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2739,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2740 ierr = PetscSFSetGraph(sfPoint, numCells+numVerticesAdj, numVerticesGhost, localVertex, PETSC_OWN_POINTER, remoteVertex, PETSC_OWN_POINTER);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2740,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2741 ierr = PetscLayoutDestroy(&vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2741,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2742 /* Fill in the rest of the topology structure */
2743 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2743,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2744 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2744,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2745 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)
;
2746}
2747
2748/*
2749 This takes as input the coordinates for each owned vertex
2750*/
2751PetscErrorCode DMPlexBuildCoordinates_Parallel_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numV, PetscSF sfVert, const PetscReal vertexCoords[])
2752{
2753 PetscSection coordSection;
2754 Vec coordinates;
2755 PetscScalar *coords;
2756 PetscInt numVertices, numVerticesAdj, coordSize, v;
2757 PetscErrorCode ierr;
2758
2759 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2759; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2760 ierr = DMSetCoordinateDim(dm, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2760,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2761 ierr = PetscSFGetGraph(sfVert, &numVertices, &numVerticesAdj, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2761,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2762 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2762,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2763 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2763,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2764 ierr = PetscSectionSetFieldComponents(coordSection, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2764,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2765 ierr = PetscSectionSetChart(coordSection, numCells, numCells + numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2765,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2766 for (v = numCells; v < numCells+numVerticesAdj; ++v) {
2767 ierr = PetscSectionSetDof(coordSection, v, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2767,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2768 ierr = PetscSectionSetFieldDof(coordSection, v, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2768,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2769 }
2770 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2770,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2771 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2771,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2772 ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2772,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2773 ierr = VecSetBlockSize(coordinates, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2773,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2774 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2774,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2775 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2775,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2776 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2776,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2777 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2777,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2778 {
2779 MPI_Datatype coordtype;
2780
2781 /* Need a temp buffer for coords if we have complex/single */
2782 ierr = MPI_Type_contiguous(spaceDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2782,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2783 ierr = MPI_Type_commit(&coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2783,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2784#if defined(PETSC_USE_COMPLEX)
2785 {
2786 PetscScalar *svertexCoords;
2787 PetscInt i;
2788 ierr = PetscMalloc1(numV*spaceDim,&svertexCoords)PetscMallocA(1,PETSC_FALSE,2788,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,(size_t)(numV*spaceDim)*sizeof(**(&svertexCoords)),(&
svertexCoords))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2788,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2789 for (i=0; i<numV*spaceDim; i++) svertexCoords[i] = vertexCoords[i];
2790 ierr = PetscSFBcastBegin(sfVert, coordtype, svertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2790,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2791 ierr = PetscSFBcastEnd(sfVert, coordtype, svertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2791,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2792 ierr = PetscFree(svertexCoords)((*PetscTrFree)((void*)(svertexCoords),2792,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((svertexCoords) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2792,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2793 }
2794#else
2795 ierr = PetscSFBcastBegin(sfVert, coordtype, vertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2795,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2796 ierr = PetscSFBcastEnd(sfVert, coordtype, vertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2796,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2797#endif
2798 ierr = MPI_Type_free(&coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2798,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2799 }
2800 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2800,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2801 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2801,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2802 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2802,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2803 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)
;
2804}
2805
2806/*@C
2807 DMPlexCreateFromCellListParallel - This takes as input common mesh generator output, a list of the vertices for each cell, and produces a DM
2808
2809 Input Parameters:
2810+ comm - The communicator
2811. dim - The topological dimension of the mesh
2812. numCells - The number of cells owned by this process
2813. numVertices - The number of vertices owned by this process
2814. numCorners - The number of vertices for each cell
2815. interpolate - Flag indicating that intermediate mesh entities (faces, edges) should be created automatically
2816. cells - An array of numCells*numCorners numbers, the global vertex numbers for each cell
2817. spaceDim - The spatial dimension used for coordinates
2818- vertexCoords - An array of numVertices*spaceDim numbers, the coordinates of each vertex
2819
2820 Output Parameter:
2821+ dm - The DM
2822- vertexSF - Optional, SF describing complete vertex ownership
2823
2824 Note: Two triangles sharing a face
2825$
2826$ 2
2827$ / | \
2828$ / | \
2829$ / | \
2830$ 0 0 | 1 3
2831$ \ | /
2832$ \ | /
2833$ \ | /
2834$ 1
2835would have input
2836$ numCells = 2, numVertices = 4
2837$ cells = [0 1 2 1 3 2]
2838$
2839which would result in the DMPlex
2840$
2841$ 4
2842$ / | \
2843$ / | \
2844$ / | \
2845$ 2 0 | 1 5
2846$ \ | /
2847$ \ | /
2848$ \ | /
2849$ 3
2850
2851 Level: beginner
2852
2853.seealso: DMPlexCreateFromCellList(), DMPlexCreateFromDAG(), DMPlexCreate()
2854@*/
2855PetscErrorCode DMPlexCreateFromCellListParallel(MPI_Comm comm, PetscInt dim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, PetscBool interpolate, const int cells[], PetscInt spaceDim, const PetscReal vertexCoords[], PetscSF *vertexSF, DM *dm)
2856{
2857 PetscSF sfVert;
2858 PetscErrorCode ierr;
2859
2860 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2860; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2861 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2861,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2862 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2862,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2863 PetscValidLogicalCollectiveInt(*dm, dim, 2)do { PetscErrorCode _7_ierr; PetscInt b1[2],b2[2]; b1[0] = -dim
; b1[1] = dim; _7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm
((PetscObject)*dm),2,2863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)*dm))),0) || MPI_Allreduce((b1),(b2),(2),(((MPI_Datatype
)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm((PetscObject
)*dm)))));do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError
(((MPI_Comm)0x44000001),2863,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),2863
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
2864 PetscValidLogicalCollectiveInt(*dm, spaceDim, 8)do { PetscErrorCode _7_ierr; PetscInt b1[2],b2[2]; b1[0] = -spaceDim
; b1[1] = spaceDim; _7_ierr = (PetscAllreduceBarrierCheck(PetscObjectComm
((PetscObject)*dm),2,2864,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm
((PetscObject)*dm))),0) || MPI_Allreduce((b1),(b2),(2),(((MPI_Datatype
)0x4c000405)),((MPI_Op)(0x58000001)),(PetscObjectComm((PetscObject
)*dm)))));do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError
(((MPI_Comm)0x44000001),2864,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),2864
,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,8); } while (0)
;
2865 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2865,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2866 ierr = DMPlexBuildFromCellList_Parallel_Internal(*dm, spaceDim, numCells, numVertices, numCorners, cells, PETSC_FALSE, &sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2866,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2867 if (interpolate) {
2868 DM idm;
2869
2870 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2870,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2871 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2871,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2872 *dm = idm;
2873 }
2874 ierr = DMPlexBuildCoordinates_Parallel_Internal(*dm, spaceDim, numCells, numVertices, sfVert, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2874,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2875 if (vertexSF) *vertexSF = sfVert;
2876 else {ierr = PetscSFDestroy(&sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2876,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2877 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)
;
2878}
2879
2880/*
2881 This takes as input the common mesh generator output, a list of the vertices for each cell
2882*/
2883PetscErrorCode DMPlexBuildFromCellList_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, const int cells[], PetscBool invertCells)
2884{
2885 PetscInt *cone, c, p;
2886 PetscErrorCode ierr;
2887
2888 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2888; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2889 ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2889,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2890 for (c = 0; c < numCells; ++c) {
2891 ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2891,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2892 }
2893 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2893,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2894 ierr = DMGetWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2894,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2895 for (c = 0; c < numCells; ++c) {
2896 for (p = 0; p < numCorners; ++p) {
2897 cone[p] = cells[c*numCorners+p]+numCells;
2898 }
2899 if (invertCells) { ierr = DMPlexInvertCell_Internal(spaceDim, numCorners, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2899,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; }
2900 ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2900,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2901 }
2902 ierr = DMRestoreWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2902,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2903 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2903,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2904 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2904,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2905 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)
;
2906}
2907
2908/*
2909 This takes as input the coordinates for each vertex
2910*/
2911PetscErrorCode DMPlexBuildCoordinates_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, const double vertexCoords[])
2912{
2913 PetscSection coordSection;
2914 Vec coordinates;
2915 DM cdm;
2916 PetscScalar *coords;
2917 PetscInt v, d;
2918 PetscErrorCode ierr;
2919
2920 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2920; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2921 ierr = DMSetCoordinateDim(dm, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2921,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2922 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2922,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2923 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2923,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2924 ierr = PetscSectionSetFieldComponents(coordSection, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2924,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2925 ierr = PetscSectionSetChart(coordSection, numCells, numCells + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2925,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2926 for (v = numCells; v < numCells+numVertices; ++v) {
2927 ierr = PetscSectionSetDof(coordSection, v, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2927,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2928 ierr = PetscSectionSetFieldDof(coordSection, v, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2928,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2929 }
2930 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2930,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2931
2932 ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2932,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2933 ierr = DMCreateLocalVector(cdm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2933,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2934 ierr = VecSetBlockSize(coordinates, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2934,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2935 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2935,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2936 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2936,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2937 for (v = 0; v < numVertices; ++v) {
2938 for (d = 0; d < spaceDim; ++d) {
2939 coords[v*spaceDim+d] = vertexCoords[v*spaceDim+d];
2940 }
2941 }
2942 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2942,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2943 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2943,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2944 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2944,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2945 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)
;
2946}
2947
2948/*@C
2949 DMPlexCreateFromCellList - This takes as input common mesh generator output, a list of the vertices for each cell, and produces a DM
2950
2951 Input Parameters:
2952+ comm - The communicator
2953. dim - The topological dimension of the mesh
2954. numCells - The number of cells
2955. numVertices - The number of vertices
2956. numCorners - The number of vertices for each cell
2957. interpolate - Flag indicating that intermediate mesh entities (faces, edges) should be created automatically
2958. cells - An array of numCells*numCorners numbers, the vertices for each cell
2959. spaceDim - The spatial dimension used for coordinates
2960- vertexCoords - An array of numVertices*spaceDim numbers, the coordinates of each vertex
2961
2962 Output Parameter:
2963. dm - The DM
2964
2965 Note: Two triangles sharing a face
2966$
2967$ 2
2968$ / | \
2969$ / | \
2970$ / | \
2971$ 0 0 | 1 3
2972$ \ | /
2973$ \ | /
2974$ \ | /
2975$ 1
2976would have input
2977$ numCells = 2, numVertices = 4
2978$ cells = [0 1 2 1 3 2]
2979$
2980which would result in the DMPlex
2981$
2982$ 4
2983$ / | \
2984$ / | \
2985$ / | \
2986$ 2 0 | 1 5
2987$ \ | /
2988$ \ | /
2989$ \ | /
2990$ 3
2991
2992 Level: beginner
2993
2994.seealso: DMPlexCreateFromDAG(), DMPlexCreate()
2995@*/
2996PetscErrorCode DMPlexCreateFromCellList(MPI_Comm comm, PetscInt dim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, PetscBool interpolate, const int cells[], PetscInt spaceDim, const double vertexCoords[], DM *dm)
2997{
2998 PetscErrorCode ierr;
2999
3000 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3000; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3001 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3001,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3002 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3002,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3003 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3003,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3004 ierr = DMPlexBuildFromCellList_Internal(*dm, spaceDim, numCells, numVertices, numCorners, cells, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3004,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3005 if (interpolate) {
3006 DM idm;
3007
3008 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3008,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3009 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3009,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3010 *dm = idm;
3011 }
3012 ierr = DMPlexBuildCoordinates_Internal(*dm, spaceDim, numCells, numVertices, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3012,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3013 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)
;
3014}
3015
3016/*@
3017 DMPlexCreateFromDAG - This takes as input the adjacency-list representation of the Directed Acyclic Graph (Hasse Diagram) encoding a mesh, and produces a DM
3018
3019 Input Parameters:
3020+ dm - The empty DM object, usually from DMCreate() and DMSetDimension()
3021. depth - The depth of the DAG
3022. numPoints - Array of size depth + 1 containing the number of points at each depth
3023. coneSize - The cone size of each point
3024. cones - The concatenation of the cone points for each point, the cone list must be oriented correctly for each point
3025. coneOrientations - The orientation of each cone point
3026- vertexCoords - An array of numPoints[0]*spacedim numbers representing the coordinates of each vertex, with spacedim the value set via DMSetCoordinateDim()
3027
3028 Output Parameter:
3029. dm - The DM
3030
3031 Note: Two triangles sharing a face would have input
3032$ depth = 1, numPoints = [4 2], coneSize = [3 3 0 0 0 0]
3033$ cones = [2 3 4 3 5 4], coneOrientations = [0 0 0 0 0 0]
3034$ vertexCoords = [-1.0 0.0 0.0 -1.0 0.0 1.0 1.0 0.0]
3035$
3036which would result in the DMPlex
3037$
3038$ 4
3039$ / | \
3040$ / | \
3041$ / | \
3042$ 2 0 | 1 5
3043$ \ | /
3044$ \ | /
3045$ \ | /
3046$ 3
3047$
3048$ Notice that all points are numbered consecutively, unlikely DMPlexCreateFromCellList()
3049
3050 Level: advanced
3051
3052.seealso: DMPlexCreateFromCellList(), DMPlexCreate()
3053@*/
3054PetscErrorCode DMPlexCreateFromDAG(DM dm, PetscInt depth, const PetscInt numPoints[], const PetscInt coneSize[], const PetscInt cones[], const PetscInt coneOrientations[], const PetscScalar vertexCoords[])
3055{
3056 Vec coordinates;
3057 PetscSection coordSection;
3058 PetscScalar *coords;
3059 PetscInt coordSize, firstVertex = -1, pStart = 0, pEnd = 0, p, v, dim, dimEmbed, d, off;
3060 PetscErrorCode ierr;
3061
3062 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3062; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3063 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3063,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3064 ierr = DMGetCoordinateDim(dm, &dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3064,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3065 if (dimEmbed < dim) SETERRQ2(PETSC_COMM_SELF,PETSC_ERR_PLIB,"Embedding dimension %d cannot be less than intrinsic dimension %d",dimEmbed,dim)return PetscError(((MPI_Comm)0x44000001),3065,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Embedding dimension %d cannot be less than intrinsic dimension %d"
,dimEmbed,dim)
;
3066 for (d = 0; d <= depth; ++d) pEnd += numPoints[d];
3067 ierr = DMPlexSetChart(dm, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3067,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3068 for (p = pStart; p < pEnd; ++p) {
3069 ierr = DMPlexSetConeSize(dm, p, coneSize[p-pStart]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3069,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3070 if (firstVertex < 0 && !coneSize[p - pStart]) {
3071 firstVertex = p - pStart;
3072 }
3073 }
3074 if (firstVertex < 0 && numPoints[0]) SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_ARG_WRONG,"Expected %d vertices but could not find any", numPoints[0])return PetscError(((MPI_Comm)0x44000001),3074,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Expected %d vertices but could not find any"
,numPoints[0])
;
3075 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3075,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
3076 for (p = pStart, off = 0; p < pEnd; off += coneSize[p-pStart], ++p) {
3077 ierr = DMPlexSetCone(dm, p, &cones[off]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3077,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3078 ierr = DMPlexSetConeOrientation(dm, p, &coneOrientations[off]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3078,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3079 }
3080 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3080,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3081 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3081,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3082 /* Build coordinates */
3083 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3083,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3084 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3084,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3085 ierr = PetscSectionSetFieldComponents(coordSection, 0, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3085,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3086 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numPoints[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3086,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3087 for (v = firstVertex; v < firstVertex+numPoints[0]; ++v) {
3088 ierr = PetscSectionSetDof(coordSection, v, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3088,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3089 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3089,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3090 }
3091 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3091,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3092 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3092,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3093 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3093,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3094 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3094,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3095 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3095,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3096 ierr = VecSetBlockSize(coordinates, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3096,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3097 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3097,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3098 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3098,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3099 for (v = 0; v < numPoints[0]; ++v) {
3100 PetscInt off;
3101
3102 ierr = PetscSectionGetOffset(coordSection, v+firstVertex, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3102,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3103 for (d = 0; d < dimEmbed; ++d) {
3104 coords[off+d] = vertexCoords[v*dimEmbed+d];
3105 }
3106 }
3107 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3107,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3108 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3108,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3109 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3109,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3110 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)
;
3111}
3112
3113/*@C
3114 DMPlexCreateCellVertexFromFile - Create a DMPlex mesh from a simple cell-vertex file.
3115
3116+ comm - The MPI communicator
3117. filename - Name of the .dat file
3118- interpolate - Create faces and edges in the mesh
3119
3120 Output Parameter:
3121. dm - The DM object representing the mesh
3122
3123 Note: The format is the simplest possible:
3124$ Ne
3125$ v0 v1 ... vk
3126$ Nv
3127$ x y z marker
3128
3129 Level: beginner
3130
3131.seealso: DMPlexCreateFromFile(), DMPlexCreateMedFromFile(), DMPlexCreateGmsh(), DMPlexCreate()
3132@*/
3133PetscErrorCode DMPlexCreateCellVertexFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
3134{
3135 DMLabel marker;
3136 PetscViewer viewer;
3137 Vec coordinates;
3138 PetscSection coordSection;
3139 PetscScalar *coords;
3140 char line[PETSC_MAX_PATH_LEN4096];
3141 PetscInt dim = 3, cdim = 3, coordSize, v, c, d;
3142 PetscMPIInt rank;
3143 int snum, Nv, Nc;
3144 PetscErrorCode ierr;
3145
3146 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3146; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3147 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3147,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3148 ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3148,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3149 ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII"ascii");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3149,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3150 ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3150,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3151 ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3151,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3152 if (!rank) {
3153 ierr = PetscViewerRead(viewer, line, 2, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3153,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3154 snum = sscanf(line, "%d %d", &Nc, &Nv);
3155 if (snum != 2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3155,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3156 } else {
3157 Nc = Nv = 0;
3158 }
3159 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3159,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3160 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3160,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3161 ierr = DMPlexSetChart(*dm, 0, Nc+Nv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3161,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3162 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3162,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3163 ierr = DMSetCoordinateDim(*dm, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3163,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3164 /* Read topology */
3165 if (!rank) {
3166 PetscInt cone[8], corners = 8;
3167 int vbuf[8], v;
3168
3169 for (c = 0; c < Nc; ++c) {ierr = DMPlexSetConeSize(*dm, c, corners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3169,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3170 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3170,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3171 for (c = 0; c < Nc; ++c) {
3172 ierr = PetscViewerRead(viewer, line, corners, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3172,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3173 snum = sscanf(line, "%d %d %d %d %d %d %d %d", &vbuf[0], &vbuf[1], &vbuf[2], &vbuf[3], &vbuf[4], &vbuf[5], &vbuf[6], &vbuf[7]);
3174 if (snum != corners) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3174,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3175 for (v = 0; v < corners; ++v) cone[v] = vbuf[v] + Nc;
3176 /* Hexahedra are inverted */
3177 {
3178 PetscInt tmp = cone[1];
3179 cone[1] = cone[3];
3180 cone[3] = tmp;
3181 }
3182 ierr = DMPlexSetCone(*dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3182,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3183 }
3184 }
3185 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3185,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3186 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3186,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3187 /* Read coordinates */
3188 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3188,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3189 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3189,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3190 ierr = PetscSectionSetFieldComponents(coordSection, 0, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3190,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3191 ierr = PetscSectionSetChart(coordSection, Nc, Nc + Nv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3191,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3192 for (v = Nc; v < Nc+Nv; ++v) {
3193 ierr = PetscSectionSetDof(coordSection, v, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3193,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3194 ierr = PetscSectionSetFieldDof(coordSection, v, 0, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3194,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3195 }
3196 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3196,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3197 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3197,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3198 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3198,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3199 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3199,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3200 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3200,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3201 ierr = VecSetBlockSize(coordinates, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3201,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3202 ierr = VecSetType(coordinates, VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3202,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3203 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3203,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3204 if (!rank) {
3205 double x[3];
3206 int val;
3207
3208 ierr = DMCreateLabel(*dm, "marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3208,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3209 ierr = DMGetLabel(*dm, "marker", &marker);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3209,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3210 for (v = 0; v < Nv; ++v) {
3211 ierr = PetscViewerRead(viewer, line, 4, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3211,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3212 snum = sscanf(line, "%lg %lg %lg %d", &x[0], &x[1], &x[2], &val);
3213 if (snum != 4) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3213,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3214 for (d = 0; d < cdim; ++d) coords[v*cdim+d] = x[d];
3215 if (val) {ierr = DMLabelSetValue(marker, v+Nc, val);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3215,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3216 }
3217 }
3218 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3218,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3219 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3219,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3220 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3220,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3221 ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3221,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3222 if (interpolate) {
3223 DM idm;
3224 DMLabel bdlabel;
3225
3226 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3226,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3227 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3227,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3228 *dm = idm;
3229
3230 ierr = DMGetLabel(*dm, "marker", &bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3230,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3231 ierr = DMPlexMarkBoundaryFaces(*dm, PETSC_DETERMINE-1, bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3231,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3232 ierr = DMPlexLabelComplete(*dm, bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3232,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3233 }
3234 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)
;
3235}
3236
3237/*@C
3238 DMPlexCreateFromFile - This takes a filename and produces a DM
3239
3240 Input Parameters:
3241+ comm - The communicator
3242. filename - A file name
3243- interpolate - Flag to create intermediate mesh pieces (edges, faces)
3244
3245 Output Parameter:
3246. dm - The DM
3247
3248 Options Database Keys:
3249. -dm_plex_create_from_hdf5_xdmf - use the PETSC_VIEWER_HDF5_XDMF format for reading HDF5
3250
3251 Level: beginner
3252
3253.seealso: DMPlexCreateFromDAG(), DMPlexCreateFromCellList(), DMPlexCreate()
3254@*/
3255PetscErrorCode DMPlexCreateFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
3256{
3257 const char *extGmsh = ".msh";
3258 const char *extGmsh2 = ".msh2";
3259 const char *extGmsh4 = ".msh4";
3260 const char *extCGNS = ".cgns";
3261 const char *extExodus = ".exo";
3262 const char *extGenesis = ".gen";
3263 const char *extFluent = ".cas";
3264 const char *extHDF5 = ".h5";
3265 const char *extMed = ".med";
3266 const char *extPLY = ".ply";
3267 const char *extCV = ".dat";
3268 size_t len;
3269 PetscBool isGmsh, isGmsh2, isGmsh4, isCGNS, isExodus, isGenesis, isFluent, isHDF5, isMed, isPLY, isCV;
3270 PetscMPIInt rank;
3271 PetscErrorCode ierr;
3272
3273 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/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3273; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3274 PetscValidPointer(filename, 2)do { if (!filename) return PetscError(((MPI_Comm)0x44000001),
3274,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(filename,PETSC_CHAR)) return PetscError(
((MPI_Comm)0x44000001),3274,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
3275 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),3275,__func__
,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",4); if
(!PetscCheckPointer(dm,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),3275,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
3276 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3276,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3277 ierr = PetscStrlen(filename, &len);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3277,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3278 if (!len) SETERRQ(comm, PETSC_ERR_ARG_WRONG, "Filename must be a valid path")return PetscError(comm,3278,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Filename must be a valid path")
;
3279 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extGmsh, 4, &isGmsh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3279,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3280 ierr = PetscStrncmp(&filename[PetscMax(0,len-5)(((0)<(len-5)) ? (len-5) : (0))], extGmsh2, 5, &isGmsh2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3280,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3281 ierr = PetscStrncmp(&filename[PetscMax(0,len-5)(((0)<(len-5)) ? (len-5) : (0))], extGmsh4, 5, &isGmsh4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3281,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3282 ierr = PetscStrncmp(&filename[PetscMax(0,len-5)(((0)<(len-5)) ? (len-5) : (0))], extCGNS, 5, &isCGNS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3282,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3283 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extExodus, 4, &isExodus);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3283,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3284 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extGenesis, 4, &isGenesis);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3284,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3285 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extFluent, 4, &isFluent);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3285,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3286 ierr = PetscStrncmp(&filename[PetscMax(0,len-3)(((0)<(len-3)) ? (len-3) : (0))], extHDF5, 3, &isHDF5);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3286,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3287 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extMed, 4, &isMed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3287,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3288 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extPLY, 4, &isPLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3288,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3289 ierr = PetscStrncmp(&filename[PetscMax(0,len-4)(((0)<(len-4)) ? (len-4) : (0))], extCV, 4, &isCV);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3289,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3290 if (isGmsh || isGmsh2 || isGmsh4) {
3291 ierr = DMPlexCreateGmshFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3291,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3292 } else if (isCGNS) {
3293 ierr = DMPlexCreateCGNSFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3293,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3294 } else if (isExodus || isGenesis) {
3295 ierr = DMPlexCreateExodusFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3295,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3296 } else if (isFluent) {
3297 ierr = DMPlexCreateFluentFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3297,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3298 } else if (isHDF5) {
3299 PetscBool load_hdf5_xdmf = PETSC_FALSE;
3300 PetscViewer viewer;
3301
3302 /* PETSC_VIEWER_HDF5_XDMF is used if the filename ends with .xdmf.h5, or if -dm_plex_create_from_hdf5_xdmf option is present */
3303 ierr = PetscStrncmp(&filename[PetscMax(0,len-8)(((0)<(len-8)) ? (len-8) : (0))], ".xdmf", 5, &load_hdf5_xdmf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3303,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3304 ierr = PetscOptionsGetBool(NULL((void*)0), NULL((void*)0), "-dm_plex_create_from_hdf5_xdmf", &load_hdf5_xdmf, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3304,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3305 ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3305,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3306 ierr = PetscViewerSetType(viewer, PETSCVIEWERHDF5"hdf5");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3306,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3307 ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3307,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3308 ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3308,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3309 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3309,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3310 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3310,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3311 if (load_hdf5_xdmf) {ierr = PetscViewerPushFormat(viewer, PETSC_VIEWER_HDF5_XDMF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3311,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3312 ierr = DMLoad(*dm, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3312,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3313 if (load_hdf5_xdmf) {ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3313,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3314 ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3314,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3315
3316 if (interpolate) {
3317 DM idm;
3318
3319 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3319,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3320 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3320,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3321 *dm = idm;
3322 }
3323 } else if (isMed) {
3324 ierr = DMPlexCreateMedFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3324,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3325 } else if (isPLY) {
3326 ierr = DMPlexCreatePLYFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3326,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3327 } else if (isCV) {
3328 ierr = DMPlexCreateCellVertexFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3328,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3329 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Cannot load file %s: unrecognized extension", filename)return PetscError(((MPI_Comm)0x44000001),3329,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Cannot load file %s: unrecognized extension"
,filename)
;
3330 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)
;
3331}
3332
3333/*@
3334 DMPlexCreateReferenceCell - Create a DMPLEX with the appropriate FEM reference cell
3335
3336 Collective on comm
3337
3338 Input Parameters:
3339+ comm - The communicator
3340. dim - The spatial dimension
3341- simplex - Flag for simplex, otherwise use a tensor-product cell
3342
3343 Output Parameter:
3344. refdm - The reference cell
3345
3346 Level: intermediate
3347
3348.keywords: reference cell
3349.seealso:
3350@*/
3351PetscErrorCode DMPlexCreateReferenceCell(MPI_Comm comm, PetscInt dim, PetscBool simplex, DM *refdm)
3352{
3353 DM rdm;
3354 Vec coords;
3355 PetscErrorCode ierr;
3356
3357 PetscFunctionBeginUserdo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3357; petscstack
->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3358 ierr = DMCreate(comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3358,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3359 ierr = DMSetType(rdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3359,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3360 ierr = DMSetDimension(rdm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3360,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3361 switch (dim) {
3362 case 0:
3363 {
3364 PetscInt numPoints[1] = {1};
3365 PetscInt coneSize[1] = {0};
3366 PetscInt cones[1] = {0};
3367 PetscInt coneOrientations[1] = {0};
3368 PetscScalar vertexCoords[1] = {0.0};
3369
3370 ierr = DMPlexCreateFromDAG(rdm, 0, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3370,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3371 }
3372 break;
3373 case 1:
3374 {
3375 PetscInt numPoints[2] = {2, 1};
3376 PetscInt coneSize[3] = {2, 0, 0};
3377 PetscInt cones[2] = {1, 2};
3378 PetscInt coneOrientations[2] = {0, 0};
3379 PetscScalar vertexCoords[2] = {-1.0, 1.0};
3380
3381 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3381,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3382 }
3383 break;
3384 case 2:
3385 if (simplex) {
3386 PetscInt numPoints[2] = {3, 1};
3387 PetscInt coneSize[4] = {3, 0, 0, 0};
3388 PetscInt cones[3] = {1, 2, 3};
3389 PetscInt coneOrientations[3] = {0, 0, 0};
3390 PetscScalar vertexCoords[6] = {-1.0, -1.0, 1.0, -1.0, -1.0, 1.0};
3391
3392 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3392,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3393 } else {
3394 PetscInt numPoints[2] = {4, 1};
3395 PetscInt coneSize[5] = {4, 0, 0, 0, 0};
3396 PetscInt cones[4] = {1, 2, 3, 4};
3397 PetscInt coneOrientations[4] = {0, 0, 0, 0};
3398 PetscScalar vertexCoords[8] = {-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0};
3399
3400 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3400,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3401 }
3402 break;
3403 case 3:
3404 if (simplex) {
3405 PetscInt numPoints[2] = {4, 1};
3406 PetscInt coneSize[5] = {4, 0, 0, 0, 0};
3407 PetscInt cones[4] = {1, 3, 2, 4};
3408 PetscInt coneOrientations[4] = {0, 0, 0, 0};
3409 PetscScalar vertexCoords[12] = {-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0, -1.0, -1.0, -1.0, 1.0};
3410
3411 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3411,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3412 } else {
3413 PetscInt numPoints[2] = {8, 1};
3414 PetscInt coneSize[9] = {8, 0, 0, 0, 0, 0, 0, 0, 0};
3415 PetscInt cones[8] = {1, 4, 3, 2, 5, 6, 7, 8};
3416 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
3417 PetscScalar vertexCoords[24] = {-1.0, -1.0, -1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, -1.0,
3418 -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0};
3419
3420 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3420,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3421 }
3422 break;
3423 default:
3424 SETERRQ1(comm, PETSC_ERR_ARG_WRONG, "Cannot create reference cell for dimension %d", dim)return PetscError(comm,3424,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Cannot create reference cell for dimension %d"
,dim)
;
3425 }
3426 ierr = DMPlexInterpolate(rdm, refdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3426,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3427 if (rdm->coordinateDM) {
3428 DM ncdm;
3429 PetscSection cs;
3430 PetscInt pEnd = -1;
3431
3432 ierr = DMGetSection(rdm->coordinateDM, &cs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3432,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3433 if (cs) {ierr = PetscSectionGetChart(cs, NULL((void*)0), &pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3433,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3434 if (pEnd >= 0) {
3435 ierr = DMClone(rdm->coordinateDM, &ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3435,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3436 ierr = DMCopyDisc(rdm->coordinateDM, ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3436,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3437 ierr = DMSetSection(ncdm, cs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3437,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3438 ierr = DMSetCoordinateDM(*refdm, ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3438,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3439 ierr = DMDestroy(&ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3439,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3440 }
3441 }
3442 ierr = DMGetCoordinatesLocal(rdm, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3442,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3443 if (coords) {
3444 ierr = DMSetCoordinatesLocal(*refdm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3444,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3445 } else {
3446 ierr = DMGetCoordinates(rdm, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3446,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3447 if (coords) {ierr = DMSetCoordinates(*refdm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3447,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3448 }
3449 ierr = DMDestroy(&rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3449,__func__,"/sandbox/petsc/petsc.next-tmp/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3450 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)
;
3451}

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

1#if !defined(PETSC_HASHSETI_H)
2#define PETSC_HASHSETI_H
3
4#include <petsc/private/hashset.h>
5
6PETSC_HASH_SET(HSetI, PetscInt, PetscHashInt, PetscHashEqual)typedef struct kh_HSetI_s { khint_t n_buckets, size, n_occupied
, upper_bound; khint32_t *flags; PetscInt *keys; char *vals; }
kh_HSetI_t; static inline __attribute((unused)) kh_HSetI_t *
kh_init_HSetI(void) { return (kh_HSetI_t*)calloc(1,sizeof(kh_HSetI_t
)); } static inline __attribute((unused)) void kh_destroy_HSetI
(kh_HSetI_t *h) { if (h) { free((void *)h->keys); free(h->
flags); free((void *)h->vals); free(h); } } static inline __attribute
((unused)) void kh_clear_HSetI(kh_HSetI_t *h) { if (h &&
h->flags) { memset(h->flags, 0xaa, ((h->n_buckets) <
16? 1 : (h->n_buckets)>>4) * sizeof(khint32_t)); h->
size = h->n_occupied = 0; } } static inline __attribute((unused
)) khint_t kh_get_HSetI(const kh_HSetI_t *h, PetscInt key) { if
(h->n_buckets) { khint_t k, i, last, mask, step = 0; mask
= h->n_buckets - 1; k = PetscHashInt(key); i = k & mask
; last = i; while (!((h->flags[i>>4]>>((i&
0xfU)<<1))&2) && (((h->flags[i>>4]
>>((i&0xfU)<<1))&1) || !((h->keys[i]) ==
(key)))) { i = (i + (++step)) & mask; if (i == last) return
h->n_buckets; } return ((h->flags[i>>4]>>(
(i&0xfU)<<1))&3)? h->n_buckets : i; } else return
0; } static inline __attribute((unused)) int kh_resize_HSetI
(kh_HSetI_t *h, khint_t new_n_buckets) { khint32_t *new_flags
= 0; khint_t j = 1; { (--(new_n_buckets), (new_n_buckets)|=(
new_n_buckets)>>1, (new_n_buckets)|=(new_n_buckets)>>
2, (new_n_buckets)|=(new_n_buckets)>>4, (new_n_buckets)
|=(new_n_buckets)>>8, (new_n_buckets)|=(new_n_buckets)>>
16, ++(new_n_buckets)); if (new_n_buckets < 4) new_n_buckets
= 4; if (h->size >= (khint_t)(new_n_buckets * __ac_HASH_UPPER
+ 0.5)) j = 0; else { new_flags = (khint32_t*)malloc(((new_n_buckets
) < 16? 1 : (new_n_buckets)>>4) * sizeof(khint32_t))
; if (!new_flags) return -1; memset(new_flags, 0xaa, ((new_n_buckets
) < 16? 1 : (new_n_buckets)>>4) * sizeof(khint32_t))
; if (h->n_buckets < new_n_buckets) { PetscInt *new_keys
= (PetscInt*)realloc((void *)h->keys,new_n_buckets * sizeof
(PetscInt)); if (!new_keys) { free(new_flags); return -1; } h
->keys = new_keys; if (0) { char *new_vals = (char*)realloc
((void *)h->vals,new_n_buckets * sizeof(char)); if (!new_vals
) { free(new_flags); return -1; } h->vals = new_vals; } } }
} if (j) { for (j = 0; j != h->n_buckets; ++j) { if (((h->
flags[j>>4]>>((j&0xfU)<<1))&3) == 0
) { PetscInt key = h->keys[j]; char val; khint_t new_mask;
new_mask = new_n_buckets - 1; if (0) val = h->vals[j]; (h
->flags[j>>4]|=1ul<<((j&0xfU)<<1)); while
(1) { khint_t k, i, step = 0; k = PetscHashInt(key); i = k &
new_mask; while (!((new_flags[i>>4]>>((i&0xfU
)<<1))&2)) i = (i + (++step)) & new_mask; (new_flags
[i>>4]&=~(2ul<<((i&0xfU)<<1))); if (
i < h->n_buckets && ((h->flags[i>>4]>>
((i&0xfU)<<1))&3) == 0) { { PetscInt tmp = h->
keys[i]; h->keys[i] = key; key = tmp; } if (0) { char tmp =
h->vals[i]; h->vals[i] = val; val = tmp; } (h->flags
[i>>4]|=1ul<<((i&0xfU)<<1)); } else { h
->keys[i] = key; if (0) h->vals[i] = val; break; } } } }
if (h->n_buckets > new_n_buckets) { h->keys = (PetscInt
*)realloc((void *)h->keys,new_n_buckets * sizeof(PetscInt)
); if (0) h->vals = (char*)realloc((void *)h->vals,new_n_buckets
* sizeof(char)); } free(h->flags); h->flags = new_flags
; h->n_buckets = new_n_buckets; h->n_occupied = h->size
; h->upper_bound = (khint_t)(h->n_buckets * __ac_HASH_UPPER
+ 0.5); } return 0; } static inline __attribute((unused)) khint_t
kh_put_HSetI(kh_HSetI_t *h, PetscInt key, int *ret) { khint_t
x; if (h->n_occupied >= h->upper_bound) { if (h->
n_buckets > (h->size<<1)) { if (kh_resize_HSetI(h
, h->n_buckets - 1) < 0) { *ret = -1; return h->n_buckets
; } } else if (kh_resize_HSetI(h, h->n_buckets + 1) < 0
) { *ret = -1; return h->n_buckets; } } { khint_t k, i, site
, last, mask = h->n_buckets - 1, step = 0; x = site = h->
n_buckets; k = PetscHashInt(key); i = k & mask; if (((h->
flags[i>>4]>>((i&0xfU)<<1))&2)) x =
i; else { last = i; while (!((h->flags[i>>4]>>
((i&0xfU)<<1))&2) && (((h->flags[i>>
4]>>((i&0xfU)<<1))&1) || !((h->keys[i]
) == (key)))) { if (((h->flags[i>>4]>>((i&
0xfU)<<1))&1)) site = i; i = (i + (++step)) & mask
; if (i == last) { x = site; break; } } if (x == h->n_buckets
) { if (((h->flags[i>>4]>>((i&0xfU)<<
1))&2) && site != h->n_buckets) x = site; else
x = i; } } } if (((h->flags[x>>4]>>((x&0xfU
)<<1))&2)) { h->keys[x] = key; (h->flags[x>>
4]&=~(3ul<<((x&0xfU)<<1))); ++h->size;
++h->n_occupied; *ret = 1; } else if (((h->flags[x>>
4]>>((x&0xfU)<<1))&1)) { h->keys[x] = key
; (h->flags[x>>4]&=~(3ul<<((x&0xfU)<<
1))); ++h->size; *ret = 2; } else *ret = 0; return x; } static
inline __attribute((unused)) void kh_del_HSetI(kh_HSetI_t *h
, khint_t x) { if (x != h->n_buckets && !((h->flags
[x>>4]>>((x&0xfU)<<1))&3)) { (h->
flags[x>>4]|=1ul<<((x&0xfU)<<1)); --h->
size; } } typedef kh_HSetI_t *PetscHSetI; static inline __attribute
((unused)) PetscErrorCode PetscHSetICreate(PetscHSetI *ht) { do
{ do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); *ht = kh_init_HSetI(); 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); } static inline __attribute((unused)) PetscErrorCode
PetscHSetIDestroy(PetscHSetI *ht) { do { do { ; if (petscstack
&& (petscstack->currentsize < 64)) { petscstack
->function[petscstack->currentsize] = __func__; petscstack
->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); if (!*ht) 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); kh_destroy_HSetI(*ht); *ht = ((void*)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); } static inline __attribute
((unused)) PetscErrorCode PetscHSetIReset(PetscHSetI ht) { do
{ do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); { if (ht) { free((ht)->keys); free((ht)->
flags); free((ht)->vals); memset((ht), 0x00, sizeof(*(ht))
); } }; 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); } static inline __attribute((unused)) PetscErrorCode PetscHSetIDuplicate
(PetscHSetI ht,PetscHSetI *hd) { int ret; PetscInt key; do { do
{ ; if (petscstack && (petscstack->currentsize <
64)) { petscstack->function[petscstack->currentsize] =
__func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!hd) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(hd,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0); *hd = kh_init_HSetI(); ret = kh_resize_HSetI(*hd
, ((ht)->size)); do { if (__builtin_expect(!!(!(ret==0)),0
)) return PetscError(((MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret==0"
); } while(0); { khint_t __i; for (__i = (khint_t)(0); __i !=
((ht)->n_buckets); ++__i) { if (!(!(((ht)->flags[(__i)
>>4]>>(((__i)&0xfU)<<1))&3))) continue
; (key) = ((ht)->keys[__i]); { kh_put_HSetI(*hd, key, &
ret); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError
(((MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0"
); } while(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); } static inline __attribute((unused)) PetscErrorCode PetscHSetIClear
(PetscHSetI ht) { do { do { ; if (petscstack && (petscstack
->currentsize < 64)) { petscstack->function[petscstack
->currentsize] = __func__; petscstack->file[petscstack->
currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); kh_clear_HSetI(ht); 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); } static inline __attribute((unused)) PetscErrorCode
PetscHSetIResize(PetscHSetI ht,PetscInt nb) { int ret; do { do
{ ; if (petscstack && (petscstack->currentsize <
64)) { petscstack->function[petscstack->currentsize] =
__func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); ret = kh_resize_HSetI(ht, (khint_t)nb); do { if
(__builtin_expect(!!(!(ret==0)),0)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret==0"
); } while(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); } static inline __attribute((unused)) PetscErrorCode PetscHSetIGetSize
(PetscHSetI ht,PetscInt *n) { do { do { ; if (petscstack &&
(petscstack->currentsize < 64)) { petscstack->function
[petscstack->currentsize] = __func__; petscstack->file[
petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!n) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(n,PETSC_INT)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d"
,2); } while (0); *n = (PetscInt)((ht)->size); 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); } static inline __attribute
((unused)) PetscErrorCode PetscHSetIHas(PetscHSetI ht,PetscInt
key,PetscBool *has) { khiter_t iter; do { do { ; if (petscstack
&& (petscstack->currentsize < 64)) { petscstack
->function[petscstack->currentsize] = __func__; petscstack
->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!has) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if
(!PetscCheckPointer(has,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0); iter = kh_get_HSetI(ht, key); *has = (iter != (
(ht)->n_buckets)) ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute((unused)) PetscErrorCode
PetscHSetIAdd(PetscHSetI ht,PetscInt key) { int ret; khiter_t
iter; do { do { ; if (petscstack && (petscstack->
currentsize < 64)) { petscstack->function[petscstack->
currentsize] = __func__; petscstack->file[petscstack->currentsize
] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); iter = kh_put_HSetI(ht, key, &ret); (void)iter
; do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError
(((MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0"
); } while(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); } static inline __attribute((unused)) PetscErrorCode PetscHSetIDel
(PetscHSetI ht,PetscInt key) { khiter_t iter; do { do { ; if (
petscstack && (petscstack->currentsize < 64)) {
petscstack->function[petscstack->currentsize] = __func__
; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); iter = kh_get_HSetI(ht, key); kh_del_HSetI(ht, iter
); 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); } static
inline __attribute((unused)) PetscErrorCode PetscHSetIQueryAdd
(PetscHSetI ht,PetscInt key,PetscBool *missing) { int ret; khiter_t
iter; do { do { ; if (petscstack && (petscstack->
currentsize < 64)) { petscstack->function[petscstack->
currentsize] = __func__; petscstack->file[petscstack->currentsize
] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!missing) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if
(!PetscCheckPointer(missing,PETSC_CHAR)) return PetscError((
(MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0); iter = kh_put_HSetI(ht, key, &ret); (void)iter
; do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError
(((MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","ret>=0"
); } while(0); *missing = ret ? PETSC_TRUE : PETSC_FALSE; 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); } static inline __attribute
((unused)) PetscErrorCode PetscHSetIQueryDel(PetscHSetI ht,PetscInt
key,PetscBool *present) { khiter_t iter; do { do { ; if (petscstack
&& (petscstack->currentsize < 64)) { petscstack
->function[petscstack->currentsize] = __func__; petscstack
->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_TRUE || petscstack->hotdepth); } ; } while (0);
; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!present) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if
(!PetscCheckPointer(present,PETSC_CHAR)) return PetscError((
(MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0); iter = kh_get_HSetI(ht, key); if (iter != ((ht)
->n_buckets)) { kh_del_HSetI(ht, iter); *present = PETSC_TRUE
; } else { *present = PETSC_FALSE; } 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); } static inline __attribute((unused)) PetscErrorCode
PetscHSetIGetElems(PetscHSetI ht,PetscInt *off,PetscInt array
[]) { PetscInt key; PetscInt pos; do { do { ; if (petscstack &&
(petscstack->currentsize < 64)) { petscstack->function
[petscstack->currentsize] = __func__; petscstack->file[
petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
; petscstack->line[petscstack->currentsize] = 6; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0); do { if (!ht) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",1); if
(!PetscCheckPointer(ht,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!off) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(off,PETSC_INT)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d"
,2); } while (0); pos = *off; { khint_t __i; for (__i = (khint_t
)(0); __i != ((ht)->n_buckets); ++__i) { if (!(!(((ht)->
flags[(__i)>>4]>>(((__i)&0xfU)<<1))&
3))) continue; (key) = ((ht)->keys[__i]); array[pos++] = key
; } }; *off = pos; 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); }
2
Within the expansion of the macro 'PETSC_HASH_SET':
a
Assuming 'petscstack' is null
b
Assuming the condition is false
c
Calling 'kh_init_HSetI'
d
Returning from 'kh_init_HSetI'
e
Assuming 'petscstack' is null
3
Within the expansion of the macro 'PETSC_HASH_SET':
a
Null pointer value stored to field 'flags'
10
Within the expansion of the macro 'PETSC_HASH_SET':
a
Assuming 'ht' is non-null
b
Assuming the condition is false
c
Calling 'kh_put_HSetI'
11
Within the expansion of the macro 'PETSC_HASH_SET':
a
Calling 'kh_resize_HSetI'
b
Returning from 'kh_resize_HSetI'
c
Calling 'PetscHashInt'
d
Returning from 'PetscHashInt'
e
Array access (via field 'flags') results in a null pointer dereference
12
Within the expansion of the macro 'PETSC_HASH_SET':
7
8#endif /* PETSC_HASHSETI_H */

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

1#if !defined(PETSC_HASHTABLE_H)
2#define PETSC_HASHTABLE_H
3
4#include <petsc/private/petscimpl.h>
5
6#define kh_inlineinline PETSC_INLINEinline
7#define klib_unused__attribute((unused)) PETSC_UNUSED__attribute((unused))
8#include <petsc/private/kernels/khash.h>
9
10/* Required for khash <= 0.2.5 */
11#if !defined(kcalloc)
12#define kcalloc(N,Z)calloc(N,Z) calloc(N,Z)
13#endif
14#if !defined(kmalloc)
15#define kmalloc(Z)malloc(Z) malloc(Z)
16#endif
17#if !defined(krealloc)
18#define krealloc(P,Z)realloc(P,Z) realloc(P,Z)
19#endif
20#if !defined(kfree)
21#define kfree(P)free(P) free(P)
22#endif
23
24/* --- Useful extensions to khash --- */
25
26#if !defined(kh_reset)
27/*! @function
28 @abstract Reset a hash table to initial state.
29 @param name Name of the hash table [symbol]
30 @param h Pointer to the hash table [khash_t(name)*]
31 */
32#define kh_reset(name, h){ if (h) { free((h)->keys); free((h)->flags); free((h)->
vals); memset((h), 0x00, sizeof(*(h))); } }
{ \
33 if (h) { \
34 kfree((h)->keys)free((h)->keys); kfree((h)->flags)free((h)->flags); \
35 kfree((h)->vals)free((h)->vals); \
36 memset((h), 0x00, sizeof(*(h))); \
37 } }
38#endif /*kh_reset*/
39
40#if !defined(kh_foreach)
41/*! @function
42 @abstract Iterate over the entries in the hash table
43 @param h Pointer to the hash table [khash_t(name)*]
44 @param kvar Variable to which key will be assigned
45 @param vvar Variable to which value will be assigned
46 @param code Block of code to execute
47 */
48#define kh_foreach(h, kvar, vvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets
); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>(((
__i)&0xfU)<<1))&3))) continue; (kvar) = ((h)->
keys[__i]); (vvar) = ((h)->vals[__i]); code; } }
{ khint_t __i; \
49 for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \
50 if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<<
1))&3))
) continue; \
51 (kvar) = kh_key(h,__i)((h)->keys[__i]); \
52 (vvar) = kh_val(h,__i)((h)->vals[__i]); \
53 code; \
54 } }
55#endif /*kh_foreach*/
56
57#if !defined(kh_foreach_key)
58/*! @function
59 @abstract Iterate over the keys in the hash table
60 @param h Pointer to the hash table [khash_t(name)*]
61 @param kvar Variable to which key will be assigned
62 @param code Block of code to execute
63 */
64#define kh_foreach_key(h, kvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets
); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>(((
__i)&0xfU)<<1))&3))) continue; (kvar) = ((h)->
keys[__i]); code; } }
{ khint_t __i; \
65 for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \
66 if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<<
1))&3))
) continue; \
67 (kvar) = kh_key(h,__i)((h)->keys[__i]); \
68 code; \
69 } }
70#endif /*kh_foreach_key*/
71
72#if !defined(kh_foreach_value)
73/*! @function
74 @abstract Iterate over the values in the hash table
75 @param h Pointer to the hash table [khash_t(name)*]
76 @param vvar Variable to which value will be assigned
77 @param code Block of code to execute
78 */
79#define kh_foreach_value(h, vvar, code){ khint_t __i; for (__i = (khint_t)(0); __i != ((h)->n_buckets
); ++__i) { if (!(!(((h)->flags[(__i)>>4]>>(((
__i)&0xfU)<<1))&3))) continue; (vvar) = ((h)->
vals[__i]); code; } }
{ khint_t __i; \
80 for (__i = kh_begin(h)(khint_t)(0); __i != kh_end(h)((h)->n_buckets); ++__i) { \
81 if (!kh_exist(h,__i)(!(((h)->flags[(__i)>>4]>>(((__i)&0xfU)<<
1))&3))
) continue; \
82 (vvar) = kh_val(h,__i)((h)->vals[__i]); \
83 code; \
84 } }
85#endif /*kh_foreach_value*/
86
87
88/* --- Helper macro for error checking --- */
89
90#if defined(PETSC_USE_DEBUG1)
91#define PetscHashAssert(expr)do { if (__builtin_expect(!!(!(expr)),0)) return PetscError((
(MPI_Comm)0x44000001),91,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashtable.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr"
); } while(0)
do { \
92 if (PetscUnlikely(!(expr))__builtin_expect(!!(!(expr)),0)) \
93 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_LIB, \return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashtable.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr"
)
94 "[khash] Assertion: `%s' failed.", \return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashtable.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr"
)
95 PetscStringize(expr))return PetscError(((MPI_Comm)0x44000001),95,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashtable.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr"
)
; \
96} while(0)
97#else
98#define PetscHashAssert(expr)do { if (__builtin_expect(!!(!(expr)),0)) return PetscError((
(MPI_Comm)0x44000001),98,__func__,"/sandbox/petsc/petsc.next-tmp/include/petsc/private/hashtable.h"
,76,PETSC_ERROR_INITIAL,"[khash] Assertion: `%s' failed.","expr"
); } while(0)
((void)(expr))
99#endif
100
101
102/* --- Low level iterator API --- */
103
104typedef khiter_t PetscHashIter;
105
106#define PetscHashIterBegin(ht,i)do { (i) = (khint_t)(0); if ((i) != (((ht))->n_buckets) &&
!(!((((ht))->flags[((i))>>4]>>((((i))&0xfU
)<<1))&3))) do { ++((i)); } while (((i)) != ((((ht)
))->n_buckets) && !(!(((((ht)))->flags[(((i)))>>
4]>>(((((i)))&0xfU)<<1))&3))); } while (0
)
do { \
107 (i) = kh_begin((ht))(khint_t)(0); \
108 if ((i) != kh_end((ht))(((ht))->n_buckets) && !kh_exist((ht),(i))(!((((ht))->flags[((i))>>4]>>((((i))&0xfU)
<<1))&3))
) \
109 PetscHashIterNext((ht),(i))do { ++((i)); } while (((i)) != ((((ht)))->n_buckets) &&
!(!(((((ht)))->flags[(((i)))>>4]>>(((((i)))&
0xfU)<<1))&3)))
; \
110} while (0)
111
112#define PetscHashIterNext(ht,i)do { ++(i); } while ((i) != (((ht))->n_buckets) &&
!(!((((ht))->flags[((i))>>4]>>((((i))&0xfU
)<<1))&3)))
\
113 do { ++(i); } while ((i) != kh_end((ht))(((ht))->n_buckets) && !kh_exist((ht),(i))(!((((ht))->flags[((i))>>4]>>((((i))&0xfU)
<<1))&3))
)
114
115#define PetscHashIterAtEnd(ht,i)((i) == (((ht))->n_buckets)) ((i) == kh_end((ht))(((ht))->n_buckets))
116
117#define PetscHashIterGetKey(ht,i,k)((k) = (((ht))->keys[(i)])) ((k) = kh_key((ht),(i))(((ht))->keys[(i)]))
118
119#define PetscHashIterGetVal(ht,i,v)((v) = (((ht))->vals[(i)])) ((v) = kh_val((ht),(i))(((ht))->vals[(i)]))
120
121#define PetscHashIterSetVal(ht,i,v)((((ht))->vals[(i)]) = (v)) (kh_val((ht),(i))(((ht))->vals[(i)]) = (v))
122
123
124/* --- Thomas Wang integer hash functions --- */
125
126typedef khint32_t PetscHash32_t;
127typedef khint64_t PetscHash64_t;
128typedef khint_t PetscHash_t;
129
130/* Thomas Wang's first version for 32bit integers */
131PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32_v0(PetscHash32_t key)
132{
133 key += ~(key << 15);
134 key ^= (key >> 10);
135 key += (key << 3);
136 key ^= (key >> 6);
137 key += ~(key << 11);
138 key ^= (key >> 16);
139 return key;
140}
141
142/* Thomas Wang's second version for 32bit integers */
143PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32_v1(PetscHash32_t key)
144{
145 key = ~key + (key << 15); /* key = (key << 15) - key - 1; */
146 key = key ^ (key >> 12);
147 key = key + (key << 2);
148 key = key ^ (key >> 4);
149 key = key * 2057; /* key = (key + (key << 3)) + (key << 11); */
150 key = key ^ (key >> 16);
151 return key;
152}
153
154PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt32(PetscHash32_t key)
155{
156 return PetscHash_UInt32_v1(key);
14
Calling 'PetscHash_UInt32_v1'
15
Returning from 'PetscHash_UInt32_v1'
157}
158
159/* Thomas Wang's version for 64bit integer -> 32bit hash */
160PETSC_STATIC_INLINEstatic inline PetscHash32_t PetscHash_UInt64_32(PetscHash64_t key)
161{
162 key = ~key + (key << 18); /* key = (key << 18) - key - 1; */
163 key = key ^ (key >> 31);
164 key = key * 21; /* key = (key + (key << 2)) + (key << 4); */
165 key = key ^ (key >> 11);
166 key = key + (key << 6);
167 key = key ^ (key >> 22);
168 return (PetscHash32_t)key;
169}
170
171/* Thomas Wang's version for 64bit integer -> 64bit hash */
172PETSC_STATIC_INLINEstatic inline PetscHash64_t PetscHash_UInt64_64(PetscHash64_t key)
173{
174 key = ~key + (key << 21); /* key = (key << 21) - key - 1; */
175 key = key ^ (key >> 24);
176 key = key * 265; /* key = (key + (key << 3)) + (key << 8); */
177 key = key ^ (key >> 14);
178 key = key * 21; /* key = (key + (key << 2)) + (key << 4); */
179 key = key ^ (key >> 28);
180 key = key + (key << 31);
181 return key;
182}
183
184PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHash_UInt64(PetscHash64_t key)
185{
186 return sizeof(PetscHash_t) < sizeof(PetscHash64_t)
187 ? (PetscHash_t)PetscHash_UInt64_32(key)
188 : (PetscHash_t)PetscHash_UInt64_64(key);
189}
190
191PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHashInt(PetscInt key)
192{
193#if defined(PETSC_USE_64BIT_INDICES)
194 return PetscHash_UInt64((PetscHash64_t)key);
195#else
196 return PetscHash_UInt32((PetscHash32_t)key);
13
Calling 'PetscHash_UInt32'
16
Returning from 'PetscHash_UInt32'
197#endif
198}
199
200PETSC_STATIC_INLINEstatic inline PetscHash_t PetscHashCombine(PetscHash_t seed, PetscHash_t hash)
201{
202 /* https://doi.org/10.1002/asi.10170 */
203 /* https://dl.acm.org/citation.cfm?id=759509 */
204 return seed ^ (hash + (seed << 6) + (seed >> 2));
205}
206
207#define PetscHashEqual(a,b)((a) == (b)) ((a) == (b))
208
209
210#endif /* PETSC_HASHTABLE_H */