File: | snes/utils/dmplexsnes.c |
Warning: | line 1407, column 58 Array access (from variable 'geoms') results in a null pointer dereference |
[?] Use j/k keys for keyboard navigation
1 | #include <petsc/private/dmpleximpl.h> /*I "petscdmplex.h" I*/ | |||
2 | #include <petsc/private/snesimpl.h> /*I "petscsnes.h" I*/ | |||
3 | #include <petscds.h> | |||
4 | #include <petscblaslapack.h> | |||
5 | #include <petsc/private/petscimpl.h> | |||
6 | #include <petsc/private/petscfeimpl.h> | |||
7 | ||||
8 | /************************** Interpolation *******************************/ | |||
9 | ||||
10 | static PetscErrorCode DMSNESConvertPlex(DM dm, DM *plex, PetscBool copy) | |||
11 | { | |||
12 | PetscBool isPlex; | |||
13 | PetscErrorCode ierr; | |||
14 | ||||
15 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 15; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
16 | ierr = PetscObjectTypeCompare((PetscObject) dm, DMPLEX"plex", &isPlex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),16,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
17 | if (isPlex) { | |||
18 | *plex = dm; | |||
19 | ierr = PetscObjectReference((PetscObject) dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),19,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
20 | } else { | |||
21 | ierr = PetscObjectQuery((PetscObject) dm, "dm_plex", (PetscObject *) plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),21,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
22 | if (!*plex) { | |||
23 | ierr = DMConvert(dm,DMPLEX"plex",plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),23,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
24 | ierr = PetscObjectCompose((PetscObject) dm, "dm_plex", (PetscObject) *plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),24,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
25 | if (copy) { | |||
26 | PetscInt i; | |||
27 | PetscObject obj; | |||
28 | const char *comps[3] = {"A","dmAux","dmCh"}; | |||
29 | ||||
30 | ierr = DMCopyDMSNES(dm, *plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),30,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
31 | for (i = 0; i < 3; i++) { | |||
32 | ierr = PetscObjectQuery((PetscObject) dm, comps[i], &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),32,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
33 | ierr = PetscObjectCompose((PetscObject) *plex, comps[i], obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),33,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
34 | } | |||
35 | } | |||
36 | } else { | |||
37 | ierr = PetscObjectReference((PetscObject) *plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),37,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
38 | } | |||
39 | } | |||
40 | 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); | |||
41 | } | |||
42 | ||||
43 | /*@C | |||
44 | DMInterpolationCreate - Creates a DMInterpolationInfo context | |||
45 | ||||
46 | Collective on comm | |||
47 | ||||
48 | Input Parameter: | |||
49 | . comm - the communicator | |||
50 | ||||
51 | Output Parameter: | |||
52 | . ctx - the context | |||
53 | ||||
54 | Level: beginner | |||
55 | ||||
56 | .seealso: DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationDestroy() | |||
57 | @*/ | |||
58 | PetscErrorCode DMInterpolationCreate(MPI_Comm comm, DMInterpolationInfo *ctx) | |||
59 | { | |||
60 | PetscErrorCode ierr; | |||
61 | ||||
62 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 62; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
63 | PetscValidPointer(ctx, 2)do { if (!ctx) return PetscError(((MPI_Comm)0x44000001),63,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(ctx,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),63,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
64 | ierr = PetscNew(ctx)PetscMallocA(1,PETSC_TRUE,64,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(1)*sizeof(**((ctx))),((ctx)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),64,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
65 | ||||
66 | (*ctx)->comm = comm; | |||
67 | (*ctx)->dim = -1; | |||
68 | (*ctx)->nInput = 0; | |||
69 | (*ctx)->points = NULL((void*)0); | |||
70 | (*ctx)->cells = NULL((void*)0); | |||
71 | (*ctx)->n = -1; | |||
72 | (*ctx)->coords = NULL((void*)0); | |||
73 | 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); | |||
74 | } | |||
75 | ||||
76 | /*@C | |||
77 | DMInterpolationSetDim - Sets the spatial dimension for the interpolation context | |||
78 | ||||
79 | Not collective | |||
80 | ||||
81 | Input Parameters: | |||
82 | + ctx - the context | |||
83 | - dim - the spatial dimension | |||
84 | ||||
85 | Level: intermediate | |||
86 | ||||
87 | .seealso: DMInterpolationGetDim(), DMInterpolationEvaluate(), DMInterpolationAddPoints() | |||
88 | @*/ | |||
89 | PetscErrorCode DMInterpolationSetDim(DMInterpolationInfo ctx, PetscInt dim) | |||
90 | { | |||
91 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 91; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
92 | if ((dim < 1) || (dim > 3)) SETERRQ1(ctx->comm, PETSC_ERR_ARG_OUTOFRANGE, "Invalid dimension for points: %d", dim)return PetscError(ctx->comm,92,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Invalid dimension for points: %d",dim ); | |||
93 | ctx->dim = dim; | |||
94 | 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); | |||
95 | } | |||
96 | ||||
97 | /*@C | |||
98 | DMInterpolationGetDim - Gets the spatial dimension for the interpolation context | |||
99 | ||||
100 | Not collective | |||
101 | ||||
102 | Input Parameter: | |||
103 | . ctx - the context | |||
104 | ||||
105 | Output Parameter: | |||
106 | . dim - the spatial dimension | |||
107 | ||||
108 | Level: intermediate | |||
109 | ||||
110 | .seealso: DMInterpolationSetDim(), DMInterpolationEvaluate(), DMInterpolationAddPoints() | |||
111 | @*/ | |||
112 | PetscErrorCode DMInterpolationGetDim(DMInterpolationInfo ctx, PetscInt *dim) | |||
113 | { | |||
114 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 114; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
115 | PetscValidIntPointer(dim, 2)do { if (!dim) return PetscError(((MPI_Comm)0x44000001),115,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(dim,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),115,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); | |||
116 | *dim = ctx->dim; | |||
117 | 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); | |||
118 | } | |||
119 | ||||
120 | /*@C | |||
121 | DMInterpolationSetDof - Sets the number of fields interpolated at a point for the interpolation context | |||
122 | ||||
123 | Not collective | |||
124 | ||||
125 | Input Parameters: | |||
126 | + ctx - the context | |||
127 | - dof - the number of fields | |||
128 | ||||
129 | Level: intermediate | |||
130 | ||||
131 | .seealso: DMInterpolationGetDof(), DMInterpolationEvaluate(), DMInterpolationAddPoints() | |||
132 | @*/ | |||
133 | PetscErrorCode DMInterpolationSetDof(DMInterpolationInfo ctx, PetscInt dof) | |||
134 | { | |||
135 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 135; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
136 | if (dof < 1) SETERRQ1(ctx->comm, PETSC_ERR_ARG_OUTOFRANGE, "Invalid number of components: %d", dof)return PetscError(ctx->comm,136,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Invalid number of components: %d",dof ); | |||
137 | ctx->dof = dof; | |||
138 | 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); | |||
139 | } | |||
140 | ||||
141 | /*@C | |||
142 | DMInterpolationGetDof - Gets the number of fields interpolated at a point for the interpolation context | |||
143 | ||||
144 | Not collective | |||
145 | ||||
146 | Input Parameter: | |||
147 | . ctx - the context | |||
148 | ||||
149 | Output Parameter: | |||
150 | . dof - the number of fields | |||
151 | ||||
152 | Level: intermediate | |||
153 | ||||
154 | .seealso: DMInterpolationSetDof(), DMInterpolationEvaluate(), DMInterpolationAddPoints() | |||
155 | @*/ | |||
156 | PetscErrorCode DMInterpolationGetDof(DMInterpolationInfo ctx, PetscInt *dof) | |||
157 | { | |||
158 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 158; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
159 | PetscValidIntPointer(dof, 2)do { if (!dof) return PetscError(((MPI_Comm)0x44000001),159,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 68,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(dof,PETSC_INT)) return PetscError(((MPI_Comm )0x44000001),159,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer to Int: Parameter # %d" ,2); } while (0); | |||
160 | *dof = ctx->dof; | |||
161 | 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); | |||
162 | } | |||
163 | ||||
164 | /*@C | |||
165 | DMInterpolationAddPoints - Add points at which we will interpolate the fields | |||
166 | ||||
167 | Not collective | |||
168 | ||||
169 | Input Parameters: | |||
170 | + ctx - the context | |||
171 | . n - the number of points | |||
172 | - points - the coordinates for each point, an array of size n * dim | |||
173 | ||||
174 | Note: The coordinate information is copied. | |||
175 | ||||
176 | Level: intermediate | |||
177 | ||||
178 | .seealso: DMInterpolationSetDim(), DMInterpolationEvaluate(), DMInterpolationCreate() | |||
179 | @*/ | |||
180 | PetscErrorCode DMInterpolationAddPoints(DMInterpolationInfo ctx, PetscInt n, PetscReal points[]) | |||
181 | { | |||
182 | PetscErrorCode ierr; | |||
183 | ||||
184 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 184; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
185 | if (ctx->dim < 0) SETERRQ(ctx->comm, PETSC_ERR_ARG_WRONGSTATE, "The spatial dimension has not been set")return PetscError(ctx->comm,185,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"The spatial dimension has not been set" ); | |||
186 | if (ctx->points) SETERRQ(ctx->comm, PETSC_ERR_ARG_WRONGSTATE, "Cannot add points multiple times yet")return PetscError(ctx->comm,186,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"Cannot add points multiple times yet" ); | |||
187 | ctx->nInput = n; | |||
188 | ||||
189 | ierr = PetscMalloc1(n*ctx->dim, &ctx->points)PetscMallocA(1,PETSC_FALSE,189,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(n*ctx->dim)*sizeof(**(&ctx->points)),(& ctx->points));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),189,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
190 | ierr = PetscMemcpy(ctx->points, points, n*ctx->dim * sizeof(PetscReal));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),190,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
191 | 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); | |||
192 | } | |||
193 | ||||
194 | /*@C | |||
195 | DMInterpolationSetUp - Computea spatial indices that add in point location during interpolation | |||
196 | ||||
197 | Collective on ctx | |||
198 | ||||
199 | Input Parameters: | |||
200 | + ctx - the context | |||
201 | . dm - the DM for the function space used for interpolation | |||
202 | - redundantPoints - If PETSC_TRUE, all processes are passing in the same array of points. Otherwise, points need to be communicated among processes. | |||
203 | ||||
204 | Level: intermediate | |||
205 | ||||
206 | .seealso: DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
207 | @*/ | |||
208 | PetscErrorCode DMInterpolationSetUp(DMInterpolationInfo ctx, DM dm, PetscBool redundantPoints) | |||
209 | { | |||
210 | MPI_Comm comm = ctx->comm; | |||
211 | PetscScalar *a; | |||
212 | PetscInt p, q, i; | |||
213 | PetscMPIInt rank, size; | |||
214 | PetscErrorCode ierr; | |||
215 | Vec pointVec; | |||
216 | PetscSF cellSF; | |||
217 | PetscLayout layout; | |||
218 | PetscReal *globalPoints; | |||
219 | PetscScalar *globalPointsScalar; | |||
220 | const PetscInt *ranges; | |||
221 | PetscMPIInt *counts, *displs; | |||
222 | const PetscSFNode *foundCells; | |||
223 | const PetscInt *foundPoints; | |||
224 | PetscMPIInt *foundProcs, *globalProcs; | |||
225 | PetscInt n, N, numFound; | |||
226 | ||||
227 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 227; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
228 | PetscValidHeaderSpecific(dm, DM_CLASSID, 1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),228,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),228,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.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),228,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),228,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||
229 | ierr = MPI_Comm_size(comm, &size);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),229,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
230 | ierr = MPI_Comm_rank(comm, &rank);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),230,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
231 | if (ctx->dim < 0) SETERRQ(comm, PETSC_ERR_ARG_WRONGSTATE, "The spatial dimension has not been set")return PetscError(comm,231,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"The spatial dimension has not been set" ); | |||
232 | /* Locate points */ | |||
233 | n = ctx->nInput; | |||
234 | if (!redundantPoints) { | |||
235 | ierr = PetscLayoutCreate(comm, &layout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),235,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
236 | ierr = PetscLayoutSetBlockSize(layout, 1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),236,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
237 | ierr = PetscLayoutSetLocalSize(layout, n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),237,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
238 | ierr = PetscLayoutSetUp(layout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),238,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
239 | ierr = PetscLayoutGetSize(layout, &N);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),239,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
240 | /* Communicate all points to all processes */ | |||
241 | ierr = PetscMalloc3(N*ctx->dim,&globalPoints,size,&counts,size,&displs)PetscMallocA(3,PETSC_FALSE,241,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(N*ctx->dim)*sizeof(**(&globalPoints)),(& globalPoints),(size_t)(size)*sizeof(**(&counts)),(&counts ),(size_t)(size)*sizeof(**(&displs)),(&displs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),241,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
242 | ierr = PetscLayoutGetRanges(layout, &ranges);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),242,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
243 | for (p = 0; p < size; ++p) { | |||
244 | counts[p] = (ranges[p+1] - ranges[p])*ctx->dim; | |||
245 | displs[p] = ranges[p]*ctx->dim; | |||
246 | } | |||
247 | ierr = MPI_Allgatherv(ctx->points, n*ctx->dim, MPIU_REAL, globalPoints, counts, displs, MPIU_REAL, comm)((petsc_gather_ct += PetscMPIParallelComm((comm)),0) || MPI_Allgatherv ((ctx->points),(n*ctx->dim),(((MPI_Datatype)0x4c00080b) ),(globalPoints),(counts),(displs),(((MPI_Datatype)0x4c00080b )),(comm)));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),247,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
248 | } else { | |||
249 | N = n; | |||
250 | globalPoints = ctx->points; | |||
251 | counts = displs = NULL((void*)0); | |||
252 | layout = NULL((void*)0); | |||
253 | } | |||
254 | #if 0 | |||
255 | ierr = PetscMalloc3(N,&foundCells,N,&foundProcs,N,&globalProcs)PetscMallocA(3,PETSC_FALSE,255,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(N)*sizeof(**(&foundCells)),(&foundCells),(size_t )(N)*sizeof(**(&foundProcs)),(&foundProcs),(size_t)(N )*sizeof(**(&globalProcs)),(&globalProcs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),255,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
256 | /* foundCells[p] = m->locatePoint(&globalPoints[p*ctx->dim]); */ | |||
257 | #else | |||
258 | #if defined(PETSC_USE_COMPLEX) | |||
259 | ierr = PetscMalloc1(N*ctx->dim,&globalPointsScalar)PetscMallocA(1,PETSC_FALSE,259,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(N*ctx->dim)*sizeof(**(&globalPointsScalar)), (&globalPointsScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),259,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
260 | for (i=0; i<N*ctx->dim; i++) globalPointsScalar[i] = globalPoints[i]; | |||
261 | #else | |||
262 | globalPointsScalar = globalPoints; | |||
263 | #endif | |||
264 | ierr = VecCreateSeqWithArray(PETSC_COMM_SELF((MPI_Comm)0x44000001), ctx->dim, N*ctx->dim, globalPointsScalar, &pointVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),264,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
265 | ierr = PetscMalloc2(N,&foundProcs,N,&globalProcs)PetscMallocA(2,PETSC_FALSE,265,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(N)*sizeof(**(&foundProcs)),(&foundProcs),(size_t )(N)*sizeof(**(&globalProcs)),(&globalProcs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),265,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
266 | for (p = 0; p < N; ++p) {foundProcs[p] = size;} | |||
267 | cellSF = NULL((void*)0); | |||
268 | ierr = DMLocatePoints(dm, pointVec, DM_POINTLOCATION_REMOVE, &cellSF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),268,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
269 | ierr = PetscSFGetGraph(cellSF,NULL((void*)0),&numFound,&foundPoints,&foundCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),269,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
270 | #endif | |||
271 | for (p = 0; p < numFound; ++p) { | |||
272 | if (foundCells[p].index >= 0) foundProcs[foundPoints ? foundPoints[p] : p] = rank; | |||
273 | } | |||
274 | /* Let the lowest rank process own each point */ | |||
275 | ierr = MPIU_Allreduce(foundProcs, globalProcs, N, MPI_INT, MPI_MIN, comm)(PetscAllreduceBarrierCheck(comm,N,275,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((petsc_allreduce_ct += PetscMPIParallelComm((comm)),0) || MPI_Allreduce((foundProcs),(globalProcs),(N),(((MPI_Datatype )0x4c000405)),((MPI_Op)(0x58000002)),(comm))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),275,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
276 | ctx->n = 0; | |||
277 | for (p = 0; p < N; ++p) { | |||
278 | if (globalProcs[p] == size) SETERRQ4(comm, PETSC_ERR_PLIB, "Point %d: %g %g %g not located in mesh", p, (double)globalPoints[p*ctx->dim+0], (double)(ctx->dim > 1 ? globalPoints[p*ctx->dim+1] : 0.0), (double)(ctx->dim > 2 ? globalPoints[p*ctx->dim+2] : 0.0))return PetscError(comm,278,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,77,PETSC_ERROR_INITIAL,"Point %d: %g %g %g not located in mesh" ,p,(double)globalPoints[p*ctx->dim+0],(double)(ctx->dim > 1 ? globalPoints[p*ctx->dim+1] : 0.0),(double)(ctx-> dim > 2 ? globalPoints[p*ctx->dim+2] : 0.0)); | |||
279 | else if (globalProcs[p] == rank) ctx->n++; | |||
280 | } | |||
281 | /* Create coordinates vector and array of owned cells */ | |||
282 | ierr = PetscMalloc1(ctx->n, &ctx->cells)PetscMallocA(1,PETSC_FALSE,282,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(ctx->n)*sizeof(**(&ctx->cells)),(&ctx ->cells));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),282,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
283 | ierr = VecCreate(comm, &ctx->coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),283,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
284 | ierr = VecSetSizes(ctx->coords, ctx->n*ctx->dim, PETSC_DECIDE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),284,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
285 | ierr = VecSetBlockSize(ctx->coords, ctx->dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),285,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
286 | ierr = VecSetType(ctx->coords,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),286,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
287 | ierr = VecGetArray(ctx->coords, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),287,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
288 | for (p = 0, q = 0, i = 0; p < N; ++p) { | |||
289 | if (globalProcs[p] == rank) { | |||
290 | PetscInt d; | |||
291 | ||||
292 | for (d = 0; d < ctx->dim; ++d, ++i) a[i] = globalPoints[p*ctx->dim+d]; | |||
293 | ctx->cells[q] = foundCells[q].index; | |||
294 | ++q; | |||
295 | } | |||
296 | } | |||
297 | ierr = VecRestoreArray(ctx->coords, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),297,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
298 | #if 0 | |||
299 | ierr = PetscFree3(foundCells,foundProcs,globalProcs)PetscFreeA(3,299,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(foundCells),&(foundProcs),&(globalProcs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),299,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
300 | #else | |||
301 | ierr = PetscFree2(foundProcs,globalProcs)PetscFreeA(2,301,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(foundProcs),&(globalProcs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),301,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
302 | ierr = PetscSFDestroy(&cellSF);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),302,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
303 | ierr = VecDestroy(&pointVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),303,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
304 | #endif | |||
305 | if ((void*)globalPointsScalar != (void*)globalPoints) {ierr = PetscFree(globalPointsScalar)((*PetscTrFree)((void*)(globalPointsScalar),305,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((globalPointsScalar) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),305,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
306 | if (!redundantPoints) {ierr = PetscFree3(globalPoints,counts,displs)PetscFreeA(3,306,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(globalPoints),&(counts),&(displs));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),306,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
307 | ierr = PetscLayoutDestroy(&layout);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),307,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
308 | 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); | |||
309 | } | |||
310 | ||||
311 | /*@C | |||
312 | DMInterpolationGetCoordinates - Gets a Vec with the coordinates of each interpolation point | |||
313 | ||||
314 | Collective on ctx | |||
315 | ||||
316 | Input Parameter: | |||
317 | . ctx - the context | |||
318 | ||||
319 | Output Parameter: | |||
320 | . coordinates - the coordinates of interpolation points | |||
321 | ||||
322 | Note: The local vector entries correspond to interpolation points lying on this process, according to the associated DM. This is a borrowed vector that the user should not destroy. | |||
323 | ||||
324 | Level: intermediate | |||
325 | ||||
326 | .seealso: DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
327 | @*/ | |||
328 | PetscErrorCode DMInterpolationGetCoordinates(DMInterpolationInfo ctx, Vec *coordinates) | |||
329 | { | |||
330 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 330; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
331 | PetscValidPointer(coordinates, 2)do { if (!coordinates) return PetscError(((MPI_Comm)0x44000001 ),331,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if (!PetscCheckPointer(coordinates,PETSC_CHAR)) return PetscError (((MPI_Comm)0x44000001),331,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
332 | if (!ctx->coords) SETERRQ(ctx->comm, PETSC_ERR_ARG_WRONGSTATE, "The interpolation context has not been setup.")return PetscError(ctx->comm,332,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"The interpolation context has not been setup." ); | |||
333 | *coordinates = ctx->coords; | |||
334 | 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); | |||
335 | } | |||
336 | ||||
337 | /*@C | |||
338 | DMInterpolationGetVector - Gets a Vec which can hold all the interpolated field values | |||
339 | ||||
340 | Collective on ctx | |||
341 | ||||
342 | Input Parameter: | |||
343 | . ctx - the context | |||
344 | ||||
345 | Output Parameter: | |||
346 | . v - a vector capable of holding the interpolated field values | |||
347 | ||||
348 | Note: This vector should be returned using DMInterpolationRestoreVector(). | |||
349 | ||||
350 | Level: intermediate | |||
351 | ||||
352 | .seealso: DMInterpolationRestoreVector(), DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
353 | @*/ | |||
354 | PetscErrorCode DMInterpolationGetVector(DMInterpolationInfo ctx, Vec *v) | |||
355 | { | |||
356 | PetscErrorCode ierr; | |||
357 | ||||
358 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 358; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
359 | PetscValidPointer(v, 2)do { if (!v) return PetscError(((MPI_Comm)0x44000001),359,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(v,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),359,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
360 | if (!ctx->coords) SETERRQ(ctx->comm, PETSC_ERR_ARG_WRONGSTATE, "The interpolation context has not been setup.")return PetscError(ctx->comm,360,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"The interpolation context has not been setup." ); | |||
361 | ierr = VecCreate(ctx->comm, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),361,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
362 | ierr = VecSetSizes(*v, ctx->n*ctx->dof, PETSC_DECIDE-1);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),362,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
363 | ierr = VecSetBlockSize(*v, ctx->dof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),363,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
364 | ierr = VecSetType(*v,VECSTANDARD"standard");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),364,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
365 | 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); | |||
366 | } | |||
367 | ||||
368 | /*@C | |||
369 | DMInterpolationRestoreVector - Returns a Vec which can hold all the interpolated field values | |||
370 | ||||
371 | Collective on ctx | |||
372 | ||||
373 | Input Parameters: | |||
374 | + ctx - the context | |||
375 | - v - a vector capable of holding the interpolated field values | |||
376 | ||||
377 | Level: intermediate | |||
378 | ||||
379 | .seealso: DMInterpolationGetVector(), DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
380 | @*/ | |||
381 | PetscErrorCode DMInterpolationRestoreVector(DMInterpolationInfo ctx, Vec *v) | |||
382 | { | |||
383 | PetscErrorCode ierr; | |||
384 | ||||
385 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 385; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
386 | PetscValidPointer(v, 2)do { if (!v) return PetscError(((MPI_Comm)0x44000001),386,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(v,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),386,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
387 | if (!ctx->coords) SETERRQ(ctx->comm, PETSC_ERR_ARG_WRONGSTATE, "The interpolation context has not been setup.")return PetscError(ctx->comm,387,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,73,PETSC_ERROR_INITIAL,"The interpolation context has not been setup." ); | |||
388 | ierr = VecDestroy(v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),388,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
389 | 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); | |||
390 | } | |||
391 | ||||
392 | PETSC_STATIC_INLINEstatic inline PetscErrorCode DMInterpolate_Triangle_Private(DMInterpolationInfo ctx, DM dm, Vec xLocal, Vec v) | |||
393 | { | |||
394 | PetscReal *v0, *J, *invJ, detJ; | |||
395 | const PetscScalar *coords; | |||
396 | PetscScalar *a; | |||
397 | PetscInt p; | |||
398 | PetscErrorCode ierr; | |||
399 | ||||
400 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 400; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
401 | ierr = PetscMalloc3(ctx->dim,&v0,ctx->dim*ctx->dim,&J,ctx->dim*ctx->dim,&invJ)PetscMallocA(3,PETSC_FALSE,401,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(ctx->dim)*sizeof(**(&v0)),(&v0),(size_t) (ctx->dim*ctx->dim)*sizeof(**(&J)),(&J),(size_t )(ctx->dim*ctx->dim)*sizeof(**(&invJ)),(&invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),401,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
402 | ierr = VecGetArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),402,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
403 | ierr = VecGetArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),403,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
404 | for (p = 0; p < ctx->n; ++p) { | |||
405 | PetscInt c = ctx->cells[p]; | |||
406 | PetscScalar *x = NULL((void*)0); | |||
407 | PetscReal xi[4]; | |||
408 | PetscInt d, f, comp; | |||
409 | ||||
410 | ierr = DMPlexComputeCellGeometryFEM(dm, c, NULL((void*)0), v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),410,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
411 | if (detJ <= 0.0) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Invalid determinant %g for element %d", (double)detJ, c)return PetscError(((MPI_Comm)0x44000001),411,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Invalid determinant %g for element %d" ,(double)detJ,c); | |||
412 | ierr = DMPlexVecGetClosure(dm, NULL((void*)0), xLocal, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),412,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
413 | for (comp = 0; comp < ctx->dof; ++comp) a[p*ctx->dof+comp] = x[0*ctx->dof+comp]; | |||
414 | ||||
415 | for (d = 0; d < ctx->dim; ++d) { | |||
416 | xi[d] = 0.0; | |||
417 | for (f = 0; f < ctx->dim; ++f) xi[d] += invJ[d*ctx->dim+f]*0.5*PetscRealPart(coords[p*ctx->dim+f] - v0[f])(coords[p*ctx->dim+f] - v0[f]); | |||
418 | for (comp = 0; comp < ctx->dof; ++comp) a[p*ctx->dof+comp] += PetscRealPart(x[(d+1)*ctx->dof+comp] - x[0*ctx->dof+comp])(x[(d+1)*ctx->dof+comp] - x[0*ctx->dof+comp])*xi[d]; | |||
419 | } | |||
420 | ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), xLocal, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),420,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
421 | } | |||
422 | ierr = VecRestoreArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),422,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
423 | ierr = VecRestoreArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),423,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
424 | ierr = PetscFree3(v0, J, invJ)PetscFreeA(3,424,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(v0),&(J),&(invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),424,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
425 | 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); | |||
426 | } | |||
427 | ||||
428 | PETSC_STATIC_INLINEstatic inline PetscErrorCode DMInterpolate_Tetrahedron_Private(DMInterpolationInfo ctx, DM dm, Vec xLocal, Vec v) | |||
429 | { | |||
430 | PetscReal *v0, *J, *invJ, detJ; | |||
431 | const PetscScalar *coords; | |||
432 | PetscScalar *a; | |||
433 | PetscInt p; | |||
434 | PetscErrorCode ierr; | |||
435 | ||||
436 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 436; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
437 | ierr = PetscMalloc3(ctx->dim,&v0,ctx->dim*ctx->dim,&J,ctx->dim*ctx->dim,&invJ)PetscMallocA(3,PETSC_FALSE,437,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(ctx->dim)*sizeof(**(&v0)),(&v0),(size_t) (ctx->dim*ctx->dim)*sizeof(**(&J)),(&J),(size_t )(ctx->dim*ctx->dim)*sizeof(**(&invJ)),(&invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),437,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
438 | ierr = VecGetArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),438,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
439 | ierr = VecGetArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),439,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
440 | for (p = 0; p < ctx->n; ++p) { | |||
441 | PetscInt c = ctx->cells[p]; | |||
442 | const PetscInt order[3] = {2, 1, 3}; | |||
443 | PetscScalar *x = NULL((void*)0); | |||
444 | PetscReal xi[4]; | |||
445 | PetscInt d, f, comp; | |||
446 | ||||
447 | ierr = DMPlexComputeCellGeometryFEM(dm, c, NULL((void*)0), v0, J, invJ, &detJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),447,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
448 | if (detJ <= 0.0) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_ARG_OUTOFRANGE, "Invalid determinant %g for element %d", (double)detJ, c)return PetscError(((MPI_Comm)0x44000001),448,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Invalid determinant %g for element %d" ,(double)detJ,c); | |||
449 | ierr = DMPlexVecGetClosure(dm, NULL((void*)0), xLocal, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),449,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
450 | for (comp = 0; comp < ctx->dof; ++comp) a[p*ctx->dof+comp] = x[0*ctx->dof+comp]; | |||
451 | ||||
452 | for (d = 0; d < ctx->dim; ++d) { | |||
453 | xi[d] = 0.0; | |||
454 | for (f = 0; f < ctx->dim; ++f) xi[d] += invJ[d*ctx->dim+f]*0.5*PetscRealPart(coords[p*ctx->dim+f] - v0[f])(coords[p*ctx->dim+f] - v0[f]); | |||
455 | for (comp = 0; comp < ctx->dof; ++comp) a[p*ctx->dof+comp] += PetscRealPart(x[order[d]*ctx->dof+comp] - x[0*ctx->dof+comp])(x[order[d]*ctx->dof+comp] - x[0*ctx->dof+comp])*xi[d]; | |||
456 | } | |||
457 | ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), xLocal, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),457,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
458 | } | |||
459 | ierr = VecRestoreArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),459,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
460 | ierr = VecRestoreArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),460,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
461 | ierr = PetscFree3(v0, J, invJ)PetscFreeA(3,461,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(v0),&(J),&(invJ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),461,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
462 | 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); | |||
463 | } | |||
464 | ||||
465 | PETSC_STATIC_INLINEstatic inline PetscErrorCode QuadMap_Private(SNES snes, Vec Xref, Vec Xreal, void *ctx) | |||
466 | { | |||
467 | const PetscScalar *vertices = (const PetscScalar*) ctx; | |||
468 | const PetscScalar x0 = vertices[0]; | |||
469 | const PetscScalar y0 = vertices[1]; | |||
470 | const PetscScalar x1 = vertices[2]; | |||
471 | const PetscScalar y1 = vertices[3]; | |||
472 | const PetscScalar x2 = vertices[4]; | |||
473 | const PetscScalar y2 = vertices[5]; | |||
474 | const PetscScalar x3 = vertices[6]; | |||
475 | const PetscScalar y3 = vertices[7]; | |||
476 | const PetscScalar f_1 = x1 - x0; | |||
477 | const PetscScalar g_1 = y1 - y0; | |||
478 | const PetscScalar f_3 = x3 - x0; | |||
479 | const PetscScalar g_3 = y3 - y0; | |||
480 | const PetscScalar f_01 = x2 - x1 - x3 + x0; | |||
481 | const PetscScalar g_01 = y2 - y1 - y3 + y0; | |||
482 | const PetscScalar *ref; | |||
483 | PetscScalar *real; | |||
484 | PetscErrorCode ierr; | |||
485 | ||||
486 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 486; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
487 | ierr = VecGetArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),487,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
488 | ierr = VecGetArray(Xreal, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),488,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
489 | { | |||
490 | const PetscScalar p0 = ref[0]; | |||
491 | const PetscScalar p1 = ref[1]; | |||
492 | ||||
493 | real[0] = x0 + f_1 * p0 + f_3 * p1 + f_01 * p0 * p1; | |||
494 | real[1] = y0 + g_1 * p0 + g_3 * p1 + g_01 * p0 * p1; | |||
495 | } | |||
496 | ierr = PetscLogFlops(28);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),496,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
497 | ierr = VecRestoreArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),497,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
498 | ierr = VecRestoreArray(Xreal, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),498,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
499 | 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); | |||
500 | } | |||
501 | ||||
502 | #include <petsc/private/dmimpl.h> | |||
503 | PETSC_STATIC_INLINEstatic inline PetscErrorCode QuadJacobian_Private(SNES snes, Vec Xref, Mat J, Mat M, void *ctx) | |||
504 | { | |||
505 | const PetscScalar *vertices = (const PetscScalar*) ctx; | |||
506 | const PetscScalar x0 = vertices[0]; | |||
507 | const PetscScalar y0 = vertices[1]; | |||
508 | const PetscScalar x1 = vertices[2]; | |||
509 | const PetscScalar y1 = vertices[3]; | |||
510 | const PetscScalar x2 = vertices[4]; | |||
511 | const PetscScalar y2 = vertices[5]; | |||
512 | const PetscScalar x3 = vertices[6]; | |||
513 | const PetscScalar y3 = vertices[7]; | |||
514 | const PetscScalar f_01 = x2 - x1 - x3 + x0; | |||
515 | const PetscScalar g_01 = y2 - y1 - y3 + y0; | |||
516 | const PetscScalar *ref; | |||
517 | PetscErrorCode ierr; | |||
518 | ||||
519 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 519; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
520 | ierr = VecGetArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),520,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
521 | { | |||
522 | const PetscScalar x = ref[0]; | |||
523 | const PetscScalar y = ref[1]; | |||
524 | const PetscInt rows[2] = {0, 1}; | |||
525 | PetscScalar values[4]; | |||
526 | ||||
527 | values[0] = (x1 - x0 + f_01*y) * 0.5; values[1] = (x3 - x0 + f_01*x) * 0.5; | |||
528 | values[2] = (y1 - y0 + g_01*y) * 0.5; values[3] = (y3 - y0 + g_01*x) * 0.5; | |||
529 | ierr = MatSetValues(J, 2, rows, 2, rows, values, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),529,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
530 | } | |||
531 | ierr = PetscLogFlops(30);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),531,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
532 | ierr = VecRestoreArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),532,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
533 | ierr = MatAssemblyBegin(J, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),533,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
534 | ierr = MatAssemblyEnd(J, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),534,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.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 | ||||
538 | PETSC_STATIC_INLINEstatic inline PetscErrorCode DMInterpolate_Quad_Private(DMInterpolationInfo ctx, DM dm, Vec xLocal, Vec v) | |||
539 | { | |||
540 | DM dmCoord; | |||
541 | PetscFE fem = NULL((void*)0); | |||
542 | SNES snes; | |||
543 | KSP ksp; | |||
544 | PC pc; | |||
545 | Vec coordsLocal, r, ref, real; | |||
546 | Mat J; | |||
547 | const PetscScalar *coords; | |||
548 | PetscScalar *a; | |||
549 | PetscInt Nf, p; | |||
550 | const PetscInt dof = ctx->dof; | |||
551 | PetscErrorCode ierr; | |||
552 | ||||
553 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 553; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
554 | ierr = DMGetNumFields(dm, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),554,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
555 | if (Nf) {ierr = DMGetField(dm, 0, NULL((void*)0), (PetscObject *) &fem);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),555,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
556 | ierr = DMGetCoordinatesLocal(dm, &coordsLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),556,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
557 | ierr = DMGetCoordinateDM(dm, &dmCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),557,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
558 | ierr = SNESCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),558,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
559 | ierr = SNESSetOptionsPrefix(snes, "quad_interp_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),559,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
560 | ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),560,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
561 | ierr = VecSetSizes(r, 2, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),561,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
562 | ierr = VecSetType(r,dm->vectype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),562,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
563 | ierr = VecDuplicate(r, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),563,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
564 | ierr = VecDuplicate(r, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),564,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
565 | ierr = MatCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),565,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
566 | ierr = MatSetSizes(J, 2, 2, 2, 2);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),566,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
567 | ierr = MatSetType(J, MATSEQDENSE"seqdense");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),567,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
568 | ierr = MatSetUp(J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),568,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
569 | ierr = SNESSetFunction(snes, r, QuadMap_Private, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),569,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
570 | ierr = SNESSetJacobian(snes, J, J, QuadJacobian_Private, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),570,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
571 | ierr = SNESGetKSP(snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),571,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
572 | ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),572,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
573 | ierr = PCSetType(pc, PCLU"lu");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),573,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
574 | ierr = SNESSetFromOptions(snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),574,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
575 | ||||
576 | ierr = VecGetArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),576,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
577 | ierr = VecGetArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),577,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
578 | for (p = 0; p < ctx->n; ++p) { | |||
579 | PetscScalar *x = NULL((void*)0), *vertices = NULL((void*)0); | |||
580 | PetscScalar *xi; | |||
581 | PetscReal xir[2]; | |||
582 | PetscInt c = ctx->cells[p], comp, coordSize, xSize; | |||
583 | ||||
584 | /* Can make this do all points at once */ | |||
585 | ierr = DMPlexVecGetClosure(dmCoord, NULL((void*)0), coordsLocal, c, &coordSize, &vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),585,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
586 | if (4*2 != coordSize) SETERRQ2(ctx->comm, PETSC_ERR_ARG_SIZ, "Invalid closure size %d should be %d", coordSize, 4*2)return PetscError(ctx->comm,586,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,60,PETSC_ERROR_INITIAL,"Invalid closure size %d should be %d" ,coordSize,4*2); | |||
587 | ierr = DMPlexVecGetClosure(dm, NULL((void*)0), xLocal, c, &xSize, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),587,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
588 | ierr = SNESSetFunction(snes, NULL((void*)0), NULL((void*)0), (void*) vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),588,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
589 | ierr = SNESSetJacobian(snes, NULL((void*)0), NULL((void*)0), NULL((void*)0), (void*) vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),589,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
590 | ierr = VecGetArray(real, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),590,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
591 | xi[0] = coords[p*ctx->dim+0]; | |||
592 | xi[1] = coords[p*ctx->dim+1]; | |||
593 | ierr = VecRestoreArray(real, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),593,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
594 | ierr = SNESSolve(snes, real, ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),594,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
595 | ierr = VecGetArray(ref, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),595,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
596 | xir[0] = PetscRealPart(xi[0])(xi[0]); | |||
597 | xir[1] = PetscRealPart(xi[1])(xi[1]); | |||
598 | if (4*dof != xSize) { | |||
599 | PetscReal *B; | |||
600 | PetscInt d; | |||
601 | ||||
602 | xir[0] = 2.0*xir[0] - 1.0; xir[1] = 2.0*xir[1] - 1.0; | |||
603 | ierr = PetscFEGetTabulation(fem, 1, xir, &B, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),603,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
604 | for (comp = 0; comp < dof; ++comp) { | |||
605 | a[p*dof+comp] = 0.0; | |||
606 | for (d = 0; d < xSize/dof; ++d) { | |||
607 | a[p*dof+comp] += x[d*dof+comp]*B[d*dof+comp]; | |||
608 | } | |||
609 | } | |||
610 | ierr = PetscFERestoreTabulation(fem, 1, xir, &B, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),610,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
611 | } else { | |||
612 | for (comp = 0; comp < dof; ++comp) | |||
613 | a[p*dof+comp] = x[0*dof+comp]*(1 - xir[0])*(1 - xir[1]) + x[1*dof+comp]*xir[0]*(1 - xir[1]) + x[2*dof+comp]*xir[0]*xir[1] + x[3*dof+comp]*(1 - xir[0])*xir[1]; | |||
614 | } | |||
615 | ierr = VecRestoreArray(ref, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),615,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
616 | ierr = DMPlexVecRestoreClosure(dmCoord, NULL((void*)0), coordsLocal, c, &coordSize, &vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),616,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
617 | ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), xLocal, c, &xSize, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),617,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
618 | } | |||
619 | ierr = VecRestoreArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),619,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
620 | ierr = VecRestoreArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),620,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
621 | ||||
622 | ierr = SNESDestroy(&snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),622,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
623 | ierr = VecDestroy(&r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),623,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
624 | ierr = VecDestroy(&ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),624,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
625 | ierr = VecDestroy(&real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),625,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
626 | ierr = MatDestroy(&J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),626,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
627 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
628 | } | |||
629 | ||||
630 | PETSC_STATIC_INLINEstatic inline PetscErrorCode HexMap_Private(SNES snes, Vec Xref, Vec Xreal, void *ctx) | |||
631 | { | |||
632 | const PetscScalar *vertices = (const PetscScalar*) ctx; | |||
633 | const PetscScalar x0 = vertices[0]; | |||
634 | const PetscScalar y0 = vertices[1]; | |||
635 | const PetscScalar z0 = vertices[2]; | |||
636 | const PetscScalar x1 = vertices[9]; | |||
637 | const PetscScalar y1 = vertices[10]; | |||
638 | const PetscScalar z1 = vertices[11]; | |||
639 | const PetscScalar x2 = vertices[6]; | |||
640 | const PetscScalar y2 = vertices[7]; | |||
641 | const PetscScalar z2 = vertices[8]; | |||
642 | const PetscScalar x3 = vertices[3]; | |||
643 | const PetscScalar y3 = vertices[4]; | |||
644 | const PetscScalar z3 = vertices[5]; | |||
645 | const PetscScalar x4 = vertices[12]; | |||
646 | const PetscScalar y4 = vertices[13]; | |||
647 | const PetscScalar z4 = vertices[14]; | |||
648 | const PetscScalar x5 = vertices[15]; | |||
649 | const PetscScalar y5 = vertices[16]; | |||
650 | const PetscScalar z5 = vertices[17]; | |||
651 | const PetscScalar x6 = vertices[18]; | |||
652 | const PetscScalar y6 = vertices[19]; | |||
653 | const PetscScalar z6 = vertices[20]; | |||
654 | const PetscScalar x7 = vertices[21]; | |||
655 | const PetscScalar y7 = vertices[22]; | |||
656 | const PetscScalar z7 = vertices[23]; | |||
657 | const PetscScalar f_1 = x1 - x0; | |||
658 | const PetscScalar g_1 = y1 - y0; | |||
659 | const PetscScalar h_1 = z1 - z0; | |||
660 | const PetscScalar f_3 = x3 - x0; | |||
661 | const PetscScalar g_3 = y3 - y0; | |||
662 | const PetscScalar h_3 = z3 - z0; | |||
663 | const PetscScalar f_4 = x4 - x0; | |||
664 | const PetscScalar g_4 = y4 - y0; | |||
665 | const PetscScalar h_4 = z4 - z0; | |||
666 | const PetscScalar f_01 = x2 - x1 - x3 + x0; | |||
667 | const PetscScalar g_01 = y2 - y1 - y3 + y0; | |||
668 | const PetscScalar h_01 = z2 - z1 - z3 + z0; | |||
669 | const PetscScalar f_12 = x7 - x3 - x4 + x0; | |||
670 | const PetscScalar g_12 = y7 - y3 - y4 + y0; | |||
671 | const PetscScalar h_12 = z7 - z3 - z4 + z0; | |||
672 | const PetscScalar f_02 = x5 - x1 - x4 + x0; | |||
673 | const PetscScalar g_02 = y5 - y1 - y4 + y0; | |||
674 | const PetscScalar h_02 = z5 - z1 - z4 + z0; | |||
675 | const PetscScalar f_012 = x6 - x0 + x1 - x2 + x3 + x4 - x5 - x7; | |||
676 | const PetscScalar g_012 = y6 - y0 + y1 - y2 + y3 + y4 - y5 - y7; | |||
677 | const PetscScalar h_012 = z6 - z0 + z1 - z2 + z3 + z4 - z5 - z7; | |||
678 | const PetscScalar *ref; | |||
679 | PetscScalar *real; | |||
680 | PetscErrorCode ierr; | |||
681 | ||||
682 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 682; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
683 | ierr = VecGetArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),683,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
684 | ierr = VecGetArray(Xreal, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),684,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
685 | { | |||
686 | const PetscScalar p0 = ref[0]; | |||
687 | const PetscScalar p1 = ref[1]; | |||
688 | const PetscScalar p2 = ref[2]; | |||
689 | ||||
690 | real[0] = x0 + f_1*p0 + f_3*p1 + f_4*p2 + f_01*p0*p1 + f_12*p1*p2 + f_02*p0*p2 + f_012*p0*p1*p2; | |||
691 | real[1] = y0 + g_1*p0 + g_3*p1 + g_4*p2 + g_01*p0*p1 + g_01*p0*p1 + g_12*p1*p2 + g_02*p0*p2 + g_012*p0*p1*p2; | |||
692 | real[2] = z0 + h_1*p0 + h_3*p1 + h_4*p2 + h_01*p0*p1 + h_01*p0*p1 + h_12*p1*p2 + h_02*p0*p2 + h_012*p0*p1*p2; | |||
693 | } | |||
694 | ierr = PetscLogFlops(114);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),694,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
695 | ierr = VecRestoreArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),695,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
696 | ierr = VecRestoreArray(Xreal, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),696,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
697 | 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); | |||
698 | } | |||
699 | ||||
700 | PETSC_STATIC_INLINEstatic inline PetscErrorCode HexJacobian_Private(SNES snes, Vec Xref, Mat J, Mat M, void *ctx) | |||
701 | { | |||
702 | const PetscScalar *vertices = (const PetscScalar*) ctx; | |||
703 | const PetscScalar x0 = vertices[0]; | |||
704 | const PetscScalar y0 = vertices[1]; | |||
705 | const PetscScalar z0 = vertices[2]; | |||
706 | const PetscScalar x1 = vertices[9]; | |||
707 | const PetscScalar y1 = vertices[10]; | |||
708 | const PetscScalar z1 = vertices[11]; | |||
709 | const PetscScalar x2 = vertices[6]; | |||
710 | const PetscScalar y2 = vertices[7]; | |||
711 | const PetscScalar z2 = vertices[8]; | |||
712 | const PetscScalar x3 = vertices[3]; | |||
713 | const PetscScalar y3 = vertices[4]; | |||
714 | const PetscScalar z3 = vertices[5]; | |||
715 | const PetscScalar x4 = vertices[12]; | |||
716 | const PetscScalar y4 = vertices[13]; | |||
717 | const PetscScalar z4 = vertices[14]; | |||
718 | const PetscScalar x5 = vertices[15]; | |||
719 | const PetscScalar y5 = vertices[16]; | |||
720 | const PetscScalar z5 = vertices[17]; | |||
721 | const PetscScalar x6 = vertices[18]; | |||
722 | const PetscScalar y6 = vertices[19]; | |||
723 | const PetscScalar z6 = vertices[20]; | |||
724 | const PetscScalar x7 = vertices[21]; | |||
725 | const PetscScalar y7 = vertices[22]; | |||
726 | const PetscScalar z7 = vertices[23]; | |||
727 | const PetscScalar f_xy = x2 - x1 - x3 + x0; | |||
728 | const PetscScalar g_xy = y2 - y1 - y3 + y0; | |||
729 | const PetscScalar h_xy = z2 - z1 - z3 + z0; | |||
730 | const PetscScalar f_yz = x7 - x3 - x4 + x0; | |||
731 | const PetscScalar g_yz = y7 - y3 - y4 + y0; | |||
732 | const PetscScalar h_yz = z7 - z3 - z4 + z0; | |||
733 | const PetscScalar f_xz = x5 - x1 - x4 + x0; | |||
734 | const PetscScalar g_xz = y5 - y1 - y4 + y0; | |||
735 | const PetscScalar h_xz = z5 - z1 - z4 + z0; | |||
736 | const PetscScalar f_xyz = x6 - x0 + x1 - x2 + x3 + x4 - x5 - x7; | |||
737 | const PetscScalar g_xyz = y6 - y0 + y1 - y2 + y3 + y4 - y5 - y7; | |||
738 | const PetscScalar h_xyz = z6 - z0 + z1 - z2 + z3 + z4 - z5 - z7; | |||
739 | const PetscScalar *ref; | |||
740 | PetscErrorCode ierr; | |||
741 | ||||
742 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 742; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
743 | ierr = VecGetArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),743,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
744 | { | |||
745 | const PetscScalar x = ref[0]; | |||
746 | const PetscScalar y = ref[1]; | |||
747 | const PetscScalar z = ref[2]; | |||
748 | const PetscInt rows[3] = {0, 1, 2}; | |||
749 | PetscScalar values[9]; | |||
750 | ||||
751 | values[0] = (x1 - x0 + f_xy*y + f_xz*z + f_xyz*y*z) / 2.0; | |||
752 | values[1] = (x3 - x0 + f_xy*x + f_yz*z + f_xyz*x*z) / 2.0; | |||
753 | values[2] = (x4 - x0 + f_yz*y + f_xz*x + f_xyz*x*y) / 2.0; | |||
754 | values[3] = (y1 - y0 + g_xy*y + g_xz*z + g_xyz*y*z) / 2.0; | |||
755 | values[4] = (y3 - y0 + g_xy*x + g_yz*z + g_xyz*x*z) / 2.0; | |||
756 | values[5] = (y4 - y0 + g_yz*y + g_xz*x + g_xyz*x*y) / 2.0; | |||
757 | values[6] = (z1 - z0 + h_xy*y + h_xz*z + h_xyz*y*z) / 2.0; | |||
758 | values[7] = (z3 - z0 + h_xy*x + h_yz*z + h_xyz*x*z) / 2.0; | |||
759 | values[8] = (z4 - z0 + h_yz*y + h_xz*x + h_xyz*x*y) / 2.0; | |||
760 | ||||
761 | ierr = MatSetValues(J, 3, rows, 3, rows, values, INSERT_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),761,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
762 | } | |||
763 | ierr = PetscLogFlops(152);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),763,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
764 | ierr = VecRestoreArrayRead(Xref, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),764,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
765 | ierr = MatAssemblyBegin(J, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),765,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
766 | ierr = MatAssemblyEnd(J, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),766,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
767 | 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); | |||
768 | } | |||
769 | ||||
770 | PETSC_STATIC_INLINEstatic inline PetscErrorCode DMInterpolate_Hex_Private(DMInterpolationInfo ctx, DM dm, Vec xLocal, Vec v) | |||
771 | { | |||
772 | DM dmCoord; | |||
773 | SNES snes; | |||
774 | KSP ksp; | |||
775 | PC pc; | |||
776 | Vec coordsLocal, r, ref, real; | |||
777 | Mat J; | |||
778 | const PetscScalar *coords; | |||
779 | PetscScalar *a; | |||
780 | PetscInt p; | |||
781 | PetscErrorCode ierr; | |||
782 | ||||
783 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 783; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
784 | ierr = DMGetCoordinatesLocal(dm, &coordsLocal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),784,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
785 | ierr = DMGetCoordinateDM(dm, &dmCoord);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),785,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
786 | ierr = SNESCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),786,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
787 | ierr = SNESSetOptionsPrefix(snes, "hex_interp_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),787,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
788 | ierr = VecCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),788,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
789 | ierr = VecSetSizes(r, 3, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),789,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
790 | ierr = VecSetType(r,dm->vectype);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),790,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
791 | ierr = VecDuplicate(r, &ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),791,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
792 | ierr = VecDuplicate(r, &real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),792,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
793 | ierr = MatCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),793,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
794 | ierr = MatSetSizes(J, 3, 3, 3, 3);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),794,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
795 | ierr = MatSetType(J, MATSEQDENSE"seqdense");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),795,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
796 | ierr = MatSetUp(J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),796,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
797 | ierr = SNESSetFunction(snes, r, HexMap_Private, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),797,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
798 | ierr = SNESSetJacobian(snes, J, J, HexJacobian_Private, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),798,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
799 | ierr = SNESGetKSP(snes, &ksp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),799,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
800 | ierr = KSPGetPC(ksp, &pc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),800,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
801 | ierr = PCSetType(pc, PCLU"lu");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),801,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
802 | ierr = SNESSetFromOptions(snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),802,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
803 | ||||
804 | ierr = VecGetArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),804,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
805 | ierr = VecGetArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),805,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
806 | for (p = 0; p < ctx->n; ++p) { | |||
807 | PetscScalar *x = NULL((void*)0), *vertices = NULL((void*)0); | |||
808 | PetscScalar *xi; | |||
809 | PetscReal xir[3]; | |||
810 | PetscInt c = ctx->cells[p], comp, coordSize, xSize; | |||
811 | ||||
812 | /* Can make this do all points at once */ | |||
813 | ierr = DMPlexVecGetClosure(dmCoord, NULL((void*)0), coordsLocal, c, &coordSize, &vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),813,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
814 | if (8*3 != coordSize) SETERRQ2(ctx->comm, PETSC_ERR_ARG_SIZ, "Invalid closure size %d should be %d", coordSize, 8*3)return PetscError(ctx->comm,814,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,60,PETSC_ERROR_INITIAL,"Invalid closure size %d should be %d" ,coordSize,8*3); | |||
815 | ierr = DMPlexVecGetClosure(dm, NULL((void*)0), xLocal, c, &xSize, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),815,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
816 | if (8*ctx->dof != xSize) SETERRQ2(ctx->comm, PETSC_ERR_ARG_SIZ, "Invalid closure size %d should be %d", xSize, 8*ctx->dof)return PetscError(ctx->comm,816,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,60,PETSC_ERROR_INITIAL,"Invalid closure size %d should be %d" ,xSize,8*ctx->dof); | |||
817 | ierr = SNESSetFunction(snes, NULL((void*)0), NULL((void*)0), (void*) vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),817,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
818 | ierr = SNESSetJacobian(snes, NULL((void*)0), NULL((void*)0), NULL((void*)0), (void*) vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),818,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
819 | ierr = VecGetArray(real, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),819,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
820 | xi[0] = coords[p*ctx->dim+0]; | |||
821 | xi[1] = coords[p*ctx->dim+1]; | |||
822 | xi[2] = coords[p*ctx->dim+2]; | |||
823 | ierr = VecRestoreArray(real, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),823,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
824 | ierr = SNESSolve(snes, real, ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),824,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
825 | ierr = VecGetArray(ref, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),825,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
826 | xir[0] = PetscRealPart(xi[0])(xi[0]); | |||
827 | xir[1] = PetscRealPart(xi[1])(xi[1]); | |||
828 | xir[2] = PetscRealPart(xi[2])(xi[2]); | |||
829 | for (comp = 0; comp < ctx->dof; ++comp) { | |||
830 | a[p*ctx->dof+comp] = | |||
831 | x[0*ctx->dof+comp]*(1-xir[0])*(1-xir[1])*(1-xir[2]) + | |||
832 | x[3*ctx->dof+comp]* xir[0]*(1-xir[1])*(1-xir[2]) + | |||
833 | x[2*ctx->dof+comp]* xir[0]* xir[1]*(1-xir[2]) + | |||
834 | x[1*ctx->dof+comp]*(1-xir[0])* xir[1]*(1-xir[2]) + | |||
835 | x[4*ctx->dof+comp]*(1-xir[0])*(1-xir[1])* xir[2] + | |||
836 | x[5*ctx->dof+comp]* xir[0]*(1-xir[1])* xir[2] + | |||
837 | x[6*ctx->dof+comp]* xir[0]* xir[1]* xir[2] + | |||
838 | x[7*ctx->dof+comp]*(1-xir[0])* xir[1]* xir[2]; | |||
839 | } | |||
840 | ierr = VecRestoreArray(ref, &xi);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),840,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
841 | ierr = DMPlexVecRestoreClosure(dmCoord, NULL((void*)0), coordsLocal, c, &coordSize, &vertices);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),841,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
842 | ierr = DMPlexVecRestoreClosure(dm, NULL((void*)0), xLocal, c, &xSize, &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),842,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
843 | } | |||
844 | ierr = VecRestoreArray(v, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),844,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
845 | ierr = VecRestoreArrayRead(ctx->coords, &coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),845,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
846 | ||||
847 | ierr = SNESDestroy(&snes);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),847,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
848 | ierr = VecDestroy(&r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),848,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
849 | ierr = VecDestroy(&ref);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),849,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
850 | ierr = VecDestroy(&real);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),850,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
851 | ierr = MatDestroy(&J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),851,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
852 | 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); | |||
853 | } | |||
854 | ||||
855 | /*@C | |||
856 | DMInterpolationEvaluate - Using the input from dm and x, calculates interpolated field values at the interpolation points. | |||
857 | ||||
858 | Input Parameters: | |||
859 | + ctx - The DMInterpolationInfo context | |||
860 | . dm - The DM | |||
861 | - x - The local vector containing the field to be interpolated | |||
862 | ||||
863 | Output Parameters: | |||
864 | . v - The vector containing the interpolated values | |||
865 | ||||
866 | Note: A suitable v can be obtained using DMInterpolationGetVector(). | |||
867 | ||||
868 | Level: beginner | |||
869 | ||||
870 | .seealso: DMInterpolationGetVector(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
871 | @*/ | |||
872 | PetscErrorCode DMInterpolationEvaluate(DMInterpolationInfo ctx, DM dm, Vec x, Vec v) | |||
873 | { | |||
874 | PetscInt dim, coneSize, n; | |||
875 | PetscErrorCode ierr; | |||
876 | ||||
877 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 877; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
878 | PetscValidHeaderSpecific(dm, DM_CLASSID, 2)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),878,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),878,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(dm))->classid != DM_CLASSID) { if ( ((PetscObject)(dm))->classid == -1) return PetscError(((MPI_Comm )0x44000001),878,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),878,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,2); } } while (0); | |||
879 | PetscValidHeaderSpecific(x, VEC_CLASSID, 3)do { if (!x) return PetscError(((MPI_Comm)0x44000001),879,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",3); if ( !PetscCheckPointer(x,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),879,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,3); if (((PetscObject)(x))->classid != VEC_CLASSID) { if ( ((PetscObject)(x))->classid == -1) return PetscError(((MPI_Comm )0x44000001),879,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,3); else return PetscError(((MPI_Comm)0x44000001),879,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,3); } } while (0); | |||
880 | PetscValidHeaderSpecific(v, VEC_CLASSID, 4)do { if (!v) return PetscError(((MPI_Comm)0x44000001),880,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",4); if ( !PetscCheckPointer(v,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),880,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,4); if (((PetscObject)(v))->classid != VEC_CLASSID) { if ( ((PetscObject)(v))->classid == -1) return PetscError(((MPI_Comm )0x44000001),880,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,4); else return PetscError(((MPI_Comm)0x44000001),880,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,4); } } while (0); | |||
881 | ierr = VecGetLocalSize(v, &n);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),881,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
882 | if (n != ctx->n*ctx->dof) SETERRQ2(ctx->comm, PETSC_ERR_ARG_SIZ, "Invalid input vector size %d should be %d", n, ctx->n*ctx->dof)return PetscError(ctx->comm,882,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,60,PETSC_ERROR_INITIAL,"Invalid input vector size %d should be %d" ,n,ctx->n*ctx->dof); | |||
883 | if (n) { | |||
884 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),884,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
885 | ierr = DMPlexGetConeSize(dm, ctx->cells[0], &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),885,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
886 | if (dim == 2) { | |||
887 | if (coneSize == 3) { | |||
888 | ierr = DMInterpolate_Triangle_Private(ctx, dm, x, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),888,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
889 | } else if (coneSize == 4) { | |||
890 | ierr = DMInterpolate_Quad_Private(ctx, dm, x, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),890,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
891 | } else SETERRQ1(ctx->comm, PETSC_ERR_ARG_OUTOFRANGE, "Unsupported dimension %d for point interpolation", dim)return PetscError(ctx->comm,891,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Unsupported dimension %d for point interpolation" ,dim); | |||
892 | } else if (dim == 3) { | |||
893 | if (coneSize == 4) { | |||
894 | ierr = DMInterpolate_Tetrahedron_Private(ctx, dm, x, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),894,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
895 | } else { | |||
896 | ierr = DMInterpolate_Hex_Private(ctx, dm, x, v);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),896,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
897 | } | |||
898 | } else SETERRQ1(ctx->comm, PETSC_ERR_ARG_OUTOFRANGE, "Unsupported dimension %d for point interpolation", dim)return PetscError(ctx->comm,898,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,63,PETSC_ERROR_INITIAL,"Unsupported dimension %d for point interpolation" ,dim); | |||
899 | } | |||
900 | 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); | |||
901 | } | |||
902 | ||||
903 | /*@C | |||
904 | DMInterpolationDestroy - Destroys a DMInterpolationInfo context | |||
905 | ||||
906 | Collective on ctx | |||
907 | ||||
908 | Input Parameter: | |||
909 | . ctx - the context | |||
910 | ||||
911 | Level: beginner | |||
912 | ||||
913 | .seealso: DMInterpolationEvaluate(), DMInterpolationAddPoints(), DMInterpolationCreate() | |||
914 | @*/ | |||
915 | PetscErrorCode DMInterpolationDestroy(DMInterpolationInfo *ctx) | |||
916 | { | |||
917 | PetscErrorCode ierr; | |||
918 | ||||
919 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 919; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
920 | PetscValidPointer(ctx, 2)do { if (!ctx) return PetscError(((MPI_Comm)0x44000001),920,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",2); if ( !PetscCheckPointer(ctx,PETSC_CHAR)) return PetscError(((MPI_Comm )0x44000001),920,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",2); } while (0); | |||
921 | ierr = VecDestroy(&(*ctx)->coords);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),921,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
922 | ierr = PetscFree((*ctx)->points)((*PetscTrFree)((void*)((*ctx)->points),922,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || (((*ctx)->points) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),922,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
923 | ierr = PetscFree((*ctx)->cells)((*PetscTrFree)((void*)((*ctx)->cells),923,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || (((*ctx)->cells) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),923,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
924 | ierr = PetscFree(*ctx)((*PetscTrFree)((void*)(*ctx),924,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((*ctx) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),924,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
925 | *ctx = NULL((void*)0); | |||
926 | 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); | |||
927 | } | |||
928 | ||||
929 | /*@C | |||
930 | SNESMonitorFields - Monitors the residual for each field separately | |||
931 | ||||
932 | Collective on SNES | |||
933 | ||||
934 | Input Parameters: | |||
935 | + snes - the SNES context | |||
936 | . its - iteration number | |||
937 | . fgnorm - 2-norm of residual | |||
938 | - vf - PetscViewerAndFormat of type ASCII | |||
939 | ||||
940 | Notes: | |||
941 | This routine prints the residual norm at each iteration. | |||
942 | ||||
943 | Level: intermediate | |||
944 | ||||
945 | .keywords: SNES, nonlinear, default, monitor, norm | |||
946 | .seealso: SNESMonitorSet(), SNESMonitorDefault() | |||
947 | @*/ | |||
948 | PetscErrorCode SNESMonitorFields(SNES snes, PetscInt its, PetscReal fgnorm, PetscViewerAndFormat *vf) | |||
949 | { | |||
950 | PetscViewer viewer = vf->viewer; | |||
951 | Vec res; | |||
952 | DM dm; | |||
953 | PetscSection s; | |||
954 | const PetscScalar *r; | |||
955 | PetscReal *lnorms, *norms; | |||
956 | PetscInt numFields, f, pStart, pEnd, p; | |||
957 | PetscErrorCode ierr; | |||
958 | ||||
959 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 959; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
960 | PetscValidHeaderSpecific(viewer,PETSC_VIEWER_CLASSID,4)do { if (!viewer) return PetscError(((MPI_Comm)0x44000001),960 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",4); if ( !PetscCheckPointer(viewer,PETSC_OBJECT)) return PetscError((( MPI_Comm)0x44000001),960,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,4); if (((PetscObject)(viewer))->classid != PETSC_VIEWER_CLASSID ) { if (((PetscObject)(viewer))->classid == -1) return PetscError (((MPI_Comm)0x44000001),960,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,4); else return PetscError(((MPI_Comm)0x44000001),960,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,4); } } while (0); | |||
961 | ierr = SNESGetFunction(snes, &res, 0, 0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),961,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
962 | ierr = SNESGetDM(snes, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),962,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
963 | ierr = DMGetSection(dm, &s);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),963,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
964 | ierr = PetscSectionGetNumFields(s, &numFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),964,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
965 | ierr = PetscSectionGetChart(s, &pStart, &pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),965,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
966 | ierr = PetscCalloc2(numFields, &lnorms, numFields, &norms)PetscMallocA(2,PETSC_TRUE,966,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numFields)*sizeof(**(&lnorms)),(&lnorms),(size_t )(numFields)*sizeof(**(&norms)),(&norms));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),966,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
967 | ierr = VecGetArrayRead(res, &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),967,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
968 | for (p = pStart; p < pEnd; ++p) { | |||
969 | for (f = 0; f < numFields; ++f) { | |||
970 | PetscInt fdof, foff, d; | |||
971 | ||||
972 | ierr = PetscSectionGetFieldDof(s, p, f, &fdof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),972,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
973 | ierr = PetscSectionGetFieldOffset(s, p, f, &foff);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),973,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
974 | for (d = 0; d < fdof; ++d) lnorms[f] += PetscRealPart(PetscSqr(r[foff+d]))(((r[foff+d])*(r[foff+d]))); | |||
975 | } | |||
976 | } | |||
977 | ierr = VecRestoreArrayRead(res, &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),977,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
978 | ierr = MPIU_Allreduce(lnorms, norms, numFields, MPIU_REAL, MPIU_SUM, PetscObjectComm((PetscObject) dm))(PetscAllreduceBarrierCheck(PetscObjectComm((PetscObject) dm) ,numFields,978,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((petsc_allreduce_ct += PetscMPIParallelComm((PetscObjectComm ((PetscObject) dm))),0) || MPI_Allreduce((lnorms),(norms),(numFields ),(((MPI_Datatype)0x4c00080b)),((MPI_Op)(0x58000003)),(PetscObjectComm ((PetscObject) dm)))));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),978,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
979 | ierr = PetscViewerPushFormat(viewer,vf->format);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),979,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
980 | ierr = PetscViewerASCIIAddTab(viewer, ((PetscObject) snes)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),980,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
981 | ierr = PetscViewerASCIIPrintf(viewer, "%3D SNES Function norm %14.12e [", its, (double) fgnorm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),981,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
982 | for (f = 0; f < numFields; ++f) { | |||
983 | if (f > 0) {ierr = PetscViewerASCIIPrintf(viewer, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),983,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
984 | ierr = PetscViewerASCIIPrintf(viewer, "%14.12e", (double) PetscSqrtReal(norms[f])sqrt(norms[f]));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),984,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
985 | } | |||
986 | ierr = PetscViewerASCIIPrintf(viewer, "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),986,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
987 | ierr = PetscViewerASCIISubtractTab(viewer, ((PetscObject) snes)->tablevel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),987,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
988 | ierr = PetscViewerPopFormat(viewer);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),988,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
989 | ierr = PetscFree2(lnorms, norms)PetscFreeA(2,989,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(lnorms),&(norms));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),989,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
990 | 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); | |||
991 | } | |||
992 | ||||
993 | /********************* Residual Computation **************************/ | |||
994 | ||||
995 | ||||
996 | /*@ | |||
997 | DMPlexSNESGetGeometryFVM - Return precomputed geometric data | |||
998 | ||||
999 | Input Parameter: | |||
1000 | . dm - The DM | |||
1001 | ||||
1002 | Output Parameters: | |||
1003 | + facegeom - The values precomputed from face geometry | |||
1004 | . cellgeom - The values precomputed from cell geometry | |||
1005 | - minRadius - The minimum radius over the mesh of an inscribed sphere in a cell | |||
1006 | ||||
1007 | Level: developer | |||
1008 | ||||
1009 | .seealso: DMPlexTSSetRHSFunctionLocal() | |||
1010 | @*/ | |||
1011 | PetscErrorCode DMPlexSNESGetGeometryFVM(DM dm, Vec *facegeom, Vec *cellgeom, PetscReal *minRadius) | |||
1012 | { | |||
1013 | DM plex; | |||
1014 | PetscErrorCode ierr; | |||
1015 | ||||
1016 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1016; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1017 | PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1017,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1017,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.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),1017,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1017,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||
1018 | ierr = DMSNESConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1018,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1019 | ierr = DMPlexGetDataFVM(plex, NULL((void*)0), cellgeom, facegeom, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1019,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1020 | if (minRadius) {ierr = DMPlexGetMinRadius(plex, minRadius);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1020,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1021 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1021,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1022 | PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0); | |||
1023 | } | |||
1024 | ||||
1025 | /*@ | |||
1026 | DMPlexSNESGetGradientDM - Return gradient data layout | |||
1027 | ||||
1028 | Input Parameters: | |||
1029 | + dm - The DM | |||
1030 | - fv - The PetscFV | |||
1031 | ||||
1032 | Output Parameter: | |||
1033 | . dmGrad - The layout for gradient values | |||
1034 | ||||
1035 | Level: developer | |||
1036 | ||||
1037 | .seealso: DMPlexSNESGetGeometryFVM() | |||
1038 | @*/ | |||
1039 | PetscErrorCode DMPlexSNESGetGradientDM(DM dm, PetscFV fv, DM *dmGrad) | |||
1040 | { | |||
1041 | DM plex; | |||
1042 | PetscBool computeGradients; | |||
1043 | PetscErrorCode ierr; | |||
1044 | ||||
1045 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1045; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1046 | PetscValidHeaderSpecific(dm,DM_CLASSID,1)do { if (!dm) return PetscError(((MPI_Comm)0x44000001),1046,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",1); if ( !PetscCheckPointer(dm,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1046,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.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),1046,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,1); else return PetscError(((MPI_Comm)0x44000001),1046,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,1); } } while (0); | |||
1047 | PetscValidHeaderSpecific(fv,PETSCFV_CLASSID,2)do { if (!fv) return PetscError(((MPI_Comm)0x44000001),1047,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 85,PETSC_ERROR_INITIAL,"Null Object: Parameter # %d",2); if ( !PetscCheckPointer(fv,PETSC_OBJECT)) return PetscError(((MPI_Comm )0x44000001),1047,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Invalid Pointer to Object: Parameter # %d" ,2); if (((PetscObject)(fv))->classid != PETSCFV_CLASSID) { if (((PetscObject)(fv))->classid == -1) return PetscError (((MPI_Comm)0x44000001),1047,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,64,PETSC_ERROR_INITIAL,"Object already free: Parameter # %d" ,2); else return PetscError(((MPI_Comm)0x44000001),1047,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Wrong type of object: Parameter # %d" ,2); } } while (0); | |||
1048 | PetscValidPointer(dmGrad,3)do { if (!dmGrad) return PetscError(((MPI_Comm)0x44000001),1048 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,85,PETSC_ERROR_INITIAL,"Null Pointer: Parameter # %d",3); if (!PetscCheckPointer(dmGrad,PETSC_CHAR)) return PetscError((( MPI_Comm)0x44000001),1048,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,68,PETSC_ERROR_INITIAL,"Invalid Pointer: Parameter # %d",3); } while (0); | |||
1049 | ierr = PetscFVGetComputeGradients(fv, &computeGradients);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1049,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1050 | if (!computeGradients) {*dmGrad = NULL((void*)0); PetscFunctionReturn(0)do { do { ; if (petscstack && petscstack->currentsize > 0) { petscstack->currentsize--; petscstack->function [petscstack->currentsize] = 0; petscstack->file[petscstack ->currentsize] = 0; petscstack->line[petscstack->currentsize ] = 0; petscstack->petscroutine[petscstack->currentsize ] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack->hotdepth-1)<(0)) ? (0) : (petscstack-> hotdepth-1)); } ; } while (0); return(0);} while (0);} | |||
1051 | ierr = DMSNESConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1051,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1052 | ierr = DMPlexGetDataFVM(plex, fv, NULL((void*)0), NULL((void*)0), dmGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1052,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1053 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1053,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1054 | 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); | |||
1055 | } | |||
1056 | ||||
1057 | static PetscErrorCode DMPlexComputeBdResidual_Single_Internal(DM dm, PetscReal t, DMLabel label, PetscInt numValues, const PetscInt values[], PetscInt field, Vec locX, Vec locX_t, Vec locF, DMField coordField, IS facetIS) | |||
1058 | { | |||
1059 | DM_Plex *mesh = (DM_Plex *) dm->data; | |||
1060 | DM plex = NULL((void*)0), plexA = NULL((void*)0); | |||
1061 | PetscDS prob, probAux = NULL((void*)0); | |||
1062 | PetscSection section, sectionAux = NULL((void*)0); | |||
1063 | Vec locA = NULL((void*)0); | |||
1064 | PetscScalar *u = NULL((void*)0), *u_t = NULL((void*)0), *a = NULL((void*)0), *elemVec = NULL((void*)0); | |||
1065 | PetscInt v; | |||
1066 | PetscInt totDim, totDimAux = 0; | |||
1067 | PetscErrorCode ierr; | |||
1068 | ||||
1069 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1069; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1070 | ierr = DMConvert(dm, DMPLEX"plex", &plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1070,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1071 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1071,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1072 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1072,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1073 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1073,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1074 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &locA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1074,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1075 | if (locA) { | |||
1076 | DM dmAux; | |||
1077 | ||||
1078 | ierr = VecGetDM(locA, &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1078,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1079 | ierr = DMConvert(dmAux, DMPLEX"plex", &plexA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1079,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1080 | ierr = DMGetDS(plexA, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1080,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1081 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1081,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1082 | ierr = DMGetSection(plexA, §ionAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1082,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1083 | } | |||
1084 | for (v = 0; v < numValues; ++v) { | |||
1085 | PetscFEGeom *fgeom; | |||
1086 | PetscInt maxDegree; | |||
1087 | PetscQuadrature qGeom = NULL((void*)0); | |||
1088 | IS pointIS; | |||
1089 | const PetscInt *points; | |||
1090 | PetscInt numFaces, face, Nq; | |||
1091 | ||||
1092 | ierr = DMLabelGetStratumIS(label, values[v], &pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1092,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1093 | if (!pointIS) continue; /* No points with that id on this process */ | |||
1094 | { | |||
1095 | IS isectIS; | |||
1096 | ||||
1097 | /* TODO: Special cases of ISIntersect where it is quick to check a priori if one is a superset of the other */ | |||
1098 | ierr = ISIntersect_Caching_Internal(facetIS,pointIS,&isectIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1098,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1099 | ierr = ISDestroy(&pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1099,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1100 | pointIS = isectIS; | |||
1101 | } | |||
1102 | ierr = ISGetLocalSize(pointIS,&numFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1102,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1103 | ierr = ISGetIndices(pointIS,&points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1103,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1104 | ierr = PetscMalloc4(numFaces*totDim, &u, locX_t ? numFaces*totDim : 0, &u_t, numFaces*totDim, &elemVec, locA ? numFaces*totDimAux : 0, &a)PetscMallocA(4,PETSC_FALSE,1104,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numFaces*totDim)*sizeof(**(&u)),(&u),(size_t )(locX_t ? numFaces*totDim : 0)*sizeof(**(&u_t)),(&u_t ),(size_t)(numFaces*totDim)*sizeof(**(&elemVec)),(&elemVec ),(size_t)(locA ? numFaces*totDimAux : 0)*sizeof(**(&a)), (&a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1104,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1105 | ierr = DMFieldGetDegree(coordField,pointIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1105,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1106 | if (maxDegree <= 1) { | |||
1107 | ierr = DMFieldCreateDefaultQuadrature(coordField,pointIS,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1107,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1108 | } | |||
1109 | if (!qGeom) { | |||
1110 | PetscFE fe; | |||
1111 | ||||
1112 | ierr = PetscDSGetDiscretization(prob, field, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1112,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1113 | ierr = PetscFEGetFaceQuadrature(fe, &qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1113,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1114 | ierr = PetscObjectReference((PetscObject)qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1114,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1115 | } | |||
1116 | ierr = PetscQuadratureGetData(qGeom, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1116,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1117 | ierr = DMSNESGetFEGeom(coordField,pointIS,qGeom,PETSC_TRUE,&fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1117,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1118 | for (face = 0; face < numFaces; ++face) { | |||
1119 | const PetscInt point = points[face], *support, *cone; | |||
1120 | PetscScalar *x = NULL((void*)0); | |||
1121 | PetscInt i, coneSize, faceLoc; | |||
1122 | ||||
1123 | ierr = DMPlexGetSupport(dm, point, &support);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1123,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1124 | ierr = DMPlexGetConeSize(dm, support[0], &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1124,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1125 | ierr = DMPlexGetCone(dm, support[0], &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1125,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1126 | for (faceLoc = 0; faceLoc < coneSize; ++faceLoc) if (cone[faceLoc] == point) break; | |||
1127 | if (faceLoc == coneSize) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Could not find face %D in cone of support[0] %D", point, support[0])return PetscError(((MPI_Comm)0x44000001),1127,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,77,PETSC_ERROR_INITIAL,"Could not find face %D in cone of support[0] %D" ,point,support[0]); | |||
1128 | fgeom->face[face][0] = faceLoc; | |||
1129 | ierr = DMPlexVecGetClosure(plex, section, locX, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1129,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1130 | for (i = 0; i < totDim; ++i) u[face*totDim+i] = x[i]; | |||
1131 | ierr = DMPlexVecRestoreClosure(plex, section, locX, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1131,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1132 | if (locX_t) { | |||
1133 | ierr = DMPlexVecGetClosure(plex, section, locX_t, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1133,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1134 | for (i = 0; i < totDim; ++i) u_t[face*totDim+i] = x[i]; | |||
1135 | ierr = DMPlexVecRestoreClosure(plex, section, locX_t, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1135,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1136 | } | |||
1137 | if (locA) { | |||
1138 | PetscInt subp; | |||
1139 | ||||
1140 | ierr = DMPlexGetAuxiliaryPoint(plex, plexA, support[0], &subp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1140,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1141 | ierr = DMPlexVecGetClosure(plexA, sectionAux, locA, subp, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1141,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1142 | for (i = 0; i < totDimAux; ++i) a[face*totDimAux+i] = x[i]; | |||
1143 | ierr = DMPlexVecRestoreClosure(plexA, sectionAux, locA, subp, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1143,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1144 | } | |||
1145 | } | |||
1146 | ierr = PetscMemzero(elemVec, numFaces*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1146,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1147 | { | |||
1148 | PetscFE fe; | |||
1149 | PetscInt Nb; | |||
1150 | PetscFEGeom *chunkGeom = NULL((void*)0); | |||
1151 | /* Conforming batches */ | |||
1152 | PetscInt numChunks, numBatches, numBlocks, Ne, blockSize, batchSize; | |||
1153 | /* Remainder */ | |||
1154 | PetscInt Nr, offset; | |||
1155 | ||||
1156 | ierr = PetscDSGetDiscretization(prob, field, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1156,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1157 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1157,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1158 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1158,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1159 | /* TODO: documentation is unclear about what is going on with these numbers: how should Nb / Nq factor in ? */ | |||
1160 | blockSize = Nb; | |||
1161 | batchSize = numBlocks * blockSize; | |||
1162 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1162,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1163 | numChunks = numFaces / (numBatches*batchSize); | |||
1164 | Ne = numChunks*numBatches*batchSize; | |||
1165 | Nr = numFaces % (numBatches*batchSize); | |||
1166 | offset = numFaces - Nr; | |||
1167 | ierr = PetscFEGeomGetChunk(fgeom,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1167,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1168 | ierr = PetscFEIntegrateBdResidual(fe, prob, field, Ne, chunkGeom, u, u_t, probAux, a, t, elemVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1168,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1169 | ierr = PetscFEGeomRestoreChunk(fgeom, 0, offset, &chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1169,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1170 | ierr = PetscFEGeomGetChunk(fgeom,offset,numFaces,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1170,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1171 | ierr = PetscFEIntegrateBdResidual(fe, prob, field, Nr, chunkGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, a ? &a[offset*totDimAux] : NULL((void*)0), t, &elemVec[offset*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1171,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1172 | ierr = PetscFEGeomRestoreChunk(fgeom,offset,numFaces,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1172,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1173 | } | |||
1174 | for (face = 0; face < numFaces; ++face) { | |||
1175 | const PetscInt point = points[face], *support; | |||
1176 | ||||
1177 | if (mesh->printFEM > 1) {ierr = DMPrintCellVector(point, "BdResidual", totDim, &elemVec[face*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1177,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1178 | ierr = DMPlexGetSupport(plex, point, &support);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1178,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1179 | ierr = DMPlexVecSetClosure(plex, NULL((void*)0), locF, support[0], &elemVec[face*totDim], ADD_ALL_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1179,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1180 | } | |||
1181 | ierr = DMSNESRestoreFEGeom(coordField,pointIS,qGeom,PETSC_TRUE,&fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1181,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1182 | ierr = PetscQuadratureDestroy(&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1182,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1183 | ierr = ISRestoreIndices(pointIS, &points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1183,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1184 | ierr = ISDestroy(&pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1184,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1185 | ierr = PetscFree4(u, u_t, elemVec, a)PetscFreeA(4,1185,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(u),&(u_t),&(elemVec),&(a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1185,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1186 | } | |||
1187 | if (plex) {ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1187,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1188 | if (plexA) {ierr = DMDestroy(&plexA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1188,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1189 | 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); | |||
1190 | } | |||
1191 | ||||
1192 | PetscErrorCode DMPlexComputeBdResidualSingle(DM dm, PetscReal t, DMLabel label, PetscInt numValues, const PetscInt values[], PetscInt field, Vec locX, Vec locX_t, Vec locF) | |||
1193 | { | |||
1194 | DMField coordField; | |||
1195 | DMLabel depthLabel; | |||
1196 | IS facetIS; | |||
1197 | PetscInt dim; | |||
1198 | PetscErrorCode ierr; | |||
1199 | ||||
1200 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1200; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1201 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1201,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1202 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1202,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1203 | ierr = DMLabelGetStratumIS(depthLabel, dim-1, &facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1203,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1204 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1204,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1205 | ierr = DMPlexComputeBdResidual_Single_Internal(dm, t, label, numValues, values, field, locX, locX_t, locF, coordField, facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1205,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1206 | 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); | |||
1207 | } | |||
1208 | ||||
1209 | PetscErrorCode DMPlexComputeBdResidual_Internal(DM dm, Vec locX, Vec locX_t, PetscReal t, Vec locF, void *user) | |||
1210 | { | |||
1211 | PetscDS prob; | |||
1212 | PetscInt numBd, bd; | |||
1213 | DMField coordField = NULL((void*)0); | |||
1214 | IS facetIS = NULL((void*)0); | |||
1215 | DMLabel depthLabel; | |||
1216 | PetscInt dim; | |||
1217 | PetscErrorCode ierr; | |||
1218 | ||||
1219 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1219; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1220 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1220,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1221 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1221,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1222 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1222,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1223 | ierr = DMLabelGetStratumIS(depthLabel,dim - 1,&facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1223,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1224 | ierr = PetscDSGetNumBoundary(prob, &numBd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1224,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1225 | for (bd = 0; bd < numBd; ++bd) { | |||
1226 | DMBoundaryConditionType type; | |||
1227 | const char *bdLabel; | |||
1228 | DMLabel label; | |||
1229 | const PetscInt *values; | |||
1230 | PetscInt field, numValues; | |||
1231 | PetscObject obj; | |||
1232 | PetscClassId id; | |||
1233 | ||||
1234 | ierr = PetscDSGetBoundary(prob, bd, &type, NULL((void*)0), &bdLabel, &field, NULL((void*)0), NULL((void*)0), NULL((void*)0), &numValues, &values, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1234,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1235 | ierr = PetscDSGetDiscretization(prob, field, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1235,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1236 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1236,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1237 | if ((id != PETSCFE_CLASSID) || (type & DM_BC_ESSENTIAL)) continue; | |||
1238 | if (!facetIS) { | |||
1239 | DMLabel depthLabel; | |||
1240 | PetscInt dim; | |||
1241 | ||||
1242 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1242,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1243 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1243,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1244 | ierr = DMLabelGetStratumIS(depthLabel, dim - 1, &facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1244,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1245 | } | |||
1246 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1246,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1247 | ierr = DMGetLabel(dm, bdLabel, &label);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1247,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1248 | ierr = DMPlexComputeBdResidual_Single_Internal(dm, t, label, numValues, values, field, locX, locX_t, locF, coordField, facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1248,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1249 | } | |||
1250 | ierr = ISDestroy(&facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1250,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1251 | 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); | |||
1252 | } | |||
1253 | ||||
1254 | PetscErrorCode DMPlexComputeResidual_Internal(DM dm, IS cellIS, PetscReal time, Vec locX, Vec locX_t, PetscReal t, Vec locF, void *user) | |||
1255 | { | |||
1256 | DM_Plex *mesh = (DM_Plex *) dm->data; | |||
1257 | const char *name = "Residual"; | |||
1258 | DM dmAux = NULL((void*)0); | |||
1259 | DM dmGrad = NULL((void*)0); | |||
1260 | DMLabel ghostLabel = NULL((void*)0); | |||
1261 | PetscDS prob = NULL((void*)0); | |||
1262 | PetscDS probAux = NULL((void*)0); | |||
1263 | PetscSection section = NULL((void*)0); | |||
1264 | PetscBool useFEM = PETSC_FALSE; | |||
1265 | PetscBool useFVM = PETSC_FALSE; | |||
1266 | PetscBool isImplicit = (locX_t || time == PETSC_MIN_REAL(-1.7976931348623157e+308)) ? PETSC_TRUE : PETSC_FALSE; | |||
| ||||
1267 | PetscFV fvm = NULL((void*)0); | |||
1268 | PetscFVCellGeom *cgeomFVM = NULL((void*)0); | |||
1269 | PetscFVFaceGeom *fgeomFVM = NULL((void*)0); | |||
1270 | DMField coordField = NULL((void*)0); | |||
1271 | Vec locA, cellGeometryFVM = NULL((void*)0), faceGeometryFVM = NULL((void*)0), grad, locGrad = NULL((void*)0); | |||
1272 | PetscScalar *u = NULL((void*)0), *u_t, *a, *uL, *uR; | |||
1273 | IS chunkIS; | |||
1274 | const PetscInt *cells; | |||
1275 | PetscInt cStart, cEnd, numCells; | |||
1276 | PetscInt Nf, f, totDim, totDimAux, numChunks, cellChunkSize, faceChunkSize, chunk, fStart, fEnd; | |||
1277 | PetscInt maxDegree = PETSC_MAX_INT2147483647; | |||
1278 | PetscQuadrature affineQuad = NULL((void*)0), *quads = NULL((void*)0); | |||
1279 | PetscFEGeom *affineGeom = NULL((void*)0), **geoms = NULL((void*)0); | |||
1280 | PetscErrorCode ierr; | |||
1281 | ||||
1282 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1282; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1283 | ierr = PetscLogEventBegin(DMPLEX_ResidualFEM,dm,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_ResidualFEM].active) ? (*PetscLogPLB)((DMPLEX_ResidualFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1283,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1284 | /* TODO The places where we have to use isFE are probably the member functions for the PetscDisc class */ | |||
1285 | /* TODO The FVM geometry is over-manipulated. Make the precalc functions return exactly what we need */ | |||
1286 | /* FEM+FVM */ | |||
1287 | ierr = ISGetPointRange(cellIS, &cStart, &cEnd, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1287,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1288 | ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1288,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1289 | /* 1: Get sizes from dm and dmAux */ | |||
1290 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1290,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1291 | ierr = DMGetLabel(dm, "ghost", &ghostLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1291,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1292 | ierr = DMGetCellDS(dm, cStart, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1292,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1293 | ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1293,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1294 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1294,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1295 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &locA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1295,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1296 | if (locA) { | |||
1297 | PetscInt subcell; | |||
1298 | ierr = DMPlexGetAuxiliaryPoint(dm, dmAux, cStart, &subcell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1298,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1299 | ierr = VecGetDM(locA, &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1299,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1300 | ierr = DMGetCellDS(dmAux, subcell, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1300,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1301 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1301,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1302 | } | |||
1303 | /* 2: Get geometric data */ | |||
1304 | for (f = 0; f < Nf; ++f) { | |||
1305 | PetscObject obj; | |||
1306 | PetscClassId id; | |||
1307 | PetscBool fimp; | |||
1308 | ||||
1309 | ierr = PetscDSGetImplicit(prob, f, &fimp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1309,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1310 | if (isImplicit != fimp) continue; | |||
1311 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1311,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1312 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1312,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1313 | if (id == PETSCFE_CLASSID) {useFEM = PETSC_TRUE;} | |||
1314 | if (id == PETSCFV_CLASSID) {useFVM = PETSC_TRUE; fvm = (PetscFV) obj;} | |||
1315 | } | |||
1316 | if (useFEM) { | |||
1317 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1317,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1318 | ierr = DMFieldGetDegree(coordField,cellIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1318,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1319 | if (maxDegree <= 1) { | |||
1320 | ierr = DMFieldCreateDefaultQuadrature(coordField,cellIS,&affineQuad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1320,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1321 | if (affineQuad) { | |||
1322 | ierr = DMSNESGetFEGeom(coordField,cellIS,affineQuad,PETSC_FALSE,&affineGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1322,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1323 | } | |||
1324 | } else { | |||
1325 | ierr = PetscCalloc2(Nf,&quads,Nf,&geoms)PetscMallocA(2,PETSC_TRUE,1325,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(Nf)*sizeof(**(&quads)),(&quads),(size_t)(Nf )*sizeof(**(&geoms)),(&geoms));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1325,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1326 | for (f = 0; f < Nf; ++f) { | |||
1327 | PetscObject obj; | |||
1328 | PetscClassId id; | |||
1329 | PetscBool fimp; | |||
1330 | ||||
1331 | ierr = PetscDSGetImplicit(prob, f, &fimp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1331,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1332 | if (isImplicit != fimp) continue; | |||
1333 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1333,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1334 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1334,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1335 | if (id == PETSCFE_CLASSID) { | |||
1336 | PetscFE fe = (PetscFE) obj; | |||
1337 | ||||
1338 | ierr = PetscFEGetQuadrature(fe, &quads[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1338,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1339 | ierr = PetscObjectReference((PetscObject)quads[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1339,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1340 | ierr = DMSNESGetFEGeom(coordField,cellIS,quads[f],PETSC_FALSE,&geoms[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1340,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1341 | } | |||
1342 | } | |||
1343 | } | |||
1344 | } | |||
1345 | if (useFVM) { | |||
1346 | ierr = DMPlexSNESGetGeometryFVM(dm, &faceGeometryFVM, &cellGeometryFVM, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1346,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1347 | ierr = VecGetArrayRead(faceGeometryFVM, (const PetscScalar **) &fgeomFVM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1347,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1348 | ierr = VecGetArrayRead(cellGeometryFVM, (const PetscScalar **) &cgeomFVM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1348,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1349 | /* Reconstruct and limit cell gradients */ | |||
1350 | ierr = DMPlexSNESGetGradientDM(dm, fvm, &dmGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1350,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1351 | if (dmGrad) { | |||
1352 | ierr = DMPlexGetHeightStratum(dm, 1, &fStart, &fEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1352,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1353 | ierr = DMGetGlobalVector(dmGrad, &grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1353,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1354 | ierr = DMPlexReconstructGradients_Internal(dm, fvm, fStart, fEnd, faceGeometryFVM, cellGeometryFVM, locX, grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1354,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1355 | /* Communicate gradient values */ | |||
1356 | ierr = DMGetLocalVector(dmGrad, &locGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1356,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1357 | ierr = DMGlobalToLocalBegin(dmGrad, grad, INSERT_VALUES, locGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1357,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1358 | ierr = DMGlobalToLocalEnd(dmGrad, grad, INSERT_VALUES, locGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1358,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1359 | ierr = DMRestoreGlobalVector(dmGrad, &grad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1359,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1360 | } | |||
1361 | /* Handle non-essential (e.g. outflow) boundary values */ | |||
1362 | ierr = DMPlexInsertBoundaryValues(dm, PETSC_FALSE, locX, time, faceGeometryFVM, cellGeometryFVM, locGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1362,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1363 | } | |||
1364 | /* Loop over chunks */ | |||
1365 | if (useFEM) {ierr = ISCreate(PETSC_COMM_SELF((MPI_Comm)0x44000001), &chunkIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1365,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1366 | numCells = cEnd - cStart; | |||
1367 | numChunks = 1; | |||
1368 | cellChunkSize = numCells/numChunks; | |||
1369 | faceChunkSize = (fEnd - fStart)/numChunks; | |||
1370 | numChunks = PetscMin(1,numCells)(((1)<(numCells)) ? (1) : (numCells)); | |||
1371 | for (chunk = 0; chunk < numChunks; ++chunk) { | |||
1372 | PetscScalar *elemVec, *fluxL, *fluxR; | |||
1373 | PetscReal *vol; | |||
1374 | PetscFVFaceGeom *fgeom; | |||
1375 | PetscInt cS = cStart+chunk*cellChunkSize, cE = PetscMin(cS+cellChunkSize, cEnd)(((cS+cellChunkSize)<(cEnd)) ? (cS+cellChunkSize) : (cEnd) ), numCells = cE - cS, c; | |||
1376 | PetscInt fS = fStart+chunk*faceChunkSize, fE = PetscMin(fS+faceChunkSize, fEnd)(((fS+faceChunkSize)<(fEnd)) ? (fS+faceChunkSize) : (fEnd) ), numFaces = 0, face; | |||
1377 | ||||
1378 | /* Extract field coefficients */ | |||
1379 | if (useFEM) { | |||
1380 | ierr = ISGetPointSubrange(chunkIS, cS, cE, cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1380,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1381 | ierr = DMPlexGetCellFields(dm, chunkIS, locX, locX_t, locA, &u, &u_t, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1381,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1382 | ierr = DMGetWorkArray(dm, numCells*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &elemVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1382,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1383 | ierr = PetscMemzero(elemVec, numCells*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1383,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1384 | } | |||
1385 | if (useFVM) { | |||
1386 | ierr = DMPlexGetFaceFields(dm, fS, fE, locX, locX_t, faceGeometryFVM, cellGeometryFVM, locGrad, &numFaces, &uL, &uR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1386,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1387 | ierr = DMPlexGetFaceGeometry(dm, fS, fE, faceGeometryFVM, cellGeometryFVM, &numFaces, &fgeom, &vol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1387,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1388 | ierr = DMGetWorkArray(dm, numFaces*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &fluxL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1388,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1389 | ierr = DMGetWorkArray(dm, numFaces*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &fluxR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1389,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1390 | ierr = PetscMemzero(fluxL, numFaces*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1390,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1391 | ierr = PetscMemzero(fluxR, numFaces*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1391,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1392 | } | |||
1393 | /* TODO We will interlace both our field coefficients (u, u_t, uL, uR, etc.) and our output (elemVec, fL, fR). I think this works */ | |||
1394 | /* Loop over fields */ | |||
1395 | for (f = 0; f < Nf; ++f) { | |||
1396 | PetscObject obj; | |||
1397 | PetscClassId id; | |||
1398 | PetscBool fimp; | |||
1399 | PetscInt numChunks, numBatches, batchSize, numBlocks, blockSize, Ne, Nr, offset; | |||
1400 | ||||
1401 | ierr = PetscDSGetImplicit(prob, f, &fimp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1401,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1402 | if (isImplicit != fimp) continue; | |||
1403 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1403,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1404 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1404,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1405 | if (id == PETSCFE_CLASSID) { | |||
1406 | PetscFE fe = (PetscFE) obj; | |||
1407 | PetscFEGeom *geom = affineGeom ? affineGeom : geoms[f]; | |||
| ||||
1408 | PetscFEGeom *chunkGeom = NULL((void*)0); | |||
1409 | PetscQuadrature quad = affineQuad ? affineQuad : quads[f]; | |||
1410 | PetscInt Nq, Nb; | |||
1411 | ||||
1412 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1412,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1413 | ierr = PetscQuadratureGetData(quad, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1413,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1414 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1414,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1415 | blockSize = Nb; | |||
1416 | batchSize = numBlocks * blockSize; | |||
1417 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1417,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1418 | numChunks = numCells / (numBatches*batchSize); | |||
1419 | Ne = numChunks*numBatches*batchSize; | |||
1420 | Nr = numCells % (numBatches*batchSize); | |||
1421 | offset = numCells - Nr; | |||
1422 | /* Integrate FE residual to get elemVec (need fields at quadrature points) */ | |||
1423 | /* For FV, I think we use a P0 basis and the cell coefficients (for subdivided cells, we can tweak the basis tabulation to be the indicator function) */ | |||
1424 | ierr = PetscFEGeomGetChunk(geom,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1424,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1425 | ierr = PetscFEIntegrateResidual(fe, prob, f, Ne, chunkGeom, u, u_t, probAux, a, t, elemVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1425,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1426 | ierr = PetscFEGeomGetChunk(geom,offset,numCells,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1426,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1427 | ierr = PetscFEIntegrateResidual(fe, prob, f, Nr, chunkGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, &elemVec[offset*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1427,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1428 | ierr = PetscFEGeomRestoreChunk(geom,offset,numCells,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1428,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1429 | } else if (id == PETSCFV_CLASSID) { | |||
1430 | PetscFV fv = (PetscFV) obj; | |||
1431 | ||||
1432 | Ne = numFaces; | |||
1433 | /* Riemann solve over faces (need fields at face centroids) */ | |||
1434 | /* We need to evaluate FE fields at those coordinates */ | |||
1435 | ierr = PetscFVIntegrateRHSFunction(fv, prob, f, Ne, fgeom, vol, uL, uR, fluxL, fluxR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1435,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1436 | } else SETERRQ1(PetscObjectComm((PetscObject) dm), PETSC_ERR_ARG_WRONG, "Unknown discretization type for field %d", f)return PetscError(PetscObjectComm((PetscObject) dm),1436,__func__ ,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c", 62,PETSC_ERROR_INITIAL,"Unknown discretization type for field %d" ,f); | |||
1437 | } | |||
1438 | /* Loop over domain */ | |||
1439 | if (useFEM) { | |||
1440 | /* Add elemVec to locX */ | |||
1441 | for (c = cS; c < cE; ++c) { | |||
1442 | const PetscInt cell = cells ? cells[c] : c; | |||
1443 | const PetscInt cind = c - cStart; | |||
1444 | ||||
1445 | if (mesh->printFEM > 1) {ierr = DMPrintCellVector(cell, name, totDim, &elemVec[cind*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1445,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1446 | if (ghostLabel) { | |||
1447 | PetscInt ghostVal; | |||
1448 | ||||
1449 | ierr = DMLabelGetValue(ghostLabel,cell,&ghostVal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1449,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1450 | if (ghostVal > 0) continue; | |||
1451 | } | |||
1452 | ierr = DMPlexVecSetClosure(dm, section, locF, cell, &elemVec[cind*totDim], ADD_ALL_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1452,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1453 | } | |||
1454 | } | |||
1455 | if (useFVM) { | |||
1456 | PetscScalar *fa; | |||
1457 | PetscInt iface; | |||
1458 | ||||
1459 | ierr = VecGetArray(locF, &fa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1459,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1460 | for (f = 0; f < Nf; ++f) { | |||
1461 | PetscFV fv; | |||
1462 | PetscObject obj; | |||
1463 | PetscClassId id; | |||
1464 | PetscInt foff, pdim; | |||
1465 | ||||
1466 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1466,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1467 | ierr = PetscDSGetFieldOffset(prob, f, &foff);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1467,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1468 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1468,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1469 | if (id != PETSCFV_CLASSID) continue; | |||
1470 | fv = (PetscFV) obj; | |||
1471 | ierr = PetscFVGetNumComponents(fv, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1471,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1472 | /* Accumulate fluxes to cells */ | |||
1473 | for (face = fS, iface = 0; face < fE; ++face) { | |||
1474 | const PetscInt *scells; | |||
1475 | PetscScalar *fL = NULL((void*)0), *fR = NULL((void*)0); | |||
1476 | PetscInt ghost, d, nsupp, nchild; | |||
1477 | ||||
1478 | ierr = DMLabelGetValue(ghostLabel, face, &ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1478,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1479 | ierr = DMPlexGetSupportSize(dm, face, &nsupp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1479,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1480 | ierr = DMPlexGetTreeChildren(dm, face, &nchild, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1480,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1481 | if (ghost >= 0 || nsupp > 2 || nchild > 0) continue; | |||
1482 | ierr = DMPlexGetSupport(dm, face, &scells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1482,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1483 | ierr = DMLabelGetValue(ghostLabel,scells[0],&ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1483,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1484 | if (ghost <= 0) {ierr = DMPlexPointLocalFieldRef(dm, scells[0], f, fa, &fL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1484,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1485 | ierr = DMLabelGetValue(ghostLabel,scells[1],&ghost);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1485,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1486 | if (ghost <= 0) {ierr = DMPlexPointLocalFieldRef(dm, scells[1], f, fa, &fR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1486,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1487 | for (d = 0; d < pdim; ++d) { | |||
1488 | if (fL) fL[d] -= fluxL[iface*totDim+foff+d]; | |||
1489 | if (fR) fR[d] += fluxR[iface*totDim+foff+d]; | |||
1490 | } | |||
1491 | ++iface; | |||
1492 | } | |||
1493 | } | |||
1494 | ierr = VecRestoreArray(locF, &fa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1494,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1495 | } | |||
1496 | /* Handle time derivative */ | |||
1497 | if (locX_t) { | |||
1498 | PetscScalar *x_t, *fa; | |||
1499 | ||||
1500 | ierr = VecGetArray(locF, &fa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1500,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1501 | ierr = VecGetArray(locX_t, &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1501,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1502 | for (f = 0; f < Nf; ++f) { | |||
1503 | PetscFV fv; | |||
1504 | PetscObject obj; | |||
1505 | PetscClassId id; | |||
1506 | PetscInt pdim, d; | |||
1507 | ||||
1508 | ierr = PetscDSGetDiscretization(prob, f, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1508,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1509 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1509,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1510 | if (id != PETSCFV_CLASSID) continue; | |||
1511 | fv = (PetscFV) obj; | |||
1512 | ierr = PetscFVGetNumComponents(fv, &pdim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1512,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1513 | for (c = cS; c < cE; ++c) { | |||
1514 | const PetscInt cell = cells ? cells[c] : c; | |||
1515 | PetscScalar *u_t, *r; | |||
1516 | ||||
1517 | if (ghostLabel) { | |||
1518 | PetscInt ghostVal; | |||
1519 | ||||
1520 | ierr = DMLabelGetValue(ghostLabel, cell, &ghostVal);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1520,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1521 | if (ghostVal > 0) continue; | |||
1522 | } | |||
1523 | ierr = DMPlexPointLocalFieldRead(dm, cell, f, x_t, &u_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1523,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1524 | ierr = DMPlexPointLocalFieldRef(dm, cell, f, fa, &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1524,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1525 | for (d = 0; d < pdim; ++d) r[d] += u_t[d]; | |||
1526 | } | |||
1527 | } | |||
1528 | ierr = VecRestoreArray(locX_t, &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1528,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1529 | ierr = VecRestoreArray(locF, &fa);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1529,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1530 | } | |||
1531 | if (useFEM) { | |||
1532 | ierr = DMPlexRestoreCellFields(dm, chunkIS, locX, locX_t, locA, &u, &u_t, &a);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1532,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1533 | ierr = DMRestoreWorkArray(dm, numCells*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &elemVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1533,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1534 | } | |||
1535 | if (useFVM) { | |||
1536 | ierr = DMPlexRestoreFaceFields(dm, fS, fE, locX, locX_t, faceGeometryFVM, cellGeometryFVM, locGrad, &numFaces, &uL, &uR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1536,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1537 | ierr = DMPlexRestoreFaceGeometry(dm, fS, fE, faceGeometryFVM, cellGeometryFVM, &numFaces, &fgeom, &vol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1537,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1538 | ierr = DMRestoreWorkArray(dm, numFaces*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &fluxL);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1538,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1539 | ierr = DMRestoreWorkArray(dm, numFaces*totDim, MPIU_SCALAR((MPI_Datatype)0x4c00080b), &fluxR);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1539,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1540 | if (dmGrad) {ierr = DMRestoreLocalVector(dmGrad, &locGrad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1540,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1541 | } | |||
1542 | } | |||
1543 | if (useFEM) {ierr = ISDestroy(&chunkIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1543,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1544 | ierr = ISRestorePointRange(cellIS, &cStart, &cEnd, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1544,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1545 | ||||
1546 | if (useFEM) { | |||
1547 | ierr = DMPlexComputeBdResidual_Internal(dm, locX, locX_t, t, locF, user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1547,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1548 | ||||
1549 | if (maxDegree <= 1) { | |||
1550 | ierr = DMSNESRestoreFEGeom(coordField,cellIS,affineQuad,PETSC_FALSE,&affineGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1550,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1551 | ierr = PetscQuadratureDestroy(&affineQuad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1551,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1552 | } else { | |||
1553 | for (f = 0; f < Nf; ++f) { | |||
1554 | ierr = DMSNESRestoreFEGeom(coordField,cellIS,quads[f],PETSC_FALSE,&geoms[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1554,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1555 | ierr = PetscQuadratureDestroy(&quads[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1555,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1556 | } | |||
1557 | ierr = PetscFree2(quads,geoms)PetscFreeA(2,1557,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(quads),&(geoms));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1557,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1558 | } | |||
1559 | } | |||
1560 | ||||
1561 | /* FEM */ | |||
1562 | /* 1: Get sizes from dm and dmAux */ | |||
1563 | /* 2: Get geometric data */ | |||
1564 | /* 3: Handle boundary values */ | |||
1565 | /* 4: Loop over domain */ | |||
1566 | /* Extract coefficients */ | |||
1567 | /* Loop over fields */ | |||
1568 | /* Set tiling for FE*/ | |||
1569 | /* Integrate FE residual to get elemVec */ | |||
1570 | /* Loop over subdomain */ | |||
1571 | /* Loop over quad points */ | |||
1572 | /* Transform coords to real space */ | |||
1573 | /* Evaluate field and aux fields at point */ | |||
1574 | /* Evaluate residual at point */ | |||
1575 | /* Transform residual to real space */ | |||
1576 | /* Add residual to elemVec */ | |||
1577 | /* Loop over domain */ | |||
1578 | /* Add elemVec to locX */ | |||
1579 | ||||
1580 | /* FVM */ | |||
1581 | /* Get geometric data */ | |||
1582 | /* If using gradients */ | |||
1583 | /* Compute gradient data */ | |||
1584 | /* Loop over domain faces */ | |||
1585 | /* Count computational faces */ | |||
1586 | /* Reconstruct cell gradient */ | |||
1587 | /* Loop over domain cells */ | |||
1588 | /* Limit cell gradients */ | |||
1589 | /* Handle boundary values */ | |||
1590 | /* Loop over domain faces */ | |||
1591 | /* Read out field, centroid, normal, volume for each side of face */ | |||
1592 | /* Riemann solve over faces */ | |||
1593 | /* Loop over domain faces */ | |||
1594 | /* Accumulate fluxes to cells */ | |||
1595 | /* TODO Change printFEM to printDisc here */ | |||
1596 | if (mesh->printFEM) { | |||
1597 | Vec locFbc; | |||
1598 | PetscInt pStart, pEnd, p, maxDof; | |||
1599 | PetscScalar *zeroes; | |||
1600 | ||||
1601 | ierr = VecDuplicate(locF,&locFbc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1601,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1602 | ierr = VecCopy(locF,locFbc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1602,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1603 | ierr = PetscSectionGetChart(section,&pStart,&pEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1603,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1604 | ierr = PetscSectionGetMaxDof(section,&maxDof);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1604,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1605 | ierr = PetscCalloc1(maxDof,&zeroes)PetscMallocA(1,PETSC_TRUE,1605,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(maxDof)*sizeof(**(&zeroes)),(&zeroes));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1605,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1606 | for (p = pStart; p < pEnd; p++) { | |||
1607 | ierr = VecSetValuesSection(locFbc,section,p,zeroes,INSERT_BC_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1607,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1608 | } | |||
1609 | ierr = PetscFree(zeroes)((*PetscTrFree)((void*)(zeroes),1609,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((zeroes) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1609,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1610 | ierr = DMPrintLocalVec(dm, name, mesh->printTol, locFbc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1610,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1611 | ierr = VecDestroy(&locFbc);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1611,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1612 | } | |||
1613 | ierr = PetscLogEventEnd(DMPLEX_ResidualFEM,dm,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_ResidualFEM].active) ? (*PetscLogPLE)((DMPLEX_ResidualFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1613,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1614 | 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); | |||
1615 | } | |||
1616 | ||||
1617 | static PetscErrorCode DMPlexComputeResidualFEM_Check_Internal(DM dm, Vec X, Vec X_t, PetscReal t, Vec F, void *user) | |||
1618 | { | |||
1619 | DM dmCh, dmAux; | |||
1620 | Vec A; | |||
1621 | DMField coordField = NULL((void*)0); | |||
1622 | PetscDS prob, probCh, probAux = NULL((void*)0); | |||
1623 | PetscSection section, sectionAux; | |||
1624 | PetscScalar *elemVec, *elemVecCh, *u, *u_t, *a = NULL((void*)0); | |||
1625 | PetscInt Nf, f, numCells, cStart, cEnd, c; | |||
1626 | PetscInt totDim, totDimAux = 0, diffCell = 0; | |||
1627 | PetscInt depth; | |||
1628 | PetscInt maxDegree; | |||
1629 | IS cellIS; | |||
1630 | DMLabel depthLabel; | |||
1631 | PetscErrorCode ierr; | |||
1632 | ||||
1633 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1633; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1634 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1634,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1635 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1635,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1636 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1636,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1637 | ierr = PetscSectionGetNumFields(section, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1637,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1638 | ierr = DMPlexGetHeightStratum(dm, 0, &cStart, &cEnd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1638,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1639 | numCells = cEnd - cStart; | |||
1640 | ierr = PetscObjectQuery((PetscObject) dm, "dmCh", (PetscObject *) &dmCh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1640,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1641 | ierr = DMGetDS(dmCh, &probCh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1641,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1642 | ierr = PetscObjectQuery((PetscObject) dm, "dmAux", (PetscObject *) &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1642,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1643 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &A);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1643,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1644 | if (dmAux) { | |||
1645 | ierr = DMGetSection(dmAux, §ionAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1645,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1646 | ierr = DMGetDS(dmAux, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1646,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1647 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1647,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1648 | } | |||
1649 | ierr = VecSet(F, 0.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1649,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1650 | ierr = PetscMalloc3(numCells*totDim,&u,X_t ? numCells*totDim : 0,&u_t,numCells*totDim,&elemVec)PetscMallocA(3,PETSC_FALSE,1650,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDim)*sizeof(**(&u)),(&u),(size_t )(X_t ? numCells*totDim : 0)*sizeof(**(&u_t)),(&u_t), (size_t)(numCells*totDim)*sizeof(**(&elemVec)),(&elemVec ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1650,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1651 | ierr = PetscMalloc1(numCells*totDim,&elemVecCh)PetscMallocA(1,PETSC_FALSE,1651,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDim)*sizeof(**(&elemVecCh)),(&elemVecCh ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1651,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1652 | if (dmAux) {ierr = PetscMalloc1(numCells*totDimAux, &a)PetscMallocA(1,PETSC_FALSE,1652,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDimAux)*sizeof(**(&a)),(&a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1652,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1653 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1653,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1654 | ierr = DMPlexGetDepth(dm,&depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1654,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1655 | ierr = DMLabelGetStratumIS(depthLabel,depth,&cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1655,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1656 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1656,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1657 | for (c = cStart; c < cEnd; ++c) { | |||
1658 | PetscScalar *x = NULL((void*)0), *x_t = NULL((void*)0); | |||
1659 | PetscInt i; | |||
1660 | ||||
1661 | ierr = DMPlexVecGetClosure(dm, section, X, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1661,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1662 | for (i = 0; i < totDim; ++i) u[c*totDim+i] = x[i]; | |||
1663 | ierr = DMPlexVecRestoreClosure(dm, section, X, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1663,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1664 | if (X_t) { | |||
1665 | ierr = DMPlexVecGetClosure(dm, section, X_t, c, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1665,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1666 | for (i = 0; i < totDim; ++i) u_t[c*totDim+i] = x_t[i]; | |||
1667 | ierr = DMPlexVecRestoreClosure(dm, section, X_t, c, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1667,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1668 | } | |||
1669 | if (dmAux) { | |||
1670 | DM dmAuxPlex; | |||
1671 | ||||
1672 | ierr = DMSNESConvertPlex(dmAux,&dmAuxPlex, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1672,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1673 | ierr = DMPlexVecGetClosure(dmAuxPlex, sectionAux, A, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1673,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1674 | for (i = 0; i < totDimAux; ++i) a[c*totDimAux+i] = x[i]; | |||
1675 | ierr = DMPlexVecRestoreClosure(dmAuxPlex, sectionAux, A, c, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1675,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1676 | ierr = DMDestroy(&dmAuxPlex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1676,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1677 | } | |||
1678 | } | |||
1679 | for (f = 0; f < Nf; ++f) { | |||
1680 | PetscFE fe, feCh; | |||
1681 | PetscInt Nq, Nb; | |||
1682 | /* Conforming batches */ | |||
1683 | PetscInt numChunks, numBatches, numBlocks, Ne, blockSize, batchSize; | |||
1684 | /* Remainder */ | |||
1685 | PetscInt Nr, offset; | |||
1686 | PetscQuadrature qGeom = NULL((void*)0); | |||
1687 | PetscFEGeom *cgeomFEM, *chunkGeom = NULL((void*)0); | |||
1688 | ||||
1689 | ierr = PetscDSGetDiscretization(prob, f, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1689,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1690 | ierr = PetscDSGetDiscretization(probCh, f, (PetscObject *) &feCh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1690,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1691 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1691,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1692 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1692,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1693 | ierr = DMFieldGetDegree(coordField,cellIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1693,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1694 | if (maxDegree <= 1) { | |||
1695 | ierr = DMFieldCreateDefaultQuadrature(coordField,cellIS,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1695,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1696 | } | |||
1697 | if (!qGeom) { | |||
1698 | ierr = PetscFEGetQuadrature(fe, &qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1698,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1699 | ierr = PetscObjectReference((PetscObject)qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1699,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1700 | } | |||
1701 | ierr = PetscQuadratureGetData(qGeom, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1701,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1702 | ierr = DMSNESGetFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1702,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1703 | blockSize = Nb; | |||
1704 | batchSize = numBlocks * blockSize; | |||
1705 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1705,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1706 | numChunks = numCells / (numBatches*batchSize); | |||
1707 | Ne = numChunks*numBatches*batchSize; | |||
1708 | Nr = numCells % (numBatches*batchSize); | |||
1709 | offset = numCells - Nr; | |||
1710 | ierr = PetscFEGeomGetChunk(cgeomFEM,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1710,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1711 | ierr = PetscFEIntegrateResidual(fe, prob, f, Ne, chunkGeom, u, u_t, probAux, a, t, elemVec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1711,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1712 | ierr = PetscFEIntegrateResidual(feCh, prob, f, Ne, chunkGeom, u, u_t, probAux, a, t, elemVecCh);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1712,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1713 | ierr = PetscFEGeomGetChunk(cgeomFEM,offset,numCells,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1713,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1714 | ierr = PetscFEIntegrateResidual(fe, prob, f, Nr, chunkGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, &elemVec[offset*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1714,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1715 | ierr = PetscFEIntegrateResidual(feCh, prob, f, Nr, chunkGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, &elemVecCh[offset*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1715,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1716 | ierr = PetscFEGeomRestoreChunk(cgeomFEM,offset,numCells,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1716,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1717 | ierr = DMSNESRestoreFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1717,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1718 | ierr = PetscQuadratureDestroy(&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1718,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1719 | } | |||
1720 | ierr = ISDestroy(&cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1720,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1721 | for (c = cStart; c < cEnd; ++c) { | |||
1722 | PetscBool diff = PETSC_FALSE; | |||
1723 | PetscInt d; | |||
1724 | ||||
1725 | for (d = 0; d < totDim; ++d) if (PetscAbsScalar(elemVec[c*totDim+d] - elemVecCh[c*totDim+d]) > 1.0e-7) {diff = PETSC_TRUE;break;} | |||
1726 | if (diff) { | |||
1727 | ierr = PetscPrintf(PetscObjectComm((PetscObject) dm), "Different cell %d\n", c);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1727,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1728 | ierr = DMPrintCellVector(c, "Residual", totDim, &elemVec[c*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1728,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1729 | ierr = DMPrintCellVector(c, "Check Residual", totDim, &elemVecCh[c*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1729,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1730 | ++diffCell; | |||
1731 | } | |||
1732 | if (diffCell > 9) break; | |||
1733 | ierr = DMPlexVecSetClosure(dm, section, F, c, &elemVec[c*totDim], ADD_ALL_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1733,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1734 | } | |||
1735 | ierr = PetscFree3(u,u_t,elemVec)PetscFreeA(3,1735,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(u),&(u_t),&(elemVec));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1735,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1736 | ierr = PetscFree(elemVecCh)((*PetscTrFree)((void*)(elemVecCh),1736,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((elemVecCh) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1736,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1737 | if (dmAux) {ierr = PetscFree(a)((*PetscTrFree)((void*)(a),1737,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((a) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1737,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1738 | 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); | |||
1739 | } | |||
1740 | ||||
1741 | /*@ | |||
1742 | DMPlexSNESComputeResidualFEM - Form the local residual F from the local input X using pointwise functions specified by the user | |||
1743 | ||||
1744 | Input Parameters: | |||
1745 | + dm - The mesh | |||
1746 | . X - Local solution | |||
1747 | - user - The user context | |||
1748 | ||||
1749 | Output Parameter: | |||
1750 | . F - Local output vector | |||
1751 | ||||
1752 | Level: developer | |||
1753 | ||||
1754 | .seealso: DMPlexComputeJacobianAction() | |||
1755 | @*/ | |||
1756 | PetscErrorCode DMPlexSNESComputeResidualFEM(DM dm, Vec X, Vec F, void *user) | |||
1757 | { | |||
1758 | PetscObject check; | |||
1759 | DM plex; | |||
1760 | IS cellIS; | |||
1761 | PetscInt depth; | |||
1762 | PetscErrorCode ierr; | |||
1763 | ||||
1764 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1764; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1765 | ierr = DMSNESConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1765,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1766 | ierr = DMPlexGetDepth(plex, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1766,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1767 | ierr = DMGetStratumIS(plex, "dim", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1767,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1768 | if (!cellIS) { | |||
1769 | ierr = DMGetStratumIS(plex, "depth", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1769,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1770 | } | |||
1771 | /* The dmCh is used to check two mathematically equivalent discretizations for computational equivalence */ | |||
1772 | ierr = PetscObjectQuery((PetscObject) plex, "dmCh", &check);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1772,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1773 | if (check) {ierr = DMPlexComputeResidualFEM_Check_Internal(plex, X, NULL((void*)0), 0.0, F, user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1773,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1774 | else {ierr = DMPlexComputeResidual_Internal(plex, cellIS, PETSC_MIN_REAL(-1.7976931348623157e+308), X, NULL((void*)0), 0.0, F, user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1774,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1775 | ierr = ISDestroy(&cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1775,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1776 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1776,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1777 | 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); | |||
1778 | } | |||
1779 | ||||
1780 | /*@ | |||
1781 | DMPlexSNESComputeBoundaryFEM - Form the boundary values for the local input X | |||
1782 | ||||
1783 | Input Parameters: | |||
1784 | + dm - The mesh | |||
1785 | - user - The user context | |||
1786 | ||||
1787 | Output Parameter: | |||
1788 | . X - Local solution | |||
1789 | ||||
1790 | Level: developer | |||
1791 | ||||
1792 | .seealso: DMPlexComputeJacobianAction() | |||
1793 | @*/ | |||
1794 | PetscErrorCode DMPlexSNESComputeBoundaryFEM(DM dm, Vec X, void *user) | |||
1795 | { | |||
1796 | DM plex; | |||
1797 | PetscErrorCode ierr; | |||
1798 | ||||
1799 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1799; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1800 | ierr = DMSNESConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1800,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1801 | ierr = DMPlexInsertBoundaryValues(plex, PETSC_TRUE, X, PETSC_MIN_REAL(-1.7976931348623157e+308), NULL((void*)0), NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1801,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1802 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1802,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1803 | 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); | |||
1804 | } | |||
1805 | ||||
1806 | PetscErrorCode DMPlexComputeBdJacobian_Single_Internal(DM dm, PetscReal t, DMLabel label, PetscInt numValues, const PetscInt values[], PetscInt fieldI, Vec locX, Vec locX_t, PetscReal X_tShift, Mat Jac, Mat JacP, DMField coordField, IS facetIS) | |||
1807 | { | |||
1808 | DM_Plex *mesh = (DM_Plex *) dm->data; | |||
1809 | DM plex = NULL((void*)0), plexA = NULL((void*)0); | |||
1810 | PetscDS prob, probAux = NULL((void*)0); | |||
1811 | PetscSection section, sectionAux = NULL((void*)0); | |||
1812 | PetscSection globalSection, subSection = NULL((void*)0); | |||
1813 | Vec locA = NULL((void*)0); | |||
1814 | PetscScalar *u = NULL((void*)0), *u_t = NULL((void*)0), *a = NULL((void*)0), *elemMat = NULL((void*)0); | |||
1815 | PetscInt v; | |||
1816 | PetscInt Nf, totDim, totDimAux = 0; | |||
1817 | PetscBool isMatISP; | |||
1818 | PetscErrorCode ierr; | |||
1819 | ||||
1820 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1820; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1821 | ierr = DMConvert(dm, DMPLEX"plex", &plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1821,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1822 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1822,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1823 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1823,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1824 | ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1824,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1825 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1825,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1826 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &locA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1826,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1827 | if (locA) { | |||
1828 | DM dmAux; | |||
1829 | ||||
1830 | ierr = VecGetDM(locA, &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1830,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1831 | ierr = DMConvert(dmAux, DMPLEX"plex", &plexA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1831,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1832 | ierr = DMGetDS(plexA, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1832,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1833 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1833,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1834 | ierr = DMGetSection(plexA, §ionAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1834,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1835 | } | |||
1836 | ||||
1837 | ierr = PetscObjectTypeCompare((PetscObject) JacP, MATIS"is", &isMatISP);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1837,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1838 | ierr = DMGetGlobalSection(dm, &globalSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1838,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1839 | if (isMatISP) {ierr = DMPlexGetSubdomainSection(dm, &subSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1839,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1840 | for (v = 0; v < numValues; ++v) { | |||
1841 | PetscFEGeom *fgeom; | |||
1842 | PetscInt maxDegree; | |||
1843 | PetscQuadrature qGeom = NULL((void*)0); | |||
1844 | IS pointIS; | |||
1845 | const PetscInt *points; | |||
1846 | PetscInt numFaces, face, Nq; | |||
1847 | ||||
1848 | ierr = DMLabelGetStratumIS(label, values[v], &pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1848,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1849 | if (!pointIS) continue; /* No points with that id on this process */ | |||
1850 | { | |||
1851 | IS isectIS; | |||
1852 | ||||
1853 | /* TODO: Special cases of ISIntersect where it is quick to check a prior if one is a superset of the other */ | |||
1854 | ierr = ISIntersect_Caching_Internal(facetIS,pointIS,&isectIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1854,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1855 | ierr = ISDestroy(&pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1855,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1856 | pointIS = isectIS; | |||
1857 | } | |||
1858 | ierr = ISGetLocalSize(pointIS, &numFaces);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1858,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1859 | ierr = ISGetIndices(pointIS, &points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1859,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1860 | ierr = PetscMalloc4(numFaces*totDim, &u, locX_t ? numFaces*totDim : 0, &u_t, numFaces*totDim*totDim, &elemMat, locA ? numFaces*totDimAux : 0, &a)PetscMallocA(4,PETSC_FALSE,1860,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numFaces*totDim)*sizeof(**(&u)),(&u),(size_t )(locX_t ? numFaces*totDim : 0)*sizeof(**(&u_t)),(&u_t ),(size_t)(numFaces*totDim*totDim)*sizeof(**(&elemMat)),( &elemMat),(size_t)(locA ? numFaces*totDimAux : 0)*sizeof( **(&a)),(&a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1860,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1861 | ierr = DMFieldGetDegree(coordField,pointIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1861,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1862 | if (maxDegree <= 1) { | |||
1863 | ierr = DMFieldCreateDefaultQuadrature(coordField,pointIS,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1863,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1864 | } | |||
1865 | if (!qGeom) { | |||
1866 | PetscFE fe; | |||
1867 | ||||
1868 | ierr = PetscDSGetDiscretization(prob, fieldI, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1868,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1869 | ierr = PetscFEGetFaceQuadrature(fe, &qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1869,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1870 | ierr = PetscObjectReference((PetscObject)qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1870,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1871 | } | |||
1872 | ierr = PetscQuadratureGetData(qGeom, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1872,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1873 | ierr = DMSNESGetFEGeom(coordField,pointIS,qGeom,PETSC_TRUE,&fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1873,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1874 | for (face = 0; face < numFaces; ++face) { | |||
1875 | const PetscInt point = points[face], *support, *cone; | |||
1876 | PetscScalar *x = NULL((void*)0); | |||
1877 | PetscInt i, coneSize, faceLoc; | |||
1878 | ||||
1879 | ierr = DMPlexGetSupport(dm, point, &support);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1879,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1880 | ierr = DMPlexGetConeSize(dm, support[0], &coneSize);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1880,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1881 | ierr = DMPlexGetCone(dm, support[0], &cone);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1881,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1882 | for (faceLoc = 0; faceLoc < coneSize; ++faceLoc) if (cone[faceLoc] == point) break; | |||
1883 | if (faceLoc == coneSize) SETERRQ2(PETSC_COMM_SELF, PETSC_ERR_PLIB, "Could not find face %d in cone of support[0] %d", point, support[0])return PetscError(((MPI_Comm)0x44000001),1883,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,77,PETSC_ERROR_INITIAL,"Could not find face %d in cone of support[0] %d" ,point,support[0]); | |||
1884 | fgeom->face[face][0] = faceLoc; | |||
1885 | ierr = DMPlexVecGetClosure(plex, section, locX, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1885,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1886 | for (i = 0; i < totDim; ++i) u[face*totDim+i] = x[i]; | |||
1887 | ierr = DMPlexVecRestoreClosure(plex, section, locX, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1887,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1888 | if (locX_t) { | |||
1889 | ierr = DMPlexVecGetClosure(plex, section, locX_t, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1889,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1890 | for (i = 0; i < totDim; ++i) u_t[face*totDim+i] = x[i]; | |||
1891 | ierr = DMPlexVecRestoreClosure(plex, section, locX_t, support[0], NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1891,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1892 | } | |||
1893 | if (locA) { | |||
1894 | PetscInt subp; | |||
1895 | ierr = DMPlexGetSubpoint(plexA, support[0], &subp);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1895,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1896 | ierr = DMPlexVecGetClosure(plexA, sectionAux, locA, subp, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1896,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1897 | for (i = 0; i < totDimAux; ++i) a[face*totDimAux+i] = x[i]; | |||
1898 | ierr = DMPlexVecRestoreClosure(plexA, sectionAux, locA, subp, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1898,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1899 | } | |||
1900 | } | |||
1901 | ierr = PetscMemzero(elemMat, numFaces*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1901,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1902 | { | |||
1903 | PetscFE fe; | |||
1904 | PetscInt Nb; | |||
1905 | /* Conforming batches */ | |||
1906 | PetscInt numChunks, numBatches, numBlocks, Ne, blockSize, batchSize; | |||
1907 | /* Remainder */ | |||
1908 | PetscFEGeom *chunkGeom = NULL((void*)0); | |||
1909 | PetscInt fieldJ, Nr, offset; | |||
1910 | ||||
1911 | ierr = PetscDSGetDiscretization(prob, fieldI, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1911,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1912 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1912,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1913 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1913,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1914 | blockSize = Nb; | |||
1915 | batchSize = numBlocks * blockSize; | |||
1916 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1916,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1917 | numChunks = numFaces / (numBatches*batchSize); | |||
1918 | Ne = numChunks*numBatches*batchSize; | |||
1919 | Nr = numFaces % (numBatches*batchSize); | |||
1920 | offset = numFaces - Nr; | |||
1921 | ierr = PetscFEGeomGetChunk(fgeom,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1921,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1922 | for (fieldJ = 0; fieldJ < Nf; ++fieldJ) { | |||
1923 | ierr = PetscFEIntegrateBdJacobian(fe, prob, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1923,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1924 | } | |||
1925 | ierr = PetscFEGeomGetChunk(fgeom,offset,numFaces,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1925,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1926 | for (fieldJ = 0; fieldJ < Nf; ++fieldJ) { | |||
1927 | ierr = PetscFEIntegrateBdJacobian(fe, prob, fieldI, fieldJ, Nr, chunkGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, a ? &a[offset*totDimAux] : NULL((void*)0), t, X_tShift, &elemMat[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1927,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1928 | } | |||
1929 | ierr = PetscFEGeomRestoreChunk(fgeom,offset,numFaces,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1929,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1930 | } | |||
1931 | for (face = 0; face < numFaces; ++face) { | |||
1932 | const PetscInt point = points[face], *support; | |||
1933 | ||||
1934 | if (mesh->printFEM > 1) {ierr = DMPrintCellMatrix(point, "BdJacobian", totDim, totDim, &elemMat[face*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1934,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1935 | ierr = DMPlexGetSupport(plex, point, &support);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1935,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1936 | if (!isMatISP) { | |||
1937 | ierr = DMPlexMatSetClosure(plex, section, globalSection, JacP, support[0], &elemMat[face*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1937,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1938 | } else { | |||
1939 | Mat lJ; | |||
1940 | ||||
1941 | ierr = MatISGetLocalMat(JacP, &lJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1941,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1942 | ierr = DMPlexMatSetClosure(plex, section, subSection, lJ, support[0], &elemMat[face*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1942,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1943 | } | |||
1944 | } | |||
1945 | ierr = DMSNESRestoreFEGeom(coordField,pointIS,qGeom,PETSC_TRUE,&fgeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1945,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1946 | ierr = PetscQuadratureDestroy(&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1946,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1947 | ierr = ISRestoreIndices(pointIS, &points);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1947,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1948 | ierr = ISDestroy(&pointIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1948,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1949 | ierr = PetscFree4(u, u_t, elemMat, a)PetscFreeA(4,1949,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(u),&(u_t),&(elemMat),&(a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1949,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1950 | } | |||
1951 | if (plex) {ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1951,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1952 | if (plexA) {ierr = DMDestroy(&plexA);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1952,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
1953 | 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); | |||
1954 | } | |||
1955 | ||||
1956 | PetscErrorCode DMPlexComputeBdJacobianSingle(DM dm, PetscReal t, DMLabel label, PetscInt numValues, const PetscInt values[], PetscInt field, Vec locX, Vec locX_t, PetscReal X_tShift, Mat Jac, Mat JacP) | |||
1957 | { | |||
1958 | DMField coordField; | |||
1959 | DMLabel depthLabel; | |||
1960 | IS facetIS; | |||
1961 | PetscInt dim; | |||
1962 | PetscErrorCode ierr; | |||
1963 | ||||
1964 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1964; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1965 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1965,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1966 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1966,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1967 | ierr = DMLabelGetStratumIS(depthLabel, dim-1, &facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1967,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1968 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1968,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1969 | ierr = DMPlexComputeBdJacobian_Single_Internal(dm, t, label, numValues, values, field, locX, locX_t, X_tShift, Jac, JacP, coordField, facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1969,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1970 | 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); | |||
1971 | } | |||
1972 | ||||
1973 | PetscErrorCode DMPlexComputeBdJacobian_Internal(DM dm, Vec locX, Vec locX_t, PetscReal t, PetscReal X_tShift, Mat Jac, Mat JacP, void *user) | |||
1974 | { | |||
1975 | PetscDS prob; | |||
1976 | PetscInt dim, numBd, bd; | |||
1977 | DMLabel depthLabel; | |||
1978 | DMField coordField = NULL((void*)0); | |||
1979 | IS facetIS; | |||
1980 | PetscErrorCode ierr; | |||
1981 | ||||
1982 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 1982; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
1983 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1983,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1984 | ierr = DMPlexGetDepthLabel(dm, &depthLabel);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1984,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1985 | ierr = DMGetDimension(dm, &dim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1985,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1986 | ierr = DMLabelGetStratumIS(depthLabel, dim-1, &facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1986,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1987 | ierr = PetscDSGetNumBoundary(prob, &numBd);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1987,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1988 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1988,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1989 | for (bd = 0; bd < numBd; ++bd) { | |||
1990 | DMBoundaryConditionType type; | |||
1991 | const char *bdLabel; | |||
1992 | DMLabel label; | |||
1993 | const PetscInt *values; | |||
1994 | PetscInt fieldI, numValues; | |||
1995 | PetscObject obj; | |||
1996 | PetscClassId id; | |||
1997 | ||||
1998 | ierr = PetscDSGetBoundary(prob, bd, &type, NULL((void*)0), &bdLabel, &fieldI, NULL((void*)0), NULL((void*)0), NULL((void*)0), &numValues, &values, NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1998,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
1999 | ierr = PetscDSGetDiscretization(prob, fieldI, &obj);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),1999,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2000 | ierr = PetscObjectGetClassId(obj, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2000,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2001 | if ((id != PETSCFE_CLASSID) || (type & DM_BC_ESSENTIAL)) continue; | |||
2002 | ierr = DMGetLabel(dm, bdLabel, &label);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2002,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2003 | ierr = DMPlexComputeBdJacobian_Single_Internal(dm, t, label, numValues, values, fieldI, locX, locX_t, X_tShift, Jac, JacP, coordField, facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2003,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2004 | } | |||
2005 | ierr = ISDestroy(&facetIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2005,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2006 | 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); | |||
2007 | } | |||
2008 | ||||
2009 | PetscErrorCode DMPlexComputeJacobian_Internal(DM dm, IS cellIS, PetscReal t, PetscReal X_tShift, Vec X, Vec X_t, Mat Jac, Mat JacP,void *user) | |||
2010 | { | |||
2011 | DM_Plex *mesh = (DM_Plex *) dm->data; | |||
2012 | const char *name = "Jacobian"; | |||
2013 | DM dmAux, plex; | |||
2014 | Vec A; | |||
2015 | DMField coordField; | |||
2016 | PetscDS prob, probAux = NULL((void*)0); | |||
2017 | PetscSection section, globalSection, subSection, sectionAux; | |||
2018 | PetscScalar *elemMat, *elemMatP, *elemMatD, *u, *u_t, *a = NULL((void*)0); | |||
2019 | const PetscInt *cells; | |||
2020 | PetscInt Nf, fieldI, fieldJ; | |||
2021 | PetscInt totDim, totDimAux, cStart, cEnd, numCells, c; | |||
2022 | PetscBool isMatIS, isMatISP, hasJac, hasPrec, hasDyn, hasFV = PETSC_FALSE; | |||
2023 | PetscErrorCode ierr; | |||
2024 | ||||
2025 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2025; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2026 | ierr = PetscLogEventBegin(DMPLEX_JacobianFEM,dm,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_JacobianFEM].active) ? (*PetscLogPLB)((DMPLEX_JacobianFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2026,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2027 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2027,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2028 | ierr = PetscObjectTypeCompare((PetscObject) JacP, MATIS"is", &isMatISP);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2028,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2029 | ierr = DMGetGlobalSection(dm, &globalSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2029,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2030 | if (isMatISP) {ierr = DMPlexGetSubdomainSection(dm, &subSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2030,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2031 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2031,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2032 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2032,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2033 | ierr = PetscDSHasJacobian(prob, &hasJac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2033,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2034 | ierr = PetscDSHasJacobianPreconditioner(prob, &hasPrec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2034,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2035 | ierr = PetscDSHasDynamicJacobian(prob, &hasDyn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2035,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2036 | hasDyn = hasDyn && (X_tShift != 0.0) ? PETSC_TRUE : PETSC_FALSE; | |||
2037 | ierr = PetscSectionGetNumFields(section, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2037,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2038 | ierr = ISGetLocalSize(cellIS, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2038,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2039 | ierr = ISGetPointRange(cellIS, &cStart, &cEnd, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2039,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2040 | ierr = PetscObjectQuery((PetscObject) dm, "dmAux", (PetscObject *) &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2040,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2041 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &A);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2041,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2042 | if (dmAux) { | |||
2043 | ierr = DMConvert(dmAux, DMPLEX"plex", &plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2043,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2044 | ierr = DMGetSection(plex, §ionAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2044,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2045 | ierr = DMGetDS(dmAux, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2045,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2046 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2046,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2047 | } | |||
2048 | ierr = PetscMalloc5(numCells*totDim,&u,X_t ? numCells*totDim : 0,&u_t,hasJac ? numCells*totDim*totDim : 0,&elemMat,hasPrec ? numCells*totDim*totDim : 0, &elemMatP,hasDyn ? numCells*totDim*totDim : 0, &elemMatD)PetscMallocA(5,PETSC_FALSE,2048,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDim)*sizeof(**(&u)),(&u),(size_t )(X_t ? numCells*totDim : 0)*sizeof(**(&u_t)),(&u_t), (size_t)(hasJac ? numCells*totDim*totDim : 0)*sizeof(**(& elemMat)),(&elemMat),(size_t)(hasPrec ? numCells*totDim*totDim : 0)*sizeof(**(&elemMatP)),(&elemMatP),(size_t)(hasDyn ? numCells*totDim*totDim : 0)*sizeof(**(&elemMatD)),(& elemMatD));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2048,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2049 | if (dmAux) {ierr = PetscMalloc1(numCells*totDimAux, &a)PetscMallocA(1,PETSC_FALSE,2049,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDimAux)*sizeof(**(&a)),(&a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2049,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2050 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2050,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2051 | for (c = cStart; c < cEnd; ++c) { | |||
2052 | const PetscInt cell = cells ? cells[c] : c; | |||
2053 | const PetscInt cind = c - cStart; | |||
2054 | PetscScalar *x = NULL((void*)0), *x_t = NULL((void*)0); | |||
2055 | PetscInt i; | |||
2056 | ||||
2057 | ierr = DMPlexVecGetClosure(dm, section, X, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2057,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2058 | for (i = 0; i < totDim; ++i) u[cind*totDim+i] = x[i]; | |||
2059 | ierr = DMPlexVecRestoreClosure(dm, section, X, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2059,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2060 | if (X_t) { | |||
2061 | ierr = DMPlexVecGetClosure(dm, section, X_t, cell, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2061,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2062 | for (i = 0; i < totDim; ++i) u_t[cind*totDim+i] = x_t[i]; | |||
2063 | ierr = DMPlexVecRestoreClosure(dm, section, X_t, cell, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2063,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2064 | } | |||
2065 | if (dmAux) { | |||
2066 | PetscInt subcell; | |||
2067 | ierr = DMPlexGetAuxiliaryPoint(dm, dmAux, cell, &subcell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2067,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2068 | ierr = DMPlexVecGetClosure(plex, sectionAux, A, subcell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2068,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2069 | for (i = 0; i < totDimAux; ++i) a[cind*totDimAux+i] = x[i]; | |||
2070 | ierr = DMPlexVecRestoreClosure(plex, sectionAux, A, subcell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2070,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2071 | } | |||
2072 | } | |||
2073 | if (hasJac) {ierr = PetscMemzero(elemMat, numCells*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2073,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2074 | if (hasPrec) {ierr = PetscMemzero(elemMatP, numCells*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2074,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2075 | if (hasDyn) {ierr = PetscMemzero(elemMatD, numCells*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2075,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2076 | for (fieldI = 0; fieldI < Nf; ++fieldI) { | |||
2077 | PetscClassId id; | |||
2078 | PetscFE fe; | |||
2079 | PetscQuadrature qGeom = NULL((void*)0); | |||
2080 | PetscInt Nb; | |||
2081 | /* Conforming batches */ | |||
2082 | PetscInt numChunks, numBatches, numBlocks, Ne, blockSize, batchSize; | |||
2083 | /* Remainder */ | |||
2084 | PetscInt Nr, offset, Nq; | |||
2085 | PetscInt maxDegree; | |||
2086 | PetscFEGeom *cgeomFEM, *chunkGeom = NULL((void*)0), *remGeom = NULL((void*)0); | |||
2087 | ||||
2088 | ierr = PetscDSGetDiscretization(prob, fieldI, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2088,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2089 | ierr = PetscObjectGetClassId((PetscObject) fe, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2089,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2090 | if (id == PETSCFV_CLASSID) {hasFV = PETSC_TRUE; continue;} | |||
2091 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2091,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2092 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2092,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2093 | ierr = DMFieldGetDegree(coordField,cellIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2093,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2094 | if (maxDegree <= 1) { | |||
2095 | ierr = DMFieldCreateDefaultQuadrature(coordField,cellIS,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2095,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2096 | } | |||
2097 | if (!qGeom) { | |||
2098 | ierr = PetscFEGetQuadrature(fe,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2098,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2099 | ierr = PetscObjectReference((PetscObject)qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2099,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2100 | } | |||
2101 | ierr = PetscQuadratureGetData(qGeom, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2101,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2102 | ierr = DMSNESGetFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2102,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2103 | blockSize = Nb; | |||
2104 | batchSize = numBlocks * blockSize; | |||
2105 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2105,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2106 | numChunks = numCells / (numBatches*batchSize); | |||
2107 | Ne = numChunks*numBatches*batchSize; | |||
2108 | Nr = numCells % (numBatches*batchSize); | |||
2109 | offset = numCells - Nr; | |||
2110 | ierr = PetscFEGeomGetChunk(cgeomFEM,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2110,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2111 | ierr = PetscFEGeomGetChunk(cgeomFEM,offset,numCells,&remGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2111,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2112 | for (fieldJ = 0; fieldJ < Nf; ++fieldJ) { | |||
2113 | if (hasJac) { | |||
2114 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2114,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2115 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN, fieldI, fieldJ, Nr, remGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, X_tShift, &elemMat[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2115,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2116 | } | |||
2117 | if (hasPrec) { | |||
2118 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_PRE, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMatP);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2118,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2119 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_PRE, fieldI, fieldJ, Nr, remGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, X_tShift, &elemMatP[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2119,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2120 | } | |||
2121 | if (hasDyn) { | |||
2122 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_DYN, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMatD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2122,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2123 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_DYN, fieldI, fieldJ, Nr, remGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, X_tShift, &elemMatD[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2123,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2124 | } | |||
2125 | } | |||
2126 | ierr = PetscFEGeomRestoreChunk(cgeomFEM,offset,numCells,&remGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2126,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2127 | ierr = PetscFEGeomRestoreChunk(cgeomFEM,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2127,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2128 | ierr = DMSNESRestoreFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2128,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2129 | ierr = PetscQuadratureDestroy(&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2129,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2130 | } | |||
2131 | /* Add contribution from X_t */ | |||
2132 | if (hasDyn) {for (c = 0; c < numCells*totDim*totDim; ++c) elemMat[c] += X_tShift*elemMatD[c];} | |||
2133 | if (hasFV) { | |||
2134 | PetscClassId id; | |||
2135 | PetscFV fv; | |||
2136 | PetscInt offsetI, NcI, NbI = 1, fc, f; | |||
2137 | ||||
2138 | for (fieldI = 0; fieldI < Nf; ++fieldI) { | |||
2139 | ierr = PetscDSGetDiscretization(prob, fieldI, (PetscObject *) &fv);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2139,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2140 | ierr = PetscDSGetFieldOffset(prob, fieldI, &offsetI);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2140,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2141 | ierr = PetscObjectGetClassId((PetscObject) fv, &id);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2141,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2142 | if (id != PETSCFV_CLASSID) continue; | |||
2143 | /* Put in the identity */ | |||
2144 | ierr = PetscFVGetNumComponents(fv, &NcI);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2144,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2145 | for (c = cStart; c < cEnd; ++c) { | |||
2146 | const PetscInt cind = c - cStart; | |||
2147 | const PetscInt eOffset = cind*totDim*totDim; | |||
2148 | for (fc = 0; fc < NcI; ++fc) { | |||
2149 | for (f = 0; f < NbI; ++f) { | |||
2150 | const PetscInt i = offsetI + f*NcI+fc; | |||
2151 | if (hasPrec) { | |||
2152 | if (hasJac) {elemMat[eOffset+i*totDim+i] = 1.0;} | |||
2153 | elemMatP[eOffset+i*totDim+i] = 1.0; | |||
2154 | } else {elemMat[eOffset+i*totDim+i] = 1.0;} | |||
2155 | } | |||
2156 | } | |||
2157 | } | |||
2158 | } | |||
2159 | /* No allocated space for FV stuff, so ignore the zero entries */ | |||
2160 | ierr = MatSetOption(JacP, MAT_IGNORE_ZERO_ENTRIES, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2160,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2161 | } | |||
2162 | /* Insert values into matrix */ | |||
2163 | isMatIS = PETSC_FALSE; | |||
2164 | if (hasPrec && hasJac) { | |||
2165 | ierr = PetscObjectTypeCompare((PetscObject) JacP, MATIS"is", &isMatIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2165,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2166 | } | |||
2167 | if (isMatIS && !subSection) { | |||
2168 | ierr = DMPlexGetSubdomainSection(dm, &subSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2168,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2169 | } | |||
2170 | for (c = cStart; c < cEnd; ++c) { | |||
2171 | const PetscInt cell = cells ? cells[c] : c; | |||
2172 | const PetscInt cind = c - cStart; | |||
2173 | ||||
2174 | if (hasPrec) { | |||
2175 | if (hasJac) { | |||
2176 | if (mesh->printFEM > 1) {ierr = DMPrintCellMatrix(cell, name, totDim, totDim, &elemMat[cind*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2176,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2177 | if (!isMatIS) { | |||
2178 | ierr = DMPlexMatSetClosure(dm, section, globalSection, Jac, cell, &elemMat[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2178,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2179 | } else { | |||
2180 | Mat lJ; | |||
2181 | ||||
2182 | ierr = MatISGetLocalMat(Jac,&lJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2182,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2183 | ierr = DMPlexMatSetClosure(dm, section, subSection, lJ, cell, &elemMat[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2183,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2184 | } | |||
2185 | } | |||
2186 | if (mesh->printFEM > 1) {ierr = DMPrintCellMatrix(cell, name, totDim, totDim, &elemMatP[cind*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2186,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2187 | if (!isMatISP) { | |||
2188 | ierr = DMPlexMatSetClosure(dm, section, globalSection, JacP, cell, &elemMatP[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2188,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2189 | } else { | |||
2190 | Mat lJ; | |||
2191 | ||||
2192 | ierr = MatISGetLocalMat(JacP,&lJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2192,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2193 | ierr = DMPlexMatSetClosure(dm, section, subSection, lJ, cell, &elemMatP[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2193,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2194 | } | |||
2195 | } else { | |||
2196 | if (mesh->printFEM > 1) {ierr = DMPrintCellMatrix(cell, name, totDim, totDim, &elemMat[cind*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2196,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2197 | if (!isMatISP) { | |||
2198 | ierr = DMPlexMatSetClosure(dm, section, globalSection, JacP, cell, &elemMat[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2198,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2199 | } else { | |||
2200 | Mat lJ; | |||
2201 | ||||
2202 | ierr = MatISGetLocalMat(JacP,&lJ);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2202,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2203 | ierr = DMPlexMatSetClosure(dm, section, subSection, lJ, cell, &elemMat[cind*totDim*totDim], ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2203,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2204 | } | |||
2205 | } | |||
2206 | } | |||
2207 | ierr = ISRestorePointRange(cellIS, &cStart, &cEnd, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2207,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2208 | if (hasFV) {ierr = MatSetOption(JacP, MAT_IGNORE_ZERO_ENTRIES, PETSC_FALSE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2208,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2209 | ierr = PetscFree5(u,u_t,elemMat,elemMatP,elemMatD)PetscFreeA(5,2209,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(u),&(u_t),&(elemMat),&(elemMatP),&(elemMatD ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2209,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2210 | if (dmAux) { | |||
2211 | ierr = PetscFree(a)((*PetscTrFree)((void*)(a),2211,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((a) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2211,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2212 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2212,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2213 | } | |||
2214 | /* Compute boundary integrals */ | |||
2215 | ierr = DMPlexComputeBdJacobian_Internal(dm, X, X_t, t, X_tShift, Jac, JacP, user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2215,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2216 | /* Assemble matrix */ | |||
2217 | if (hasJac && hasPrec) { | |||
2218 | ierr = MatAssemblyBegin(Jac, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2218,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2219 | ierr = MatAssemblyEnd(Jac, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2219,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2220 | } | |||
2221 | ierr = MatAssemblyBegin(JacP, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2221,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2222 | ierr = MatAssemblyEnd(JacP, MAT_FINAL_ASSEMBLY);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2222,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2223 | ierr = PetscLogEventEnd(DMPLEX_JacobianFEM,dm,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_JacobianFEM].active) ? (*PetscLogPLE)((DMPLEX_JacobianFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2223,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2224 | 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); | |||
2225 | } | |||
2226 | ||||
2227 | /*@ | |||
2228 | DMPlexComputeJacobianAction - Form the local portion of the Jacobian action Z = J(X) Y at the local solution X using pointwise functions specified by the user. | |||
2229 | ||||
2230 | Input Parameters: | |||
2231 | + dm - The mesh | |||
2232 | . cellIS - | |||
2233 | . t - The time | |||
2234 | . X_tShift - The multiplier for the Jacobian with repsect to X_t | |||
2235 | . X - Local solution vector | |||
2236 | . X_t - Time-derivative of the local solution vector | |||
2237 | . Y - Local input vector | |||
2238 | - user - The user context | |||
2239 | ||||
2240 | Output Parameter: | |||
2241 | . Z - Local output vector | |||
2242 | ||||
2243 | Note: | |||
2244 | We form the residual one batch of elements at a time. This allows us to offload work onto an accelerator, | |||
2245 | like a GPU, or vectorize on a multicore machine. | |||
2246 | ||||
2247 | Level: developer | |||
2248 | ||||
2249 | .seealso: FormFunctionLocal() | |||
2250 | @*/ | |||
2251 | PetscErrorCode DMPlexComputeJacobianAction(DM dm, IS cellIS, PetscReal t, PetscReal X_tShift, Vec X, Vec X_t, Vec Y, Vec Z, void *user) | |||
2252 | { | |||
2253 | DM_Plex *mesh = (DM_Plex *) dm->data; | |||
2254 | const char *name = "Jacobian"; | |||
2255 | DM dmAux, plex, plexAux = NULL((void*)0); | |||
2256 | Vec A; | |||
2257 | PetscDS prob, probAux = NULL((void*)0); | |||
2258 | PetscQuadrature quad; | |||
2259 | PetscSection section, globalSection, sectionAux; | |||
2260 | PetscScalar *elemMat, *elemMatD, *u, *u_t, *a = NULL((void*)0), *y, *z; | |||
2261 | PetscInt Nf, fieldI, fieldJ; | |||
2262 | PetscInt totDim, totDimAux = 0; | |||
2263 | const PetscInt *cells; | |||
2264 | PetscInt cStart, cEnd, numCells, c; | |||
2265 | PetscBool hasDyn; | |||
2266 | DMField coordField; | |||
2267 | PetscErrorCode ierr; | |||
2268 | ||||
2269 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2269; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2270 | ierr = PetscLogEventBegin(DMPLEX_JacobianFEM,dm,0,0,0)(((PetscLogPLB && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_JacobianFEM].active) ? (*PetscLogPLB)((DMPLEX_JacobianFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2270,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2271 | ierr = DMSNESConvertPlex(dm, &plex, PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2271,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2272 | if (!cellIS) { | |||
2273 | PetscInt depth; | |||
2274 | ||||
2275 | ierr = DMPlexGetDepth(plex, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2275,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2276 | ierr = DMGetStratumIS(plex, "dim", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2276,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2277 | if (!cellIS) {ierr = DMGetStratumIS(plex, "depth", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2277,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2278 | } else { | |||
2279 | ierr = PetscObjectReference((PetscObject) cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2279,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2280 | } | |||
2281 | ierr = DMGetSection(dm, §ion);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2281,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2282 | ierr = DMGetGlobalSection(dm, &globalSection);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2282,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2283 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2283,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2284 | ierr = PetscDSGetTotalDimension(prob, &totDim);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2284,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2285 | ierr = PetscDSHasDynamicJacobian(prob, &hasDyn);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2285,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2286 | hasDyn = hasDyn && (X_tShift != 0.0) ? PETSC_TRUE : PETSC_FALSE; | |||
2287 | ierr = PetscSectionGetNumFields(section, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2287,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2288 | ierr = ISGetLocalSize(cellIS, &numCells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2288,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2289 | ierr = ISGetPointRange(cellIS, &cStart, &cEnd, &cells);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2289,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2290 | ierr = PetscObjectQuery((PetscObject) dm, "dmAux", (PetscObject *) &dmAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2290,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2291 | ierr = PetscObjectQuery((PetscObject) dm, "A", (PetscObject *) &A);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2291,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2292 | if (dmAux) { | |||
2293 | ierr = DMConvert(dmAux, DMPLEX"plex", &plexAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2293,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2294 | ierr = DMGetSection(plexAux, §ionAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2294,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2295 | ierr = DMGetDS(dmAux, &probAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2295,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2296 | ierr = PetscDSGetTotalDimension(probAux, &totDimAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2296,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2297 | } | |||
2298 | ierr = VecSet(Z, 0.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2298,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2299 | ierr = PetscMalloc6(numCells*totDim,&u,X_t ? numCells*totDim : 0,&u_t,numCells*totDim*totDim,&elemMat,hasDyn ? numCells*totDim*totDim : 0, &elemMatD,numCells*totDim,&y,totDim,&z)PetscMallocA(6,PETSC_FALSE,2299,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDim)*sizeof(**(&u)),(&u),(size_t )(X_t ? numCells*totDim : 0)*sizeof(**(&u_t)),(&u_t), (size_t)(numCells*totDim*totDim)*sizeof(**(&elemMat)),(& elemMat),(size_t)(hasDyn ? numCells*totDim*totDim : 0)*sizeof (**(&elemMatD)),(&elemMatD),(size_t)(numCells*totDim) *sizeof(**(&y)),(&y),(size_t)(totDim)*sizeof(**(& z)),(&z));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2299,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2300 | if (dmAux) {ierr = PetscMalloc1(numCells*totDimAux, &a)PetscMallocA(1,PETSC_FALSE,2300,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(numCells*totDimAux)*sizeof(**(&a)),(&a));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2300,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2301 | ierr = DMGetCoordinateField(dm, &coordField);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2301,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2302 | for (c = cStart; c < cEnd; ++c) { | |||
2303 | const PetscInt cell = cells ? cells[c] : c; | |||
2304 | const PetscInt cind = c - cStart; | |||
2305 | PetscScalar *x = NULL((void*)0), *x_t = NULL((void*)0); | |||
2306 | PetscInt i; | |||
2307 | ||||
2308 | ierr = DMPlexVecGetClosure(dm, section, X, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2308,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2309 | for (i = 0; i < totDim; ++i) u[cind*totDim+i] = x[i]; | |||
2310 | ierr = DMPlexVecRestoreClosure(dm, section, X, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2310,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2311 | if (X_t) { | |||
2312 | ierr = DMPlexVecGetClosure(dm, section, X_t, cell, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2312,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2313 | for (i = 0; i < totDim; ++i) u_t[cind*totDim+i] = x_t[i]; | |||
2314 | ierr = DMPlexVecRestoreClosure(dm, section, X_t, cell, NULL((void*)0), &x_t);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2314,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2315 | } | |||
2316 | if (dmAux) { | |||
2317 | PetscInt subcell; | |||
2318 | ierr = DMPlexGetAuxiliaryPoint(dm, dmAux, cell, &subcell);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2318,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2319 | ierr = DMPlexVecGetClosure(plexAux, sectionAux, A, subcell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2319,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2320 | for (i = 0; i < totDimAux; ++i) a[cind*totDimAux+i] = x[i]; | |||
2321 | ierr = DMPlexVecRestoreClosure(plexAux, sectionAux, A, subcell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2321,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2322 | } | |||
2323 | ierr = DMPlexVecGetClosure(dm, section, Y, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2323,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2324 | for (i = 0; i < totDim; ++i) y[cind*totDim+i] = x[i]; | |||
2325 | ierr = DMPlexVecRestoreClosure(dm, section, Y, cell, NULL((void*)0), &x);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2325,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2326 | } | |||
2327 | ierr = PetscMemzero(elemMat, numCells*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2327,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2328 | if (hasDyn) {ierr = PetscMemzero(elemMatD, numCells*totDim*totDim * sizeof(PetscScalar));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2328,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2329 | for (fieldI = 0; fieldI < Nf; ++fieldI) { | |||
2330 | PetscFE fe; | |||
2331 | PetscInt Nb; | |||
2332 | /* Conforming batches */ | |||
2333 | PetscInt numChunks, numBatches, numBlocks, Ne, blockSize, batchSize; | |||
2334 | /* Remainder */ | |||
2335 | PetscInt Nr, offset, Nq; | |||
2336 | PetscQuadrature qGeom = NULL((void*)0); | |||
2337 | PetscInt maxDegree; | |||
2338 | PetscFEGeom *cgeomFEM, *chunkGeom = NULL((void*)0), *remGeom = NULL((void*)0); | |||
2339 | ||||
2340 | ierr = PetscDSGetDiscretization(prob, fieldI, (PetscObject *) &fe);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2340,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2341 | ierr = PetscFEGetQuadrature(fe, &quad);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2341,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2342 | ierr = PetscFEGetDimension(fe, &Nb);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2342,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2343 | ierr = PetscFEGetTileSizes(fe, NULL((void*)0), &numBlocks, NULL((void*)0), &numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2343,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2344 | ierr = DMFieldGetDegree(coordField,cellIS,NULL((void*)0),&maxDegree);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2344,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2345 | if (maxDegree <= 1) {ierr = DMFieldCreateDefaultQuadrature(coordField,cellIS,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2345,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2346 | if (!qGeom) { | |||
2347 | ierr = PetscFEGetQuadrature(fe,&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2347,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2348 | ierr = PetscObjectReference((PetscObject)qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2348,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2349 | } | |||
2350 | ierr = PetscQuadratureGetData(qGeom, NULL((void*)0), NULL((void*)0), &Nq, NULL((void*)0), NULL((void*)0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2350,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2351 | ierr = DMSNESGetFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2351,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2352 | blockSize = Nb; | |||
2353 | batchSize = numBlocks * blockSize; | |||
2354 | ierr = PetscFESetTileSizes(fe, blockSize, numBlocks, batchSize, numBatches);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2354,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2355 | numChunks = numCells / (numBatches*batchSize); | |||
2356 | Ne = numChunks*numBatches*batchSize; | |||
2357 | Nr = numCells % (numBatches*batchSize); | |||
2358 | offset = numCells - Nr; | |||
2359 | ierr = PetscFEGeomGetChunk(cgeomFEM,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2359,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2360 | ierr = PetscFEGeomGetChunk(cgeomFEM,offset,numCells,&remGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2360,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2361 | for (fieldJ = 0; fieldJ < Nf; ++fieldJ) { | |||
2362 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMat);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2362,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2363 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN, fieldI, fieldJ, Nr, remGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, X_tShift, &elemMat[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2363,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2364 | if (hasDyn) { | |||
2365 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_DYN, fieldI, fieldJ, Ne, chunkGeom, u, u_t, probAux, a, t, X_tShift, elemMatD);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2365,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2366 | ierr = PetscFEIntegrateJacobian(fe, prob, PETSCFE_JACOBIAN_DYN, fieldI, fieldJ, Nr, remGeom, &u[offset*totDim], u_t ? &u_t[offset*totDim] : NULL((void*)0), probAux, &a[offset*totDimAux], t, X_tShift, &elemMatD[offset*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2366,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2367 | } | |||
2368 | } | |||
2369 | ierr = PetscFEGeomRestoreChunk(cgeomFEM,offset,numCells,&remGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2369,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2370 | ierr = PetscFEGeomRestoreChunk(cgeomFEM,0,offset,&chunkGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2370,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2371 | ierr = DMSNESRestoreFEGeom(coordField,cellIS,qGeom,PETSC_FALSE,&cgeomFEM);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2371,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2372 | ierr = PetscQuadratureDestroy(&qGeom);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2372,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2373 | } | |||
2374 | if (hasDyn) { | |||
2375 | for (c = 0; c < numCells*totDim*totDim; ++c) elemMat[c] += X_tShift*elemMatD[c]; | |||
2376 | } | |||
2377 | for (c = cStart; c < cEnd; ++c) { | |||
2378 | const PetscInt cell = cells ? cells[c] : c; | |||
2379 | const PetscInt cind = c - cStart; | |||
2380 | const PetscBLASInt M = totDim, one = 1; | |||
2381 | const PetscScalar a = 1.0, b = 0.0; | |||
2382 | ||||
2383 | PetscStackCallBLAS("BLASgemv", BLASgemv_("N", &M, &M, &a, &elemMat[cind*totDim*totDim], &M, &y[cind*totDim], &one, &b, z, &one))do { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = "BLASgemv"; petscstack->file[petscstack->currentsize ] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2383; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_TRUE || petscstack->hotdepth); } ; } while (0); dgemv_("N", &M, &M, &a, &elemMat[cind*totDim *totDim], &M, &y[cind*totDim], &one, &b, z, & one); do { do {PetscErrorCode _7_ierr = PetscMallocValidate(2383 ,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" );do {if (__builtin_expect(!!(_7_ierr),0)) return PetscError( ((MPI_Comm)0x44000001),2383,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,_7_ierr,PETSC_ERROR_REPEAT," ");} while (0);} while(0); do { ; if (petscstack && petscstack->currentsize > 0 ) { petscstack->currentsize--; petscstack->function[petscstack ->currentsize] = 0; petscstack->file[petscstack->currentsize ] = 0; petscstack->line[petscstack->currentsize] = 0; petscstack ->petscroutine[petscstack->currentsize] = PETSC_FALSE; } if (petscstack) { petscstack->hotdepth = (((petscstack-> hotdepth-1)<(0)) ? (0) : (petscstack->hotdepth-1)); } ; } while (0); } while (0); } while(0); | |||
2384 | if (mesh->printFEM > 1) { | |||
2385 | ierr = DMPrintCellMatrix(c, name, totDim, totDim, &elemMat[cind*totDim*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2385,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2386 | ierr = DMPrintCellVector(c, "Y", totDim, &y[cind*totDim]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2386,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2387 | ierr = DMPrintCellVector(c, "Z", totDim, z);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2387,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2388 | } | |||
2389 | ierr = DMPlexVecSetClosure(dm, section, Z, cell, z, ADD_VALUES);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2389,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2390 | } | |||
2391 | ierr = PetscFree6(u,u_t,elemMat,elemMatD,y,z)PetscFreeA(6,2391,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,&(u),&(u_t),&(elemMat),&(elemMatD),&(y), &(z));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2391,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2392 | if (mesh->printFEM) { | |||
2393 | ierr = PetscPrintf(PETSC_COMM_WORLD, "Z:\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2393,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2394 | ierr = VecView(Z, PETSC_VIEWER_STDOUT_WORLDPETSC_VIEWER_STDOUT_(PETSC_COMM_WORLD));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2394,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2395 | } | |||
2396 | ierr = PetscFree(a)((*PetscTrFree)((void*)(a),2396,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((a) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2396,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2397 | ierr = ISDestroy(&cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2397,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2398 | ierr = DMDestroy(&plexAux);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2398,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2399 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2399,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2400 | ierr = PetscLogEventEnd(DMPLEX_JacobianFEM,dm,0,0,0)(((PetscLogPLE && petsc_stageLog->stageInfo[petsc_stageLog ->curStage].perfInfo.active && petsc_stageLog-> stageInfo[petsc_stageLog->curStage].eventLog->eventInfo [DMPLEX_JacobianFEM].active) ? (*PetscLogPLE)((DMPLEX_JacobianFEM ),0,(PetscObject)(dm),(PetscObject)(0),(PetscObject)(0),(PetscObject )(0)) : 0 ));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2400,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2401 | 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); | |||
2402 | } | |||
2403 | ||||
2404 | /*@ | |||
2405 | DMPlexSNESComputeJacobianFEM - Form the local portion of the Jacobian matrix J at the local solution X using pointwise functions specified by the user. | |||
2406 | ||||
2407 | Input Parameters: | |||
2408 | + dm - The mesh | |||
2409 | . X - Local input vector | |||
2410 | - user - The user context | |||
2411 | ||||
2412 | Output Parameter: | |||
2413 | . Jac - Jacobian matrix | |||
2414 | ||||
2415 | Note: | |||
2416 | We form the residual one batch of elements at a time. This allows us to offload work onto an accelerator, | |||
2417 | like a GPU, or vectorize on a multicore machine. | |||
2418 | ||||
2419 | Level: developer | |||
2420 | ||||
2421 | .seealso: FormFunctionLocal() | |||
2422 | @*/ | |||
2423 | PetscErrorCode DMPlexSNESComputeJacobianFEM(DM dm, Vec X, Mat Jac, Mat JacP,void *user) | |||
2424 | { | |||
2425 | DM plex; | |||
2426 | PetscDS prob; | |||
2427 | IS cellIS; | |||
2428 | PetscBool hasJac, hasPrec; | |||
2429 | PetscInt depth; | |||
2430 | PetscErrorCode ierr; | |||
2431 | ||||
2432 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2432; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2433 | ierr = DMSNESConvertPlex(dm,&plex,PETSC_TRUE);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2433,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2434 | ierr = DMPlexGetDepth(plex, &depth);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2434,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2435 | ierr = DMGetStratumIS(plex, "dim", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2435,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2436 | if (!cellIS) {ierr = DMGetStratumIS(plex, "depth", depth, &cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2436,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2437 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2437,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2438 | ierr = PetscDSHasJacobian(prob, &hasJac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2438,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2439 | ierr = PetscDSHasJacobianPreconditioner(prob, &hasPrec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2439,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2440 | if (hasJac && hasPrec) {ierr = MatZeroEntries(Jac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2440,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2441 | ierr = MatZeroEntries(JacP);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2441,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2442 | ierr = DMPlexComputeJacobian_Internal(plex, cellIS, 0.0, 0.0, X, NULL((void*)0), Jac, JacP, user);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2442,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2443 | ierr = ISDestroy(&cellIS);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2443,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2444 | ierr = DMDestroy(&plex);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2444,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2445 | 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); | |||
2446 | } | |||
2447 | ||||
2448 | /*@ | |||
2449 | DMPlexSetSNESLocalFEM - Use DMPlex's internal FEM routines to compute SNES boundary values, residual, and Jacobian. | |||
2450 | ||||
2451 | Input Parameters: | |||
2452 | + dm - The DM object | |||
2453 | . boundaryctx - the user context that will be passed to pointwise evaluation of boundary values (see PetscDSAddBoundary()) | |||
2454 | . residualctx - the user context that will be passed to pointwise evaluation of finite element residual computations (see PetscDSSetResidual()) | |||
2455 | - jacobianctx - the user context that will be passed to pointwise evaluation of finite element Jacobian construction (see PetscDSSetJacobian()) | |||
2456 | ||||
2457 | Level: developer | |||
2458 | @*/ | |||
2459 | PetscErrorCode DMPlexSetSNESLocalFEM(DM dm, void *boundaryctx, void *residualctx, void *jacobianctx) | |||
2460 | { | |||
2461 | PetscErrorCode ierr; | |||
2462 | ||||
2463 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2463; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2464 | ierr = DMSNESSetBoundaryLocal(dm,DMPlexSNESComputeBoundaryFEM,boundaryctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2464,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2465 | ierr = DMSNESSetFunctionLocal(dm,DMPlexSNESComputeResidualFEM,residualctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2465,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2466 | ierr = DMSNESSetJacobianLocal(dm,DMPlexSNESComputeJacobianFEM,jacobianctx);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2466,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2467 | 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); | |||
2468 | } | |||
2469 | ||||
2470 | PetscErrorCode DMSNESCheckFromOptions_Internal(SNES snes, DM dm, Vec u, PetscErrorCode (**exactFuncs)(PetscInt, PetscReal, const PetscReal x[], PetscInt, PetscScalar *u, void *ctx), void **ctxs) | |||
2471 | { | |||
2472 | PetscErrorCode (**exacts)(PetscInt, PetscReal, const PetscReal x[], PetscInt, PetscScalar *u, void *ctx); | |||
2473 | PetscDS prob; | |||
2474 | Mat J, M; | |||
2475 | Vec r, b; | |||
2476 | MatNullSpace nullSpace; | |||
2477 | PetscReal *error, res = 0.0; | |||
2478 | PetscInt numFields; | |||
2479 | PetscBool hasJac, hasPrec; | |||
2480 | PetscInt Nf, f; | |||
2481 | PetscErrorCode ierr; | |||
2482 | ||||
2483 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2483; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2484 | ierr = DMGetNumFields(dm, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2484,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2485 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2485,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2486 | ierr = PetscMalloc1(Nf, &exacts)PetscMallocA(1,PETSC_FALSE,2486,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(Nf)*sizeof(**(&exacts)),(&exacts));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2486,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2487 | for (f = 0; f < Nf; ++f) {ierr = PetscDSGetExactSolution(prob, f, &exacts[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2487,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2488 | ierr = VecDuplicate(u, &r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2488,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2489 | ierr = DMCreateMatrix(dm, &J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2489,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2490 | /* TODO Null space for J */ | |||
2491 | /* Check discretization error */ | |||
2492 | ierr = DMGetNumFields(dm, &numFields);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2492,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2493 | ierr = PetscMalloc1(PetscMax(1, numFields), &error)PetscMallocA(1,PETSC_FALSE,2493,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)((((1)<(numFields)) ? (numFields) : (1)))*sizeof( **(&error)),(&error));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2493,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2494 | ierr = DMProjectFunction(dm, 0.0, exactFuncs ? exactFuncs : exacts, ctxs, INSERT_ALL_VALUES, u);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2494,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2495 | if (numFields > 1) { | |||
2496 | PetscInt f; | |||
2497 | ||||
2498 | ierr = DMComputeL2FieldDiff(dm, 0.0, exactFuncs ? exactFuncs : exacts, ctxs, u, error);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2498,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2499 | ierr = PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: [");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2499,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2500 | for (f = 0; f < numFields; ++f) { | |||
2501 | if (f) {ierr = PetscPrintf(PETSC_COMM_WORLD, ", ");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2501,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2502 | if (error[f] >= 1.0e-11) {ierr = PetscPrintf(PETSC_COMM_WORLD, "%g", (double)error[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2502,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2503 | else {ierr = PetscPrintf(PETSC_COMM_WORLD, "< 1.0e-11");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2503,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2504 | } | |||
2505 | ierr = PetscPrintf(PETSC_COMM_WORLD, "]\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2505,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2506 | } else { | |||
2507 | ierr = DMComputeL2Diff(dm, 0.0, exactFuncs ? exactFuncs : exacts, ctxs, u, &error[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2507,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2508 | if (error[0] >= 1.0e-11) {ierr = PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: %g\n", (double)error[0]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2508,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2509 | else {ierr = PetscPrintf(PETSC_COMM_WORLD, "L_2 Error: < 1.0e-11\n");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2509,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2510 | } | |||
2511 | ierr = PetscFree(error)((*PetscTrFree)((void*)(error),2511,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((error) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2511,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2512 | /* Check residual */ | |||
2513 | ierr = SNESComputeFunction(snes, u, r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2513,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2514 | ierr = VecNorm(r, NORM_2, &res);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2514,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2515 | ierr = PetscPrintf(PETSC_COMM_WORLD, "L_2 Residual: %g\n", (double)res);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2515,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2516 | ierr = VecChop(r, 1.0e-10);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2516,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2517 | ierr = PetscObjectSetName((PetscObject) r, "Initial Residual");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2517,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2518 | ierr = PetscObjectSetOptionsPrefix((PetscObject)r,"res_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2518,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2519 | ierr = VecViewFromOptions(r, NULL((void*)0), "-vec_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2519,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2520 | /* Check Jacobian */ | |||
2521 | ierr = PetscDSHasJacobian(prob, &hasJac);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2521,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2522 | ierr = PetscDSHasJacobianPreconditioner(prob, &hasPrec);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2522,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2523 | if (hasJac && hasPrec) { | |||
2524 | ierr = DMCreateMatrix(dm, &M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2524,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2525 | ierr = SNESComputeJacobian(snes, u, J, M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2525,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2526 | ierr = PetscObjectSetOptionsPrefix((PetscObject) M, "jacpre_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2526,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2527 | ierr = MatViewFromOptions(M, NULL((void*)0), "-mat_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2527,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2528 | ierr = MatDestroy(&M);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2528,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2529 | } else { | |||
2530 | ierr = SNESComputeJacobian(snes, u, J, J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2530,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2531 | } | |||
2532 | ierr = PetscObjectSetOptionsPrefix((PetscObject) J, "jac_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2532,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2533 | ierr = MatViewFromOptions(J, NULL((void*)0), "-mat_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2533,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2534 | ierr = MatGetNullSpace(J, &nullSpace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2534,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2535 | if (nullSpace) { | |||
2536 | PetscBool isNull; | |||
2537 | ierr = MatNullSpaceTest(nullSpace, J, &isNull);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2537,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2538 | if (!isNull) SETERRQ(PETSC_COMM_WORLD, PETSC_ERR_PLIB, "The null space calculated for the system operator is invalid.")return PetscError(PETSC_COMM_WORLD,2538,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,77,PETSC_ERROR_INITIAL,"The null space calculated for the system operator is invalid." ); | |||
2539 | } | |||
2540 | ierr = VecDuplicate(u, &b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2540,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2541 | ierr = VecSet(r, 0.0);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2541,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2542 | ierr = SNESComputeFunction(snes, r, b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2542,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2543 | ierr = MatMult(J, u, r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2543,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2544 | ierr = VecAXPY(r, 1.0, b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2544,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2545 | ierr = VecDestroy(&b);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2545,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2546 | ierr = VecNorm(r, NORM_2, &res);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2546,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2547 | ierr = PetscPrintf(PETSC_COMM_WORLD, "Linear L_2 Residual: %g\n", (double)res);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2547,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2548 | ierr = VecChop(r, 1.0e-10);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2548,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2549 | ierr = PetscObjectSetName((PetscObject) r, "Au - b = Au + F(0)");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2549,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2550 | ierr = PetscObjectSetOptionsPrefix((PetscObject)r,"linear_res_");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2550,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2551 | ierr = VecViewFromOptions(r, NULL((void*)0), "-vec_view");CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2551,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2552 | ierr = VecDestroy(&r);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2552,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2553 | ierr = MatNullSpaceDestroy(&nullSpace);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2553,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2554 | ierr = MatDestroy(&J);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2554,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2555 | ierr = PetscFree(exacts)((*PetscTrFree)((void*)(exacts),2555,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((exacts) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2555,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2556 | 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); | |||
2557 | } | |||
2558 | ||||
2559 | /*@C | |||
2560 | DMSNESCheckFromOptions - Check the residual and Jacobian functions using the exact solution by outputting some diagnostic information | |||
2561 | ||||
2562 | Input Parameters: | |||
2563 | + snes - the SNES object | |||
2564 | . u - representative SNES vector | |||
2565 | . exactFuncs - pointwise functions of the exact solution for each field | |||
2566 | - ctxs - contexts for the functions | |||
2567 | ||||
2568 | Level: developer | |||
2569 | @*/ | |||
2570 | PetscErrorCode DMSNESCheckFromOptions(SNES snes, Vec u, PetscErrorCode (**exactFuncs)(PetscInt dim, PetscReal time, const PetscReal x[], PetscInt Nf, PetscScalar *u, void *ctx), void **ctxs) | |||
2571 | { | |||
2572 | PetscErrorCode (**exact)(PetscInt, PetscReal, const PetscReal[], PetscInt, PetscScalar *, void *) = NULL((void*)0); | |||
2573 | DM dm; | |||
2574 | PetscDS prob; | |||
2575 | Vec sol; | |||
2576 | PetscBool check; | |||
2577 | PetscInt Nf, f; | |||
2578 | PetscErrorCode ierr; | |||
2579 | ||||
2580 | PetscFunctionBegindo { do { ; if (petscstack && (petscstack->currentsize < 64)) { petscstack->function[petscstack->currentsize ] = __func__; petscstack->file[petscstack->currentsize] = "/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ; petscstack->line[petscstack->currentsize] = 2580; petscstack ->petscroutine[petscstack->currentsize] = PETSC_TRUE; petscstack ->currentsize++; } if (petscstack) { petscstack->hotdepth += (PETSC_FALSE || petscstack->hotdepth); } ; } while (0) ; ; } while (0); | |||
2581 | ierr = PetscOptionsHasName(((PetscObject)snes)->options,((PetscObject)snes)->prefix, "-dmsnes_check", &check);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2581,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2582 | if (!check) 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); | |||
2583 | ierr = SNESGetDM(snes, &dm);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2583,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2584 | ierr = DMGetDS(dm, &prob);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2584,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2585 | if (!exactFuncs) { | |||
2586 | ierr = PetscDSGetNumFields(prob, &Nf);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2586,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2587 | ierr = PetscMalloc1(Nf, &exact)PetscMallocA(1,PETSC_FALSE,2587,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,(size_t)(Nf)*sizeof(**(&exact)),(&exact));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2587,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2588 | for (f = 0; f < Nf; ++f) {ierr = PetscDSGetExactSolution(prob, f, &exact[f]);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2588,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0);} | |||
2589 | } | |||
2590 | ierr = VecDuplicate(u, &sol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2590,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2591 | ierr = SNESSetSolution(snes, sol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2591,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2592 | ierr = DMSNESCheckFromOptions_Internal(snes, dm, sol, exactFuncs ? exactFuncs : exact, ctxs);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2592,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2593 | ierr = VecDestroy(&sol);CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2593,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2594 | ierr = PetscFree(exact)((*PetscTrFree)((void*)(exact),2594,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ) || ((exact) = 0,0));CHKERRQ(ierr)do {if (__builtin_expect(!!(ierr),0)) return PetscError(((MPI_Comm )0x44000001),2594,__func__,"/sandbox/petsc/petsc.next-tmp/src/snes/utils/dmplexsnes.c" ,ierr,PETSC_ERROR_REPEAT," ");} while (0); | |||
2595 | 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); | |||
2596 | } |