7 int nDOF_trial_element,
11 int* freeGlobal_trial,
17 int hasDiffusionInMixedForm,
18 int needNumericalFluxJacobian,
19 int nElementBoundaries_element,
20 int* elementNeighborsArray,
21 int nInteriorElementBoundaries_global,
22 int* interiorElementBoundariesArray,
23 int* elementBoundaryElementsArray,
24 int* elementBoundaryLocalElementBoundariesArray,
25 int hasFluxBoundaryConditions,
26 int nExteriorElementBoundaries_global,
27 int* exteriorElementBoundariesArray,
28 int hasOutflowBoundary,
29 int needOutflowJacobian)
32 for(
int eN=0;eN<nElements_global;eN++)
34 for(
int ii=0;ii<nFreeDOF_test[eN];ii++)
36 int I = offset_test + stride_test*freeGlobal_test[eN*nDOF_test_element+ii];
37 for(
int jj=0;jj<nFreeDOF_trial[eN];jj++)
39 int J = offset_trial + stride_trial*freeGlobal_trial[eN*nDOF_trial_element+jj];
40 columnIndecesMap[I].insert(J);
44 if (hasNumericalFlux &&
45 hasDiffusionInMixedForm &&
46 needNumericalFluxJacobian)
48 for(
int ebN=0;ebN<nElementBoundaries_element;ebN++)
50 int eN_ebN = elementNeighborsArray[eN*nElementBoundaries_element + ebN];
53 for (
int ii=0;ii<nFreeDOF_test[eN];ii++)
55 int I = offset_test + stride_test*freeGlobal_test[eN*nDOF_test_element+ii];
56 for (
int jj=0;jj<nFreeDOF_trial[eN_ebN];jj++)
58 int J = offset_trial + stride_trial*freeGlobal_trial[eN_ebN*nDOF_trial_element+jj];
59 columnIndecesMap[I].insert(J);
67 if (hasNumericalFlux &&
68 needNumericalFluxJacobian)
70 for(
int ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
72 int ebN = interiorElementBoundariesArray[ebNI],
73 left_eN_global = elementBoundaryElementsArray[ebN*2 + 0],
74 right_eN_global = elementBoundaryElementsArray[ebN*2 + 1];
77 for(
int ii=0;ii<nFreeDOF_test[left_eN_global];ii++)
79 int left_I = offset_test+stride_test*freeGlobal_test[left_eN_global*nDOF_test_element + ii];
80 for (
int jj=0;jj<nFreeDOF_trial[left_eN_global];jj++)
82 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_global*nDOF_trial_element + jj];
83 columnIndecesMap[left_I].insert(left_J);
85 for (
int jj=0;jj<nFreeDOF_trial[right_eN_global];jj++)
87 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_global*nDOF_trial_element + jj];
88 columnIndecesMap[left_I].insert(right_J);
91 for(
int ii=0;ii<nFreeDOF_test[right_eN_global];ii++)
93 int right_I = offset_test+stride_test*freeGlobal_test[right_eN_global*nDOF_test_element+ii];
94 for(
int jj=0;jj<nFreeDOF_trial[left_eN_global];jj++)
96 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_global*nDOF_trial_element+jj];
97 columnIndecesMap[right_I].insert(left_J);
99 for(
int jj=0;jj<nFreeDOF_trial[right_eN_global];jj++)
101 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_global*nDOF_trial_element+jj];
102 columnIndecesMap[right_I].insert(right_J);
105 if(hasDiffusionInMixedForm)
107 for(
int ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
109 int left_eN_ebN = elementNeighborsArray[left_eN_global*nElementBoundaries_element+ebN_eN],
110 right_eN_ebN = elementNeighborsArray[right_eN_global*nElementBoundaries_element+ebN_eN];
111 for(
int ii=0;ii<nFreeDOF_test[left_eN_global];ii++)
113 int left_I = offset_test+stride_test*freeGlobal_test[left_eN_global*nDOF_test_element+ii];
116 for (
int jj=0;jj<nFreeDOF_trial[left_eN_ebN];jj++)
118 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_ebN*nDOF_trial_element+jj];
119 columnIndecesMap[left_I].insert(left_J);
122 if(right_eN_ebN >= 0)
124 for(
int jj=0;jj<nFreeDOF_trial[right_eN_ebN];jj++)
126 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_ebN*nDOF_trial_element+jj];
127 columnIndecesMap[left_I].insert(right_J);
131 for(
int ii=0;ii<nFreeDOF_test[right_eN_global];ii++)
133 int right_I = offset_test+stride_test*freeGlobal_test[right_eN_global*nDOF_test_element+ii];
136 for(
int jj=0;jj<nFreeDOF_trial[left_eN_ebN];jj++)
138 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_ebN*nDOF_trial_element+jj];
139 columnIndecesMap[right_I].insert(left_J);
142 if(right_eN_ebN >= 0)
144 for(
int jj=0;jj<nFreeDOF_trial[right_eN_ebN];jj++)
146 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_ebN*nDOF_trial_element+jj];
147 columnIndecesMap[right_I].insert(right_J);
156 if ((hasNumericalFlux &&
157 needNumericalFluxJacobian) ||
158 (hasOutflowBoundary &&
159 needOutflowJacobian))
161 for(
int ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
163 int ebN = exteriorElementBoundariesArray[ebNE],
164 eN_global = elementBoundaryElementsArray[ebN*2+0];
166 for (
int ii=0;ii<nFreeDOF_test[eN_global];ii++)
168 int I = offset_test+stride_test*freeGlobal_test[eN_global*nDOF_test_element+ii];
169 for (
int jj=0;jj<nFreeDOF_trial[eN_global];jj++)
171 int J = offset_trial+stride_trial*freeGlobal_trial[eN_global*nDOF_trial_element+jj];
172 columnIndecesMap[I].insert(J);
175 if(hasNumericalFlux &&
176 hasDiffusionInMixedForm)
178 for(
int ebN_eN=0;ebN_eN < nElementBoundaries_element;ebN_eN++)
180 int eN_ebN = elementNeighborsArray[eN_global*nElementBoundaries_element+ebN_eN];
181 for (
int ii=0;ii<nFreeDOF_test[eN_global];ii++)
183 int I = offset_test + stride_test*freeGlobal_test[eN_global*nDOF_test_element+ii];
186 for(
int jj=0;jj<nFreeDOF_trial[eN_ebN];jj++)
188 int J = offset_trial+stride_trial*freeGlobal_trial[eN_ebN*nDOF_trial_element+jj];
189 columnIndecesMap[I].insert(J);
207 int nDOF_test_element,
208 int nDOF_trial_element,
210 int* freeGlobal_test,
212 int* freeGlobal_trial,
217 int hasNumericalFlux,
218 int hasDiffusionInMixedForm,
219 int needNumericalFluxJacobian,
220 int nElementBoundaries_element,
221 int* elementNeighborsArray,
222 int nInteriorElementBoundaries_global,
223 int* interiorElementBoundariesArray,
224 int* elementBoundaryElementsArray,
225 int* elementBoundaryLocalElementBoundariesArray,
226 int hasFluxBoundaryConditions,
227 int nExteriorElementBoundaries_global,
228 int* exteriorElementBoundariesArray,
229 int hasOutflowBoundary,
230 int needOutflowJacobian,
233 int* csrColumnOffsets,
234 int* csrColumnOffsets_eNebN,
235 int* csrColumnOffsets_eb,
236 int* csrColumnOffsets_eb_eNebN)
239 for(
int eN=0;eN<nElements_global;eN++)
241 for(
int ii=0;ii<nFreeDOF_test[eN];ii++)
243 int I = offset_test + stride_test*freeGlobal_test[eN*nDOF_test_element+ii];
244 csrRowIndeces[eN*nDOF_test_element+ii] =
rowptr[I];
245 for(
int jj=0;jj<nFreeDOF_trial[eN];jj++)
247 int J = offset_trial + stride_trial*freeGlobal_trial[eN*nDOF_trial_element+jj];
248 csrColumnOffsets[eN*nDOF_test_element*nDOF_trial_element+
249 ii*nDOF_trial_element+
250 jj] = columnOffsetsMap[I][J];
254 if (hasNumericalFlux &&
255 hasDiffusionInMixedForm &&
256 needNumericalFluxJacobian)
258 for(
int ebN=0;ebN<nElementBoundaries_element;ebN++)
260 int eN_ebN = elementNeighborsArray[eN*nElementBoundaries_element + ebN];
263 for (
int ii=0;ii<nFreeDOF_test[eN];ii++)
265 int I = offset_test + stride_test*freeGlobal_test[eN*nDOF_test_element+ii];
266 for (
int jj=0;jj<nFreeDOF_trial[eN_ebN];jj++)
268 int J = offset_trial + stride_trial*freeGlobal_trial[eN_ebN*nDOF_trial_element+jj];
269 csrColumnOffsets_eNebN[eN*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
270 ebN*nDOF_test_element*nDOF_trial_element+
271 ii*nDOF_test_element+
272 jj] = columnOffsetsMap[I][J];
280 if (hasNumericalFlux &&
281 needNumericalFluxJacobian)
283 for(
int ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
285 int ebN = interiorElementBoundariesArray[ebNI],
286 left_eN_global = elementBoundaryElementsArray[ebN*2 + 0],
287 right_eN_global = elementBoundaryElementsArray[ebN*2 + 1];
290 for(
int ii=0;ii<nFreeDOF_test[left_eN_global];ii++)
292 int left_I = offset_test+stride_test*freeGlobal_test[left_eN_global*nDOF_test_element + ii];
293 for (
int jj=0;jj<nFreeDOF_trial[left_eN_global];jj++)
295 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_global*nDOF_trial_element + jj];
296 csrColumnOffsets_eb[ebN*2*2*nDOF_test_element*nDOF_trial_element+
297 0*2*nDOF_test_element*nDOF_trial_element+
298 0*nDOF_test_element*nDOF_trial_element+
299 ii*nDOF_trial_element+
300 jj] = columnOffsetsMap[left_I][left_J];
302 for (
int jj=0;jj<nFreeDOF_trial[right_eN_global];jj++)
304 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_global*nDOF_trial_element + jj];
305 csrColumnOffsets_eb[ebN*2*2*nDOF_test_element*nDOF_trial_element+
306 0*2*nDOF_test_element*nDOF_trial_element+
307 1*nDOF_test_element*nDOF_trial_element+
308 ii*nDOF_trial_element+
309 jj] = columnOffsetsMap[left_I][right_J];
312 for(
int ii=0;ii<nFreeDOF_test[right_eN_global];ii++)
314 int right_I = offset_test+stride_test*freeGlobal_test[right_eN_global*nDOF_test_element+ii];
315 for(
int jj=0;jj<nFreeDOF_trial[left_eN_global];jj++)
317 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_global*nDOF_trial_element+jj];
318 csrColumnOffsets_eb[ebN*2*2*nDOF_test_element*nDOF_trial_element+
319 1*2*nDOF_test_element*nDOF_trial_element+
320 0*nDOF_test_element*nDOF_trial_element+
321 ii*nDOF_trial_element+
322 jj] = columnOffsetsMap[right_I][left_J];
324 for(
int jj=0;jj<nFreeDOF_trial[right_eN_global];jj++)
326 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_global*nDOF_trial_element+jj];
327 csrColumnOffsets_eb[ebN*2*2*nDOF_test_element*nDOF_trial_element+
328 1*2*nDOF_test_element*nDOF_trial_element+
329 1*nDOF_test_element*nDOF_trial_element+
330 ii*nDOF_trial_element+
331 jj] = columnOffsetsMap[right_I][right_J];
334 if(hasDiffusionInMixedForm)
336 for(
int ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
338 int left_eN_ebN = elementNeighborsArray[left_eN_global*nElementBoundaries_element+ebN_eN],
339 right_eN_ebN = elementNeighborsArray[right_eN_global*nElementBoundaries_element+ebN_eN];
340 for(
int ii=0;ii<nFreeDOF_test[left_eN_global];ii++)
342 int left_I = offset_test+stride_test*freeGlobal_test[left_eN_global*nDOF_test_element+ii];
345 for (
int jj=0;jj<nFreeDOF_trial[left_eN_ebN];jj++)
347 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_ebN*nDOF_trial_element+jj];
348 csrColumnOffsets_eb_eNebN[ebN*2*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
349 0*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
350 0*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
351 ebN_eN*nDOF_test_element*nDOF_trial_element+
352 ii*nDOF_trial_element+
353 jj] = columnOffsetsMap[left_I][left_J];
356 if(right_eN_ebN >= 0)
358 for(
int jj=0;jj<nFreeDOF_trial[right_eN_ebN];jj++)
360 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_ebN*nDOF_trial_element+jj];
361 csrColumnOffsets_eb_eNebN[ebN*2*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
362 0*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
363 1*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
364 ebN_eN*nDOF_test_element*nDOF_trial_element+
365 ii*nDOF_trial_element+
366 jj] = columnOffsetsMap[left_I][right_J];
370 for(
int ii=0;ii<nFreeDOF_test[right_eN_global];ii++)
372 int right_I = offset_test+stride_test*freeGlobal_test[right_eN_global*nDOF_test_element+ii];
375 for(
int jj=0;jj<nFreeDOF_trial[left_eN_ebN];jj++)
377 int left_J = offset_trial+stride_trial*freeGlobal_trial[left_eN_ebN*nDOF_trial_element+jj];
378 csrColumnOffsets_eb_eNebN[ebN*2*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
379 1*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
380 0*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
381 ebN_eN*nDOF_test_element*nDOF_trial_element+
382 ii*nDOF_trial_element+
383 jj] = columnOffsetsMap[right_I][left_J];
386 if(right_eN_ebN >= 0)
388 for(
int jj=0;jj<nFreeDOF_trial[right_eN_ebN];jj++)
390 int right_J = offset_trial+stride_trial*freeGlobal_trial[right_eN_ebN*nDOF_trial_element+jj];
391 csrColumnOffsets_eb_eNebN[ebN*2*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
392 1*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
393 1*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
394 ebN_eN*nDOF_test_element*nDOF_trial_element+
395 ii*nDOF_trial_element+
396 jj] = columnOffsetsMap[right_I][right_J];
405 if ((hasNumericalFlux &&
406 needNumericalFluxJacobian) ||
407 (hasOutflowBoundary &&
408 needOutflowJacobian))
410 for(
int ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
412 int ebN = exteriorElementBoundariesArray[ebNE],
413 eN_global = elementBoundaryElementsArray[ebN*2+0];
415 for (
int ii=0;ii<nFreeDOF_test[eN_global];ii++)
417 int I = offset_test+stride_test*freeGlobal_test[eN_global*nDOF_test_element+ii];
418 for (
int jj=0;jj<nFreeDOF_trial[eN_global];jj++)
420 int J = offset_trial+stride_trial*freeGlobal_trial[eN_global*nDOF_trial_element+jj];
421 csrColumnOffsets_eb[ebN*2*2*nDOF_test_element*nDOF_trial_element+
422 0*2*nDOF_test_element*nDOF_trial_element+
423 0*nDOF_test_element*nDOF_trial_element+
424 ii*nDOF_trial_element+
425 jj] = columnOffsetsMap[I][J];
428 if(hasNumericalFlux &&
429 hasDiffusionInMixedForm)
431 for(
int ebN_eN=0;ebN_eN < nElementBoundaries_element;ebN_eN++)
433 int eN_ebN = elementNeighborsArray[eN_global*nElementBoundaries_element+ebN_eN];
434 for (
int ii=0;ii<nFreeDOF_test[eN_global];ii++)
436 int I = offset_test + stride_test*freeGlobal_test[eN_global*nDOF_test_element+ii];
439 for(
int jj=0;jj<nFreeDOF_trial[eN_ebN];jj++)
441 int J = offset_trial+stride_trial*freeGlobal_trial[eN_ebN*nDOF_trial_element+jj];
442 csrColumnOffsets_eb_eNebN[ebN*2*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
443 0*2*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
444 0*nElementBoundaries_element*nDOF_test_element*nDOF_trial_element+
445 ebN_eN*nDOF_test_element*nDOF_trial_element+
446 ii*nDOF_trial_element+
447 jj] = columnOffsetsMap[I][J];
466 nrows = int(columnIndecesMap.size())+1;
469 for(
int I=1;I< columnIndecesMap.size()+1;I++)
470 rowptr[I]=
rowptr[I-1] +
int(columnIndecesMap[I-1].size());
475 for(
int I=0;I< columnIndecesMap.size();I++)
478 for(std::set<int>::iterator sit=columnIndecesMap[I].begin();sit != columnIndecesMap[I].end();sit++)
480 columnOffsetsMap[I][*sit] = offset;