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.master/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
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.seealso: DMSetType(), DMCreate()
25@*/
26PetscErrorCode DMPlexCreateDoublet(MPI_Comm comm, PetscInt dim, PetscBool simplex, PetscBool interpolate, PetscBool refinementUniform, PetscReal refinementLimit, DM *newdm)
27{
28 DM dm;
29 PetscInt p;
30 PetscMPIInt rank;
31 PetscErrorCode ierr;
32
33 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 33; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
34 ierr = DMCreate(comm, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),34,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
35 ierr = DMSetType(dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),35,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
36 ierr = DMSetDimension(dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),36,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
37 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),37,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
38 switch (dim) {
39 case 2:
40 if (simplex) {ierr = PetscObjectSetName((PetscObject) dm, "triangular");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),40,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
41 else {ierr = PetscObjectSetName((PetscObject) dm, "quadrilateral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),41,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
42 break;
43 case 3:
44 if (simplex) {ierr = PetscObjectSetName((PetscObject) dm, "tetrahedral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),44,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
45 else {ierr = PetscObjectSetName((PetscObject) dm, "hexahedral");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),45,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
46 break;
47 default:
48 SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Cannot make meshes for dimension %d", dim)return PetscError(comm,48,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Cannot make meshes for dimension %d"
,dim)
;
49 }
50 if (rank) {
51 PetscInt numPoints[2] = {0, 0};
52 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),52,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
53 } else {
54 switch (dim) {
55 case 2:
56 if (simplex) {
57 PetscInt numPoints[2] = {4, 2};
58 PetscInt coneSize[6] = {3, 3, 0, 0, 0, 0};
59 PetscInt cones[6] = {2, 3, 4, 5, 4, 3};
60 PetscInt coneOrientations[6] = {0, 0, 0, 0, 0, 0};
61 PetscScalar vertexCoords[8] = {-0.5, 0.5, 0.0, 0.0, 0.0, 1.0, 0.5, 0.5};
62 PetscInt markerPoints[8] = {2, 1, 3, 1, 4, 1, 5, 1};
63
64 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),64,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
65 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),65,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
66 } else {
67 PetscInt numPoints[2] = {6, 2};
68 PetscInt coneSize[8] = {4, 4, 0, 0, 0, 0, 0, 0};
69 PetscInt cones[8] = {2, 3, 4, 5, 3, 6, 7, 4};
70 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
71 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};
72
73 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),73,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
74 }
75 break;
76 case 3:
77 if (simplex) {
78 PetscInt numPoints[2] = {5, 2};
79 PetscInt coneSize[7] = {4, 4, 0, 0, 0, 0, 0};
80 PetscInt cones[8] = {4, 3, 5, 2, 5, 3, 4, 6};
81 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
82 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};
83 PetscInt markerPoints[10] = {2, 1, 3, 1, 4, 1, 5, 1, 6, 1};
84
85 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),85,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
86 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),86,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
87 } else {
88 PetscInt numPoints[2] = {12, 2};
89 PetscInt coneSize[14] = {8, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
90 PetscInt cones[16] = {2, 3, 4, 5, 6, 7, 8, 9, 5, 4, 10, 11, 7, 12, 13, 8};
91 PetscInt coneOrientations[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
92 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,
93 -1.0, -0.5, 0.5, 0.0, -0.5, 0.5, 0.0, 0.5, 0.5, -1.0, 0.5, 0.5,
94 1.0, 0.5, -0.5, 1.0, -0.5, -0.5, 1.0, -0.5, 0.5, 1.0, 0.5, 0.5};
95
96 ierr = DMPlexCreateFromDAG(dm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),96,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
97 }
98 break;
99 default:
100 SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Cannot make meshes for dimension %d", dim)return PetscError(comm,100,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Cannot make meshes for dimension %d"
,dim)
;
101 }
102 }
103 *newdm = dm;
104 if (refinementLimit > 0.0) {
105 DM rdm;
106 const char *name;
107
108 ierr = DMPlexSetRefinementUniform(*newdm, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),108,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
109 ierr = DMPlexSetRefinementLimit(*newdm, refinementLimit);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),109,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
110 ierr = DMRefine(*newdm, comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),110,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
111 ierr = PetscObjectGetName((PetscObject) *newdm, &name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),111,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
112 ierr = PetscObjectSetName((PetscObject) rdm, name);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),112,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
113 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),113,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
114 *newdm = rdm;
115 }
116 if (interpolate) {
117 DM idm;
118
119 ierr = DMPlexInterpolate(*newdm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),119,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
120 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),120,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
121 *newdm = idm;
122 }
123 {
124 DM refinedMesh = NULL((void*)0);
125 DM distributedMesh = NULL((void*)0);
126
127 /* Distribute mesh over processes */
128 ierr = DMPlexDistribute(*newdm, 0, NULL((void*)0), &distributedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),128,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
129 if (distributedMesh) {
130 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),130,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
131 *newdm = distributedMesh;
132 }
133 if (refinementUniform) {
134 ierr = DMPlexSetRefinementUniform(*newdm, refinementUniform);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),134,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
135 ierr = DMRefine(*newdm, comm, &refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),135,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
136 if (refinedMesh) {
137 ierr = DMDestroy(newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),137,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
138 *newdm = refinedMesh;
139 }
140 }
141 }
142 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)
;
143}
144
145/*@
146 DMPlexCreateSquareBoundary - Creates a 1D mesh the is the boundary of a square lattice.
147
148 Collective
149
150 Input Parameters:
151+ comm - The communicator for the DM object
152. lower - The lower left corner coordinates
153. upper - The upper right corner coordinates
154- edges - The number of cells in each direction
155
156 Output Parameter:
157. dm - The DM object
158
159 Note: Here is the numbering returned for 2 cells in each direction:
160$ 18--5-17--4--16
161$ | | |
162$ 6 10 3
163$ | | |
164$ 19-11-20--9--15
165$ | | |
166$ 7 8 2
167$ | | |
168$ 12--0-13--1--14
169
170 Level: beginner
171
172.seealso: DMPlexCreateBoxMesh(), DMPlexCreateCubeBoundary(), DMSetType(), DMCreate()
173@*/
174PetscErrorCode DMPlexCreateSquareBoundary(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt edges[])
175{
176 const PetscInt numVertices = (edges[0]+1)*(edges[1]+1);
177 const PetscInt numEdges = edges[0]*(edges[1]+1) + (edges[0]+1)*edges[1];
178 PetscInt markerTop = 1;
179 PetscInt markerBottom = 1;
180 PetscInt markerRight = 1;
181 PetscInt markerLeft = 1;
182 PetscBool markerSeparate = PETSC_FALSE;
183 Vec coordinates;
184 PetscSection coordSection;
185 PetscScalar *coords;
186 PetscInt coordSize;
187 PetscMPIInt rank;
188 PetscInt v, vx, vy;
189 PetscErrorCode ierr;
190
191 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 191; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
192 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),192,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
193 if (markerSeparate) {
194 markerTop = 3;
195 markerBottom = 1;
196 markerRight = 2;
197 markerLeft = 4;
198 }
199 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),199,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
200 if (!rank) {
201 PetscInt e, ex, ey;
202
203 ierr = DMPlexSetChart(dm, 0, numEdges+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),203,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
204 for (e = 0; e < numEdges; ++e) {
205 ierr = DMPlexSetConeSize(dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),205,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
206 }
207 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),207,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
208 for (vx = 0; vx <= edges[0]; vx++) {
209 for (ey = 0; ey < edges[1]; ey++) {
210 PetscInt edge = vx*edges[1] + ey + edges[0]*(edges[1]+1);
211 PetscInt vertex = ey*(edges[0]+1) + vx + numEdges;
212 PetscInt cone[2];
213
214 cone[0] = vertex; cone[1] = vertex+edges[0]+1;
215 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),215,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
216 if (vx == edges[0]) {
217 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),217,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
218 ierr = DMSetLabelValue(dm, "marker", cone[0], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),218,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
219 if (ey == edges[1]-1) {
220 ierr = DMSetLabelValue(dm, "marker", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),220,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
221 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),221,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
222 }
223 } else if (vx == 0) {
224 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),224,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
225 ierr = DMSetLabelValue(dm, "marker", cone[0], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),225,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
226 if (ey == edges[1]-1) {
227 ierr = DMSetLabelValue(dm, "marker", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),227,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
228 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),228,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
229 }
230 }
231 }
232 }
233 for (vy = 0; vy <= edges[1]; vy++) {
234 for (ex = 0; ex < edges[0]; ex++) {
235 PetscInt edge = vy*edges[0] + ex;
236 PetscInt vertex = vy*(edges[0]+1) + ex + numEdges;
237 PetscInt cone[2];
238
239 cone[0] = vertex; cone[1] = vertex+1;
240 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),240,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
241 if (vy == edges[1]) {
242 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),242,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
243 ierr = DMSetLabelValue(dm, "marker", cone[0], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),243,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
244 if (ex == edges[0]-1) {
245 ierr = DMSetLabelValue(dm, "marker", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),245,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
246 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),246,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
247 }
248 } else if (vy == 0) {
249 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),249,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
250 ierr = DMSetLabelValue(dm, "marker", cone[0], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),250,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
251 if (ex == edges[0]-1) {
252 ierr = DMSetLabelValue(dm, "marker", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),252,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
253 ierr = DMSetLabelValue(dm, "Face Sets", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),253,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
254 }
255 }
256 }
257 }
258 }
259 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),259,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
260 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),260,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
261 /* Build coordinates */
262 ierr = DMSetCoordinateDim(dm, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),262,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
263 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),263,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
264 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),264,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
265 ierr = PetscSectionSetChart(coordSection, numEdges, numEdges + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),265,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
266 ierr = PetscSectionSetFieldComponents(coordSection, 0, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),266,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
267 for (v = numEdges; v < numEdges+numVertices; ++v) {
268 ierr = PetscSectionSetDof(coordSection, v, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),268,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
269 ierr = PetscSectionSetFieldDof(coordSection, v, 0, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),269,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
270 }
271 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),271,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
272 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),272,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
273 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),273,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
274 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),274,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
275 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),275,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
276 ierr = VecSetBlockSize(coordinates, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),276,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
277 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),277,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
278 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),278,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
279 for (vy = 0; vy <= edges[1]; ++vy) {
280 for (vx = 0; vx <= edges[0]; ++vx) {
281 coords[(vy*(edges[0]+1)+vx)*2+0] = lower[0] + ((upper[0] - lower[0])/edges[0])*vx;
282 coords[(vy*(edges[0]+1)+vx)*2+1] = lower[1] + ((upper[1] - lower[1])/edges[1])*vy;
283 }
284 }
285 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),285,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
286 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),286,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
287 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),287,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
288 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)
;
289}
290
291/*@
292 DMPlexCreateCubeBoundary - Creates a 2D mesh that is the boundary of a cubic lattice.
293
294 Collective
295
296 Input Parameters:
297+ comm - The communicator for the DM object
298. lower - The lower left front corner coordinates
299. upper - The upper right back corner coordinates
300- edges - The number of cells in each direction
301
302 Output Parameter:
303. dm - The DM object
304
305 Level: beginner
306
307.seealso: DMPlexCreateBoxMesh(), DMPlexCreateSquareBoundary(), DMSetType(), DMCreate()
308@*/
309PetscErrorCode DMPlexCreateCubeBoundary(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt faces[])
310{
311 PetscInt vertices[3], numVertices;
312 PetscInt numFaces = 2*faces[0]*faces[1] + 2*faces[1]*faces[2] + 2*faces[0]*faces[2];
313 Vec coordinates;
314 PetscSection coordSection;
315 PetscScalar *coords;
316 PetscInt coordSize;
317 PetscMPIInt rank;
318 PetscInt v, vx, vy, vz;
319 PetscInt voffset, iface=0, cone[4];
320 PetscErrorCode ierr;
321
322 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 322; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
323 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),323,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Must have at least 1 face per side")
;
324 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),324,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
325 vertices[0] = faces[0]+1; vertices[1] = faces[1]+1; vertices[2] = faces[2]+1;
326 numVertices = vertices[0]*vertices[1]*vertices[2];
327 if (!rank) {
328 PetscInt f;
329
330 ierr = DMPlexSetChart(dm, 0, numFaces+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),330,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
331 for (f = 0; f < numFaces; ++f) {
332 ierr = DMPlexSetConeSize(dm, f, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),332,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
333 }
334 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),334,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
335
336 /* Side 0 (Top) */
337 for (vy = 0; vy < faces[1]; vy++) {
338 for (vx = 0; vx < faces[0]; vx++) {
339 voffset = numFaces + vertices[0]*vertices[1]*(vertices[2]-1) + vy*vertices[0] + vx;
340 cone[0] = voffset; cone[1] = voffset+1; cone[2] = voffset+vertices[0]+1; cone[3] = voffset+vertices[0];
341 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),341,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
342 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),342,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
343 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),343,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
344 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),344,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
345 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),345,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
346 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),346,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
347 iface++;
348 }
349 }
350
351 /* Side 1 (Bottom) */
352 for (vy = 0; vy < faces[1]; vy++) {
353 for (vx = 0; vx < faces[0]; vx++) {
354 voffset = numFaces + vy*(faces[0]+1) + vx;
355 cone[0] = voffset+1; cone[1] = voffset; cone[2] = voffset+vertices[0]; cone[3] = voffset+vertices[0]+1;
356 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),356,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
357 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),357,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
358 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),358,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
359 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),359,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
360 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),360,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
361 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),361,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
362 iface++;
363 }
364 }
365
366 /* Side 2 (Front) */
367 for (vz = 0; vz < faces[2]; vz++) {
368 for (vx = 0; vx < faces[0]; vx++) {
369 voffset = numFaces + vz*vertices[0]*vertices[1] + vx;
370 cone[0] = voffset; cone[1] = voffset+1; cone[2] = voffset+vertices[0]*vertices[1]+1; cone[3] = voffset+vertices[0]*vertices[1];
371 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),371,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
372 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),372,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
373 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),373,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
374 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),374,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
375 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),375,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
376 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),376,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
377 iface++;
378 }
379 }
380
381 /* Side 3 (Back) */
382 for (vz = 0; vz < faces[2]; vz++) {
383 for (vx = 0; vx < faces[0]; vx++) {
384 voffset = numFaces + vz*vertices[0]*vertices[1] + vertices[0]*(vertices[1]-1) + vx;
385 cone[0] = voffset+vertices[0]*vertices[1]; cone[1] = voffset+vertices[0]*vertices[1]+1;
386 cone[2] = voffset+1; cone[3] = voffset;
387 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),387,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
388 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),388,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
389 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),389,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
390 ierr = DMSetLabelValue(dm, "marker", voffset+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),390,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
391 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),391,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
392 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+1, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),392,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
393 iface++;
394 }
395 }
396
397 /* Side 4 (Left) */
398 for (vz = 0; vz < faces[2]; vz++) {
399 for (vy = 0; vy < faces[1]; vy++) {
400 voffset = numFaces + vz*vertices[0]*vertices[1] + vy*vertices[0];
401 cone[0] = voffset; cone[1] = voffset+vertices[0]*vertices[1];
402 cone[2] = voffset+vertices[0]*vertices[1]+vertices[0]; cone[3] = voffset+vertices[0];
403 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),403,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
404 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),404,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
405 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),405,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
406 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),406,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
407 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),407,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
408 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),408,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
409 iface++;
410 }
411 }
412
413 /* Side 5 (Right) */
414 for (vz = 0; vz < faces[2]; vz++) {
415 for (vy = 0; vy < faces[1]; vy++) {
416 voffset = numFaces + vz*vertices[0]*vertices[1] + vy*vertices[0] + faces[0];
417 cone[0] = voffset+vertices[0]*vertices[1]; cone[1] = voffset;
418 cone[2] = voffset+vertices[0]; cone[3] = voffset+vertices[0]*vertices[1]+vertices[0];
419 ierr = DMPlexSetCone(dm, iface, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),419,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
420 ierr = DMSetLabelValue(dm, "marker", iface, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),420,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
421 ierr = DMSetLabelValue(dm, "marker", voffset+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),421,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
422 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),422,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
423 ierr = DMSetLabelValue(dm, "marker", voffset+vertices[0]*vertices[1]+0, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),423,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
424 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),424,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
425 iface++;
426 }
427 }
428 }
429 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),429,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
430 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),430,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
431 /* Build coordinates */
432 ierr = DMSetCoordinateDim(dm, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),432,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
433 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),433,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
434 ierr = PetscSectionSetChart(coordSection, numFaces, numFaces + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),434,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
435 for (v = numFaces; v < numFaces+numVertices; ++v) {
436 ierr = PetscSectionSetDof(coordSection, v, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),436,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
437 }
438 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),438,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
439 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),439,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
440 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),440,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
441 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),441,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
442 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),442,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
443 ierr = VecSetBlockSize(coordinates, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),443,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
444 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),444,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
445 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),445,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
446 for (vz = 0; vz <= faces[2]; ++vz) {
447 for (vy = 0; vy <= faces[1]; ++vy) {
448 for (vx = 0; vx <= faces[0]; ++vx) {
449 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+0] = lower[0] + ((upper[0] - lower[0])/faces[0])*vx;
450 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+1] = lower[1] + ((upper[1] - lower[1])/faces[1])*vy;
451 coords[((vz*(faces[1]+1)+vy)*(faces[0]+1)+vx)*3+2] = lower[2] + ((upper[2] - lower[2])/faces[2])*vz;
452 }
453 }
454 }
455 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),455,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
456 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),456,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
457 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),457,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
458 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)
;
459}
460
461static PetscErrorCode DMPlexCreateLineMesh_Internal(MPI_Comm comm,PetscInt segments,PetscReal lower,PetscReal upper,DMBoundaryType bd,DM *dm)
462{
463 PetscInt i,fStart,fEnd,numCells = 0,numVerts = 0;
464 PetscInt numPoints[2],*coneSize,*cones,*coneOrientations;
465 PetscScalar *vertexCoords;
466 PetscReal L,maxCell;
467 PetscBool markerSeparate = PETSC_FALSE;
468 PetscInt markerLeft = 1, faceMarkerLeft = 1;
469 PetscInt markerRight = 1, faceMarkerRight = 2;
470 PetscBool wrap = (bd == DM_BOUNDARY_PERIODIC || bd == DM_BOUNDARY_TWIST) ? PETSC_TRUE : PETSC_FALSE;
471 PetscMPIInt rank;
472 PetscErrorCode ierr;
473
474 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 474; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
475 PetscValidPointer(dm,4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),475,__func__
,"/sandbox/petsc/petsc.master/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),475,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
476
477 ierr = DMCreate(comm,dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),477,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
478 ierr = DMSetType(*dm,DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),478,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
479 ierr = DMSetDimension(*dm,1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),479,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
480 ierr = DMCreateLabel(*dm,"marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),480,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
481 ierr = DMCreateLabel(*dm,"Face Sets");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),481,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
482
483 ierr = MPI_Comm_rank(comm,&rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),483,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
484 if (!rank) numCells = segments;
485 if (!rank) numVerts = segments + (wrap ? 0 : 1);
486
487 numPoints[0] = numVerts ; numPoints[1] = numCells;
488 ierr = PetscMalloc4(numCells+numVerts,&coneSize,numCells*2,&cones,numCells+numVerts,&coneOrientations,numVerts,&vertexCoords)PetscMallocA(4,PETSC_FALSE,488,__func__,"/sandbox/petsc/petsc.master/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),488,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
489 ierr = PetscArrayzero(coneOrientations,numCells+numVerts)PetscMemzero(coneOrientations,(numCells+numVerts)*sizeof(*(coneOrientations
)));
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),489,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
490 for (i = 0; i < numCells; ++i) { coneSize[i] = 2; }
491 for (i = 0; i < numVerts; ++i) { coneSize[numCells+i] = 0; }
492 for (i = 0; i < numCells; ++i) { cones[2*i] = numCells + i%numVerts; cones[2*i+1] = numCells + (i+1)%numVerts; }
493 for (i = 0; i < numVerts; ++i) { vertexCoords[i] = lower + (upper-lower)*((PetscReal)i/(PetscReal)numCells); }
494 ierr = DMPlexCreateFromDAG(*dm,1,numPoints,coneSize,cones,coneOrientations,vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),494,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
495 ierr = PetscFree4(coneSize,cones,coneOrientations,vertexCoords)PetscFreeA(4,495,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,&(coneSize),&(cones),&(coneOrientations),&(vertexCoords
))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),495,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
496
497 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),497,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
498 if (markerSeparate) { markerLeft = faceMarkerLeft; markerRight = faceMarkerRight;}
499 if (!wrap && !rank) {
500 ierr = DMPlexGetHeightStratum(*dm,1,&fStart,&fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),500,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
501 ierr = DMSetLabelValue(*dm,"marker",fStart,markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),501,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
502 ierr = DMSetLabelValue(*dm,"marker",fEnd-1,markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),502,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
503 ierr = DMSetLabelValue(*dm,"Face Sets",fStart,faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),503,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
504 ierr = DMSetLabelValue(*dm,"Face Sets",fEnd-1,faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),504,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
505 }
506 if (wrap) {
507 L = upper - lower;
508 maxCell = (PetscReal)1.1*(L/(PetscReal)PetscMax(1,segments)(((1)<(segments)) ? (segments) : (1)));
509 ierr = DMSetPeriodicity(*dm,PETSC_TRUE,&maxCell,&L,&bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),509,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
510 }
511 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)
;
512}
513
514static 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)
515{
516 DM boundary;
517 PetscInt i;
518 PetscErrorCode ierr;
519
520 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 520; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
521 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),521,__func__
,"/sandbox/petsc/petsc.master/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),521,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
522 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,522,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Periodicity is not supported for simplex meshes"
)
;
523 ierr = DMCreate(comm, &boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),523,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
524 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,524,__func__,"/sandbox/petsc/petsc.master/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),524,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)boundary)
,524,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
525 ierr = DMSetType(boundary, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),525,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
526 ierr = DMSetDimension(boundary, dim-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),526,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
527 ierr = DMSetCoordinateDim(boundary, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),527,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
528 switch (dim) {
529 case 2: ierr = DMPlexCreateSquareBoundary(boundary, lower, upper, faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),529,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;
530 case 3: ierr = DMPlexCreateCubeBoundary(boundary, lower, upper, faces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),530,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;
531 default: SETERRQ1(comm, PETSC_ERR_SUP, "Dimension not supported: %d", dim)return PetscError(comm,531,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension not supported: %d",dim)
;
532 }
533 ierr = DMPlexGenerate(boundary, NULL((void*)0), interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),533,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
534 ierr = DMDestroy(&boundary);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),534,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
535 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)
;
536}
537
538static PetscErrorCode DMPlexCreateCubeMesh_Internal(DM dm, const PetscReal lower[], const PetscReal upper[], const PetscInt edges[], DMBoundaryType bdX, DMBoundaryType bdY, DMBoundaryType bdZ)
539{
540 DMLabel cutLabel = NULL((void*)0);
541 PetscInt markerTop = 1, faceMarkerTop = 1;
542 PetscInt markerBottom = 1, faceMarkerBottom = 1;
543 PetscInt markerFront = 1, faceMarkerFront = 1;
544 PetscInt markerBack = 1, faceMarkerBack = 1;
545 PetscInt markerRight = 1, faceMarkerRight = 1;
546 PetscInt markerLeft = 1, faceMarkerLeft = 1;
547 PetscInt dim;
548 PetscBool markerSeparate = PETSC_FALSE, cutMarker = PETSC_FALSE;
549 PetscMPIInt rank;
550 PetscErrorCode ierr;
551
552 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 552; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
553 ierr = DMGetDimension(dm,&dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),553,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
554 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject)dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),554,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
555 ierr = DMCreateLabel(dm,"marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),555,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
556 ierr = DMCreateLabel(dm,"Face Sets");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),556,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
557 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),557,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
558 if (bdX == DM_BOUNDARY_PERIODIC || bdX == DM_BOUNDARY_TWIST ||
559 bdY == DM_BOUNDARY_PERIODIC || bdY == DM_BOUNDARY_TWIST ||
560 bdZ == DM_BOUNDARY_PERIODIC || bdZ == DM_BOUNDARY_TWIST) {
561
562 if (cutMarker) {ierr = DMCreateLabel(dm, "periodic_cut");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),562,__func__,"/sandbox/petsc/petsc.master/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),562,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
563 }
564 switch (dim) {
565 case 2:
566 faceMarkerTop = 3;
567 faceMarkerBottom = 1;
568 faceMarkerRight = 2;
569 faceMarkerLeft = 4;
570 break;
571 case 3:
572 faceMarkerBottom = 1;
573 faceMarkerTop = 2;
574 faceMarkerFront = 3;
575 faceMarkerBack = 4;
576 faceMarkerRight = 5;
577 faceMarkerLeft = 6;
578 break;
579 default:
580 SETERRQ1(PETSC_COMM_SELF,PETSC_ERR_SUP,"Dimension %d not supported",dim)return PetscError(((MPI_Comm)0x44000001),580,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension %d not supported",dim)
;
581 break;
582 }
583 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),583,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
584 if (markerSeparate) {
585 markerBottom = faceMarkerBottom;
586 markerTop = faceMarkerTop;
587 markerFront = faceMarkerFront;
588 markerBack = faceMarkerBack;
589 markerRight = faceMarkerRight;
590 markerLeft = faceMarkerLeft;
591 }
592 {
593 const PetscInt numXEdges = !rank ? edges[0] : 0;
594 const PetscInt numYEdges = !rank ? edges[1] : 0;
595 const PetscInt numZEdges = !rank ? edges[2] : 0;
596 const PetscInt numXVertices = !rank ? (bdX == DM_BOUNDARY_PERIODIC || bdX == DM_BOUNDARY_TWIST ? edges[0] : edges[0]+1) : 0;
597 const PetscInt numYVertices = !rank ? (bdY == DM_BOUNDARY_PERIODIC || bdY == DM_BOUNDARY_TWIST ? edges[1] : edges[1]+1) : 0;
598 const PetscInt numZVertices = !rank ? (bdZ == DM_BOUNDARY_PERIODIC || bdZ == DM_BOUNDARY_TWIST ? edges[2] : edges[2]+1) : 0;
599 const PetscInt numCells = numXEdges*numYEdges*numZEdges;
600 const PetscInt numXFaces = numYEdges*numZEdges;
601 const PetscInt numYFaces = numXEdges*numZEdges;
602 const PetscInt numZFaces = numXEdges*numYEdges;
603 const PetscInt numTotXFaces = numXVertices*numXFaces;
604 const PetscInt numTotYFaces = numYVertices*numYFaces;
605 const PetscInt numTotZFaces = numZVertices*numZFaces;
606 const PetscInt numFaces = numTotXFaces + numTotYFaces + numTotZFaces;
607 const PetscInt numTotXEdges = numXEdges*numYVertices*numZVertices;
608 const PetscInt numTotYEdges = numYEdges*numXVertices*numZVertices;
609 const PetscInt numTotZEdges = numZEdges*numXVertices*numYVertices;
610 const PetscInt numVertices = numXVertices*numYVertices*numZVertices;
611 const PetscInt numEdges = numTotXEdges + numTotYEdges + numTotZEdges;
612 const PetscInt firstVertex = (dim == 2) ? numFaces : numCells;
613 const PetscInt firstXFace = (dim == 2) ? 0 : numCells + numVertices;
614 const PetscInt firstYFace = firstXFace + numTotXFaces;
615 const PetscInt firstZFace = firstYFace + numTotYFaces;
616 const PetscInt firstXEdge = numCells + numFaces + numVertices;
617 const PetscInt firstYEdge = firstXEdge + numTotXEdges;
618 const PetscInt firstZEdge = firstYEdge + numTotYEdges;
619 Vec coordinates;
620 PetscSection coordSection;
621 PetscScalar *coords;
622 PetscInt coordSize;
623 PetscInt v, vx, vy, vz;
624 PetscInt c, f, fx, fy, fz, e, ex, ey, ez;
625
626 ierr = DMPlexSetChart(dm, 0, numCells+numFaces+numEdges+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),626,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
627 for (c = 0; c < numCells; c++) {
628 ierr = DMPlexSetConeSize(dm, c, 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),628,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
629 }
630 for (f = firstXFace; f < firstXFace+numFaces; ++f) {
631 ierr = DMPlexSetConeSize(dm, f, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),631,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
632 }
633 for (e = firstXEdge; e < firstXEdge+numEdges; ++e) {
634 ierr = DMPlexSetConeSize(dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),634,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
635 }
636 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),636,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
637 /* Build cells */
638 for (fz = 0; fz < numZEdges; ++fz) {
639 for (fy = 0; fy < numYEdges; ++fy) {
640 for (fx = 0; fx < numXEdges; ++fx) {
641 PetscInt cell = (fz*numYEdges + fy)*numXEdges + fx;
642 PetscInt faceB = firstZFace + (fy*numXEdges+fx)*numZVertices + fz;
643 PetscInt faceT = firstZFace + (fy*numXEdges+fx)*numZVertices + ((fz+1)%numZVertices);
644 PetscInt faceF = firstYFace + (fz*numXEdges+fx)*numYVertices + fy;
645 PetscInt faceK = firstYFace + (fz*numXEdges+fx)*numYVertices + ((fy+1)%numYVertices);
646 PetscInt faceL = firstXFace + (fz*numYEdges+fy)*numXVertices + fx;
647 PetscInt faceR = firstXFace + (fz*numYEdges+fy)*numXVertices + ((fx+1)%numXVertices);
648 /* B, T, F, K, R, L */
649 PetscInt ornt[6] = {-4, 0, 0, -1, 0, -4}; /* ??? */
650 PetscInt cone[6];
651
652 /* no boundary twisting in 3D */
653 cone[0] = faceB; cone[1] = faceT; cone[2] = faceF; cone[3] = faceK; cone[4] = faceR; cone[5] = faceL;
654 ierr = DMPlexSetCone(dm, cell, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),654,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
655 ierr = DMPlexSetConeOrientation(dm, cell, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),655,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
656 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),656,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
657 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),657,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
658 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),658,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
659 }
660 }
661 }
662 /* Build x faces */
663 for (fz = 0; fz < numZEdges; ++fz) {
664 for (fy = 0; fy < numYEdges; ++fy) {
665 for (fx = 0; fx < numXVertices; ++fx) {
666 PetscInt face = firstXFace + (fz*numYEdges+fy)*numXVertices + fx;
667 PetscInt edgeL = firstZEdge + ( fy* numXVertices+fx)*numZEdges + fz;
668 PetscInt edgeR = firstZEdge + (((fy+1)%numYVertices)*numXVertices+fx)*numZEdges + fz;
669 PetscInt edgeB = firstYEdge + ( fz* numXVertices+fx)*numYEdges + fy;
670 PetscInt edgeT = firstYEdge + (((fz+1)%numZVertices)*numXVertices+fx)*numYEdges + fy;
671 PetscInt ornt[4] = {0, 0, -2, -2};
672 PetscInt cone[4];
673
674 if (dim == 3) {
675 /* markers */
676 if (bdX != DM_BOUNDARY_PERIODIC) {
677 if (fx == numXVertices-1) {
678 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),678,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
679 ierr = DMSetLabelValue(dm, "marker", face, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),679,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
680 }
681 else if (fx == 0) {
682 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),682,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
683 ierr = DMSetLabelValue(dm, "marker", face, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),683,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
684 }
685 }
686 }
687 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
688 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),688,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
689 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),689,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
690 }
691 }
692 }
693 /* Build y faces */
694 for (fz = 0; fz < numZEdges; ++fz) {
695 for (fx = 0; fx < numXEdges; ++fx) {
696 for (fy = 0; fy < numYVertices; ++fy) {
697 PetscInt face = firstYFace + (fz*numXEdges+fx)*numYVertices + fy;
698 PetscInt edgeL = firstZEdge + (fy*numXVertices+ fx )*numZEdges + fz;
699 PetscInt edgeR = firstZEdge + (fy*numXVertices+((fx+1)%numXVertices))*numZEdges + fz;
700 PetscInt edgeB = firstXEdge + ( fz *numYVertices+fy)*numXEdges + fx;
701 PetscInt edgeT = firstXEdge + (((fz+1)%numZVertices)*numYVertices+fy)*numXEdges + fx;
702 PetscInt ornt[4] = {0, 0, -2, -2};
703 PetscInt cone[4];
704
705 if (dim == 3) {
706 /* markers */
707 if (bdY != DM_BOUNDARY_PERIODIC) {
708 if (fy == numYVertices-1) {
709 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),709,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
710 ierr = DMSetLabelValue(dm, "marker", face, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),710,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
711 }
712 else if (fy == 0) {
713 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),713,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
714 ierr = DMSetLabelValue(dm, "marker", face, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),714,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
715 }
716 }
717 }
718 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
719 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),719,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
720 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),720,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
721 }
722 }
723 }
724 /* Build z faces */
725 for (fy = 0; fy < numYEdges; ++fy) {
726 for (fx = 0; fx < numXEdges; ++fx) {
727 for (fz = 0; fz < numZVertices; fz++) {
728 PetscInt face = firstZFace + (fy*numXEdges+fx)*numZVertices + fz;
729 PetscInt edgeL = firstYEdge + (fz*numXVertices+ fx )*numYEdges + fy;
730 PetscInt edgeR = firstYEdge + (fz*numXVertices+((fx+1)%numXVertices))*numYEdges + fy;
731 PetscInt edgeB = firstXEdge + (fz*numYVertices+ fy )*numXEdges + fx;
732 PetscInt edgeT = firstXEdge + (fz*numYVertices+((fy+1)%numYVertices))*numXEdges + fx;
733 PetscInt ornt[4] = {0, 0, -2, -2};
734 PetscInt cone[4];
735
736 if (dim == 2) {
737 if (bdX == DM_BOUNDARY_TWIST && fx == numXEdges-1) {edgeR += numYEdges-1-2*fy; ornt[1] = -2;}
738 if (bdY == DM_BOUNDARY_TWIST && fy == numYEdges-1) {edgeT += numXEdges-1-2*fx; ornt[2] = 0;}
739 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),739,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
740 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),740,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
741 } else {
742 /* markers */
743 if (bdZ != DM_BOUNDARY_PERIODIC) {
744 if (fz == numZVertices-1) {
745 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),745,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
746 ierr = DMSetLabelValue(dm, "marker", face, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),746,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
747 }
748 else if (fz == 0) {
749 ierr = DMSetLabelValue(dm, "Face Sets", face, faceMarkerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),749,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
750 ierr = DMSetLabelValue(dm, "marker", face, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),750,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
751 }
752 }
753 }
754 cone[0] = edgeB; cone[1] = edgeR; cone[2] = edgeT; cone[3] = edgeL;
755 ierr = DMPlexSetCone(dm, face, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),755,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
756 ierr = DMPlexSetConeOrientation(dm, face, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),756,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
757 }
758 }
759 }
760 /* Build Z edges*/
761 for (vy = 0; vy < numYVertices; vy++) {
762 for (vx = 0; vx < numXVertices; vx++) {
763 for (ez = 0; ez < numZEdges; ez++) {
764 const PetscInt edge = firstZEdge + (vy*numXVertices+vx)*numZEdges + ez;
765 const PetscInt vertexB = firstVertex + ( ez *numYVertices+vy)*numXVertices + vx;
766 const PetscInt vertexT = firstVertex + (((ez+1)%numZVertices)*numYVertices+vy)*numXVertices + vx;
767 PetscInt cone[2];
768
769 if (dim == 3) {
770 if (bdX != DM_BOUNDARY_PERIODIC) {
771 if (vx == numXVertices-1) {
772 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),772,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
773 }
774 else if (vx == 0) {
775 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),775,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
776 }
777 }
778 if (bdY != DM_BOUNDARY_PERIODIC) {
779 if (vy == numYVertices-1) {
780 ierr = DMSetLabelValue(dm, "marker", edge, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),780,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
781 }
782 else if (vy == 0) {
783 ierr = DMSetLabelValue(dm, "marker", edge, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),783,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
784 }
785 }
786 }
787 cone[0] = vertexB; cone[1] = vertexT;
788 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),788,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
789 }
790 }
791 }
792 /* Build Y edges*/
793 for (vz = 0; vz < numZVertices; vz++) {
794 for (vx = 0; vx < numXVertices; vx++) {
795 for (ey = 0; ey < numYEdges; ey++) {
796 const PetscInt nextv = (dim == 2 && bdY == DM_BOUNDARY_TWIST && ey == numYEdges-1) ? (numXVertices-vx-1) : (vz*numYVertices+((ey+1)%numYVertices))*numXVertices + vx;
797 const PetscInt edge = firstYEdge + (vz*numXVertices+vx)*numYEdges + ey;
798 const PetscInt vertexF = firstVertex + (vz*numYVertices+ey)*numXVertices + vx;
799 const PetscInt vertexK = firstVertex + nextv;
800 PetscInt cone[2];
801
802 cone[0] = vertexF; cone[1] = vertexK;
803 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),803,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
804 if (dim == 2) {
805 if ((bdX != DM_BOUNDARY_PERIODIC) && (bdX != DM_BOUNDARY_TWIST)) {
806 if (vx == numXVertices-1) {
807 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),807,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
808 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),808,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
809 ierr = DMSetLabelValue(dm, "marker", cone[0], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),809,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
810 if (ey == numYEdges-1) {
811 ierr = DMSetLabelValue(dm, "marker", cone[1], markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),811,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
812 }
813 } else if (vx == 0) {
814 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),814,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
815 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),815,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
816 ierr = DMSetLabelValue(dm, "marker", cone[0], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),816,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
817 if (ey == numYEdges-1) {
818 ierr = DMSetLabelValue(dm, "marker", cone[1], markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),818,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
819 }
820 }
821 } else {
822 if (vx == 0 && cutLabel) {
823 ierr = DMLabelSetValue(cutLabel, edge, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),823,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
824 ierr = DMLabelSetValue(cutLabel, cone[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),824,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
825 if (ey == numYEdges-1) {
826 ierr = DMLabelSetValue(cutLabel, cone[1], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),826,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
827 }
828 }
829 }
830 } else {
831 if (bdX != DM_BOUNDARY_PERIODIC) {
832 if (vx == numXVertices-1) {
833 ierr = DMSetLabelValue(dm, "marker", edge, markerRight);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),833,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
834 } else if (vx == 0) {
835 ierr = DMSetLabelValue(dm, "marker", edge, markerLeft);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),835,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
836 }
837 }
838 if (bdZ != DM_BOUNDARY_PERIODIC) {
839 if (vz == numZVertices-1) {
840 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),840,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
841 } else if (vz == 0) {
842 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),842,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
843 }
844 }
845 }
846 }
847 }
848 }
849 /* Build X edges*/
850 for (vz = 0; vz < numZVertices; vz++) {
851 for (vy = 0; vy < numYVertices; vy++) {
852 for (ex = 0; ex < numXEdges; ex++) {
853 const PetscInt nextv = (dim == 2 && bdX == DM_BOUNDARY_TWIST && ex == numXEdges-1) ? (numYVertices-vy-1)*numXVertices : (vz*numYVertices+vy)*numXVertices + (ex+1)%numXVertices;
854 const PetscInt edge = firstXEdge + (vz*numYVertices+vy)*numXEdges + ex;
855 const PetscInt vertexL = firstVertex + (vz*numYVertices+vy)*numXVertices + ex;
856 const PetscInt vertexR = firstVertex + nextv;
857 PetscInt cone[2];
858
859 cone[0] = vertexL; cone[1] = vertexR;
860 ierr = DMPlexSetCone(dm, edge, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),860,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
861 if (dim == 2) {
862 if ((bdY != DM_BOUNDARY_PERIODIC) && (bdY != DM_BOUNDARY_TWIST)) {
863 if (vy == numYVertices-1) {
864 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),864,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
865 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),865,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
866 ierr = DMSetLabelValue(dm, "marker", cone[0], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),866,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
867 if (ex == numXEdges-1) {
868 ierr = DMSetLabelValue(dm, "marker", cone[1], markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),868,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
869 }
870 } else if (vy == 0) {
871 ierr = DMSetLabelValue(dm, "Face Sets", edge, faceMarkerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),871,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
872 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),872,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
873 ierr = DMSetLabelValue(dm, "marker", cone[0], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),873,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
874 if (ex == numXEdges-1) {
875 ierr = DMSetLabelValue(dm, "marker", cone[1], markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),875,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
876 }
877 }
878 } else {
879 if (vy == 0 && cutLabel) {
880 ierr = DMLabelSetValue(cutLabel, edge, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),880,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
881 ierr = DMLabelSetValue(cutLabel, cone[0], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),881,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
882 if (ex == numXEdges-1) {
883 ierr = DMLabelSetValue(cutLabel, cone[1], 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),883,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
884 }
885 }
886 }
887 } else {
888 if (bdY != DM_BOUNDARY_PERIODIC) {
889 if (vy == numYVertices-1) {
890 ierr = DMSetLabelValue(dm, "marker", edge, markerBack);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),890,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
891 }
892 else if (vy == 0) {
893 ierr = DMSetLabelValue(dm, "marker", edge, markerFront);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),893,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
894 }
895 }
896 if (bdZ != DM_BOUNDARY_PERIODIC) {
897 if (vz == numZVertices-1) {
898 ierr = DMSetLabelValue(dm, "marker", edge, markerTop);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),898,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
899 }
900 else if (vz == 0) {
901 ierr = DMSetLabelValue(dm, "marker", edge, markerBottom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),901,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
902 }
903 }
904 }
905 }
906 }
907 }
908 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),908,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
909 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),909,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
910 /* Build coordinates */
911 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),911,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
912 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),912,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
913 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),913,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
914 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),914,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
915 for (v = firstVertex; v < firstVertex+numVertices; ++v) {
916 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),916,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
917 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),917,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
918 }
919 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),919,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
920 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),920,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
921 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),921,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
922 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),922,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
923 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),923,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
924 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),924,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
925 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),925,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
926 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),926,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
927 for (vz = 0; vz < numZVertices; ++vz) {
928 for (vy = 0; vy < numYVertices; ++vy) {
929 for (vx = 0; vx < numXVertices; ++vx) {
930 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+0] = lower[0] + ((upper[0] - lower[0])/numXEdges)*vx;
931 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+1] = lower[1] + ((upper[1] - lower[1])/numYEdges)*vy;
932 if (dim == 3) {
933 coords[((vz*numYVertices+vy)*numXVertices+vx)*dim+2] = lower[2] + ((upper[2] - lower[2])/numZEdges)*vz;
934 }
935 }
936 }
937 }
938 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),938,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
939 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),939,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
940 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),940,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
941 }
942 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)
;
943}
944
945static 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)
946{
947 PetscInt i;
948 PetscErrorCode ierr;
949
950 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 950; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
951 PetscValidPointer(dm, 7)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),951,__func__
,"/sandbox/petsc/petsc.master/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),951,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",7);
} while (0)
;
952 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),952,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
953 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,953,__func__,"/sandbox/petsc/petsc.master/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),953,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),953,
__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
954 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),954,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
955 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),955,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
956 switch (dim) {
957 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),957,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;}
958 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),958,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;break;}
959 default: SETERRQ1(comm, PETSC_ERR_SUP, "Dimension not supported: %d", dim)return PetscError(comm,959,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Dimension not supported: %d",dim)
;
960 }
961 if (periodicity[0] == DM_BOUNDARY_PERIODIC || periodicity[0] == DM_BOUNDARY_TWIST ||
962 periodicity[1] == DM_BOUNDARY_PERIODIC || periodicity[1] == DM_BOUNDARY_TWIST ||
963 (dim > 2 && (periodicity[2] == DM_BOUNDARY_PERIODIC || periodicity[2] == DM_BOUNDARY_TWIST))) {
964 PetscReal L[3];
965 PetscReal maxCell[3];
966
967 for (i = 0; i < dim; i++) {
968 L[i] = upper[i] - lower[i];
969 maxCell[i] = 1.1 * (L[i] / PetscMax(1,faces[i])(((1)<(faces[i])) ? (faces[i]) : (1)));
970 }
971 ierr = DMSetPeriodicity(*dm,PETSC_TRUE,maxCell,L,periodicity);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),971,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
972 }
973 if (!interpolate) {
974 DM udm;
975
976 ierr = DMPlexUninterpolate(*dm, &udm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),976,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
977 ierr = DMPlexCopyCoordinates(*dm, udm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),977,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
978 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),978,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
979 *dm = udm;
980 }
981 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)
;
982}
983
984/*@C
985 DMPlexCreateBoxMesh - Creates a mesh on the tensor product of unit intervals (box) using simplices or tensor cells (hexahedra).
986
987 Collective
988
989 Input Parameters:
990+ comm - The communicator for the DM object
991. dim - The spatial dimension
992. simplex - PETSC_TRUE for simplices, PETSC_FALSE for tensor cells
993. faces - Number of faces per dimension, or NULL for (1,) in 1D and (2, 2) in 2D and (1, 1, 1) in 3D
994. lower - The lower left corner, or NULL for (0, 0, 0)
995. upper - The upper right corner, or NULL for (1, 1, 1)
996. periodicity - The boundary type for the X,Y,Z direction, or NULL for DM_BOUNDARY_NONE
997- interpolate - Flag to create intermediate mesh pieces (edges, faces)
998
999 Output Parameter:
1000. dm - The DM object
1001
1002 Options Database Keys:
1003+ -dm_plex_box_lower <x,y,z> - Specify lower-left-bottom coordinates for the box
1004- -dm_plex_box_upper <x,y,z> - Specify upper-right-top coordinates for the box
1005
1006 Note: Here is the numbering returned for 2 faces in each direction for tensor cells:
1007$ 10---17---11---18----12
1008$ | | |
1009$ | | |
1010$ 20 2 22 3 24
1011$ | | |
1012$ | | |
1013$ 7---15----8---16----9
1014$ | | |
1015$ | | |
1016$ 19 0 21 1 23
1017$ | | |
1018$ | | |
1019$ 4---13----5---14----6
1020
1021and for simplicial cells
1022
1023$ 14----8---15----9----16
1024$ |\ 5 |\ 7 |
1025$ | \ | \ |
1026$ 13 2 14 3 15
1027$ | 4 \ | 6 \ |
1028$ | \ | \ |
1029$ 11----6---12----7----13
1030$ |\ |\ |
1031$ | \ 1 | \ 3 |
1032$ 10 0 11 1 12
1033$ | 0 \ | 2 \ |
1034$ | \ | \ |
1035$ 8----4----9----5----10
1036
1037 Level: beginner
1038
1039.seealso: DMPlexCreateFromFile(), DMPlexCreateHexCylinderMesh(), DMSetType(), DMCreate()
1040@*/
1041PetscErrorCode DMPlexCreateBoxMesh(MPI_Comm comm, PetscInt dim, PetscBool simplex, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool interpolate, DM *dm)
1042{
1043 PetscInt fac[3] = {0, 0, 0};
1044 PetscReal low[3] = {0, 0, 0};
1045 PetscReal upp[3] = {1, 1, 1};
1046 DMBoundaryType bdt[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
1047 PetscInt i, n;
1048 PetscBool flg;
1049 PetscErrorCode ierr;
1050
1051 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1051; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1052 n = 3;
1053 ierr = PetscOptionsGetIntArray(NULL((void*)0), NULL((void*)0), "-dm_plex_box_faces", fac, &n, &flg);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1053,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1054 for (i = 0; i < dim; ++i) fac[i] = faces ? faces[i] : (flg && i < n ? fac[i] : (dim == 1 ? 1 : 4-dim));
1055 if (lower) for (i = 0; i < dim; ++i) low[i] = lower[i];
1056 if (upper) for (i = 0; i < dim; ++i) upp[i] = upper[i];
1057 if (periodicity) for (i = 0; i < dim; ++i) bdt[i] = periodicity[i];
1058 /* Allow bounds to be specified from the command line */
1059 n = 3;
1060 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),1060,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1061 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,1061,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,60,PETSC_ERROR_INITIAL,"Lower box point had %D values, should have been %D"
,n,dim)
;
1062 n = 3;
1063 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),1063,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1064 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,1064,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,60,PETSC_ERROR_INITIAL,"Upper box point had %D values, should have been %D"
,n,dim)
;
1065
1066 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),1066,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1067 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),1067,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1068 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),1068,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1069 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)
;
1070}
1071
1072/*@
1073 DMPlexCreateWedgeBoxMesh - Creates a 3-D mesh tesselating the (x,y) plane and extruding in the third direction using wedge cells.
1074
1075 Collective
1076
1077 Input Parameters:
1078+ comm - The communicator for the DM object
1079. faces - Number of faces per dimension, or NULL for (1, 1, 1)
1080. lower - The lower left corner, or NULL for (0, 0, 0)
1081. upper - The upper right corner, or NULL for (1, 1, 1)
1082. periodicity - The boundary type for the X,Y,Z direction, or NULL for DM_BOUNDARY_NONE
1083. ordExt - If PETSC_TRUE, orders the extruded cells in the height first. Otherwise, orders the cell on the layers first
1084- interpolate - Flag to create intermediate mesh pieces (edges, faces)
1085
1086 Output Parameter:
1087. dm - The DM object
1088
1089 Level: beginner
1090
1091.seealso: DMPlexCreateHexCylinderMesh(), DMPlexCreateWedgeCylinderMesh(), DMPlexExtrude(), DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1092@*/
1093PetscErrorCode DMPlexCreateWedgeBoxMesh(MPI_Comm comm, const PetscInt faces[], const PetscReal lower[], const PetscReal upper[], const DMBoundaryType periodicity[], PetscBool ordExt, PetscBool interpolate, DM *dm)
1094{
1095 DM bdm, botdm;
1096 PetscInt i;
1097 PetscInt fac[3] = {0, 0, 0};
1098 PetscReal low[3] = {0, 0, 0};
1099 PetscReal upp[3] = {1, 1, 1};
1100 DMBoundaryType bdt[3] = {DM_BOUNDARY_NONE, DM_BOUNDARY_NONE, DM_BOUNDARY_NONE};
1101 PetscErrorCode ierr;
1102
1103 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1103; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1104 for (i = 0; i < 3; ++i) fac[i] = faces ? (faces[i] > 0 ? faces[i] : 1) : 1;
1105 if (lower) for (i = 0; i < 3; ++i) low[i] = lower[i];
1106 if (upper) for (i = 0; i < 3; ++i) upp[i] = upper[i];
1107 if (periodicity) for (i = 0; i < 3; ++i) bdt[i] = periodicity[i];
1108 for (i = 0; i < 3; ++i) if (bdt[i] != DM_BOUNDARY_NONE) SETERRQ(comm, PETSC_ERR_SUP, "Periodicity not yet supported")return PetscError(comm,1108,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Periodicity not yet supported")
;
1109
1110 ierr = DMCreate(comm, &bdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1110,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1111 ierr = DMSetType(bdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1111,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1112 ierr = DMSetDimension(bdm, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1112,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1113 ierr = DMSetCoordinateDim(bdm, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1113,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1114 ierr = DMPlexCreateSquareBoundary(bdm, low, upp, fac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1114,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1115 ierr = DMPlexGenerate(bdm, NULL((void*)0), PETSC_FALSE, &botdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1115,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1116 ierr = DMDestroy(&bdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1116,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1117 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),1117,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1118 if (low[2] != 0.0) {
1119 Vec v;
1120 PetscScalar *x;
1121 PetscInt cDim, n;
1122
1123 ierr = DMGetCoordinatesLocal(*dm, &v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1123,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1124 ierr = VecGetBlockSize(v, &cDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1124,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1125 ierr = VecGetLocalSize(v, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1125,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1126 ierr = VecGetArray(v, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1126,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1127 x += cDim;
1128 for (i=0; i<n; i+=cDim) x[i] += low[2];
1129 ierr = VecRestoreArray(v,&x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1129,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1130 ierr = DMSetCoordinatesLocal(*dm, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1130,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1131 }
1132 ierr = DMDestroy(&botdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1132,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1133 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)
;
1134}
1135
1136/*@
1137 DMPlexExtrude - Creates a (d+1)-D mesh by extruding a d-D mesh in the normal direction using prismatic cells.
1138
1139 Collective on idm
1140
1141 Input Parameters:
1142+ idm - The mesh to be extruted
1143. layers - The number of layers
1144. height - The height of the extruded layer
1145. ordExt - If PETSC_TRUE, orders the extruded cells in the height first. Otherwise, orders the cell on the layers first
1146- interpolate - Flag to create intermediate mesh pieces (edges, faces)
1147
1148 Output Parameter:
1149. dm - The DM object
1150
1151 Notes: The object created is an hybrid mesh, the vertex ordering in the cone of the cell is that of the prismatic cells
1152
1153 Level: advanced
1154
1155.seealso: DMPlexCreateWedgeCylinderMesh(), DMPlexCreateWedgeBoxMesh(), DMPlexSetHybridBounds(), DMSetType(), DMCreate()
1156@*/
1157PetscErrorCode DMPlexExtrude(DM idm, PetscInt layers, PetscReal height, PetscBool ordExt, PetscBool interpolate, DM* dm)
1158{
1159 PetscScalar *coordsB;
1160 const PetscScalar *coordsA;
1161 PetscReal *normals = NULL((void*)0);
1162 Vec coordinatesA, coordinatesB;
1163 PetscSection coordSectionA, coordSectionB;
1164 PetscInt dim, cDim, cDimB, c, l, v, coordSize, *newCone;
1165 PetscInt cStart, cEnd, vStart, vEnd, cellV, numCells, numVertices;
1166 PetscErrorCode ierr;
1167
1168 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1168; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1169 PetscValidHeaderSpecific(idm, DM_CLASSID, 1)do { if (!idm) return PetscError(((MPI_Comm)0x44000001),1169,
__func__,"/sandbox/petsc/petsc.master/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),1169,__func__,"/sandbox/petsc/petsc.master/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),1169,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),1169,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
1170 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,1170,__func__,"/sandbox/petsc/petsc.master/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),1170,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)idm),1170
,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
1171 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),1171
,__func__,"/sandbox/petsc/petsc.master/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),1171,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Real value must be same on all processes, argument # %d"
,3); } while (0)
;
1172 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,1172,__func__,"/sandbox/petsc/petsc.master/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),1172,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)idm),1172
,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Bool value must be same on all processes, argument # %d"
,4); } while (0)
;
1173 ierr = DMGetDimension(idm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1173,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1174 if (dim < 1 || dim > 3) SETERRQ1(PetscObjectComm((PetscObject)idm), PETSC_ERR_SUP, "Support for dimension %D not coded", dim)return PetscError(PetscObjectComm((PetscObject)idm),1174,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Support for dimension %D not coded",
dim)
;
1175
1176 ierr = DMPlexGetHeightStratum(idm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1176,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1177 ierr = DMPlexGetDepthStratum(idm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1177,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1178 numCells = (cEnd - cStart)*layers;
1179 numVertices = (vEnd - vStart)*(layers+1);
1180 ierr = DMCreate(PetscObjectComm((PetscObject)idm), dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1180,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1181 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1181,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1182 ierr = DMSetDimension(*dm, dim+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1182,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1183 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1183,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1184 for (c = cStart, cellV = 0; c < cEnd; ++c) {
1185 PetscInt *closure = NULL((void*)0);
1186 PetscInt closureSize, numCorners = 0;
1187
1188 ierr = DMPlexGetTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1188,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1189 for (v = 0; v < closureSize*2; v += 2) if ((closure[v] >= vStart) && (closure[v] < vEnd)) numCorners++;
1190 ierr = DMPlexRestoreTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1190,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1191 for (l = 0; l < layers; ++l) {
1192 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),1192,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1193 }
1194 cellV = PetscMax(numCorners,cellV)(((numCorners)<(cellV)) ? (cellV) : (numCorners));
1195 }
1196 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),1196,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1197 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1197,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1198
1199 ierr = DMGetCoordinateDim(idm, &cDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1199,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1200 if (dim != cDim) {
1201 ierr = PetscCalloc1(cDim*(vEnd - vStart), &normals)PetscMallocA(1,PETSC_TRUE,1201,__func__,"/sandbox/petsc/petsc.master/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),1201,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1202 }
1203 ierr = PetscMalloc1(3*cellV,&newCone)PetscMallocA(1,PETSC_FALSE,1203,__func__,"/sandbox/petsc/petsc.master/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),1203,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1204 for (c = cStart; c < cEnd; ++c) {
1205 PetscInt *closure = NULL((void*)0);
1206 PetscInt closureSize, numCorners = 0, l;
1207 PetscReal normal[3] = {0, 0, 0};
1208
1209 if (normals) {
1210 ierr = DMPlexComputeCellGeometryFVM(idm, c, NULL((void*)0), NULL((void*)0), normal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1210,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1211 }
1212 ierr = DMPlexGetTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1212,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1213 for (v = 0; v < closureSize*2; v += 2) {
1214 if ((closure[v] >= vStart) && (closure[v] < vEnd)) {
1215 PetscInt d;
1216
1217 newCone[numCorners++] = closure[v] - vStart;
1218 if (normals) { for (d = 0; d < cDim; ++d) normals[cDim*(closure[v]-vStart)+d] += normal[d]; }
1219 }
1220 }
1221 switch (numCorners) {
1222 case 4: /* do nothing */
1223 case 2: /* do nothing */
1224 break;
1225 case 3: /* from counter-clockwise to wedge ordering */
1226 l = newCone[1];
1227 newCone[1] = newCone[2];
1228 newCone[2] = l;
1229 break;
1230 default: SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_SUP, "Unsupported number of corners: %D", numCorners)return PetscError(((MPI_Comm)0x44000001),1230,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Unsupported number of corners: %D",numCorners
)
;
1231 }
1232 ierr = DMPlexRestoreTransitiveClosure(idm, c, PETSC_TRUE, &closureSize, &closure);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1232,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1233 for (l = 0; l < layers; ++l) {
1234 PetscInt i;
1235
1236 for (i = 0; i < numCorners; ++i) {
1237 newCone[ numCorners + i] = ordExt ? (layers+1)*newCone[i] + l + numCells : l*(vEnd - vStart) + newCone[i] + numCells;
1238 newCone[2*numCorners + i] = ordExt ? (layers+1)*newCone[i] + l + 1 + numCells : (l+1)*(vEnd - vStart) + newCone[i] + numCells;
1239 }
1240 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),1240,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1241 }
1242 }
1243 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1243,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1244 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1244,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1245 ierr = PetscFree(newCone)((*PetscTrFree)((void*)(newCone),1245,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((newCone) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1245,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1246
1247 cDimB = cDim == dim ? cDim+1 : cDim;
1248 ierr = DMGetCoordinateSection(*dm, &coordSectionB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1248,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1249 ierr = PetscSectionSetNumFields(coordSectionB, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1249,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1250 ierr = PetscSectionSetFieldComponents(coordSectionB, 0, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1250,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1251 ierr = PetscSectionSetChart(coordSectionB, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1251,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1252 for (v = numCells; v < numCells+numVertices; ++v) {
1253 ierr = PetscSectionSetDof(coordSectionB, v, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1253,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1254 ierr = PetscSectionSetFieldDof(coordSectionB, v, 0, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1254,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1255 }
1256 ierr = PetscSectionSetUp(coordSectionB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1256,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1257 ierr = PetscSectionGetStorageSize(coordSectionB, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1257,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1258 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1258,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1259 ierr = PetscObjectSetName((PetscObject) coordinatesB, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1259,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1260 ierr = VecSetSizes(coordinatesB, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1260,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1261 ierr = VecSetBlockSize(coordinatesB, cDimB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1261,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1262 ierr = VecSetType(coordinatesB,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1262,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1263
1264 ierr = DMGetCoordinateSection(idm, &coordSectionA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1264,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1265 ierr = DMGetCoordinatesLocal(idm, &coordinatesA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1265,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1266 ierr = VecGetArray(coordinatesB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1266,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1267 ierr = VecGetArrayRead(coordinatesA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1267,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1268 for (v = vStart; v < vEnd; ++v) {
1269 const PetscScalar *cptr;
1270 PetscReal ones2[2] = { 0., 1.}, ones3[3] = { 0., 0., 1.};
1271 PetscReal *normal, norm, h = height/layers;
1272 PetscInt offA, d, cDimA = cDim;
1273
1274 normal = normals ? normals + cDimB*(v - vStart) : (cDim > 1 ? ones3 : ones2);
1275 if (normals) {
1276 for (d = 0, norm = 0.0; d < cDimB; ++d) norm += normal[d]*normal[d];
1277 for (d = 0; d < cDimB; ++d) normal[d] *= 1./PetscSqrtReal(norm)sqrt(norm);
1278 }
1279
1280 ierr = PetscSectionGetOffset(coordSectionA, v, &offA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1280,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1281 cptr = coordsA + offA;
1282 for (l = 0; l < layers+1; ++l) {
1283 PetscInt offB, d, newV;
1284
1285 newV = ordExt ? (layers+1)*(v -vStart) + l + numCells : (vEnd -vStart)*l + (v -vStart) + numCells;
1286 ierr = PetscSectionGetOffset(coordSectionB, newV, &offB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1286,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1287 for (d = 0; d < cDimA; ++d) { coordsB[offB+d] = cptr[d]; }
1288 for (d = 0; d < cDimB; ++d) { coordsB[offB+d] += l ? normal[d]*h : 0.0; }
1289 cptr = coordsB + offB;
1290 cDimA = cDimB;
1291 }
1292 }
1293 ierr = VecRestoreArrayRead(coordinatesA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1293,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1294 ierr = VecRestoreArray(coordinatesB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1294,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1295 ierr = DMSetCoordinatesLocal(*dm, coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1295,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1296 ierr = VecDestroy(&coordinatesB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1296,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1297 ierr = PetscFree(normals)((*PetscTrFree)((void*)(normals),1297,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((normals) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1297,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1298 if (interpolate) {
1299 DM idm;
1300
1301 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1301,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1302 ierr = DMPlexCopyCoordinates(*dm, idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1302,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1303 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1303,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1304 *dm = idm;
1305 }
1306 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)
;
1307}
1308
1309/*@C
1310 DMPlexSetOptionsPrefix - Sets the prefix used for searching for all DM options in the database.
1311
1312 Logically Collective on dm
1313
1314 Input Parameters:
1315+ dm - the DM context
1316- prefix - the prefix to prepend to all option names
1317
1318 Notes:
1319 A hyphen (-) must NOT be given at the beginning of the prefix name.
1320 The first character of all runtime options is AUTOMATICALLY the hyphen.
1321
1322 Level: advanced
1323
1324.seealso: SNESSetFromOptions()
1325@*/
1326PetscErrorCode DMPlexSetOptionsPrefix(DM dm, const char prefix[])
1327{
1328 DM_Plex *mesh = (DM_Plex *) dm->data;
1329 PetscErrorCode ierr;
1330
1331 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1331; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1332 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1332,__func__
,"/sandbox/petsc/petsc.master/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),1332,__func__,"/sandbox/petsc/petsc.master/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),1332,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),1332,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
1333 ierr = PetscObjectSetOptionsPrefix((PetscObject) dm, prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1333,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1334 ierr = PetscObjectSetOptionsPrefix((PetscObject) mesh->partitioner, prefix);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1334,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1335 PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize
> 0) { petscstack->currentsize--; petscstack->function
[petscstack->currentsize] = 0; petscstack->file[petscstack
->currentsize] = 0; petscstack->line[petscstack->currentsize
] = 0; petscstack->petscroutine[petscstack->currentsize
] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth =
(((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack->
hotdepth-1)); } ; } while (0); return(0);} while (0)
;
1336}
1337
1338/*@
1339 DMPlexCreateHexCylinderMesh - Creates a mesh on the tensor product of the unit interval with the circle (cylinder) using hexahedra.
1340
1341 Collective
1342
1343 Input Parameters:
1344+ comm - The communicator for the DM object
1345. numRefine - The number of regular refinements to the basic 5 cell structure
1346- periodicZ - The boundary type for the Z direction
1347
1348 Output Parameter:
1349. dm - The DM object
1350
1351 Note: Here is the output numbering looking from the bottom of the cylinder:
1352$ 17-----14
1353$ | |
1354$ | 2 |
1355$ | |
1356$ 17-----8-----7-----14
1357$ | | | |
1358$ | 3 | 0 | 1 |
1359$ | | | |
1360$ 19-----5-----6-----13
1361$ | |
1362$ | 4 |
1363$ | |
1364$ 19-----13
1365$
1366$ and up through the top
1367$
1368$ 18-----16
1369$ | |
1370$ | 2 |
1371$ | |
1372$ 18----10----11-----16
1373$ | | | |
1374$ | 3 | 0 | 1 |
1375$ | | | |
1376$ 20-----9----12-----15
1377$ | |
1378$ | 4 |
1379$ | |
1380$ 20-----15
1381
1382 Level: beginner
1383
1384.seealso: DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1385@*/
1386PetscErrorCode DMPlexCreateHexCylinderMesh(MPI_Comm comm, PetscInt numRefine, DMBoundaryType periodicZ, DM *dm)
1387{
1388 const PetscInt dim = 3;
1389 PetscInt numCells, numVertices, r;
1390 PetscMPIInt rank;
1391 PetscErrorCode ierr;
1392
1393 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1393; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1394 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1394,__func__
,"/sandbox/petsc/petsc.master/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),1394,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
1395 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1395,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1396 if (numRefine < 0) SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Number of refinements %D cannot be negative", numRefine)return PetscError(comm,1396,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Number of refinements %D cannot be negative"
,numRefine)
;
1397 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1397,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1398 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1398,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1399 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1399,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1400 /* Create topology */
1401 {
1402 PetscInt cone[8], c;
1403
1404 numCells = !rank ? 5 : 0;
1405 numVertices = !rank ? 16 : 0;
1406 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1407 numCells *= 3;
1408 numVertices = !rank ? 24 : 0;
1409 }
1410 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1410,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1411 for (c = 0; c < numCells; c++) {ierr = DMPlexSetConeSize(*dm, c, 8);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1411,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1412 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1412,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1413 if (!rank) {
1414 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1415 cone[0] = 15; cone[1] = 18; cone[2] = 17; cone[3] = 16;
1416 cone[4] = 31; cone[5] = 32; cone[6] = 33; cone[7] = 34;
1417 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1417,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1418 cone[0] = 16; cone[1] = 17; cone[2] = 24; cone[3] = 23;
1419 cone[4] = 32; cone[5] = 36; cone[6] = 37; cone[7] = 33; /* 22 25 26 21 */
1420 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1420,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1421 cone[0] = 18; cone[1] = 27; cone[2] = 24; cone[3] = 17;
1422 cone[4] = 34; cone[5] = 33; cone[6] = 37; cone[7] = 38;
1423 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1423,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1424 cone[0] = 29; cone[1] = 27; cone[2] = 18; cone[3] = 15;
1425 cone[4] = 35; cone[5] = 31; cone[6] = 34; cone[7] = 38;
1426 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1426,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1427 cone[0] = 29; cone[1] = 15; cone[2] = 16; cone[3] = 23;
1428 cone[4] = 35; cone[5] = 36; cone[6] = 32; cone[7] = 31;
1429 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1429,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1430
1431 cone[0] = 31; cone[1] = 34; cone[2] = 33; cone[3] = 32;
1432 cone[4] = 19; cone[5] = 22; cone[6] = 21; cone[7] = 20;
1433 ierr = DMPlexSetCone(*dm, 5, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1433,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1434 cone[0] = 32; cone[1] = 33; cone[2] = 37; cone[3] = 36;
1435 cone[4] = 22; cone[5] = 25; cone[6] = 26; cone[7] = 21;
1436 ierr = DMPlexSetCone(*dm, 6, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1436,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1437 cone[0] = 34; cone[1] = 38; cone[2] = 37; cone[3] = 33;
1438 cone[4] = 20; cone[5] = 21; cone[6] = 26; cone[7] = 28;
1439 ierr = DMPlexSetCone(*dm, 7, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1439,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1440 cone[0] = 35; cone[1] = 38; cone[2] = 34; cone[3] = 31;
1441 cone[4] = 30; cone[5] = 19; cone[6] = 20; cone[7] = 28;
1442 ierr = DMPlexSetCone(*dm, 8, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1442,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1443 cone[0] = 35; cone[1] = 31; cone[2] = 32; cone[3] = 36;
1444 cone[4] = 30; cone[5] = 25; cone[6] = 22; cone[7] = 19;
1445 ierr = DMPlexSetCone(*dm, 9, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1445,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1446
1447 cone[0] = 19; cone[1] = 20; cone[2] = 21; cone[3] = 22;
1448 cone[4] = 15; cone[5] = 16; cone[6] = 17; cone[7] = 18;
1449 ierr = DMPlexSetCone(*dm, 10, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1449,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1450 cone[0] = 22; cone[1] = 21; cone[2] = 26; cone[3] = 25;
1451 cone[4] = 16; cone[5] = 23; cone[6] = 24; cone[7] = 17;
1452 ierr = DMPlexSetCone(*dm, 11, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1452,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1453 cone[0] = 20; cone[1] = 28; cone[2] = 26; cone[3] = 21;
1454 cone[4] = 18; cone[5] = 17; cone[6] = 24; cone[7] = 27;
1455 ierr = DMPlexSetCone(*dm, 12, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1455,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1456 cone[0] = 30; cone[1] = 28; cone[2] = 20; cone[3] = 19;
1457 cone[4] = 29; cone[5] = 15; cone[6] = 18; cone[7] = 27;
1458 ierr = DMPlexSetCone(*dm, 13, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1458,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1459 cone[0] = 30; cone[1] = 19; cone[2] = 22; cone[3] = 25;
1460 cone[4] = 29; cone[5] = 23; cone[6] = 16; cone[7] = 15;
1461 ierr = DMPlexSetCone(*dm, 14, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1461,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1462 } else {
1463 cone[0] = 5; cone[1] = 8; cone[2] = 7; cone[3] = 6;
1464 cone[4] = 9; cone[5] = 12; cone[6] = 11; cone[7] = 10;
1465 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1465,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1466 cone[0] = 6; cone[1] = 7; cone[2] = 14; cone[3] = 13;
1467 cone[4] = 12; cone[5] = 15; cone[6] = 16; cone[7] = 11;
1468 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1468,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1469 cone[0] = 8; cone[1] = 17; cone[2] = 14; cone[3] = 7;
1470 cone[4] = 10; cone[5] = 11; cone[6] = 16; cone[7] = 18;
1471 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1471,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1472 cone[0] = 19; cone[1] = 17; cone[2] = 8; cone[3] = 5;
1473 cone[4] = 20; cone[5] = 9; cone[6] = 10; cone[7] = 18;
1474 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1474,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1475 cone[0] = 19; cone[1] = 5; cone[2] = 6; cone[3] = 13;
1476 cone[4] = 20; cone[5] = 15; cone[6] = 12; cone[7] = 9;
1477 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1477,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1478 }
1479 }
1480 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1480,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1481 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1481,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1482 }
1483 /* Interpolate */
1484 {
1485 DM idm;
1486
1487 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1487,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1488 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1488,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1489 *dm = idm;
1490 }
1491 /* Create cube geometry */
1492 {
1493 Vec coordinates;
1494 PetscSection coordSection;
1495 PetscScalar *coords;
1496 PetscInt coordSize, v;
1497 const PetscReal dis = 1.0/PetscSqrtReal(2.0)sqrt(2.0);
1498 const PetscReal ds2 = dis/2.0;
1499
1500 /* Build coordinates */
1501 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1501,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1502 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1502,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1503 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1503,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1504 ierr = PetscSectionSetChart(coordSection, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1504,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1505 for (v = numCells; v < numCells+numVertices; ++v) {
1506 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1506,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1507 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1507,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1508 }
1509 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1509,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1510 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1510,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1511 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1511,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1512 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1512,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1513 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1513,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1514 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1514,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1515 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1515,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1516 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1516,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1517 if (!rank) {
1518 coords[0*dim+0] = -ds2; coords[0*dim+1] = -ds2; coords[0*dim+2] = 0.0;
1519 coords[1*dim+0] = ds2; coords[1*dim+1] = -ds2; coords[1*dim+2] = 0.0;
1520 coords[2*dim+0] = ds2; coords[2*dim+1] = ds2; coords[2*dim+2] = 0.0;
1521 coords[3*dim+0] = -ds2; coords[3*dim+1] = ds2; coords[3*dim+2] = 0.0;
1522 coords[4*dim+0] = -ds2; coords[4*dim+1] = -ds2; coords[4*dim+2] = 1.0;
1523 coords[5*dim+0] = -ds2; coords[5*dim+1] = ds2; coords[5*dim+2] = 1.0;
1524 coords[6*dim+0] = ds2; coords[6*dim+1] = ds2; coords[6*dim+2] = 1.0;
1525 coords[7*dim+0] = ds2; coords[7*dim+1] = -ds2; coords[7*dim+2] = 1.0;
1526 coords[ 8*dim+0] = dis; coords[ 8*dim+1] = -dis; coords[ 8*dim+2] = 0.0;
1527 coords[ 9*dim+0] = dis; coords[ 9*dim+1] = dis; coords[ 9*dim+2] = 0.0;
1528 coords[10*dim+0] = dis; coords[10*dim+1] = -dis; coords[10*dim+2] = 1.0;
1529 coords[11*dim+0] = dis; coords[11*dim+1] = dis; coords[11*dim+2] = 1.0;
1530 coords[12*dim+0] = -dis; coords[12*dim+1] = dis; coords[12*dim+2] = 0.0;
1531 coords[13*dim+0] = -dis; coords[13*dim+1] = dis; coords[13*dim+2] = 1.0;
1532 coords[14*dim+0] = -dis; coords[14*dim+1] = -dis; coords[14*dim+2] = 0.0;
1533 coords[15*dim+0] = -dis; coords[15*dim+1] = -dis; coords[15*dim+2] = 1.0;
1534 if (periodicZ == DM_BOUNDARY_PERIODIC) {
1535 /* 15 31 19 */ coords[16*dim+0] = -ds2; coords[16*dim+1] = -ds2; coords[16*dim+2] = 0.5;
1536 /* 16 32 22 */ coords[17*dim+0] = ds2; coords[17*dim+1] = -ds2; coords[17*dim+2] = 0.5;
1537 /* 17 33 21 */ coords[18*dim+0] = ds2; coords[18*dim+1] = ds2; coords[18*dim+2] = 0.5;
1538 /* 18 34 20 */ coords[19*dim+0] = -ds2; coords[19*dim+1] = ds2; coords[19*dim+2] = 0.5;
1539 /* 29 35 30 */ coords[20*dim+0] = -dis; coords[20*dim+1] = -dis; coords[20*dim+2] = 0.5;
1540 /* 23 36 25 */ coords[21*dim+0] = dis; coords[21*dim+1] = -dis; coords[21*dim+2] = 0.5;
1541 /* 24 37 26 */ coords[22*dim+0] = dis; coords[22*dim+1] = dis; coords[22*dim+2] = 0.5;
1542 /* 27 38 28 */ coords[23*dim+0] = -dis; coords[23*dim+1] = dis; coords[23*dim+2] = 0.5;
1543 }
1544 }
1545 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1545,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1546 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1546,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1547 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1547,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1548 }
1549 /* Create periodicity */
1550 if (periodicZ == DM_BOUNDARY_PERIODIC || periodicZ == DM_BOUNDARY_TWIST) {
1551 PetscReal L[3];
1552 PetscReal maxCell[3];
1553 DMBoundaryType bdType[3];
1554 PetscReal lower[3] = {0.0, 0.0, 0.0};
1555 PetscReal upper[3] = {1.0, 1.0, 1.5};
1556 PetscInt i, numZCells = 3;
1557
1558 bdType[0] = DM_BOUNDARY_NONE;
1559 bdType[1] = DM_BOUNDARY_NONE;
1560 bdType[2] = periodicZ;
1561 for (i = 0; i < dim; i++) {
1562 L[i] = upper[i] - lower[i];
1563 maxCell[i] = 1.1 * (L[i] / numZCells);
1564 }
1565 ierr = DMSetPeriodicity(*dm, PETSC_TRUE, maxCell, L, bdType);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1565,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1566 }
1567 /* Refine topology */
1568 for (r = 0; r < numRefine; ++r) {
1569 DM rdm = NULL((void*)0);
1570
1571 ierr = DMRefine(*dm, comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1571,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1572 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1572,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1573 *dm = rdm;
1574 }
1575 /* Remap geometry to cylinder
1576 Interior square: Linear interpolation is correct
1577 The other cells all have vertices on rays from the origin. We want to uniformly expand the spacing
1578 such that the last vertex is on the unit circle. So the closest and farthest vertices are at distance
1579
1580 phi = arctan(y/x)
1581 d_close = sqrt(1/8 + 1/4 sin^2(phi))
1582 d_far = sqrt(1/2 + sin^2(phi))
1583
1584 so we remap them using
1585
1586 x_new = x_close + (x - x_close) (1 - d_close) / (d_far - d_close)
1587 y_new = y_close + (y - y_close) (1 - d_close) / (d_far - d_close)
1588
1589 If pi/4 < phi < 3pi/4 or -3pi/4 < phi < -pi/4, then we switch x and y.
1590 */
1591 {
1592 Vec coordinates;
1593 PetscSection coordSection;
1594 PetscScalar *coords;
1595 PetscInt vStart, vEnd, v;
1596 const PetscReal dis = 1.0/PetscSqrtReal(2.0)sqrt(2.0);
1597 const PetscReal ds2 = 0.5*dis;
1598
1599 ierr = DMPlexGetDepthStratum(*dm, 0, &vStart, &vEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1599,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1600 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1600,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1601 ierr = DMGetCoordinatesLocal(*dm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1601,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1602 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1602,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1603 for (v = vStart; v < vEnd; ++v) {
1604 PetscReal phi, sinp, cosp, dc, df, x, y, xc, yc;
1605 PetscInt off;
1606
1607 ierr = PetscSectionGetOffset(coordSection, v, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1607,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1608 if ((PetscAbsScalar(coords[off+0]) <= ds2) && (PetscAbsScalar(coords[off+1]) <= ds2)) continue;
1609 x = PetscRealPart(coords[off])(coords[off]);
1610 y = PetscRealPart(coords[off+1])(coords[off+1]);
1611 phi = PetscAtan2Real(y, x)atan2(y,x);
1612 sinp = PetscSinReal(phi)sin(phi);
1613 cosp = PetscCosReal(phi)cos(phi);
1614 if ((PetscAbsReal(phi)fabs(phi) > PETSC_PI3.1415926535897932384626433832795029/4.0) && (PetscAbsReal(phi)fabs(phi) < 3.0*PETSC_PI3.1415926535897932384626433832795029/4.0)) {
1615 dc = PetscAbsReal(ds2/sinp)fabs(ds2/sinp);
1616 df = PetscAbsReal(dis/sinp)fabs(dis/sinp);
1617 xc = ds2*x/PetscAbsReal(y)fabs(y);
1618 yc = ds2*PetscSignReal(y)(((y) >= 0.0) ? ((y) == 0.0 ? 0.0 : 1.0) : -1.0);
1619 } else {
1620 dc = PetscAbsReal(ds2/cosp)fabs(ds2/cosp);
1621 df = PetscAbsReal(dis/cosp)fabs(dis/cosp);
1622 xc = ds2*PetscSignReal(x)(((x) >= 0.0) ? ((x) == 0.0 ? 0.0 : 1.0) : -1.0);
1623 yc = ds2*y/PetscAbsReal(x)fabs(x);
1624 }
1625 coords[off+0] = xc + (coords[off+0] - xc)*(1.0 - dc)/(df - dc);
1626 coords[off+1] = yc + (coords[off+1] - yc)*(1.0 - dc)/(df - dc);
1627 }
1628 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1628,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1629 if (periodicZ == DM_BOUNDARY_PERIODIC || periodicZ == DM_BOUNDARY_TWIST) {
1630 ierr = DMLocalizeCoordinates(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1630,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1631 }
1632 }
1633 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)
;
1634}
1635
1636/*@
1637 DMPlexCreateWedgeCylinderMesh - Creates a mesh on the tensor product of the unit interval with the circle (cylinder) using wedges.
1638
1639 Collective
1640
1641 Input Parameters:
1642+ comm - The communicator for the DM object
1643. n - The number of wedges around the origin
1644- interpolate - Create edges and faces
1645
1646 Output Parameter:
1647. dm - The DM object
1648
1649 Level: beginner
1650
1651.seealso: DMPlexCreateHexCylinderMesh(), DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1652@*/
1653PetscErrorCode DMPlexCreateWedgeCylinderMesh(MPI_Comm comm, PetscInt n, PetscBool interpolate, DM *dm)
1654{
1655 const PetscInt dim = 3;
1656 PetscInt numCells, numVertices;
1657 PetscMPIInt rank;
1658 PetscErrorCode ierr;
1659
1660 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1660; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1661 PetscValidPointer(dm, 3)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1661,__func__
,"/sandbox/petsc/petsc.master/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),1661,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3);
} while (0)
;
1662 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1662,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1663 if (n < 0) SETERRQ1(comm, PETSC_ERR_ARG_OUTOFRANGE, "Number of wedges %D cannot be negative", n)return PetscError(comm,1663,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Number of wedges %D cannot be negative"
,n)
;
1664 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1664,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1665 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1665,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1666 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1666,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1667 /* Create topology */
1668 {
1669 PetscInt cone[6], c;
1670
1671 numCells = !rank ? n : 0;
1672 numVertices = !rank ? 2*(n+1) : 0;
1673 ierr = DMPlexSetChart(*dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1673,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1674 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),1674,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1675 for (c = 0; c < numCells; c++) {ierr = DMPlexSetConeSize(*dm, c, 6);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1675,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
1676 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1676,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1677 for (c = 0; c < numCells; c++) {
1678 cone[0] = c+n*1; cone[1] = (c+1)%n+n*1; cone[2] = 0+3*n;
1679 cone[3] = c+n*2; cone[4] = (c+1)%n+n*2; cone[5] = 1+3*n;
1680 ierr = DMPlexSetCone(*dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1680,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1681 }
1682 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1682,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1683 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1683,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1684 }
1685 /* Interpolate */
1686 if (interpolate) {
1687 DM idm;
1688
1689 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1689,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1690 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1690,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1691 *dm = idm;
1692 }
1693 /* Create cylinder geometry */
1694 {
1695 Vec coordinates;
1696 PetscSection coordSection;
1697 PetscScalar *coords;
1698 PetscInt coordSize, v, c;
1699
1700 /* Build coordinates */
1701 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1701,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1702 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1702,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1703 ierr = PetscSectionSetFieldComponents(coordSection, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1703,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1704 ierr = PetscSectionSetChart(coordSection, numCells, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1704,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1705 for (v = numCells; v < numCells+numVertices; ++v) {
1706 ierr = PetscSectionSetDof(coordSection, v, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1706,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1707 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1707,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1708 }
1709 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1709,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1710 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1710,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1711 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1711,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1712 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1712,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1713 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1713,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1714 ierr = VecSetBlockSize(coordinates, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1714,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1715 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1715,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1716 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1716,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1717 for (c = 0; c < numCells; c++) {
1718 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;
1719 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;
1720 }
1721 if (!rank) {
1722 coords[(2*n+0)*dim+0] = 0.0; coords[(2*n+0)*dim+1] = 0.0; coords[(2*n+0)*dim+2] = 1.0;
1723 coords[(2*n+1)*dim+0] = 0.0; coords[(2*n+1)*dim+1] = 0.0; coords[(2*n+1)*dim+2] = 0.0;
1724 }
1725 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1725,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1726 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1726,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1727 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1727,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1728 }
1729 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)
;
1730}
1731
1732PETSC_STATIC_INLINEstatic inline PetscReal DiffNormReal(PetscInt dim, const PetscReal x[], const PetscReal y[])
1733{
1734 PetscReal prod = 0.0;
1735 PetscInt i;
1736 for (i = 0; i < dim; ++i) prod += PetscSqr(x[i] - y[i])((x[i] - y[i])*(x[i] - y[i]));
1737 return PetscSqrtReal(prod)sqrt(prod);
1738}
1739PETSC_STATIC_INLINEstatic inline PetscReal DotReal(PetscInt dim, const PetscReal x[], const PetscReal y[])
1740{
1741 PetscReal prod = 0.0;
1742 PetscInt i;
1743 for (i = 0; i < dim; ++i) prod += x[i]*y[i];
1744 return prod;
1745}
1746
1747/*@
1748 DMPlexCreateSphereMesh - Creates a mesh on the d-dimensional sphere, S^d.
1749
1750 Collective
1751
1752 Input Parameters:
1753. comm - The communicator for the DM object
1754. dim - The dimension
1755- simplex - Use simplices, or tensor product cells
1756
1757 Output Parameter:
1758. dm - The DM object
1759
1760 Level: beginner
1761
1762.seealso: DMPlexCreateBoxMesh(), DMSetType(), DMCreate()
1763@*/
1764PetscErrorCode DMPlexCreateSphereMesh(MPI_Comm comm, PetscInt dim, PetscBool simplex, DM *dm)
1765{
1766 const PetscInt embedDim = dim+1;
1767 PetscSection coordSection;
1768 Vec coordinates;
1769 PetscScalar *coords;
1770 PetscReal *coordsIn;
1771 PetscInt numCells, numEdges, numVerts, firstVertex, v, firstEdge, coordSize, d, c, e;
1772 PetscMPIInt rank;
1773 PetscErrorCode ierr;
1774
1775 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 1775; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
1776 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1776,__func__
,"/sandbox/petsc/petsc.master/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),1776,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
1777 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1777,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1778 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1778,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1779 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1779,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1780 ierr = DMSetCoordinateDim(*dm, dim+1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1780,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1781 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject) *dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1781,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1782 switch (dim) {
1783 case 2:
1784 if (simplex) {
1785 DM idm;
1786 const PetscReal edgeLen = 2.0/(1.0 + PETSC_PHI1.6180339887498948482045868343656381);
1787 const PetscReal vertex[3] = {0.0, 1.0/(1.0 + PETSC_PHI1.6180339887498948482045868343656381), PETSC_PHI1.6180339887498948482045868343656381/(1.0 + PETSC_PHI1.6180339887498948482045868343656381)};
1788 const PetscInt degree = 5;
1789 PetscInt s[3] = {1, 1, 1};
1790 PetscInt cone[3];
1791 PetscInt *graph, p, i, j, k;
1792
1793 numCells = !rank ? 20 : 0;
1794 numVerts = !rank ? 12 : 0;
1795 firstVertex = numCells;
1796 /* Use icosahedron, which for a unit sphere has coordinates which are all cyclic permutations of
1797
1798 (0, \pm 1/\phi+1, \pm \phi/\phi+1)
1799
1800 where \phi^2 - \phi - 1 = 0, meaning \phi is the golden ratio \frac{1 + \sqrt{5}}{2}. The edge
1801 length is then given by 2/\phi = 2 * 2.73606 = 5.47214.
1802 */
1803 /* Construct vertices */
1804 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,1804,__func__,"/sandbox/petsc/petsc.master/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),1804,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1805 for (p = 0, i = 0; p < embedDim; ++p) {
1806 for (s[1] = -1; s[1] < 2; s[1] += 2) {
1807 for (s[2] = -1; s[2] < 2; s[2] += 2) {
1808 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[(d+p)%embedDim]*vertex[(d+p)%embedDim];
1809 ++i;
1810 }
1811 }
1812 }
1813 /* Construct graph */
1814 ierr = PetscCalloc1(numVerts * numVerts, &graph)PetscMallocA(1,PETSC_TRUE,1814,__func__,"/sandbox/petsc/petsc.master/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),1814,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1815 for (i = 0; i < numVerts; ++i) {
1816 for (j = 0, k = 0; j < numVerts; ++j) {
1817 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;}
1818 }
1819 if (k != degree) SETERRQ3(comm, PETSC_ERR_PLIB, "Invalid icosahedron, vertex %D degree %D != %D", i, k, degree)return PetscError(comm,1819,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid icosahedron, vertex %D degree %D != %D"
,i,k,degree)
;
1820 }
1821 /* Build Topology */
1822 ierr = DMPlexSetChart(*dm, 0, numCells+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1822,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1823 for (c = 0; c < numCells; c++) {
1824 ierr = DMPlexSetConeSize(*dm, c, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1824,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1825 }
1826 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1826,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
1827 /* Cells */
1828 for (i = 0, c = 0; i < numVerts; ++i) {
1829 for (j = 0; j < i; ++j) {
1830 for (k = 0; k < j; ++k) {
1831 if (graph[i*numVerts+j] && graph[j*numVerts+k] && graph[k*numVerts+i]) {
1832 cone[0] = firstVertex+i; cone[1] = firstVertex+j; cone[2] = firstVertex+k;
1833 /* Check orientation */
1834 {
1835 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}}};
1836 PetscReal normal[3];
1837 PetscInt e, f;
1838
1839 for (d = 0; d < embedDim; ++d) {
1840 normal[d] = 0.0;
1841 for (e = 0; e < embedDim; ++e) {
1842 for (f = 0; f < embedDim; ++f) {
1843 normal[d] += epsilon[d][e][f]*(coordsIn[j*embedDim+e] - coordsIn[i*embedDim+e])*(coordsIn[k*embedDim+f] - coordsIn[i*embedDim+f]);
1844 }
1845 }
1846 }
1847 if (DotReal(embedDim, normal, &coordsIn[i*embedDim]) < 0) {PetscInt tmp = cone[1]; cone[1] = cone[2]; cone[2] = tmp;}
1848 }
1849 ierr = DMPlexSetCone(*dm, c++, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1849,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1850 }
1851 }
1852 }
1853 }
1854 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1854,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1855 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1855,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1856 ierr = PetscFree(graph)((*PetscTrFree)((void*)(graph),1856,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((graph) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1856,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1857 /* Interpolate mesh */
1858 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1858,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1859 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1859,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1860 *dm = idm;
1861 } else {
1862 /*
1863 12-21--13
1864 | |
1865 25 4 24
1866 | |
1867 12-25--9-16--8-24--13
1868 | | | |
1869 23 5 17 0 15 3 22
1870 | | | |
1871 10-20--6-14--7-19--11
1872 | |
1873 20 1 19
1874 | |
1875 10-18--11
1876 | |
1877 23 2 22
1878 | |
1879 12-21--13
1880 */
1881 const PetscReal dist = 1.0/PetscSqrtReal(3.0)sqrt(3.0);
1882 PetscInt cone[4], ornt[4];
1883
1884 numCells = !rank ? 6 : 0;
1885 numEdges = !rank ? 12 : 0;
1886 numVerts = !rank ? 8 : 0;
1887 firstVertex = numCells;
1888 firstEdge = numCells + numVerts;
1889 /* Build Topology */
1890 ierr = DMPlexSetChart(*dm, 0, numCells+numEdges+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1890,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1891 for (c = 0; c < numCells; c++) {
1892 ierr = DMPlexSetConeSize(*dm, c, 4);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1892,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1893 }
1894 for (e = firstEdge; e < firstEdge+numEdges; ++e) {
1895 ierr = DMPlexSetConeSize(*dm, e, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1895,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1896 }
1897 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1897,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
1898 /* Cell 0 */
1899 cone[0] = 14; cone[1] = 15; cone[2] = 16; cone[3] = 17;
1900 ierr = DMPlexSetCone(*dm, 0, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1900,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1901 ornt[0] = 0; ornt[1] = 0; ornt[2] = 0; ornt[3] = 0;
1902 ierr = DMPlexSetConeOrientation(*dm, 0, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1902,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1903 /* Cell 1 */
1904 cone[0] = 18; cone[1] = 19; cone[2] = 14; cone[3] = 20;
1905 ierr = DMPlexSetCone(*dm, 1, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1905,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1906 ornt[0] = 0; ornt[1] = 0; ornt[2] = -2; ornt[3] = 0;
1907 ierr = DMPlexSetConeOrientation(*dm, 1, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1907,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1908 /* Cell 2 */
1909 cone[0] = 21; cone[1] = 22; cone[2] = 18; cone[3] = 23;
1910 ierr = DMPlexSetCone(*dm, 2, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1910,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1911 ornt[0] = 0; ornt[1] = 0; ornt[2] = -2; ornt[3] = 0;
1912 ierr = DMPlexSetConeOrientation(*dm, 2, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1912,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1913 /* Cell 3 */
1914 cone[0] = 19; cone[1] = 22; cone[2] = 24; cone[3] = 15;
1915 ierr = DMPlexSetCone(*dm, 3, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1915,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1916 ornt[0] = -2; ornt[1] = -2; ornt[2] = 0; ornt[3] = -2;
1917 ierr = DMPlexSetConeOrientation(*dm, 3, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1917,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1918 /* Cell 4 */
1919 cone[0] = 16; cone[1] = 24; cone[2] = 21; cone[3] = 25;
1920 ierr = DMPlexSetCone(*dm, 4, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1920,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1921 ornt[0] = -2; ornt[1] = -2; ornt[2] = -2; ornt[3] = 0;
1922 ierr = DMPlexSetConeOrientation(*dm, 4, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1922,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1923 /* Cell 5 */
1924 cone[0] = 20; cone[1] = 17; cone[2] = 25; cone[3] = 23;
1925 ierr = DMPlexSetCone(*dm, 5, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1925,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1926 ornt[0] = -2; ornt[1] = -2; ornt[2] = -2; ornt[3] = -2;
1927 ierr = DMPlexSetConeOrientation(*dm, 5, ornt);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1927,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1928 /* Edges */
1929 cone[0] = 6; cone[1] = 7;
1930 ierr = DMPlexSetCone(*dm, 14, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1930,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1931 cone[0] = 7; cone[1] = 8;
1932 ierr = DMPlexSetCone(*dm, 15, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1932,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1933 cone[0] = 8; cone[1] = 9;
1934 ierr = DMPlexSetCone(*dm, 16, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1934,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1935 cone[0] = 9; cone[1] = 6;
1936 ierr = DMPlexSetCone(*dm, 17, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1936,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1937 cone[0] = 10; cone[1] = 11;
1938 ierr = DMPlexSetCone(*dm, 18, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1938,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1939 cone[0] = 11; cone[1] = 7;
1940 ierr = DMPlexSetCone(*dm, 19, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1940,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1941 cone[0] = 6; cone[1] = 10;
1942 ierr = DMPlexSetCone(*dm, 20, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1942,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1943 cone[0] = 12; cone[1] = 13;
1944 ierr = DMPlexSetCone(*dm, 21, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1944,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1945 cone[0] = 13; cone[1] = 11;
1946 ierr = DMPlexSetCone(*dm, 22, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1946,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1947 cone[0] = 10; cone[1] = 12;
1948 ierr = DMPlexSetCone(*dm, 23, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1948,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1949 cone[0] = 13; cone[1] = 8;
1950 ierr = DMPlexSetCone(*dm, 24, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1950,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1951 cone[0] = 12; cone[1] = 9;
1952 ierr = DMPlexSetCone(*dm, 25, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1952,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1953 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1953,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1954 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),1954,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1955 /* Build coordinates */
1956 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,1956,__func__,"/sandbox/petsc/petsc.master/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),1956,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1957 coordsIn[0*embedDim+0] = -dist; coordsIn[0*embedDim+1] = dist; coordsIn[0*embedDim+2] = -dist;
1958 coordsIn[1*embedDim+0] = dist; coordsIn[1*embedDim+1] = dist; coordsIn[1*embedDim+2] = -dist;
1959 coordsIn[2*embedDim+0] = dist; coordsIn[2*embedDim+1] = -dist; coordsIn[2*embedDim+2] = -dist;
1960 coordsIn[3*embedDim+0] = -dist; coordsIn[3*embedDim+1] = -dist; coordsIn[3*embedDim+2] = -dist;
1961 coordsIn[4*embedDim+0] = -dist; coordsIn[4*embedDim+1] = dist; coordsIn[4*embedDim+2] = dist;
1962 coordsIn[5*embedDim+0] = dist; coordsIn[5*embedDim+1] = dist; coordsIn[5*embedDim+2] = dist;
1963 coordsIn[6*embedDim+0] = -dist; coordsIn[6*embedDim+1] = -dist; coordsIn[6*embedDim+2] = dist;
1964 coordsIn[7*embedDim+0] = dist; coordsIn[7*embedDim+1] = -dist; coordsIn[7*embedDim+2] = dist;
1965 }
1966 break;
1967 case 3:
1968 if (simplex) {
1969 DM idm;
1970 const PetscReal edgeLen = 1.0/PETSC_PHI1.6180339887498948482045868343656381;
1971 const PetscReal vertexA[4] = {0.5, 0.5, 0.5, 0.5};
1972 const PetscReal vertexB[4] = {1.0, 0.0, 0.0, 0.0};
1973 const PetscReal vertexC[4] = {0.5, 0.5*PETSC_PHI1.6180339887498948482045868343656381, 0.5/PETSC_PHI1.6180339887498948482045868343656381, 0.0};
1974 const PetscInt degree = 12;
1975 PetscInt s[4] = {1, 1, 1};
1976 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},
1977 {2, 0, 1, 3}, {2, 1, 3, 0}, {2, 3, 0, 1}, {3, 0, 2, 1}, {3, 1, 0, 2}, {3, 2, 1, 0}};
1978 PetscInt cone[4];
1979 PetscInt *graph, p, i, j, k, l;
1980
1981 numCells = !rank ? 600 : 0;
1982 numVerts = !rank ? 120 : 0;
1983 firstVertex = numCells;
1984 /* Use the 600-cell, which for a unit sphere has coordinates which are
1985
1986 1/2 (\pm 1, \pm 1, \pm 1, \pm 1) 16
1987 (\pm 1, 0, 0, 0) all cyclic permutations 8
1988 1/2 (\pm 1, \pm phi, \pm 1/phi, 0) all even permutations 96
1989
1990 where \phi^2 - \phi - 1 = 0, meaning \phi is the golden ratio \frac{1 + \sqrt{5}}{2}. The edge
1991 length is then given by 1/\phi = 2.73606.
1992
1993 http://buzzard.pugetsound.edu/sage-practice/ch03s03.html
1994 http://mathworld.wolfram.com/600-Cell.html
1995 */
1996 /* Construct vertices */
1997 ierr = PetscCalloc1(numVerts * embedDim, &coordsIn)PetscMallocA(1,PETSC_TRUE,1997,__func__,"/sandbox/petsc/petsc.master/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),1997,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1998 i = 0;
1999 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2000 for (s[1] = -1; s[1] < 2; s[1] += 2) {
2001 for (s[2] = -1; s[2] < 2; s[2] += 2) {
2002 for (s[3] = -1; s[3] < 2; s[3] += 2) {
2003 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[d]*vertexA[d];
2004 ++i;
2005 }
2006 }
2007 }
2008 }
2009 for (p = 0; p < embedDim; ++p) {
2010 s[1] = s[2] = s[3] = 1;
2011 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2012 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[(d+p)%embedDim]*vertexB[(d+p)%embedDim];
2013 ++i;
2014 }
2015 }
2016 for (p = 0; p < 12; ++p) {
2017 s[3] = 1;
2018 for (s[0] = -1; s[0] < 2; s[0] += 2) {
2019 for (s[1] = -1; s[1] < 2; s[1] += 2) {
2020 for (s[2] = -1; s[2] < 2; s[2] += 2) {
2021 for (d = 0; d < embedDim; ++d) coordsIn[i*embedDim+d] = s[evenPerm[p][d]]*vertexC[evenPerm[p][d]];
2022 ++i;
2023 }
2024 }
2025 }
2026 }
2027 if (i != numVerts) SETERRQ2(comm, PETSC_ERR_PLIB, "Invalid 600-cell, vertices %D != %D", i, numVerts)return PetscError(comm,2027,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid 600-cell, vertices %D != %D"
,i,numVerts)
;
2028 /* Construct graph */
2029 ierr = PetscCalloc1(numVerts * numVerts, &graph)PetscMallocA(1,PETSC_TRUE,2029,__func__,"/sandbox/petsc/petsc.master/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),2029,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2030 for (i = 0; i < numVerts; ++i) {
2031 for (j = 0, k = 0; j < numVerts; ++j) {
2032 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;}
2033 }
2034 if (k != degree) SETERRQ3(comm, PETSC_ERR_PLIB, "Invalid 600-cell, vertex %D degree %D != %D", i, k, degree)return PetscError(comm,2034,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid 600-cell, vertex %D degree %D != %D"
,i,k,degree)
;
2035 }
2036 /* Build Topology */
2037 ierr = DMPlexSetChart(*dm, 0, numCells+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2037,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2038 for (c = 0; c < numCells; c++) {
2039 ierr = DMPlexSetConeSize(*dm, c, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2039,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2040 }
2041 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2041,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
2042 /* Cells */
2043 for (i = 0, c = 0; i < numVerts; ++i) {
2044 for (j = 0; j < i; ++j) {
2045 for (k = 0; k < j; ++k) {
2046 for (l = 0; l < k; ++l) {
2047 if (graph[i*numVerts+j] && graph[j*numVerts+k] && graph[k*numVerts+i] &&
2048 graph[l*numVerts+i] && graph[l*numVerts+j] && graph[l*numVerts+k]) {
2049 cone[0] = firstVertex+i; cone[1] = firstVertex+j; cone[2] = firstVertex+k; cone[3] = firstVertex+l;
2050 /* Check orientation: https://ef.gy/linear-algebra:normal-vectors-in-higher-dimensional-spaces */
2051 {
2052 const PetscInt epsilon[4][4][4][4] = {{{{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2053 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 1}, { 0, 0, -1, 0}},
2054 {{0, 0, 0, 0}, { 0, 0, 0, -1}, { 0, 0, 0, 0}, { 0, 1, 0, 0}},
2055 {{0, 0, 0, 0}, { 0, 0, 1, 0}, { 0, -1, 0, 0}, { 0, 0, 0, 0}}},
2056
2057 {{{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, -1}, { 0, 0, 1, 0}},
2058 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2059 {{0, 0, 0, 1}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, {-1, 0, 0, 0}},
2060 {{0, 0, -1, 0}, { 0, 0, 0, 0}, { 1, 0, 0, 0}, { 0, 0, 0, 0}}},
2061
2062 {{{0, 0, 0, 0}, { 0, 0, 0, 1}, { 0, 0, 0, 0}, { 0, -1, 0, 0}},
2063 {{0, 0, 0, -1}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 1, 0, 0, 0}},
2064 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2065 {{0, 1, 0, 0}, {-1, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}}},
2066
2067 {{{0, 0, 0, 0}, { 0, 0, -1, 0}, { 0, 1, 0, 0}, { 0, 0, 0, 0}},
2068 {{0, 0, 1, 0}, { 0, 0, 0, 0}, {-1, 0, 0, 0}, { 0, 0, 0, 0}},
2069 {{0, -1, 0, 0}, { 1, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}},
2070 {{0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}, { 0, 0, 0, 0}}}};
2071 PetscReal normal[4];
2072 PetscInt e, f, g;
2073
2074 for (d = 0; d < embedDim; ++d) {
2075 normal[d] = 0.0;
2076 for (e = 0; e < embedDim; ++e) {
2077 for (f = 0; f < embedDim; ++f) {
2078 for (g = 0; g < embedDim; ++g) {
2079 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]);
2080 }
2081 }
2082 }
2083 }
2084 if (DotReal(embedDim, normal, &coordsIn[i*embedDim]) < 0) {PetscInt tmp = cone[1]; cone[1] = cone[2]; cone[2] = tmp;}
2085 }
2086 ierr = DMPlexSetCone(*dm, c++, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2086,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2087 }
2088 }
2089 }
2090 }
2091 }
2092 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2092,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2093 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2093,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2094 ierr = PetscFree(graph)((*PetscTrFree)((void*)(graph),2094,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((graph) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2094,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2095 /* Interpolate mesh */
2096 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2096,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2097 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2097,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2098 *dm = idm;
2099 break;
2100 }
2101 default: SETERRQ1(comm, PETSC_ERR_SUP, "Unsupported dimension for sphere: %D", dim)return PetscError(comm,2101,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,56,PETSC_ERROR_INITIAL,"Unsupported dimension for sphere: %D"
,dim)
;
2102 }
2103 /* Create coordinates */
2104 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2104,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2105 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2105,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2106 ierr = PetscSectionSetFieldComponents(coordSection, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2106,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2107 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numVerts);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2107,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2108 for (v = firstVertex; v < firstVertex+numVerts; ++v) {
2109 ierr = PetscSectionSetDof(coordSection, v, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2109,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2110 ierr = PetscSectionSetFieldDof(coordSection, v, 0, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2110,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2111 }
2112 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2112,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2113 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2113,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2114 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2114,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2115 ierr = VecSetBlockSize(coordinates, embedDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2115,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2116 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2116,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2117 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2117,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2118 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2118,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2119 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2119,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2120 for (v = 0; v < numVerts; ++v) for (d = 0; d < embedDim; ++d) {coords[v*embedDim+d] = coordsIn[v*embedDim+d];}
2121 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2121,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2122 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2122,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2123 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2123,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2124 ierr = PetscFree(coordsIn)((*PetscTrFree)((void*)(coordsIn),2124,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((coordsIn) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2124,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2125 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)
;
2126}
2127
2128/* External function declarations here */
2129extern PetscErrorCode DMCreateInterpolation_Plex(DM dmCoarse, DM dmFine, Mat *interpolation, Vec *scaling);
2130extern PetscErrorCode DMCreateInjection_Plex(DM dmCoarse, DM dmFine, Mat *mat);
2131extern PetscErrorCode DMCreateMassMatrix_Plex(DM dmCoarse, DM dmFine, Mat *mat);
2132extern PetscErrorCode DMCreateDefaultSection_Plex(DM dm);
2133extern PetscErrorCode DMCreateDefaultConstraints_Plex(DM dm);
2134extern PetscErrorCode DMCreateMatrix_Plex(DM dm, Mat *J);
2135extern PetscErrorCode DMCreateCoordinateDM_Plex(DM dm, DM *cdm);
2136extern PetscErrorCode DMCreateCoordinateField_Plex(DM dm, DMField *field);
2137PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMClone_Plex(DM dm, DM *newdm);
2138extern PetscErrorCode DMSetUp_Plex(DM dm);
2139extern PetscErrorCode DMDestroy_Plex(DM dm);
2140extern PetscErrorCode DMView_Plex(DM dm, PetscViewer viewer);
2141extern PetscErrorCode DMLoad_Plex(DM dm, PetscViewer viewer);
2142extern PetscErrorCode DMCreateSubDM_Plex(DM dm, PetscInt numFields, const PetscInt fields[], IS *is, DM *subdm);
2143extern PetscErrorCode DMCreateSuperDM_Plex(DM dms[], PetscInt len, IS **is, DM *superdm);
2144static PetscErrorCode DMInitialize_Plex(DM dm);
2145
2146/* Replace dm with the contents of dmNew
2147 - Share the DM_Plex structure
2148 - Share the coordinates
2149 - Share the SF
2150*/
2151static PetscErrorCode DMPlexReplace_Static(DM dm, DM dmNew)
2152{
2153 PetscSF sf;
2154 DM coordDM, coarseDM;
2155 Vec coords;
2156 PetscBool isper;
2157 const PetscReal *maxCell, *L;
2158 const DMBoundaryType *bd;
2159 PetscErrorCode ierr;
2160
2161 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2161; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2162 ierr = DMGetPointSF(dmNew, &sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2162,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2163 ierr = DMSetPointSF(dm, sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2163,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2164 ierr = DMGetCoordinateDM(dmNew, &coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2164,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2165 ierr = DMGetCoordinatesLocal(dmNew, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2165,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2166 ierr = DMSetCoordinateDM(dm, coordDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2166,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2167 ierr = DMSetCoordinatesLocal(dm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2167,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2168 ierr = DMGetPeriodicity(dm, &isper, &maxCell, &L, &bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2168,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2169 ierr = DMSetPeriodicity(dmNew, isper, maxCell, L, bd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2169,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2170 ierr = DMDestroy_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2170,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2171 ierr = DMInitialize_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2171,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2172 dm->data = dmNew->data;
2173 ((DM_Plex *) dmNew->data)->refct++;
2174 dmNew->labels->refct++;
2175 if (!--(dm->labels->refct)) {
2176 DMLabelLink next = dm->labels->next;
2177
2178 /* destroy the labels */
2179 while (next) {
2180 DMLabelLink tmp = next->next;
2181
2182 ierr = DMLabelDestroy(&next->label);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2182,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2183 ierr = PetscFree(next)((*PetscTrFree)((void*)(next),2183,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((next) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2183,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2184 next = tmp;
2185 }
2186 ierr = PetscFree(dm->labels)((*PetscTrFree)((void*)(dm->labels),2186,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((dm->labels) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2186,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2187 }
2188 dm->labels = dmNew->labels;
2189 dm->depthLabel = dmNew->depthLabel;
2190 ierr = DMGetCoarseDM(dmNew,&coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2190,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2191 ierr = DMSetCoarseDM(dm,coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2191,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2192 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)
;
2193}
2194
2195/* Swap dm with the contents of dmNew
2196 - Swap the DM_Plex structure
2197 - Swap the coordinates
2198 - Swap the point PetscSF
2199*/
2200static PetscErrorCode DMPlexSwap_Static(DM dmA, DM dmB)
2201{
2202 DM coordDMA, coordDMB;
2203 Vec coordsA, coordsB;
2204 PetscSF sfA, sfB;
2205 void *tmp;
2206 DMLabelLinkList listTmp;
2207 DMLabel depthTmp;
2208 PetscInt tmpI;
2209 PetscErrorCode ierr;
2210
2211 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2211; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2212 ierr = DMGetPointSF(dmA, &sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2212,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2213 ierr = DMGetPointSF(dmB, &sfB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2213,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2214 ierr = PetscObjectReference((PetscObject) sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2214,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2215 ierr = DMSetPointSF(dmA, sfB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2215,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2216 ierr = DMSetPointSF(dmB, sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2216,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2217 ierr = PetscObjectDereference((PetscObject) sfA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2217,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2218
2219 ierr = DMGetCoordinateDM(dmA, &coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2219,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2220 ierr = DMGetCoordinateDM(dmB, &coordDMB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2220,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2221 ierr = PetscObjectReference((PetscObject) coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2221,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2222 ierr = DMSetCoordinateDM(dmA, coordDMB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2222,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2223 ierr = DMSetCoordinateDM(dmB, coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2223,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2224 ierr = PetscObjectDereference((PetscObject) coordDMA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2224,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2225
2226 ierr = DMGetCoordinatesLocal(dmA, &coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2226,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2227 ierr = DMGetCoordinatesLocal(dmB, &coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2227,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2228 ierr = PetscObjectReference((PetscObject) coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2228,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2229 ierr = DMSetCoordinatesLocal(dmA, coordsB);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2229,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2230 ierr = DMSetCoordinatesLocal(dmB, coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2230,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2231 ierr = PetscObjectDereference((PetscObject) coordsA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2231,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2232
2233 tmp = dmA->data;
2234 dmA->data = dmB->data;
2235 dmB->data = tmp;
2236 listTmp = dmA->labels;
2237 dmA->labels = dmB->labels;
2238 dmB->labels = listTmp;
2239 depthTmp = dmA->depthLabel;
2240 dmA->depthLabel = dmB->depthLabel;
2241 dmB->depthLabel = depthTmp;
2242 tmpI = dmA->levelup;
2243 dmA->levelup = dmB->levelup;
2244 dmB->levelup = tmpI;
2245 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)
;
2246}
2247
2248PetscErrorCode DMSetFromOptions_NonRefinement_Plex(PetscOptionItems *PetscOptionsObject,DM dm)
2249{
2250 DM_Plex *mesh = (DM_Plex*) dm->data;
2251 PetscErrorCode ierr;
2252
2253 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2253; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2254 /* Handle viewing */
2255 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),2255,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2256 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),2256,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2257 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),2257,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2258 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),2258,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2259 /* Point Location */
2260 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),2260,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2261 /* Partitioning and distribution */
2262 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),2262,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2263 /* Generation and remeshing */
2264 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),2264,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2265 /* Projection behavior */
2266 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),2266,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2267 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),2267,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2268 /* Checking structure */
2269 {
2270 PetscBool flg = PETSC_FALSE, flg2 = PETSC_FALSE;
2271
2272 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),2272,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2273 if (flg && flg2) {ierr = DMPlexCheckSymmetry(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2273,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2274 ierr = PetscOptionsBool("-dm_plex_check_skeleton", "Check that each cell has the correct number of vertices (only for homogeneous simplex or tensor meshes)", "DMPlexCheckSkeleton", PETSC_FALSE, &flg, &flg2)PetscOptionsBool_Private(PetscOptionsObject,"-dm_plex_check_skeleton"
,"Check that each cell has the correct number of vertices (only for homogeneous simplex or tensor meshes)"
,"DMPlexCheckSkeleton",PETSC_FALSE,&flg,&flg2)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2274,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2275 if (flg && flg2) {ierr = DMPlexCheckSkeleton(dm, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2275,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2276 ierr = PetscOptionsBool("-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", PETSC_FALSE, &flg, &flg2)PetscOptionsBool_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",PETSC_FALSE,&flg,&flg2)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2276,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2277 if (flg && flg2) {ierr = DMPlexCheckFaces(dm, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2277,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2278 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),2278,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2279 if (flg && flg2) {ierr = DMPlexCheckGeometry(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2279,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2280 }
2281
2282 ierr = PetscPartitionerSetFromOptions(mesh->partitioner);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2282,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2283 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)
;
2284}
2285
2286static PetscErrorCode DMSetFromOptions_Plex(PetscOptionItems *PetscOptionsObject,DM dm)
2287{
2288 PetscInt refine = 0, coarsen = 0, r;
2289 PetscBool isHierarchy;
2290 PetscErrorCode ierr;
2291
2292 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2292; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2293 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2293,__func__
,"/sandbox/petsc/petsc.master/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),2293,__func__,"/sandbox/petsc/petsc.master/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),2293,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2293,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2294 ierr = PetscOptionsHead(PetscOptionsObject,"DMPlex Options");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2294,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2295 /* Handle DMPlex refinement */
2296 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),2296,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2297 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),2297,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2298 if (refine) {ierr = DMPlexSetRefinementUniform(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2298,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2299 if (refine && isHierarchy) {
2300 DM *dms, coarseDM;
2301
2302 ierr = DMGetCoarseDM(dm, &coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2302,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2303 ierr = PetscObjectReference((PetscObject)coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2303,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2304 ierr = PetscMalloc1(refine,&dms)PetscMallocA(1,PETSC_FALSE,2304,__func__,"/sandbox/petsc/petsc.master/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),2304,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2305 ierr = DMRefineHierarchy(dm, refine, dms);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2305,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2306 /* Total hack since we do not pass in a pointer */
2307 ierr = DMPlexSwap_Static(dm, dms[refine-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2307,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2308 if (refine == 1) {
2309 ierr = DMSetCoarseDM(dm, dms[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2309,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2310 ierr = DMPlexSetRegularRefinement(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2310,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2311 } else {
2312 ierr = DMSetCoarseDM(dm, dms[refine-2]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2312,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2313 ierr = DMPlexSetRegularRefinement(dm, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2313,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2314 ierr = DMSetCoarseDM(dms[0], dms[refine-1]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2314,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2315 ierr = DMPlexSetRegularRefinement(dms[0], PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2315,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2316 }
2317 ierr = DMSetCoarseDM(dms[refine-1], coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2317,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2318 ierr = PetscObjectDereference((PetscObject)coarseDM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2318,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2319 /* Free DMs */
2320 for (r = 0; r < refine; ++r) {
2321 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2321,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2322 ierr = DMDestroy(&dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2322,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2323 }
2324 ierr = PetscFree(dms)((*PetscTrFree)((void*)(dms),2324,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((dms) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2324,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2325 } else {
2326 for (r = 0; r < refine; ++r) {
2327 DM refinedMesh;
2328
2329 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2329,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2330 ierr = DMRefine(dm, PetscObjectComm((PetscObject) dm), &refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2330,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2331 /* Total hack since we do not pass in a pointer */
2332 ierr = DMPlexReplace_Static(dm, refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2332,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2333 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2333,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2334 ierr = DMDestroy(&refinedMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2334,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2335 }
2336 }
2337 /* Handle DMPlex coarsening */
2338 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),2338,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2339 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),2339,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2340 if (coarsen && isHierarchy) {
2341 DM *dms;
2342
2343 ierr = PetscMalloc1(coarsen, &dms)PetscMallocA(1,PETSC_FALSE,2343,__func__,"/sandbox/petsc/petsc.master/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),2343,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2344 ierr = DMCoarsenHierarchy(dm, coarsen, dms);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2344,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2345 /* Free DMs */
2346 for (r = 0; r < coarsen; ++r) {
2347 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2347,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2348 ierr = DMDestroy(&dms[r]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2348,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2349 }
2350 ierr = PetscFree(dms)((*PetscTrFree)((void*)(dms),2350,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((dms) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2350,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2351 } else {
2352 for (r = 0; r < coarsen; ++r) {
2353 DM coarseMesh;
2354
2355 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2355,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2356 ierr = DMCoarsen(dm, PetscObjectComm((PetscObject) dm), &coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2356,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2357 /* Total hack since we do not pass in a pointer */
2358 ierr = DMPlexReplace_Static(dm, coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2358,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2359 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2359,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2360 ierr = DMDestroy(&coarseMesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2360,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2361 }
2362 }
2363 /* Handle */
2364 ierr = DMSetFromOptions_NonRefinement_Plex(PetscOptionsObject, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2364,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2365 ierr = PetscOptionsTail()0; do {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);} while(0)
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2365,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2366 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)
;
2367}
2368
2369static PetscErrorCode DMCreateGlobalVector_Plex(DM dm,Vec *vec)
2370{
2371 PetscErrorCode ierr;
2372
2373 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2373; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2374 ierr = DMCreateGlobalVector_Section_Private(dm,vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2374,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2375 /* ierr = VecSetOperation(*vec, VECOP_DUPLICATE, (void(*)(void)) VecDuplicate_MPI_DM);CHKERRQ(ierr); */
2376 ierr = VecSetOperation(*vec, VECOP_VIEW, (void (*)(void)) VecView_Plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2376,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2377 ierr = VecSetOperation(*vec, VECOP_VIEWNATIVE, (void (*)(void)) VecView_Plex_Native);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2377,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2378 ierr = VecSetOperation(*vec, VECOP_LOAD, (void (*)(void)) VecLoad_Plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2378,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2379 ierr = VecSetOperation(*vec, VECOP_LOADNATIVE, (void (*)(void)) VecLoad_Plex_Native);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2379,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2380 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)
;
2381}
2382
2383static PetscErrorCode DMCreateLocalVector_Plex(DM dm,Vec *vec)
2384{
2385 PetscErrorCode ierr;
2386
2387 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2387; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2388 ierr = DMCreateLocalVector_Section_Private(dm,vec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2388,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2389 ierr = VecSetOperation(*vec, VECOP_VIEW, (void (*)(void)) VecView_Plex_Local);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2389,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2390 ierr = VecSetOperation(*vec, VECOP_LOAD, (void (*)(void)) VecLoad_Plex_Local);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2390,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2391 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)
;
2392}
2393
2394static PetscErrorCode DMGetDimPoints_Plex(DM dm, PetscInt dim, PetscInt *pStart, PetscInt *pEnd)
2395{
2396 PetscInt depth, d;
2397 PetscErrorCode ierr;
2398
2399 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2399; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2400 ierr = DMPlexGetDepth(dm, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2400,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2401 if (depth == 1) {
2402 ierr = DMGetDimension(dm, &d);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2402,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2403 if (dim == 0) {ierr = DMPlexGetDepthStratum(dm, dim, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2403,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2404 else if (dim == d) {ierr = DMPlexGetDepthStratum(dm, 1, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2404,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2405 else {*pStart = 0; *pEnd = 0;}
2406 } else {
2407 ierr = DMPlexGetDepthStratum(dm, dim, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2407,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2408 }
2409 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)
;
2410}
2411
2412static PetscErrorCode DMGetNeighors_Plex(DM dm, PetscInt *nranks, const PetscMPIInt *ranks[])
2413{
2414 PetscSF sf;
2415 PetscErrorCode ierr;
2416
2417 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2417; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2418 ierr = DMGetPointSF(dm, &sf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2418,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2419 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),2419,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2420 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)
;
2421}
2422
2423static PetscErrorCode DMHasCreateInjection_Plex(DM dm, PetscBool *flg)
2424{
2425 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2425; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2426 PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2426,__func__
,"/sandbox/petsc/petsc.master/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),2426,__func__,"/sandbox/petsc/petsc.master/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),2426,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2426,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2427 PetscValidPointer(flg,2)do { if (!flg) return PetscError(((MPI_Comm)0x44000001),2427,
__func__,"/sandbox/petsc/petsc.master/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),2427,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
2428 *flg = PETSC_TRUE;
2429 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)
;
2430}
2431
2432static PetscErrorCode DMInitialize_Plex(DM dm)
2433{
2434 PetscErrorCode ierr;
2435
2436 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2436; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2437 dm->ops->view = DMView_Plex;
2438 dm->ops->load = DMLoad_Plex;
2439 dm->ops->setfromoptions = DMSetFromOptions_Plex;
2440 dm->ops->clone = DMClone_Plex;
2441 dm->ops->setup = DMSetUp_Plex;
2442 dm->ops->createdefaultsection = DMCreateDefaultSection_Plex;
2443 dm->ops->createdefaultconstraints = DMCreateDefaultConstraints_Plex;
2444 dm->ops->createglobalvector = DMCreateGlobalVector_Plex;
2445 dm->ops->createlocalvector = DMCreateLocalVector_Plex;
2446 dm->ops->getlocaltoglobalmapping = NULL((void*)0);
2447 dm->ops->createfieldis = NULL((void*)0);
2448 dm->ops->createcoordinatedm = DMCreateCoordinateDM_Plex;
2449 dm->ops->createcoordinatefield = DMCreateCoordinateField_Plex;
2450 dm->ops->getcoloring = NULL((void*)0);
2451 dm->ops->creatematrix = DMCreateMatrix_Plex;
2452 dm->ops->createinterpolation = DMCreateInterpolation_Plex;
2453 dm->ops->createmassmatrix = DMCreateMassMatrix_Plex;
2454 dm->ops->getaggregates = NULL((void*)0);
2455 dm->ops->getinjection = DMCreateInjection_Plex;
2456 dm->ops->hascreateinjection = DMHasCreateInjection_Plex;
2457 dm->ops->refine = DMRefine_Plex;
2458 dm->ops->coarsen = DMCoarsen_Plex;
2459 dm->ops->refinehierarchy = DMRefineHierarchy_Plex;
2460 dm->ops->coarsenhierarchy = DMCoarsenHierarchy_Plex;
2461 dm->ops->adaptlabel = DMAdaptLabel_Plex;
2462 dm->ops->adaptmetric = DMAdaptMetric_Plex;
2463 dm->ops->globaltolocalbegin = NULL((void*)0);
2464 dm->ops->globaltolocalend = NULL((void*)0);
2465 dm->ops->localtoglobalbegin = NULL((void*)0);
2466 dm->ops->localtoglobalend = NULL((void*)0);
2467 dm->ops->destroy = DMDestroy_Plex;
2468 dm->ops->createsubdm = DMCreateSubDM_Plex;
2469 dm->ops->createsuperdm = DMCreateSuperDM_Plex;
2470 dm->ops->getdimpoints = DMGetDimPoints_Plex;
2471 dm->ops->locatepoints = DMLocatePoints_Plex;
2472 dm->ops->projectfunctionlocal = DMProjectFunctionLocal_Plex;
2473 dm->ops->projectfunctionlabellocal = DMProjectFunctionLabelLocal_Plex;
2474 dm->ops->projectfieldlocal = DMProjectFieldLocal_Plex;
2475 dm->ops->projectfieldlabellocal = DMProjectFieldLabelLocal_Plex;
2476 dm->ops->computel2diff = DMComputeL2Diff_Plex;
2477 dm->ops->computel2gradientdiff = DMComputeL2GradientDiff_Plex;
2478 dm->ops->computel2fielddiff = DMComputeL2FieldDiff_Plex;
2479 dm->ops->getneighbors = DMGetNeighors_Plex;
2480 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),2480,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2481 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),2481,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2482 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)
;
2483}
2484
2485PETSC_INTERNextern __attribute__((visibility ("hidden"))) PetscErrorCode DMClone_Plex(DM dm, DM *newdm)
2486{
2487 DM_Plex *mesh = (DM_Plex *) dm->data;
2488 PetscErrorCode ierr;
2489
2490 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2490; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2491 mesh->refct++;
2492 (*newdm)->data = mesh;
2493 ierr = PetscObjectChangeTypeName((PetscObject) *newdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2493,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2494 ierr = DMInitialize_Plex(*newdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2494,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2495 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)
;
2496}
2497
2498/*MC
2499 DMPLEX = "plex" - A DM object that encapsulates an unstructured mesh, or CW Complex, which can be expressed using a Hasse Diagram.
2500 In the local representation, Vecs contain all unknowns in the interior and shared boundary. This is
2501 specified by a PetscSection object. Ownership in the global representation is determined by
2502 ownership of the underlying DMPlex points. This is specified by another PetscSection object.
2503
2504 Options Database Keys:
2505+ -dm_plex_hash_location - Use grid hashing for point location
2506. -dm_plex_partition_balance - Attempt to evenly divide points on partition boundary between processes
2507. -dm_plex_remesh_bd - Allow changes to the boundary on remeshing
2508. -dm_plex_max_projection_height - Maxmimum mesh point height used to project locally
2509. -dm_plex_regular_refinement - Use special nested projection algorithm for regular refinement
2510. -dm_plex_check_symmetry - Check that the adjacency information in the mesh is symmetric
2511. -dm_plex_check_skeleton <celltype> - Check that each cell has the correct number of vertices
2512. -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
2513. -dm_plex_check_geometry - Check that cells have positive volume
2514. -dm_view :mesh.tex:ascii_latex - View the mesh in LaTeX/TikZ
2515. -dm_plex_view_scale <num> - Scale the TikZ
2516- -dm_plex_print_fem <num> - View FEM assembly information, such as element vectors and matrices
2517
2518
2519 Level: intermediate
2520
2521.seealso: DMType, DMPlexCreate(), DMCreate(), DMSetType()
2522M*/
2523
2524PETSC_EXTERNextern __attribute__((visibility ("default"))) PetscErrorCode DMCreate_Plex(DM dm)
2525{
2526 DM_Plex *mesh;
2527 PetscInt unit, d;
2528 PetscErrorCode ierr;
2529
2530 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2530; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2531 PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),2531,__func__
,"/sandbox/petsc/petsc.master/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),2531,__func__,"/sandbox/petsc/petsc.master/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),2531,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d"
,1); else return PetscError(((MPI_Comm)0x44000001),2531,__func__
,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d"
,1); } } while (0)
;
2532 ierr = PetscNewLog(dm,&mesh)(PetscMallocA(1,PETSC_TRUE,2532,__func__,"/sandbox/petsc/petsc.master/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),2532,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2533 dm->dim = 0;
2534 dm->data = mesh;
2535
2536 mesh->refct = 1;
2537 ierr = PetscSectionCreate(PetscObjectComm((PetscObject)dm), &mesh->coneSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2537,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2538 mesh->maxConeSize = 0;
2539 mesh->cones = NULL((void*)0);
2540 mesh->coneOrientations = NULL((void*)0);
2541 ierr = PetscSectionCreate(PetscObjectComm((PetscObject)dm), &mesh->supportSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2541,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2542 mesh->maxSupportSize = 0;
2543 mesh->supports = NULL((void*)0);
2544 mesh->refinementUniform = PETSC_TRUE;
2545 mesh->refinementLimit = -1.0;
2546
2547 mesh->facesTmp = NULL((void*)0);
2548
2549 mesh->tetgenOpts = NULL((void*)0);
2550 mesh->triangleOpts = NULL((void*)0);
2551 ierr = PetscPartitionerCreate(PetscObjectComm((PetscObject)dm), &mesh->partitioner);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2551,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2552 mesh->remeshBd = PETSC_FALSE;
2553
2554 mesh->subpointMap = NULL((void*)0);
2555
2556 for (unit = 0; unit < NUM_PETSC_UNITS; ++unit) mesh->scale[unit] = 1.0;
2557
2558 mesh->regularRefinement = PETSC_FALSE;
2559 mesh->depthState = -1;
2560 mesh->globalVertexNumbers = NULL((void*)0);
2561 mesh->globalCellNumbers = NULL((void*)0);
2562 mesh->anchorSection = NULL((void*)0);
2563 mesh->anchorIS = NULL((void*)0);
2564 mesh->createanchors = NULL((void*)0);
2565 mesh->computeanchormatrix = NULL((void*)0);
2566 mesh->parentSection = NULL((void*)0);
2567 mesh->parents = NULL((void*)0);
2568 mesh->childIDs = NULL((void*)0);
2569 mesh->childSection = NULL((void*)0);
2570 mesh->children = NULL((void*)0);
2571 mesh->referenceTree = NULL((void*)0);
2572 mesh->getchildsymmetry = NULL((void*)0);
2573 for (d = 0; d < 8; ++d) mesh->hybridPointMax[d] = PETSC_DETERMINE-1;
2574 mesh->vtkCellHeight = 0;
2575 mesh->useAnchors = PETSC_FALSE;
2576
2577 mesh->maxProjectionHeight = 0;
2578
2579 mesh->printSetValues = PETSC_FALSE;
2580 mesh->printFEM = 0;
2581 mesh->printTol = 1.0e-10;
2582
2583 ierr = DMInitialize_Plex(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2583,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2584 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)
;
2585}
2586
2587/*@
2588 DMPlexCreate - Creates a DMPlex object, which encapsulates an unstructured mesh, or CW complex, which can be expressed using a Hasse Diagram.
2589
2590 Collective
2591
2592 Input Parameter:
2593. comm - The communicator for the DMPlex object
2594
2595 Output Parameter:
2596. mesh - The DMPlex object
2597
2598 Level: beginner
2599
2600@*/
2601PetscErrorCode DMPlexCreate(MPI_Comm comm, DM *mesh)
2602{
2603 PetscErrorCode ierr;
2604
2605 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2605; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2606 PetscValidPointer(mesh,2)do { if (!mesh) return PetscError(((MPI_Comm)0x44000001),2606
,__func__,"/sandbox/petsc/petsc.master/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),2606,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
2607 ierr = DMCreate(comm, mesh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2607,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2608 ierr = DMSetType(*mesh, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2608,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2609 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)
;
2610}
2611
2612/*
2613 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
2614*/
2615/* TODO: invertCells and spaceDim arguments could be added also to to DMPlexCreateFromCellListParallel(), DMPlexBuildFromCellList_Internal() and DMPlexCreateFromCellList() */
2616PetscErrorCode DMPlexBuildFromCellList_Parallel_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, const int cells[], PetscBool invertCells, PetscSF *sfVert)
2617{
2618 PetscSF sfPoint;
2619 PetscLayout vLayout;
2620 PetscHSetI vhash;
2621 PetscSFNode *remoteVerticesAdj, *vertexLocal, *vertexOwner, *remoteVertex;
2622 const PetscInt *vrange;
2623 PetscInt numVerticesAdj, off = 0, *verticesAdj, numVerticesGhost = 0, *localVertex, *cone, c, p, v, g;
2624 PetscMPIInt rank, size;
2625 PetscErrorCode ierr;
2626
2627 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2627; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2628 ierr = MPI_Comm_rank(PetscObjectComm((PetscObject) dm), &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2628,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2629 ierr = MPI_Comm_size(PetscObjectComm((PetscObject) dm), &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2629,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2630 /* Partition vertices */
2631 ierr = PetscLayoutCreate(PetscObjectComm((PetscObject) dm), &vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2631,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2632 ierr = PetscLayoutSetLocalSize(vLayout, numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2632,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2633 ierr = PetscLayoutSetBlockSize(vLayout, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2633,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2634 ierr = PetscLayoutSetUp(vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2634,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2635 ierr = PetscLayoutGetRanges(vLayout, &vrange);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2635,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2636 /* Count vertices and map them to procs */
2637 ierr = PetscHSetICreate(&vhash);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2637,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
1
Calling 'PetscHSetICreate'
4
Returning from 'PetscHSetICreate'
2638 for (c = 0; c < numCells; ++c) {
5
Assuming 'c' is < 'numCells'
6
Loop condition is true. Entering loop body
2639 for (p = 0; p < numCorners; ++p) {
7
Assuming 'p' is < 'numCorners'
8
Loop condition is true. Entering loop body
2640 ierr = PetscHSetIAdd(vhash, cells[c*numCorners+p]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2640,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
9
Calling 'PetscHSetIAdd'
2641 }
2642 }
2643 ierr = PetscHSetIGetSize(vhash, &numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2643,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2644 ierr = PetscMalloc1(numVerticesAdj, &verticesAdj)PetscMallocA(1,PETSC_FALSE,2644,__func__,"/sandbox/petsc/petsc.master/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),2644,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2645 ierr = PetscHSetIGetElems(vhash, &off, verticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2645,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2646 ierr = PetscHSetIDestroy(&vhash);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2646,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2647 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),2647,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Invalid number of local vertices %D should be %D"
,off,numVerticesAdj)
;
2648 ierr = PetscSortInt(numVerticesAdj, verticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2648,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2649 ierr = PetscMalloc1(numVerticesAdj, &remoteVerticesAdj)PetscMallocA(1,PETSC_FALSE,2649,__func__,"/sandbox/petsc/petsc.master/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),2649,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2650 for (v = 0; v < numVerticesAdj; ++v) {
2651 const PetscInt gv = verticesAdj[v];
2652 PetscInt vrank;
2653
2654 ierr = PetscFindInt(gv, size+1, vrange, &vrank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2654,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2655 vrank = vrank < 0 ? -(vrank+2) : vrank;
2656 remoteVerticesAdj[v].index = gv - vrange[vrank];
2657 remoteVerticesAdj[v].rank = vrank;
2658 }
2659 /* Create cones */
2660 ierr = DMPlexSetChart(dm, 0, numCells+numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2660,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2661 for (c = 0; c < numCells; ++c) {ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2661,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2662 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2662,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2663 ierr = DMGetWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2663,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2664 for (c = 0; c < numCells; ++c) {
2665 for (p = 0; p < numCorners; ++p) {
2666 const PetscInt gv = cells[c*numCorners+p];
2667 PetscInt lv;
2668
2669 ierr = PetscFindInt(gv, numVerticesAdj, verticesAdj, &lv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2669,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2670 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),2670,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,63,PETSC_ERROR_INITIAL,"Could not find global vertex %D in local connectivity"
,gv)
;
2671 cone[p] = lv+numCells;
2672 }
2673 if (invertCells) { ierr = DMPlexInvertCell_Internal(spaceDim, numCorners, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2673,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; }
2674 ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2674,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2675 }
2676 ierr = DMRestoreWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2676,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2677 /* Create SF for vertices */
2678 ierr = PetscSFCreate(PetscObjectComm((PetscObject)dm), sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2678,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2679 ierr = PetscObjectSetName((PetscObject) *sfVert, "Vertex Ownership SF");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2679,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2680 ierr = PetscSFSetFromOptions(*sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2680,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2681 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),2681,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2682 ierr = PetscFree(verticesAdj)((*PetscTrFree)((void*)(verticesAdj),2682,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((verticesAdj) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2682,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2683 /* Build pointSF */
2684 ierr = PetscMalloc2(numVerticesAdj, &vertexLocal, numVertices, &vertexOwner)PetscMallocA(2,PETSC_FALSE,2684,__func__,"/sandbox/petsc/petsc.master/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),2684,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2685 for (v = 0; v < numVerticesAdj; ++v) {vertexLocal[v].index = v+numCells; vertexLocal[v].rank = rank;}
2686 for (v = 0; v < numVertices; ++v) {vertexOwner[v].index = -1; vertexOwner[v].rank = -1;}
2687 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),2687,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2688 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),2688,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2689 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),2689,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Global vertex %d on rank %d was unclaimed"
,v + vrange[rank],rank)
;
2690 ierr = PetscSFBcastBegin(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexOwner, vertexLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2690,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2691 ierr = PetscSFBcastEnd(*sfVert, MPIU_2INT((MPI_Datatype)0x4c000816), vertexOwner, vertexLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2691,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2692 for (v = 0; v < numVerticesAdj; ++v) if (vertexLocal[v].rank != rank) ++numVerticesGhost;
2693 ierr = PetscMalloc1(numVerticesGhost, &localVertex)PetscMallocA(1,PETSC_FALSE,2693,__func__,"/sandbox/petsc/petsc.master/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),2693,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2694 ierr = PetscMalloc1(numVerticesGhost, &remoteVertex)PetscMallocA(1,PETSC_FALSE,2694,__func__,"/sandbox/petsc/petsc.master/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),2694,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2695 for (v = 0, g = 0; v < numVerticesAdj; ++v) {
2696 if (vertexLocal[v].rank != rank) {
2697 localVertex[g] = v+numCells;
2698 remoteVertex[g].index = vertexLocal[v].index;
2699 remoteVertex[g].rank = vertexLocal[v].rank;
2700 ++g;
2701 }
2702 }
2703 ierr = PetscFree2(vertexLocal, vertexOwner)PetscFreeA(2,2703,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,&(vertexLocal),&(vertexOwner))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2703,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2704 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),2704,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Invalid number of vertex ghosts %D should be %D"
,g,numVerticesGhost)
;
2705 ierr = DMGetPointSF(dm, &sfPoint);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2705,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2706 ierr = PetscObjectSetName((PetscObject) sfPoint, "point SF");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2706,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2707 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),2707,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2708 ierr = PetscLayoutDestroy(&vLayout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2708,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2709 /* Fill in the rest of the topology structure */
2710 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2710,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2711 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2711,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2712 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)
;
2713}
2714
2715/*
2716 This takes as input the coordinates for each owned vertex
2717*/
2718PetscErrorCode DMPlexBuildCoordinates_Parallel_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numV, PetscSF sfVert, const PetscReal vertexCoords[])
2719{
2720 PetscSection coordSection;
2721 Vec coordinates;
2722 PetscScalar *coords;
2723 PetscInt numVertices, numVerticesAdj, coordSize, v;
2724 PetscErrorCode ierr;
2725
2726 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2726; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2727 ierr = DMSetCoordinateDim(dm, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2727,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2728 ierr = PetscSFGetGraph(sfVert, &numVertices, &numVerticesAdj, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2728,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2729 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2729,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2730 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2730,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2731 ierr = PetscSectionSetFieldComponents(coordSection, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2731,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2732 ierr = PetscSectionSetChart(coordSection, numCells, numCells + numVerticesAdj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2732,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2733 for (v = numCells; v < numCells+numVerticesAdj; ++v) {
2734 ierr = PetscSectionSetDof(coordSection, v, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2734,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2735 ierr = PetscSectionSetFieldDof(coordSection, v, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2735,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2736 }
2737 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2737,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2738 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2738,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2739 ierr = VecCreate(PetscObjectComm((PetscObject)dm), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2739,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2740 ierr = VecSetBlockSize(coordinates, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2740,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2741 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2741,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2742 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2742,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2743 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2743,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2744 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2744,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2745 {
2746 MPI_Datatype coordtype;
2747
2748 /* Need a temp buffer for coords if we have complex/single */
2749 ierr = MPI_Type_contiguous(spaceDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2749,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2750 ierr = MPI_Type_commit(&coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2750,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2751#if defined(PETSC_USE_COMPLEX)
2752 {
2753 PetscScalar *svertexCoords;
2754 PetscInt i;
2755 ierr = PetscMalloc1(numV*spaceDim,&svertexCoords)PetscMallocA(1,PETSC_FALSE,2755,__func__,"/sandbox/petsc/petsc.master/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),2755,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2756 for (i=0; i<numV*spaceDim; i++) svertexCoords[i] = vertexCoords[i];
2757 ierr = PetscSFBcastBegin(sfVert, coordtype, svertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2757,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2758 ierr = PetscSFBcastEnd(sfVert, coordtype, svertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2758,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2759 ierr = PetscFree(svertexCoords)((*PetscTrFree)((void*)(svertexCoords),2759,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
) || ((svertexCoords) = 0,0))
;CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2759,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2760 }
2761#else
2762 ierr = PetscSFBcastBegin(sfVert, coordtype, vertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2762,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2763 ierr = PetscSFBcastEnd(sfVert, coordtype, vertexCoords, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2763,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2764#endif
2765 ierr = MPI_Type_free(&coordtype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2765,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2766 }
2767 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2767,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2768 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2768,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2769 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2769,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2770 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)
;
2771}
2772
2773/*@
2774 DMPlexCreateFromCellListParallel - This takes as input common mesh generator output, a list of the vertices for each cell, and produces a DM
2775
2776 Input Parameters:
2777+ comm - The communicator
2778. dim - The topological dimension of the mesh
2779. numCells - The number of cells owned by this process
2780. numVertices - The number of vertices owned by this process
2781. numCorners - The number of vertices for each cell
2782. interpolate - Flag indicating that intermediate mesh entities (faces, edges) should be created automatically
2783. cells - An array of numCells*numCorners numbers, the global vertex numbers for each cell
2784. spaceDim - The spatial dimension used for coordinates
2785- vertexCoords - An array of numVertices*spaceDim numbers, the coordinates of each vertex
2786
2787 Output Parameter:
2788+ dm - The DM
2789- vertexSF - Optional, SF describing complete vertex ownership
2790
2791 Note: Two triangles sharing a face
2792$
2793$ 2
2794$ / | \
2795$ / | \
2796$ / | \
2797$ 0 0 | 1 3
2798$ \ | /
2799$ \ | /
2800$ \ | /
2801$ 1
2802would have input
2803$ numCells = 2, numVertices = 4
2804$ cells = [0 1 2 1 3 2]
2805$
2806which would result in the DMPlex
2807$
2808$ 4
2809$ / | \
2810$ / | \
2811$ / | \
2812$ 2 0 | 1 5
2813$ \ | /
2814$ \ | /
2815$ \ | /
2816$ 3
2817
2818 Level: beginner
2819
2820.seealso: DMPlexCreateFromCellList(), DMPlexCreateFromDAG(), DMPlexCreate()
2821@*/
2822PetscErrorCode 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)
2823{
2824 PetscSF sfVert;
2825 PetscErrorCode ierr;
2826
2827 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2827; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2828 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2828,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2829 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2829,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2830 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,2830,__func__,"/sandbox/petsc/petsc.master/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),2830,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),2830
,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,2); } while (0)
;
2831 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,2831,__func__,"/sandbox/petsc/petsc.master/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),2831,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0); if (-b2[0] != b2
[1]) return PetscError(PetscObjectComm((PetscObject)*dm),2831
,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Int value must be same on all processes, argument # %d"
,8); } while (0)
;
2832 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2832,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2833 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),2833,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2834 if (interpolate) {
2835 DM idm;
2836
2837 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2837,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2838 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2838,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2839 *dm = idm;
2840 }
2841 ierr = DMPlexBuildCoordinates_Parallel_Internal(*dm, spaceDim, numCells, numVertices, sfVert, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2841,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2842 if (vertexSF) *vertexSF = sfVert;
2843 else {ierr = PetscSFDestroy(&sfVert);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2843,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
2844 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)
;
2845}
2846
2847/*
2848 This takes as input the common mesh generator output, a list of the vertices for each cell
2849*/
2850PetscErrorCode DMPlexBuildFromCellList_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, const int cells[], PetscBool invertCells)
2851{
2852 PetscInt *cone, c, p;
2853 PetscErrorCode ierr;
2854
2855 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2855; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2856 ierr = DMPlexSetChart(dm, 0, numCells+numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2856,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2857 for (c = 0; c < numCells; ++c) {
2858 ierr = DMPlexSetConeSize(dm, c, numCorners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2858,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2859 }
2860 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2860,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2861 ierr = DMGetWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2861,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2862 for (c = 0; c < numCells; ++c) {
2863 for (p = 0; p < numCorners; ++p) {
2864 cone[p] = cells[c*numCorners+p]+numCells;
2865 }
2866 if (invertCells) { ierr = DMPlexInvertCell_Internal(spaceDim, numCorners, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2866,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; }
2867 ierr = DMPlexSetCone(dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2867,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2868 }
2869 ierr = DMRestoreWorkArray(dm, numCorners, MPIU_INT((MPI_Datatype)0x4c000405), &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2869,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2870 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2870,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2871 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2871,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2872 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)
;
2873}
2874
2875/*
2876 This takes as input the coordinates for each vertex
2877*/
2878PetscErrorCode DMPlexBuildCoordinates_Internal(DM dm, PetscInt spaceDim, PetscInt numCells, PetscInt numVertices, const double vertexCoords[])
2879{
2880 PetscSection coordSection;
2881 Vec coordinates;
2882 DM cdm;
2883 PetscScalar *coords;
2884 PetscInt v, d;
2885 PetscErrorCode ierr;
2886
2887 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2887; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2888 ierr = DMSetCoordinateDim(dm, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2888,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2889 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2889,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2890 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2890,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2891 ierr = PetscSectionSetFieldComponents(coordSection, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2891,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2892 ierr = PetscSectionSetChart(coordSection, numCells, numCells + numVertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2892,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2893 for (v = numCells; v < numCells+numVertices; ++v) {
2894 ierr = PetscSectionSetDof(coordSection, v, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2894,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2895 ierr = PetscSectionSetFieldDof(coordSection, v, 0, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2895,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2896 }
2897 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2897,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2898
2899 ierr = DMGetCoordinateDM(dm, &cdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2899,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2900 ierr = DMCreateLocalVector(cdm, &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2900,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2901 ierr = VecSetBlockSize(coordinates, spaceDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2901,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2902 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2902,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2903 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2903,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2904 for (v = 0; v < numVertices; ++v) {
2905 for (d = 0; d < spaceDim; ++d) {
2906 coords[v*spaceDim+d] = vertexCoords[v*spaceDim+d];
2907 }
2908 }
2909 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2909,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2910 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2910,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2911 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2911,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2912 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)
;
2913}
2914
2915/*@
2916 DMPlexCreateFromCellList - This takes as input common mesh generator output, a list of the vertices for each cell, and produces a DM
2917
2918 Input Parameters:
2919+ comm - The communicator
2920. dim - The topological dimension of the mesh
2921. numCells - The number of cells
2922. numVertices - The number of vertices
2923. numCorners - The number of vertices for each cell
2924. interpolate - Flag indicating that intermediate mesh entities (faces, edges) should be created automatically
2925. cells - An array of numCells*numCorners numbers, the vertices for each cell
2926. spaceDim - The spatial dimension used for coordinates
2927- vertexCoords - An array of numVertices*spaceDim numbers, the coordinates of each vertex
2928
2929 Output Parameter:
2930. dm - The DM
2931
2932 Note: Two triangles sharing a face
2933$
2934$ 2
2935$ / | \
2936$ / | \
2937$ / | \
2938$ 0 0 | 1 3
2939$ \ | /
2940$ \ | /
2941$ \ | /
2942$ 1
2943would have input
2944$ numCells = 2, numVertices = 4
2945$ cells = [0 1 2 1 3 2]
2946$
2947which would result in the DMPlex
2948$
2949$ 4
2950$ / | \
2951$ / | \
2952$ / | \
2953$ 2 0 | 1 5
2954$ \ | /
2955$ \ | /
2956$ \ | /
2957$ 3
2958
2959 Level: beginner
2960
2961.seealso: DMPlexCreateFromDAG(), DMPlexCreate()
2962@*/
2963PetscErrorCode DMPlexCreateFromCellList(MPI_Comm comm, PetscInt dim, PetscInt numCells, PetscInt numVertices, PetscInt numCorners, PetscBool interpolate, const int cells[], PetscInt spaceDim, const double vertexCoords[], DM *dm)
2964{
2965 PetscErrorCode ierr;
2966
2967 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 2967; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
2968 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2968,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2969 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2969,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2970 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2970,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2971 ierr = DMPlexBuildFromCellList_Internal(*dm, spaceDim, numCells, numVertices, numCorners, cells, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2971,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2972 if (interpolate) {
2973 DM idm;
2974
2975 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2975,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2976 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2976,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2977 *dm = idm;
2978 }
2979 ierr = DMPlexBuildCoordinates_Internal(*dm, spaceDim, numCells, numVertices, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),2979,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
2980 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)
;
2981}
2982
2983/*@
2984 DMPlexCreateFromDAG - This takes as input the adjacency-list representation of the Directed Acyclic Graph (Hasse Diagram) encoding a mesh, and produces a DM
2985
2986 Input Parameters:
2987+ dm - The empty DM object, usually from DMCreate() and DMSetDimension()
2988. depth - The depth of the DAG
2989. numPoints - Array of size depth + 1 containing the number of points at each depth
2990. coneSize - The cone size of each point
2991. cones - The concatenation of the cone points for each point, the cone list must be oriented correctly for each point
2992. coneOrientations - The orientation of each cone point
2993- vertexCoords - An array of numPoints[0]*spacedim numbers representing the coordinates of each vertex, with spacedim the value set via DMSetCoordinateDim()
2994
2995 Output Parameter:
2996. dm - The DM
2997
2998 Note: Two triangles sharing a face would have input
2999$ depth = 1, numPoints = [4 2], coneSize = [3 3 0 0 0 0]
3000$ cones = [2 3 4 3 5 4], coneOrientations = [0 0 0 0 0 0]
3001$ vertexCoords = [-1.0 0.0 0.0 -1.0 0.0 1.0 1.0 0.0]
3002$
3003which would result in the DMPlex
3004$
3005$ 4
3006$ / | \
3007$ / | \
3008$ / | \
3009$ 2 0 | 1 5
3010$ \ | /
3011$ \ | /
3012$ \ | /
3013$ 3
3014$
3015$ Notice that all points are numbered consecutively, unlikely DMPlexCreateFromCellList()
3016
3017 Level: advanced
3018
3019.seealso: DMPlexCreateFromCellList(), DMPlexCreate()
3020@*/
3021PetscErrorCode DMPlexCreateFromDAG(DM dm, PetscInt depth, const PetscInt numPoints[], const PetscInt coneSize[], const PetscInt cones[], const PetscInt coneOrientations[], const PetscScalar vertexCoords[])
3022{
3023 Vec coordinates;
3024 PetscSection coordSection;
3025 PetscScalar *coords;
3026 PetscInt coordSize, firstVertex = -1, pStart = 0, pEnd = 0, p, v, dim, dimEmbed, d, off;
3027 PetscErrorCode ierr;
3028
3029 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3029; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3030 ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3030,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3031 ierr = DMGetCoordinateDim(dm, &dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3031,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3032 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),3032,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,77,PETSC_ERROR_INITIAL,"Embedding dimension %d cannot be less than intrinsic dimension %d"
,dimEmbed,dim)
;
3033 for (d = 0; d <= depth; ++d) pEnd += numPoints[d];
3034 ierr = DMPlexSetChart(dm, pStart, pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3034,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3035 for (p = pStart; p < pEnd; ++p) {
3036 ierr = DMPlexSetConeSize(dm, p, coneSize[p-pStart]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3036,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3037 if (firstVertex < 0 && !coneSize[p - pStart]) {
3038 firstVertex = p - pStart;
3039 }
3040 }
3041 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),3041,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Expected %d vertices but could not find any"
,numPoints[0])
;
3042 ierr = DMSetUp(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3042,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
; /* Allocate space for cones */
3043 for (p = pStart, off = 0; p < pEnd; off += coneSize[p-pStart], ++p) {
3044 ierr = DMPlexSetCone(dm, p, &cones[off]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3044,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3045 ierr = DMPlexSetConeOrientation(dm, p, &coneOrientations[off]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3045,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3046 }
3047 ierr = DMPlexSymmetrize(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3047,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3048 ierr = DMPlexStratify(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3048,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3049 /* Build coordinates */
3050 ierr = DMGetCoordinateSection(dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3050,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3051 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3051,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3052 ierr = PetscSectionSetFieldComponents(coordSection, 0, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3052,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3053 ierr = PetscSectionSetChart(coordSection, firstVertex, firstVertex+numPoints[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3053,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3054 for (v = firstVertex; v < firstVertex+numPoints[0]; ++v) {
3055 ierr = PetscSectionSetDof(coordSection, v, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3055,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3056 ierr = PetscSectionSetFieldDof(coordSection, v, 0, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3056,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3057 }
3058 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3058,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3059 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3059,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3060 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3060,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3061 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3061,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3062 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3062,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3063 ierr = VecSetBlockSize(coordinates, dimEmbed);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3063,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3064 ierr = VecSetType(coordinates,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3064,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3065 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3065,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3066 for (v = 0; v < numPoints[0]; ++v) {
3067 PetscInt off;
3068
3069 ierr = PetscSectionGetOffset(coordSection, v+firstVertex, &off);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3069,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3070 for (d = 0; d < dimEmbed; ++d) {
3071 coords[off+d] = vertexCoords[v*dimEmbed+d];
3072 }
3073 }
3074 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3074,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3075 ierr = DMSetCoordinatesLocal(dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3075,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3076 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3076,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3077 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)
;
3078}
3079
3080/*@C
3081 DMPlexCreateCellVertexFromFile - Create a DMPlex mesh from a simple cell-vertex file.
3082
3083+ comm - The MPI communicator
3084. filename - Name of the .dat file
3085- interpolate - Create faces and edges in the mesh
3086
3087 Output Parameter:
3088. dm - The DM object representing the mesh
3089
3090 Note: The format is the simplest possible:
3091$ Ne
3092$ v0 v1 ... vk
3093$ Nv
3094$ x y z marker
3095
3096 Level: beginner
3097
3098.seealso: DMPlexCreateFromFile(), DMPlexCreateMedFromFile(), DMPlexCreateGmsh(), DMPlexCreate()
3099@*/
3100PetscErrorCode DMPlexCreateCellVertexFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
3101{
3102 DMLabel marker;
3103 PetscViewer viewer;
3104 Vec coordinates;
3105 PetscSection coordSection;
3106 PetscScalar *coords;
3107 char line[PETSC_MAX_PATH_LEN4096];
3108 PetscInt dim = 3, cdim = 3, coordSize, v, c, d;
3109 PetscMPIInt rank;
3110 int snum, Nv, Nc;
3111 PetscErrorCode ierr;
3112
3113 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3113; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3114 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3114,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3115 ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3115,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3116 ierr = PetscViewerSetType(viewer, PETSCVIEWERASCII"ascii");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3116,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3117 ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3117,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3118 ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3118,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3119 if (!rank) {
3120 ierr = PetscViewerRead(viewer, line, 2, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3120,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3121 snum = sscanf(line, "%d %d", &Nc, &Nv);
3122 if (snum != 2) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3122,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3123 } else {
3124 Nc = Nv = 0;
3125 }
3126 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3126,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3127 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3127,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3128 ierr = DMPlexSetChart(*dm, 0, Nc+Nv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3128,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3129 ierr = DMSetDimension(*dm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3129,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3130 ierr = DMSetCoordinateDim(*dm, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3130,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3131 /* Read topology */
3132 if (!rank) {
3133 PetscInt cone[8], corners = 8;
3134 int vbuf[8], v;
3135
3136 for (c = 0; c < Nc; ++c) {ierr = DMPlexSetConeSize(*dm, c, corners);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3136,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3137 ierr = DMSetUp(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3137,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3138 for (c = 0; c < Nc; ++c) {
3139 ierr = PetscViewerRead(viewer, line, corners, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3139,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3140 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]);
3141 if (snum != corners) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3141,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3142 for (v = 0; v < corners; ++v) cone[v] = vbuf[v] + Nc;
3143 /* Hexahedra are inverted */
3144 {
3145 PetscInt tmp = cone[1];
3146 cone[1] = cone[3];
3147 cone[3] = tmp;
3148 }
3149 ierr = DMPlexSetCone(*dm, c, cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3149,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3150 }
3151 }
3152 ierr = DMPlexSymmetrize(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3152,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3153 ierr = DMPlexStratify(*dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3153,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3154 /* Read coordinates */
3155 ierr = DMGetCoordinateSection(*dm, &coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3155,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3156 ierr = PetscSectionSetNumFields(coordSection, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3156,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3157 ierr = PetscSectionSetFieldComponents(coordSection, 0, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3157,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3158 ierr = PetscSectionSetChart(coordSection, Nc, Nc + Nv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3158,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3159 for (v = Nc; v < Nc+Nv; ++v) {
3160 ierr = PetscSectionSetDof(coordSection, v, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3160,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3161 ierr = PetscSectionSetFieldDof(coordSection, v, 0, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3161,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3162 }
3163 ierr = PetscSectionSetUp(coordSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3163,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3164 ierr = PetscSectionGetStorageSize(coordSection, &coordSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3164,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3165 ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3165,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3166 ierr = PetscObjectSetName((PetscObject) coordinates, "coordinates");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3166,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3167 ierr = VecSetSizes(coordinates, coordSize, PETSC_DETERMINE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3167,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3168 ierr = VecSetBlockSize(coordinates, cdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3168,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3169 ierr = VecSetType(coordinates, VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3169,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3170 ierr = VecGetArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3170,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3171 if (!rank) {
3172 double x[3];
3173 int val;
3174
3175 ierr = DMCreateLabel(*dm, "marker");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3175,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3176 ierr = DMGetLabel(*dm, "marker", &marker);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3176,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3177 for (v = 0; v < Nv; ++v) {
3178 ierr = PetscViewerRead(viewer, line, 4, NULL((void*)0), PETSC_STRING);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3178,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3179 snum = sscanf(line, "%lg %lg %lg %d", &x[0], &x[1], &x[2], &val);
3180 if (snum != 4) SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Unable to parse cell-vertex file: %s", line)return PetscError(((MPI_Comm)0x44000001),3180,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Unable to parse cell-vertex file: %s"
,line)
;
3181 for (d = 0; d < cdim; ++d) coords[v*cdim+d] = x[d];
3182 if (val) {ierr = DMLabelSetValue(marker, v+Nc, val);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3182,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3183 }
3184 }
3185 ierr = VecRestoreArray(coordinates, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3185,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3186 ierr = DMSetCoordinatesLocal(*dm, coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3186,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3187 ierr = VecDestroy(&coordinates);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3187,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3188 ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3188,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3189 if (interpolate) {
3190 DM idm;
3191 DMLabel bdlabel;
3192
3193 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3193,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3194 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3194,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3195 *dm = idm;
3196
3197 ierr = DMGetLabel(*dm, "marker", &bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3197,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3198 ierr = DMPlexMarkBoundaryFaces(*dm, PETSC_DETERMINE-1, bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3198,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3199 ierr = DMPlexLabelComplete(*dm, bdlabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3199,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3200 }
3201 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)
;
3202}
3203
3204/*@C
3205 DMPlexCreateFromFile - This takes a filename and produces a DM
3206
3207 Input Parameters:
3208+ comm - The communicator
3209. filename - A file name
3210- interpolate - Flag to create intermediate mesh pieces (edges, faces)
3211
3212 Output Parameter:
3213. dm - The DM
3214
3215 Options Database Keys:
3216. -dm_plex_create_from_hdf5_xdmf - use the PETSC_VIEWER_HDF5_XDMF format for reading HDF5
3217
3218 Level: beginner
3219
3220.seealso: DMPlexCreateFromDAG(), DMPlexCreateFromCellList(), DMPlexCreate()
3221@*/
3222PetscErrorCode DMPlexCreateFromFile(MPI_Comm comm, const char filename[], PetscBool interpolate, DM *dm)
3223{
3224 const char *extGmsh = ".msh";
3225 const char *extGmsh2 = ".msh2";
3226 const char *extGmsh4 = ".msh4";
3227 const char *extCGNS = ".cgns";
3228 const char *extExodus = ".exo";
3229 const char *extGenesis = ".gen";
3230 const char *extFluent = ".cas";
3231 const char *extHDF5 = ".h5";
3232 const char *extMed = ".med";
3233 const char *extPLY = ".ply";
3234 const char *extCV = ".dat";
3235 size_t len;
3236 PetscBool isGmsh, isGmsh2, isGmsh4, isCGNS, isExodus, isGenesis, isFluent, isHDF5, isMed, isPLY, isCV;
3237 PetscMPIInt rank;
3238 PetscErrorCode ierr;
3239
3240 PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3240; petscstack
->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3241 PetscValidPointer(filename, 2)do { if (!filename) return PetscError(((MPI_Comm)0x44000001),
3241,__func__,"/sandbox/petsc/petsc.master/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),3241,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0)
;
3242 PetscValidPointer(dm, 4)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),3242,__func__
,"/sandbox/petsc/petsc.master/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),3242,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",4);
} while (0)
;
3243 ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3243,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3244 ierr = PetscStrlen(filename, &len);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3244,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3245 if (!len) SETERRQ(comm, PETSC_ERR_ARG_WRONG, "Filename must be a valid path")return PetscError(comm,3245,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Filename must be a valid path")
;
3246 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),3246,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3247 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),3247,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3248 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),3248,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3249 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),3249,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3250 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),3250,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3251 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),3251,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3252 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),3252,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3253 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),3253,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3254 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),3254,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3255 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),3255,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3256 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),3256,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3257 if (isGmsh || isGmsh2 || isGmsh4) {
3258 ierr = DMPlexCreateGmshFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3258,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3259 } else if (isCGNS) {
3260 ierr = DMPlexCreateCGNSFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3260,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3261 } else if (isExodus || isGenesis) {
3262 ierr = DMPlexCreateExodusFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3262,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3263 } else if (isFluent) {
3264 ierr = DMPlexCreateFluentFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3264,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3265 } else if (isHDF5) {
3266 PetscBool load_hdf5_xdmf = PETSC_FALSE;
3267 PetscViewer viewer;
3268
3269 /* PETSC_VIEWER_HDF5_XDMF is used if the filename ends with .xdmf.h5, or if -dm_plex_create_from_hdf5_xdmf option is present */
3270 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),3270,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3271 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),3271,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3272 ierr = PetscViewerCreate(comm, &viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3272,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3273 ierr = PetscViewerSetType(viewer, PETSCVIEWERHDF5"hdf5");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3273,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3274 ierr = PetscViewerFileSetMode(viewer, FILE_MODE_READ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3274,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3275 ierr = PetscViewerFileSetName(viewer, filename);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3275,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3276 ierr = DMCreate(comm, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3276,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3277 ierr = DMSetType(*dm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3277,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3278 if (load_hdf5_xdmf) {ierr = PetscViewerPushFormat(viewer, PETSC_VIEWER_HDF5_XDMF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3278,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3279 ierr = DMLoad(*dm, viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3279,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3280 if (load_hdf5_xdmf) {ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3280,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3281 ierr = PetscViewerDestroy(&viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3281,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3282
3283 if (interpolate) {
3284 DM idm;
3285
3286 ierr = DMPlexInterpolate(*dm, &idm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3286,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3287 ierr = DMDestroy(dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3287,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3288 *dm = idm;
3289 }
3290 } else if (isMed) {
3291 ierr = DMPlexCreateMedFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3291,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3292 } else if (isPLY) {
3293 ierr = DMPlexCreatePLYFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3293,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3294 } else if (isCV) {
3295 ierr = DMPlexCreateCellVertexFromFile(comm, filename, interpolate, dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3295,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3296 } else SETERRQ1(PETSC_COMM_SELF, PETSC_ERR_ARG_WRONG, "Cannot load file %s: unrecognized extension", filename)return PetscError(((MPI_Comm)0x44000001),3296,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Cannot load file %s: unrecognized extension"
,filename)
;
3297 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)
;
3298}
3299
3300/*@
3301 DMPlexCreateReferenceCell - Create a DMPLEX with the appropriate FEM reference cell
3302
3303 Collective
3304
3305 Input Parameters:
3306+ comm - The communicator
3307. dim - The spatial dimension
3308- simplex - Flag for simplex, otherwise use a tensor-product cell
3309
3310 Output Parameter:
3311. refdm - The reference cell
3312
3313 Level: intermediate
3314
3315.seealso:
3316@*/
3317PetscErrorCode DMPlexCreateReferenceCell(MPI_Comm comm, PetscInt dim, PetscBool simplex, DM *refdm)
3318{
3319 DM rdm;
3320 Vec coords;
3321 PetscErrorCode ierr;
3322
3323 PetscFunctionBeginUserdo { do { ; if (petscstack && (petscstack->currentsize
< 64)) { petscstack->function[petscstack->currentsize
] = __func__; petscstack->file[petscstack->currentsize]
= "/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
; petscstack->line[petscstack->currentsize] = 3323; petscstack
->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack
->currentsize++; } if (petscstack) { petscstack->hotdepth
+= (PETSC_FALSE || petscstack->hotdepth); } ; } while (0)
; ; } while (0)
;
3324 ierr = DMCreate(comm, &rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3324,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3325 ierr = DMSetType(rdm, DMPLEX"plex");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3325,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3326 ierr = DMSetDimension(rdm, dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3326,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3327 switch (dim) {
3328 case 0:
3329 {
3330 PetscInt numPoints[1] = {1};
3331 PetscInt coneSize[1] = {0};
3332 PetscInt cones[1] = {0};
3333 PetscInt coneOrientations[1] = {0};
3334 PetscScalar vertexCoords[1] = {0.0};
3335
3336 ierr = DMPlexCreateFromDAG(rdm, 0, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3336,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3337 }
3338 break;
3339 case 1:
3340 {
3341 PetscInt numPoints[2] = {2, 1};
3342 PetscInt coneSize[3] = {2, 0, 0};
3343 PetscInt cones[2] = {1, 2};
3344 PetscInt coneOrientations[2] = {0, 0};
3345 PetscScalar vertexCoords[2] = {-1.0, 1.0};
3346
3347 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3347,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3348 }
3349 break;
3350 case 2:
3351 if (simplex) {
3352 PetscInt numPoints[2] = {3, 1};
3353 PetscInt coneSize[4] = {3, 0, 0, 0};
3354 PetscInt cones[3] = {1, 2, 3};
3355 PetscInt coneOrientations[3] = {0, 0, 0};
3356 PetscScalar vertexCoords[6] = {-1.0, -1.0, 1.0, -1.0, -1.0, 1.0};
3357
3358 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3358,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3359 } else {
3360 PetscInt numPoints[2] = {4, 1};
3361 PetscInt coneSize[5] = {4, 0, 0, 0, 0};
3362 PetscInt cones[4] = {1, 2, 3, 4};
3363 PetscInt coneOrientations[4] = {0, 0, 0, 0};
3364 PetscScalar vertexCoords[8] = {-1.0, -1.0, 1.0, -1.0, 1.0, 1.0, -1.0, 1.0};
3365
3366 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3366,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3367 }
3368 break;
3369 case 3:
3370 if (simplex) {
3371 PetscInt numPoints[2] = {4, 1};
3372 PetscInt coneSize[5] = {4, 0, 0, 0, 0};
3373 PetscInt cones[4] = {1, 3, 2, 4};
3374 PetscInt coneOrientations[4] = {0, 0, 0, 0};
3375 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};
3376
3377 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3377,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3378 } else {
3379 PetscInt numPoints[2] = {8, 1};
3380 PetscInt coneSize[9] = {8, 0, 0, 0, 0, 0, 0, 0, 0};
3381 PetscInt cones[8] = {1, 4, 3, 2, 5, 6, 7, 8};
3382 PetscInt coneOrientations[8] = {0, 0, 0, 0, 0, 0, 0, 0};
3383 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,
3384 -1.0, -1.0, 1.0, 1.0, -1.0, 1.0, 1.0, 1.0, 1.0, -1.0, 1.0, 1.0};
3385
3386 ierr = DMPlexCreateFromDAG(rdm, 1, numPoints, coneSize, cones, coneOrientations, vertexCoords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3386,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3387 }
3388 break;
3389 default:
3390 SETERRQ1(comm, PETSC_ERR_ARG_WRONG, "Cannot create reference cell for dimension %d", dim)return PetscError(comm,3390,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,62,PETSC_ERROR_INITIAL,"Cannot create reference cell for dimension %d"
,dim)
;
3391 }
3392 ierr = DMPlexInterpolate(rdm, refdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3392,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3393 if (rdm->coordinateDM) {
3394 DM ncdm;
3395 PetscSection cs;
3396 PetscInt pEnd = -1;
3397
3398 ierr = DMGetSection(rdm->coordinateDM, &cs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3398,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3399 if (cs) {ierr = PetscSectionGetChart(cs, NULL((void*)0), &pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3399,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3400 if (pEnd >= 0) {
3401 ierr = DMClone(*refdm, &ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3401,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3402 ierr = DMCopyDisc(rdm->coordinateDM, ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3402,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3403 ierr = DMSetSection(ncdm, cs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3403,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3404 ierr = DMSetCoordinateDM(*refdm, ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3404,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3405 ierr = DMDestroy(&ncdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3405,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3406 }
3407 }
3408 ierr = DMGetCoordinatesLocal(rdm, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3408,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3409 if (coords) {
3410 ierr = DMSetCoordinatesLocal(*refdm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3410,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3411 } else {
3412 ierr = DMGetCoordinates(rdm, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3412,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3413 if (coords) {ierr = DMSetCoordinates(*refdm, coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3413,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;}
3414 }
3415 ierr = DMDestroy(&rdm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm
)0x44000001),3415,__func__,"/sandbox/petsc/petsc.master/src/dm/impls/plex/plexcreate.c"
,ierr,PETSC_ERROR_REPEAT," ");} while (0)
;
3416 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)
;
3417}

/sandbox/petsc/petsc.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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 PetscHSetIUpdate
(PetscHSetI ht,PetscHSetI hta) { int ret; PetscInt key; do { do
{ ; if (petscstack && (petscstack->currentsize <
64)) { petscstack->function[petscstack->currentsize] =
__func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.master/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.master/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.master/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",1);
} while (0); do { if (!hta) return PetscError(((MPI_Comm)0x44000001
),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashseti.h"
,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if
(!PetscCheckPointer(hta,PETSC_CHAR)) return PetscError(((MPI_Comm
)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2);
} while (0); { khint_t __i; for (__i = (khint_t)(0); __i != (
(hta)->n_buckets); ++__i) { if (!(!(((hta)->flags[(__i)
>>4]>>(((__i)&0xfU)<<1))&3))) continue
; (key) = ((hta)->keys[__i]); { kh_put_HSetI(ht, key, &
ret); do { if (__builtin_expect(!!(!(ret>=0)),0)) return PetscError
(((MPI_Comm)0x44000001),6,__func__,"/sandbox/petsc/petsc.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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 PetscHSetIGetCapacity(PetscHSetI ht
,PetscInt *n) { do { do { ; if (petscstack && (petscstack
->currentsize < 64)) { petscstack->function[petscstack
->currentsize] = __func__; petscstack->file[petscstack->
currentsize] = "/sandbox/petsc/petsc.master/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.master/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.master/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.master/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.master/include/petsc/private/hashseti.h"
,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d"
,2); } while (0); *n = (PetscInt)((ht)->n_buckets); 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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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.master/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 */