proteus  1.8.1
C/C++/Fortran libraries
femIntegrals.c
Go to the documentation of this file.
1 #include <stdlib.h>
2 #include <stdio.h>
3 #include <math.h>
4 #include <string.h>
5 #include <strings.h>
6 #include <assert.h>
7 #include "femIntegrals.h"
8 #include PROTEUS_LAPACK_H
9 
20 void copyLeftElementBoundaryInfo(int nElementBoundaries_element,
21  int nElementBoundaryQuadraturePoints_elementBoundary,
22  int nSpace_global,
23  int nExteriorElementBoundaries_global,
24  int nInteriorElementBoundaries_global,
25  int* elementBoundaryElementsArray,
26  int* elementBoundaryLocalElementBoundariesArray,
27  int* exteriorElementBoundariesArray,
28  int* interiorElementBoundariesArray,
29  double* x,
30  double* n,
31  double* xg,
32  double* ng)
33 {
34  int ebNE,ebNI,ebN,k,left_eN_global,left_ebN_element,right_eN_global,right_ebN_element,I;
35  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
36  {
37  ebN = exteriorElementBoundariesArray[ebNE];
38  left_eN_global = elementBoundaryElementsArray[ebN*2+0];
39  left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
40  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
41  for (I=0;I<nSpace_global;I++)
42  {
43  xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
44  k*3+
45  I] =
46  x[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
47  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
48  k*3+
49  I];
50  ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
51  k*nSpace_global+
52  I] =
53  n[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
54  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
55  k*nSpace_global+
56  I];
57  }
58  }
59  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
60  {
61  ebN = interiorElementBoundariesArray[ebNI];
62  left_eN_global = elementBoundaryElementsArray[ebN*2+0];
63  left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
64  right_eN_global = elementBoundaryElementsArray[ebN*2+1];
65  right_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+1];
66  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
67  for (I=0;I<nSpace_global;I++)
68  {
69  xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
70  k*3+
71  I] =
72  x[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
73  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
74  k*3+
75  I];
76  ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
77  k*nSpace_global+
78  I] =
79  n[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
80  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
81  k*nSpace_global+
82  I];
83  x[right_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
84  right_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
85  k*3+
86  I]=
87  x[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
88  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
89  k*3+
90  I];
91  n[right_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
92  right_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
93  k*nSpace_global+
94  I]=
95  -n[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
96  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
97  k*nSpace_global+
98  I];
99  }
100  }
101 }
102 
103 void copyGlobalElementBoundaryInfo(int nElementBoundaries_element,
104  int nElementBoundaryQuadraturePoints_elementBoundary,
105  int nSpace_global,
106  int nExteriorElementBoundaries_global,
107  int nInteriorElementBoundaries_global,
108  int* elementBoundaryElementsArray,
109  int* elementBoundaryLocalElementBoundariesArray,
110  int* exteriorElementBoundariesArray,
111  int* interiorElementBoundariesArray,
112  double* x,
113  double* n,
114  double* ebqe_x,
115  double* ebqe_n,
116  double* xg,
117  double* ng)
118 {
119  int ebNE,ebNI,ebN,k,left_eN_global,left_ebN_element,right_eN_global,right_ebN_element,I,J;
120  double dot,sign;
121  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
122  {
123  ebN = exteriorElementBoundariesArray[ebNE];
124  left_eN_global = elementBoundaryElementsArray[ebN*2+0];
125  left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
126  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
127  {
128  dot=0.0;
129  for (J=0;J<nSpace_global;J++)
130  dot+= ebqe_n[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
131  k*nSpace_global+
132  J]*
133  ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
134  k*nSpace_global+
135  J];
136  if(dot < 0.0)
137  sign=-1.0;
138  else
139  sign=1.0;
140 
141  for (I=0;I<nSpace_global;I++)
142  {
143  x[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
144  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
145  k*3+
146  I] = xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
147  k*3+
148  I];
149  n[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
150  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
151  k*nSpace_global+
152  I] =
153  ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
154  k*nSpace_global+
155  I];
156  ebqe_x[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*3+
157  k*3+
158  I] = xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
159  k*3+
160  I];
161  ebqe_n[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
162  k*nSpace_global+
163  I]=
164  sign*ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
165  k*nSpace_global+
166  I];
167  }
168  }
169  }
170  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
171  {
172  ebN = interiorElementBoundariesArray[ebNI];
173  left_eN_global = elementBoundaryElementsArray[ebN*2+0];
174  left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
175  right_eN_global = elementBoundaryElementsArray[ebN*2+1];
176  right_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+1];
177  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
178  for (I=0;I<nSpace_global;I++)
179  {
180  x[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
181  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
182  k*3+
183  I] = xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
184  k*3+
185  I];
186  n[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
187  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
188  k*nSpace_global+
189  I] = ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
190  k*nSpace_global+
191  I];
192  x[right_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
193  right_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
194  k*3+
195  I] = xg[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
196  k*3+
197  I];
198  n[right_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
199  right_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
200  k*nSpace_global+
201  I] = -ng[ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global+
202  k*nSpace_global+
203  I];
204  }
205  }
206 }
207 
208 void copyLeftElementBoundaryInfo_movingDomain(int nElementBoundaries_element,
209  int nElementBoundaryQuadraturePoints_elementBoundary,
210  int nExteriorElementBoundaries_global,
211  int nInteriorElementBoundaries_global,
212  int* elementBoundaryElementsArray,
213  int* elementBoundaryLocalElementBoundariesArray,
214  int* exteriorElementBoundariesArray,
215  int* interiorElementBoundariesArray,
216  double* xt)
217 {
218  int ebNI,ebN,k,left_eN_global,left_ebN_element,right_eN_global,right_ebN_element,I;
219  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
220  {
221  ebN = interiorElementBoundariesArray[ebNI];
222  left_eN_global = elementBoundaryElementsArray[ebN*2+0];
223  left_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
224  right_eN_global = elementBoundaryElementsArray[ebN*2+1];
225  right_ebN_element = elementBoundaryLocalElementBoundariesArray[ebN*2+1];
226  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
227  for (I=0;I<3;I++)
228  {
229  xt[right_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
230  right_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
231  k*3+
232  I]=
233  xt[left_eN_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
234  left_ebN_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
235  k*3+
236  I];
237  }
238  }
239 }
240 
241 void parametricFiniteElementSpace_getValues(int nElements_global,
242  int nQuadraturePoints_element,
243  int nDOF_element,
244  double* psi,
245  double* vArray)
246 {
247  int eN,k,j;
248  for(eN=0;eN<nElements_global;eN++)
249  for(k=0;k<nQuadraturePoints_element;k++)
250  for(j=0;j<nDOF_element;j++)
251  vArray[eN*nQuadraturePoints_element*nDOF_element+
252  k*nDOF_element+
253  j]
254  =
255  psi[k*nDOF_element+
256  j];
257 }
258 
260  int nElementBoundaries_element,
261  int nElementBoundaryQuadraturePoints_elementBoundary,
262  int nDOF_element,
263  double* psi,
264  int* permutations,
265  double* vArray)
266 {
267  int eN,ebN,k,j;
268  for(eN=0;eN<nElements_global;eN++)
269  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
270  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
271  for(j=0;j<nDOF_element;j++)
272  vArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
273  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
274  k*nDOF_element+
275  j]
276  =
277  psi[permutations[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary+
278  ebN*nElementBoundaryQuadraturePoints_elementBoundary+
279  k]*nDOF_element+
280  j];
281 }
282 
284  int nElementBoundaryQuadraturePoints_elementBoundary,
285  int nDOF_element,
286  int nExteriorElementBoundaries_global,
287  const int* exteriorElementBoundariesArray,
288  const int* elementBoundaryElementsArray,
289  const int* elementBoundaryLocalElementBoundariesArray,
290  double* psi,
291  double* vArray)
292 {
293  int eN,ebN,ebNE,ebN_local,k,j;
294  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
295  {
296  ebN = exteriorElementBoundariesArray[ebNE];
297  eN = elementBoundaryElementsArray[ebN*2+0];
298  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
299  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
300  for(j=0;j<nDOF_element;j++)
301  vArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
302  k*nDOF_element+
303  j]
304  =
305  psi[ebN_local*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element +
306  k*nDOF_element +
307  j];
308  }
309 }
310 
312  int nQuadraturePoints_element,
313  int nDOF_element,
314  int nSpace_global,
315  double* grad_psi,
316  double* inverseJacobianArray,
317  double* grad_vArray)
318 {
319  int eN,k,j,I,J,nSpace_global2 = nSpace_global*nSpace_global;
320  for(eN=0;eN<nElements_global;eN++)
321  for(k=0;k<nQuadraturePoints_element;k++)
322  for(j=0;j<nDOF_element;j++)
323  for (I=0;I<nSpace_global;I++)
324  for (J=0;J<nSpace_global;J++)
325  grad_vArray[eN*nQuadraturePoints_element*nDOF_element*nSpace_global+
326  k*nDOF_element*nSpace_global+
327  j*nSpace_global+
328  I]
329  +=
330  grad_psi[k*nDOF_element*nSpace_global+
331  j*nSpace_global+
332  J]
333  *
334  inverseJacobianArray[eN*nQuadraturePoints_element*nSpace_global2+
335  k*nSpace_global2+
336  J*nSpace_global+
337  I];
338 }
339 
341  int nQuadraturePoints_element,
342  int nDOF_element,
343  int nSpace_global,
344  double* Hessian_psi,
345  double* inverseJacobianArray,
346  double* Hessian_vArray)
347 {
348  int eN,k,j,I,J,K,L,nSpace_global2 = nSpace_global*nSpace_global;
349  for(eN=0;eN<nElements_global;eN++)
350  for(k=0;k<nQuadraturePoints_element;k++)
351  for(j=0;j<nDOF_element;j++)
352  for (I=0;I<nSpace_global;I++)
353  for (J=0;J<nSpace_global;J++)
354  for (K=0;K<nSpace_global;K++)
355  for (L=0;L<nSpace_global;L++)
356  Hessian_vArray[eN*nQuadraturePoints_element*nDOF_element*nSpace_global2+
357  k*nDOF_element*nSpace_global2+
358  j*nSpace_global2+
359  I*nSpace_global+
360  J]
361  +=
362  Hessian_psi[k*nDOF_element*nSpace_global2+
363  j*nSpace_global2+
364  K*nSpace_global+
365  L]
366  *
367  inverseJacobianArray[eN*nQuadraturePoints_element*nSpace_global2+
368  k*nSpace_global2+
369  L*nSpace_global+
370  J]
371  *
372  inverseJacobianArray[eN*nQuadraturePoints_element*nSpace_global2+
373  k*nSpace_global2+
374  K*nSpace_global+
375  I];
376 }
377 
379  int nElementBoundaries_element,
380  int nElementBoundaryQuadraturePoints_elementBoundary,
381  int nDOF_element,
382  int nSpace_global,
383  double* grad_psi,
384  int* permutations,
385  double* inverseJacobianArray,
386  double* grad_vArray)
387 {
388  int eN,ebN,k,j,I,J,nSpace_global2 = nSpace_global*nSpace_global;
389  for(eN=0;eN<nElements_global;eN++)
390  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
391  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
392  for(j=0;j<nDOF_element;j++)
393  for (I=0;I<nSpace_global;I++)
394  for (J=0;J<nSpace_global;J++)
395  grad_vArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace_global+
396  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace_global+
397  k*nDOF_element*nSpace_global+
398  j*nSpace_global+
399  I]
400  +=
401  grad_psi[permutations[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary+
402  ebN*nElementBoundaryQuadraturePoints_elementBoundary+
403  k]*nDOF_element*nSpace_global+
404  j*nSpace_global+
405  J]
406  *
407  inverseJacobianArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
408  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
409  k*nSpace_global2+
410  J*nSpace_global+
411  I];
412 }
413 
415  int nElementBoundaryQuadraturePoints_elementBoundary,
416  int nDOF_element,
417  int nSpace_global,
418  int nExteriorElementBoundaries_global,
419  const int *exteriorElementBoundariesArray,
420  const int *elementBoundaryElementsArray,
421  const int *elementBoundaryLocalElementBoundariesArray,
422  double* grad_psi,
423  double* inverseJacobianArray,
424  double* grad_vArray)
425 {
426  int ebN,ebNE,ebN_local,eN,k,j,I,J,nSpace_global2 = nSpace_global*nSpace_global;
427  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
428  {
429  ebN = exteriorElementBoundariesArray[ebNE];
430  eN = elementBoundaryElementsArray[ebN*2+0];
431  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
432  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
433  for(j=0;j<nDOF_element;j++)
434  for (I=0;I<nSpace_global;I++)
435  for (J=0;J<nSpace_global;J++)
436  grad_vArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace_global+
437  k*nDOF_element*nSpace_global+
438  j*nSpace_global+
439  I]
440  +=
441  grad_psi[ebN_local*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace_global+
442  k*nDOF_element*nSpace_global+
443  j*nSpace_global+
444  J]
445  *
446  inverseJacobianArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
447  k*nSpace_global2+
448  J*nSpace_global+
449  I];
450  }
451 }
452 
453 void parametricMaps_getPermutations(int nElements_global,
454  int nElementBoundaries_element,
455  int nElementBoundaryQuadraturePoints_elementBoundary,
456  int nSpace_global,
457  double* xiArray,
458  int* permutations)
459 {
460  const int kTot=(nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary);
461  int eN,ebN,k,k0,I;
462  register double errorNorm,errorNormMin;
463  /* permutations are relative to the ordering on the first element so the first entries used are the identity*/
464  for (k0=0;k0<kTot;k0++)
465  permutations[k0]=k0;
466  /* now loop over remaining elements and find the permutation used to get to reference points to match*/
467  for (eN=1;eN<nElements_global;eN++)
468  {
469  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
470  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
471  {
472  errorNormMin=1.0;
473  for (k0=0;k0<kTot;k0++)
474  {
475  errorNorm=0.0;
476  for (I=0;I<nSpace_global;I++)
477  {
478  errorNorm += fabs(xiArray[k0*3+I]
479  -
480  xiArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
481  ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
482  k*3+
483  I]);
484  }
485  if (errorNorm < errorNormMin)
486  {
487  permutations[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary+
488  ebN*nElementBoundaryQuadraturePoints_elementBoundary+
489  k] = k0;
490  errorNormMin = errorNorm;
491  }
492  }
493  }
494  }
495 }
496 void parametricMaps_getPermutationsGlobalExterior(int nElementBoundaryQuadraturePoints_elementBoundary,
497  int nSpace_global,
498  int nExteriorElementBoundaries_global,
499  const int * exteriorElementBoundariesArray,
500  const int * elementBoundaryElementsArray,
501  const int * elementBoundaryLocalElementBoundariesArray,
502  double* xiArray,
503  int* permutations)
504 {
505  const int kTot=nElementBoundaryQuadraturePoints_elementBoundary;
506  int eN,ebN,ebNE,ebN_local,k,k0,I;
507  register double errorNorm,errorNormMin;
508  /* permutations are relative to the ordering on the first elementBoundary so the first entries used are the identity*/
509  for (k0=0;k0<kTot;k0++)
510  permutations[k0]=k0;
511  /* loop over exterior elementBoundaries and setup permutation used to get to reference points to match*/
512  for (ebNE = 1; ebNE < nExteriorElementBoundaries_global; ebNE++)
513  {
514  ebN = exteriorElementBoundariesArray[ebNE];
515  eN = elementBoundaryElementsArray[ebN*2+0];
516  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
517  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
518  {
519  errorNormMin=1.0;
520  for (k0=0;k0<kTot;k0++)
521  {
522  errorNorm=0.0;
523  for (I=0;I<nSpace_global;I++)
524  {
525  errorNorm += fabs(xiArray[k0*3+I]
526  -
527  xiArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*3+
528  k*3+
529  I]);
530  }
531  if (errorNorm < errorNormMin)
532  {
533  permutations[ebNE*nElementBoundaryQuadraturePoints_elementBoundary+
534  k] = k0;
535  errorNormMin = errorNorm;
536  }
537  }
538  }
539  }
540 }
541 
542 void getPermutationsGlobal(int nElementBoundaries_global,
543  int nElementBoundaryQuadraturePoints_elementBoundary,
544  double* xArray,
545  double* xArrayNew,
546  int* permutations)
547 {
548  int ebN,k,k0,I;
549  register double errorNorm,errorNormMin;
550  /* now loop over remaining elements and find the permutation used to get to reference points to match*/
551  for (ebN=0;ebN<nElementBoundaries_global;ebN++)
552  {
553  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
554  {
555  errorNormMin=1.0;
556  for (k0=0;k0<nElementBoundaryQuadraturePoints_elementBoundary;k0++)
557  {
558  errorNorm=0.0;
559  for (I=0;I<3;I++)
560  {
561  errorNorm += fabs(xArrayNew[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
562  k0*3+
563  I]
564  -
565  xArray[ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
566  k*3+
567  I]);
568  }
569  if (errorNorm < errorNormMin)
570  {
571  permutations[ebN*nElementBoundaryQuadraturePoints_elementBoundary+
572  k] = k0;
573  errorNormMin = errorNorm;
574  }
575  }
576  }
577  }
578 }
579 
580 void parametricMaps_getValues(int nElements_global,
581  int nQuadraturePoints_element,
582  int nDOF_element,
583  int nSpace_global,
584  double* psi,
585  int* l2g,
586  double* nodeArray,
587  double* xArray)
588 {
589  memset(xArray,0,sizeof(double)*nElements_global*nQuadraturePoints_element*3);
590  int eN,k,j,j_global,I;
591  for(eN=0;eN<nElements_global;eN++)
592  for(k=0;k<nQuadraturePoints_element;k++)
593  for(j=0;j<nDOF_element;j++)
594  {
595  j_global = l2g[eN*nDOF_element+
596  j];
597  for(I=0;I<nSpace_global;I++)
598  xArray[eN*nQuadraturePoints_element*3+
599  k*3+
600  I]
601  +=
602  psi[k*nDOF_element+
603  j]
604  *
605  nodeArray[j_global*3+
606  I];
607  }
608 }
609 
610 void parametricMaps_getValuesTrace(int nElements_global,
611  int nElementBoundaries_element,
612  int nQuadraturePoints_element,
613  int nDOF_element,
614  int nSpace_global,
615  double* psi,
616  int* l2g,
617  double* nodeArray,
618  double* xArray)
619 {
620  memset(xArray,0,sizeof(double)*nElements_global*nElementBoundaries_element*nQuadraturePoints_element*3);
621  int eN,ebN,k,j,j_global,I;
622  for(eN=0;eN<nElements_global;eN++)
623  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
624  for(k=0;k<nQuadraturePoints_element;k++)
625  for(j=0;j<nDOF_element;j++)
626  {
627  j_global = l2g[eN*nDOF_element+
628  j];
629  for(I=0;I<nSpace_global;I++)
630  xArray[eN*nElementBoundaries_element*nQuadraturePoints_element*3+
631  ebN*nQuadraturePoints_element*3+
632  k*3+
633  I]
634  +=
635  psi[ebN*nQuadraturePoints_element*nDOF_element+
636  k*nDOF_element+
637  j]
638  *
639  nodeArray[j_global*3+
640  I];
641  }
642 }
643 
644 void parametricMaps_getValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary,
645  int nDOF_element,
646  int nSpace_global,
647  int nExteriorElementBoundaries_global,
648  const int* exteriorElementBoundariesArray,
649  const int* elementBoundaryElementsArray,
650  const int* elementBoundaryLocalElementBoundariesArray,
651  double* psi,
652  int* l2g,
653  double* nodeArray,
654  double* xArray)
655 {
656  memset(xArray,0,sizeof(double)*nExteriorElementBoundaries_global*nQuadraturePoints_elementBoundary*3);
657  int eN,ebN,ebNE,ebN_local,k,j,j_global,I;
658  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
659  {
660  ebN = exteriorElementBoundariesArray[ebNE];
661  eN = elementBoundaryElementsArray[ebN*2 + 0];
662  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2 + 0];
663  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
664  for(j=0;j<nDOF_element;j++)
665  {
666  j_global = l2g[eN*nDOF_element+
667  j];
668  for(I=0;I<nSpace_global;I++)
669  xArray[ebNE*nQuadraturePoints_elementBoundary*3+
670  k*3+
671  I]
672  +=
673  psi[ebN_local*nQuadraturePoints_elementBoundary*nDOF_element+
674  k*nDOF_element+
675  j]
676  *
677  nodeArray[j_global*3+
678  I];
679  }
680  }
681 }
682 
683 void parametricMaps_getInverseValues(int nElements_global,
684  int nQuadraturePoints_element,
685  int nDOF_element,
686  int nSpace_global,
687  double* inverseJacobian,
688  int* l2g,
689  double* nodeArray,
690  double* xArray,
691  double* xiArray)
692 {
693  memset(xiArray,0,sizeof(double)*nElements_global*nQuadraturePoints_element*3);
694  int eN,k,node0,I,J,nSpace_global2=nSpace_global*nSpace_global;
695  double dx[nSpace_global];
696  for(eN=0;eN<nElements_global;eN++)
697  for(k=0;k<nQuadraturePoints_element;k++)
698  {
699  node0 = l2g[eN*nDOF_element];
700  for(I=0;I<nSpace_global;I++)
701  dx[I] =
702  xArray[eN*nQuadraturePoints_element*3+
703  k*3+
704  I]
705  -
706  nodeArray[node0*3+I];
707  for(I=0;I<nSpace_global;I++)
708  for(J=0;J<nSpace_global;J++)
709  xiArray[eN*nQuadraturePoints_element*3+
710  k*3+
711  I]
712  +=
713  inverseJacobian[eN*nQuadraturePoints_element*nSpace_global2+
714  k*nSpace_global2+
715  I*nSpace_global+
716  J]
717  *
718  dx[J];
719  }
720 }
721 
722 void parametricMaps_getInverseValuesTrace(int nElements_global,
723  int nElementBoundaries_element,
724  int nElementBoundaryQuadraturePoints_elementBoundary,
725  int nDOF_element,
726  int nSpace_global,
727  double* inverseJacobian,
728  int* l2g,
729  double* nodeArray,
730  double* xArray,
731  double* xiArray)
732 {
733  memset(xiArray,0,sizeof(double)*nElements_global*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3);
734  int eN,ebN,k,node0,I,J,nSpace_global2=nSpace_global*nSpace_global;
735  double dx[nSpace_global];
736  for(eN=0;eN<nElements_global;eN++)
737  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
738  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
739  {
740  node0 = l2g[eN*nDOF_element];
741  for(I=0;I<nSpace_global;I++)
742  dx[I] =
743  xArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
744  ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
745  k*3+
746  I]
747  -
748  nodeArray[node0*3+I];
749  for(I=0;I<nSpace_global;I++)
750  for(J=0;J<nSpace_global;J++)
751  xiArray[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*3+
752  ebN*nElementBoundaryQuadraturePoints_elementBoundary*3+
753  k*3+
754  I]
755  +=
756  inverseJacobian[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
757  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
758  k*nSpace_global2+
759  I*nSpace_global+
760  J]
761  *
762  dx[J];
763  }
764 }
765 
766 void parametricMaps_getInverseValuesGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary,
767  int nDOF_element,
768  int nSpace_global,
769  int nExteriorElementBoundaries_global,
770  const int* exteriorElementBoundariesArray,
771  const int* elementBoundaryElementsArray,
772  const int* elementBoundaryLocalElementBoundariesArray,
773  double* inverseJacobian,
774  int* l2g,
775  double* nodeArray,
776  double* xArray,
777  double* xiArray)
778 {
779  memset(xiArray,0,sizeof(double)*nExteriorElementBoundaries_global*nElementBoundaryQuadraturePoints_elementBoundary*3);
780  int eN,ebN,ebNE,ebN_local,k,node0,I,J,nSpace_global2=nSpace_global*nSpace_global;
781  double dx[nSpace_global];
782  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
783  {
784  ebN = exteriorElementBoundariesArray[ebNE];
785  eN = elementBoundaryElementsArray[ebN*2+0];
786  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
787 
788  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
789  {
790  node0 = l2g[eN*nDOF_element];
791  for(I=0;I<nSpace_global;I++)
792  dx[I] =
793  xArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*3+
794  k*3+
795  I]
796  -
797  nodeArray[node0*3+I];
798  for(I=0;I<nSpace_global;I++)
799  for(J=0;J<nSpace_global;J++)
800  xiArray[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*3+
801  k*3+
802  I]
803  +=
804  inverseJacobian[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nSpace_global2+
805  k*nSpace_global2+
806  I*nSpace_global+
807  J]
808  *
809  dx[J];
810  }
811  }
812 }
813 
814 void parametricMaps_getJacobianValues3D(int nElements_global,
815  int nQuadraturePoints_element,
816  int nDOF_element,
817  double* grad_psi,
818  int* l2g,
819  double* nodeArray,
820  double* jacobianArray,
821  double* jacobianDeterminantArray,
822  double* jacobianInverseArray)
823 {
824  int eN,k,j,j_global;
825  const int X=0,Y=1,Z=2,
826  XX=0,XY=1,XZ=2,
827  YX=3,YY=4,YZ=5,
828  ZX=6,ZY=7,ZZ=8;
829  double *jac=NULL,*jacDet=NULL,*jacInv=NULL,*grad=NULL,*node=NULL;
830  register double oneOverJacDet=0.0;
831  for(eN=0;eN<nElements_global;eN++)
832  for(k=0;k<nQuadraturePoints_element;k++)
833  {
834  jac = jacobianArray +
835  eN*nQuadraturePoints_element*9+
836  k*9;
837  jacDet = jacobianDeterminantArray +
838  eN*nQuadraturePoints_element+
839  k;
840  jacInv = jacobianInverseArray +
841  eN*nQuadraturePoints_element*9+
842  k*9;
843  for(j=0;j<nDOF_element;j++)
844  {
845  j_global = l2g[eN*nDOF_element+
846  j];
847  grad = grad_psi + k*nDOF_element*3 + j*3;
848  node = nodeArray + j_global*3;
849  jac[XX] += node[X]*grad[X];
850  jac[XY] += node[X]*grad[Y];
851  jac[XZ] += node[X]*grad[Z];
852  jac[YX] += node[Y]*grad[X];
853  jac[YY] += node[Y]*grad[Y];
854  jac[YZ] += node[Y]*grad[Z];
855  jac[ZX] += node[Z]*grad[X];
856  jac[ZY] += node[Z]*grad[Y];
857  jac[ZZ] += node[Z]*grad[Z];
858  }
859  *jacDet
860  =
861  jac[XX]*(jac[YY]*jac[ZZ] - jac[YZ]*jac[ZY]) -
862  jac[XY]*(jac[YX]*jac[ZZ] - jac[YZ]*jac[ZX]) +
863  jac[XZ]*(jac[YX]*jac[ZY] - jac[YY]*jac[ZX]);
864  oneOverJacDet = 1.0/(*jacDet);
865  jacInv[XX] = oneOverJacDet*(jac[YY]*jac[ZZ] - jac[YZ]*jac[ZY]);
866  jacInv[YX] = oneOverJacDet*(jac[YZ]*jac[ZX] - jac[YX]*jac[ZZ]);
867  jacInv[ZX] = oneOverJacDet*(jac[YX]*jac[ZY] - jac[YY]*jac[ZX]);
868  jacInv[XY] = oneOverJacDet*(jac[ZY]*jac[XZ] - jac[ZZ]*jac[XY]);
869  jacInv[YY] = oneOverJacDet*(jac[ZZ]*jac[XX] - jac[ZX]*jac[XZ]);
870  jacInv[ZY] = oneOverJacDet*(jac[ZX]*jac[XY] - jac[ZY]*jac[XX]);
871  jacInv[XZ] = oneOverJacDet*(jac[XY]*jac[YZ] - jac[XZ]*jac[YY]);
872  jacInv[YZ] = oneOverJacDet*(jac[XZ]*jac[YX] - jac[XX]*jac[YZ]);
873  jacInv[ZZ] = oneOverJacDet*(jac[XX]*jac[YY] - jac[XY]*jac[YX]);
874  }
875 }
876 
877 void parametricMaps_getJacobianValues2D(int nElements_global,
878  int nQuadraturePoints_element,
879  int nDOF_element,
880  double* grad_psi,
881  int* l2g,
882  double* nodeArray,
883  double* jacobianArray,
884  double* jacobianDeterminantArray,
885  double* jacobianInverseArray)
886 {
887  int eN,k,j,j_global;
888  const int X=0,Y=1,
889  XX=0,XY=1,
890  YX=2,YY=3;
891  double *jac=NULL,*jacDet=NULL,*jacInv=NULL,*grad=NULL,*node=NULL;
892  register double oneOverJacDet=0.0;
893  for(eN=0;eN<nElements_global;eN++)
894  for(k=0;k<nQuadraturePoints_element;k++)
895  {
896  jac = jacobianArray +
897  eN*nQuadraturePoints_element*4+
898  k*4;
899  jacDet = jacobianDeterminantArray +
900  eN*nQuadraturePoints_element+
901  k;
902  jacInv = jacobianInverseArray +
903  eN*nQuadraturePoints_element*4+
904  k*4;
905  for(j=0;j<nDOF_element;j++)
906  {
907  j_global = l2g[eN*nDOF_element+
908  j];
909  grad = grad_psi + k*nDOF_element*2 + j*2;
910  /* nodes are always 3D */
911  node = nodeArray + j_global*3;
912  jac[XX] += node[X]*grad[X];
913  jac[XY] += node[X]*grad[Y];
914  jac[YX] += node[Y]*grad[X];
915  jac[YY] += node[Y]*grad[Y];
916  }
917  *jacDet
918  =
919  jac[XX]*jac[YY]- jac[XY]*jac[YX];
920  oneOverJacDet = 1.0/(*jacDet);
921  jacInv[XX] = oneOverJacDet*jac[YY];
922  jacInv[YX] = -oneOverJacDet*jac[YX];
923  jacInv[XY] = -oneOverJacDet*jac[XY];
924  jacInv[YY] = oneOverJacDet*jac[XX];
925  }
926 }
927 
928 void parametricMaps_getJacobianValues1D(int nElements_global,
929  int nQuadraturePoints_element,
930  int nDOF_element,
931  double* grad_psi,
932  int* l2g,
933  double* nodeArray,
934  double* jacobianArray,
935  double* jacobianDeterminantArray,
936  double* jacobianInverseArray)
937 {
938  int eN,k,j,j_global;
939  const int X=0,
940  XX=0;
941  double *jac=NULL,*jacDet=NULL,*jacInv=NULL,*grad=NULL,*node=NULL;
942  register double oneOverJacDet=0.0;
943  for(eN=0;eN<nElements_global;eN++)
944  for(k=0;k<nQuadraturePoints_element;k++)
945  {
946  jac = jacobianArray +
947  eN*nQuadraturePoints_element+
948  k;
949  jacDet = jacobianDeterminantArray +
950  eN*nQuadraturePoints_element+
951  k;
952  jacInv = jacobianInverseArray +
953  eN*nQuadraturePoints_element+
954  k;
955  for(j=0;j<nDOF_element;j++)
956  {
957  j_global = l2g[eN*nDOF_element+
958  j];
959  grad = grad_psi + k*nDOF_element + j;
960  /* nodes are always 3D */
961  node = nodeArray + j_global*3;
962  jac[XX] += node[X]*grad[X];
963  }
964  *jacDet
965  =
966  jac[XX];
967  oneOverJacDet = 1.0/(*jacDet);
968  jacInv[XX] = oneOverJacDet;
969  }
970 }
971 
972 void parametricMaps_getJacobianValuesTrace3D(int nElements_global,
973  int nElementBoundaries_element,
974  int nQuadraturePoints_element,
975  int nDOF_element,
976  double* grad_psi,
977  double* boundaryNormals,
978  double* boundaryJacobians,
979  int* l2g,
980  double* nodeArray,
981  double* jacobianInverseArray,
982  double* metricTensorArray,
983  double* metricTensorDeterminantSqrtArray,
984  double* unitNormalArray)
985 {
986  int eN,ebN,k,j,j_global;
987  const int
988  X=0,Y=1,Z=2,
989  XX=0,XY=1,XZ=2,
990  YX=3,YY=4,YZ=5,
991  ZX=6,ZY=7,ZZ=8,
992  XHX=0,XHY=1,
993  YHX=2,YHY=3,
994  ZHX=4,ZHY=5,
995  HXHX=0,HXHY=1,
996  HYHX=2,HYHY=3;
997  double *jacInv=NULL,*mt=NULL,*mtDetSqrt=NULL,*n=NULL,*grad=NULL,*node=NULL,*bn,*bj;
998  register double oneOverJacDet=0.0,oneOverNbn=0.0;
999  double emj[9],ebmj[6];
1000  for(eN=0;eN<nElements_global;eN++)
1001  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
1002  for(k=0;k<nQuadraturePoints_element;k++)
1003  {
1004  emj[XX] = 0.0;
1005  emj[XY] = 0.0;
1006  emj[XZ] = 0.0;
1007  emj[YX] = 0.0;
1008  emj[YY] = 0.0;
1009  emj[YZ] = 0.0;
1010  emj[ZX] = 0.0;
1011  emj[ZY] = 0.0;
1012  emj[ZZ] = 0.0;
1013  ebmj[XHX] = 0.0;
1014  ebmj[XHY] = 0.0;
1015  ebmj[YHX] = 0.0;
1016  ebmj[YHY] = 0.0;
1017  ebmj[ZHX] = 0.0;
1018  ebmj[ZHY] = 0.0;
1019  jacInv = jacobianInverseArray +
1020  eN*nElementBoundaries_element*nQuadraturePoints_element*9+
1021  ebN*nQuadraturePoints_element*9+
1022  k*9;
1023  mt = metricTensorArray +
1024  eN*nElementBoundaries_element*nQuadraturePoints_element*4+
1025  ebN*nQuadraturePoints_element*4+
1026  k*4;
1027  mtDetSqrt = metricTensorDeterminantSqrtArray +
1028  eN*nElementBoundaries_element*nQuadraturePoints_element+
1029  ebN*nQuadraturePoints_element+
1030  k;
1031  n = unitNormalArray+
1032  eN*nElementBoundaries_element*nQuadraturePoints_element*3+
1033  ebN*nQuadraturePoints_element*3+
1034  k*3;
1035  bn = boundaryNormals + ebN*3;
1036  bj = boundaryJacobians + ebN*6;
1037  for(j=0;j<nDOF_element;j++)
1038  {
1039  j_global = l2g[eN*nDOF_element+
1040  j];
1041  grad = grad_psi + ebN*nQuadraturePoints_element*nDOF_element*3+k*nDOF_element*3 + j*3;
1042  /* nodes are always 3D */
1043  node = nodeArray + j_global*3;
1044  emj[XX] += node[X]*grad[X];
1045  emj[XY] += node[X]*grad[Y];
1046  emj[XZ] += node[X]*grad[Z];
1047  emj[YX] += node[Y]*grad[X];
1048  emj[YY] += node[Y]*grad[Y];
1049  emj[YZ] += node[Y]*grad[Z];
1050  emj[ZX] += node[Z]*grad[X];
1051  emj[ZY] += node[Z]*grad[Y];
1052  emj[ZZ] += node[Z]*grad[Z];
1053  }
1054  oneOverJacDet = 1.0/(emj[XX]*(emj[YY]*emj[ZZ] - emj[YZ]*emj[ZY]) -
1055  emj[XY]*(emj[YX]*emj[ZZ] - emj[YZ]*emj[ZX]) +
1056  emj[XZ]*(emj[YX]*emj[ZY] - emj[YY]*emj[ZX]));
1057  jacInv[XX] = oneOverJacDet*(emj[YY]*emj[ZZ] - emj[YZ]*emj[ZY]);
1058  jacInv[YX] = oneOverJacDet*(emj[YZ]*emj[ZX] - emj[YX]*emj[ZZ]);
1059  jacInv[ZX] = oneOverJacDet*(emj[YX]*emj[ZY] - emj[YY]*emj[ZX]);
1060  jacInv[XY] = oneOverJacDet*(emj[ZY]*emj[XZ] - emj[ZZ]*emj[XY]);
1061  jacInv[YY] = oneOverJacDet*(emj[ZZ]*emj[XX] - emj[ZX]*emj[XZ]);
1062  jacInv[ZY] = oneOverJacDet*(emj[ZX]*emj[XY] - emj[ZY]*emj[XX]);
1063  jacInv[XZ] = oneOverJacDet*(emj[XY]*emj[YZ] - emj[XZ]*emj[YY]);
1064  jacInv[YZ] = oneOverJacDet*(emj[XZ]*emj[YX] - emj[XX]*emj[YZ]);
1065  jacInv[ZZ] = oneOverJacDet*(emj[XX]*emj[YY] - emj[XY]*emj[YX]);
1066 
1067  ebmj[XHX] = emj[XX]*bj[XHX]+emj[XY]*bj[YHX]+emj[XZ]*bj[ZHX];
1068  ebmj[XHY] = emj[XX]*bj[XHY]+emj[XY]*bj[YHY]+emj[XZ]*bj[ZHY];
1069  ebmj[YHX] = emj[YX]*bj[XHX]+emj[YY]*bj[YHX]+emj[YZ]*bj[ZHX];
1070  ebmj[YHY] = emj[YX]*bj[XHY]+emj[YY]*bj[YHY]+emj[YZ]*bj[ZHY];
1071  ebmj[ZHX] = emj[ZX]*bj[XHX]+emj[ZY]*bj[YHX]+emj[ZZ]*bj[ZHX];
1072  ebmj[ZHY] = emj[ZX]*bj[XHY]+emj[ZY]*bj[YHY]+emj[ZZ]*bj[ZHY];
1073 
1074  mt[HXHX] = ebmj[XHX]*ebmj[XHX]+ebmj[YHX]*ebmj[YHX]+ebmj[ZHX]*ebmj[ZHX];
1075  mt[HXHY] = ebmj[XHX]*ebmj[XHY]+ebmj[YHX]*ebmj[YHY]+ebmj[ZHX]*ebmj[ZHY];
1076  mt[HYHX] = ebmj[XHY]*ebmj[XHX]+ebmj[YHY]*ebmj[YHX]+ebmj[ZHY]*ebmj[ZHX];
1077  mt[HYHY] = ebmj[XHY]*ebmj[XHY]+ebmj[YHY]*ebmj[YHY]+ebmj[ZHY]*ebmj[ZHY];
1078 
1079  *mtDetSqrt=sqrt(mt[HXHX]*mt[HYHY]- mt[HXHY]*mt[HYHX]);
1080 
1081 
1082  n[X] = (jacInv[XX]*bn[X]+jacInv[YX]*bn[Y]+jacInv[ZX]*bn[Z]);
1083  n[Y] = (jacInv[XY]*bn[X]+jacInv[YY]*bn[Y]+jacInv[ZY]*bn[Z]);
1084  n[Z] = (jacInv[XZ]*bn[X]+jacInv[YZ]*bn[Y]+jacInv[ZZ]*bn[Z]);
1085 
1086  oneOverNbn = 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]+n[Z]*n[Z]);
1087 
1088  n[X] *= oneOverNbn;
1089  n[Y] *= oneOverNbn;
1090  n[Z] *= oneOverNbn;
1091 
1092  }
1093 }
1094 
1096  int nElementBoundaries_element,
1097  int nQuadraturePoints_element,
1098  int nDOF_element,
1099  double* grad_psi,
1100  double* boundaryNormals,
1101  double* boundaryJacobians,
1102  int* l2g,
1103  double* nodeArray,
1104  double* jacobianInverseArray,
1105  double* metricTensorArray,
1106  double* metricTensorDeterminantSqrtArray,
1107  double* unitNormalArray)
1108 {
1109  int eN,ebN,k,j,j_global;
1110  const int X=0,Y=1,
1111  XX=0,XY=1,
1112  YX=2,YY=3;
1113  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL,*bn,*bj;
1114  register double oneOverJacDet=0.0,oneOverNbn=0.0;
1115  double emj[4],ebmj[2];
1116  for(eN=0;eN<nElements_global;eN++)
1117  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
1118  for(k=0;k<nQuadraturePoints_element;k++)
1119  {
1120  emj[XX] = 0.0;
1121  emj[XY] = 0.0;
1122  emj[YX] = 0.0;
1123  emj[YY] = 0.0;
1124  ebmj[XX] = 0.0;
1125  ebmj[XY] = 0.0;
1126  jacInv = jacobianInverseArray +
1127  eN*nElementBoundaries_element*nQuadraturePoints_element*4+
1128  ebN*nQuadraturePoints_element*4+
1129  k*4;
1130  mt = metricTensorArray +
1131  eN*nElementBoundaries_element*nQuadraturePoints_element+
1132  ebN*nQuadraturePoints_element+
1133  k;
1134  mtDetSqrt = metricTensorDeterminantSqrtArray +
1135  eN*nElementBoundaries_element*nQuadraturePoints_element+
1136  ebN*nQuadraturePoints_element+
1137  k;
1138  n = unitNormalArray+
1139  eN*nElementBoundaries_element*nQuadraturePoints_element*2+
1140  ebN*nQuadraturePoints_element*2+
1141  k*2;
1142  bn = boundaryNormals + ebN*2;
1143  bj = boundaryJacobians + ebN*2;
1144  for(j=0;j<nDOF_element;j++)
1145  {
1146  j_global = l2g[eN*nDOF_element+
1147  j];
1148  grad = grad_psi + ebN*nQuadraturePoints_element*nDOF_element*2+k*nDOF_element*2 + j*2;
1149  /* nodes are always 3D */
1150  node = nodeArray + j_global*3;
1151  emj[XX] += node[X]*grad[X];
1152  emj[XY] += node[X]*grad[Y];
1153  emj[YX] += node[Y]*grad[X];
1154  emj[YY] += node[Y]*grad[Y];
1155  }
1156  oneOverJacDet = 1.0/(emj[XX]*emj[YY]- emj[XY]*emj[YX]);
1157  jacInv[XX] = oneOverJacDet*emj[YY];
1158  jacInv[YX] = -oneOverJacDet*emj[YX];
1159  jacInv[XY] = -oneOverJacDet*emj[XY];
1160  jacInv[YY] = oneOverJacDet*emj[XX];
1161  ebmj[X] = emj[XX]*bj[XX]+emj[XY]*bj[Y];
1162  ebmj[Y] = emj[YX]*bj[X]+emj[YY]*bj[Y];
1163  mt[X] = ebmj[X]*ebmj[X]+ebmj[Y]*ebmj[Y];
1164  *mtDetSqrt=sqrt(mt[XX]);
1165  n[X] = jacInv[XX]*bn[X]+jacInv[YX]*bn[Y];
1166  n[Y] = jacInv[XY]*bn[X]+jacInv[YY]*bn[Y];
1167  oneOverNbn= 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]);
1168  n[X] *= oneOverNbn;
1169  n[Y] *= oneOverNbn;
1170  }
1171 }
1172 
1174  int nElementBoundaries_element,
1175  int nQuadraturePoints_element,
1176  int nDOF_element,
1177  double* xtArray,
1178  double* grad_psi,
1179  double* boundaryNormals,
1180  double* boundaryJacobians,
1181  int* l2g,
1182  double* nodeArray,
1183  double* jacobianInverseArray,
1184  double* metricTensorArray,
1185  double* metricTensorDeterminantSqrtArray,
1186  double* unitNormalArray)
1187 {
1188  int eN,ebN,k,j,j_global;
1189  const int X=0,Y=1,
1190  XX=0,XY=1,
1191  YX=2,YY=3;
1192  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL,*bn,*bj,*xt;
1193  register double oneOverJacDet=0.0,oneOverNbn=0.0,xt_dot_xt,xt_dot_n,xt_dot_bj;
1194  double emj[4],ebmj[2];
1195  for(eN=0;eN<nElements_global;eN++)
1196  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
1197  for(k=0;k<nQuadraturePoints_element;k++)
1198  {
1199  emj[XX] = 0.0;
1200  emj[XY] = 0.0;
1201  emj[YX] = 0.0;
1202  emj[YY] = 0.0;
1203  ebmj[XX] = 0.0;
1204  ebmj[XY] = 0.0;
1205  jacInv = jacobianInverseArray +
1206  eN*nElementBoundaries_element*nQuadraturePoints_element*4+
1207  ebN*nQuadraturePoints_element*4+
1208  k*4;
1209  mt = metricTensorArray +
1210  eN*nElementBoundaries_element*nQuadraturePoints_element+
1211  ebN*nQuadraturePoints_element+
1212  k;
1213  mtDetSqrt = metricTensorDeterminantSqrtArray +
1214  eN*nElementBoundaries_element*nQuadraturePoints_element+
1215  ebN*nQuadraturePoints_element+
1216  k;
1217  n = unitNormalArray+
1218  eN*nElementBoundaries_element*nQuadraturePoints_element*2+
1219  ebN*nQuadraturePoints_element*2+
1220  k*2;
1221  xt = xtArray + eN*nElementBoundaries_element*nQuadraturePoints_element*3+
1222  ebN*nQuadraturePoints_element*3+
1223  k*3;
1224  bn = boundaryNormals + ebN*2;
1225  bj = boundaryJacobians + ebN*2;
1226  for(j=0;j<nDOF_element;j++)
1227  {
1228  j_global = l2g[eN*nDOF_element+
1229  j];
1230  grad = grad_psi + ebN*nQuadraturePoints_element*nDOF_element*2+k*nDOF_element*2 + j*2;
1231  /* nodes are always 3D */
1232  node = nodeArray + j_global*3;
1233  emj[XX] += node[X]*grad[X];
1234  emj[XY] += node[X]*grad[Y];
1235  emj[YX] += node[Y]*grad[X];
1236  emj[YY] += node[Y]*grad[Y];
1237  }
1238  oneOverJacDet = 1.0/(emj[XX]*emj[YY]- emj[XY]*emj[YX]);
1239  jacInv[XX] = oneOverJacDet*emj[YY];
1240  jacInv[YX] = -oneOverJacDet*emj[YX];
1241  jacInv[XY] = -oneOverJacDet*emj[XY];
1242  jacInv[YY] = oneOverJacDet*emj[XX];
1243  ebmj[X] = emj[XX]*bj[X]+emj[XY]*bj[Y];
1244  ebmj[Y] = emj[YX]*bj[X]+emj[YY]*bj[Y];
1245  mt[X] = ebmj[X]*ebmj[X]+ebmj[Y]*ebmj[Y];
1246  n[X] = jacInv[XX]*bn[X]+jacInv[YX]*bn[Y];
1247  n[Y] = jacInv[XY]*bn[X]+jacInv[YY]*bn[Y];
1248  oneOverNbn= 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]);
1249  n[X] *= oneOverNbn;
1250  n[Y] *= oneOverNbn;
1251  xt_dot_xt = xt[X]*xt[X]+xt[Y]*xt[Y];
1252  xt_dot_bj = xt[X]*ebmj[X]+xt[Y]*ebmj[Y];
1253  xt_dot_n = xt[X]*n[X]+xt[Y]*n[Y];
1254  //printf("%12.5e %12.5e %12.5e\n",xt_dot_xt,xt_dot_bj,xt_dot_n);
1255  //printf("%12.5e \n",((1.0+xt_dot_xt)*mt[X] - xt_dot_bj*xt_dot_bj)/(1.0+xt_dot_n*xt_dot_n));
1256  *mtDetSqrt=sqrt(((1.0+xt_dot_xt)*mt[X] - xt_dot_bj*xt_dot_bj)/(1.0+xt_dot_n*xt_dot_n));// sqrt(det(G^t G))/sqrt(1 + (xt^t n)^2)
1257  }
1258 }
1259 
1261  int nElementBoundaries_element,
1262  int nQuadraturePoints_element,
1263  int nDOF_element,
1264  double* grad_psi,
1265  double* boundaryNormals,
1266  double* boundaryJacobians,
1267  int* l2g,
1268  double* nodeArray,
1269  double* jacobianInverseArray,
1270  double* metricTensorArray,
1271  double* metricTensorDeterminantSqrtArray,
1272  double* unitNormalArray)
1273 {
1274  int eN,ebN,k,j,j_global;
1275  const int X=0,
1276  XX=0;
1277  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL;
1278  register double emj=0.0,ebmj=0.0;
1279  for(eN=0;eN<nElements_global;eN++)
1280  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
1281  for(k=0;k<nQuadraturePoints_element;k++)
1282  {
1283  emj = 0.0;
1284  ebmj = 0.0;
1285  jacInv = jacobianInverseArray +
1286  eN*nElementBoundaries_element*nQuadraturePoints_element+
1287  ebN*nQuadraturePoints_element+
1288  k;
1289  mt = metricTensorArray +
1290  eN*nElementBoundaries_element*nQuadraturePoints_element+
1291  ebN*nQuadraturePoints_element+
1292  k;
1293  mtDetSqrt = metricTensorDeterminantSqrtArray +
1294  eN*nElementBoundaries_element*nQuadraturePoints_element+
1295  ebN*nQuadraturePoints_element+
1296  k;
1297  n = unitNormalArray+
1298  eN*nElementBoundaries_element*nQuadraturePoints_element+
1299  ebN*nQuadraturePoints_element+
1300  k;
1301  for(j=0;j<nDOF_element;j++)
1302  {
1303  j_global = l2g[eN*nDOF_element+
1304  j];
1305  grad = grad_psi + ebN*nQuadraturePoints_element*nDOF_element+k*nDOF_element + j;
1306  /* nodes are always 3D */
1307  node = nodeArray + j_global*3;
1308  emj += node[X]*grad[X];
1309  }
1310  jacInv[XX] = 1.0/(emj);
1311  mt[XX] = 1.0;
1312  *mtDetSqrt=1.0;
1313  n[X] = boundaryNormals[ebN];
1314  }
1315 }
1316 
1318  int nDOF_element,
1319  int nExteriorElementBoundaries_global,
1320  const int * exteriorElementBoundariesArray,
1321  const int * elementBoundaryElementsArray,
1322  const int * elementBoundaryLocalElementBoundariesArray,
1323  double* grad_psi,
1324  double* boundaryNormals,
1325  double* boundaryJacobians,
1326  int* l2g,
1327  double* nodeArray,
1328  double* jacobianInverseArray,
1329  double* metricTensorArray,
1330  double* metricTensorDeterminantSqrtArray,
1331  double* unitNormalArray)
1332 {
1333  int eN,ebN,ebNE,ebN_local,k,j,j_global;
1334  const int X=0,
1335  XX=0;
1336  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL;
1337  register double emj=0.0,ebmj=0.0;
1338  for(ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1339  {
1340  ebN = exteriorElementBoundariesArray[ebNE];
1341  eN = elementBoundaryElementsArray[ebN*2+0];
1342  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
1343  for(k=0;k<nQuadraturePoints_element;k++)
1344  {
1345  emj = 0.0;
1346  ebmj = 0.0;
1347  jacInv = jacobianInverseArray +
1348  ebNE*nQuadraturePoints_element+
1349  k;
1350  mt = metricTensorArray +
1351  ebNE*nQuadraturePoints_element+
1352  k;
1353  mtDetSqrt = metricTensorDeterminantSqrtArray +
1354  ebNE*nQuadraturePoints_element+
1355  k;
1356  n = unitNormalArray+
1357  ebNE*nQuadraturePoints_element+
1358  k;
1359  for(j=0;j<nDOF_element;j++)
1360  {
1361  j_global = l2g[eN*nDOF_element+
1362  j];
1363  grad = grad_psi + ebN_local*nQuadraturePoints_element*nDOF_element+k*nDOF_element + j;
1364  /* nodes are always 3D */
1365  node = nodeArray + j_global*3;
1366  emj += node[X]*grad[X];
1367  }
1368  jacInv[XX] = 1.0/(emj);
1369  mt[XX] = 1.0;
1370  *mtDetSqrt=1.0;
1371  n[X] = boundaryNormals[ebN_local];
1372  }
1373  }
1374 }
1376  int nDOF_element,
1377  int nExteriorElementBoundaries_global,
1378  const int * exteriorElementBoundariesArray,
1379  const int * elementBoundaryElementsArray,
1380  const int * elementBoundaryLocalElementBoundariesArray,
1381  double* grad_psi,
1382  double* boundaryNormals,
1383  double* boundaryJacobians,
1384  int* l2g,
1385  double* nodeArray,
1386  double* jacobianInverseArray,
1387  double* metricTensorArray,
1388  double* metricTensorDeterminantSqrtArray,
1389  double* unitNormalArray)
1390 {
1391  int eN,ebN,ebNE,ebN_local,k,j,j_global;
1392  const int X=0,Y=1,
1393  XX=0,XY=1,
1394  YX=2,YY=3;
1395  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL,*bn,*bj;
1396  register double oneOverJacDet=0.0,oneOverNbn=0.0;
1397  double emj[4],ebmj[2];
1398  for(ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1399  {
1400  ebN = exteriorElementBoundariesArray[ebNE];
1401  eN = elementBoundaryElementsArray[ebN*2+0];
1402  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
1403  for(k=0;k<nQuadraturePoints_element;k++)
1404  {
1405  emj[XX] = 0.0;
1406  emj[XY] = 0.0;
1407  emj[YX] = 0.0;
1408  emj[YY] = 0.0;
1409  ebmj[XX] = 0.0;
1410  ebmj[XY] = 0.0;
1411  jacInv = jacobianInverseArray +
1412  ebNE*nQuadraturePoints_element*4+
1413  k*4;
1414  mt = metricTensorArray +
1415  ebNE*nQuadraturePoints_element+
1416  k;
1417  mtDetSqrt = metricTensorDeterminantSqrtArray +
1418  ebNE*nQuadraturePoints_element+
1419  k;
1420  n = unitNormalArray+
1421  ebNE*nQuadraturePoints_element*2+
1422  k*2;
1423  bn = boundaryNormals + ebN_local*2;
1424  bj = boundaryJacobians + ebN_local*2;
1425  for(j=0;j<nDOF_element;j++)
1426  {
1427  j_global = l2g[eN*nDOF_element+
1428  j];
1429  grad = grad_psi + ebN_local*nQuadraturePoints_element*nDOF_element*2+k*nDOF_element*2 + j*2;
1430  /* nodes are always 3D */
1431  node = nodeArray + j_global*3;
1432  emj[XX] += node[X]*grad[X];
1433  emj[XY] += node[X]*grad[Y];
1434  emj[YX] += node[Y]*grad[X];
1435  emj[YY] += node[Y]*grad[Y];
1436  }
1437  oneOverJacDet = 1.0/(emj[XX]*emj[YY]- emj[XY]*emj[YX]);
1438  jacInv[XX] = oneOverJacDet*emj[YY];
1439  jacInv[YX] = -oneOverJacDet*emj[YX];
1440  jacInv[XY] = -oneOverJacDet*emj[XY];
1441  jacInv[YY] = oneOverJacDet*emj[XX];
1442  ebmj[X] = emj[XX]*bj[XX]+emj[XY]*bj[Y];
1443  ebmj[Y] = emj[YX]*bj[X]+emj[YY]*bj[Y];
1444  mt[X] = ebmj[X]*ebmj[X]+ebmj[Y]*ebmj[Y];
1445  *mtDetSqrt=sqrt(mt[XX]);
1446  n[X] = jacInv[XX]*bn[X]+jacInv[YX]*bn[Y];
1447  n[Y] = jacInv[XY]*bn[X]+jacInv[YY]*bn[Y];
1448  oneOverNbn= 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]);
1449  n[X] *= oneOverNbn;
1450  n[Y] *= oneOverNbn;
1451  }
1452  }
1453 }
1454 
1456  int nDOF_element,
1457  int nExteriorElementBoundaries_global,
1458  const int * exteriorElementBoundariesArray,
1459  const int * elementBoundaryElementsArray,
1460  const int * elementBoundaryLocalElementBoundariesArray,
1461  double* xtArray,
1462  double* grad_psi,
1463  double* boundaryNormals,
1464  double* boundaryJacobians,
1465  int* l2g,
1466  double* nodeArray,
1467  double* jacobianInverseArray,
1468  double* metricTensorArray,
1469  double* metricTensorDeterminantSqrtArray,
1470  double* unitNormalArray)
1471 {
1472  int eN,ebN,ebNE,ebN_local,k,j,j_global;
1473  const int X=0,Y=1,
1474  XX=0,XY=1,
1475  YX=2,YY=3;
1476  double *jacInv=NULL,*mt,*mtDetSqrt,*n,*grad=NULL,*node=NULL,*bn,*bj,*xt;
1477  register double oneOverJacDet=0.0,oneOverNbn=0.0,xt_dot_xt,xt_dot_n,xt_dot_bj;
1478  double emj[4],ebmj[2];
1479  for(ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1480  {
1481  ebN = exteriorElementBoundariesArray[ebNE];
1482  eN = elementBoundaryElementsArray[ebN*2+0];
1483  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
1484  for(k=0;k<nQuadraturePoints_element;k++)
1485  {
1486  emj[XX] = 0.0;
1487  emj[XY] = 0.0;
1488  emj[YX] = 0.0;
1489  emj[YY] = 0.0;
1490  ebmj[XX] = 0.0;
1491  ebmj[XY] = 0.0;
1492  jacInv = jacobianInverseArray +
1493  ebNE*nQuadraturePoints_element*4+
1494  k*4;
1495  mt = metricTensorArray +
1496  ebNE*nQuadraturePoints_element+
1497  k;
1498  mtDetSqrt = metricTensorDeterminantSqrtArray +
1499  ebNE*nQuadraturePoints_element+
1500  k;
1501  n = unitNormalArray+
1502  ebNE*nQuadraturePoints_element*2+
1503  k*2;
1504  xt = xtArray+
1505  ebNE*nQuadraturePoints_element*3+
1506  k*3;
1507  bn = boundaryNormals + ebN_local*2;
1508  bj = boundaryJacobians + ebN_local*2;
1509  for(j=0;j<nDOF_element;j++)
1510  {
1511  j_global = l2g[eN*nDOF_element+
1512  j];
1513  grad = grad_psi + ebN_local*nQuadraturePoints_element*nDOF_element*2+k*nDOF_element*2 + j*2;
1514  /* nodes are always 3D */
1515  node = nodeArray + j_global*3;
1516  emj[XX] += node[X]*grad[X];
1517  emj[XY] += node[X]*grad[Y];
1518  emj[YX] += node[Y]*grad[X];
1519  emj[YY] += node[Y]*grad[Y];
1520  }
1521  oneOverJacDet = 1.0/(emj[XX]*emj[YY]- emj[XY]*emj[YX]);
1522  jacInv[XX] = oneOverJacDet*emj[YY];
1523  jacInv[YX] = -oneOverJacDet*emj[YX];
1524  jacInv[XY] = -oneOverJacDet*emj[XY];
1525  jacInv[YY] = oneOverJacDet*emj[XX];
1526  ebmj[X] = emj[XX]*bj[XX]+emj[XY]*bj[Y];
1527  ebmj[Y] = emj[YX]*bj[X]+emj[YY]*bj[Y];
1528  mt[X] = ebmj[X]*ebmj[X]+ebmj[Y]*ebmj[Y];
1529  n[X] = jacInv[XX]*bn[X]+jacInv[YX]*bn[Y];
1530  n[Y] = jacInv[XY]*bn[X]+jacInv[YY]*bn[Y];
1531  oneOverNbn= 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]);
1532  n[X] *= oneOverNbn;
1533  n[Y] *= oneOverNbn;
1534  xt_dot_xt = xt[X]*xt[X]+xt[Y]*xt[Y];
1535  xt_dot_bj = xt[X]*ebmj[X]+xt[Y]*ebmj[Y];
1536  xt_dot_n = xt[X]*n[X]+xt[Y]*n[Y];
1537  //printf("%12.5e %12.5e %12.5e\n",xt_dot_xt,xt_dot_bj,xt_dot_n);
1538  *mtDetSqrt=sqrt(((1.0+xt_dot_xt)*mt[X] - xt_dot_bj*xt_dot_bj)/(1.0+xt_dot_n*xt_dot_n));// sqrt(det(G^t G))/sqrt(1 + (xt^t n)^2)
1539  }
1540  }
1541 }
1543  int nDOF_element,
1544  int nExteriorElementBoundaries_global,
1545  const int * exteriorElementBoundariesArray,
1546  const int * elementBoundaryElementsArray,
1547  const int * elementBoundaryLocalElementBoundariesArray,
1548  double* grad_psi,
1549  double* boundaryNormals,
1550  double* boundaryJacobians,
1551  int* l2g,
1552  double* nodeArray,
1553  double* jacobianInverseArray,
1554  double* metricTensorArray,
1555  double* metricTensorDeterminantSqrtArray,
1556  double* unitNormalArray)
1557 {
1558  int eN,ebN,ebNE,ebN_local,k,j,j_global;
1559  const int
1560  X=0,Y=1,Z=2,
1561  XX=0,XY=1,XZ=2,
1562  YX=3,YY=4,YZ=5,
1563  ZX=6,ZY=7,ZZ=8,
1564  XHX=0,XHY=1,
1565  YHX=2,YHY=3,
1566  ZHX=4,ZHY=5,
1567  HXHX=0,HXHY=1,
1568  HYHX=2,HYHY=3;
1569  double *jacInv=NULL,*mt=NULL,*mtDetSqrt=NULL,*n=NULL,*grad=NULL,*node=NULL,*bn,*bj;
1570  register double oneOverJacDet=0.0,oneOverNbn=0.0;
1571  double emj[9],ebmj[6];
1572  for(ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1573  {
1574  ebN = exteriorElementBoundariesArray[ebNE];
1575  eN = elementBoundaryElementsArray[ebN*2+0];
1576  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
1577  for(k=0;k<nQuadraturePoints_element;k++)
1578  {
1579  emj[XX] = 0.0;
1580  emj[XY] = 0.0;
1581  emj[XZ] = 0.0;
1582  emj[YX] = 0.0;
1583  emj[YY] = 0.0;
1584  emj[YZ] = 0.0;
1585  emj[ZX] = 0.0;
1586  emj[ZY] = 0.0;
1587  emj[ZZ] = 0.0;
1588  ebmj[XHX] = 0.0;
1589  ebmj[XHY] = 0.0;
1590  ebmj[YHX] = 0.0;
1591  ebmj[YHY] = 0.0;
1592  ebmj[ZHX] = 0.0;
1593  ebmj[ZHY] = 0.0;
1594  jacInv = jacobianInverseArray +
1595  ebNE*nQuadraturePoints_element*9+
1596  k*9;
1597  mt = metricTensorArray +
1598  ebNE*nQuadraturePoints_element*4+
1599  k*4;
1600  mtDetSqrt = metricTensorDeterminantSqrtArray +
1601  ebNE*nQuadraturePoints_element+
1602  k;
1603  n = unitNormalArray+
1604  ebNE*nQuadraturePoints_element*3+
1605  k*3;
1606  bn = boundaryNormals + ebN_local*3;
1607  bj = boundaryJacobians + ebN_local*6;
1608  for(j=0;j<nDOF_element;j++)
1609  {
1610  j_global = l2g[eN*nDOF_element+
1611  j];
1612  grad = grad_psi + ebN_local*nQuadraturePoints_element*nDOF_element*3+k*nDOF_element*3 + j*3;
1613  /* nodes are always 3D */
1614  node = nodeArray + j_global*3;
1615  emj[XX] += node[X]*grad[X];
1616  emj[XY] += node[X]*grad[Y];
1617  emj[XZ] += node[X]*grad[Z];
1618  emj[YX] += node[Y]*grad[X];
1619  emj[YY] += node[Y]*grad[Y];
1620  emj[YZ] += node[Y]*grad[Z];
1621  emj[ZX] += node[Z]*grad[X];
1622  emj[ZY] += node[Z]*grad[Y];
1623  emj[ZZ] += node[Z]*grad[Z];
1624  }
1625  oneOverJacDet = 1.0/(emj[XX]*(emj[YY]*emj[ZZ] - emj[YZ]*emj[ZY]) -
1626  emj[XY]*(emj[YX]*emj[ZZ] - emj[YZ]*emj[ZX]) +
1627  emj[XZ]*(emj[YX]*emj[ZY] - emj[YY]*emj[ZX]));
1628  jacInv[XX] = oneOverJacDet*(emj[YY]*emj[ZZ] - emj[YZ]*emj[ZY]);
1629  jacInv[YX] = oneOverJacDet*(emj[YZ]*emj[ZX] - emj[YX]*emj[ZZ]);
1630  jacInv[ZX] = oneOverJacDet*(emj[YX]*emj[ZY] - emj[YY]*emj[ZX]);
1631  jacInv[XY] = oneOverJacDet*(emj[ZY]*emj[XZ] - emj[ZZ]*emj[XY]);
1632  jacInv[YY] = oneOverJacDet*(emj[ZZ]*emj[XX] - emj[ZX]*emj[XZ]);
1633  jacInv[ZY] = oneOverJacDet*(emj[ZX]*emj[XY] - emj[ZY]*emj[XX]);
1634  jacInv[XZ] = oneOverJacDet*(emj[XY]*emj[YZ] - emj[XZ]*emj[YY]);
1635  jacInv[YZ] = oneOverJacDet*(emj[XZ]*emj[YX] - emj[XX]*emj[YZ]);
1636  jacInv[ZZ] = oneOverJacDet*(emj[XX]*emj[YY] - emj[XY]*emj[YX]);
1637 
1638  ebmj[XHX] = emj[XX]*bj[XHX]+emj[XY]*bj[YHX]+emj[XZ]*bj[ZHX];
1639  ebmj[XHY] = emj[XX]*bj[XHY]+emj[XY]*bj[YHY]+emj[XZ]*bj[ZHY];
1640  ebmj[YHX] = emj[YX]*bj[XHX]+emj[YY]*bj[YHX]+emj[YZ]*bj[ZHX];
1641  ebmj[YHY] = emj[YX]*bj[XHY]+emj[YY]*bj[YHY]+emj[YZ]*bj[ZHY];
1642  ebmj[ZHX] = emj[ZX]*bj[XHX]+emj[ZY]*bj[YHX]+emj[ZZ]*bj[ZHX];
1643  ebmj[ZHY] = emj[ZX]*bj[XHY]+emj[ZY]*bj[YHY]+emj[ZZ]*bj[ZHY];
1644 
1645  mt[HXHX] = ebmj[XHX]*ebmj[XHX]+ebmj[YHX]*ebmj[YHX]+ebmj[ZHX]*ebmj[ZHX];
1646  mt[HXHY] = ebmj[XHX]*ebmj[XHY]+ebmj[YHX]*ebmj[YHY]+ebmj[ZHX]*ebmj[ZHY];
1647  mt[HYHX] = ebmj[XHY]*ebmj[XHX]+ebmj[YHY]*ebmj[YHX]+ebmj[ZHY]*ebmj[ZHX];
1648  mt[HYHY] = ebmj[XHY]*ebmj[XHY]+ebmj[YHY]*ebmj[YHY]+ebmj[ZHY]*ebmj[ZHY];
1649 
1650  *mtDetSqrt=sqrt(mt[HXHX]*mt[HYHY]- mt[HXHY]*mt[HYHX]);
1651 
1652 
1653  n[X] = (jacInv[XX]*bn[X]+jacInv[YX]*bn[Y]+jacInv[ZX]*bn[Z]);
1654  n[Y] = (jacInv[XY]*bn[X]+jacInv[YY]*bn[Y]+jacInv[ZY]*bn[Z]);
1655  n[Z] = (jacInv[XZ]*bn[X]+jacInv[YZ]*bn[Y]+jacInv[ZZ]*bn[Z]);
1656 
1657  oneOverNbn = 1.0/sqrt(n[X]*n[X]+n[Y]*n[Y]+n[Z]*n[Z]);
1658 
1659  n[X] *= oneOverNbn;
1660  n[Y] *= oneOverNbn;
1661  n[Z] *= oneOverNbn;
1662 
1663  }
1664  }
1665 }
1666 
1698 void updateMass_weak(int nElements_global,
1699  int nQuadraturePoints_element,
1700  int nDOF_test_element,
1701  double* mt,
1702  double* w_dV,
1703  double* weak_residual)
1704 {
1705  int eN,i,k;
1706  for(eN=0;eN<nElements_global;eN++)
1707  for (i=0;i<nDOF_test_element;i++)
1708  for (k=0;k<nQuadraturePoints_element;k++)
1709  weak_residual[eN*nDOF_test_element +
1710  i]
1711  +=
1712  mt[eN*nQuadraturePoints_element +
1713  k]
1714  *
1715  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
1716  k*nDOF_test_element +
1717  i];
1718 }
1719 
1759 void updateMassJacobian_weak(int nElements_global,
1760  int nQuadraturePoints_element,
1761  int nDOF_trial_element,
1762  int nDOF_test_element,
1763  double* dmt,
1764  double* v_X_w_dV,
1765  double* jacobian_weak_residual)
1766 {
1767  int eN,i,j,k,nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
1768  for(eN=0;eN<nElements_global;eN++)
1769  for (i=0;i<nDOF_test_element;i++)
1770  for (k=0;k<nQuadraturePoints_element;k++)
1771  for (j=0;j<nDOF_trial_element;j++)
1772  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
1773  i*nDOF_trial_element+
1774  j]
1775  +=
1776  dmt[eN*nQuadraturePoints_element +
1777  k]
1778  *
1779  v_X_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element +
1780  k*nDOF_test_X_trial_element +
1781  j*nDOF_test_element+
1782  i];
1783 }
1784 
1785 void updateMassJacobian_weak_lowmem(int nElements_global,
1786  int nQuadraturePoints_element,
1787  int nDOF_trial_element,
1788  int nDOF_test_element,
1789  double* dmt,
1790  double* v,
1791  double* w_dV,
1792  double* jacobian_weak_residual)
1793 {
1794  int eN,i,j,k,nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
1795  for(eN=0;eN<nElements_global;eN++)
1796  for (i=0;i<nDOF_test_element;i++)
1797  for (k=0;k<nQuadraturePoints_element;k++)
1798  for (j=0;j<nDOF_trial_element;j++)
1799  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
1800  i*nDOF_trial_element+
1801  j]
1802  +=
1803  dmt[eN*nQuadraturePoints_element +
1804  k]
1805  *
1806  v[eN*nQuadraturePoints_element*nDOF_trial_element +
1807  k*nDOF_trial_element +
1808  j]
1809  *
1810  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
1811  k*nDOF_test_element +
1812  i];
1813 }
1814 
1834 void updateMass_strong(int nElements_global,
1835  int nQuadraturePoints_element,
1836  double* mt,
1837  double* strong_residual)
1838 {
1839  int eN,k;
1840  for(eN=0;eN<nElements_global;eN++)
1841  for (k=0;k<nQuadraturePoints_element;k++)
1842  strong_residual[eN*nQuadraturePoints_element+
1843  k]
1844  +=
1845  mt[eN*nQuadraturePoints_element+
1846  k];
1847 }
1848 
1873 void updateMassJacobian_strong(int nElements_global,
1874  int nQuadraturePoints_element,
1875  int nDOF_trial_element,
1876  double* dmt,
1877  double* v,
1878  double* dstrong_residual)
1879 {
1880  int eN,k,j;
1881  for(eN=0;eN<nElements_global;eN++)
1882  for(j=0;j<nDOF_trial_element;j++)
1883  for (k=0;k<nQuadraturePoints_element;k++)
1884  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
1885  k*nDOF_trial_element +
1886  j]
1887  +=
1888  dmt[eN*nQuadraturePoints_element+
1889  k]
1890  *
1891  v[eN*nQuadraturePoints_element*nDOF_trial_element+
1892  k*nDOF_trial_element +
1893  j];
1894 }
1895 
1921 void updateMass_adjoint(int nElements_global,
1922  int nQuadraturePoints_element,
1923  int nDOF_test_element,
1924  double* dmt,
1925  double* w_dV,
1926  double* Lstar_w_dV)
1927 {
1928  int eN,i,k;
1929  for(eN=0;eN<nElements_global;eN++)
1930  for (i=0;i<nDOF_test_element;i++)
1931  for (k=0;k<nQuadraturePoints_element;k++)
1932  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
1933  k*nDOF_test_element +
1934  i]
1935  +=
1936  dmt[eN*nQuadraturePoints_element +
1937  k]
1938  *
1939  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
1940  k*nDOF_test_element +
1941  i];
1942 }
1943 
1944 
1985 void updateAdvection_weak(int nElements_global,
1986  int nQuadraturePoints_element,
1987  int nDOF_test_element,
1988  int nSpace,
1989  double* f,
1990  double* grad_w_dV,
1991  double* weak_residual)
1992 {
1993  int eN,i,k,I;
1994  for(eN=0;eN<nElements_global;eN++)
1995  for (i=0;i<nDOF_test_element;i++)
1996  for (k=0;k<nQuadraturePoints_element;k++)
1997  for (I=0;I<nSpace;I++)
1998  weak_residual[eN*nDOF_test_element +
1999  i]
2000  -=
2001  f[eN*nQuadraturePoints_element*nSpace +
2002  k*nSpace +
2003  I]
2004  *
2005  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2006  k*nDOF_test_element*nSpace +
2007  i*nSpace +
2008  I];
2009 }
2010 
2055 void updateAdvectionJacobian_weak(int nElements_global,
2056  int nQuadraturePoints_element,
2057  int nDOF_trial_element,
2058  int nDOF_test_element,
2059  int nSpace,
2060  double* df,
2061  double* v_X_grad_w_dV,
2062  double* jacobian_weak_residual)
2063 {
2064  int eN,i,j,k,I,nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
2065  for(eN=0;eN<nElements_global;eN++)
2066  for (i=0;i<nDOF_test_element;i++)
2067  for (k=0;k<nQuadraturePoints_element;k++)
2068  for (j=0;j<nDOF_trial_element;j++)
2069  for (I=0;I<nSpace;I++)
2070  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2071  i*nDOF_trial_element+
2072  j]
2073  -=
2074  df[eN*nQuadraturePoints_element*nSpace +
2075  k*nSpace +
2076  I]
2077  *
2078  v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace +
2079  k*nDOF_test_X_trial_element*nSpace +
2080  j*nDOF_test_element*nSpace +
2081  i*nSpace +
2082  I];
2083 }
2084 
2085 void updateAdvectionJacobian_weak_lowmem(int nElements_global,
2086  int nQuadraturePoints_element,
2087  int nDOF_trial_element,
2088  int nDOF_test_element,
2089  int nSpace,
2090  double* df,
2091  double* v,
2092  double* grad_w_dV,
2093  double* jacobian_weak_residual)
2094 {
2095  int eN,i,j,k,I,nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
2096  for(eN=0;eN<nElements_global;eN++)
2097  for (i=0;i<nDOF_test_element;i++)
2098  for (k=0;k<nQuadraturePoints_element;k++)
2099  for (j=0;j<nDOF_trial_element;j++)
2100  for (I=0;I<nSpace;I++)
2101  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2102  i*nDOF_trial_element+
2103  j]
2104  -=
2105  df[eN*nQuadraturePoints_element*nSpace +
2106  k*nSpace +
2107  I]
2108  *
2109  v[eN*nQuadraturePoints_element*nDOF_trial_element +
2110  k*nDOF_trial_element +
2111  j]
2112  *
2113  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2114  k*nDOF_test_element*nSpace +
2115  i*nSpace +
2116  I];
2117 }
2118 
2143 void updateAdvection_strong(int nElements_global,
2144  int nQuadraturePoints_element,
2145  int nSpace,
2146  double* df,
2147  double* grad_u,
2148  double* strong_residual)
2149 {
2150  int eN,k,I;
2151  for(eN=0;eN<nElements_global;eN++)
2152  for (k=0;k<nQuadraturePoints_element;k++)
2153  for(I=0;I<nSpace;I++)
2154  strong_residual[eN*nQuadraturePoints_element+
2155  k]
2156  +=
2157  df[eN*nQuadraturePoints_element*nSpace +
2158  k*nSpace +
2159  I]
2160  *
2161  grad_u[eN*nQuadraturePoints_element*nSpace +
2162  k*nSpace +
2163  I];
2164 }
2165 
2190 void updateAdvectionJacobian_strong(int nElements_global,
2191  int nQuadraturePoints_element,
2192  int nDOF_trial_element,
2193  int nSpace,
2194  double* df,
2195  double* grad_v,
2196  double* dstrong_residual)
2197 {
2198  int eN,k,j,I;
2199  for(eN=0;eN<nElements_global;eN++)
2200  for(j=0;j<nDOF_trial_element;j++)
2201  for (k=0;k<nQuadraturePoints_element;k++)
2202  for (I=0;I<nSpace;I++)
2203  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
2204  k*nDOF_trial_element +
2205  j]
2206  +=
2207  df[eN*nQuadraturePoints_element*nSpace +
2208  k*nSpace +
2209  I]
2210  *
2211  grad_v[eN*nQuadraturePoints_element*nSpace*nDOF_trial_element +
2212  k*nSpace*nDOF_trial_element +
2213  j*nSpace+
2214  I];
2215 }
2216 
2247 void updateAdvection_adjoint(int nElements_global,
2248  int nQuadraturePoints_element,
2249  int nDOF_test_element,
2250  int nSpace,
2251  double* df,
2252  double* grad_w_dV,
2253  double* Lstar_w_dV)
2254 {
2255  int eN,i,k,I;
2256  for(eN=0;eN<nElements_global;eN++)
2257  for (i=0;i<nDOF_test_element;i++)
2258  for (k=0;k<nQuadraturePoints_element;k++)
2259  for (I=0;I<nSpace;I++)
2260  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
2261  k*nDOF_test_element +
2262  i]
2263  -=
2264  df[eN*nQuadraturePoints_element*nSpace +
2265  k*nSpace +
2266  I]
2267  *
2268  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2269  k*nDOF_test_element*nSpace +
2270  i*nSpace +
2271  I];
2272 }
2273 
2306 void updateHamiltonian_weak(int nElements_global,
2307  int nQuadraturePoints_element,
2308  int nDOF_test_element,
2309  double* H,
2310  double* w_dV,
2311  double* weak_residual)
2312 {
2313  int eN,i,k;
2314  for(eN=0;eN<nElements_global;eN++)
2315  for (i=0;i<nDOF_test_element;i++)
2316  for (k=0;k<nQuadraturePoints_element;k++)
2317  weak_residual[eN*nDOF_test_element + i]
2318  +=
2319  H[eN*nQuadraturePoints_element +
2320  k]
2321  *
2322  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
2323  k*nDOF_test_element +
2324  i];
2325 }
2326 
2372 void updateHamiltonianJacobian_weak(int nElements_global,
2373  int nQuadraturePoints_element,
2374  int nDOF_trial_element,
2375  int nDOF_test_element,
2376  int nSpace,
2377  double* dH,
2378  double* grad_v_X_w_dV,
2379  double* jacobian_weak_residual)
2380 {
2381  int eN,i,j,k,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
2382  for(eN=0;eN<nElements_global;eN++)
2383  for (i=0;i<nDOF_test_element;i++)
2384  for (k=0;k<nQuadraturePoints_element;k++)
2385  for (j=0;j<nDOF_trial_element;j++)
2386  for (I=0;I<nSpace;I++)
2387  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2388  i*nDOF_trial_element +
2389  j]
2390  +=
2391  dH[eN*nQuadraturePoints_element*nSpace +
2392  k*nSpace+
2393  I]
2394  *
2395  grad_v_X_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace +
2396  k*nDOF_test_X_trial_element*nSpace +
2397  j*nDOF_test_element*nSpace +
2398  i*nSpace+
2399  I];
2400 }
2401 
2402 void updateHamiltonianJacobian_weak_lowmem(int nElements_global,
2403  int nQuadraturePoints_element,
2404  int nDOF_trial_element,
2405  int nDOF_test_element,
2406  int nSpace,
2407  double* dH,
2408  double* grad_v,
2409  double* w_dV,
2410  double* jacobian_weak_residual)
2411 {
2412  int eN,i,j,k,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
2413  for(eN=0;eN<nElements_global;eN++)
2414  for (i=0;i<nDOF_test_element;i++)
2415  for (k=0;k<nQuadraturePoints_element;k++)
2416  for (j=0;j<nDOF_trial_element;j++)
2417  for (I=0;I<nSpace;I++)
2418  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2419  i*nDOF_trial_element +
2420  j]
2421  +=
2422  dH[eN*nQuadraturePoints_element*nSpace +
2423  k*nSpace+
2424  I]
2425  *
2426  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
2427  k*nDOF_trial_element*nSpace +
2428  j*nSpace +
2429  I]
2430  *
2431  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
2432  k*nDOF_test_element +
2433  i];
2434 }
2435 
2462 void updateHamiltonian_strong(int nElements_global,
2463  int nQuadraturePoints_element,
2464  int nSpace,
2465  double* dH,
2466  double* grad_u,
2467  double* strong_residual)
2468 {
2469  int eN,k,I;
2470  for(eN=0;eN<nElements_global;eN++)
2471  for (k=0;k<nQuadraturePoints_element;k++)
2472  for (I=0;I<nSpace;I++)
2473  strong_residual[eN*nQuadraturePoints_element+k]
2474  +=
2475  dH[eN*nQuadraturePoints_element*nSpace+
2476  k*nSpace+
2477  I]
2478  *
2479  grad_u[eN*nQuadraturePoints_element*nSpace+
2480  k*nSpace+
2481  I];
2482 }
2483 
2508 void updateHamiltonianJacobian_strong(int nElements_global,
2509  int nQuadraturePoints_element,
2510  int nDOF_trial_element,
2511  int nSpace,
2512  double* dH,
2513  double* grad_v,
2514  double* dstrong_residual)
2515 {
2516  int eN,k,j,I;
2517  for(eN=0;eN<nElements_global;eN++)
2518  for(j=0;j<nDOF_trial_element;j++)
2519  for (k=0;k<nQuadraturePoints_element;k++)
2520  for (I=0;I<nSpace;I++)
2521  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
2522  k*nDOF_trial_element +
2523  j]
2524  +=
2525  dH[eN*nQuadraturePoints_element*nSpace+
2526  k*nSpace+
2527  I]
2528  *
2529  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace+
2530  k*nDOF_trial_element*nSpace +
2531  j*nSpace +
2532  I];
2533 }
2534 
2566 void updateHamiltonian_adjoint(int nElements_global,
2567  int nQuadraturePoints_element,
2568  int nDOF_test_element,
2569  int nSpace,
2570  double* dH,
2571  double* grad_w_dV,
2572  double* Lstar_w_dV)
2573 {
2574  int eN,i,k,I;
2575  for(eN=0;eN<nElements_global;eN++)
2576  for (i=0;i<nDOF_test_element;i++)
2577  for (k=0;k<nQuadraturePoints_element;k++)
2578  for (I=0;I<nSpace;I++)
2579  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
2580  k*nDOF_test_element +
2581  i]
2582  -=
2583  dH[eN*nQuadraturePoints_element*nSpace +
2584  k*nSpace +
2585  I]
2586  *
2587  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2588  k*nDOF_test_element*nSpace +
2589  i*nSpace +
2590  I];
2591 }
2592 
2633 /*#define SCALAR_DIFFUSION*/
2634 void updateDiffusion_weak(int nElements_global,
2635  int nQuadraturePoints_element,
2636  int nDOF_test_element,
2637  int nSpace,
2638  double* a,
2639  double* grad_phi_X_grad_w_dV,
2640  double* weak_residual)
2641 {
2642  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
2643  for(eN=0;eN<nElements_global;eN++)
2644  for (i=0;i<nDOF_test_element;i++)
2645  for (k=0;k<nQuadraturePoints_element;k++)
2646  for (I=0;I<nSpace;I++)
2647  for (J=0;J<nSpace;J++)
2648  weak_residual[eN*nDOF_test_element + i]
2649  +=
2650  a[eN*nQuadraturePoints_element*nSpace2 +
2651  k*nSpace2 +
2652  I*nSpace +
2653  J]
2654  *
2655  grad_phi_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2 +
2656  k*nDOF_test_element*nSpace2 +
2657  i*nSpace2+
2658  J*nSpace +
2659  I];
2660 }
2661 
2662 void updateDiffusion_weak_lowmem(int nElements_global,
2663  int nQuadraturePoints_element,
2664  int nDOF_test_element,
2665  int nSpace,
2666  double* a,
2667  double* grad_phi,
2668  double* grad_w_dV,
2669  double* weak_residual)
2670 {
2671  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
2672  for(eN=0;eN<nElements_global;eN++)
2673  for (i=0;i<nDOF_test_element;i++)
2674  for (k=0;k<nQuadraturePoints_element;k++)
2675 #ifdef SCALAR_DIFFUSION
2676  for (I=0;I<nSpace;I++)
2677  {
2678  J=I;
2679  weak_residual[eN*nDOF_test_element + i]
2680  +=
2681  a[eN*nQuadraturePoints_element*nSpace2 +
2682  k*nSpace2]
2683  *
2684  grad_phi[eN*nQuadraturePoints_element*nSpace +
2685  k*nSpace +
2686  J]
2687  *
2688  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2689  k*nDOF_test_element*nSpace +
2690  i*nSpace+
2691  I];
2692  }
2693 #else
2694  for (I=0;I<nSpace;I++)
2695  for (J=0;J<nSpace;J++)
2696  weak_residual[eN*nDOF_test_element + i]
2697  +=
2698  a[eN*nQuadraturePoints_element*nSpace2 +
2699  k*nSpace2 +
2700  I*nSpace +
2701  J]
2702  *
2703  grad_phi[eN*nQuadraturePoints_element*nSpace +
2704  k*nSpace +
2705  J]
2706  *
2707  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2708  k*nDOF_test_element*nSpace +
2709  i*nSpace+
2710  I];
2711 #endif
2712 }
2713 
2714 void updateDiffusion_weak_sd(int nElements_global,
2715  int nQuadraturePoints_element,
2716  int nDOF_test_element,
2717  int nSpace,
2718  int* rowptr,
2719  int* colind,
2720  double* a,
2721  double* grad_phi,
2722  double* grad_w_dV,
2723  double* weak_residual)
2724 {
2725  int eN,i,k,I,m,nnz=rowptr[nSpace];
2726  for(eN=0;eN<nElements_global;eN++)
2727  for (i=0;i<nDOF_test_element;i++)
2728  for (k=0;k<nQuadraturePoints_element;k++)
2729  for (I=0;I<nSpace;I++)
2730  for (m=rowptr[I];m<rowptr[I+1];m++)
2731  weak_residual[eN*nDOF_test_element + i]
2732  +=
2733  a[eN*nQuadraturePoints_element*nnz+
2734  k*nnz +
2735  m]
2736  *
2737  grad_phi[eN*nQuadraturePoints_element*nSpace +
2738  k*nSpace +
2739  colind[m]]
2740  *
2741  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2742  k*nDOF_test_element*nSpace +
2743  i*nSpace+
2744  I];
2745 }
2746 
2819 void updateDiffusionJacobian_weak(int nElements_global,
2820  int nQuadraturePoints_element,
2821  int nDOF_trial_element,
2822  int nDOF_test_element,
2823  int nSpace,
2824  int* l2g,
2825  double* a,
2826  double* da,
2827  double* grad_phi_X_grad_w_dV,
2828  double* dphi,
2829  double* v,
2830  double* grad_v_X_grad_w_dV,
2831  double* jacobian_weak_residual)
2832 {
2833  int eN,i,j,k,I,J,nSpace2=nSpace*nSpace,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
2834  double daProduct,dphiProduct;
2835  for(eN=0;eN<nElements_global;eN++)
2836  for (i=0;i<nDOF_test_element;i++)
2837  for (k=0;k<nQuadraturePoints_element;k++)
2838  {
2839  daProduct=0.0;
2840  for (I=0;I<nSpace;I++)
2841  for (J=0;J<nSpace;J++)
2842  daProduct
2843  +=
2844  da[eN*nQuadraturePoints_element*nSpace2 +
2845  k*nSpace2 +
2846  I*nSpace +
2847  J]
2848  *
2849  grad_phi_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2 +
2850  k*nDOF_test_element*nSpace2 +
2851  i*nSpace2+
2852  J*nSpace +
2853  I];
2854  for (j=0;j<nDOF_trial_element;j++)
2855  {
2856  dphiProduct=0.0;
2857  for (I=0;I<nSpace;I++)
2858  for (J=0;J<nSpace;J++)
2859  dphiProduct
2860  +=
2861  a[eN*nQuadraturePoints_element*nSpace2 +
2862  k*nSpace2+
2863  I*nSpace +
2864  J]
2865  *
2866  grad_v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace2 +
2867  k*nDOF_test_X_trial_element*nSpace2 +
2868  j*nDOF_test_element*nSpace2 +
2869  i*nSpace2 +
2870  J*nSpace +
2871  I];
2872  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2873  i*nDOF_trial_element +
2874  j]
2875  +=
2876  daProduct
2877  *
2878  v[eN*nQuadraturePoints_element*nDOF_trial_element+
2879  k*nDOF_trial_element+
2880  j]
2881  +
2882  dphiProduct
2883  *
2884  dphi[l2g[eN*nDOF_trial_element +
2885  j]];
2886  }
2887  }
2888 }
2889 
2890 void updateDiffusionJacobian_weak_lowmem(int nElements_global,
2891  int nQuadraturePoints_element,
2892  int nDOF_trial_element,
2893  int nDOF_test_element,
2894  int nSpace,
2895  int* l2g,
2896  double* a,
2897  double* da,
2898  double* grad_phi,
2899  double* grad_w_dV,
2900  double* dphi,
2901  double* v,
2902  double* grad_v,
2903  double* jacobian_weak_residual)
2904 {
2905  int eN,i,j,k,I,J,nSpace2=nSpace*nSpace,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
2906  double daProduct,dphiProduct;
2907  for(eN=0;eN<nElements_global;eN++)
2908  for (i=0;i<nDOF_test_element;i++)
2909  for (k=0;k<nQuadraturePoints_element;k++)
2910  {
2911  daProduct=0.0;
2912 #ifdef SCALAR_DIFFUSION
2913  for (I=0;I<nSpace;I++)
2914  {
2915  J=I;
2916  daProduct
2917  +=
2918  da[eN*nQuadraturePoints_element*nSpace2 +
2919  k*nSpace2]
2920  *
2921  grad_phi[eN*nQuadraturePoints_element*nSpace +
2922  k*nSpace +
2923  J]
2924  *
2925  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2926  k*nDOF_test_element*nSpace +
2927  i*nSpace+
2928  I];
2929  }
2930  for (j=0;j<nDOF_trial_element;j++)
2931  {
2932  dphiProduct=0.0;
2933  for (I=0;I<nSpace;I++)
2934  {
2935  J=I;
2936  dphiProduct
2937  +=
2938  a[eN*nQuadraturePoints_element*nSpace2 +
2939  k*nSpace2]
2940  *
2941  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
2942  k*nDOF_trial_element*nSpace +
2943  j*nSpace +
2944  J]
2945  *
2946  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2947  k*nDOF_test_element*nSpace +
2948  i*nSpace +
2949  I];
2950  }
2951  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
2952  i*nDOF_trial_element +
2953  j]
2954  +=
2955  daProduct
2956  *
2957  v[eN*nQuadraturePoints_element*nDOF_trial_element+
2958  k*nDOF_trial_element+
2959  j]
2960  +
2961  dphiProduct
2962  *
2963  dphi[l2g[eN*nDOF_trial_element +
2964  j]];
2965  }
2966 #else
2967  for (I=0;I<nSpace;I++)
2968  for (J=0;J<nSpace;J++)
2969  daProduct
2970  +=
2971  da[eN*nQuadraturePoints_element*nSpace2 +
2972  k*nSpace2 +
2973  I*nSpace +
2974  J]
2975  *
2976  grad_phi[eN*nQuadraturePoints_element*nSpace +
2977  k*nSpace +
2978  J]
2979  *
2980  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
2981  k*nDOF_test_element*nSpace +
2982  i*nSpace+
2983  I];
2984  for (j=0;j<nDOF_trial_element;j++)
2985  {
2986  dphiProduct=0.0;
2987  for (I=0;I<nSpace;I++)
2988  for (J=0;J<nSpace;J++)
2989  dphiProduct
2990  +=
2991  a[eN*nQuadraturePoints_element*nSpace2 +
2992  k*nSpace2+
2993  I*nSpace +
2994  J]
2995  *
2996  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
2997  k*nDOF_trial_element*nSpace +
2998  j*nSpace +
2999  J]
3000  *
3001  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
3002  k*nDOF_test_element*nSpace +
3003  i*nSpace +
3004  I];
3005  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
3006  i*nDOF_trial_element +
3007  j]
3008  +=
3009  daProduct
3010  *
3011  v[eN*nQuadraturePoints_element*nDOF_trial_element+
3012  k*nDOF_trial_element+
3013  j]
3014  +
3015  dphiProduct
3016  *
3017  dphi[l2g[eN*nDOF_trial_element +
3018  j]];
3019  }
3020 #endif
3021  }
3022 }
3023 void updateDiffusionJacobian_weak_sd(int nElements_global,
3024  int nQuadraturePoints_element,
3025  int nDOF_trial_element,
3026  int nDOF_test_element,
3027  int nSpace,
3028  int* rowptr,
3029  int* colind,
3030  int* l2g,
3031  double* a,
3032  double* da,
3033  double* grad_phi,
3034  double* grad_w_dV,
3035  double* dphi,
3036  double* v,
3037  double* grad_v,
3038  double* jacobian_weak_residual)
3039 {
3040  int eN,i,j,k,I,m,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,nnz=rowptr[nSpace];
3041  double daProduct,dphiProduct;
3042  for(eN=0;eN<nElements_global;eN++)
3043  for (i=0;i<nDOF_test_element;i++)
3044  for (k=0;k<nQuadraturePoints_element;k++)
3045  {
3046  daProduct=0.0;
3047  for (I=0;I<nSpace;I++)
3048  for (m=rowptr[I];m<rowptr[I+1];m++)
3049  daProduct
3050  +=
3051  da[eN*nQuadraturePoints_element*nnz+
3052  k*nnz +
3053  m]
3054  *
3055  grad_phi[eN*nQuadraturePoints_element*nSpace +
3056  k*nSpace +
3057  colind[m]]
3058  *
3059  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
3060  k*nDOF_test_element*nSpace +
3061  i*nSpace+
3062  I];
3063  for (j=0;j<nDOF_trial_element;j++)
3064  {
3065  dphiProduct=0.0;
3066  for (I=0;I<nSpace;I++)
3067  for(m=rowptr[I];m<rowptr[I+1];m++)
3068  dphiProduct
3069  +=
3070  a[eN*nQuadraturePoints_element*nnz +
3071  k*nnz+
3072  m]
3073  *
3074  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
3075  k*nDOF_trial_element*nSpace +
3076  j*nSpace +
3077  colind[m]]
3078  *
3079  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
3080  k*nDOF_test_element*nSpace +
3081  i*nSpace +
3082  I];
3083  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
3084  i*nDOF_trial_element +
3085  j]
3086  +=
3087  daProduct
3088  *
3089  v[eN*nQuadraturePoints_element*nDOF_trial_element+
3090  k*nDOF_trial_element+
3091  j]
3092  +
3093  dphiProduct
3094  *
3095  dphi[l2g[eN*nDOF_trial_element +
3096  j]];
3097  }
3098  }
3099 }
3100 
3125 void updateDiffusion_strong(int nElements_global,
3126  int nQuadraturePoints_element,
3127  int nSpace,
3128  double* da,
3129  double* grad_phi,
3130  double* grad_u,
3131  double* strong_residual)
3132 {
3133  int eN,k,I,J,nSpace2=nSpace*nSpace;
3134  for(eN=0;eN<nElements_global;eN++)
3135  for (k=0;k<nQuadraturePoints_element;k++)
3136  for(I=0;I<nSpace;I++)
3137  for (J=0;J<nSpace;J++)
3138  strong_residual[eN*nQuadraturePoints_element+
3139  k]
3140  -=
3141  da[eN*nQuadraturePoints_element*nSpace2 +
3142  k*nSpace2 +
3143  I*nSpace+
3144  J]
3145  *
3146  grad_phi[eN*nQuadraturePoints_element*nSpace +
3147  k*nSpace +
3148  J]
3149  *grad_u[eN*nQuadraturePoints_element*nSpace +
3150  k*nSpace +
3151  I];
3152 }
3153 void updateDiffusion_strong_sd(int nElements_global,
3154  int nQuadraturePoints_element,
3155  int nSpace,
3156  int* rowptr,
3157  int* colind,
3158  double* da,
3159  double* grad_phi,
3160  double* grad_u,
3161  double* strong_residual)
3162 {
3163  int eN,k,I,m,nnz=rowptr[nSpace];
3164  for(eN=0;eN<nElements_global;eN++)
3165  for (k=0;k<nQuadraturePoints_element;k++)
3166  for(I=0;I<nSpace;I++)
3167  for(m=rowptr[I];m<rowptr[I+1];m++)
3168  strong_residual[eN*nQuadraturePoints_element+
3169  k]
3170  -=
3171  da[eN*nQuadraturePoints_element*nnz +
3172  k*nnz+
3173  m]
3174  *
3175  grad_phi[eN*nQuadraturePoints_element*nSpace +
3176  k*nSpace +
3177  colind[m]]
3178  *grad_u[eN*nQuadraturePoints_element*nSpace +
3179  k*nSpace +
3180  I];
3181 }
3182 
3207 void updateDiffusionJacobian_strong(int nElements_global,
3208  int nQuadraturePoints_element,
3209  int nDOF_trial_element,
3210  int nSpace,
3211  int* l2g,
3212  double* da,
3213  double* dphi,
3214  double* grad_phi,
3215  double* grad_u,
3216  double* grad_v,
3217  double* dstrong_residual)
3218 {
3219  int eN,k,j,I,J,nSpace2=nSpace*nSpace;
3220  for(eN=0;eN<nElements_global;eN++)
3221  for (k=0;k<nQuadraturePoints_element;k++)
3222  for(j=0;j<nDOF_trial_element;j++)
3223  for(I=0;I<nSpace;I++)
3224  for(J=0;J<nSpace;J++)
3225  {
3226  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
3227  k*nDOF_trial_element +
3228  j]
3229  -=
3230  da[eN*nQuadraturePoints_element*nSpace2 +
3231  k*nSpace2 +
3232  I*nSpace+
3233  J]
3234  *
3235  (
3236  grad_phi[eN*nQuadraturePoints_element*nSpace +
3237  k*nSpace +
3238  J]
3239  *
3240  grad_v[eN*nQuadraturePoints_element*nSpace*nDOF_trial_element +
3241  k*nSpace*nDOF_trial_element +
3242  j*nSpace +
3243  I]
3244  +
3245  dphi[l2g[eN*nDOF_trial_element +
3246  j]]*
3247  grad_v[eN*nQuadraturePoints_element*nSpace*nDOF_trial_element +
3248  k*nSpace*nDOF_trial_element +
3249  j*nSpace +
3250  J]
3251  *
3252  grad_u[eN*nQuadraturePoints_element*nSpace+
3253  k*nSpace+
3254  I]
3255  );
3256  }
3257 }
3258 void updateDiffusionJacobian_strong_sd(int nElements_global,
3259  int nQuadraturePoints_element,
3260  int nDOF_trial_element,
3261  int nSpace,
3262  int* rowptr,
3263  int* colind,
3264  int* l2g,
3265  double* da,
3266  double* dphi,
3267  double* grad_phi,
3268  double* grad_u,
3269  double* grad_v,
3270  double* dstrong_residual)
3271 {
3272  int eN,k,j,I,m,nnz=rowptr[nSpace];
3273  for(eN=0;eN<nElements_global;eN++)
3274  for (k=0;k<nQuadraturePoints_element;k++)
3275  for(j=0;j<nDOF_trial_element;j++)
3276  for(I=0;I<nSpace;I++)
3277  for(m=rowptr[I];m<rowptr[I+1];m++)
3278  {
3279  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
3280  k*nDOF_trial_element +
3281  j]
3282  -=
3283  da[eN*nQuadraturePoints_element*nnz +
3284  k*nnz+
3285  m]
3286  *
3287  (
3288  grad_phi[eN*nQuadraturePoints_element*nSpace +
3289  k*nSpace +
3290  colind[m]]
3291  *
3292  grad_v[eN*nQuadraturePoints_element*nSpace*nDOF_trial_element +
3293  k*nSpace*nDOF_trial_element +
3294  j*nSpace +
3295  I]
3296  +
3297  dphi[l2g[eN*nDOF_trial_element +
3298  j]]*
3299  grad_v[eN*nQuadraturePoints_element*nSpace*nDOF_trial_element +
3300  k*nSpace*nDOF_trial_element +
3301  j*nSpace +
3302  colind[m]]
3303  *
3304  grad_u[eN*nQuadraturePoints_element*nSpace+
3305  k*nSpace+
3306  I]
3307  );
3308  }
3309 }
3310 
3311 
3344 void updateDiffusion_adjoint(int nElements_global,
3345  int nQuadraturePoints_element,
3346  int nDOF_test_element,
3347  int nSpace,
3348  double* da,
3349  double* grad_phi,
3350  double* grad_w_dV,
3351  double* Lstar_w_dV)
3352 {
3353  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
3354  for(eN=0;eN<nElements_global;eN++)
3355  for (i=0;i<nDOF_test_element;i++)
3356  for (k=0;k<nQuadraturePoints_element;k++)
3357  for (I=0;I<nSpace;I++)
3358  for(J=0;J<nSpace;J++)
3359  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3360  k*nDOF_test_element +
3361  i]
3362  +=
3363  da[eN*nQuadraturePoints_element*nSpace2 +
3364  k*nSpace2 +
3365  I*nSpace+
3366  J]
3367  *
3368  grad_phi[eN*nQuadraturePoints_element*nSpace+
3369  k*nSpace+
3370  J]
3371  *
3372  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
3373  k*nDOF_test_element*nSpace +
3374  i*nSpace +
3375  I];
3376 }
3377 
3378 void updateDiffusion_adjoint_sd(int nElements_global,
3379  int nQuadraturePoints_element,
3380  int nDOF_test_element,
3381  int nSpace,
3382  int* rowptr,
3383  int* colind,
3384  double* da,
3385  double* grad_phi,
3386  double* grad_w_dV,
3387  double* Lstar_w_dV)
3388 {
3389  int eN,i,k,I,m,nnz=rowptr[nSpace];
3390  for(eN=0;eN<nElements_global;eN++)
3391  for (i=0;i<nDOF_test_element;i++)
3392  for (k=0;k<nQuadraturePoints_element;k++)
3393  for (I=0;I<nSpace;I++)
3394  for(m=rowptr[I];m<rowptr[I+1];m++)
3395  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3396  k*nDOF_test_element +
3397  i]
3398  +=
3399  da[eN*nQuadraturePoints_element*nnz +
3400  k*nnz+
3401  m]
3402  *
3403  grad_phi[eN*nQuadraturePoints_element*nSpace+
3404  k*nSpace+
3405  colind[m]]
3406  *
3407  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
3408  k*nDOF_test_element*nSpace +
3409  i*nSpace +
3410  I];
3411 }
3412 
3413 void updateDiffusion2_strong(int nElements_global,
3414  int nQuadraturePoints_element,
3415  int nSpace,
3416  double* a,
3417  double* Hess_phi,
3418  double* strong_residual)
3419 {
3420  int eN,k,I,J,nSpace2=nSpace*nSpace;
3421  for(eN=0;eN<nElements_global;eN++)
3422  for (k=0;k<nQuadraturePoints_element;k++)
3423  for(I=0;I<nSpace;I++)
3424  for (J=0;J<nSpace;J++)
3425  {
3426  strong_residual[eN*nQuadraturePoints_element+
3427  k]
3428  -=
3429  a[eN*nQuadraturePoints_element*nSpace2 +
3430  k*nSpace2 +
3431  I*nSpace+
3432  J]
3433  *
3434  Hess_phi[eN*nQuadraturePoints_element*nSpace2 +
3435  k*nSpace2 +
3436  J*nSpace+
3437  I];
3438  }
3439 }
3440 
3441 void updateDiffusion2_strong_sd(int nElements_global,
3442  int nQuadraturePoints_element,
3443  int nSpace,
3444  int* rowptr,
3445  int* colind,
3446  double* a,
3447  double* Hess_phi,
3448  double* strong_residual)
3449 {
3450  int eN,k,I,m,nSpace2=nSpace*nSpace,nnz=rowptr[nSpace];
3451  for(eN=0;eN<nElements_global;eN++)
3452  for (k=0;k<nQuadraturePoints_element;k++)
3453  for(I=0;I<nSpace;I++)
3454  for (m=rowptr[I];m<rowptr[I+1];m++)
3455  {
3456  strong_residual[eN*nQuadraturePoints_element+
3457  k]
3458  -=
3459  a[eN*nQuadraturePoints_element*nnz +
3460  k*nnz+
3461  m]
3462  *
3463  Hess_phi[eN*nQuadraturePoints_element*nSpace2 +
3464  k*nSpace2 +
3465  colind[m]*nSpace+
3466  I];
3467  }
3468 }
3469 
3470 void updateDiffusionJacobian2_strong(int nElements_global,
3471  int nQuadraturePoints_element,
3472  int nDOF_trial_element,
3473  int nSpace,
3474  int* l2g,
3475  double* a,
3476  double* da,
3477  double* v,
3478  double* Hess_phi,
3479  double* dphi,
3480  double* Hess_v,
3481  double* dstrong_residual)
3482 {
3483  int eN,k,j,I,J,nSpace2=nSpace*nSpace;
3484  /*double tmp;*/
3485  for(eN=0;eN<nElements_global;eN++)
3486  for (k=0;k<nQuadraturePoints_element;k++)
3487  for (j=0;j<nDOF_trial_element;j++)
3488  for(I=0;I<nSpace;I++)
3489  for (J=0;J<nSpace;J++)
3490  {
3491  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
3492  k*nDOF_trial_element+
3493  j]
3494  -=
3495  (da[eN*nQuadraturePoints_element*nSpace2 +
3496  k*nSpace2 +
3497  I*nSpace+
3498  J]
3499  *
3500  v[eN*nQuadraturePoints_element*nDOF_trial_element+
3501  k*nDOF_trial_element+
3502  j]
3503  *
3504  Hess_phi[eN*nQuadraturePoints_element*nSpace2 +
3505  k*nSpace2 +
3506  J*nSpace+
3507  I]
3508  +
3509  a[eN*nQuadraturePoints_element*nSpace2 +
3510  k*nSpace2 +
3511  I*nSpace+
3512  J]
3513  *
3514  dphi[l2g[eN*nDOF_trial_element +
3515  j]]
3516  *
3517  Hess_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace2 +
3518  k*nDOF_trial_element*nSpace2 +
3519  j*nSpace2+
3520  J*nSpace+
3521  I]);
3522  }
3523 }
3524 
3525 void updateDiffusionJacobian2_strong_sd(int nElements_global,
3526  int nQuadraturePoints_element,
3527  int nDOF_trial_element,
3528  int nSpace,
3529  int* rowptr,
3530  int* colind,
3531  int* l2g,
3532  double* a,
3533  double* da,
3534  double* v,
3535  double* Hess_phi,
3536  double* dphi,
3537  double* Hess_v,
3538  double* dstrong_residual)
3539 {
3540  int eN,k,j,I,m,nSpace2=nSpace*nSpace,nnz=rowptr[nSpace];
3541  /*double tmp;*/
3542  for(eN=0;eN<nElements_global;eN++)
3543  for (k=0;k<nQuadraturePoints_element;k++)
3544  for (j=0;j<nDOF_trial_element;j++)
3545  for(I=0;I<nSpace;I++)
3546  for (m=rowptr[I];m<rowptr[I+1];m++)
3547  {
3548  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
3549  k*nDOF_trial_element+
3550  j]
3551  -=
3552  (da[eN*nQuadraturePoints_element*nnz+
3553  k*nnz+
3554  m]
3555  *
3556  v[eN*nQuadraturePoints_element*nDOF_trial_element+
3557  k*nDOF_trial_element+
3558  j]
3559  *
3560  Hess_phi[eN*nQuadraturePoints_element*nSpace2 +
3561  k*nSpace2 +
3562  colind[m]*nSpace+
3563  I]
3564  +
3565  a[eN*nQuadraturePoints_element*nnz+
3566  k*nnz+
3567  m]
3568  *
3569  dphi[l2g[eN*nDOF_trial_element +
3570  j]]
3571  *
3572  Hess_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace2 +
3573  k*nDOF_trial_element*nSpace2 +
3574  j*nSpace2+
3575  colind[m]*nSpace+
3576  I]);
3577  }
3578 }
3579 
3580 void updateDiffusion2_adjoint(int nElements_global,
3581  int nQuadraturePoints_element,
3582  int nDOF_test_element,
3583  int nSpace,
3584  double* a,
3585  double* Hess_w_dV,
3586  double* Lstar_w_dV)
3587 {
3588  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
3589  for(eN=0;eN<nElements_global;eN++)
3590  for (i=0;i<nDOF_test_element;i++)
3591  for (k=0;k<nQuadraturePoints_element;k++)
3592  for (I=0;I<nSpace;I++)
3593  for(J=0;J<nSpace;J++)
3594  {
3595  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3596  k*nDOF_test_element +
3597  i]
3598  -=
3599  a[eN*nQuadraturePoints_element*nSpace2 +
3600  k*nSpace2 +
3601  I*nSpace+
3602  J]
3603  *
3604  Hess_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2 +
3605  k*nDOF_test_element*nSpace2 +
3606  i*nSpace2+
3607  I*nSpace +
3608  J];
3609  }
3610 }
3611 
3612 
3613 void updateDiffusion2_adjoint_sd(int nElements_global,
3614  int nQuadraturePoints_element,
3615  int nDOF_test_element,
3616  int nSpace,
3617  int* rowptr,
3618  int* colind,
3619  double* a,
3620  double* Hess_w_dV,
3621  double* Lstar_w_dV)
3622 {
3623  int eN,i,k,I,m,nSpace2=nSpace*nSpace,nnz=rowptr[nSpace];
3624  for(eN=0;eN<nElements_global;eN++)
3625  for (i=0;i<nDOF_test_element;i++)
3626  for (k=0;k<nQuadraturePoints_element;k++)
3627  for (I=0;I<nSpace;I++)
3628  for(m=rowptr[I];m<rowptr[I+1];m++)
3629  {
3630  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3631  k*nDOF_test_element +
3632  i]
3633  -=
3634  a[eN*nQuadraturePoints_element*nnz+
3635  k*nnz+
3636  m]
3637  *
3638  Hess_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2 +
3639  k*nDOF_test_element*nSpace2 +
3640  i*nSpace2+
3641  I*nSpace +
3642  colind[m]];
3643  }
3644 }
3645 
3646 
3680 void updateReaction_weak(int nElements_global,
3681  int nQuadraturePoints_element,
3682  int nDOF_test_element,
3683  double* r,
3684  double* w_dV,
3685  double* weak_residual)
3686 {
3687  updateMass_weak(nElements_global,nQuadraturePoints_element,nDOF_test_element,r,w_dV,weak_residual);
3688 }
3689 
3729 void updateReactionJacobian_weak(int nElements_global,
3730  int nQuadraturePoints_element,
3731  int nDOF_trial_element,
3732  int nDOF_test_element,
3733  double* dr,
3734  double* v_X_w_dV,
3735  double* jacobian_weak_residual)
3736 {
3737  updateMassJacobian_weak(nElements_global,nQuadraturePoints_element,nDOF_trial_element,nDOF_test_element,dr,v_X_w_dV,jacobian_weak_residual);
3738 }
3739 
3740 void updateReactionJacobian_weak_lowmem(int nElements_global,
3741  int nQuadraturePoints_element,
3742  int nDOF_trial_element,
3743  int nDOF_test_element,
3744  double* dr,
3745  double* v,
3746  double* w_dV,
3747  double* jacobian_weak_residual)
3748 {
3749  updateMassJacobian_weak_lowmem(nElements_global,nQuadraturePoints_element,nDOF_trial_element,nDOF_test_element,dr,
3750  v,w_dV,jacobian_weak_residual);
3751 }
3752 
3771 void updateReaction_strong(int nElements_global,
3772  int nQuadraturePoints_element,
3773  double* r,
3774  double* strong_residual)
3775 {
3776  int eN,k;
3777  for(eN=0;eN<nElements_global;eN++)
3778  for (k=0;k<nQuadraturePoints_element;k++)
3779  strong_residual[eN*nQuadraturePoints_element+
3780  k]
3781  +=
3782  r[eN*nQuadraturePoints_element+
3783  k];
3784 }
3785 
3805 void updateReactionJacobian_strong(int nElements_global,
3806  int nQuadraturePoints_element,
3807  int nDOF_trial_element,
3808  double* dr,
3809  double* v,
3810  double* dstrong_residual)
3811 {
3812  int eN,k,j;
3813  for(eN=0;eN<nElements_global;eN++)
3814  for(j=0;j<nDOF_trial_element;j++)
3815  for (k=0;k<nQuadraturePoints_element;k++)
3816  dstrong_residual[eN*nQuadraturePoints_element*nDOF_trial_element+
3817  k*nDOF_trial_element +
3818  j]
3819  +=
3820  dr[eN*nQuadraturePoints_element+
3821  k]
3822  *
3823  v[eN*nQuadraturePoints_element*nDOF_trial_element+
3824  k*nDOF_trial_element +
3825  j];
3826 }
3827 
3852 void updateReaction_adjoint(int nElements_global,
3853  int nQuadraturePoints_element,
3854  int nDOF_test_element,
3855  double* dr,
3856  double* w_dV,
3857  double* Lstar_w_dV)
3858 {
3859  int eN,i,k;
3860  for(eN=0;eN<nElements_global;eN++)
3861  for (i=0;i<nDOF_test_element;i++)
3862  for (k=0;k<nQuadraturePoints_element;k++)
3863  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3864  k*nDOF_test_element +
3865  i]
3866  +=
3867  dr[eN*nQuadraturePoints_element +
3868  k]
3869  *
3870  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3871  k*nDOF_test_element +
3872  i];
3873 }
3874 
3875 
3909 void updateSubgridError(int nElements_global,
3910  int nQuadraturePoints_element,
3911  int nDOF_test_element,
3912  double* error,
3913  double* Lstar_w_dV,
3914  double* weak_residual)
3915 {
3916  int eN,i,k;
3917  for(eN=0;eN<nElements_global;eN++)
3918  for (i=0;i<nDOF_test_element;i++)
3919  for (k=0;k<nQuadraturePoints_element;k++)
3920  weak_residual[eN*nDOF_test_element + i]
3921  +=
3922  error[eN*nQuadraturePoints_element +
3923  k]
3924  *
3925  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3926  k*nDOF_test_element +
3927  i];
3928 }
3929 
3969 void updateSubgridErrorJacobian(int nElements_global,
3970  int nQuadraturePoints_element,
3971  int nDOF_trial_element,
3972  int nDOF_test_element,
3973  double* derror,
3974  double* Lstar_w_dV,
3975  double* jacobian_weak_residual)
3976 {
3977  int eN,i,j,k,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
3978  for(eN=0;eN<nElements_global;eN++)
3979  for (i=0;i<nDOF_test_element;i++)
3980  for (k=0;k<nQuadraturePoints_element;k++)
3981  for (j=0;j<nDOF_trial_element;j++)
3982  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
3983  i*nDOF_trial_element +
3984  j]
3985  +=
3986  derror[eN*nQuadraturePoints_element*nDOF_trial_element+
3987  k*nDOF_trial_element+
3988  j]
3989  *
3990  Lstar_w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
3991  k*nDOF_test_element +
3992  i];
3993 }
3994 
4034 void updateNumericalDiffusion(int nElements_global,
4035  int nQuadraturePoints_element,
4036  int nDOF_test_element,
4037  int nSpace,
4038  double* numDiff,
4039  double* grad_u_X_grad_w_dV,
4040  double* weak_residual)
4041 {
4042  int eN,i,k,I,nSpace2=nSpace*nSpace;
4043  for(eN=0;eN<nElements_global;eN++)
4044  for (i=0;i<nDOF_test_element;i++)
4045  for (k=0;k<nQuadraturePoints_element;k++)
4046  for (I=0;I<nSpace;I++)
4047  weak_residual[eN*nDOF_test_element + i]
4048  +=
4049  numDiff[eN*nQuadraturePoints_element +
4050  k]
4051  *
4052  grad_u_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2 +
4053  k*nDOF_test_element*nSpace2 +
4054  i*nSpace2 +
4055  I*nSpace +
4056  I];
4057 }
4058 
4059 void updateNumericalDiffusion_lowmem(int nElements_global,
4060  int nQuadraturePoints_element,
4061  int nDOF_test_element,
4062  int nSpace,
4063  double* numDiff,
4064  double* grad_u,
4065  double* grad_w_dV,
4066  double* weak_residual)
4067 {
4068  int eN,i,k,I;
4069  for(eN=0;eN<nElements_global;eN++)
4070  for (i=0;i<nDOF_test_element;i++)
4071  for (k=0;k<nQuadraturePoints_element;k++)
4072  for (I=0;I<nSpace;I++)
4073  weak_residual[eN*nDOF_test_element + i]
4074  +=
4075  numDiff[eN*nQuadraturePoints_element +
4076  k]
4077  *
4078  grad_u[eN*nQuadraturePoints_element*nSpace +
4079  k*nSpace +
4080  I]
4081  *
4082  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
4083  k*nDOF_test_element*nSpace +
4084  i*nSpace +
4085  I];
4086 }
4087 
4131 void updateNumericalDiffusionJacobian(int nElements_global,
4132  int nQuadraturePoints_element,
4133  int nDOF_trial_element,
4134  int nDOF_test_element,
4135  int nSpace,
4136  double* numDiff,
4137  double* grad_v_X_grad_w_dV,
4138  double* jacobian_weak_residual)
4139 {
4140  int eN,i,j,k,I,nSpace2=nSpace*nSpace,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
4141  for(eN=0;eN<nElements_global;eN++)
4142  for (i=0;i<nDOF_test_element;i++)
4143  for (k=0;k<nQuadraturePoints_element;k++)
4144  for (j=0;j<nDOF_trial_element;j++)
4145  for (I=0;I<nSpace;I++)
4146  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
4147  i*nDOF_trial_element +
4148  j]
4149  +=
4150  numDiff[eN*nQuadraturePoints_element +
4151  k]
4152  *
4153  grad_v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace2 +
4154  k*nDOF_test_X_trial_element*nSpace2 +
4155  j*nDOF_test_element*nSpace2 +
4156  i*nSpace2 +
4157  I*nSpace +
4158  I];
4159 }
4160 
4162  int nQuadraturePoints_element,
4163  int nDOF_trial_element,
4164  int nDOF_test_element,
4165  int nSpace,
4166  double* numDiff,
4167  double* grad_v,
4168  double* grad_w_dV,
4169  double* jacobian_weak_residual)
4170 {
4171  int eN,i,j,k,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
4172  for(eN=0;eN<nElements_global;eN++)
4173  for (i=0;i<nDOF_test_element;i++)
4174  for (k=0;k<nQuadraturePoints_element;k++)
4175  for (j=0;j<nDOF_trial_element;j++)
4176  for (I=0;I<nSpace;I++)
4177  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
4178  i*nDOF_trial_element +
4179  j]
4180  +=
4181  numDiff[eN*nQuadraturePoints_element +
4182  k]
4183  *
4184  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
4185  k*nDOF_trial_element*nSpace +
4186  j*nSpace +
4187  I]
4188  *
4189  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
4190  k*nDOF_test_element*nSpace +
4191  i*nSpace +
4192  I];
4193 }
4194 
4198 void calculateScalarScalarProduct(int nElements_global,
4199  int nQuadraturePoints_element,
4200  double* s1,
4201  double* s2,
4202  double* sResult)
4203 {
4204  int eN,k;
4205  for(eN=0;eN<nElements_global;eN++)
4206  for (k=0;k<nQuadraturePoints_element;k++)
4207  sResult[eN*nQuadraturePoints_element +
4208  k]
4209  =
4210  s1[eN*nQuadraturePoints_element +
4211  k]
4212  *
4213  s2[eN*nQuadraturePoints_element +
4214  k];
4215 }
4216 
4220 void calculateVectorScalarProduct(int nElements_global,
4221  int nQuadraturePoints_element,
4222  int nSpace,
4223  double* v,
4224  double* s,
4225  double* vResult)
4226 {
4227  int eN,k,I;
4228  for(eN=0;eN<nElements_global;eN++)
4229  for (k=0;k<nQuadraturePoints_element;k++)
4230  for (I=0;I<nSpace;I++)
4231  vResult[eN*nQuadraturePoints_element*nSpace +
4232  k*nSpace +
4233  I]
4234  =
4235  v[eN*nQuadraturePoints_element*nSpace +
4236  k*nSpace +
4237  I]
4238  *
4239  s[eN*nQuadraturePoints_element +
4240  k];
4241 }
4242 
4246 void calculateTensorScalarProduct(int nElements_global,
4247  int nQuadraturePoints_element,
4248  int nSpace,
4249  double* t,
4250  double* s,
4251  double* tResult)
4252 {
4253  int eN,k,I,J,nSpace2=nSpace*nSpace;
4254  for(eN=0;eN<nElements_global;eN++)
4255  for (k=0;k<nQuadraturePoints_element;k++)
4256  for (I=0;I<nSpace;I++)
4257  for (J=0;J<nSpace;J++)
4258  tResult[eN*nQuadraturePoints_element*nSpace2 +
4259  k*nSpace2 +
4260  I*nSpace +
4261  J]
4262  =
4263  t[eN*nQuadraturePoints_element*nSpace2 +
4264  k*nSpace2 +
4265  I*nSpace +
4266  J]
4267  *
4268  s[eN*nQuadraturePoints_element +
4269  k];
4270 }
4271 
4272 
4273 
4274 
4275 
4276 
4280 void updateInteriorElementBoundaryFlux(int nInteriorElementBoundaries_global,
4281  int nElementBoundaries_element,
4282  int nQuadraturePoints_elementBoundary,
4283  int nDOF_test_element,
4284  int* interiorElementBoundaries,
4285  int* elementBoundaryElements,
4286  int* elementBoundaryLocalElementBoundaries,
4287  double* flux,
4288  double* w_dS,
4289  double* residual)
4290 {
4291  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,k;
4292  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4293  {
4294  ebN = interiorElementBoundaries[ebNI];
4295  left_eN_global = elementBoundaryElements[ebN*2+0];
4296  right_eN_global = elementBoundaryElements[ebN*2+1];
4297  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4298  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4299  for(i=0;i<nDOF_test_element;i++)
4300  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4301  {
4302  residual[left_eN_global*nDOF_test_element+
4303  i]
4304  +=
4305  flux[ebN*nQuadraturePoints_elementBoundary+
4306  k]*
4307  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4308  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4309  k*nDOF_test_element+
4310  i];
4311  residual[right_eN_global*nDOF_test_element+
4312  i]
4313  -=
4314  flux[ebN*nQuadraturePoints_elementBoundary+
4315  k]*
4316  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4317  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4318  k*nDOF_test_element+
4319  i];
4320  }
4321  }
4322 }
4323 
4327 void updateExteriorElementBoundaryFlux(int nExteriorElementBoundaries_global,
4328  int nElementBoundaries_element,
4329  int nQuadraturePoints_elementBoundary,
4330  int nDOF_test_element,
4331  int* exteriorElementBoundaries,
4332  int* elementBoundaryElements,
4333  int* elementBoundaryLocalElementBoundaries,
4334  double* flux,
4335  double* w_dS,
4336  double* residual)
4337 {
4338  int ebNE,ebN,eN_global,ebN_element,i,k;
4339  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4340  {
4341  ebN = exteriorElementBoundaries[ebNE];
4342  eN_global = elementBoundaryElements[ebN*2+0];
4343  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4344  for(i=0;i<nDOF_test_element;i++)
4345  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4346  {
4347  residual[eN_global*nDOF_test_element+
4348  i]
4349  +=
4350  flux[ebN*nQuadraturePoints_elementBoundary+
4351  k]
4352  *
4353  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4354  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4355  k*nDOF_test_element+
4356  i];
4357  }
4358  }
4359 }
4360 
4361 void updateGlobalExteriorElementBoundaryFlux(int nExteriorElementBoundaries_global,
4362  int nQuadraturePoints_elementBoundary,
4363  int nDOF_test_element,
4364  int* exteriorElementBoundaries,
4365  int* elementBoundaryElements,
4366  int* elementBoundaryLocalElementBoundaries,
4367  double* flux,
4368  double* w_dS,
4369  double* residual)
4370 {
4371  int ebNE,ebN,eN_global,ebN_element,i,k;
4372  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4373  {
4374  ebN = exteriorElementBoundaries[ebNE];
4375  eN_global = elementBoundaryElements[ebN*2+0];
4376  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4377  for(i=0;i<nDOF_test_element;i++)
4378  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4379  {
4380  residual[eN_global*nDOF_test_element+
4381  i]
4382  +=
4383  flux[ebNE*nQuadraturePoints_elementBoundary+
4384  k]
4385  *
4386  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
4387  k*nDOF_test_element+
4388  i];
4389  }
4390  }
4391 }
4392 void updateGlobalExteriorElementBoundaryStressFlux(int nExteriorElementBoundaries_global,
4393  int nQuadraturePoints_elementBoundary,
4394  int nDOF_test_element,
4395  int* exteriorElementBoundaries,
4396  int* elementBoundaryElements,
4397  int* elementBoundaryLocalElementBoundaries,
4398  double* stressFlux,
4399  double* w_dS,
4400  double* residual)
4401 {
4402  int ebNE,ebN,eN_global,ebN_element,i,k,I;
4403  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4404  {
4405  ebN = exteriorElementBoundaries[ebNE];
4406  eN_global = elementBoundaryElements[ebN*2+0];
4407  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4408  for(i=0;i<nDOF_test_element;i++)
4409  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4410  residual[eN_global*nDOF_test_element+
4411  i]
4412  +=
4413  stressFlux[ebNE*nQuadraturePoints_elementBoundary+
4414  k]
4415  *
4416  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
4417  k*nDOF_test_element+
4418  i];
4419  }
4420 }
4424 void updateInteriorTwoSidedElementBoundaryFlux(int nInteriorElementBoundaries_global,
4425  int nElementBoundaries_element,
4426  int nQuadraturePoints_elementBoundary,
4427  int nDOF_test_element,
4428  int* interiorElementBoundaries,
4429  int* elementBoundaryElements,
4430  int* elementBoundaryLocalElementBoundaries,
4431  double* flux,
4432  double* w_dS,
4433  double* residual)
4434 {
4435  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,k;
4436  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4437  {
4438  ebN = interiorElementBoundaries[ebNI];
4439  left_eN_global = elementBoundaryElements[ebN*2+0];
4440  right_eN_global = elementBoundaryElements[ebN*2+1];
4441  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4442  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4443  for(i=0;i<nDOF_test_element;i++)
4444  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4445  {
4446  residual[left_eN_global*nDOF_test_element+
4447  i]
4448  +=
4449  flux[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
4450  left_ebN_element*nQuadraturePoints_elementBoundary+ /*left flux*/
4451  k]*
4452  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4453  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4454  k*nDOF_test_element+
4455  i];
4456  residual[right_eN_global*nDOF_test_element+
4457  i]
4458  +=
4459  flux[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
4460  right_ebN_element*nQuadraturePoints_elementBoundary+ /*right flux*/
4461  k]*
4462  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4463  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4464  k*nDOF_test_element+
4465  i];
4466  }
4467  }
4468 }
4469 
4470 void calculateExteriorElementBoundaryStress3D(int nExteriorElementBoundaries_global,
4471  int nQuadraturePoints_elementBoundary,
4472  int* elementBoundaryMaterialTypes,
4473  int* exteriorElementBoundaries,
4474  int* elementBoundaryElements,
4475  int* elementBoundaryLocalElementBoundaries,
4476  double* p,
4477  double* mom_flux_vec_u,
4478  double* mom_flux_vec_v,
4479  double* mom_flux_vec_w,
4480  double* dS,
4481  double* n,
4482  double* F)
4483 {
4484  int ebNE,ebN,eN_global,ebN_element,k,I;
4485  double stress_x,stress_y,stress_z;
4486  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4487  {
4488  ebN = exteriorElementBoundaries[ebNE];
4489  eN_global = elementBoundaryElements[ebN*2+0];
4490  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4491  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4492  {
4493  stress_x = 0.0;
4494  stress_y = 0.0;
4495  stress_z = 0.0;
4496  stress_x += p[ebNE*nQuadraturePoints_elementBoundary+
4497  k]
4498  *
4499  n[ebNE*nQuadraturePoints_elementBoundary*3+
4500  k*3+
4501  0];
4502  stress_y += p[ebNE*nQuadraturePoints_elementBoundary+
4503  k]
4504  *
4505  n[ebNE*nQuadraturePoints_elementBoundary*3+
4506  k*3+
4507  1];
4508  stress_z += p[ebNE*nQuadraturePoints_elementBoundary+
4509  k]
4510  *
4511  n[ebNE*nQuadraturePoints_elementBoundary*3+
4512  k*3+
4513  2];
4514  for(I=0;I<3;I++)
4515  {
4516  stress_x += mom_flux_vec_u[ebNE*nQuadraturePoints_elementBoundary*3+
4517  k*3+
4518  I]
4519  *
4520  n[ebNE*nQuadraturePoints_elementBoundary*3+
4521  k*3+
4522  I];
4523  stress_y += mom_flux_vec_v[ebNE*nQuadraturePoints_elementBoundary*3+
4524  k*3+
4525  I]
4526  *
4527  n[ebNE*nQuadraturePoints_elementBoundary*3+
4528  k*3+
4529  I];
4530  stress_z += mom_flux_vec_w[ebNE*nQuadraturePoints_elementBoundary*3+
4531  k*3+
4532  I]
4533  *
4534  n[ebNE*nQuadraturePoints_elementBoundary*3+
4535  k*3+
4536  I];
4537  }
4538  F[elementBoundaryMaterialTypes[ebN]*3 + 0] += stress_x*
4539  dS[ebNE*nQuadraturePoints_elementBoundary+
4540  k];
4541  F[elementBoundaryMaterialTypes[ebN]*3 + 1] += stress_y*
4542  dS[ebNE*nQuadraturePoints_elementBoundary+
4543  k];
4544  F[elementBoundaryMaterialTypes[ebN]*3 + 2] += stress_z*
4545  dS[ebNE*nQuadraturePoints_elementBoundary+
4546  k];
4547  }
4548  }
4549 }
4550 
4551 void calculateExteriorElementBoundaryStress2D(int nExteriorElementBoundaries_global,
4552  int nQuadraturePoints_elementBoundary,
4553  int* elementBoundaryMaterialTypes,
4554  int* exteriorElementBoundaries,
4555  int* elementBoundaryElements,
4556  int* elementBoundaryLocalElementBoundaries,
4557  double* p,
4558  double* mom_flux_vec_u,
4559  double* mom_flux_vec_v,
4560  double* dS,
4561  double* n,
4562  double* F)
4563 {
4564  int ebNE,ebN,eN_global,ebN_element,k,I;
4565  double stress_x,stress_y;
4566  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4567  {
4568  ebN = exteriorElementBoundaries[ebNE];
4569  eN_global = elementBoundaryElements[ebN*2+0];
4570  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4571  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4572  {
4573  stress_x = 0.0;
4574  stress_y = 0.0;
4575  stress_x += p[ebNE*nQuadraturePoints_elementBoundary+
4576  k]
4577  *
4578  n[ebNE*nQuadraturePoints_elementBoundary*2+
4579  k*2+
4580  0];
4581  stress_y += p[ebNE*nQuadraturePoints_elementBoundary+
4582  k]
4583  *
4584  n[ebNE*nQuadraturePoints_elementBoundary*2+
4585  k*2+
4586  1];
4587  /* for(I=0;I<2;I++) */
4588  /* { */
4589  /* stress_x += mom_flux_vec_u[ebNE*nQuadraturePoints_elementBoundary*2+ */
4590  /* k*2+ */
4591  /* I] */
4592  /* * */
4593  /* n[ebNE*nQuadraturePoints_elementBoundary*2+ */
4594  /* k*2+ */
4595  /* I]; */
4596  /* stress_y += mom_flux_vec_v[ebNE*nQuadraturePoints_elementBoundary*2+ */
4597  /* k*2+ */
4598  /* I] */
4599  /* * */
4600  /* n[ebNE*nQuadraturePoints_elementBoundary*2+ */
4601  /* k*2+ */
4602  /* I]; */
4603  /* } */
4604  F[elementBoundaryMaterialTypes[ebN]*2 + 0] += stress_x*
4605  dS[ebNE*nQuadraturePoints_elementBoundary+
4606  k];
4607  F[elementBoundaryMaterialTypes[ebN]*2 + 1] += stress_y*
4608  dS[ebNE*nQuadraturePoints_elementBoundary+
4609  k];
4610  }
4611  }
4612 }
4618 void accumulateExteriorElementPressureIntegrals(int nExteriorElementBoundaries_global,
4619  int nQuadraturePoints_elementBoundary,
4620  int* elementBoundaryMaterialTypes,
4621  int* exteriorElementBoundaries,
4622  double* p,
4623  double* dS,
4624  double* P,
4625  double* boundaryMeasure)
4626 {
4627  int ebNE,ebN,k,elementBoundaryFlag;
4628  /*loop through exterior element boundaries*/
4629  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4630  {
4631  /*get the global element boundary number for the current exterior element boundary*/
4632  ebN = exteriorElementBoundaries[ebNE];
4633  /*integer flag for this boundary*/
4634  elementBoundaryFlag = elementBoundaryMaterialTypes[ebN];
4635  /*loop through element boundary quadrature points and accumulate pressure and boundary area/length */
4636  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4637  {
4638  P[elementBoundaryFlag] += p[ebNE*nQuadraturePoints_elementBoundary+k]
4639  *
4640  dS[ebNE*nQuadraturePoints_elementBoundary+k];
4641  boundaryMeasure[elementBoundaryFlag] +=
4642  dS[ebNE*nQuadraturePoints_elementBoundary+k];
4643  }
4644  }
4645 }
4646 
4647 
4652  int nDOF_test_element,
4653  int offset_r,
4654  int stride_r,
4655  int* nFreeDOF_element_r,
4656  int* freeLocal_r,
4657  int* freeGlobal_r,
4658  double* elementResidual,
4659  double* globalResidual)
4660 {
4661  int eN,ii;
4662  for (eN=0;eN<nElements_global;eN++)
4663  for (ii=0;ii<nFreeDOF_element_r[eN];ii++)
4664  globalResidual[offset_r +
4665  stride_r*freeGlobal_r[eN*nDOF_test_element+
4666  ii]]
4667  +=
4668  elementResidual[eN*nDOF_test_element +
4669  freeLocal_r[eN*nDOF_test_element+
4670  ii]];
4671 }
4672 
4677  int nDOF_test_element,
4678  int nDOF_trial_element,
4679  int offset_r,
4680  int stride_r,
4681  int offset_u,
4682  int stride_u,
4683  int nFreeVDOF_global,
4684  int* nFreeDOF_element_r,
4685  int* freeLocal_r,
4686  int* freeGlobal_r,
4687  int* nFreeDOF_element_u,
4688  int* freeLocal_u,
4689  int* freeGlobal_u,
4690  double* elementJacobian,
4691  double* globalJacobian)
4692 {
4693  int eN,ii,jj,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,i,j,jacIndex,I,J;
4694  for (eN=0;eN<nElements_global;eN++)
4695  for (ii=0;ii<nFreeDOF_element_r[eN];ii++)
4696  {
4697  i = freeLocal_r[eN*nDOF_test_element+
4698  ii];
4699  I = offset_r + stride_r*freeGlobal_r[eN*nDOF_test_element+
4700  ii];
4701  for (jj=0;jj<nFreeDOF_element_u[eN];jj++)
4702  {
4703  j = freeLocal_u[eN*nDOF_trial_element+
4704  jj];
4705  J = offset_u + stride_u*freeGlobal_u[eN*nDOF_trial_element+
4706  jj];
4707  jacIndex = I + J*nFreeVDOF_global;
4708  globalJacobian[jacIndex]
4709  +=
4710  elementJacobian[eN*nDOF_test_X_trial_element +
4711  i*nDOF_trial_element+
4712  j];
4713  }
4714  }
4715 }
4716 
4721  int nElements_global,
4722  int nElementBoundaries_element,
4723  int nDOF_test_element,
4724  int nDOF_trial_element,
4725  int offset_r,
4726  int stride_r,
4727  int offset_u,
4728  int stride_u,
4729  int nFreeVDOF_global,
4730  int* nFreeDOF_element_r,
4731  int* freeLocal_r,
4732  int* freeGlobal_r,
4733  int* nFreeDOF_element_u,
4734  int* freeLocal_u,
4735  int* freeGlobal_u,
4736  double* elementJacobian_eb,
4737  double* globalJacobian)
4738 {
4739  int eN,ebN,eN_ebN,ii,jj,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,i,j,jacIndex,I,J;
4740  for (eN=0;eN<nElements_global;eN++)
4741  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
4742  {
4743 /* /\*cek 1D debugging *\/ */
4744 /* if(ebN == 0) */
4745 /* eN_ebN = eN+1; */
4746 /* if(ebN == 1) */
4747 /* eN_ebN = eN-1; */
4748 /* if(eN_ebN >= 0 && eN_ebN < nElements_global) */
4749  eN_ebN = elementNeighbors[eN*nElementBoundaries_element+ebN];
4750  if (eN_ebN >= 0)
4751  for (ii=0;ii<nFreeDOF_element_r[eN];ii++)
4752  {
4753  i = freeLocal_r[eN*nDOF_test_element+
4754  ii];
4755  I = offset_r + stride_r*freeGlobal_r[eN*nDOF_test_element+
4756  ii];
4757  for (jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
4758  {
4759  j = freeLocal_u[eN_ebN*nDOF_trial_element+
4760  jj];
4761  J = offset_u + stride_u*freeGlobal_u[eN_ebN*nDOF_trial_element+
4762  jj];
4763  jacIndex = I + J*nFreeVDOF_global;
4764  globalJacobian[jacIndex]
4765  +=
4766  elementJacobian_eb[eN*nElementBoundaries_element*nDOF_test_X_trial_element +
4767  ebN*nDOF_test_X_trial_element+
4768  i*nDOF_trial_element+
4769  j];
4770  }
4771  }
4772  }
4773 }
4774 
4779  int nElementBoundaries_element,
4780  int nQuadraturePoints_elementBoundary,
4781  int nDOF_test_element,
4782  int nDOF_trial_element,
4783  int offset_r,
4784  int stride_r,
4785  int offset_u,
4786  int stride_u,
4787  int nFreeVDOF_global,
4788  int* interiorElementBoundaries,
4789  int* elementBoundaryElements,
4790  int* elementBoundaryLocalElementBoundaries,
4791  int* nFreeDOF_element_r,
4792  int* freeLocal_r,
4793  int* freeGlobal_r,
4794  int* nFreeDOF_element_u,
4795  int* freeLocal_u,
4796  int* freeGlobal_u,
4797  double* elementBoundaryFluxJacobian,
4798  double* w_dS,
4799  double* jac)
4800 {
4801  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,I,J;
4802  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4803  {
4804  ebN = interiorElementBoundaries[ebNI];
4805  left_eN_global = elementBoundaryElements[ebN*2+0];
4806  right_eN_global = elementBoundaryElements[ebN*2+1];
4807  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4808  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4809  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
4810  {
4811  i = freeLocal_r[left_eN_global*nDOF_test_element+
4812  ii];
4813  I = offset_r + stride_r*freeGlobal_r[left_eN_global*nDOF_test_element+
4814  ii];
4815  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4816  {
4817  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
4818  {
4819  j = freeLocal_u[left_eN_global*nDOF_trial_element+
4820  jj];
4821  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
4822  jj];
4823  jacIndex = I+J*nFreeVDOF_global;
4824  jac[jacIndex]
4825  +=
4826  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
4827  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4828  k*nDOF_trial_element+
4829  j]
4830  *
4831  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
4832  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4833  k*nDOF_test_element+
4834  i];
4835  }
4836  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
4837  {
4838  j = freeLocal_u[right_eN_global*nDOF_trial_element+
4839  jj];
4840  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
4841  jj];
4842  jacIndex = I+J*nFreeVDOF_global;
4843  jac[jacIndex]
4844  +=
4845  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
4846  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4847  k*nDOF_trial_element+
4848  j]*
4849  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
4850  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4851  k*nDOF_test_element+i];
4852  }
4853  }
4854  }
4855  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
4856  {
4857  i = freeLocal_r[right_eN_global*nDOF_test_element+
4858  ii];
4859  I = offset_r + stride_r*freeGlobal_r[right_eN_global*nDOF_test_element+
4860  ii];
4861  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4862  {
4863  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
4864  {
4865  j = freeLocal_u[left_eN_global*nDOF_trial_element+
4866  jj];
4867  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
4868  jj];
4869  jacIndex = I+J*nFreeVDOF_global;
4870  jac[jacIndex]
4871  -=
4872  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4873  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4874  k*nDOF_trial_element+
4875  j]
4876  *
4877  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4878  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4879  k*nDOF_test_element+
4880  i];
4881  }
4882  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
4883  {
4884  j = freeLocal_u[right_eN_global*nDOF_trial_element+
4885  jj];
4886  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
4887  jj];
4888  jacIndex = I+J*nFreeVDOF_global;
4889  jac[jacIndex]
4890  -=
4891  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4892  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4893  k*nDOF_trial_element+
4894  j]*
4895  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4896  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4897  k*nDOF_test_element+
4898  i];
4899  }
4900  }
4901  }
4902  }
4903 }
4904 
4909  int nElements_global,
4910  int nInteriorElementBoundaries_global,
4911  int nElementBoundaries_element,
4912  int nQuadraturePoints_elementBoundary,
4913  int nDOF_test_element,
4914  int nDOF_trial_element,
4915  int offset_r,
4916  int stride_r,
4917  int offset_u,
4918  int stride_u,
4919  int nFreeVDOF_global,
4920  int* interiorElementBoundaries,
4921  int* elementBoundaryElements,
4922  int* elementBoundaryLocalElementBoundaries,
4923  int* nFreeDOF_element_r,
4924  int* freeLocal_r,
4925  int* freeGlobal_r,
4926  int* nFreeDOF_element_u,
4927  int* freeLocal_u,
4928  int* freeGlobal_u,
4929  double* elementBoundaryFluxJacobian_eb,
4930  double* w_dS,
4931  double* jac)
4932 {
4933  int ebNI,ebN,ebN_element,left_eN_ebN,right_eN_ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,I,J;
4934  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4935  {
4936  ebN = interiorElementBoundaries[ebNI];
4937  left_eN_global = elementBoundaryElements[ebN*2+0];
4938  right_eN_global = elementBoundaryElements[ebN*2+1];
4939  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4940  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4941  for(ebN_element=0;ebN_element<nElementBoundaries_element;ebN_element++)
4942  {
4943 /* /\* cek debugging 1D *\/ */
4944 /* if(ebN_element == 0) */
4945 /* left_eN_ebN = left_eN_global+1; */
4946 /* if(ebN_element == 1) */
4947 /* left_eN_ebN = left_eN_global-1; */
4948 /* if(ebN_element == 0) */
4949 /* right_eN_ebN = right_eN_global+1; */
4950 /* if(ebN_element == 1) */
4951 /* right_eN_ebN = right_eN_global-1; */
4952  left_eN_ebN = elementNeighbors[left_eN_global*nElementBoundaries_element+ebN_element];
4953  right_eN_ebN = elementNeighbors[right_eN_global*nElementBoundaries_element+ebN_element];
4954  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
4955  {
4956  i = freeLocal_r[left_eN_global*nDOF_test_element+
4957  ii];
4958  I = offset_r + stride_r*freeGlobal_r[left_eN_global*nDOF_test_element+
4959  ii];
4960  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4961  {
4962 /* if(left_eN_ebN >= 0 && left_eN_ebN < nElements_global) */
4963  if(left_eN_ebN >= 0)
4964  for(jj=0;jj<nFreeDOF_element_u[left_eN_ebN];jj++)
4965  {
4966  j = freeLocal_u[left_eN_ebN*nDOF_trial_element+
4967  jj];
4968  J = offset_u + stride_u*freeGlobal_u[left_eN_ebN*nDOF_trial_element+
4969  jj];
4970  jacIndex = I+J*nFreeVDOF_global;
4971  jac[jacIndex]
4972  +=
4973  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
4974  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4975  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
4976  k*nDOF_trial_element+
4977  j]
4978  *
4979  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
4980  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
4981  k*nDOF_test_element+
4982  i];
4983 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
4984 /* jacIndex,ebN,left_eN_global,left_ebN_element,ebN_element,i,j,jac[jacIndex], */
4985 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
4986 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
4987 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
4988 /* k*nDOF_trial_element+ */
4989 /* j], */
4990 /* w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
4991 /* left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
4992 /* k*nDOF_test_element+ */
4993 /* i]); */
4994  }
4995 /* if(right_eN_ebN >= 0 && right_eN_ebN < nElements_global) */
4996  if(right_eN_ebN >= 0)
4997  for(jj=0;jj<nFreeDOF_element_u[right_eN_ebN];jj++)
4998  {
4999  j = freeLocal_u[right_eN_ebN*nDOF_trial_element+
5000  jj];
5001  J = offset_u + stride_u*freeGlobal_u[right_eN_ebN*nDOF_trial_element+
5002  jj];
5003  jacIndex = I+J*nFreeVDOF_global;
5004  jac[jacIndex]
5005  +=
5006  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5007  1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5008  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5009  k*nDOF_trial_element+
5010  j]*
5011  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5012  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5013  k*nDOF_test_element+i];
5014 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5015 /* jacIndex,ebN,left_eN_global,left_ebN_element,ebN_element,i,j,jac[jacIndex], */
5016 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5017 /* 1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5018 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5019 /* k*nDOF_trial_element+ */
5020 /* j], */
5021 /* w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5022 /* left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5023 /* k*nDOF_test_element+ */
5024 /* i]); */
5025  }
5026  }
5027  }
5028  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
5029  {
5030  i = freeLocal_r[right_eN_global*nDOF_test_element+
5031  ii];
5032  I = offset_r + stride_r*freeGlobal_r[right_eN_global*nDOF_test_element+
5033  ii];
5034  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5035  {
5036 /* if(left_eN_ebN >= 0 && left_eN_ebN < nElements_global) */
5037  if(left_eN_ebN >= 0)
5038  for(jj=0;jj<nFreeDOF_element_u[left_eN_ebN];jj++)
5039  {
5040  j = freeLocal_u[left_eN_ebN*nDOF_trial_element+
5041  jj];
5042  J = offset_u + stride_u*freeGlobal_u[left_eN_ebN*nDOF_trial_element+
5043  jj];
5044  jacIndex = I+J*nFreeVDOF_global;
5045  jac[jacIndex]
5046  -=
5047  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5048  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5049  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5050  k*nDOF_trial_element+
5051  j]
5052  *
5053  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5054  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5055  k*nDOF_test_element+
5056  i];
5057 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5058 /* jacIndex,ebN,right_eN_global,right_ebN_element,ebN_element,i,j,jac[jacIndex], */
5059 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5060 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5061 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5062 /* k*nDOF_trial_element+ */
5063 /* j], */
5064 /* w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5065 /* right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5066 /* k*nDOF_test_element+ */
5067 /* i]); */
5068  }
5069 /* if(right_eN_ebN >= 0 && right_eN_ebN < nElements_global) */
5070  if(right_eN_ebN >= 0)
5071  for(jj=0;jj<nFreeDOF_element_u[right_eN_ebN];jj++)
5072  {
5073  j = freeLocal_u[right_eN_ebN*nDOF_trial_element+
5074  jj];
5075  J = offset_u + stride_u*freeGlobal_u[right_eN_ebN*nDOF_trial_element+
5076  jj];
5077  jacIndex = I+J*nFreeVDOF_global;
5078  jac[jacIndex]
5079  -=
5080  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5081  1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5082  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5083  k*nDOF_trial_element+
5084  j]*
5085  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5086  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5087  k*nDOF_test_element+
5088  i];
5089 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5090 /* jacIndex,ebN,right_eN_global,right_ebN_element,ebN_element,i,j,jac[jacIndex], */
5091 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5092 /* 1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5093 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5094 /* k*nDOF_trial_element+ */
5095 /* j], */
5096 /* w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5097 /* right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5098 /* k*nDOF_test_element+ */
5099 /* i]); */
5100  }
5101  }
5102  }
5103  }
5104  }
5105 }
5110  int nElementBoundaries_element,
5111  int nQuadraturePoints_elementBoundary,
5112  int nDOF_test_element,
5113  int nDOF_trial_element,
5114  int offset_r,
5115  int stride_r,
5116  int offset_u,
5117  int stride_u,
5118  int nFreeVDOF_global,
5119  int* interiorElementBoundaries,
5120  int* elementBoundaryElements,
5121  int* elementBoundaryLocalElementBoundaries,
5122  int* nFreeDOF_element_r,
5123  int* freeLocal_r,
5124  int* freeGlobal_r,
5125  int* nFreeDOF_element_u,
5126  int* freeLocal_u,
5127  int* freeGlobal_u,
5128  double* elementBoundaryFluxJacobian_2sided,
5129  double* w_dS,
5130  double* jac)
5131 {
5132  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,I,J;
5133  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5134  {
5135  ebN = interiorElementBoundaries[ebNI];
5136  left_eN_global = elementBoundaryElements[ebN*2+0];
5137  right_eN_global = elementBoundaryElements[ebN*2+1];
5138  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5139  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5140  /*left flux*/
5141  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
5142  {
5143  i = freeLocal_r[left_eN_global*nDOF_test_element+
5144  ii];
5145  I = offset_r + stride_r*freeGlobal_r[left_eN_global*nDOF_test_element+
5146  ii];
5147  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5148  {
5149  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
5150  {
5151  j = freeLocal_u[left_eN_global*nDOF_trial_element+
5152  jj];
5153  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
5154  jj];
5155  jacIndex = I+J*nFreeVDOF_global;
5156  jac[jacIndex]
5157  +=
5158  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5159  0*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*left flux*/
5160  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*left neig. dep*/
5161  k*nDOF_trial_element+
5162  j]
5163  *
5164  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5165  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5166  k*nDOF_test_element+
5167  i];
5168  }
5169  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
5170  {
5171  j = freeLocal_u[right_eN_global*nDOF_trial_element+
5172  jj];
5173  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
5174  jj];
5175  jacIndex = I+J*nFreeVDOF_global;
5176  jac[jacIndex]
5177  +=
5178  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5179  0*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*left flux*/
5180  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*right neig. dep*/
5181  k*nDOF_trial_element+
5182  j]*
5183  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5184  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5185  k*nDOF_test_element+i];
5186  }
5187  }/*k*/
5188  }/*ii*/
5189  /*right flux*/
5190  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
5191  {
5192  i = freeLocal_r[right_eN_global*nDOF_test_element+
5193  ii];
5194  I = offset_r + stride_r*freeGlobal_r[right_eN_global*nDOF_test_element+
5195  ii];
5196  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5197  {
5198  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
5199  {
5200  j = freeLocal_u[left_eN_global*nDOF_trial_element+
5201  jj];
5202  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
5203  jj];
5204  jacIndex = I+J*nFreeVDOF_global;
5205  jac[jacIndex]
5206  +=
5207  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5208  1*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*right flux*/
5209  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*left neighbor*/
5210  k*nDOF_trial_element+
5211  j]
5212  *
5213  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5214  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5215  k*nDOF_test_element+
5216  i];
5217  }
5218  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
5219  {
5220  j = freeLocal_u[right_eN_global*nDOF_trial_element+
5221  jj];
5222  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
5223  jj];
5224  jacIndex = I+J*nFreeVDOF_global;
5225  jac[jacIndex]
5226  +=
5227  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5228  1*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*right flux*/
5229  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*right neig dep*/
5230  k*nDOF_trial_element+
5231  j]*
5232  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5233  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5234  k*nDOF_test_element+
5235  i];
5236  }
5237  }
5238  }
5239  }
5240 }
5241 
5246  int nElementBoundaries_element,
5247  int nQuadraturePoints_elementBoundary,
5248  int nDOF_test_element,
5249  int nDOF_trial_element,
5250  int offset_r,
5251  int stride_r,
5252  int offset_u,
5253  int stride_u,
5254  int nFreeVDOF_global,
5255  int* exteriorElementBoundaries,
5256  int* elementBoundaryElements,
5257  int* elementBoundaryLocalElementBoundaries,
5258  int* nFreeDOF_element_r,
5259  int* freeLocal_r,
5260  int* freeGlobal_r,
5261  int* nFreeDOF_element_u,
5262  int* freeLocal_u,
5263  int* freeGlobal_u,
5264  double* elementBoundaryFluxJacobian,
5265  double* w_dS,
5266  double* jac)
5267 {
5268  int ebNE,ebN,eN_global,ebN_element,ii,i,k,jj,j,I,J,jacIndex;
5269  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5270  {
5271  ebN = exteriorElementBoundaries[ebNE];
5272  eN_global = elementBoundaryElements[ebN*2+0];
5273  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5274  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5275  {
5276  i = freeLocal_r[eN_global*nDOF_test_element+
5277  ii];
5278  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
5279  ii];
5280  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5281  {
5282  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
5283  {
5284  j = freeLocal_u[eN_global*nDOF_trial_element+
5285  jj];
5286  J = offset_u + stride_u*freeGlobal_u[eN_global*nDOF_trial_element+
5287  jj];
5288  jacIndex = I+J*nFreeVDOF_global;
5289  jac[jacIndex]
5290  +=
5291  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5292  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5293  k*nDOF_trial_element+
5294  j]
5295  *
5296  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5297  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5298  k*nDOF_test_element+
5299  i];
5300  }
5301  }
5302  }
5303  }
5304 }
5305 
5310  int nElements_global,
5311  int nExteriorElementBoundaries_global,
5312  int nElementBoundaries_element,
5313  int nQuadraturePoints_elementBoundary,
5314  int nDOF_test_element,
5315  int nDOF_trial_element,
5316  int offset_r,
5317  int stride_r,
5318  int offset_u,
5319  int stride_u,
5320  int nFreeVDOF_global,
5321  int* exteriorElementBoundaries,
5322  int* elementBoundaryElements,
5323  int* elementBoundaryLocalElementBoundaries,
5324  int* nFreeDOF_element_r,
5325  int* freeLocal_r,
5326  int* freeGlobal_r,
5327  int* nFreeDOF_element_u,
5328  int* freeLocal_u,
5329  int* freeGlobal_u,
5330  double* elementBoundaryFluxJacobian_eb,
5331  double* w_dS,
5332  double* jac)
5333 {
5334  int ebNE,ebN,eN_global,ebN_element,ebN_eN,eN_ebN,ii,i,k,jj,j,I,J,jacIndex;
5335  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5336  {
5337  ebN = exteriorElementBoundaries[ebNE];
5338  eN_global = elementBoundaryElements[ebN*2+0];
5339  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5340  for (ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
5341  {
5342 /* /\* cek debugging 1D *\/ */
5343 /* if(ebN_eN == 0) */
5344 /* eN_ebN = eN_global+1; */
5345 /* if(ebN_eN == 1) */
5346 /* eN_ebN = eN_global-1; */
5347  eN_ebN = elementNeighbors[eN_global*nElementBoundaries_element+ebN_eN];
5348  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5349  {
5350  i = freeLocal_r[eN_global*nDOF_test_element+
5351  ii];
5352  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
5353  ii];
5354  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5355  {
5356 /* if(eN_ebN >= 0 && eN_ebN < nElements_global) */
5357  if(eN_ebN >= 0)
5358  for(jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
5359  {
5360  j = freeLocal_u[eN_ebN*nDOF_trial_element+
5361  jj];
5362  J = offset_u + stride_u*freeGlobal_u[eN_ebN*nDOF_trial_element+
5363  jj];
5364  jacIndex = I+J*nFreeVDOF_global;
5365  jac[jacIndex]
5366  +=
5367  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5368  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5369  ebN_eN*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5370  k*nDOF_trial_element+
5371  j]
5372  *
5373  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5374  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5375  k*nDOF_test_element+
5376  i];
5377 /* printf("ind=%i,ebN = %i,eN_global=%i,ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5378 /* jacIndex,ebN,eN_global,ebN_element,ebN_element,i,j,jac[jacIndex], */
5379 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5380 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5381 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5382 /* k*nDOF_trial_element+ */
5383 /* j], */
5384 /* w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5385 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5386 /* k*nDOF_test_element+ */
5387 /* i]); */
5388  }
5389  }
5390  }
5391  }
5392  }
5393 }
5400  int nElements_global,
5401  int nExteriorElementBoundaries_global,
5402  int nElementBoundaries_element,
5403  int nQuadraturePoints_elementBoundary,
5404  int nDOF_test_element,
5405  int nDOF_trial_element,
5406  int offset_r,
5407  int stride_r,
5408  int offset_u,
5409  int stride_u,
5410  int nFreeVDOF_global,
5411  int* exteriorElementBoundaries,
5412  int* elementBoundaryElements,
5413  int* elementBoundaryLocalElementBoundaries,
5414  int* nFreeDOF_element_r,
5415  int* freeLocal_r,
5416  int* freeGlobal_r,
5417  int* nFreeDOF_element_u,
5418  int* freeLocal_u,
5419  int* freeGlobal_u,
5420  double* elementBoundaryFluxJacobian_eb,
5421  double* w_dS,
5422  double* jac)
5423 {
5424  int ebNE,ebN,eN_global,ebN_element,ebN_eN,eN_ebN,ii,i,k,jj,j,I,J,jacIndex;
5425  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5426  {
5427  ebN = exteriorElementBoundaries[ebNE];
5428  eN_global = elementBoundaryElements[ebN*2+0];
5429  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5430  for (ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
5431  {
5432 /* /\* cek debugging 1D *\/ */
5433 /* if(ebN_eN == 0) */
5434 /* eN_ebN = eN_global+1; */
5435 /* if(ebN_eN == 1) */
5436 /* eN_ebN = eN_global-1; */
5437  eN_ebN = elementNeighbors[eN_global*nElementBoundaries_element+ebN_eN];
5438  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5439  {
5440  i = freeLocal_r[eN_global*nDOF_test_element+
5441  ii];
5442  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
5443  ii];
5444  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5445  {
5446 /* if(eN_ebN >= 0 && eN_ebN < nElements_global) */
5447  if(eN_ebN >= 0)
5448  for(jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
5449  {
5450  j = freeLocal_u[eN_ebN*nDOF_trial_element+
5451  jj];
5452  J = offset_u + stride_u*freeGlobal_u[eN_ebN*nDOF_trial_element+
5453  jj];
5454  jacIndex = I+J*nFreeVDOF_global;
5455  jac[jacIndex]
5456  +=
5457  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5458  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5459  ebN_eN*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5460  k*nDOF_trial_element+
5461  j]
5462  *
5463  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
5464  k*nDOF_test_element+
5465  i];
5466 /* printf("ind=%i,ebN = %i,eN_global=%i,ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5467 /* jacIndex,ebN,eN_global,ebN_element,ebN_element,i,j,jac[jacIndex], */
5468 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5469 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5470 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5471 /* k*nDOF_trial_element+ */
5472 /* j], */
5473 /* w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5474 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5475 /* k*nDOF_test_element+ */
5476 /* i]); */
5477  }
5478  }
5479  }
5480  }
5481  }
5482 }
5487  int nQuadraturePoints_elementBoundary,
5488  int nDOF_test_element,
5489  int nDOF_trial_element,
5490  int offset_r,
5491  int stride_r,
5492  int offset_u,
5493  int stride_u,
5494  int nFreeVDOF_global,
5495  int* exteriorElementBoundaries,
5496  int* elementBoundaryElements,
5497  int* elementBoundaryLocalElementBoundaries,
5498  int* nFreeDOF_element_r,
5499  int* freeLocal_r,
5500  int* freeGlobal_r,
5501  int* nFreeDOF_element_u,
5502  int* freeLocal_u,
5503  int* freeGlobal_u,
5504  double* elementBoundaryFluxJacobian,
5505  double* w_dS,
5506  double* jac)
5507 {
5508  int ebNE,ebN,eN_global,ebN_element,ii,i,k,jj,j,I,J,jacIndex;
5509  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5510  {
5511  ebN = exteriorElementBoundaries[ebNE];
5512  eN_global = elementBoundaryElements[ebN*2+0];
5513  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5514  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5515  {
5516  i = freeLocal_r[eN_global*nDOF_test_element+
5517  ii];
5518  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
5519  ii];
5520  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5521  {
5522  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
5523  {
5524  j = freeLocal_u[eN_global*nDOF_trial_element+
5525  jj];
5526  J = offset_u + stride_u*freeGlobal_u[eN_global*nDOF_trial_element+
5527  jj];
5528  jacIndex = I+J*nFreeVDOF_global;
5529  jac[jacIndex]
5530  +=
5531  elementBoundaryFluxJacobian[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5532  k*nDOF_trial_element+
5533  j]
5534  *
5535  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
5536  k*nDOF_test_element+
5537  i];
5538  }
5539  }
5540  }
5541  }
5542 }
5543 
5548  int nDOF_test_element,
5549  int nDOF_trial_element,
5550  int* nFreeDOF_element_r,
5551  int* freeLocal_r,
5552  int* nFreeDOF_element_u,
5553  int* freeLocal_u,
5554  int* csrRowIndeces_ru,
5555  int* csrColumnOffsets_ru,
5556  double* elementJacobian,
5557  double* globalJacobian)
5558 {
5559  int eN,ii,jj,i,j,jacIndex,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
5560  for (eN=0;eN<nElements_global;eN++)
5561  for (ii=0;ii<nFreeDOF_element_r[eN];ii++)
5562  {
5563  i = freeLocal_r[eN*nDOF_test_element+
5564  ii];
5565  for (jj=0;jj<nFreeDOF_element_u[eN];jj++)
5566  {
5567  j = freeLocal_u[eN*nDOF_trial_element+
5568  jj];
5569  jacIndex = csrRowIndeces_ru[eN*nDOF_test_element+
5570  ii]
5571  +
5572  csrColumnOffsets_ru[eN*nDOF_test_X_trial_element+
5573  ii*nDOF_trial_element+
5574  jj];
5575  globalJacobian[jacIndex]
5576  +=
5577  elementJacobian[eN*nDOF_test_X_trial_element +
5578  i*nDOF_trial_element +
5579  j];
5580  }
5581  }
5582 }
5583 
5588  int nElements_global,
5589  int nElementBoundaries_element,
5590  int nDOF_test_element,
5591  int nDOF_trial_element,
5592  int* nFreeDOF_element_r,
5593  int* freeLocal_r,
5594  int* nFreeDOF_element_u,
5595  int* freeLocal_u,
5596  int* csrRowIndeces_ru,
5597  int* csrColumnOffsets_eb_ru,
5598  double* elementJacobian_eb,
5599  double* globalJacobian)
5600 {
5601  int eN,ebN,eN_ebN,ii,jj,i,j,jacIndex,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
5602  for (eN=0;eN<nElements_global;eN++)
5603  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
5604  {
5605 /* /\*cek 1D debugging *\/ */
5606 /* /\** \todo cek Need to add mesh structure for getting element's corresponding to element boundaries and */
5607 /* fix sparse matrix load of off element jacobian terms in the element Jacobians for LDG methods *\/ */
5608 /* if(ebN == 0) */
5609 /* eN_ebN = eN+1; */
5610 /* if(ebN == 1) */
5611 /* eN_ebN = eN-1; */
5612  eN_ebN = elementNeighbors[eN*nElementBoundaries_element+ebN];
5613  if (eN_ebN >= 0)
5614  for (ii=0;ii<nFreeDOF_element_r[eN];ii++)
5615  {
5616  i = freeLocal_r[eN*nDOF_test_element+
5617  ii];
5618  for (jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
5619  {
5620  j = freeLocal_u[eN_ebN*nDOF_trial_element+
5621  jj];
5622  jacIndex = csrRowIndeces_ru[eN*nDOF_test_element+
5623  ii]
5624  +
5625  csrColumnOffsets_eb_ru[eN*nElementBoundaries_element*nDOF_test_X_trial_element+
5626  ebN*nDOF_test_X_trial_element+
5627  ii*nDOF_trial_element+
5628  jj];
5629  globalJacobian[jacIndex]
5630  +=
5631  elementJacobian_eb[eN*nElementBoundaries_element*nDOF_test_X_trial_element +
5632  ebN*nDOF_test_X_trial_element+
5633  i*nDOF_trial_element +
5634  j];
5635  }
5636  }
5637  }
5638 }
5639 
5643 void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_CSR(int nInteriorElementBoundaries_global,
5644  int nElementBoundaries_element,
5645  int nQuadraturePoints_elementBoundary,
5646  int nDOF_test_element,
5647  int nDOF_trial_element,
5648  int* interiorElementBoundaries,
5649  int* elementBoundaryElements,
5650  int* elementBoundaryLocalElementBoundaries,
5651  int* nFreeDOF_element_r,
5652  int* freeLocal_r,
5653  int* nFreeDOF_element_u,
5654  int* freeLocal_u,
5655  int* csrRowIndeces_ru,
5656  int* csrColumnOffsets_eb_ru,
5657  double* elementBoundaryFluxJacobian,
5658  double* w_dS,
5659  double* jac)
5660 {
5661  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
5662  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5663  {
5664  ebN = interiorElementBoundaries[ebNI];
5665  left_eN_global = elementBoundaryElements[ebN*2+0];
5666  right_eN_global = elementBoundaryElements[ebN*2+1];
5667  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5668  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5669  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
5670  {
5671  i = freeLocal_r[left_eN_global*nDOF_test_element+ii];
5672  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5673  {
5674  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
5675  {
5676  j = freeLocal_u[left_eN_global*nDOF_trial_element+
5677  jj];
5678  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
5679  ii]
5680  +
5681  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
5682  0*2*nDOF_test_X_trial_element +
5683  0*nDOF_test_X_trial_element +
5684  ii*nDOF_trial_element +
5685  jj];
5686  jac[jacIndex]
5687  +=
5688  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5689  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5690  k*nDOF_trial_element+
5691  j]
5692  *
5693  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5694  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5695  k*nDOF_test_element+
5696  i];
5697  }
5698  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
5699  {
5700  j = freeLocal_u[right_eN_global*nDOF_trial_element+
5701  jj];
5702  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
5703  ii]
5704  +
5705  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
5706  0*2*nDOF_test_X_trial_element+
5707  1*nDOF_test_X_trial_element+
5708  ii*nDOF_trial_element+
5709  jj];
5710  jac[jacIndex]
5711  +=
5712  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5713  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5714  k*nDOF_trial_element+
5715  j]
5716  *
5717  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5718  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5719  k*nDOF_test_element+
5720  i];
5721  }
5722  }
5723  }
5724  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
5725  {
5726  i = freeLocal_r[right_eN_global*nDOF_test_element+
5727  ii];
5728  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5729  {
5730  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
5731  {
5732  j = freeLocal_u[left_eN_global*nDOF_trial_element+
5733  jj];
5734  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
5735  ii]
5736  +
5737  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
5738  1*2*nDOF_test_X_trial_element+
5739  0*nDOF_test_X_trial_element+
5740  ii*nDOF_trial_element+
5741  jj];
5742  jac[jacIndex]
5743  -=
5744  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5745  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5746  k*nDOF_trial_element+
5747  j]
5748  *
5749  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5750  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5751  k*nDOF_test_element+
5752  i];
5753  }
5754  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
5755  {
5756  j = freeLocal_u[right_eN_global*nDOF_trial_element+
5757  jj];
5758  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
5759  ii]
5760  +
5761  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
5762  1*2*nDOF_test_X_trial_element+
5763  1*nDOF_test_X_trial_element+
5764  ii*nDOF_trial_element+
5765  jj];
5766  jac[jacIndex]
5767  -=
5768  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5769  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5770  k*nDOF_trial_element+
5771  j]*
5772  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5773  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5774  k*nDOF_test_element+
5775  i];
5776  }
5777  }
5778  }
5779  }
5780 }
5781 
5785 void updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_CSR(int nExteriorElementBoundaries_global,
5786  int nElementBoundaries_element,
5787  int nQuadraturePoints_elementBoundary,
5788  int nDOF_test_element,
5789  int nDOF_trial_element,
5790  int* exteriorElementBoundaries,
5791  int* elementBoundaryElements,
5792  int* elementBoundaryLocalElementBoundaries,
5793  int* nFreeDOF_element_r,
5794  int* freeLocal_r,
5795  int* nFreeDOF_element_u,
5796  int* freeLocal_u,
5797  int* csrRowIndeces_ru,
5798  int* csrColumnOffsets_eb_ru,
5799  double* elementBoundaryFluxJacobian,
5800  double* w_dS,
5801  double* jac)
5802 {
5803  int ebNE,ebN,eN_global,ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
5804  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5805  {
5806  ebN = exteriorElementBoundaries[ebNE];
5807  eN_global = elementBoundaryElements[ebN*2+0];
5808  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5809  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5810  {
5811  i = freeLocal_r[eN_global*nDOF_test_element+ii];
5812  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5813  {
5814  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
5815  {
5816  j = freeLocal_u[eN_global*nDOF_trial_element+
5817  jj];
5818  jacIndex = csrRowIndeces_ru[eN_global*nDOF_test_element+
5819  ii]
5820  +
5821  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
5822  0*2*nDOF_test_X_trial_element +
5823  0*nDOF_test_X_trial_element +
5824  ii*nDOF_trial_element +
5825  jj];
5826  jac[jacIndex]
5827  +=
5828  elementBoundaryFluxJacobian[ebN*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5829  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5830  k*nDOF_trial_element+
5831  j]
5832  *
5833  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5834  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5835  k*nDOF_test_element+
5836  i];
5837  }
5838  }
5839  }
5840  }
5841 }
5846  int nQuadraturePoints_elementBoundary,
5847  int nDOF_test_element,
5848  int nDOF_trial_element,
5849  int* exteriorElementBoundaries,
5850  int* elementBoundaryElements,
5851  int* elementBoundaryLocalElementBoundaries,
5852  int* nFreeDOF_element_r,
5853  int* freeLocal_r,
5854  int* nFreeDOF_element_u,
5855  int* freeLocal_u,
5856  int* csrRowIndeces_ru,
5857  int* csrColumnOffsets_eb_ru,
5858  double* elementBoundaryFluxJacobian,
5859  double* w_dS,
5860  double* jac)
5861 {
5862  int ebNE,ebN,eN_global,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
5863  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5864  {
5865  ebN = exteriorElementBoundaries[ebNE];
5866  eN_global = elementBoundaryElements[ebN*2+0];
5867  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
5868  {
5869  i = freeLocal_r[eN_global*nDOF_test_element+ii];
5870  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5871  {
5872  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
5873  {
5874  j = freeLocal_u[eN_global*nDOF_trial_element+
5875  jj];
5876  jacIndex = csrRowIndeces_ru[eN_global*nDOF_test_element+
5877  ii]
5878  +
5879  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
5880  0*2*nDOF_test_X_trial_element +
5881  0*nDOF_test_X_trial_element +
5882  ii*nDOF_trial_element +
5883  jj];
5884  jac[jacIndex]
5885  +=
5886  elementBoundaryFluxJacobian[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5887  k*nDOF_trial_element+
5888  j]
5889  *
5890  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
5891  k*nDOF_test_element+
5892  i];
5893  }
5894  }
5895  }
5896  }
5897 }
5898 
5903  int nInteriorElementBoundaries_global,
5904  int nElementBoundaries_element,
5905  int nQuadraturePoints_elementBoundary,
5906  int nDOF_test_element,
5907  int nDOF_trial_element,
5908  int* interiorElementBoundaries,
5909  int* elementBoundaryElements,
5910  int* elementBoundaryLocalElementBoundaries,
5911  int* nFreeDOF_element_r,
5912  int* freeLocal_r,
5913  int* nFreeDOF_element_u,
5914  int* freeLocal_u,
5915  int* csrRowIndeces_ru,
5916  int* csrColumnOffsets_eb_eNebN_ru,
5917  double* elementBoundaryFluxJacobian_eb,
5918  double* w_dS,
5919  double* jac)
5920 {
5921  int ebNI,ebN,ebN_element,left_eN_ebN,right_eN_ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
5922  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5923  {
5924  ebN = interiorElementBoundaries[ebNI];
5925  left_eN_global = elementBoundaryElements[ebN*2+0];
5926  right_eN_global = elementBoundaryElements[ebN*2+1];
5927  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5928  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5929  for(ebN_element=0;ebN_element<nElementBoundaries_element;ebN_element++)
5930  {
5931  left_eN_ebN = elementNeighbors[left_eN_global*nElementBoundaries_element+ebN_element];
5932  right_eN_ebN = elementNeighbors[right_eN_global*nElementBoundaries_element+ebN_element];
5933  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
5934  {
5935  i = freeLocal_r[left_eN_global*nDOF_test_element+ii];
5936  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5937  {
5938  if(left_eN_ebN >= 0)
5939  for(jj=0;jj<nFreeDOF_element_u[left_eN_ebN];jj++)
5940  {
5941  j = freeLocal_u[left_eN_ebN*nDOF_trial_element+
5942  jj];
5943  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
5944  ii]
5945  +
5946  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element +
5947  0*2*nElementBoundaries_element*nDOF_test_X_trial_element +
5948  0*nElementBoundaries_element*nDOF_test_X_trial_element +
5949  ebN_element*nDOF_test_X_trial_element+
5950  ii*nDOF_trial_element +
5951  jj];
5952  jac[jacIndex]
5953  +=
5954  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5955  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5956  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5957  k*nDOF_trial_element+
5958  j]
5959  *
5960  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5961  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5962  k*nDOF_test_element+
5963  i];
5964 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
5965 /* jacIndex,ebN,left_eN_global,left_ebN_element,ebN_element,i,j,jac[jacIndex], */
5966 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
5967 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5968 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
5969 /* k*nDOF_trial_element+ */
5970 /* j], */
5971 /* w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
5972 /* left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
5973 /* k*nDOF_test_element+ */
5974 /* i]); */
5975  }
5976  if(right_eN_ebN >= 0)
5977  for(jj=0;jj<nFreeDOF_element_u[right_eN_ebN];jj++)
5978  {
5979  j = freeLocal_u[right_eN_ebN*nDOF_trial_element+
5980  jj];
5981  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
5982  ii]
5983  +
5984  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element+
5985  0*2*nElementBoundaries_element*nDOF_test_X_trial_element+
5986  1*nElementBoundaries_element*nDOF_test_X_trial_element+
5987  ebN_element*nDOF_test_X_trial_element+
5988  ii*nDOF_trial_element+
5989  jj];
5990  jac[jacIndex]
5991  +=
5992  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
5993  1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5994  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
5995  k*nDOF_trial_element+
5996  j]
5997  *
5998  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
5999  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6000  k*nDOF_test_element+
6001  i];
6002 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
6003 /* jacIndex,ebN,left_eN_global,left_ebN_element,ebN_element,i,j,jac[jacIndex], */
6004 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
6005 /* 1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6006 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6007 /* k*nDOF_trial_element+ */
6008 /* j], */
6009 /* w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
6010 /* left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
6011 /* k*nDOF_test_element+ */
6012 /* i]); */
6013  }
6014  }
6015  }
6016  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
6017  {
6018  i = freeLocal_r[right_eN_global*nDOF_test_element+
6019  ii];
6020  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6021  {
6022  if(left_eN_ebN >= 0)
6023  for(jj=0;jj<nFreeDOF_element_u[left_eN_ebN];jj++)
6024  {
6025  j = freeLocal_u[left_eN_ebN*nDOF_trial_element+
6026  jj];
6027  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
6028  ii]
6029  +
6030  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element+
6031  1*2*nElementBoundaries_element*nDOF_test_X_trial_element+
6032  0*nElementBoundaries_element*nDOF_test_X_trial_element+
6033  ebN_element*nDOF_test_X_trial_element+
6034  ii*nDOF_trial_element+
6035  jj];
6036  jac[jacIndex]
6037  -=
6038  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6039  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6040  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6041  k*nDOF_trial_element+
6042  j]
6043  *
6044  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6045  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6046  k*nDOF_test_element+
6047  i];
6048 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
6049 /* jacIndex,ebN,right_eN_global,right_ebN_element,ebN_element,i,j,jac[jacIndex], */
6050 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
6051 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6052 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6053 /* k*nDOF_trial_element+ */
6054 /* j], */
6055 /* w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
6056 /* right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
6057 /* k*nDOF_test_element+ */
6058 /* i]); */
6059  }
6060  if(right_eN_ebN >= 0)
6061  for(jj=0;jj<nFreeDOF_element_u[right_eN_ebN];jj++)
6062  {
6063  j = freeLocal_u[right_eN_ebN*nDOF_trial_element+
6064  jj];
6065  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
6066  ii]
6067  +
6068  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element+
6069  1*2*nElementBoundaries_element*nDOF_test_X_trial_element+
6070  1*nElementBoundaries_element*nDOF_test_X_trial_element+
6071  ebN_element*nDOF_test_X_trial_element+
6072  ii*nDOF_trial_element+
6073  jj];
6074  jac[jacIndex]
6075  -=
6076  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6077  1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6078  ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6079  k*nDOF_trial_element+
6080  j]*
6081  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6082  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6083  k*nDOF_test_element+
6084  i];
6085 /* printf("ind=%i,ebN = %i,left_eN_global=%i,left_ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
6086 /* jacIndex,ebN,right_eN_global,right_ebN_element,ebN_element,i,j,jac[jacIndex], */
6087 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
6088 /* 1*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6089 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6090 /* k*nDOF_trial_element+ */
6091 /* j], */
6092 /* w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
6093 /* right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
6094 /* k*nDOF_test_element+ */
6095 /* i]); */
6096  }
6097  }
6098  }
6099  }
6100  }
6101 }
6102 
6107  int nExteriorElementBoundaries_global,
6108  int nElementBoundaries_element,
6109  int nQuadraturePoints_elementBoundary,
6110  int nDOF_test_element,
6111  int nDOF_trial_element,
6112  int* exteriorElementBoundaries,
6113  int* elementBoundaryElements,
6114  int* elementBoundaryLocalElementBoundaries,
6115  int* nFreeDOF_element_r,
6116  int* freeLocal_r,
6117  int* nFreeDOF_element_u,
6118  int* freeLocal_u,
6119  int* csrRowIndeces_ru,
6120  int* csrColumnOffsets_eb_eNebN_ru,
6121  double* elementBoundaryFluxJacobian_eb,
6122  double* w_dS,
6123  double* jac)
6124 {
6125  int ebNE,ebN,ebN_eN,eN_ebN,eN_global,ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
6126  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6127  {
6128  ebN = exteriorElementBoundaries[ebNE];
6129  eN_global = elementBoundaryElements[ebN*2+0];
6130  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
6131  for(ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
6132  {
6133  eN_ebN = elementNeighbors[eN_global*nElementBoundaries_element+ebN_eN];
6134  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
6135  {
6136  i = freeLocal_r[eN_global*nDOF_test_element+ii];
6137  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6138  {
6139  if(eN_ebN >= 0)
6140  for(jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
6141  {
6142  j = freeLocal_u[eN_ebN*nDOF_trial_element+
6143  jj];
6144  jacIndex = csrRowIndeces_ru[eN_global*nDOF_test_element+
6145  ii]
6146  +
6147  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element +
6148  0*2*nElementBoundaries_element*nDOF_test_X_trial_element +
6149  0*nElementBoundaries_element*nDOF_test_X_trial_element +
6150  ebN_eN*nDOF_test_X_trial_element +
6151  ii*nDOF_trial_element +
6152  jj];
6153  jac[jacIndex]
6154  +=
6155  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
6156  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6157  ebN_eN*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6158  k*nDOF_trial_element+
6159  j]
6160  *
6161  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
6162  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6163  k*nDOF_test_element+
6164  i];
6165 /* printf("ind=%i,ebN = %i,eN_global=%i,ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
6166 /* jacIndex,ebN,eN_global,ebN_element,ebN_element,i,j,jac[jacIndex], */
6167 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
6168 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6169 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6170 /* k*nDOF_trial_element+ */
6171 /* j], */
6172 /* w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
6173 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
6174 /* k*nDOF_test_element+ */
6175 /* i]); */
6176  }
6177  }
6178  }
6179  }
6180  }
6181 }
6188  int nExteriorElementBoundaries_global,
6189  int nElementBoundaries_element,
6190  int nQuadraturePoints_elementBoundary,
6191  int nDOF_test_element,
6192  int nDOF_trial_element,
6193  int* exteriorElementBoundaries,
6194  int* elementBoundaryElements,
6195  int* elementBoundaryLocalElementBoundaries,
6196  int* nFreeDOF_element_r,
6197  int* freeLocal_r,
6198  int* nFreeDOF_element_u,
6199  int* freeLocal_u,
6200  int* csrRowIndeces_ru,
6201  int* csrColumnOffsets_eb_eNebN_ru,
6202  double* elementBoundaryFluxJacobian_eb,
6203  double* w_dS,
6204  double* jac)
6205 {
6206  int ebNE,ebN,ebN_eN,eN_ebN,eN_global,ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
6207  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6208  {
6209  ebN = exteriorElementBoundaries[ebNE];
6210  eN_global = elementBoundaryElements[ebN*2+0];
6211  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
6212  for(ebN_eN=0;ebN_eN<nElementBoundaries_element;ebN_eN++)
6213  {
6214  eN_ebN = elementNeighbors[eN_global*nElementBoundaries_element+ebN_eN];
6215  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
6216  {
6217  i = freeLocal_r[eN_global*nDOF_test_element+ii];
6218  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6219  {
6220  if(eN_ebN >= 0)
6221  for(jj=0;jj<nFreeDOF_element_u[eN_ebN];jj++)
6222  {
6223  j = freeLocal_u[eN_ebN*nDOF_trial_element+
6224  jj];
6225  jacIndex = csrRowIndeces_ru[eN_global*nDOF_test_element+
6226  ii]
6227  +
6228  csrColumnOffsets_eb_eNebN_ru[ebN*4*nElementBoundaries_element*nDOF_test_X_trial_element +
6229  0*2*nElementBoundaries_element*nDOF_test_X_trial_element +
6230  0*nElementBoundaries_element*nDOF_test_X_trial_element +
6231  ebN_eN*nDOF_test_X_trial_element +
6232  ii*nDOF_trial_element +
6233  jj];
6234  jac[jacIndex]
6235  +=
6236  elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element +
6237  0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6238  ebN_eN*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6239  k*nDOF_trial_element+
6240  j]
6241  *
6242  w_dS[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element+
6243  k*nDOF_test_element+
6244  i];
6245 /* printf("ind=%i,ebN = %i,eN_global=%i,ebN_element=%i,ebN_element=%i,i=%i,j=%i,jac=%12.5e,fjac=%12.5e,w=%12.5e\n", */
6246 /* jacIndex,ebN,eN_global,ebN_element,ebN_element,i,j,jac[jacIndex], */
6247 /* elementBoundaryFluxJacobian_eb[ebN*2*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element + */
6248 /* 0*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6249 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+ */
6250 /* k*nDOF_trial_element+ */
6251 /* j], */
6252 /* w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element + */
6253 /* ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+ */
6254 /* k*nDOF_test_element+ */
6255 /* i]); */
6256  }
6257  }
6258  }
6259  }
6260  }
6261 }
6266  int nElementBoundaries_element,
6267  int nQuadraturePoints_elementBoundary,
6268  int nDOF_test_element,
6269  int nDOF_trial_element,
6270  int* interiorElementBoundaries,
6271  int* elementBoundaryElements,
6272  int* elementBoundaryLocalElementBoundaries,
6273  int* nFreeDOF_element_r,
6274  int* freeLocal_r,
6275  int* nFreeDOF_element_u,
6276  int* freeLocal_u,
6277  int* csrRowIndeces_ru,
6278  int* csrColumnOffsets_eb_ru,
6279  double* elementBoundaryFluxJacobian_2sided,
6280  double* w_dS,
6281  double* jac)
6282 {
6283  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,jacIndex;
6284  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
6285  {
6286  ebN = interiorElementBoundaries[ebNI];
6287  left_eN_global = elementBoundaryElements[ebN*2+0];
6288  right_eN_global = elementBoundaryElements[ebN*2+1];
6289  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
6290  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
6291  /*left flux*/
6292  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
6293  {
6294  i = freeLocal_r[left_eN_global*nDOF_test_element+ii];
6295  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6296  {
6297  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
6298  {
6299  j = freeLocal_u[left_eN_global*nDOF_trial_element+
6300  jj];
6301  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
6302  ii]
6303  +
6304  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
6305  0*2*nDOF_test_X_trial_element +
6306  0*nDOF_test_X_trial_element +
6307  ii*nDOF_trial_element +
6308  jj];
6309  jac[jacIndex]
6310  +=
6311  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
6312  0*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*left flux*/
6313  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*left neig dep*/
6314  k*nDOF_trial_element+
6315  j]
6316  *
6317  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
6318  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6319  k*nDOF_test_element+
6320  i];
6321  }
6322  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
6323  {
6324  j = freeLocal_u[right_eN_global*nDOF_trial_element+
6325  jj];
6326  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
6327  ii]
6328  +
6329  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
6330  0*2*nDOF_test_X_trial_element+
6331  1*nDOF_test_X_trial_element+
6332  ii*nDOF_trial_element+
6333  jj];
6334  jac[jacIndex]
6335  +=
6336  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element +
6337  0*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*left flux*/
6338  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*right neig dep*/
6339  k*nDOF_trial_element+
6340  j]
6341  *
6342  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element +
6343  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6344  k*nDOF_test_element+
6345  i];
6346  }
6347  }
6348  }
6349  /*right flux*/
6350  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
6351  {
6352  i = freeLocal_r[right_eN_global*nDOF_test_element+
6353  ii];
6354  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6355  {
6356  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
6357  {
6358  j = freeLocal_u[left_eN_global*nDOF_trial_element+
6359  jj];
6360  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
6361  ii]
6362  +
6363  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
6364  1*2*nDOF_test_X_trial_element+
6365  0*nDOF_test_X_trial_element+
6366  ii*nDOF_trial_element+
6367  jj];
6368  jac[jacIndex]
6369  +=
6370  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6371  1*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*right flux*/
6372  0*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*left neig dep*/
6373  k*nDOF_trial_element+
6374  j]
6375  *
6376  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6377  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6378  k*nDOF_test_element+
6379  i];
6380  }
6381  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
6382  {
6383  j = freeLocal_u[right_eN_global*nDOF_trial_element+
6384  jj];
6385  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
6386  ii]
6387  +
6388  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
6389  1*2*nDOF_test_X_trial_element+
6390  1*nDOF_test_X_trial_element+
6391  ii*nDOF_trial_element+
6392  jj];
6393  jac[jacIndex]
6394  +=
6395  elementBoundaryFluxJacobian_2sided[ebN*2*2*nQuadraturePoints_elementBoundary*nDOF_trial_element+
6396  1*2*nQuadraturePoints_elementBoundary*nDOF_trial_element + /*right flux*/
6397  1*nQuadraturePoints_elementBoundary*nDOF_trial_element+ /*right neig dep*/
6398  k*nDOF_trial_element+
6399  j]*
6400  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6401  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
6402  k*nDOF_test_element+
6403  i];
6404  }
6405  }
6406  }
6407  }
6408 }
6409 
6413 void calculateWeightedShape(int nElements_global,
6414  int nQuadraturePoints_element,
6415  int nDOF_test_element,
6416  double* dVR,
6417  double* abs_det_jac,
6418  double* w,
6419  double* w_dV)
6420 {
6421  int eN,i,k;
6422  for (eN=0;eN<nElements_global;eN++)
6423  for (k=0;k<nQuadraturePoints_element;k++)
6424  for (i=0;i<nDOF_test_element;i++)
6425  w_dV[eN*nQuadraturePoints_element*nDOF_test_element+
6426  k*nDOF_test_element+
6427  i]
6428  =
6429  w[eN*nQuadraturePoints_element*nDOF_test_element+
6430  k*nDOF_test_element+
6431  i]
6432  *
6433  dVR[k]
6434  *
6435  abs_det_jac[eN*nQuadraturePoints_element+
6436  k];
6437 }
6438 
6442 void calculateWeightedShapeGradients(int nElements_global,
6443  int nQuadraturePoints_element,
6444  int nDOF_test_element,
6445  int nSpace,
6446  double* dVR,
6447  double* abs_det_jac,
6448  double* grad_w,
6449  double* grad_w_dV)
6450 {
6451  int eN,i,k,I;
6452  for (eN=0;eN<nElements_global;eN++)
6453  for (k=0;k<nQuadraturePoints_element;k++)
6454  for (i=0;i<nDOF_test_element;i++)
6455  for (I=0;I<nSpace;I++)
6456  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace+
6457  k*nDOF_test_element*nSpace+
6458  i*nSpace+
6459  I]
6460  =
6461  grad_w[eN*nQuadraturePoints_element*nDOF_test_element*nSpace+
6462  k*nDOF_test_element*nSpace+
6463  i*nSpace+
6464  I]
6465  *
6466  dVR[k]
6467  *
6468  abs_det_jac[eN*nQuadraturePoints_element+
6469  k];
6470 }
6471 
6473 void calculateWeightedPiolaShapeGradients(int nElements_global,
6474  int nQuadraturePoints_element,
6475  int nDOF_test_element,
6476  int nSpace,
6477  double* dVR,
6478  double* abs_det_jac,
6479  double* grad_w,
6480  double* grad_w_dV)
6481 {
6482  int eN,i,k,I;
6483  for (eN=0;eN<nElements_global;eN++)
6484  for (k=0;k<nQuadraturePoints_element;k++)
6485  for (i=0;i<nDOF_test_element;i++)
6486  for (I=0;I<nSpace;I++)
6487  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace+
6488  k*nDOF_test_element*nSpace+
6489  i*nSpace+
6490  I]
6491  =
6492  grad_w[eN*nQuadraturePoints_element*nDOF_test_element*nSpace+
6493  k*nDOF_test_element*nSpace+
6494  i*nSpace+
6495  I]
6496  *
6497  dVR[k]
6498  ;
6499 }
6500 
6501 void calculateWeightedShapeHessians(int nElements_global,
6502  int nQuadraturePoints_element,
6503  int nDOF_test_element,
6504  int nSpace,
6505  double* dVR,
6506  double* abs_det_jac,
6507  double* Hess_w,
6508  double* Hess_w_dV)
6509 {
6510  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
6511  for (eN=0;eN<nElements_global;eN++)
6512  for (k=0;k<nQuadraturePoints_element;k++)
6513  for (i=0;i<nDOF_test_element;i++)
6514  for (I=0;I<nSpace;I++)
6515  for (J=0;J<nSpace;J++)
6516  Hess_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2+
6517  k*nDOF_test_element*nSpace2+
6518  i*nSpace2+
6519  I*nSpace+
6520  J]
6521  =
6522  Hess_w[eN*nQuadraturePoints_element*nDOF_test_element*nSpace2+
6523  k*nDOF_test_element*nSpace2+
6524  i*nSpace2+
6525  I*nSpace+
6526  J]
6527  *
6528  dVR[k]
6529  *
6530  abs_det_jac[eN*nQuadraturePoints_element+
6531  k];
6532 }
6533 
6537 void calculateShape_X_weightedShape(int nElements_global,
6538  int nQuadraturePoints_element,
6539  int nDOF_trial_element,
6540  int nDOF_test_element,
6541  double* v,
6542  double* w_dV,
6543  double* v_X_w_dV)
6544 {
6545  int eN,k,i,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6546  for (eN=0;eN<nElements_global;eN++)
6547  for (k=0;k<nQuadraturePoints_element;k++)
6548  for (i=0;i<nDOF_test_element;i++)
6549  for (j=0;j<nDOF_trial_element;j++)
6550  v_X_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element +
6551  k*nDOF_test_X_trial_element+
6552  j*nDOF_test_element+
6553  i]
6554  =
6555  v[eN*nQuadraturePoints_element*nDOF_trial_element +
6556  k*nDOF_trial_element+
6557  j]
6558  *
6559  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
6560  k*nDOF_test_element+
6561  i];
6562 }
6563 
6567 void calculateShape_X_weightedGradShape(int nElements_global,
6568  int nQuadraturePoints_element,
6569  int nDOF_trial_element,
6570  int nDOF_test_element,
6571  int nSpace,
6572  double* v,
6573  double* grad_w_dV,
6574  double* v_X_grad_w_dV)
6575 {
6576  int eN,k,i,j,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6577  for (eN=0;eN<nElements_global;eN++)
6578  for (k=0;k<nQuadraturePoints_element;k++)
6579  for (i=0;i<nDOF_test_element;i++)
6580  for (j=0;j<nDOF_trial_element;j++)
6581  for (I=0;I<nSpace;I++)
6582  v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace +
6583  k*nDOF_test_X_trial_element*nSpace+
6584  j*nDOF_test_element*nSpace+
6585  i*nSpace+
6586  I]
6587  =
6588  v[eN*nQuadraturePoints_element*nDOF_trial_element +
6589  k*nDOF_trial_element+
6590  j]
6591  *
6592  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
6593  k*nDOF_test_element*nSpace+
6594  i*nSpace+
6595  I];
6596 }
6597 
6601 void calculateGradShape_X_weightedShape(int nElements_global,
6602  int nQuadraturePoints_element,
6603  int nDOF_trial_element,
6604  int nDOF_test_element,
6605  int nSpace,
6606  double* grad_v,
6607  double* w_dV,
6608  double* grad_v_X_w_dV)
6609 {
6610  int eN,k,i,j,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6611  for (eN=0;eN<nElements_global;eN++)
6612  for (k=0;k<nQuadraturePoints_element;k++)
6613  for (i=0;i<nDOF_test_element;i++)
6614  for (j=0;j<nDOF_trial_element;j++)
6615  for (I=0;I<nSpace;I++)
6616  grad_v_X_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace +
6617  k*nDOF_test_X_trial_element*nSpace+
6618  j*nDOF_test_element*nSpace+
6619  i*nSpace+
6620  I]
6621  =
6622  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
6623  k*nDOF_trial_element*nSpace+
6624  j*nSpace+
6625  I]
6626  *
6627  w_dV[eN*nQuadraturePoints_element*nDOF_test_element +
6628  k*nDOF_test_element+
6629  i];
6630 }
6631 
6635 void calculateGradShape_X_weightedGradShape(int nElements_global,
6636  int nQuadraturePoints_element,
6637  int nDOF_trial_element,
6638  int nDOF_test_element,
6639  int nSpace,
6640  double* grad_v,
6641  double* grad_w_dV,
6642  double* grad_v_X_grad_w_dV)
6643 {
6644  int eN,k,i,j,I,J,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,nSpace2=nSpace*nSpace;
6645  for (eN=0;eN<nElements_global;eN++)
6646  for (k=0;k<nQuadraturePoints_element;k++)
6647  for (i=0;i<nDOF_test_element;i++)
6648  for (j=0;j<nDOF_trial_element;j++)
6649  for (I=0;I<nSpace;I++)
6650  for (J=0;J<nSpace;J++)
6651  grad_v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace2 +
6652  k*nDOF_test_X_trial_element*nSpace2+
6653  j*nDOF_test_element*nSpace2+
6654  i*nSpace2+
6655  I*nSpace+
6656  J]
6657  =
6658  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
6659  k*nDOF_trial_element*nSpace+
6660  j*nSpace+
6661  I]
6662  *
6663  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
6664  k*nDOF_test_element*nSpace+
6665  i*nSpace+
6666  J];
6667 }
6668 
6672 void calculateWeightedShapeTrace(int nElements_global,
6673  int nElementBoundaries_element,
6674  int nElementBoundaryQuadraturePoints_elementBoundary,
6675  int nDOF_test_element,
6676  double* dSR,
6677  double* sqrt_det_g,
6678  double* w,
6679  double* w_dS)
6680 {
6681  int eN,ebN,i,k;
6682  for (eN=0;eN<nElements_global;eN++)
6683  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
6684  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6685  for (i=0;i<nDOF_test_element;i++)
6686  {
6687  w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element+
6688  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6689  k*nDOF_test_element+
6690  i]
6691  =
6692  w[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element+
6693  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6694  k*nDOF_test_element+
6695  i]
6696  *
6697  dSR[k]
6698  *
6699  sqrt_det_g[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary+
6700  ebN*nElementBoundaryQuadraturePoints_elementBoundary+
6701  k];
6702  }
6703 }
6704 void calculateWeightedPiolaShapeTrace(int nElements_global,
6705  int nElementBoundaries_element,
6706  int nElementBoundaryQuadraturePoints_elementBoundary,
6707  int nDOF_test_element,
6708  double* dSR,
6709  double* sqrt_det_g,
6710  double* w,
6711  double* w_dS)
6712 {
6713  int eN,ebN,i,k;
6714  for (eN=0;eN<nElements_global;eN++)
6715  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
6716  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6717  for (i=0;i<nDOF_test_element;i++)
6718  {
6719  w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element+
6720  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6721  k*nDOF_test_element+
6722  i]
6723  =
6724  w[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element+
6725  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6726  k*nDOF_test_element+
6727  i]
6728  *
6729  dSR[k]
6730  *
6731  sqrt_det_g[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary+
6732  ebN*nElementBoundaryQuadraturePoints_elementBoundary+
6733  k];
6734  }
6735 }
6736 
6740 void calculateShape_X_weightedShapeTrace(int nElements_global,
6741  int nElementBoundaries_element,
6742  int nElementBoundaryQuadraturePoints_elementBoundary,
6743  int nDOF_trial_element,
6744  int nDOF_test_element,
6745  double* v,
6746  double* w_dS,
6747  double* v_X_w_dS)
6748 {
6749  int eN,ebN,k,i,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6750  for (eN=0;eN<nElements_global;eN++)
6751  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
6752  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6753  for (i=0;i<nDOF_test_element;i++)
6754  for (j=0;j<nDOF_trial_element;j++)
6755  v_X_w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element +
6756  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element +
6757  k*nDOF_test_X_trial_element+
6758  j*nDOF_test_element+
6759  i]
6760  =
6761  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element +
6762  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element +
6763  k*nDOF_trial_element+
6764  j]
6765  *
6766  w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6767  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6768  k*nDOF_trial_element+
6769  i];
6770 }
6771 
6776  int nElementBoundaries_element,
6777  int nElementBoundaryQuadraturePoints_elementBoundary,
6778  int nDOF_trial_element,
6779  int nDOF_test_element,
6780  int nSpace,
6781  double* grad_v,
6782  double* w_dS,
6783  double* grad_v_X_w_dS)
6784 {
6785  int eN,ebN,k,i,j,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6786  for (eN=0;eN<nElements_global;eN++)
6787  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
6788  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6789  for (i=0;i<nDOF_test_element;i++)
6790  for (j=0;j<nDOF_trial_element;j++)
6791  for (I=0;I<nSpace;I++)
6792  grad_v_X_w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element*nSpace +
6793  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element*nSpace +
6794  k*nDOF_test_X_trial_element*nSpace+
6795  j*nDOF_test_element*nSpace+
6796  i*nSpace+
6797  I]
6798  =
6799  grad_v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace +
6800  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace +
6801  k*nDOF_trial_element*nSpace+
6802  j*nSpace+
6803  I]
6804  *
6805  w_dS[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6806  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6807  k*nDOF_test_element+
6808  i];
6809 }
6814 void calculateWeightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary,
6815  int nDOF_test_element,
6816  int nExteriorElementBoundaries_global,
6817  const int* exteriorElementBoundariesArray,
6818  const int* elementBoundaryElementsArray,
6819  const int* elementBoundaryLocalElementBoundariesArray,
6820  double* dSR,
6821  double* sqrt_det_g,
6822  double* w,
6823  double* w_dS)
6824 {
6825  int ebNE,i,k;
6826  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
6827  {
6828  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6829  for (i=0;i<nDOF_test_element;i++)
6830  {
6831  w_dS[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6832  k*nDOF_test_element+
6833  i]
6834  =
6835  w[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6836  k*nDOF_test_element+
6837  i]
6838  *
6839  dSR[k]
6840  *
6841  sqrt_det_g[ebNE*nElementBoundaryQuadraturePoints_elementBoundary+
6842  k];
6843  }
6844  }
6845 }
6850 void calculateShape_X_weightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary,
6851  int nDOF_trial_element,
6852  int nDOF_test_element,
6853  int nExteriorElementBoundaries_global,
6854  const int* exteriorElementBoundariesArray,
6855  const int* elementBoundaryElementsArray,
6856  const int* elementBoundaryLocalElementBoundariesArray,
6857  double* v,
6858  double* w_dS,
6859  double* v_X_w_dS)
6860 {
6861  int ebNE,k,i,j,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6862  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6863  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6864  for (i=0;i<nDOF_test_element;i++)
6865  for (j=0;j<nDOF_trial_element;j++)
6866  v_X_w_dS[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element +
6867  k*nDOF_test_X_trial_element+
6868  j*nDOF_test_element+
6869  i]
6870  =
6871  v[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element +
6872  k*nDOF_trial_element+
6873  j]
6874  *
6875  w_dS[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6876  k*nDOF_trial_element+
6877  i];
6878 }
6879 
6883 void calculateGradShape_X_weightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary,
6884  int nDOF_trial_element,
6885  int nDOF_test_element,
6886  int nSpace,
6887  int nExteriorElementBoundaries_global,
6888  const int* exteriorElementBoundariesArray,
6889  const int* elementBoundaryElementsArray,
6890  const int* elementBoundaryLocalElementBoundariesArray,
6891  double* grad_v,
6892  double* w_dS,
6893  double* grad_v_X_w_dS)
6894 {
6895  int ebNE,k,i,j,I,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
6896  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6897  for (k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
6898  for (i=0;i<nDOF_test_element;i++)
6899  for (j=0;j<nDOF_trial_element;j++)
6900  for (I=0;I<nSpace;I++)
6901  grad_v_X_w_dS[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_X_trial_element*nSpace +
6902  k*nDOF_test_X_trial_element*nSpace+
6903  j*nDOF_test_element*nSpace+
6904  i*nSpace+
6905  I]
6906  =
6907  grad_v[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace +
6908  k*nDOF_trial_element*nSpace+
6909  j*nSpace+
6910  I]
6911  *
6912  w_dS[ebNE*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_test_element +
6913  k*nDOF_test_element+
6914  i];
6915 }
6916 
6917 
6921 void calculateIntegrationWeights(int nElements_global,
6922  int nQuadraturePoints_element,
6923  double* abs_det_J,
6924  double* referenceWeights,
6925  double* weights)
6926 {
6927  int eN,k;
6928  for (eN=0;eN<nElements_global;eN++)
6929  for (k=0;k<nQuadraturePoints_element;k++)
6930  weights[eN*nQuadraturePoints_element+
6931  k]
6932  =
6933  abs_det_J[eN*nQuadraturePoints_element+
6934  k]
6935  *
6936  referenceWeights[k];
6937 }
6938 
6940  int nElementBoundaries_element,
6941  int nQuadraturePoints_elementBoundary,
6942  double* sqrt_det_g,
6943  double* referenceWeights,
6944  double* weights)
6945 {
6946  int ebN,eN,k;
6947  for (eN=0;eN<nElements_global;eN++)
6948  for (ebN=0; ebN < nElementBoundaries_element; ebN++)
6949  for (k=0;k<nQuadraturePoints_elementBoundary;k++)
6950  weights[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
6951  ebN*nQuadraturePoints_elementBoundary +
6952  k]
6953  =
6954  sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
6955  ebN*nQuadraturePoints_elementBoundary +
6956  k]
6957  *
6958  referenceWeights[k];
6959 }
6960 
6961 void calculateGlobalExteriorElementBoundaryIntegrationWeights(int nQuadraturePoints_elementBoundary,
6962  int nExteriorElementBoundaries_global,
6963  double* sqrt_det_g,
6964  double* referenceWeights,
6965  double* weights)
6966 {
6967  int ebNE,k;
6968  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6969  for (k=0;k<nQuadraturePoints_elementBoundary;k++)
6970  weights[ebNE*nQuadraturePoints_elementBoundary +
6971  k]
6972  =
6973  sqrt_det_g[ebNE*nQuadraturePoints_elementBoundary +
6974  k]
6975  *
6976  referenceWeights[k];
6977 }
6978 
6982 void calculateFiniteElementFunctionValues(int nElements_global,
6983  int nQuadraturePoints_element,
6984  int nDOF_trial_element,
6985  int nComponents,
6986  int* l2g,
6987  double* dof,
6988  double* v,
6989  double* u)
6990 {
6991  int eN,k,j,t;
6992  memset(u,0,sizeof(double)*nElements_global*nQuadraturePoints_element*nComponents);
6993  for (eN=0;eN<nElements_global;eN++)
6994  for (k=0;k<nQuadraturePoints_element;k++)
6995  for (j=0;j<nDOF_trial_element;j++)
6996  for (t=0;t<nComponents;t++)
6997  u[eN*nQuadraturePoints_element*nComponents+
6998  k*nComponents+
6999  t]
7000  +=
7001  dof[l2g[eN*nDOF_trial_element+
7002  j]*nComponents+
7003  t]
7004  *
7005  v[eN*nQuadraturePoints_element*nDOF_trial_element+
7006  k*nDOF_trial_element+
7007  j];
7008 }
7009 
7014  int nQuadraturePoints_element,
7015  int nDOF_trial_element,
7016  int nComponents,
7017  int nSpace,
7018  int* l2g,
7019  double* dof,
7020  double* grad_v,
7021  double* grad_u)
7022 {
7023  int eN,k,j,t,I;
7024  memset(grad_u,0,sizeof(double)*nElements_global*nQuadraturePoints_element*nComponents*nSpace);
7025  for (eN=0;eN<nElements_global;eN++)
7026  for (k=0;k<nQuadraturePoints_element;k++)
7027  for (j=0;j<nDOF_trial_element;j++)
7028  for (t=0;t<nComponents;t++)
7029  for (I=0;I<nSpace;I++)
7030  grad_u[eN*nQuadraturePoints_element*nComponents*nSpace+
7031  k*nComponents*nSpace+
7032  t*nSpace+
7033  I]
7034  +=
7035  dof[l2g[eN*nDOF_trial_element+
7036  j]*nComponents+
7037  t]
7038  *
7039  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace+
7040  k*nDOF_trial_element*nSpace+
7041  j*nSpace+
7042  I];
7043 }
7044 
7046  int nQuadraturePoints_element,
7047  int nDOF_trial_element,
7048  int nComponents,
7049  int nSpace,
7050  int* l2g,
7051  double* dof,
7052  double* Hessian_v,
7053  double* Hessian_u)
7054 {
7055  int eN,k,j,t,I,J,nSpace2=nSpace*nSpace;
7056  memset(Hessian_u,0,sizeof(double)*nElements_global*nQuadraturePoints_element*nComponents*nSpace2);
7057  for (eN=0;eN<nElements_global;eN++)
7058  for (k=0;k<nQuadraturePoints_element;k++)
7059  for (j=0;j<nDOF_trial_element;j++)
7060  for (t=0;t<nComponents;t++)
7061  for (I=0;I<nSpace;I++)
7062  for (J=0;J<nSpace;J++)
7063  Hessian_u[eN*nQuadraturePoints_element*nComponents*nSpace2+
7064  k*nComponents*nSpace2+
7065  t*nSpace2+
7066  I*nSpace+
7067  J]
7068  +=
7069  dof[l2g[eN*nDOF_trial_element+
7070  j]*nComponents+
7071  t]
7072  *
7073  Hessian_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace2+
7074  k*nDOF_trial_element*nSpace2+
7075  j*nSpace2+
7076  I*nSpace+
7077  J];
7078 }
7079 
7125  int nQuadraturePoints_element,
7126  int nDOF_trial_element,
7127  int nDOF_test_element,
7128  int nComponents,
7129  int nSpace,
7130  int* l2g,
7131  double* dof,
7132  double* grad_v_X_grad_w_dV,
7133  double* grad_u_X_grad_w_dV)
7134 {
7135  int eN,k,j,i,I,J,t,nSpace2=nSpace*nSpace;
7136  int nDOF_test_X_trial_element = nDOF_test_element*nDOF_trial_element;
7137  memset(grad_u_X_grad_w_dV,0,sizeof(double)*nElements_global*nQuadraturePoints_element*nDOF_test_element*nComponents*nSpace2);
7138  for(eN=0;eN<nElements_global;eN++)
7139  for(k=0;k<nQuadraturePoints_element;k++)
7140  for(j=0;j<nDOF_trial_element;j++)
7141  for(i=0;i<nDOF_test_element;i++)
7142  for (t=0;t<nComponents;t++)
7143  for(I=0;I<nSpace;I++)
7144  for(J=0;J<nSpace;J++)
7145  grad_u_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nComponents*nSpace2+
7146  k*nDOF_test_element*nComponents*nSpace2 +
7147  i*nComponents*nSpace2 +
7148  t*nSpace2 +
7149  I*nSpace +
7150  J]
7151  +=
7152  dof[l2g[eN*nDOF_trial_element+
7153  j]*nComponents+
7154  t]
7155  *
7156  grad_v_X_grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_X_trial_element*nSpace2 +
7157  k*nDOF_test_X_trial_element*nSpace2 +
7158  j*nDOF_test_element*nSpace2 +
7159  i*nSpace2 +
7160  I*nSpace +
7161  J];
7162 }
7163 
7168  int nElementBoundaries_element,
7169  int nQuadraturePoints_elementBoundary,
7170  int nDOF_trial_element,
7171  int nComponents,
7172  int* l2g,
7173  double* dof,
7174  double* v,
7175  double* u)
7176 {
7177  int eN,ebN,k,j,t;
7178  memset(u,0,sizeof(double)*nElements_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nComponents);
7179  for(eN=0;eN<nElements_global;eN++)
7180  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
7181  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7182  for(j=0;j<nDOF_trial_element;j++)
7183  for(t=0;t<nComponents;t++)
7184  u[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nComponents+
7185  ebN*nQuadraturePoints_elementBoundary*nComponents+
7186  k*nComponents+
7187  t]
7188  +=
7189  dof[l2g[eN*nDOF_trial_element+j]*nComponents+
7190  t]
7191  *
7192  v[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
7193  ebN*nQuadraturePoints_elementBoundary*nDOF_trial_element+
7194  k*nDOF_trial_element+
7195  j];
7196 }
7197 
7198 
7203  int nElementBoundaries_element,
7204  int nQuadraturePoints_elementBoundary,
7205  int nDOF_trial_element,
7206  int nComponents,
7207  int nSpace,
7208  int* l2g,
7209  double* dof,
7210  double* grad_v,
7211  double* grad_u)
7212 {
7213  int eN,ebN,k,j,t,I;
7214  memset(grad_u,0,sizeof(double)*nElements_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nComponents*nSpace);
7215  for(eN=0;eN<nElements_global;eN++)
7216  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
7217  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7218  for(j=0;j<nDOF_trial_element;j++)
7219  for(t=0;t<nComponents;t++)
7220  for(I=0;I<nSpace;I++)
7221  grad_u[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nComponents*nSpace+
7222  ebN*nQuadraturePoints_elementBoundary*nComponents*nSpace+
7223  k*nComponents*nSpace+
7224  t*nSpace+
7225  I]
7226  +=
7227  dof[l2g[eN*nDOF_trial_element+j]*nComponents+
7228  t]
7229  *
7230  grad_v[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
7231  ebN*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
7232  k*nDOF_trial_element*nSpace+
7233  j*nSpace+
7234  I];
7235 }
7236 void calculateFiniteElementFunctionValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary,
7237  int nDOF_trial_element,
7238  int nComponents,
7239  int nExteriorElementBoundaries_global,
7240  const int * exteriorElementBoundariesArray,
7241  const int * elementBoundaryElementsArray,
7242  const int * elementBoundaryLocalElementBoundariesArray,
7243  int* l2g,
7244  double* dof,
7245  double* v,
7246  double* u)
7247 {
7248  int eN,ebN,ebNE,ebN_local,k,j,t;
7249  memset(u,0,sizeof(double)*nExteriorElementBoundaries_global*nQuadraturePoints_elementBoundary*nComponents);
7250  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
7251  {
7252  ebN = exteriorElementBoundariesArray[ebNE];
7253  eN = elementBoundaryElementsArray[ebN*2+0];
7254  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
7255  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7256  for(j=0;j<nDOF_trial_element;j++)
7257  for(t=0;t<nComponents;t++)
7258  u[ebNE*nQuadraturePoints_elementBoundary*nComponents+
7259  k*nComponents+
7260  t]
7261  +=
7262  dof[l2g[eN*nDOF_trial_element+j]*nComponents+
7263  t]
7264  *
7265  v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
7266  k*nDOF_trial_element+
7267  j];
7268  }
7269 }
7270 
7271 void calculateFiniteElementFunctionGradientValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary,
7272  int nDOF_trial_element,
7273  int nComponents,
7274  int nSpace,
7275  int nExteriorElementBoundaries_global,
7276  const int * exteriorElementBoundariesArray,
7277  const int * elementBoundaryElementsArray,
7278  const int * elementBoundaryLocalElementBoundariesArray,
7279  int* l2g,
7280  double* dof,
7281  double* grad_v,
7282  double* grad_u)
7283 {
7284  int eN,ebN,ebNE,ebN_local,k,j,t,I;
7285  memset(grad_u,0,sizeof(double)*nExteriorElementBoundaries_global*nQuadraturePoints_elementBoundary*nComponents*nSpace);
7286  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
7287  {
7288  ebN = exteriorElementBoundariesArray[ebNE];
7289  eN = elementBoundaryElementsArray[ebN*2+0];
7290  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
7291  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7292  for(j=0;j<nDOF_trial_element;j++)
7293  for(t=0;t<nComponents;t++)
7294  for(I=0;I<nSpace;I++)
7295  grad_u[ebNE*nQuadraturePoints_elementBoundary*nComponents*nSpace+
7296  k*nComponents*nSpace+
7297  t*nSpace+
7298  I]
7299  +=
7300  dof[l2g[eN*nDOF_trial_element+j]*nComponents+
7301  t]
7302  *
7303  grad_v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
7304  k*nDOF_trial_element*nSpace+
7305  j*nSpace+
7306  I];
7307  }
7308 }
7309 
7310 
7314 void calculateFlowVelocity(int nElements_global,
7315  int nQuadraturePoints_element,
7316  int nSpace,
7317  double* f,
7318  double* a,
7319  double* grad_phi,
7320  double* v)
7321 {
7322  int eN,k,I,J,nSpace2=nSpace*nSpace;
7323  for (eN=0;eN<nElements_global;eN++)
7324  for (k=0;k<nQuadraturePoints_element;k++)
7325  for (I=0;I<nSpace;I++)
7326  {
7327  v[eN*nQuadraturePoints_element*nSpace+
7328  k*nSpace+
7329  I]
7330  =
7331  f[eN*nQuadraturePoints_element*nSpace+
7332  k*nSpace+
7333  I];
7334  for (J=0;J<nSpace;J++)
7335  v[eN*nQuadraturePoints_element*nSpace+
7336  k*nSpace+
7337  I]
7338  -=
7339  a[eN*nQuadraturePoints_element*nSpace2+
7340  k*nSpace2+
7341  I*nSpace+
7342  J]
7343  *
7344  grad_phi[eN*nQuadraturePoints_element*nSpace+
7345  k*nSpace+
7346  J];
7347  }
7348 }
7349 
7353 void updateAddJacobian_CSR(int jacIndex,
7354  double val,
7355  double* jac)
7356 {
7357  jac[jacIndex] += val;
7358 }
7359 
7363 void zeroJacobian_CSR(int nNonzeros,
7364  double* jac)
7365 {
7366  memset(jac,0,sizeof(double)*nNonzeros);
7367 }
7368 
7369 void calculateInteriorElementBoundaryVelocities(int nInteriorElementBoundaries_global,
7370  int nElementBoundaries_element,
7371  int nQuadraturePoints_elementBoundary,
7372  int nSpace,
7373  int* interiorElementBoundaries,
7374  int* elementBoundaryElements,
7375  int* elementBoundaryLocalElementBoundaries,
7376  double* m,
7377  double* a,
7378  double* grad_phi,
7379  double* f,
7380  double* vAverage,
7381  double* vJump,
7382  double* mAverage,
7383  double* mJump)
7384 {
7385  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,I,J,nSpace2=nSpace*nSpace;
7386  register double vLeft,vRight,mLeft,mRight;
7387  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
7388  {
7389  ebN = interiorElementBoundaries[ebNI];
7390  left_eN_global = elementBoundaryElements[ebN*2+0];
7391  right_eN_global = elementBoundaryElements[ebN*2+1];
7392  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7393  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
7394  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7395  {
7396  mLeft
7397  =
7398  m[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
7399  left_ebN_element*nQuadraturePoints_elementBoundary+
7400  k];
7401  mRight
7402  =
7403  m[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
7404  right_ebN_element*nQuadraturePoints_elementBoundary+
7405  k];
7406  for (I=0;I<nSpace;I++)
7407  {
7408  vLeft
7409  =
7410  f[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7411  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7412  k*nSpace+
7413  I];
7414  vRight
7415  =
7416  f[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7417  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7418  k*nSpace+
7419  I];
7420  for (J=0;J<nSpace;J++)
7421  {
7422  vLeft
7423  -=
7424  a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7425  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7426  k*nSpace2+
7427  I*nSpace+
7428  J]
7429  *
7430  grad_phi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7431  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7432  k*nSpace+
7433  J];
7434  vRight -=
7435  a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7436  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7437  k*nSpace2+
7438  I*nSpace+
7439  J]
7440  *
7441  grad_phi[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7442  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7443  k*nSpace+
7444  J];
7445  }
7446  vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
7447  k*nSpace+
7448  I] = 0.5*(vLeft + vRight);
7449  vJump[ebN*nQuadraturePoints_elementBoundary*nSpace+
7450  k*nSpace+
7451  I] = (vLeft - vRight);
7452  }
7453  mAverage[ebN*nQuadraturePoints_elementBoundary+
7454  k] = 0.5*(mLeft+mRight);
7455  mJump[ebN*nQuadraturePoints_elementBoundary+
7456  k] = mLeft - mRight;
7457  }
7458  }
7459 }
7460 
7461 void calculateExteriorElementBoundaryVelocities(int nExteriorElementBoundaries_global,
7462  int nElementBoundaries_element,
7463  int nQuadraturePoints_elementBoundary,
7464  int nSpace,
7465  int* exteriorElementBoundaries,
7466  int* elementBoundaryElements,
7467  int* elementBoundaryLocalElementBoundaries,
7468  double* m,
7469  double* a,
7470  double* grad_phi,
7471  double* f,
7472  double* vAverage,
7473  double* vJump,
7474  double* mAverage,
7475  double* mJump)
7476 {
7477  int ebNE,ebN,left_eN_global,left_ebN_element,k,I,J,nSpace2=nSpace*nSpace;
7478  register double vLeft,mLeft;
7479  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
7480  {
7481  ebN = exteriorElementBoundaries[ebNE];
7482  left_eN_global = elementBoundaryElements[ebN*2+0];
7483  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7484  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7485  {
7486  mLeft
7487  =
7488  m[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
7489  left_ebN_element*nQuadraturePoints_elementBoundary+
7490  k];
7491  for (I=0;I<nSpace;I++)
7492  {
7493  vLeft
7494  =
7495  f[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7496  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7497  k*nSpace+
7498  I];
7499  for (J=0;J<nSpace;J++)
7500  {
7501  vLeft
7502  -=
7503  a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7504  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7505  k*nSpace2+
7506  I*nSpace+
7507  J]
7508  *
7509  grad_phi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7510  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7511  k*nSpace+
7512  J];
7513  }
7514  vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
7515  k*nSpace+
7516  I] = vLeft;
7517  vJump[ebN*nQuadraturePoints_elementBoundary*nSpace+
7518  k*nSpace+
7519  I] = vLeft;
7520  }
7521  mAverage[ebN*nQuadraturePoints_elementBoundary+
7522  k] = mLeft;
7523  mJump[ebN*nQuadraturePoints_elementBoundary+
7524  k] = mLeft;
7525  }
7526  }
7527 }
7528 
7529 /*mwf hack
7530  load in boundary condition velocity values directy into velocity vector
7531 */
7533  int nExteriorElementBoundaries_global,
7534  int nQuadraturePoints_elementBoundary,
7535  int nSpace,
7536  int* exteriorElementBoundaries,
7537  int* elementBoundaryElements,
7538  int* elementBoundaryLocalElementBoundaries,
7539  double* n,
7540  double* vn_in,
7541  double* v_out)
7542 {
7543  int ebNE,ebN,k,I;
7544  double multiple = 0.0;
7545  if (updateFluxValues > 0)
7546  multiple = 1.0;
7547  /*mwf debug*/
7548  printf("setExteriorGlobalElementBoundaryVelocityValues update= %d nExtElmBndr_global= %d nQuadElmBndr= %d nSpace=%d \n",
7549  updateFluxValues,nExteriorElementBoundaries_global,nQuadraturePoints_elementBoundary,nSpace);
7550  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
7551  {
7552  ebN = exteriorElementBoundaries[ebNE];
7553  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7554  for (I=0;I<nSpace;I++)
7555  {
7556  v_out[ebN*nQuadraturePoints_elementBoundary*nSpace+
7557  k*nSpace+
7558  I] =
7559  multiple*v_out[ebN*nQuadraturePoints_elementBoundary*nSpace+
7560  k*nSpace+
7561  I]
7562  +
7563  n[ebN*nQuadraturePoints_elementBoundary*nSpace+
7564  k*nSpace+
7565  I]
7566  *
7567  vn_in[ebN*nQuadraturePoints_elementBoundary+
7568  k];
7569 
7570  /*mwf debug*/
7571  printf("setExtGlobElmVel ebN=%d k=%d I=%d vn_in=%g v_out=%g \n",
7572  ebN,k,I,
7573  vn_in[ebN*nQuadraturePoints_elementBoundary+
7574  k],
7575  v_out[ebN*nQuadraturePoints_elementBoundary*nSpace+
7576  k*nSpace+
7577  I]);
7578 
7579  }
7580  }
7581 
7582 }
7583 
7584 
7588 void calculateDimensionlessNumbersADR(int nElements_global,
7589  int nQuadraturePoints_element,
7590  int nSpace,
7591  int computeDiffusiveTimeStepLimit,
7592  double* elementDiameter,
7593  double* df,
7594  double* a,
7595  double* dphi,
7596  double* dr,
7597  double* dmt,
7598  double* pe,
7599  double* cfl)
7600 {
7601  int eN,k,I,nSpace2=nSpace*nSpace;
7602  double h,Vlin,Alin,A_II,num,den,cfl1,cfl2;
7603  for(eN=0;eN<nElements_global;eN++)
7604  {
7605  h = elementDiameter[eN];
7606  for (k=0;k<nQuadraturePoints_element;k++)
7607  {
7608  Vlin = 0.0;
7609  Alin = 0.0;
7610  for(I=0;I<nSpace;I++)
7611  Vlin
7612  +=
7613  df[eN*nQuadraturePoints_element*nSpace +
7614  k*nSpace +
7615  I]
7616  *
7617  df[eN*nQuadraturePoints_element*nSpace +
7618  k*nSpace +
7619  I];
7620  Vlin = sqrt(Vlin);
7621  /*max diagonal entry for A. This choice needs to be looked into*/
7622  for(I=0;I<nSpace;I++)
7623  {
7624  A_II = a[eN*nQuadraturePoints_element*nSpace2 +
7625  k*nSpace2 +
7626  I*nSpace +
7627  I];
7628  Alin = (A_II > Alin) ? A_II : Alin;
7629  }
7630  Alin*=dphi[eN*nQuadraturePoints_element +
7631  k];
7632  cfl1 = Vlin/h;
7633  cfl2 = Alin/(h*h);
7634  if (computeDiffusiveTimeStepLimit)
7635  cfl[eN*nQuadraturePoints_element +
7636  k] = cfl2;
7637  else
7638  cfl[eN*nQuadraturePoints_element +
7639  k] = cfl1;
7640  num = 0.5*Vlin*h + 1.0e-8;
7641  den = Alin + num*1.0e-8;
7642  pe[eN*nQuadraturePoints_element + k] = num/den;
7643  }
7644  }
7645 }
7646 
7647 void calculateDimensionlessNumbersADR_sd(int nElements_global,
7648  int nQuadraturePoints_element,
7649  int nSpace,
7650  int computeDiffusiveTimeStepLimit,
7651  int* rowptr,
7652  int* colind,
7653  double* elementDiameter,
7654  double* df,
7655  double* a,
7656  double* dphi,
7657  double* dr,
7658  double* dmt,
7659  double* pe,
7660  double* cfl)
7661 {
7662  int eN,k,I,m,nnz=rowptr[nSpace];
7663  double h,Vlin,Alin,A_II,num,den,cfl1,cfl2;
7664  for(eN=0;eN<nElements_global;eN++)
7665  {
7666  h = elementDiameter[eN];
7667  for (k=0;k<nQuadraturePoints_element;k++)
7668  {
7669  Vlin = 0.0;
7670  Alin = 0.0;
7671  for(I=0;I<nSpace;I++)
7672  {
7673  Vlin
7674  +=
7675  df[eN*nQuadraturePoints_element*nSpace +
7676  k*nSpace +
7677  I]
7678  *
7679  df[eN*nQuadraturePoints_element*nSpace +
7680  k*nSpace +
7681  I];
7682  }
7683  Vlin = sqrt(Vlin);
7684  /*max diagonal entry for A. This choice needs to be looked into*/
7685  for(I=0;I<nSpace;I++)
7686  {
7687  for(m=rowptr[I];m<rowptr[I+1];m++)
7688  {
7689  if (I == colind[m])
7690  {
7691  A_II = a[eN*nQuadraturePoints_element*nnz+
7692  k*nnz+
7693  m];
7694  Alin = (A_II > Alin) ? A_II : Alin;
7695  }
7696  }
7697  }
7698  Alin*=dphi[eN*nQuadraturePoints_element +
7699  k];
7700  cfl1 = Vlin/h;
7701  cfl2 = Alin/(h*h);
7702  if (computeDiffusiveTimeStepLimit)
7703  cfl[eN*nQuadraturePoints_element +
7704  k] = cfl2;
7705  else
7706  cfl[eN*nQuadraturePoints_element +
7707  k] = cfl1;
7708  num = 0.5*Vlin*h + 1.0e-8;
7709  den = Alin + num*1.0e-8;
7710  pe[eN*nQuadraturePoints_element + k] = num/den;
7711  }
7712  }
7713 }
7714 
7715 /*just compute CFL*/
7716 void calculateCFLADR(int nElements_global,
7717  int nQuadraturePoints_element,
7718  int nSpace,
7719  double* elementDiameter,
7720  double* dm,
7721  double* df,
7722  double* cfl)
7723 {
7724  int eN,k,I;
7725  double h,Vlin,dmdu,cfl1;
7726  for(eN=0;eN<nElements_global;eN++)
7727  {
7728  h = elementDiameter[eN];
7729  for (k=0;k<nQuadraturePoints_element;k++)
7730  {
7731  dmdu = dm[eN*nQuadraturePoints_element + k];
7732  Vlin = 0.0;
7733  for(I=0;I<nSpace;I++)
7734  Vlin
7735  +=
7736  df[eN*nQuadraturePoints_element*nSpace +
7737  k*nSpace +
7738  I]
7739  *
7740  df[eN*nQuadraturePoints_element*nSpace +
7741  k*nSpace +
7742  I];
7743  Vlin = sqrt(Vlin)/(dmdu+1.0e-10);
7744  cfl1 = Vlin/h;
7745  cfl[eN*nQuadraturePoints_element +
7746  k] = cfl1;
7747 
7748  }
7749  }
7750 }
7751 /*not really likely but in case have two separate characteristic speeds to add?*/
7752 void calculateCFLADR2speeds(int nElements_global,
7753  int nQuadraturePoints_element,
7754  int nSpace,
7755  double* elementDiameter,
7756  double* dm,
7757  double* df1,
7758  double* df2,
7759  double* cfl)
7760 {
7761  int eN,k,I;
7762  double h,Vlin,dmdu,cfl1;
7763  for(eN=0;eN<nElements_global;eN++)
7764  {
7765  h = elementDiameter[eN];
7766  for (k=0;k<nQuadraturePoints_element;k++)
7767  {
7768  dmdu = dm[eN*nQuadraturePoints_element + k];
7769  Vlin = 0.0;
7770  for(I=0;I<nSpace;I++)
7771  Vlin
7772  +=
7773  df1[eN*nQuadraturePoints_element*nSpace +
7774  k*nSpace +
7775  I]
7776  *
7777  df1[eN*nQuadraturePoints_element*nSpace +
7778  k*nSpace +
7779  I]
7780  +
7781  df2[eN*nQuadraturePoints_element*nSpace +
7782  k*nSpace +
7783  I]
7784  *
7785  df2[eN*nQuadraturePoints_element*nSpace +
7786  k*nSpace +
7787  I];
7788 
7789  Vlin = sqrt(Vlin)/(dmdu+1.0e-10);
7790  cfl1 = Vlin/h;
7791  cfl[eN*nQuadraturePoints_element +
7792  k] = cfl1;
7793 
7794  }
7795  }
7796 }
7797 
7798 
7802 void updateInteriorElementBoundaryDiffusiveVelocity(int nInteriorElementBoundaries_global,
7803  int nElementBoundaries_element,
7804  int nQuadraturePoints_elementBoundary,
7805  int nSpace,
7806  int* interiorElementBoundaries,
7807  int* elementBoundaryElements,
7808  int* elementBoundaryLocalElementBoundaries,
7809  double* a,
7810  double* grad_phi,
7811  double* velocity)
7812 {
7813  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,J,I,nSpace2=nSpace*nSpace;
7814  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
7815  {
7816  ebN = interiorElementBoundaries[ebNI];
7817  left_eN_global = elementBoundaryElements[ebN*2+0];
7818  right_eN_global = elementBoundaryElements[ebN*2+1];
7819  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7820  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
7821  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7822  for(I=0;I<nSpace;I++)
7823  for(J=0;J<nSpace;J++)
7824  {
7825  velocity[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7826  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7827  k*nSpace+I]
7828  -=
7829  a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7830  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7831  k*nSpace2+
7832  I*nSpace+
7833  J]
7834  *
7835  grad_phi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7836  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7837  k*nSpace+J];
7838  velocity[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7839  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7840  k*nSpace+I]
7841  -=
7842  a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7843  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7844  k*nSpace2+
7845  I*nSpace+
7846  J]
7847  *
7848  grad_phi[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7849  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7850  k*nSpace+J];
7851  }
7852  }
7853 }
7854 
7855 void updateInteriorElementBoundaryDiffusiveVelocity_sd(int nInteriorElementBoundaries_global,
7856  int nElementBoundaries_element,
7857  int nQuadraturePoints_elementBoundary,
7858  int nSpace,
7859  int* rowptr,
7860  int* colind,
7861  int* interiorElementBoundaries,
7862  int* elementBoundaryElements,
7863  int* elementBoundaryLocalElementBoundaries,
7864  double* a,
7865  double* grad_phi,
7866  double* velocity)
7867 {
7868  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,m,I,nnz=rowptr[nSpace];
7869  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
7870  {
7871  ebN = interiorElementBoundaries[ebNI];
7872  left_eN_global = elementBoundaryElements[ebN*2+0];
7873  right_eN_global = elementBoundaryElements[ebN*2+1];
7874  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7875  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
7876  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7877  for(I=0;I<nSpace;I++)
7878  for(m=rowptr[I];m<rowptr[I+1];m++)
7879  {
7880  velocity[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7881  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7882  k*nSpace+I]
7883  -=
7884  a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
7885  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
7886  k*nnz+
7887  m]
7888  *
7889  grad_phi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7890  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7891  k*nSpace+colind[m]];
7892  velocity[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7893  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7894  k*nSpace+I]
7895  -=
7896  a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
7897  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
7898  k*nnz+
7899  m]
7900  *
7901  grad_phi[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7902  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7903  k*nSpace+colind[m]];
7904  }
7905  }
7906 }
7907 
7911 void updateExteriorElementBoundaryDiffusiveVelocity(int nExteriorElementBoundaries_global,
7912  int nElementBoundaries_element,
7913  int nQuadraturePoints_elementBoundary,
7914  int nSpace,
7915  int* exteriorElementBoundaries,
7916  int* elementBoundaryElements,
7917  int* elementBoundaryLocalElementBoundaries,
7918  double* a,
7919  double* grad_phi,
7920  double* velocity)
7921 {
7922  int ebNE,ebN,eN_global,ebN_element,k,J,I,nSpace2=nSpace*nSpace;
7923  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
7924  {
7925  ebN = exteriorElementBoundaries[ebNE];
7926  eN_global = elementBoundaryElements[ebN*2+0];
7927  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7928  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7929  for(I=0;I<nSpace;I++)
7930  {
7931  for(J=0;J<nSpace;J++)
7932  {
7933  velocity[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7934  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7935  k*nSpace+I]
7936  -=
7937  a[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
7938  ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
7939  k*nSpace2+
7940  I*nSpace+
7941  J]
7942  *
7943  grad_phi[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7944  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7945  k*nSpace+J];
7946  }
7947  }/*I*/
7948  }
7949 }
7950 
7951 void updateExteriorElementBoundaryDiffusiveVelocity_sd(int nExteriorElementBoundaries_global,
7952  int nElementBoundaries_element,
7953  int nQuadraturePoints_elementBoundary,
7954  int nSpace,
7955  int* rowptr,
7956  int* colind,
7957  int* exteriorElementBoundaries,
7958  int* elementBoundaryElements,
7959  int* elementBoundaryLocalElementBoundaries,
7960  double* a,
7961  double* grad_phi,
7962  double* velocity)
7963 {
7964  int ebNE,ebN,eN_global,ebN_element,k,m,I,nnz=rowptr[nSpace];
7965  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
7966  {
7967  ebN = exteriorElementBoundaries[ebNE];
7968  eN_global = elementBoundaryElements[ebN*2+0];
7969  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
7970  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
7971  for(I=0;I<nSpace;I++)
7972  {
7973  for(m=rowptr[I];m<rowptr[I+1];m++)
7974  {
7975  velocity[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7976  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7977  k*nSpace+I]
7978  -=
7979  a[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
7980  ebN_element*nQuadraturePoints_elementBoundary*nnz+
7981  k*nnz+
7982  m]
7983  *
7984  grad_phi[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
7985  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
7986  k*nSpace+colind[m]];
7987  }
7988  }/*I*/
7989  }
7990 }
7991 
7995 void updateGlobalExteriorElementBoundaryDiffusiveVelocity(int nExteriorElementBoundaries_global,
7996  int nQuadraturePoints_elementBoundary,
7997  int nSpace,
7998  int* exteriorElementBoundaries,
7999  int* elementBoundaryElements,
8000  int* elementBoundaryLocalElementBoundaries,
8001  double* a,
8002  double* grad_phi,
8003  double* velocity)
8004 {
8005  int ebNE,k,J,I,nSpace2=nSpace*nSpace;
8006  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8007  {
8008  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8009  for(I=0;I<nSpace;I++)
8010  {
8011  for(J=0;J<nSpace;J++)
8012  {
8013  velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8014  k*nSpace+I]
8015  -=
8016  a[ebNE*nQuadraturePoints_elementBoundary*nSpace2+
8017  k*nSpace2+
8018  I*nSpace+
8019  J]
8020  *
8021  grad_phi[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8022  k*nSpace+J];
8023  }
8024  }/*I*/
8025  }
8026 }
8027 
8028 void updateGlobalExteriorElementBoundaryDiffusiveVelocity_sd(int nExteriorElementBoundaries_global,
8029  int nQuadraturePoints_elementBoundary,
8030  int nSpace,
8031  int* rowptr,
8032  int* colind,
8033  int* exteriorElementBoundaries,
8034  int* elementBoundaryElements,
8035  int* elementBoundaryLocalElementBoundaries,
8036  double* a,
8037  double* grad_phi,
8038  double* velocity)
8039 {
8040  int ebNE,k,m,I,nnz=rowptr[nSpace];
8041  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8042  {
8043  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8044  for(I=0;I<nSpace;I++)
8045  {
8046  for(m=rowptr[I];m<rowptr[I+1];m++)
8047  {
8048  velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8049  k*nSpace+I]
8050  -=
8051  a[ebNE*nQuadraturePoints_elementBoundary*nnz+
8052  k*nnz+
8053  m]
8054  *
8055  grad_phi[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8056  k*nSpace+colind[m]];
8057  }
8058  }/*I*/
8059  }
8060 }
8061 
8062 
8066 void updateInteriorElementBoundaryAdvectiveVelocity(int nInteriorElementBoundaries_global,
8067  int nElementBoundaries_element,
8068  int nQuadraturePoints_elementBoundary,
8069  int nSpace,
8070  int* interiorElementBoundaries,
8071  int* elementBoundaryElements,
8072  int* elementBoundaryLocalElementBoundaries,
8073  double* f,
8074  double* velocity)
8075 {
8076  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,J;
8077  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8078  {
8079  ebN = interiorElementBoundaries[ebNI];
8080  left_eN_global = elementBoundaryElements[ebN*2+0];
8081  right_eN_global = elementBoundaryElements[ebN*2+1];
8082  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8083  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8084  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8085  for (J=0;J<nSpace;J++)
8086  {
8087  velocity[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8088  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8089  k*nSpace+
8090  J]
8091  +=
8092  f[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8093  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8094  k*nSpace+
8095  J];
8096  velocity[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8097  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8098  k*nSpace+
8099  J]
8100  +=
8101  f[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8102  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8103  k*nSpace+
8104  J];
8105  }
8106  }
8107 }
8108 
8109 
8113 void updateExteriorElementBoundaryAdvectiveVelocity(int nExteriorElementBoundaries_global,
8114  int nElementBoundaries_element,
8115  int nQuadraturePoints_elementBoundary,
8116  int nSpace,
8117  int* exteriorElementBoundaries,
8118  int* elementBoundaryElements,
8119  int* elementBoundaryLocalElementBoundaries,
8120  double* f,
8121  double* velocity)
8122 {
8123  int ebNE,ebN,eN_global,ebN_element,k,J;
8124  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8125  {
8126  ebN = exteriorElementBoundaries[ebNE];
8127  eN_global = elementBoundaryElements[ebN*2+0];
8128  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8129  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8130  for(J=0;J<nSpace;J++)
8131  {
8132  velocity[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8133  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8134  k*nSpace+
8135  J]
8136  +=
8137  f[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8138  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8139  k*nSpace+
8140  J];
8141  }
8142  }
8143 }
8147 void updateGlobalExteriorElementBoundaryAdvectiveVelocity(int nExteriorElementBoundaries_global,
8148  int nQuadraturePoints_elementBoundary,
8149  int nSpace,
8150  int* exteriorElementBoundaries,
8151  int* elementBoundaryElements,
8152  int* elementBoundaryLocalElementBoundaries,
8153  double* f,
8154  double* velocity)
8155 {
8156  int ebNE,k,J;
8157  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8158  {
8159  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8160  for(J=0;J<nSpace;J++)
8161  {
8162  velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8163  k*nSpace+
8164  J]
8165  +=
8166  f[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8167  k*nSpace+
8168  J];
8169  }
8170  }
8171 }
8172 
8176 void updateInteriorElementBoundaryShockCapturingVelocity(int nInteriorElementBoundaries_global,
8177  int nElementBoundaries_element,
8178  int nQuadraturePoints_elementBoundary,
8179  int nQuadraturePoints_element,
8180  int nSpace,
8181  int* interiorElementBoundaries,
8182  int* elementBoundaryElements,
8183  int* elementBoundaryLocalElementBoundaries,
8184  double* numDiff,
8185  double* grad_u,
8186  double* velocity)
8187 {
8188  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,I;
8189  double numDiffAvg_left,numDiffAvg_right;
8190  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8191  {
8192  ebN = interiorElementBoundaries[ebNI];
8193  left_eN_global = elementBoundaryElements[ebN*2+0];
8194  right_eN_global = elementBoundaryElements[ebN*2+1];
8195  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8196  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8197  /*get scalar numDiff coefficient from the left and right assuming constant*/
8198  numDiffAvg_left = numDiff[left_eN_global*nQuadraturePoints_element+0];
8199  numDiffAvg_right = numDiff[right_eN_global*nQuadraturePoints_element+0];
8200  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8201  for(I=0;I<nSpace;I++)
8202  {
8203  velocity[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8204  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8205  k*nSpace+I]
8206  -=
8207  numDiffAvg_left
8208  *
8209  grad_u[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8210  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8211  k*nSpace+I];
8212  velocity[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8213  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8214  k*nSpace+I]
8215  -=
8216  numDiffAvg_right
8217  *
8218  grad_u[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8219  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8220  k*nSpace+I];
8221  }
8222  }
8223 }
8224 
8228 void updateExteriorElementBoundaryShockCapturingVelocity(int nExteriorElementBoundaries_global,
8229  int nElementBoundaries_element,
8230  int nQuadraturePoints_elementBoundary,
8231  int nQuadraturePoints_element,
8232  int nSpace,
8233  int* exteriorElementBoundaries,
8234  int* elementBoundaryElements,
8235  int* elementBoundaryLocalElementBoundaries,
8236  double* numDiff,
8237  double* grad_u,
8238  double* velocity)
8239 {
8240  int ebNE,ebN,eN_global,ebN_element,k,I;
8241  double numDiffAvg;
8242  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8243  {
8244  ebN = exteriorElementBoundaries[ebNE];
8245  eN_global = elementBoundaryElements[ebN*2+0];
8246  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8247  /*get scalar numDiff coefficient from the left and right assuming constant*/
8248  numDiffAvg = numDiff[eN_global*nQuadraturePoints_element+0];
8249  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8250  for(I=0;I<nSpace;I++)
8251  {
8252  velocity[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8253  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8254  k*nSpace+I]
8255  -=
8256  numDiffAvg
8257  *
8258  grad_u[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8259  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8260  k*nSpace+I];
8261 
8262  }/*I*/
8263  }/*ebN*/
8264 }
8265 
8266 
8270 void updateGlobalExteriorElementBoundaryShockCapturingVelocity(int nExteriorElementBoundaries_global,
8271  int nQuadraturePoints_elementBoundary,
8272  int nSpace,
8273  int* exteriorElementBoundaries,
8274  int* elementBoundaryElements,
8275  int* elementBoundaryLocalElementBoundaries,
8276  double* numDiff,
8277  double* grad_u,
8278  double* velocity)
8279 {
8280  int ebNE,k,I;
8281  double numDiffAvg;
8282  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8283  {
8284  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8285  for(I=0;I<nSpace;I++)
8286  {
8287  numDiffAvg = numDiff[ebNE*nQuadraturePoints_elementBoundary+k];
8288  velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8289  k*nSpace+I]
8290  -=
8291  numDiffAvg
8292  *
8293  grad_u[ebNE*nQuadraturePoints_elementBoundary*nSpace+
8294  k*nSpace+I];
8295 
8296  }/*I*/
8297  }/*ebN*/
8298 }
8299 void calculateInteriorElementBoundaryAverageVelocity(int nInteriorElementBoundaries_global,
8300  int nElementBoundaries_element,
8301  int nQuadraturePoints_elementBoundary,
8302  int nSpace,
8303  int* interiorElementBoundaries,
8304  int* elementBoundaryElements,
8305  int* elementBoundaryLocalElementBoundaries,
8306  double* v,
8307  double* vAverage)
8308 {
8309  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k,I;
8310  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8311  {
8312  ebN = interiorElementBoundaries[ebNI];
8313  left_eN_global = elementBoundaryElements[ebN*2+0];
8314  right_eN_global = elementBoundaryElements[ebN*2+1];
8315  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8316  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8317  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8318  for (I=0;I<nSpace;I++)
8319  vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
8320  k*nSpace+
8321  I]
8322  = 0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8323  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8324  k*nSpace+
8325  I]
8326  +
8327  v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8328  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8329  k*nSpace+
8330  I]);
8331  }
8332 }
8333 
8334 void calculateExteriorElementBoundaryAverageVelocity(int nExteriorElementBoundaries_global,
8335  int nElementBoundaries_element,
8336  int nQuadraturePoints_elementBoundary,
8337  int nSpace,
8338  int* exteriorElementBoundaries,
8339  int* elementBoundaryElements,
8340  int* elementBoundaryLocalElementBoundaries,
8341  double* v,
8342  double* vAverage)
8343 {
8344  int ebNE,ebN,left_eN_global,left_ebN_element,k,I;
8345  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8346  {
8347  ebN = exteriorElementBoundaries[ebNE];
8348  left_eN_global = elementBoundaryElements[ebN*2+0];
8349  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8350  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8351  for (I=0;I<nSpace;I++)
8352  {
8353 
8354  vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
8355  k*nSpace+
8356  I]
8357  = v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8358  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8359  k*nSpace+
8360  I];
8361  /*mwf debug
8362  printf("vfem.ext.vavg ebN=%d eN=%d ebN_element=%d k=%d v[%d]= %g \n",ebN,left_eN_global,
8363  left_ebN_element,k,I,
8364  v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8365  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8366  k*nSpace+
8367  I]);
8368  */
8369  }
8370  }
8371 }
8372 
8373 
8374 
8375 
8376 void calculateConservationResidualDG(int nElements_global,
8377  int nDOF_test_element,
8378  double * elementResidual,
8379  double * conservationResidual)
8380 {
8381  int eN,i;
8382  for (eN = 0; eN < nElements_global; eN++)
8383  {
8384  conservationResidual[eN] = 0.0;
8385  for (i = 0; i < nDOF_test_element; i++)
8386  conservationResidual[eN] += elementResidual[eN*nDOF_test_element + i];
8387  }
8388 }
8389 
8397 void calculateConservationResidual(int nElements_global,
8398  int nDOF_test_element,
8399  int nElementBoundaries_element,
8400  int nQuadraturePoints_elementBoundary,
8401  int nSpace,
8402  double * n,
8403  double * dS_u,
8404  double * elementResidual,
8405  double * velocity,
8406  double * conservationResidual)
8407 {
8408  int eN,ebN,i,k,I;
8409  double boundaryFlux;
8410  for (eN = 0; eN < nElements_global; eN++)
8411  {
8412  conservationResidual[eN] = 0.0;
8413 
8414  for (i = 0; i < nDOF_test_element; i++)
8415  conservationResidual[eN] += elementResidual[eN*nDOF_test_element + i];
8416 
8417  boundaryFlux = 0.0;
8418  for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
8419  {
8420  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
8421  {
8422  for (I = 0; I < nSpace; I++)
8423  {
8424  boundaryFlux +=
8425  n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
8426  ebN*nQuadraturePoints_elementBoundary*nSpace +
8427  k*nSpace +
8428  I]
8429  *
8430  velocity[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
8431  ebN*nQuadraturePoints_elementBoundary*nSpace +
8432  k*nSpace +
8433  I]
8434  *
8435  dS_u[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
8436  ebN*nQuadraturePoints_elementBoundary +
8437  k];
8438  }/*I*/
8439  }/*k*/
8440  }/*ebN*/
8441  /*mwf debug
8442  printf("calcConsRes eN=%d accum= %g boundaryFlux= %g diff=%g \n",eN,conservationResidual[eN],boundaryFlux,
8443  conservationResidual[eN] -boundaryFlux);
8444 
8445  */
8446  conservationResidual[eN] += boundaryFlux;
8447 
8448  }/*eN*/
8449 }
8450 /* void calculateConservationResidualGlobalBoundaries(int nElements_global, */
8451 /* int nInteriorElementBoundaries_global, */
8452 /* int nExteriorElementBoundaries_global, */
8453 /* int nElementBoundaries_element, */
8454 /* int nQuadraturePoints_elementBoundary, */
8455 /* int nNodes_element, */
8456 /* int nSpace, */
8457 /* int* interiorElementBoundaries, */
8458 /* int* exteriorElementBoundaries, */
8459 /* int* elementBoundaryElements, */
8460 /* int* elementBoundaryLocalElementBoundaries, */
8461 /* double* dS, */
8462 /* double* normal, */
8463 /* double* elementResidual, */
8464 /* double* velocity, */
8465 /* double* conservationResidual) */
8466 /* { */
8467 /* int ebNI,ebNE,ebN,eN,nN,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,k,I; */
8468 /* register double flux,ds; */
8469 /* /\* /\\*mwf debug*\\/ *\/ */
8470 /* /\* register double signDebug = -1.0; *\/ */
8471 /* /\*first loop through and get element residual sums*\/ */
8472 /* for (eN = 0; eN < nElements_global; eN++) */
8473 /* { */
8474 /* for (nN = 0; nN < nNodes_element; nN++) */
8475 /* { */
8476 /* conservationResidual[eN] += elementResidual[eN*nNodes_element + nN]; */
8477 /* } */
8478 /* } */
8479 /* /\*now loop through element boundaries and update element sums*\/ */
8480 /* /\*interior*\/ */
8481 /* for (ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++) */
8482 /* { */
8483 /* ebN = interiorElementBoundaries[ebNI]; */
8484 /* left_eN = elementBoundaryElements[ebN*2+0]; */
8485 /* right_eN = elementBoundaryElements[ebN*2+1]; */
8486 /* left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0]; */
8487 /* right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1]; */
8488 
8489 /* flux = 0.0; */
8490 /* for(k=0;k<nQuadraturePoints_elementBoundary;k++) */
8491 /* { */
8492 /* ds = dS[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+ */
8493 /* left_ebN_element*nQuadraturePoints_elementBoundary+ */
8494 /* k]; */
8495 /* for (I = 0; I < nSpace; I++) */
8496 /* { */
8497 /* flux+= velocity[ebN*nQuadraturePoints_elementBoundary*nSpace+ */
8498 /* k*nSpace+ */
8499 /* I] */
8500 /* * */
8501 /* normal[ebN*nQuadraturePoints_elementBoundary*nSpace+ */
8502 /* k*nSpace+ */
8503 /* I] */
8504 /* * */
8505 /* ds; */
8506 /* } */
8507 /* }/\*k*\/ */
8508 /* conservationResidual[left_eN] += flux; */
8509 /* conservationResidual[right_eN]-= flux; */
8510 
8511 /* }/\*ebNI*\/ */
8512 /* /\*exterior*\/ */
8513 /* for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) */
8514 /* { */
8515 /* ebN = exteriorElementBoundaries[ebNE]; */
8516 /* eN = elementBoundaryElements[ebN*2+0]; */
8517 /* ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0]; */
8518 /* flux = 0.0; */
8519 /* for(k=0;k<nQuadraturePoints_elementBoundary;k++) */
8520 /* { */
8521 /* ds = dS[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+ */
8522 /* ebN_element*nQuadraturePoints_elementBoundary+ */
8523 /* k]; */
8524 /* for (I = 0; I < nSpace; I++) */
8525 /* { */
8526 /* flux+= velocity[ebN*nQuadraturePoints_elementBoundary*nSpace+ */
8527 /* k*nSpace+ */
8528 /* I] */
8529 /* * */
8530 /* normal[ebN*nQuadraturePoints_elementBoundary*nSpace+ */
8531 /* k*nSpace+ */
8532 /* I] */
8533 /* * */
8534 /* ds; */
8535 /* } */
8536 /* }/\*k*\/ */
8537 /* conservationResidual[eN] += flux; */
8538 /* }/\*ebNE*\/ */
8539 /* } */
8540 
8541 
8543  int nInteriorElementBoundaries_global,
8544  int nExteriorElementBoundaries_global,
8545  int nElementBoundaries_global,
8546  int nElementBoundaries_element,
8547  int nQuadraturePoints_elementBoundary,
8548  int nSpace,
8549  int * interiorElementBoundaries,
8550  int * exteriorElementBoundaries,
8551  int * elementBoundaryElementsArray,
8552  int * elementBoundaryLocalElementBoundariesArray,
8553  double * velocityBoundary_global,
8554  double * velocityBoundary_element)
8555 {
8556  int ebN,ebNE,ebNI,eN_left,eN_right,ebN_left_element,ebN_right_element,k,I;
8557 
8558  for (ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
8559  {
8560  ebN = interiorElementBoundaries[ebNI];
8561  eN_left = elementBoundaryElementsArray[ebN*2 + 0];
8562  eN_right= elementBoundaryElementsArray[ebN*2 + 1];
8563  ebN_left_element = elementBoundaryLocalElementBoundariesArray[ebN*2 + 0];
8564  ebN_right_element= elementBoundaryLocalElementBoundariesArray[ebN*2 + 1];
8565 
8566  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
8567  for (I = 0; I < nSpace; I++)
8568  {
8569  velocityBoundary_element[eN_left*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
8570  ebN_left_element*nQuadraturePoints_elementBoundary*nSpace +
8571  k*nSpace +
8572  I] =
8573  velocityBoundary_global[ebN*nQuadraturePoints_elementBoundary*nSpace +
8574  k*nSpace +
8575  I];
8576  velocityBoundary_element[eN_right*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
8577  ebN_right_element*nQuadraturePoints_elementBoundary*nSpace +
8578  k*nSpace +
8579  I] =
8580  velocityBoundary_global[ebN*nQuadraturePoints_elementBoundary*nSpace +
8581  k*nSpace +
8582  I];
8583 
8584  }
8585  }/*ebNI*/
8586 
8587  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
8588  {
8589  ebN = exteriorElementBoundaries[ebNE];
8590  eN_left = elementBoundaryElementsArray[ebN*2 + 0];
8591  ebN_left_element = elementBoundaryLocalElementBoundariesArray[ebN*2 + 0];
8592 
8593  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
8594  for (I = 0; I < nSpace; I++)
8595  {
8596  velocityBoundary_element[eN_left*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
8597  ebN_left_element*nQuadraturePoints_elementBoundary*nSpace +
8598  k*nSpace +
8599  I] =
8600  velocityBoundary_global[ebN*nQuadraturePoints_elementBoundary*nSpace +
8601  k*nSpace +
8602  I];
8603  }
8604  }/*ebNE*/
8605 }
8606 void loadBoundaryFluxIntoGlobalElementBoundaryVelocity(int nExteriorElementBoundaries_global,
8607  int nQuadraturePoints_elementBoundary,
8608  int nSpace,
8609  int* exteriorElementBoundaries,
8610  int* fluxElementBoundaries,
8611  double* normal,
8612  double* flux,
8613  double updateCoef,
8614  double* velocity)
8615 {
8616  int ebNE,ebN,I,k;
8617  double val;
8618  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
8619  {
8620  ebN = exteriorElementBoundaries[ebNE];
8621  if (fluxElementBoundaries[ebNE] > 0)
8622  {
8623  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
8624  {
8625  for (I=0; I < nSpace; I++)
8626  {
8627  val = velocity[ebN*nQuadraturePoints_elementBoundary*nSpace +
8628  k*nSpace + I];
8629  velocity[ebN*nQuadraturePoints_elementBoundary*nSpace +
8630  k*nSpace + I]
8631  = val*updateCoef +
8632  flux[ebN*nQuadraturePoints_elementBoundary +
8633  k]
8634  *
8635  normal[ebN*nQuadraturePoints_elementBoundary*nSpace +
8636  k*nSpace + I];
8637  /*mwf debug
8638  printf("load fluxes ebNE=%d ebN=%d k=%d I=%d val=%g flux=%g n=%g vel=%g\n",
8639  ebNE,ebN,k,I,val,
8640  flux[ebN*nQuadraturePoints_elementBoundary+k],
8641  normal[ebN*nQuadraturePoints_elementBoundary*nSpace + k*nSpace + I],
8642  velocity[ebN*nQuadraturePoints_elementBoundary*nSpace +
8643  k*nSpace + I]);
8644  */
8645  }
8646  }
8647  }
8648  }
8649 
8650 }
8651 
8652 #define TR_ALPHA 0.5
8653 #define TR_ALPHA_EXT 1.0
8654 
8658 void calculateInteriorNumericalTrace_Potential(int nInteriorElementBoundaries_global,
8659  int nElementBoundaries_element,
8660  int nQuadraturePoints_elementBoundary,
8661  int* interiorElementBoundaries,
8662  int* elementBoundaryElements,
8663  int* elementBoundaryLocalElementBoundaries,
8664  double* phi,
8665  double* dphi,
8666  double* phi_trace,
8667  double* dphi_trace_left,
8668  double* dphi_trace_right)
8669 {
8670  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,k;
8671  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8672  {
8673  ebN = interiorElementBoundaries[ebNI];
8674  left_eN_global = elementBoundaryElements[ebN*2+0];
8675  right_eN_global = elementBoundaryElements[ebN*2+1];
8676  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8677  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8678  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8679  {
8680  phi_trace[ebN*nQuadraturePoints_elementBoundary+
8681  k]
8682  = (1.0-TR_ALPHA)*phi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8683  left_ebN_element*nQuadraturePoints_elementBoundary+
8684  k]
8685  +
8686  TR_ALPHA*phi[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8687  right_ebN_element*nQuadraturePoints_elementBoundary+
8688  k];
8689  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
8690  k]
8691  = (1.0-TR_ALPHA)*
8692  dphi[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8693  left_ebN_element*nQuadraturePoints_elementBoundary+
8694  k];
8695  dphi_trace_right[ebN*nQuadraturePoints_elementBoundary+
8696  k]
8697  = TR_ALPHA*dphi[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8698  right_ebN_element*nQuadraturePoints_elementBoundary+
8699  k];
8700  }
8701  }
8702 }
8703 
8708  int nExteriorElementBoundaries_global,
8709  int nElementBoundaries_element,
8710  int nQuadraturePoints_elementBoundary,
8711  int* exteriorElementBoundaries,
8712  int* elementBoundaryElements,
8713  int* elementBoundaryLocalElementBoundaries,
8714  double* phi_bc,
8715  double* phi,
8716  double* dphi,
8717  double* phi_trace,
8718  double* dphi_trace_left)
8719 {
8720  int ebNE,ebN,eN_global,ebN_element,k;
8721  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8722  {
8723  ebN = exteriorElementBoundaries[ebNE];
8724  eN_global = elementBoundaryElements[ebN*2+0];
8725  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8726  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8727  {
8728  phi_trace[ebN*nQuadraturePoints_elementBoundary+
8729  k]
8730  = (1.0-TR_ALPHA_EXT)*phi[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8731  ebN_element*nQuadraturePoints_elementBoundary+
8732  k]
8733  +
8734  TR_ALPHA_EXT*phi_bc[ebNE*nQuadraturePoints_elementBoundary+
8735  k];
8736  if(isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k] == 1)
8737  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
8738  k]
8739  = (1.0-TR_ALPHA_EXT)*dphi[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8740  ebN_element*nQuadraturePoints_elementBoundary+
8741  k];
8742  else
8743  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
8744  k]
8745  = dphi[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
8746  ebN_element*nQuadraturePoints_elementBoundary+
8747  k];
8748  }
8749  }
8750 }
8754 void updateInteriorElementBoundary_MixedForm_weak(int nInteriorElementBoundaries_global,
8755  int nElementBoundaries_element,
8756  int nQuadraturePoints_elementBoundary,
8757  int nDOF_test_element,
8758  int nSpace,
8759  int* interiorElementBoundaries,
8760  int* elementBoundaryElements,
8761  int* elementBoundaryLocalElementBoundaries,
8762  double* n,
8763  double* phi_trace,
8764  double* w_dS,
8765  double* b)
8766 {
8767  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,k,I;
8768  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8769  {
8770  ebN = interiorElementBoundaries[ebNI];
8771  left_eN_global = elementBoundaryElements[ebN*2+0];
8772  right_eN_global = elementBoundaryElements[ebN*2+1];
8773  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8774  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8775  for(i=0;i<nDOF_test_element;i++)
8776  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8777  for(I=0;I<nSpace;I++)
8778  {
8779  b[left_eN_global*nDOF_test_element*nSpace+
8780  I*nDOF_test_element+
8781  i]
8782  -=
8783  phi_trace[ebN*nQuadraturePoints_elementBoundary+
8784  k]
8785  *
8786  n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8787  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8788  k*nSpace+
8789  I]
8790  *
8791  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8792  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8793  k*nDOF_test_element+
8794  i];
8795  b[right_eN_global*nDOF_test_element*nSpace+
8796  I*nDOF_test_element+
8797  i]
8798  -=
8799  phi_trace[ebN*nQuadraturePoints_elementBoundary+
8800  k]
8801  *
8802  n[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8803  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8804  k*nSpace+
8805  I]
8806  *
8807  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8808  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8809  k*nDOF_test_element+
8810  i];
8811  }
8812  }
8813 }
8814 
8818 void updateInteriorElementBoundary_MixedForm_weakJacobian(int nInteriorElementBoundaries_global,
8819  int nElementBoundaries_element,
8820  int nQuadraturePoints_elementBoundary,
8821  int nDOF_test_element,
8822  int nSpace,
8823  int* interiorElementBoundaries,
8824  int* elementBoundaryElements,
8825  int* elementBoundaryLocalElementBoundaries,
8826  double* n,
8827  double* dphi_trace_left,
8828  double* dphi_trace_right,
8829  double* v,
8830  double* w_dS,
8831  double* db,
8832  double* db_eb)
8833 {
8834  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,j,k,I,nDOF_test_element2=nDOF_test_element*nDOF_test_element;
8835  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
8836  {
8837  ebN = interiorElementBoundaries[ebNI];
8838  left_eN_global = elementBoundaryElements[ebN*2+0];
8839  right_eN_global = elementBoundaryElements[ebN*2+1];
8840  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8841  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
8842  for(i=0;i<nDOF_test_element;i++)
8843  for(j=0;j<nDOF_test_element;j++)
8844  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8845  for(I=0;I<nSpace;I++)
8846  {
8847  db[left_eN_global*nDOF_test_element2*nSpace+
8848  I*nDOF_test_element2+
8849  i*nDOF_test_element+
8850  j]
8851  -=
8852  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
8853  k]*
8854 
8855  v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8856  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8857  k*nDOF_test_element+
8858  j]
8859  *
8860  n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8861  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8862  k*nSpace+
8863  I]
8864  *
8865  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8866  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8867  k*nDOF_test_element+
8868  i];
8869  db_eb[left_eN_global*nElementBoundaries_element*nDOF_test_element2*nSpace+
8870  left_ebN_element*nDOF_test_element2*nSpace+
8871  I*nDOF_test_element2+
8872  i*nDOF_test_element+
8873  j]
8874  -=
8875  dphi_trace_right[ebN*nQuadraturePoints_elementBoundary+
8876  k]
8877  *
8878  v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8879  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8880  k*nDOF_test_element+
8881  j]
8882  *
8883  n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8884  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8885  k*nSpace+
8886  I]
8887  *
8888  w_dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8889  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8890  k*nDOF_test_element+
8891  i];
8892  db_eb[right_eN_global*nElementBoundaries_element*nDOF_test_element2*nSpace+
8893  right_ebN_element*nDOF_test_element2*nSpace+
8894  I*nDOF_test_element2+
8895  i*nDOF_test_element+
8896  j]
8897  -=
8898  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
8899  k]*
8900 
8901  v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8902  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8903  k*nDOF_test_element+
8904  j]
8905  *
8906  n[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8907  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8908  k*nSpace+
8909  I]
8910  *
8911  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8912  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8913  k*nDOF_test_element+
8914  i];
8915  db[right_eN_global*nDOF_test_element2*nSpace+
8916  I*nDOF_test_element2+
8917  i*nDOF_test_element+
8918  j]
8919  -=
8920  dphi_trace_right[ebN*nQuadraturePoints_elementBoundary+
8921  k]
8922  *
8923  v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8924  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8925  k*nDOF_test_element+
8926  j]
8927  *
8928  n[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8929  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8930  k*nSpace+
8931  I]
8932  *
8933  w_dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8934  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8935  k*nDOF_test_element+
8936  i];
8937  }
8938  }
8939 }
8940 
8944 void updateExteriorElementBoundary_MixedForm_weak(int nExteriorElementBoundaries_global,
8945  int nElementBoundaries_element,
8946  int nQuadraturePoints_elementBoundary,
8947  int nDOF_test_element,
8948  int nSpace,
8949  int* exteriorElementBoundaries,
8950  int* elementBoundaryElements,
8951  int* elementBoundaryLocalElementBoundaries,
8952  double* n,
8953  double* phi_trace,
8954  double* w_dS,
8955  double* b)
8956 {
8957  int ebNE,ebN,eN_global,ebN_element,i,k,I;
8958  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
8959  {
8960  ebN = exteriorElementBoundaries[ebNE];
8961  eN_global = elementBoundaryElements[ebN*2+0];
8962  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
8963  for(i=0;i<nDOF_test_element;i++)
8964  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
8965  for (I=0;I<nSpace;I++)
8966  b[eN_global*nDOF_test_element*nSpace+
8967  I*nDOF_test_element+
8968  i]
8969  -=
8970  phi_trace[ebN*nQuadraturePoints_elementBoundary+
8971  k]
8972  *
8973  n[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
8974  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
8975  k*nSpace+
8976  I]
8977  *
8978  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8979  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
8980  k*nDOF_test_element+
8981  i];
8982  }
8983 }
8984 
8988 void updateExteriorElementBoundary_MixedForm_weakJacobian(int nExteriorElementBoundaries_global,
8989  int nElementBoundaries_element,
8990  int nQuadraturePoints_elementBoundary,
8991  int nDOF_test_element,
8992  int nSpace,
8993  int* exteriorElementBoundaries,
8994  int* elementBoundaryElements,
8995  int* elementBoundaryLocalElementBoundaries,
8996  double* n,
8997  double* dphi_trace_left,
8998  double* v,
8999  double* w_dS,
9000  double* db,
9001  double* db_eb)
9002 {
9003  int ebNE,ebN,eN_global,ebN_element,i,j,k,I,nDOF_test_element2=nDOF_test_element*nDOF_test_element;
9004  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
9005  {
9006  ebN = exteriorElementBoundaries[ebNE];
9007  eN_global = elementBoundaryElements[ebN*2+0];
9008  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
9009  for(i=0;i<nDOF_test_element;i++)
9010  for(j=0;j<nDOF_test_element;j++)
9011  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
9012  for(I=0;I<nSpace;I++)
9013  {
9014  db[eN_global*nDOF_test_element2*nSpace+
9015  I*nDOF_test_element2+
9016  i*nDOF_test_element+
9017  j]
9018  -=
9019  dphi_trace_left[ebN*nQuadraturePoints_elementBoundary+
9020  k]
9021  *
9022  v[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
9023  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
9024  k*nDOF_test_element+
9025  j]
9026  *
9027  n[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
9028  ebN_element*nQuadraturePoints_elementBoundary*nSpace+
9029  k*nSpace+
9030  I]
9031  *
9032  w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
9033  ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
9034  k*nDOF_test_element+
9035  i];
9036  }
9037  }
9038 }
9039 
9040 void updatePotential_MixedForm_weak(int nElements_global,
9041  int nQuadraturePoints_element,
9042  int nDOF_test_element,
9043  int nSpace,
9044  double* phi,
9045  double* grad_w_dV,
9046  double* b)
9047 {
9048  int eN,i,k,I;
9049  for(eN=0;eN<nElements_global;eN++)
9050  for (I=0;I<nSpace;I++)
9051  for (i=0;i<nDOF_test_element;i++)
9052  for (k=0;k<nQuadraturePoints_element;k++)
9053  b[eN*nDOF_test_element*nSpace +
9054  I*nDOF_test_element+
9055  i]
9056  +=
9057  phi[eN*nQuadraturePoints_element+
9058  k]
9059  *
9060  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
9061  k*nDOF_test_element*nSpace +
9062  i*nSpace +
9063  I];
9064 }
9065 
9066 void updatePotential_MixedForm_weak_gwvd(int nElements_global,
9067  int nQuadraturePoints_element,
9068  int nDOF_test_element,
9069  int nSpace,
9070  double epsilon,
9071  double* phi,
9072  double* w_dV,
9073  double* grad_w_dV,
9074  double* b,
9075  double* mf)
9076 {
9077  int eN,i,k,I;
9078  for(eN=0;eN<nElements_global;eN++)
9079  for (I=0;I<nSpace;I++)
9080  for (i=0;i<nDOF_test_element;i++)
9081  for (k=0;k<nQuadraturePoints_element;k++)
9082  {
9083  b[eN*nDOF_test_element*nSpace +
9084  I*nDOF_test_element+i]
9085  +=
9086  phi[eN*nQuadraturePoints_element+
9087  k]
9088  *
9089  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
9090  k*nDOF_test_element*nSpace +
9091  i*nSpace +
9092  I];
9093  if (I==nSpace-1)
9094  {
9095  b[eN*nDOF_test_element*nSpace +
9096  I*nDOF_test_element+i]
9097  -= epsilon*mf[eN*nQuadraturePoints_element+
9098  k ]*w_dV[eN*nQuadraturePoints_element*nDOF_test_element+ k*nDOF_test_element + i ];
9099  }
9100  }
9101 }
9102 
9103 void updatePotential_MixedForm_weakJacobian(int nElements_global,
9104  int nQuadraturePoints_element,
9105  int nDOF_test_element,
9106  int nSpace,
9107  double* dphi,
9108  double* v,
9109  double* grad_w_dV,
9110  double* db)
9111 {
9112  int eN,i,j,k,I,nDOF_test_element2=nDOF_test_element*nDOF_test_element;
9113  for(eN=0;eN<nElements_global;eN++)
9114  for (I=0;I<nSpace;I++)
9115  for (i=0;i<nDOF_test_element;i++)
9116  for (j=0;j<nDOF_test_element;j++)
9117  for (k=0;k<nQuadraturePoints_element;k++)
9118  db[eN*nDOF_test_element2*nSpace +
9119  I*nDOF_test_element2+
9120  i*nDOF_test_element+
9121  j]
9122  +=
9123  dphi[eN*nQuadraturePoints_element+
9124  k]
9125  *
9126  v[eN*nQuadraturePoints_element*nDOF_test_element+
9127  k*nDOF_test_element+
9128  j]
9129  *
9130  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
9131  k*nDOF_test_element*nSpace +
9132  i*nSpace +
9133  I];
9134 }
9135 
9136 void calculateVelocityQuadrature_MixedForm(int nElements_global,
9137  int nElementBoundaries_element,
9138  int nElementBoundaryQuadraturePoints_elementBoundary,
9139  int nDOF_element,
9140  int nSpace,
9141  int nQuadraturePoints_element,
9142  double* A_inv,
9143  double* b,
9144  double* v,
9145  double* V,
9146  double* qv,
9147  double* qV)
9148 {
9149  int eN,ebN,k,i,j,I,nDOF_element2=nDOF_element*nDOF_element;
9150  double V_dof[nSpace][nDOF_element];
9151  memset(V,0,sizeof(double)*
9152  nElements_global*
9153  nElementBoundaries_element*
9154  nElementBoundaryQuadraturePoints_elementBoundary*
9155  nSpace);
9156  memset(qV,0,sizeof(double)*
9157  nElements_global*
9158  nQuadraturePoints_element*
9159  nSpace);
9160  for(eN=0;eN<nElements_global;eN++)
9161  {
9162  /* velocity DOF */
9163  for(I=0;I<nSpace;I++)
9164  for(i=0;i<nDOF_element;i++)
9165  {
9166  V_dof[I][i]=0.0;
9167  for(j=0;j<nDOF_element;j++)
9168  V_dof[I][i]
9169  +=
9170  A_inv[eN*nDOF_element2+
9171  i*nDOF_element+
9172  j]
9173  *
9174  b[eN*nSpace*nDOF_element+
9175  I*nDOF_element+
9176  j];
9177  }
9178  /* evaluate at element quadrature */
9179  for(k=0;k<nQuadraturePoints_element;k++)
9180  for(j=0;j<nDOF_element;j++)
9181  for(I=0;I<nSpace;I++)
9182  qV[eN*nQuadraturePoints_element*nSpace+
9183  k*nSpace+
9184  I]
9185  +=
9186  V_dof[I][j]
9187  *
9188  qv[eN*nQuadraturePoints_element*nDOF_element+
9189  k*nDOF_element+
9190  j];
9191  /* evaluate at element boundary quadrature*/
9192  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9193  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9194  for(j=0;j<nDOF_element;j++)
9195  for(I=0;I<nSpace;I++)
9196  V[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9197  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9198  k*nSpace+
9199  I]
9200  +=
9201  V_dof[I][j]
9202  *
9203  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9204  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9205  k*nDOF_element+
9206  j];
9207  }
9208 }
9209 
9210 void calculateVelocityQuadrature_MixedForm2(int nElements_global,
9211  int nElementBoundaries_element,
9212  int nElementBoundaryQuadraturePoints_elementBoundary,
9213  int nDOF_element,
9214  int nSpace,
9215  int nQuadraturePoints_element,
9216  double* qa,
9217  double* qw_dV,
9218  double* b,
9219  double* v,
9220  double* V,
9221  double* qv,
9222  double* qV)
9223 {
9224  int eN,ebN,k,i,j,I,nDOF_element2=nDOF_element*nDOF_element,nSpace2=nSpace*nSpace;
9225  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
9226  double work[nDOF_element],A_inv[nDOF_element2];
9227  double V_dof[nSpace][nDOF_element];
9228  memset(V,0,sizeof(double)*
9229  nElements_global*
9230  nElementBoundaries_element*
9231  nElementBoundaryQuadraturePoints_elementBoundary*
9232  nSpace);
9233  memset(qV,0,sizeof(double)*
9234  nElements_global*
9235  nQuadraturePoints_element*
9236  nSpace);
9237  for(eN=0;eN<nElements_global;eN++)
9238  {
9239  for(I=0;I<nSpace;I++)
9240  {
9241  memset(A_inv,0,sizeof(double)*nDOF_element2);
9242  for(i=0;i<nDOF_element;i++)
9243  for(j=0;j<nDOF_element;j++)
9244  {
9245  for(k=0;k<nQuadraturePoints_element;k++)
9246  {
9247  //cek hack do diagonal only for now
9248  A_inv[i*nDOF_element+j] += (1.0/qa[eN*nQuadraturePoints_element*nSpace2+
9249  k*nSpace2+
9250  I*nSpace+
9251  I])
9252  *qv[eN*nQuadraturePoints_element*nDOF_element+
9253  k*nDOF_element+
9254  j]
9255  *
9256  qw_dV[eN*nQuadraturePoints_element*nDOF_element+
9257  k*nDOF_element+
9258  i];
9259  }
9260  }
9261  info=0;
9262  dgetrf_(&dim,&dim,A_inv,&dim,ipiv,&info);
9263  dgetri_(&dim,A_inv,&dim,ipiv,work,&lwork,&info);
9264 
9265  /* velocity DOF */
9266  for(i=0;i<nDOF_element;i++)
9267  {
9268  V_dof[I][i]=0.0;
9269  for(j=0;j<nDOF_element;j++)
9270  V_dof[I][i]
9271  +=
9272  A_inv[i*nDOF_element+
9273  j]
9274  *
9275  b[eN*nSpace*nDOF_element+
9276  I*nDOF_element+
9277  j];
9278  }
9279  }
9280  /* evaluate at element quadrature */
9281  for(k=0;k<nQuadraturePoints_element;k++)
9282  for(j=0;j<nDOF_element;j++)
9283  for(I=0;I<nSpace;I++)
9284  qV[eN*nQuadraturePoints_element*nSpace+
9285  k*nSpace+
9286  I]
9287  +=
9288  V_dof[I][j]
9289  *
9290  qv[eN*nQuadraturePoints_element*nDOF_element+
9291  k*nDOF_element+
9292  j];
9293  /* evaluate at element boundary quadrature*/
9294  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9295  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9296  for(j=0;j<nDOF_element;j++)
9297  for(I=0;I<nSpace;I++)
9298  V[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9299  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9300  k*nSpace+
9301  I]
9302  +=
9303  V_dof[I][j]
9304  *
9305  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9306  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9307  k*nDOF_element+
9308  j];
9309  }
9310 }
9311 
9313  int nElementBoundaries_element,
9314  int nElementBoundaryQuadraturePoints_elementBoundary,
9315  int nDOF_element,
9316  int nSpace,
9317  int nQuadraturePoints_element,
9318  const int * rowptr,
9319  const int * colind,
9320  double* qa,
9321  double* qw_dV,
9322  double* b,
9323  double* v,
9324  double* V,
9325  double* qv,
9326  double* qV)
9327 {
9328  int eN,ebN,k,i,j,I,nDOF_element2=nDOF_element*nDOF_element,nSpace2=nSpace*nSpace;
9329  int m,nnz=rowptr[nSpace];
9330  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
9331  double work[nDOF_element],A_inv[nDOF_element2];
9332  double V_dof[nSpace][nDOF_element];
9333  memset(V,0,sizeof(double)*
9334  nElements_global*
9335  nElementBoundaries_element*
9336  nElementBoundaryQuadraturePoints_elementBoundary*
9337  nSpace);
9338  memset(qV,0,sizeof(double)*
9339  nElements_global*
9340  nQuadraturePoints_element*
9341  nSpace);
9342  for(eN=0;eN<nElements_global;eN++)
9343  {
9344  for(I=0;I<nSpace;I++)
9345  {
9346  memset(A_inv,0,sizeof(double)*nDOF_element2);
9347  for(i=0;i<nDOF_element;i++)
9348  for(j=0;j<nDOF_element;j++)
9349  {
9350  for(k=0;k<nQuadraturePoints_element;k++)
9351  {
9352  //cek hack do diagonal only for now
9353  for (m=rowptr[I]; m < rowptr[I+1];m++)
9354  if (colind[m] == I)
9355  {
9356  /*mwf debug
9357  printf("mixedform2 eN=%d I=%d m=%d colind[m]=%d a=%g \n",
9358  eN,I,m,colind[m],qa[eN*nQuadraturePoints_element*nnz+
9359  k*nnz + m]);
9360  */
9361  A_inv[i*nDOF_element+j] += (1.0/qa[eN*nQuadraturePoints_element*nnz+
9362  k*nnz + m])
9363  *qv[eN*nQuadraturePoints_element*nDOF_element+
9364  k*nDOF_element+
9365  j]
9366  *
9367  qw_dV[eN*nQuadraturePoints_element*nDOF_element+
9368  k*nDOF_element+
9369  i];
9370  }
9371  }
9372  }
9373  info=0;
9374  dgetrf_(&dim,&dim,A_inv,&dim,ipiv,&info);
9375  dgetri_(&dim,A_inv,&dim,ipiv,work,&lwork,&info);
9376 
9377  /* velocity DOF */
9378  for(i=0;i<nDOF_element;i++)
9379  {
9380  V_dof[I][i]=0.0;
9381  for(j=0;j<nDOF_element;j++)
9382  V_dof[I][i]
9383  +=
9384  A_inv[i*nDOF_element+
9385  j]
9386  *
9387  b[eN*nSpace*nDOF_element+
9388  I*nDOF_element+
9389  j];
9390  }
9391  }
9392  /* evaluate at element quadrature */
9393  for(k=0;k<nQuadraturePoints_element;k++)
9394  for(j=0;j<nDOF_element;j++)
9395  for(I=0;I<nSpace;I++)
9396  qV[eN*nQuadraturePoints_element*nSpace+
9397  k*nSpace+
9398  I]
9399  +=
9400  V_dof[I][j]
9401  *
9402  qv[eN*nQuadraturePoints_element*nDOF_element+
9403  k*nDOF_element+
9404  j];
9405  /* evaluate at element boundary quadrature*/
9406  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9407  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9408  for(j=0;j<nDOF_element;j++)
9409  for(I=0;I<nSpace;I++)
9410  V[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9411  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9412  k*nSpace+
9413  I]
9414  +=
9415  V_dof[I][j]
9416  *
9417  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9418  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9419  k*nDOF_element+
9420  j];
9421  }
9422 }
9423 
9424 /* Velocity Quadrature_MixedForm2 function that saves the velocity degrees of freedom, tjp added*/
9425 
9427  int nElementBoundaries_element,
9428  int nElementBoundaryQuadraturePoints_elementBoundary,
9429  int nDOF_element,
9430  int nSpace,
9431  int nQuadraturePoints_element,
9432  const int * rowptr,
9433  const int * colind,
9434  double* qa,
9435  double* qw_dV,
9436  double* b,
9437  double* v,
9438  double* V,
9439  double* qv,
9440  double* qV,
9441  double* vel_dofs)
9442 {
9443  int eN,ebN,k,i,j,I,nDOF_element2=nDOF_element*nDOF_element,nSpace2=nSpace*nSpace;
9444  int m,nnz=rowptr[nSpace];
9445  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
9446  double work[nDOF_element],A_inv[nDOF_element2];
9447  double V_dof[nSpace][nDOF_element];
9448  double vel_dofs_temp[nElements_global][nSpace][nDOF_element];
9449  memset(V,0,sizeof(double)*
9450  nElements_global*
9451  nElementBoundaries_element*
9452  nElementBoundaryQuadraturePoints_elementBoundary*
9453  nSpace);
9454  memset(qV,0,sizeof(double)*
9455  nElements_global*
9456  nQuadraturePoints_element*
9457  nSpace);
9458  for(eN=0;eN<nElements_global;eN++)
9459  {
9460  for(I=0;I<nSpace;I++)
9461  {
9462  memset(A_inv,0,sizeof(double)*nDOF_element2);
9463  for(i=0;i<nDOF_element;i++)
9464  for(j=0;j<nDOF_element;j++)
9465  {
9466  for(k=0;k<nQuadraturePoints_element;k++)
9467  {
9468  //cek hack do diagonal only for now
9469  for (m=rowptr[I]; m < rowptr[I+1];m++)
9470  if (colind[m] == I)
9471  {
9472  /*mwf debug
9473  printf("mixedform2 eN=%d I=%d m=%d colind[m]=%d a=%g \n",
9474  eN,I,m,colind[m],qa[eN*nQuadraturePoints_element*nnz+
9475  k*nnz + m]);
9476  */
9477  A_inv[i*nDOF_element+j] += (1.0/qa[eN*nQuadraturePoints_element*nnz+
9478  k*nnz + m])
9479  *qv[eN*nQuadraturePoints_element*nDOF_element+
9480  k*nDOF_element+
9481  j]
9482  *
9483  qw_dV[eN*nQuadraturePoints_element*nDOF_element+
9484  k*nDOF_element+
9485  i];
9486  }
9487  }
9488  }
9489  info=0;
9490  dgetrf_(&dim,&dim,A_inv,&dim,ipiv,&info);
9491  dgetri_(&dim,A_inv,&dim,ipiv,work,&lwork,&info);
9492 
9493  /* velocity DOF */
9494  for(i=0;i<nDOF_element;i++)
9495  {
9496  V_dof[I][i]=0.0;
9497  vel_dofs_temp[eN][I][i]=0.0;
9498  for(j=0;j<nDOF_element;j++)
9499  {
9500  V_dof[I][i]
9501  +=
9502  A_inv[i*nDOF_element+
9503  j]
9504  *
9505  b[eN*nSpace*nDOF_element+
9506  I*nDOF_element+
9507  j];
9508  vel_dofs_temp[eN][I][i]
9509  += A_inv[i*nDOF_element+
9510  j]
9511  *
9512  b[eN*nSpace*nDOF_element+
9513  I*nDOF_element+
9514  j];
9515  }
9516  }
9517  }
9518 
9519  /* Change the shape of the velocity degrees of freedom */
9520  for(j=0;j<nDOF_element;j++)
9521  for(I=0;I<nSpace;I++)
9522  vel_dofs[eN*nDOF_element*nSpace+
9523  j*nSpace+
9524  I]
9525  =vel_dofs_temp[eN][I][j];
9526 
9527  /* evaluate at element quadrature */
9528  for(k=0;k<nQuadraturePoints_element;k++)
9529  for(j=0;j<nDOF_element;j++)
9530  for(I=0;I<nSpace;I++)
9531  qV[eN*nQuadraturePoints_element*nSpace+
9532  k*nSpace+
9533  I]
9534  +=
9535  V_dof[I][j]
9536  *
9537  qv[eN*nQuadraturePoints_element*nDOF_element+
9538  k*nDOF_element+
9539  j];
9540 
9541 
9542  /* evaluate at element boundary quadrature*/
9543  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9544  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9545  for(j=0;j<nDOF_element;j++)
9546  for(I=0;I<nSpace;I++)
9547  V[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9548  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nSpace+
9549  k*nSpace+
9550  I]
9551  +=
9552  V_dof[I][j]
9553  *
9554  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9555  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9556  k*nDOF_element+
9557  j];
9558  }
9559 }
9560 
9561 
9563  int nElementBoundaries_element,
9564  int nElementBoundaryQuadraturePoints_elementBoundary,
9565  int nDOF_element,
9566  int nSpace,
9567  int nQuadraturePoints_element,
9568  double* A_inv,
9569  double* db,
9570  double* db_eb,
9571  double* v,
9572  double* DV,
9573  double* DV_eb,
9574  double* qv,
9575  double* qDV,
9576  double* qDV_eb)
9577 {
9578  int eN,ebN,ebN_ebN,k,i,j,jj,I,nDOF_element2=nDOF_element*nDOF_element;
9579  double DV_dof[nSpace][nDOF_element][nDOF_element];
9580  memset(DV,0,sizeof(double)*
9581  nElements_global*
9582  nElementBoundaries_element*
9583  nElementBoundaryQuadraturePoints_elementBoundary*
9584  nDOF_element*
9585  nSpace);
9586  memset(DV_eb,0,sizeof(double)*
9587  nElements_global*
9588  nElementBoundaries_element*
9589  nElementBoundaries_element*
9590  nElementBoundaryQuadraturePoints_elementBoundary*
9591  nDOF_element*
9592  nSpace);
9593  memset(qDV,0,sizeof(double)*
9594  nElements_global*
9595  nQuadraturePoints_element*
9596  nDOF_element*
9597  nSpace);
9598  memset(qDV_eb,0,sizeof(double)*
9599  nElements_global*
9600  nElementBoundaries_element*
9601  nQuadraturePoints_element*
9602  nDOF_element*
9603  nSpace);
9604  for(eN=0;eN<nElements_global;eN++)
9605  {
9606  /* get derivatives of velocity DOF w.r.t. u DOF*/
9607  for(I=0;I<nSpace;I++)
9608  for(jj=0;jj<nDOF_element;jj++)
9609  for(i=0;i<nDOF_element;i++)
9610  {
9611  DV_dof[I][i][jj]=0.0;
9612  for(j=0;j<nDOF_element;j++)
9613  DV_dof[I][i][jj]
9614  +=
9615  A_inv[eN*nDOF_element2+
9616  i*nDOF_element+
9617  j]
9618  *
9619  db[eN*nSpace*nDOF_element2+
9620  I*nDOF_element2+
9621  j*nDOF_element+
9622  jj];
9623  }
9624  /* get derivatives of velocity at element quadrature w.r.t u DOF on element*/
9625  for(k=0;k<nQuadraturePoints_element;k++)
9626  for(j=0;j<nDOF_element;j++)
9627  for(jj=0;jj<nDOF_element;jj++)
9628  for(I=0;I<nSpace;I++)
9629  qDV[eN*nQuadraturePoints_element*nDOF_element*nSpace+
9630  k*nDOF_element*nSpace+
9631  jj*nSpace+
9632  I]
9633  +=
9634  DV_dof[I][j][jj]
9635  *
9636  qv[eN*nQuadraturePoints_element*nDOF_element+
9637  k*nDOF_element+
9638  j];
9639  /* get derivatives of velocity at element boundary quadrature w.r.t. u DOF on element */
9640  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9641  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9642  for(j=0;j<nDOF_element;j++)
9643  for(jj=0;jj<nDOF_element;jj++)
9644  for(I=0;I<nSpace;I++)
9645  DV[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9646  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9647  k*nDOF_element*nSpace+
9648  jj*nSpace+
9649  I]
9650  +=
9651  DV_dof[I][j][jj]
9652  *
9653  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9654  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9655  k*nDOF_element+
9656  j];
9657  /* get derivatives at element neighbors */
9658  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9659  {
9660  /* DOF calculations */
9661  for(I=0;I<nSpace;I++)
9662  for(jj=0;jj<nDOF_element;jj++)
9663  for(i=0;i<nDOF_element;i++)
9664  {
9665  DV_dof[I][i][jj] = 0.0;
9666  for(j=0;j<nDOF_element;j++)
9667  DV_dof[I][i][jj]
9668  +=
9669  A_inv[eN*nDOF_element2+
9670  i*nDOF_element+
9671  j]
9672  *
9673  db_eb[eN*nElementBoundaries_element*nSpace*nDOF_element2+
9674  ebN*nSpace*nDOF_element2+
9675  I*nDOF_element2+
9676  j*nDOF_element+
9677  jj];
9678  }
9679  /* quadrature calculations */
9680  for(k=0;k<nQuadraturePoints_element;k++)
9681  for(j=0;j<nDOF_element;j++)
9682  for(jj=0;jj<nDOF_element;jj++)
9683  for(I=0;I<nSpace;I++)
9684  {
9685  qDV_eb[eN*nElementBoundaries_element*nQuadraturePoints_element*nDOF_element*nSpace+
9686  ebN*nQuadraturePoints_element*nDOF_element*nSpace+
9687  k*nDOF_element*nSpace+
9688  jj*nSpace+
9689  I]
9690  +=
9691  DV_dof[I][j][jj]
9692  *
9693  qv[eN*nQuadraturePoints_element*nDOF_element+
9694  k*nDOF_element+
9695  j];
9696  }
9697  for (ebN_ebN=0;ebN_ebN<nElementBoundaries_element;ebN_ebN++)
9698  {
9699  /* element boundary quadrature calculations */
9700  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9701  for(j=0;j<nDOF_element;j++)
9702  for(jj=0;jj<nDOF_element;jj++)
9703  for(I=0;I<nSpace;I++)
9704  {
9705  DV_eb[eN*nElementBoundaries_element*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9706  ebN_ebN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9707  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9708  k*nDOF_element*nSpace+
9709  jj*nSpace+
9710  I]
9711  +=
9712  DV_dof[I][j][jj]
9713  *
9714  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9715  ebN_ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9716  k*nDOF_element+
9717  j];
9718  }
9719  }
9720  }
9721  }
9722 }
9724  int nElementBoundaries_element,
9725  int nElementBoundaryQuadraturePoints_elementBoundary,
9726  int nDOF_element,
9727  int nSpace,
9728  int nQuadraturePoints_element,
9729  double* qa,
9730  double* qw_dV,
9731  double* db,
9732  double* db_eb,
9733  double* v,
9734  double* DV,
9735  double* DV_eb,
9736  double* qv,
9737  double* qDV,
9738  double* qDV_eb)
9739 {
9740  int eN,ebN,ebN_ebN,k,i,j,jj,I,nDOF_element2=nDOF_element*nDOF_element,nSpace2=nSpace*nSpace;
9741  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
9742  double work[nDOF_element],A_inv[nSpace][nDOF_element2];
9743  double DV_dof[nSpace][nDOF_element][nDOF_element];
9744  memset(DV,0,sizeof(double)*
9745  nElements_global*
9746  nElementBoundaries_element*
9747  nElementBoundaryQuadraturePoints_elementBoundary*
9748  nDOF_element*
9749  nSpace);
9750  memset(DV_eb,0,sizeof(double)*
9751  nElements_global*
9752  nElementBoundaries_element*
9753  nElementBoundaries_element*
9754  nElementBoundaryQuadraturePoints_elementBoundary*
9755  nDOF_element*
9756  nSpace);
9757  memset(qDV,0,sizeof(double)*
9758  nElements_global*
9759  nQuadraturePoints_element*
9760  nDOF_element*
9761  nSpace);
9762  memset(qDV_eb,0,sizeof(double)*
9763  nElements_global*
9764  nElementBoundaries_element*
9765  nQuadraturePoints_element*
9766  nDOF_element*
9767  nSpace);
9768  for(eN=0;eN<nElements_global;eN++)
9769  {
9770  for(I=0;I<nSpace;I++)
9771  {
9772  memset(A_inv[I],0,sizeof(double)*nDOF_element2);
9773  for(i=0;i<nDOF_element;i++)
9774  for(j=0;j<nDOF_element;j++)
9775  {
9776  for(k=0;k<nQuadraturePoints_element;k++)
9777  {
9778  //cek hack do diagonal only for now
9779  A_inv[I][i*nDOF_element+j] += (1.0/qa[eN*nQuadraturePoints_element*nSpace2+
9780  k*nSpace2+
9781  I*nSpace+
9782  I])
9783  *qv[eN*nQuadraturePoints_element*nDOF_element+
9784  k*nDOF_element+
9785  j]
9786  *
9787  qw_dV[eN*nQuadraturePoints_element*nDOF_element+
9788  k*nDOF_element+
9789  i];
9790  }
9791  }
9792  info=0;
9793  dgetrf_(&dim,&dim,&A_inv[I],&dim,ipiv,&info);
9794  dgetri_(&dim,&A_inv[I],&dim,ipiv,work,&lwork,&info);
9795  /* get derivatives of velocity DOF w.r.t. u DOF*/
9796  for(jj=0;jj<nDOF_element;jj++)
9797  for(i=0;i<nDOF_element;i++)
9798  {
9799  DV_dof[I][i][jj]=0.0;
9800  for(j=0;j<nDOF_element;j++)
9801  DV_dof[I][i][jj]
9802  +=
9803  A_inv[I][i*nDOF_element+
9804  j]
9805  *
9806  db[eN*nSpace*nDOF_element2+
9807  I*nDOF_element2+
9808  j*nDOF_element+
9809  jj];
9810  }
9811  }
9812  /* get derivatives of velocity at element quadrature w.r.t u DOF on element*/
9813  for(k=0;k<nQuadraturePoints_element;k++)
9814  for(j=0;j<nDOF_element;j++)
9815  for(jj=0;jj<nDOF_element;jj++)
9816  for(I=0;I<nSpace;I++)
9817  qDV[eN*nQuadraturePoints_element*nDOF_element*nSpace+
9818  k*nDOF_element*nSpace+
9819  jj*nSpace+
9820  I]
9821  +=
9822  DV_dof[I][j][jj]
9823  *
9824  qv[eN*nQuadraturePoints_element*nDOF_element+
9825  k*nDOF_element+
9826  j];
9827  /* get derivatives of velocity at element boundary quadrature w.r.t. u DOF on element */
9828  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9829  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9830  for(j=0;j<nDOF_element;j++)
9831  for(jj=0;jj<nDOF_element;jj++)
9832  for(I=0;I<nSpace;I++)
9833  DV[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9834  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9835  k*nDOF_element*nSpace+
9836  jj*nSpace+
9837  I]
9838  +=
9839  DV_dof[I][j][jj]
9840  *
9841  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9842  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9843  k*nDOF_element+
9844  j];
9845  /* get derivatives at element neighbors */
9846  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
9847  {
9848  /* DOF calculations */
9849  for(I=0;I<nSpace;I++)
9850  for(jj=0;jj<nDOF_element;jj++)
9851  for(i=0;i<nDOF_element;i++)
9852  {
9853  DV_dof[I][i][jj] = 0.0;
9854  for(j=0;j<nDOF_element;j++)
9855  DV_dof[I][i][jj]
9856  +=
9857  A_inv[I][i*nDOF_element+
9858  j]
9859  *
9860  db_eb[eN*nElementBoundaries_element*nSpace*nDOF_element2+
9861  ebN*nSpace*nDOF_element2+
9862  I*nDOF_element2+
9863  j*nDOF_element+
9864  jj];
9865  }
9866  /* quadrature calculations */
9867  for(k=0;k<nQuadraturePoints_element;k++)
9868  for(j=0;j<nDOF_element;j++)
9869  for(jj=0;jj<nDOF_element;jj++)
9870  for(I=0;I<nSpace;I++)
9871  {
9872  qDV_eb[eN*nElementBoundaries_element*nQuadraturePoints_element*nDOF_element*nSpace+
9873  ebN*nQuadraturePoints_element*nDOF_element*nSpace+
9874  k*nDOF_element*nSpace+
9875  jj*nSpace+
9876  I]
9877  +=
9878  DV_dof[I][j][jj]
9879  *
9880  qv[eN*nQuadraturePoints_element*nDOF_element+
9881  k*nDOF_element+
9882  j];
9883  }
9884  for (ebN_ebN=0;ebN_ebN<nElementBoundaries_element;ebN_ebN++)
9885  {
9886  /* element boundary quadrature calculations */
9887  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
9888  for(j=0;j<nDOF_element;j++)
9889  for(jj=0;jj<nDOF_element;jj++)
9890  for(I=0;I<nSpace;I++)
9891  {
9892  DV_eb[eN*nElementBoundaries_element*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9893  ebN_ebN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9894  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
9895  k*nDOF_element*nSpace+
9896  jj*nSpace+
9897  I]
9898  +=
9899  DV_dof[I][j][jj]
9900  *
9901  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9902  ebN_ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
9903  k*nDOF_element+
9904  j];
9905  }
9906  }
9907  }
9908  }
9909 }
9910 
9912  int nElementBoundaries_element,
9913  int nElementBoundaryQuadraturePoints_elementBoundary,
9914  int nDOF_element,
9915  int nSpace,
9916  int nQuadraturePoints_element,
9917  const int *rowptr,
9918  const int *colind,
9919  double* qa,
9920  double* qw_dV,
9921  double* db,
9922  double* db_eb,
9923  double* v,
9924  double* DV,
9925  double* DV_eb,
9926  double* qv,
9927  double* qDV,
9928  double* qDV_eb)
9929 {
9930  int eN,ebN,ebN_ebN,k,i,j,jj,I,nDOF_element2=nDOF_element*nDOF_element,nSpace2=nSpace*nSpace;
9931  int m,nnz=rowptr[nSpace];
9932  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
9933  double work[nDOF_element],A_inv[nSpace][nDOF_element2];
9934  double DV_dof[nSpace][nDOF_element][nDOF_element];
9935  memset(DV,0,sizeof(double)*
9936  nElements_global*
9937  nElementBoundaries_element*
9938  nElementBoundaryQuadraturePoints_elementBoundary*
9939  nDOF_element*
9940  nSpace);
9941  memset(DV_eb,0,sizeof(double)*
9942  nElements_global*
9943  nElementBoundaries_element*
9944  nElementBoundaries_element*
9945  nElementBoundaryQuadraturePoints_elementBoundary*
9946  nDOF_element*
9947  nSpace);
9948  memset(qDV,0,sizeof(double)*
9949  nElements_global*
9950  nQuadraturePoints_element*
9951  nDOF_element*
9952  nSpace);
9953  memset(qDV_eb,0,sizeof(double)*
9954  nElements_global*
9955  nElementBoundaries_element*
9956  nQuadraturePoints_element*
9957  nDOF_element*
9958  nSpace);
9959  for(eN=0;eN<nElements_global;eN++)
9960  {
9961  for(I=0;I<nSpace;I++)
9962  {
9963  memset(A_inv[I],0,sizeof(double)*nDOF_element2);
9964  for(i=0;i<nDOF_element;i++)
9965  for(j=0;j<nDOF_element;j++)
9966  {
9967  for(k=0;k<nQuadraturePoints_element;k++)
9968  {
9969  //cek hack do diagonal only for now
9970  for (m=rowptr[I]; m < rowptr[I+1]; m++)
9971  if (colind[m] == I)
9972  {
9973  A_inv[I][i*nDOF_element+j] += (1.0/qa[eN*nQuadraturePoints_element*nnz+
9974  k*nnz+m])
9975  *qv[eN*nQuadraturePoints_element*nDOF_element+
9976  k*nDOF_element+
9977  j]
9978  *
9979  qw_dV[eN*nQuadraturePoints_element*nDOF_element+
9980  k*nDOF_element+
9981  i];
9982  }
9983  }
9984  }
9985  info=0;
9986  dgetrf_(&dim,&dim,A_inv[I],&dim,ipiv,&info);
9987  dgetri_(&dim,A_inv[I],&dim,ipiv,work,&lwork,&info);
9988  /* get derivatives of velocity DOF w.r.t. u DOF*/
9989  for(jj=0;jj<nDOF_element;jj++)
9990  {
9991  for(i=0;i<nDOF_element;i++)
9992  {
9993  DV_dof[I][i][jj]=0.0;
9994  for(j=0;j<nDOF_element;j++)
9995  DV_dof[I][i][jj]
9996  +=
9997  A_inv[I][i*nDOF_element+
9998  j]
9999  *
10000  db[eN*nSpace*nDOF_element2+
10001  I*nDOF_element2+
10002  j*nDOF_element+
10003  jj];
10004  }
10005  }
10006  }
10007  for(k=0;k<nQuadraturePoints_element;k++)
10008  for(j=0;j<nDOF_element;j++)
10009  for(jj=0;jj<nDOF_element;jj++)
10010  for(I=0;I<nSpace;I++)
10011  qDV[eN*nQuadraturePoints_element*nDOF_element*nSpace+
10012  k*nDOF_element*nSpace+
10013  jj*nSpace+
10014  I]
10015  +=
10016  DV_dof[I][j][jj]
10017  *
10018  qv[eN*nQuadraturePoints_element*nDOF_element+
10019  k*nDOF_element+
10020  j];
10021  /* get derivatives of velocity at element boundary quadrature w.r.t. u DOF on element */
10022  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
10023  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
10024  for(j=0;j<nDOF_element;j++)
10025  for(jj=0;jj<nDOF_element;jj++)
10026  for(I=0;I<nSpace;I++)
10027  DV[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
10028  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
10029  k*nDOF_element*nSpace+
10030  jj*nSpace+
10031  I]
10032  +=
10033  DV_dof[I][j][jj]
10034  *
10035  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
10036  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
10037  k*nDOF_element+
10038  j];
10039  /* get derivatives at element neighbors */
10040  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
10041  {
10042  /* DOF calculations */
10043  for(I=0;I<nSpace;I++)
10044  for(jj=0;jj<nDOF_element;jj++)
10045  {
10046  for(i=0;i<nDOF_element;i++)
10047  {
10048  DV_dof[I][i][jj] = 0.0;
10049  for(j=0;j<nDOF_element;j++)
10050  DV_dof[I][i][jj]
10051  +=
10052  A_inv[I][i*nDOF_element+
10053  j]
10054  *
10055  db_eb[eN*nElementBoundaries_element*nSpace*nDOF_element2+
10056  ebN*nSpace*nDOF_element2+
10057  I*nDOF_element2+
10058  j*nDOF_element+
10059  jj];
10060  }
10061  }
10062  /* quadrature calculations */
10063  for(k=0;k<nQuadraturePoints_element;k++)
10064  for(j=0;j<nDOF_element;j++)
10065  for(jj=0;jj<nDOF_element;jj++)
10066  for(I=0;I<nSpace;I++)
10067  {
10068  qDV_eb[eN*nElementBoundaries_element*nQuadraturePoints_element*nDOF_element*nSpace+
10069  ebN*nQuadraturePoints_element*nDOF_element*nSpace+
10070  k*nDOF_element*nSpace+
10071  jj*nSpace+
10072  I]
10073  +=
10074  DV_dof[I][j][jj]
10075  *
10076  qv[eN*nQuadraturePoints_element*nDOF_element+
10077  k*nDOF_element+
10078  j];
10079  }
10080  for (ebN_ebN=0;ebN_ebN<nElementBoundaries_element;ebN_ebN++)
10081  {
10082  /* element boundary quadrature calculations */
10083  for(k=0;k<nElementBoundaryQuadraturePoints_elementBoundary;k++)
10084  for(j=0;j<nDOF_element;j++)
10085  for(jj=0;jj<nDOF_element;jj++)
10086  for(I=0;I<nSpace;I++)
10087  {
10088  DV_eb[eN*nElementBoundaries_element*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
10089  ebN_ebN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
10090  ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element*nSpace+
10091  k*nDOF_element*nSpace+
10092  jj*nSpace+
10093  I]
10094  +=
10095  DV_dof[I][j][jj]
10096  *
10097  v[eN*nElementBoundaries_element*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
10098  ebN_ebN*nElementBoundaryQuadraturePoints_elementBoundary*nDOF_element+
10099  k*nDOF_element+
10100  j];
10101  }
10102  }
10103  }
10104  }
10105 }
10106 
10107 
10108 
10109 void calculateVelocityProjectionMatrixLDG(int nElements_global,
10110  int nQuadraturePoints_element,
10111  int nDOF_element,
10112  double* vXw_dV,
10113  double* A_inv)
10114 {
10115  int eN,i,j,k,nDOF_element2=nDOF_element*nDOF_element;
10116  PROTEUS_LAPACK_INTEGER ipiv[nDOF_element],lwork=((PROTEUS_LAPACK_INTEGER)nDOF_element),dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0;
10117  double work[nDOF_element];
10118  memset(A_inv,0,sizeof(double)*nElements_global*nDOF_element2);
10119  for(eN=0;eN<nElements_global;eN++)
10120  {
10121  for(i=0;i<nDOF_element;i++)
10122  for(j=0;j<nDOF_element;j++)
10123  {
10124  for(k=0;k<nQuadraturePoints_element;k++)
10125  {
10126  A_inv[eN*nDOF_element2+i*nDOF_element+j] += vXw_dV[eN*nQuadraturePoints_element*nDOF_element2+
10127  k*nDOF_element2+
10128  j*nDOF_element+
10129  i];
10130  }
10131  }
10132  dgetrf_(&dim,&dim,&A_inv[eN*nDOF_element2],&dim,ipiv,&info);
10133  dgetri_(&dim,&A_inv[eN*nDOF_element2],&dim,ipiv,work,&lwork,&info);
10134  }
10135 }
10136 
10137 void updateDiffusion_MixedForm_weak(int nElements_global,
10138  int nQuadraturePoints_element,
10139  int nDOF_test_element,
10140  int nSpace,
10141  double* a,
10142  double* qV,
10143  double* grad_w_dV,
10144  double* weak_residual)
10145 {
10146  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
10147  for(eN=0;eN<nElements_global;eN++)
10148  for (i=0;i<nDOF_test_element;i++)
10149  for (k=0;k<nQuadraturePoints_element;k++)
10150  for (I=0;I<nSpace;I++)
10151  for (J=0;J<nSpace;J++)
10152  weak_residual[eN*nDOF_test_element + i]
10153  -=
10154  a[eN*nQuadraturePoints_element*nSpace2 +
10155  k*nSpace2 +
10156  I*nSpace +
10157  J]
10158  *
10159  qV[eN*nQuadraturePoints_element*nSpace +
10160  k*nSpace +
10161  J]
10162  *
10163  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10164  k*nDOF_test_element*nSpace +
10165  i*nSpace+
10166  I];
10167 }
10168 
10169 void updateDiffusion_MixedForm_weak_sd(int nElements_global,
10170  int nQuadraturePoints_element,
10171  int nDOF_test_element,
10172  int nSpace,
10173  int rho_split,
10174  int* rowptr,
10175  int* colind,
10176  double* a,
10177  double* qV,
10178  double* grad_w_dV,
10179  double* velocity, /* added for ldg coupling */
10180  double* weak_residual)
10181 {
10182  int eN,i,k,I,m,nnz=rowptr[nSpace];
10183  for(eN=0;eN<nElements_global;eN++)
10184  for (i=0;i<nDOF_test_element;i++)
10185  for (k=0;k<nQuadraturePoints_element;k++)
10186  for (I=0;I<nSpace;I++)
10187  for (m=rowptr[I];m<rowptr[I+1];m++)
10188  {
10189  weak_residual[eN*nDOF_test_element + i]
10190  -=
10191  a[eN*nQuadraturePoints_element*nnz+
10192  k*nnz+
10193  m]
10194  *
10195  qV[eN*nQuadraturePoints_element*nSpace +
10196  k*nSpace +
10197  colind[m]]
10198  *
10199  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10200  k*nDOF_test_element*nSpace +
10201  i*nSpace+
10202  I];
10203  }
10204 
10205  for(eN=0;eN<nElements_global;eN++)
10206  for (k=0;k<nQuadraturePoints_element;k++)
10207  for (I=0;I<nSpace;I++)
10208  if (rho_split==0)
10209  {
10210  for (m=rowptr[I];m<rowptr[I+1];m++)
10211  {
10212  velocity[eN*nQuadraturePoints_element*nSpace +
10213  k*nSpace + I]
10214  += a[eN*nQuadraturePoints_element*nnz+
10215  k*nnz+ m]
10216  *
10217  qV[eN*nQuadraturePoints_element*nSpace +
10218  k*nSpace + colind[m]];
10219  }
10220  }
10221  else if (rho_split==1)
10222  {
10223  velocity[eN*nQuadraturePoints_element*nSpace +
10224  k*nSpace + I]
10225  =
10226  qV[eN*nQuadraturePoints_element*nSpace +
10227  k*nSpace + I];
10228  }
10229 }
10230 
10231 void updateDiffusionJacobian_MixedForm_weak(int nElements_global,
10232  int nElementBoundaries_element,
10233  int nQuadraturePoints_element,
10234  int nDOF_trial_element,
10235  int nDOF_test_element,
10236  int nSpace,
10237  double* a,
10238  double* da,
10239  double* qV,
10240  double* qDV,
10241  double* qDV_eb,
10242  double* grad_w_dV,
10243  double* v,
10244  double* jacobian_weak_residual,
10245  double* jacobian_weak_residual_eb)
10246 {
10247  int eN,ebN,i,j,k,I,J,nSpace2=nSpace*nSpace,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element;
10248  double daProduct,dphiProduct;
10249  for(eN=0;eN<nElements_global;eN++)
10250  {
10251  for (i=0;i<nDOF_test_element;i++)
10252  for (k=0;k<nQuadraturePoints_element;k++)
10253  {
10254  daProduct=0.0;
10255  for (I=0;I<nSpace;I++)
10256  for (J=0;J<nSpace;J++)
10257  daProduct
10258  -=
10259  da[eN*nQuadraturePoints_element*nSpace2 +
10260  k*nSpace2 +
10261  I*nSpace +
10262  J]
10263  *
10264  qV[eN*nQuadraturePoints_element*nSpace +
10265  k*nSpace +
10266  J]
10267  *
10268  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10269  k*nDOF_test_element*nSpace +
10270  i*nSpace+
10271  I];
10272  for (j=0;j<nDOF_trial_element;j++)
10273  {
10274  dphiProduct=0.0;
10275  for (I=0;I<nSpace;I++)
10276  for (J=0;J<nSpace;J++)
10277  dphiProduct
10278  -=
10279  a[eN*nQuadraturePoints_element*nSpace2 +
10280  k*nSpace2+
10281  I*nSpace +
10282  J]
10283  *
10284  qDV[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
10285  k*nDOF_trial_element*nSpace +
10286  j*nSpace+
10287  J]
10288  *
10289  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10290  k*nDOF_test_element*nSpace +
10291  i*nSpace+
10292  I];
10293  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
10294  i*nDOF_trial_element +
10295  j]
10296  +=
10297  daProduct
10298  *
10299  v[eN*nQuadraturePoints_element*nDOF_trial_element+
10300  k*nDOF_trial_element+
10301  j]
10302  +
10303  dphiProduct;
10304  }
10305  }
10306  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
10307  for (i=0;i<nDOF_test_element;i++)
10308  for (k=0;k<nQuadraturePoints_element;k++)
10309  {
10310  for (j=0;j<nDOF_trial_element;j++)
10311  {
10312  dphiProduct=0.0;
10313  for (I=0;I<nSpace;I++)
10314  for (J=0;J<nSpace;J++)
10315  dphiProduct
10316  -=
10317  a[eN*nQuadraturePoints_element*nSpace2 +
10318  k*nSpace2+
10319  I*nSpace +
10320  J]
10321  *
10322  qDV_eb[eN*nElementBoundaries_element*nQuadraturePoints_element*nDOF_trial_element*nSpace +
10323  ebN*nQuadraturePoints_element*nDOF_trial_element*nSpace+
10324  k*nDOF_trial_element*nSpace +
10325  j*nSpace+
10326  J]
10327  *
10328  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10329  k*nDOF_test_element*nSpace +
10330  i*nSpace+
10331  I];
10332  jacobian_weak_residual_eb[eN*nElementBoundaries_element*nDOF_test_X_trial_element +
10333  ebN*nDOF_test_X_trial_element +
10334  i*nDOF_trial_element +
10335  j]
10336  +=
10337  dphiProduct;
10338  }
10339  }
10340  }
10341 }
10342 
10344  int nElementBoundaries_element,
10345  int nQuadraturePoints_element,
10346  int nDOF_trial_element,
10347  int nDOF_test_element,
10348  int nSpace,
10349  int* rowptr,
10350  int* colind,
10351  double* a,
10352  double* da,
10353  double* qV,
10354  double* qDV,
10355  double* qDV_eb,
10356  double* grad_w_dV,
10357  double* v,
10358  double* jacobian_weak_residual,
10359  double* jacobian_weak_residual_eb)
10360 {
10361  int eN,ebN,i,j,k,I,m,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,nnz=rowptr[nSpace];
10362  double daProduct,dphiProduct;
10363  for(eN=0;eN<nElements_global;eN++)
10364  {
10365  for (i=0;i<nDOF_test_element;i++)
10366  for (k=0;k<nQuadraturePoints_element;k++)
10367  {
10368  daProduct=0.0;
10369  for (I=0;I<nSpace;I++)
10370  for (m=rowptr[I];m<rowptr[I+1];m++)
10371  daProduct
10372  -=
10373  da[eN*nQuadraturePoints_element*nnz+
10374  k*nnz+
10375  m]
10376  *
10377  qV[eN*nQuadraturePoints_element*nSpace +
10378  k*nSpace +
10379  colind[m]]
10380  *
10381  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10382  k*nDOF_test_element*nSpace +
10383  i*nSpace+
10384  I];
10385  for (j=0;j<nDOF_trial_element;j++)
10386  {
10387  dphiProduct=0.0;
10388  for (I=0;I<nSpace;I++)
10389  for(m=rowptr[I];m<rowptr[I+1];m++)
10390  dphiProduct
10391  -=
10392  a[eN*nQuadraturePoints_element*nnz+
10393  k*nnz+
10394  m]
10395  *
10396  qDV[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
10397  k*nDOF_trial_element*nSpace +
10398  j*nSpace+
10399  colind[m]]
10400  *
10401  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10402  k*nDOF_test_element*nSpace +
10403  i*nSpace+
10404  I];
10405  jacobian_weak_residual[eN*nDOF_test_X_trial_element +
10406  i*nDOF_trial_element +
10407  j]
10408  +=
10409  daProduct
10410  *
10411  v[eN*nQuadraturePoints_element*nDOF_trial_element+
10412  k*nDOF_trial_element+
10413  j]
10414  +
10415  dphiProduct;
10416  }
10417  }
10418  for (ebN=0;ebN<nElementBoundaries_element;ebN++)
10419  for (i=0;i<nDOF_test_element;i++)
10420  for (k=0;k<nQuadraturePoints_element;k++)
10421  {
10422  for (j=0;j<nDOF_trial_element;j++)
10423  {
10424  dphiProduct=0.0;
10425  for (I=0;I<nSpace;I++)
10426  for(m=rowptr[I];m<rowptr[I+1];m++)
10427  dphiProduct
10428  -=
10429  a[eN*nQuadraturePoints_element*nnz+
10430  k*nnz+
10431  m]
10432  *
10433  qDV_eb[eN*nElementBoundaries_element*nQuadraturePoints_element*nDOF_trial_element*nSpace +
10434  ebN*nQuadraturePoints_element*nDOF_trial_element*nSpace+
10435  k*nDOF_trial_element*nSpace +
10436  j*nSpace+
10437  colind[m]]
10438  *
10439  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
10440  k*nDOF_test_element*nSpace +
10441  i*nSpace+
10442  I];
10443  jacobian_weak_residual_eb[eN*nElementBoundaries_element*nDOF_test_X_trial_element +
10444  ebN*nDOF_test_X_trial_element +
10445  i*nDOF_trial_element +
10446  j]
10447  +=
10448  dphiProduct;
10449  }
10450  }
10451  }
10452 }
10453 
10454 void estimate_mt(int nElements_global,
10455  int nQuadraturePoints_element,
10456  int nDOF_element,
10457  double* v,
10458  double* vXw_dV,
10459  double* elementSpatialResidual,
10460  double* mt)
10461 {
10462  int eN,i,j,k,nDOF_element2=nDOF_element*nDOF_element;
10463  char trans='N';
10464  PROTEUS_LAPACK_INTEGER nrhs=1,dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0,ipiv[nDOF_element];
10465  double massMatrix[nDOF_element2],b[nDOF_element];
10466  /* loop over elements and solve for the local polynomial \pi(mt) such that (\pi(mt),w) = - elementSpatialResidual = b(u,w) -a(u,w) */
10467  /* then evaluate \pi(mt) at the quadrature points to recover the mt estimate */
10468  memset(mt,0,sizeof(double)*nElements_global*nQuadraturePoints_element);
10469  for(eN=0;eN<nElements_global;eN++)
10470  {
10471  memset(massMatrix,0,sizeof(double)*nDOF_element2);
10472  memset(ipiv,0,sizeof(PROTEUS_LAPACK_INTEGER)*nDOF_element);
10473  for(i=0;i<nDOF_element;i++)
10474  for(j=0;j<nDOF_element;j++)
10475  {
10476  for(k=0;k<nQuadraturePoints_element;k++)
10477  {
10478  mt[eN*nQuadraturePoints_element+
10479  k] = 0.0;
10480  massMatrix[i*nDOF_element+j] += vXw_dV[eN*nQuadraturePoints_element*nDOF_element2+
10481  k*nDOF_element2+
10482  j*nDOF_element+
10483  i];
10484  }
10485  b[j] = -elementSpatialResidual[eN*nDOF_element+j];
10486  }
10487  dgetrf_(&dim,&dim,massMatrix,&dim,ipiv,&info);
10488  dgetrs_(&trans,&dim,&nrhs,massMatrix,&dim,ipiv,b,&dim,&info);
10489  for (j=0;j<nDOF_element;j++)
10490  for(k=0;k<nQuadraturePoints_element;k++)
10491  mt[eN*nQuadraturePoints_element+
10492  k] += b[j]*v[eN*nQuadraturePoints_element*nDOF_element+
10493  k*nDOF_element+
10494  j];
10495  }
10496 }
10497 void estimate_mt_lowmem(int nElements_global,
10498  int nQuadraturePoints_element,
10499  int nDOF_element,
10500  double* v,
10501  double* w_dV,
10502  double* elementSpatialResidual,
10503  double* mt)
10504 {
10505  int eN,i,j,k,nDOF_element2=nDOF_element*nDOF_element;
10506  char trans='N';
10507  PROTEUS_LAPACK_INTEGER nrhs=1,dim=((PROTEUS_LAPACK_INTEGER)nDOF_element),info=0,ipiv[nDOF_element];
10508  double massMatrix[nDOF_element2],b[nDOF_element];
10509  /* loop over elements and solve for the local polynomial \pi(mt) such that (\pi(mt),w) = - elementSpatialResidual = b(u,w) -a(u,w) */
10510  /* then evaluate \pi(mt) at the quadrature points to recover the mt estimate */
10511  for(eN=0;eN<nElements_global;eN++)
10512  {
10513  memset(massMatrix,0,sizeof(double)*nDOF_element2);
10514  memset(ipiv,0,sizeof(PROTEUS_LAPACK_INTEGER)*nDOF_element);
10515  for(i=0;i<nDOF_element;i++)
10516  for(j=0;j<nDOF_element;j++)
10517  {
10518  for(k=0;k<nQuadraturePoints_element;k++)
10519  {
10520  mt[eN*nQuadraturePoints_element+
10521  k] = 0.0;
10522  massMatrix[i*nDOF_element+j] +=
10523  v[eN*nQuadraturePoints_element*nDOF_element+
10524  k*nDOF_element+
10525  j]
10526  *w_dV[eN*nQuadraturePoints_element*nDOF_element+
10527  k*nDOF_element+
10528  i];
10529  }
10530  b[j] = -elementSpatialResidual[eN*nDOF_element+j];
10531  }
10532  dgetrf_(&dim,&dim,massMatrix,&dim,ipiv,&info);
10533  dgetrs_(&trans,&dim,&nrhs,massMatrix,&dim,ipiv,b,&dim,&info);
10534  for (j=0;j<nDOF_element;j++)
10535  for(k=0;k<nQuadraturePoints_element;k++)
10536  mt[eN*nQuadraturePoints_element+
10537  k] += b[j]*v[eN*nQuadraturePoints_element*nDOF_element+
10538  k*nDOF_element+
10539  j];
10540  }
10541 }
10545 void copyExteriorElementBoundaryValuesFromElementBoundaryValues(int nExteriorElementBoundaries_global,
10546  int nElements_global,
10547  int nElementBoundaries_element,
10548  int nQuadraturePoints_elementBoundary,
10549  int nValuesPerQuadraturePoint,
10550  const int * exteriorElementBoundaries,
10551  const int* elementBoundaryElements,
10552  const int * elementBoundaryLocalElementBoundaries,
10553  const double * ebq_val,
10554  double * ebqe_val)
10555 {
10556  int ebNE,ebN,eN,ebN_element,k,i;
10557  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10558  {
10559  ebN = exteriorElementBoundaries[ebNE];
10560  eN = elementBoundaryElements[ebN*2+0];
10561  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
10562  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
10563  for (i=0; i < nValuesPerQuadraturePoint; i++)
10564  {
10565  ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10566  k*nValuesPerQuadraturePoint + i]
10567  =
10568  ebq_val[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10569  ebN_element*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10570  k*nValuesPerQuadraturePoint+
10571  i];
10572  }/*i,k*/
10573  }/*ebNE*/
10574 }
10578 void copyExteriorElementBoundaryValuesToElementBoundaryValues(int nExteriorElementBoundaries_global,
10579  int nElements_global,
10580  int nElementBoundaries_element,
10581  int nQuadraturePoints_elementBoundary,
10582  int nValuesPerQuadraturePoint,
10583  const int * exteriorElementBoundaries,
10584  const int* elementBoundaryElements,
10585  const int * elementBoundaryLocalElementBoundaries,
10586  const double * ebqe_val,
10587  double * ebq_val)
10588 {
10589  int ebNE,ebN,eN,ebN_element,k,i;
10590  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10591  {
10592  ebN = exteriorElementBoundaries[ebNE];
10593  eN = elementBoundaryElements[ebN*2+0];
10594  ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
10595  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
10596  for (i=0; i < nValuesPerQuadraturePoint; i++)
10597  {
10598  ebq_val[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10599  ebN_element*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10600  k*nValuesPerQuadraturePoint+
10601  i]
10602  =
10603  ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10604  k*nValuesPerQuadraturePoint + i];
10605  }/*i,k*/
10606  }/*ebNE*/
10607 }
10611 void copyExteriorElementBoundaryValuesToGlobalElementBoundaryValues(int nExteriorElementBoundaries_global,
10612  int nQuadraturePoints_elementBoundary,
10613  int nValuesPerQuadraturePoint,
10614  const int * exteriorElementBoundaries,
10615  const int* elementBoundaryElements,
10616  const int * elementBoundaryLocalElementBoundaries,
10617  const double * ebqe_val,
10618  double * ebq_global_val)
10619 {
10620  int ebNE,ebN,eN,k,i;
10621  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10622  {
10623  ebN = exteriorElementBoundaries[ebNE];
10624  eN = elementBoundaryElements[ebN*2+0];
10625  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
10626  for (i=0; i < nValuesPerQuadraturePoint; i++)
10627  {
10628  ebq_global_val[ebN*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10629  k*nValuesPerQuadraturePoint+
10630  i]
10631  =
10632  ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10633  k*nValuesPerQuadraturePoint + i];
10634  }/*i,k*/
10635  }/*ebNE*/
10636 }
10637 
10641 void copyExteriorElementBoundaryValuesFromGlobalElementBoundaryValues(int nExteriorElementBoundaries_global,
10642  int nQuadraturePoints_elementBoundary,
10643  int nValuesPerQuadraturePoint,
10644  const int * exteriorElementBoundaries,
10645  const int* elementBoundaryElements,
10646  const int * elementBoundaryLocalElementBoundaries,
10647  const double * ebq_global_val,
10648  double * ebqe_val)
10649 {
10650  int ebNE,ebN,eN,k,i;
10651  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10652  {
10653  ebN = exteriorElementBoundaries[ebNE];
10654  eN = elementBoundaryElements[ebN*2+0];
10655  for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
10656  for (i=0; i < nValuesPerQuadraturePoint; i++)
10657  {
10658  ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10659  k*nValuesPerQuadraturePoint + i]
10660  =
10661  ebq_global_val[ebN*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint+
10662  k*nValuesPerQuadraturePoint+
10663  i];
10664  }/*i,k*/
10665  }/*ebNE*/
10666 }
10667 
10668 double scalarDomainIntegral(int nElements,
10669  int nQuadraturePoints_element,
10670  double* dV,
10671  double* nValueArray)
10672 {
10673  int eN,k;
10674  register double integral=0.0;
10675  for(eN=0;eN<nElements;eN++)
10676  for(k=0;k<nQuadraturePoints_element;k++)
10677  {
10678  integral += nValueArray[eN*nQuadraturePoints_element + k]*
10679  dV[eN*nQuadraturePoints_element+k];
10680  }
10681  return integral;
10682 }
10683 
10684 double scalarHeavisideDomainIntegral(int nElements,
10685  int nQuadraturePoints_element,
10686  double* dV,
10687  double* nValueArray)
10688 {
10689  int eN,k;
10690  register double integral=0.0;
10691  for(eN=0;eN<nElements;eN++)
10692  for(k=0;k<nQuadraturePoints_element;k++)
10693  {
10694  if(nValueArray[eN*nQuadraturePoints_element + k] > 0.0)
10695  integral += dV[eN*nQuadraturePoints_element+k];
10696  else if (nValueArray[eN*nQuadraturePoints_element + k] == 0.0)
10697  integral += 0.5*dV[eN*nQuadraturePoints_element+k];
10698  }
10699  return integral;
10700 }
10701 
10703  int nQuadraturePoints_element,
10704  double epsFact,
10705  double* elementDiameter,
10706  double* dV,
10707  double* nValueArray)
10708 {
10709  int eN,k;
10710  register double integral=0.0,eps,H,phi;
10711  for(eN=0;eN<nElements;eN++)
10712  {
10713  eps = elementDiameter[eN]*epsFact;
10714  for(k=0;k<nQuadraturePoints_element;k++)
10715  {
10716  phi = nValueArray[eN*nQuadraturePoints_element + k];
10717  if (phi > eps)
10718  H=1.0;
10719  else if (phi < -eps)
10720  H=0.0;
10721  else if (phi==0.0)
10722  H=0.5;
10723  else
10724  H = 0.5*(1.0 + phi/eps + sin(M_PI*phi/eps)/M_PI);
10725  integral += H*dV[eN*nQuadraturePoints_element+k];
10726  }
10727  }
10728  return integral;
10729 }
10730 
10731 double fluxDomainBoundaryIntegral(int nExteriorElementBoundaries,
10732  int nElementBoundaries_owned,
10733  int nQuadraturePoints_elementBoundary,
10734  int* flag,
10735  int* exteriorElementBoundariesArray,
10736  double* dS,
10737  double* nValueArray)
10738 {
10739  int ebNE,ebN,k;
10740  register double integral=0.0;
10741  for(ebNE=0;ebNE<nExteriorElementBoundaries;ebNE++)
10742  {
10743  ebN = exteriorElementBoundariesArray[ebNE];
10744  if (ebN < nElementBoundaries_owned && flag[ebN] > 0)
10745  {
10746  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
10747  {
10748  integral += nValueArray[ebNE*nQuadraturePoints_elementBoundary + k]*
10749  dS[ebNE*nQuadraturePoints_elementBoundary+k];
10750  }
10751  }
10752  }
10753  return integral;
10754 }
10755 
10756 double fluxDomainBoundaryIntegralFromVector(int nExteriorElementBoundaries,
10757  int nElementBoundaries_owned,
10758  int nQuadraturePoints_elementBoundary,
10759  int nSpace,
10760  int* flag,
10761  int* exteriorElementBoundaries,
10762  double* dS,
10763  double* nValueArray,
10764  double* normal)
10765 {
10766  int ebNE,ebN,k,I;
10767  register double integral=0.0,flux=0.0;
10768  for(ebNE=0;ebNE<nExteriorElementBoundaries;ebNE++)
10769  {
10770  ebN = exteriorElementBoundaries[ebNE];
10771  if (ebN < nElementBoundaries_owned && flag[ebN] > 0)
10772  {
10773  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
10774  {
10775  flux=0.0;
10776  for (I=0;I<nSpace;I++)
10777  {
10778  flux += nValueArray[ebNE*nQuadraturePoints_elementBoundary*nSpace + k*nSpace+I]*
10779  normal[ebNE*nQuadraturePoints_elementBoundary*nSpace + k*nSpace+I];
10780  }
10781  integral += flux*dS[ebNE*nQuadraturePoints_elementBoundary+k];
10782  }
10783  }
10784  }
10785  return integral;
10786 }
10787 
10788 
10789 void computeC0P1InterpolantDGP12(int nElements_global,
10790  int nNodes_global,
10791  int nNodes_element,
10792  int nDOF_element,
10793  int dim_dof,
10794  const int* elementNodesArray,
10795  const int* nodeElementOffsets,
10796  const int* nodeElementsArray,
10797  const int* l2g,
10798  const double * dof,
10799  double* nodalAverage)
10800 {
10801  int eN,nN,i,ig,iv;
10802  int nElements_nN;
10803  memset(nodalAverage,0,sizeof(double)*nNodes_global*dim_dof);
10804  for (iv = 0; iv < dim_dof; iv++)
10805  {
10806  for (eN = 0; eN < nElements_global; eN++)
10807  {
10808  for (i = 0; i < nNodes_element; i++)
10809  {
10810  nN = elementNodesArray[eN*nNodes_element + i];
10811  ig = l2g[eN*nDOF_element + i];
10812  nodalAverage[nN*dim_dof + iv] += dof[ig*dim_dof + iv];
10813  }
10814  }
10815  for (nN = 0; nN < nNodes_global; nN++)
10816  {
10817  nElements_nN = nodeElementOffsets[nN+1] - nodeElementOffsets[nN];
10818  nodalAverage[nN*dim_dof + iv] /= nElements_nN;
10819  }
10820  }/*iv*/
10821 }
10822 
10823 void computeC0P1InterpolantDGP0(int nElements_global,
10824  int nNodes_global,
10825  int nNodes_element,
10826  int nDOF_element,
10827  int dim_dof,
10828  const int* elementNodesArray,
10829  const int* nodeElementOffsets,
10830  const int* nodeElementsArray,
10831  const int* l2g,
10832  const double * dof,
10833  double* nodalAverage)
10834 {
10835  int eN,nN,i,ig,iv;
10836  int nElements_nN;
10837  memset(nodalAverage,0,sizeof(double)*nNodes_global*dim_dof);
10838  for (iv = 0; iv < dim_dof; iv++)
10839  {
10840  for (eN = 0; eN < nElements_global; eN++)
10841  {
10842  ig = l2g[eN*nDOF_element+0];
10843  for (i = 0; i < nNodes_element; i++)
10844  {
10845  nN = elementNodesArray[eN*nNodes_element+i];
10846  nodalAverage[nN*dim_dof + iv] += dof[ig*dim_dof + iv];
10847  }
10848  }
10849  for (nN = 0; nN < nNodes_global; nN++)
10850  {
10851  nElements_nN = nodeElementOffsets[nN+1] - nodeElementOffsets[nN];
10852  nodalAverage[nN*dim_dof + iv] /= nElements_nN;
10853  }
10854  }
10855 }
10856 
10857 void computeC0P1InterpolantNCP1(int nElements_global,
10858  int nNodes_global,
10859  int nNodes_element,
10860  int nDOF_element,
10861  int dim_dof,
10862  const int* elementNodesArray,
10863  const int* nodeElementOffsets,
10864  const int* nodeElementsArray,
10865  const int* l2g,
10866  const double * dof,
10867  double* nodalAverage)
10868 {
10869  int eN,nN,i,j,ig,jg,iv;
10870  int nElements_nN;
10871  double val,nd;
10872  memset(nodalAverage,0,sizeof(double)*nNodes_global*dim_dof);
10873  nd = nNodes_element - 1.0;
10874  for (iv = 0; iv < dim_dof; iv++)
10875  {
10876  for (eN = 0; eN < nElements_global; eN++)
10877  {
10878  /*
10879  recall N_i = n_d(1/n_d - \lambda_i)
10880  lambda_i = barycentric coord for node i
10881 
10882  */
10883  for (i = 0; i < nNodes_element; i++)
10884  {
10885  val = 0.0;
10886  for (j=0; j < i; j++)
10887  {
10888  jg = l2g[eN*nDOF_element+j];
10889  val += dof[jg*dim_dof + iv];
10890  }
10891  for (j=i+1; j < nNodes_element; j++)
10892  {
10893  jg = l2g[eN*nDOF_element+j];
10894  val += dof[jg*dim_dof + iv];
10895  }
10896  ig = l2g[eN*nDOF_element+i];
10897  val += (1.0-nd)*dof[ig*dim_dof + iv];
10898  nN = elementNodesArray[eN*nNodes_element+i];
10899  nodalAverage[nN*dim_dof + iv] += val;
10900  }
10901  }
10902  for (nN = 0; nN < nNodes_global; nN++)
10903  {
10904  nElements_nN = nodeElementOffsets[nN+1] - nodeElementOffsets[nN];
10905  nodalAverage[nN*dim_dof + iv] /= nElements_nN;
10906  }
10907  }/*iv*/
10908 }
10909 
10914  int nExteriorElementBoundaries_global,
10915  int nQuadraturePoints_elementBoundary,
10916  int nValuesPerQuadraturePoint,
10917  double tolerance,
10918  const int * exteriorElementBoundariesArray,
10919  const int * elementBoundaryElementsArray,
10920  const int * elementBoundaryLocalElementBoundariesArray,
10921  const double * ebq_val,
10922  const double * ebqe_val,
10923  int* firstBadIndex)
10924 {
10925  int eN,ebN,ebN_local,ebNE,k,i;
10926  double val1,val2;
10927  int failed = 0;
10928  *firstBadIndex = -1;
10929 
10930  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10931  {
10932  ebN = exteriorElementBoundariesArray[ebNE];
10933  eN = elementBoundaryElementsArray[ebN*2+0];
10934  ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0];
10935 
10936  for (i=0; i < nValuesPerQuadraturePoint; i++)
10937  {
10938  val1 = ebq_val[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10939  ebN_local*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10940  k*nValuesPerQuadraturePoint +
10941  i];
10942  val2 = ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10943  k*nValuesPerQuadraturePoint +
10944  i];
10945  if (fabs(val1-val2) > tolerance)
10946  {
10947  failed = 1;
10948  *firstBadIndex = ebNE;
10949  return failed;
10950  }
10951  }
10952  }
10953  return failed;
10954 }
10955 
10959 int checkGlobalElementBoundaryAndExteriorElementBoundaryArraysSame(int nExteriorElementBoundaries_global,
10960  int nQuadraturePoints_elementBoundary,
10961  int nValuesPerQuadraturePoint,
10962  double tolerance,
10963  const int * exteriorElementBoundariesArray,
10964  const int * elementBoundaryElementsArray,
10965  const int * elementBoundaryLocalElementBoundariesArray,
10966  const double * ebq_global_val,
10967  const double * ebqe_val,
10968  int* firstBadIndex)
10969 {
10970  int eN,ebN,ebNE,k,i;
10971  double val1,val2;
10972  int failed = 0;
10973  *firstBadIndex = -1;
10974 
10975  for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
10976  {
10977  ebN = exteriorElementBoundariesArray[ebNE];
10978  eN = elementBoundaryElementsArray[ebN*2+0];
10979 
10980  for (i=0; i < nValuesPerQuadraturePoint; i++)
10981  {
10982  val1 = ebq_global_val[ebN*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10983  k*nValuesPerQuadraturePoint +
10984  i];
10985  val2 = ebqe_val[ebNE*nQuadraturePoints_elementBoundary*nValuesPerQuadraturePoint +
10986  k*nValuesPerQuadraturePoint +
10987  i];
10988  if (fabs(val1-val2) > tolerance)
10989  {
10990  failed = 1;
10991  *firstBadIndex = ebNE;
10992  return failed;
10993  }
10994  }
10995  }
10996  return failed;
10997 }
10998 
11000  int offset,
11001  int stride,
11002  const int* globalDOFids,
11003  const int* freeDOFids,
11004  const double * free_u,
11005  double * u)
11006 {
11007  int i,dofN,free_dofN;
11008  for (i = 0; i < nDOF2set; i++)
11009  {
11010  dofN = globalDOFids[i]; free_dofN = freeDOFids[i];
11011  u[dofN] = free_u[offset + stride*free_dofN];
11012  }
11013 
11014 }
11015 
11017  int offset,
11018  int stride,
11019  const int* globalDOFids,
11020  const int* freeDOFids,
11021  const double * u,
11022  double * free_u)
11023 {
11024  int i,dofN,free_dofN;
11025  for (i = 0; i < nDOF2set; i++)
11026  {
11027  dofN = globalDOFids[i]; free_dofN = freeDOFids[i];
11028  free_u[offset + stride*free_dofN] = u[dofN]; /*hit multiple times*/
11029  }
11030 
11031 }
11032 
11033 void updateInteriorElementBoundaryDiffusionAdjoint(int nInteriorElementBoundaries_global,
11034  int nElementBoundaries_element,
11035  int nQuadraturePoints_elementBoundary,
11036  int nDOF_test_element,
11037  int nSpace,
11038  int* interiorElementBoundaries,
11039  int* elementBoundaryElements,
11040  int* elementBoundaryLocalElementBoundaries,
11041  double sigma,
11042  double* u,
11043  double* n,
11044  double* a,
11045  double* grad_w,
11046  double* dS,
11047  double* residual)
11048 {
11049  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,k,I,J,nSpace2=nSpace*nSpace;
11050  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
11051  {
11052  ebN = interiorElementBoundaries[ebNI];
11053  left_eN_global = elementBoundaryElements[ebN*2+0];
11054  right_eN_global = elementBoundaryElements[ebN*2+1];
11055  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
11056  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
11057  for(i=0;i<nDOF_test_element;i++)
11058  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11059  {
11060  for (I=0;I<nSpace;I++)
11061  for (J=0;J<nSpace;J++)
11062  {
11063  residual[left_eN_global*nDOF_test_element+
11064  i]
11065  -=
11066  sigma*0.5*((u[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11067  left_ebN_element*nQuadraturePoints_elementBoundary+
11068  k]
11069  -u[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11070  right_ebN_element*nQuadraturePoints_elementBoundary+
11071  k])
11072  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11073  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11074  k*nSpace+I]
11075  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11076  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
11077  k*nSpace2+
11078  J*nSpace+
11079  I]
11080  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11081  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11082  k*nDOF_test_element*nSpace+
11083  i*nSpace+
11084  I]
11085  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11086  left_ebN_element*nQuadraturePoints_elementBoundary+
11087  k]);
11088  residual[right_eN_global*nDOF_test_element+
11089  i]
11090  -=
11091  sigma*0.5*((u[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11092  left_ebN_element*nQuadraturePoints_elementBoundary+
11093  k]
11094  -u[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11095  right_ebN_element*nQuadraturePoints_elementBoundary+
11096  k])
11097  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11098  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11099  k*nSpace+I]
11100  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11101  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
11102  k*nSpace2+
11103  J*nSpace+
11104  I]
11105  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11106  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11107  k*nDOF_test_element*nSpace+
11108  i*nSpace+
11109  I]
11110  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11111  right_ebN_element*nQuadraturePoints_elementBoundary+
11112  k]);
11113  }
11114  }
11115  }
11116 }
11117 
11118 void updateExteriorElementBoundaryDiffusionAdjoint(int nExteriorElementBoundaries_global,
11119  int nQuadraturePoints_elementBoundary,
11120  int nDOF_test_element,
11121  int nSpace,
11122  int* isDOFBoundary,
11123  int* exteriorElementBoundaries,
11124  int* elementBoundaryElements,
11125  int* elementBoundaryLocalElementBoundaries,
11126  double sigma,
11127  double* u,
11128  double* ub,
11129  double* n,
11130  double* a,
11131  double* grad_w,
11132  double* dS,
11133  double* residual)
11134 {
11135  int ebNE,ebN,eN_global,i,k,I,J,nSpace2=nSpace*nSpace;
11136  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
11137  {
11138  ebN = exteriorElementBoundaries[ebNE];
11139  eN_global = elementBoundaryElements[ebN*2+0];
11140  for(i=0;i<nDOF_test_element;i++)
11141  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11142  {
11143  if (isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k])
11144  {
11145  for (I=0;I<nSpace;I++)
11146  for (J=0;J<nSpace;J++)
11147  {
11148  residual[eN_global*nDOF_test_element+
11149  i]
11150  -=
11151  sigma*((u[ebNE*nQuadraturePoints_elementBoundary+
11152  k]
11153  -ub[ebNE*nQuadraturePoints_elementBoundary+
11154  k])
11155  *n[ebNE*nQuadraturePoints_elementBoundary*nSpace+
11156  k*nSpace+
11157  I]
11158  *a[ebNE*nQuadraturePoints_elementBoundary*nSpace2+
11159  k*nSpace2+
11160  J*nSpace+
11161  I]
11162  *grad_w[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11163  k*nDOF_test_element*nSpace+
11164  i*nSpace+
11165  I]
11166  *dS[ebNE*nQuadraturePoints_elementBoundary+
11167  k]);
11168  }
11169  }
11170  }
11171  }
11172 }
11173 
11175  int nElementBoundaries_element,
11176  int nQuadraturePoints_elementBoundary,
11177  int nDOF_test_element,
11178  int nDOF_trial_element,
11179  int nSpace,
11180  int offset_r,
11181  int stride_r,
11182  int offset_u,
11183  int stride_u,
11184  int nFreeVDOF_global,
11185  int* interiorElementBoundaries,
11186  int* elementBoundaryElements,
11187  int* elementBoundaryLocalElementBoundaries,
11188  int* nFreeDOF_element_r,
11189  int* freeLocal_r,
11190  int* freeGlobal_r,
11191  int* nFreeDOF_element_u,
11192  int* freeLocal_u,
11193  int* freeGlobal_u,
11194  double sigma,
11195  double* v,
11196  double* n,
11197  double* a,
11198  double* grad_w,
11199  double* dS,
11200  double* jac)
11201 {
11202  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,I,J,II,JJ,nSpace2=nSpace*nSpace;
11203  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
11204  {
11205  ebN = interiorElementBoundaries[ebNI];
11206  left_eN_global = elementBoundaryElements[ebN*2+0];
11207  right_eN_global = elementBoundaryElements[ebN*2+1];
11208  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
11209  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
11210  /*left flux*/
11211  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
11212  {
11213  i = freeLocal_r[left_eN_global*nDOF_test_element+
11214  ii];
11215  I = offset_r + stride_r*freeGlobal_r[left_eN_global*nDOF_test_element+
11216  ii];
11217  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11218  {
11219  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11220  {
11221  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11222  jj];
11223  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
11224  jj];
11225  jacIndex = I+J*nFreeVDOF_global;
11226  for (II=0;II<nSpace;II++)
11227  for (JJ=0;JJ<nSpace;JJ++)
11228  jac[jacIndex]
11229  -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11230  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11231  k*nDOF_trial_element+
11232  j]
11233  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11234  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11235  k*nSpace+
11236  II]
11237  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11238  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+k*nSpace2+
11239  II*nSpace+
11240  JJ]
11241  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11242  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11243  k*nDOF_trial_element*nSpace+
11244  i*nSpace+
11245  II]
11246  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11247  left_ebN_element*nQuadraturePoints_elementBoundary+
11248  k]);
11249  }
11250  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
11251  {
11252  j = freeLocal_u[right_eN_global*nDOF_trial_element+
11253  jj];
11254  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
11255  jj];
11256  jacIndex = I+J*nFreeVDOF_global;
11257  for (II=0;II<nSpace;II++)
11258  for (JJ=0;JJ<nSpace;JJ++)
11259  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11260  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11261  k*nDOF_trial_element+
11262  j]
11263  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11264  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11265  k*nSpace+
11266  II]
11267  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11268  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
11269  k*nSpace2+
11270  II*nSpace+
11271  JJ]
11272  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11273  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11274  k*nDOF_trial_element*nSpace+
11275  i*nSpace+
11276  II]
11277  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11278  left_ebN_element*nQuadraturePoints_elementBoundary+
11279  k]);
11280  }
11281  }/*k*/
11282  }/*ii*/
11283  /*right flux*/
11284  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
11285  {
11286  i = freeLocal_r[right_eN_global*nDOF_test_element+
11287  ii];
11288  I = offset_r + stride_r*freeGlobal_r[right_eN_global*nDOF_test_element+
11289  ii];
11290  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11291  {
11292  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11293  {
11294  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11295  jj];
11296  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
11297  jj];
11298  jacIndex = I+J*nFreeVDOF_global;
11299  for (II=0;II<nSpace;II++)
11300  for (JJ=0;JJ<nSpace;JJ++)
11301  jac[jacIndex] -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11302  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11303  k*nDOF_trial_element+
11304  j]
11305  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11306  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11307  k*nSpace+
11308  II]
11309  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11310  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
11311  k*nSpace2+
11312  II*nSpace+
11313  JJ]
11314  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11315  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11316  k*nDOF_trial_element*nSpace+
11317  i*nSpace+
11318  II]
11319  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11320  right_ebN_element*nQuadraturePoints_elementBoundary+
11321  k]);
11322  }
11323  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
11324  {
11325  j = freeLocal_u[right_eN_global*nDOF_trial_element+
11326  jj];
11327  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
11328  jj];
11329  jacIndex = I+J*nFreeVDOF_global;
11330  for (II=0;II<nSpace;II++)
11331  for (JJ=0;JJ<nSpace;JJ++)
11332  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11333  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11334  k*nDOF_trial_element+j]
11335  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11336  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11337  k*nSpace+
11338  II]
11339  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace2+
11340  right_ebN_element*nQuadraturePoints_elementBoundary*nSpace2+
11341  k*nSpace2+
11342  II*nSpace+
11343  JJ]
11344  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11345  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11346  k*nDOF_trial_element*nSpace+
11347  i*nSpace+
11348  II]
11349  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11350  right_ebN_element*nQuadraturePoints_elementBoundary+
11351  k]);
11352  }
11353  }
11354  }
11355  }
11356 }
11357 
11359  int nQuadraturePoints_elementBoundary,
11360  int nDOF_test_element,
11361  int nDOF_trial_element,
11362  int nSpace,
11363  int offset_r,
11364  int stride_r,
11365  int offset_u,
11366  int stride_u,
11367  int nFreeVDOF_global,
11368  int* exteriorElementBoundaries,
11369  int* elementBoundaryElements,
11370  int* elementBoundaryLocalElementBoundaries,
11371  int* nFreeDOF_element_r,
11372  int* freeLocal_r,
11373  int* freeGlobal_r,
11374  int* nFreeDOF_element_u,
11375  int* freeLocal_u,
11376  int* freeGlobal_u,
11377  int* isDOFBoundary,
11378  double sigma,
11379  double* v,
11380  double* n,
11381  double* a,
11382  double* grad_w,
11383  double* dS,
11384  double* jac)
11385 {
11386  int ebNE,ebN,eN_global,ii,i,k,jj,j,jacIndex,I,J,II,JJ,nSpace2=nSpace*nSpace;
11387  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
11388  {
11389  ebN = exteriorElementBoundaries[ebNE];
11390  eN_global = elementBoundaryElements[ebN*2+0];
11391  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
11392  {
11393  i = freeLocal_r[eN_global*nDOF_test_element+
11394  ii];
11395  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
11396  ii];
11397  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11398  {
11399  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
11400  {
11401  j = freeLocal_u[eN_global*nDOF_trial_element+
11402  jj];
11403  J = offset_u + stride_u*freeGlobal_u[eN_global*nDOF_trial_element+
11404  jj];
11405  jacIndex = I+J*nFreeVDOF_global;
11406  if (isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k])
11407  {
11408  for (II=0;II<nSpace;II++)
11409  for (JJ=0;JJ<nSpace;JJ++)
11410  jac[jacIndex]
11411  -= sigma*(v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11412  k*nDOF_trial_element+
11413  j]
11414  *n[ebNE*nQuadraturePoints_elementBoundary*nSpace+
11415  k*nSpace+
11416  II]
11417  *a[ebNE*nQuadraturePoints_elementBoundary*nSpace2+
11418  II*nSpace+
11419  JJ]
11420  *grad_w[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11421  k*nDOF_trial_element*nSpace+
11422  i*nSpace+
11423  II]
11424  *dS[ebNE*nQuadraturePoints_elementBoundary+
11425  k]);
11426  }
11427  }
11428  }
11429  }
11430  }
11431 }
11432 
11433 void updateInteriorElementBoundaryDiffusionAdjoint_sd(int nInteriorElementBoundaries_global,
11434  int nElementBoundaries_element,
11435  int nQuadraturePoints_elementBoundary,
11436  int nDOF_test_element,
11437  int nSpace,
11438  int* rowptr,
11439  int* colind,
11440  int* interiorElementBoundaries,
11441  int* elementBoundaryElements,
11442  int* elementBoundaryLocalElementBoundaries,
11443  double sigma,
11444  double* u,
11445  double* n,
11446  double* a,
11447  double* grad_w,
11448  double* dS,
11449  double* residual)
11450 {
11451  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,i,k,I,m,nnz=rowptr[nSpace];
11452  for(ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
11453  {
11454  ebN = interiorElementBoundaries[ebNI];
11455  left_eN_global = elementBoundaryElements[ebN*2+0];
11456  right_eN_global = elementBoundaryElements[ebN*2+1];
11457  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
11458  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
11459  for(i=0;i<nDOF_test_element;i++)
11460  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11461  {
11462  for (I=0;I<nSpace;I++)
11463  for (m=rowptr[I];m<rowptr[I+1];m++)
11464  {
11465  residual[left_eN_global*nDOF_test_element+
11466  i]
11467  -=
11468  sigma*0.5*((u[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11469  left_ebN_element*nQuadraturePoints_elementBoundary+
11470  k]
11471  -u[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11472  right_ebN_element*nQuadraturePoints_elementBoundary+
11473  k])
11474  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11475  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11476  k*nSpace+
11477  colind[m]]
11478  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11479  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11480  k*nnz+
11481  m]
11482  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11483  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11484  k*nDOF_test_element*nSpace+
11485  i*nSpace+
11486  I]
11487  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11488  left_ebN_element*nQuadraturePoints_elementBoundary+
11489  k]);
11490  residual[right_eN_global*nDOF_test_element+
11491  i]
11492  -=
11493  sigma*0.5*((u[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11494  left_ebN_element*nQuadraturePoints_elementBoundary+
11495  k]
11496  -u[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11497  right_ebN_element*nQuadraturePoints_elementBoundary+
11498  k])
11499  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11500  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11501  k*nSpace+
11502  colind[m]]
11503  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11504  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11505  k*nnz+
11506  m]
11507  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11508  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11509  k*nDOF_test_element*nSpace+
11510  i*nSpace+
11511  I]
11512  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11513  right_ebN_element*nQuadraturePoints_elementBoundary+
11514  k]);
11515  }
11516  }
11517  }
11518 }
11519 
11520 void updateExteriorElementBoundaryDiffusionAdjoint_sd(int nExteriorElementBoundaries_global,
11521  int nQuadraturePoints_elementBoundary,
11522  int nDOF_test_element,
11523  int nSpace,
11524  int* rowptr,
11525  int* colind,
11526  int* isDOFBoundary,
11527  int* exteriorElementBoundaries,
11528  int* elementBoundaryElements,
11529  int* elementBoundaryLocalElementBoundaries,
11530  double sigma,
11531  double* u,
11532  double* ub,
11533  double* n,
11534  double* a,
11535  double* grad_w,
11536  double* dS,
11537  double* residual)
11538 {
11539  int ebNE,ebN,eN_global,i,k,I,m,nnz=rowptr[nSpace];
11540  for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
11541  {
11542  ebN = exteriorElementBoundaries[ebNE];
11543  eN_global = elementBoundaryElements[ebN*2+0];
11544  for(i=0;i<nDOF_test_element;i++)
11545  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11546  {
11547  if (isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k])
11548  {
11549  for (I=0;I<nSpace;I++)
11550  for (m=rowptr[I];m<rowptr[I+1];m++)
11551  {
11552  residual[eN_global*nDOF_test_element+
11553  i]
11554  -=
11555  sigma*((u[ebNE*nQuadraturePoints_elementBoundary+
11556  k]
11557  -ub[ebNE*nQuadraturePoints_elementBoundary+
11558  k])
11559  *n[ebNE*nQuadraturePoints_elementBoundary*nSpace+
11560  k*nSpace+
11561  colind[m]]
11562  *a[ebNE*nQuadraturePoints_elementBoundary*nnz+
11563  k*nnz+
11564  m]
11565  *grad_w[ebNE*nQuadraturePoints_elementBoundary*nDOF_test_element*nSpace+
11566  k*nDOF_test_element*nSpace+
11567  i*nSpace+
11568  I]
11569  *dS[ebNE*nQuadraturePoints_elementBoundary+
11570  k]);
11571  }
11572  }
11573  }
11574  }
11575 }
11576 
11578  int nElementBoundaries_element,
11579  int nQuadraturePoints_elementBoundary,
11580  int nDOF_test_element,
11581  int nDOF_trial_element,
11582  int nSpace,
11583  int* rowptr,
11584  int* colind,
11585  int offset_r,
11586  int stride_r,
11587  int offset_u,
11588  int stride_u,
11589  int nFreeVDOF_global,
11590  int* interiorElementBoundaries,
11591  int* elementBoundaryElements,
11592  int* elementBoundaryLocalElementBoundaries,
11593  int* nFreeDOF_element_r,
11594  int* freeLocal_r,
11595  int* freeGlobal_r,
11596  int* nFreeDOF_element_u,
11597  int* freeLocal_u,
11598  int* freeGlobal_u,
11599  double sigma,
11600  double* v,
11601  double* n,
11602  double* a,
11603  double* grad_w,
11604  double* dS,
11605  double* jac)
11606 {
11607  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,I,J,II,m,nnz=rowptr[nSpace];
11608  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
11609  {
11610  ebN = interiorElementBoundaries[ebNI];
11611  left_eN_global = elementBoundaryElements[ebN*2+0];
11612  right_eN_global = elementBoundaryElements[ebN*2+1];
11613  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
11614  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
11615  /*left flux*/
11616  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
11617  {
11618  i = freeLocal_r[left_eN_global*nDOF_test_element+
11619  ii];
11620  I = offset_r + stride_r*freeGlobal_r[left_eN_global*nDOF_test_element+
11621  ii];
11622  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11623  {
11624  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11625  {
11626  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11627  jj];
11628  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
11629  jj];
11630  jacIndex = I+J*nFreeVDOF_global;
11631  for (II=0;II<nSpace;II++)
11632  for(m=rowptr[II];m<rowptr[II+1];m++)
11633  {
11634  jac[jacIndex]
11635  -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11636  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11637  k*nDOF_trial_element+
11638  j]
11639  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11640  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11641  k*nSpace+
11642  colind[II]]
11643  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11644  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11645  k*nnz+
11646  m]
11647  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11648  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11649  k*nDOF_trial_element*nSpace+
11650  i*nSpace+
11651  II]
11652  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11653  left_ebN_element*nQuadraturePoints_elementBoundary+
11654  k]);
11655  }
11656  }
11657  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
11658  {
11659  j = freeLocal_u[right_eN_global*nDOF_trial_element+
11660  jj];
11661  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
11662  jj];
11663  jacIndex = I+J*nFreeVDOF_global;
11664  for (II=0;II<nSpace;II++)
11665  for (m=rowptr[II];m<rowptr[II+1];m++)
11666  {
11667  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11668  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11669  k*nDOF_trial_element+
11670  j]
11671  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11672  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11673  k*nSpace+
11674  colind[m]]
11675  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11676  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11677  k*nnz+
11678  m]
11679  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11680  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11681  k*nDOF_trial_element*nSpace+
11682  i*nSpace+
11683  II]
11684  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11685  left_ebN_element*nQuadraturePoints_elementBoundary+
11686  k]);
11687  }
11688  }
11689  }/*k*/
11690  }/*ii*/
11691  /*right flux*/
11692  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
11693  {
11694  i = freeLocal_r[right_eN_global*nDOF_test_element+
11695  ii];
11696  I = offset_r + stride_r*freeGlobal_r[right_eN_global*nDOF_test_element+
11697  ii];
11698  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11699  {
11700  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11701  {
11702  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11703  jj];
11704  J = offset_u + stride_u*freeGlobal_u[left_eN_global*nDOF_trial_element+
11705  jj];
11706  jacIndex = I+J*nFreeVDOF_global;
11707  for (II=0;II<nSpace;II++)
11708  for (m=rowptr[II];m<rowptr[II+1];m++)
11709  {
11710  jac[jacIndex] -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11711  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11712  k*nDOF_trial_element+
11713  j]
11714  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11715  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11716  k*nSpace+
11717  colind[m]]
11718  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11719  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11720  k*nnz+
11721  m]
11722  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11723  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11724  k*nDOF_trial_element*nSpace+
11725  i*nSpace+
11726  II]
11727  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11728  right_ebN_element*nQuadraturePoints_elementBoundary+
11729  k]);
11730  }
11731  }
11732  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
11733  {
11734  j = freeLocal_u[right_eN_global*nDOF_trial_element+
11735  jj];
11736  J = offset_u + stride_u*freeGlobal_u[right_eN_global*nDOF_trial_element+
11737  jj];
11738  jacIndex = I+J*nFreeVDOF_global;
11739  for (II=0;II<nSpace;II++)
11740  for (m=rowptr[II];m<rowptr[II+1];m++)
11741  {
11742  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11743  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11744  k*nDOF_trial_element+j]
11745  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11746  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11747  k*nSpace+
11748  colind[m]]
11749  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11750  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11751  k*nnz+
11752  m]
11753  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11754  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11755  k*nDOF_trial_element*nSpace+
11756  i*nSpace+
11757  II]
11758  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11759  right_ebN_element*nQuadraturePoints_elementBoundary+
11760  k]);
11761  }
11762  }
11763  }
11764  }
11765  }
11766 }
11767 
11769  int nQuadraturePoints_elementBoundary,
11770  int nDOF_test_element,
11771  int nDOF_trial_element,
11772  int nSpace,
11773  int* rowptr,
11774  int* colind,
11775  int offset_r,
11776  int stride_r,
11777  int offset_u,
11778  int stride_u,
11779  int nFreeVDOF_global,
11780  int* exteriorElementBoundaries,
11781  int* elementBoundaryElements,
11782  int* elementBoundaryLocalElementBoundaries,
11783  int* nFreeDOF_element_r,
11784  int* freeLocal_r,
11785  int* freeGlobal_r,
11786  int* nFreeDOF_element_u,
11787  int* freeLocal_u,
11788  int* freeGlobal_u,
11789  int* isDOFBoundary,
11790  double sigma,
11791  double* v,
11792  double* n,
11793  double* a,
11794  double* grad_w,
11795  double* dS,
11796  double* jac)
11797 {
11798  int ebNE,ebN,eN_global,ii,i,k,jj,j,jacIndex,I,J,II,m,nnz=rowptr[nSpace];
11799  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
11800  {
11801  ebN = exteriorElementBoundaries[ebNE];
11802  eN_global = elementBoundaryElements[ebN*2+0];
11803  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
11804  {
11805  i = freeLocal_r[eN_global*nDOF_test_element+
11806  ii];
11807  I = offset_r + stride_r*freeGlobal_r[eN_global*nDOF_test_element+
11808  ii];
11809  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11810  {
11811  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
11812  {
11813  j = freeLocal_u[eN_global*nDOF_trial_element+
11814  jj];
11815  J = offset_u + stride_u*freeGlobal_u[eN_global*nDOF_trial_element+
11816  jj];
11817  jacIndex = I+J*nFreeVDOF_global;
11818  if (isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k])
11819  {
11820  for (II=0;II<nSpace;II++)
11821  for (m=rowptr[II];m<rowptr[II+1];m++)
11822  jac[jacIndex]
11823  -= sigma*(v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11824  k*nDOF_trial_element+
11825  j]
11826  *n[ebNE*nQuadraturePoints_elementBoundary*nSpace+
11827  k*nSpace+
11828  colind[m]]
11829  *a[ebNE*nQuadraturePoints_elementBoundary*nnz+
11830  k*nnz+
11831  m]
11832  *grad_w[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11833  k*nDOF_trial_element*nSpace+
11834  i*nSpace+
11835  II]
11836  *dS[ebNE*nQuadraturePoints_elementBoundary+
11837  k]);
11838  }
11839  }
11840  }
11841  }
11842  }
11843 }
11845  int nElementBoundaries_element,
11846  int nQuadraturePoints_elementBoundary,
11847  int nDOF_test_element,
11848  int nDOF_trial_element,
11849  int nSpace,
11850  int* rowptr,
11851  int* colind,
11852  int offset_r,
11853  int stride_r,
11854  int offset_u,
11855  int stride_u,
11856  int nFreeVDOF_global,
11857  int* interiorElementBoundaries,
11858  int* elementBoundaryElements,
11859  int* elementBoundaryLocalElementBoundaries,
11860  int* nFreeDOF_element_r,
11861  int* freeLocal_r,
11862  int* freeGlobal_r,
11863  int* nFreeDOF_element_u,
11864  int* freeLocal_u,
11865  int* freeGlobal_u,
11866  int* csrRowIndeces_ru,
11867  int* csrColumnOffsets_eb_ru,
11868  double sigma,
11869  double* v,
11870  double* n,
11871  double* a,
11872  double* grad_w,
11873  double* dS,
11874  double* jac)
11875 {
11876  int ebNI,ebN,left_eN_global,right_eN_global,left_ebN_element,right_ebN_element,ii,i,k,jj,j,jacIndex,II,m,nnz=rowptr[nSpace],nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
11877  for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
11878  {
11879  ebN = interiorElementBoundaries[ebNI];
11880  left_eN_global = elementBoundaryElements[ebN*2+0];
11881  right_eN_global = elementBoundaryElements[ebN*2+1];
11882  left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
11883  right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
11884  /*left flux*/
11885  for(ii=0;ii<nFreeDOF_element_r[left_eN_global];ii++)
11886  {
11887  i = freeLocal_r[left_eN_global*nDOF_test_element+
11888  ii];
11889  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11890  {
11891  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11892  {
11893  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11894  jj];
11895  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
11896  ii]
11897  +
11898  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
11899  0*2*nDOF_test_X_trial_element +
11900  0*nDOF_test_X_trial_element +
11901  ii*nDOF_trial_element +
11902  jj];
11903  for (II=0;II<nSpace;II++)
11904  for(m=rowptr[II];m<rowptr[II+1];m++)
11905  jac[jacIndex] -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11906  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11907  k*nDOF_trial_element+
11908  j]
11909  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11910  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11911  k*nSpace+
11912  colind[m]]
11913  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11914  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11915  k*nnz+
11916  m]
11917  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11918  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11919  k*nDOF_trial_element*nSpace+
11920  i*nSpace+
11921  II]
11922  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11923  left_ebN_element*nQuadraturePoints_elementBoundary+
11924  k]);
11925  }
11926  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
11927  {
11928  j = freeLocal_u[right_eN_global*nDOF_trial_element+
11929  jj];
11930  jacIndex = csrRowIndeces_ru[left_eN_global*nDOF_test_element+
11931  ii]
11932  +
11933  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
11934  0*2*nDOF_test_X_trial_element+
11935  1*nDOF_test_X_trial_element+
11936  ii*nDOF_trial_element+
11937  jj];
11938  for (II=0;II<nSpace;II++)
11939  for (m=rowptr[II];m<rowptr[II+1];m++)
11940  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11941  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11942  k*nDOF_trial_element+
11943  j]
11944  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11945  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11946  k*nSpace+
11947  colind[m]]
11948  *a[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11949  left_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11950  k*nnz+
11951  m]
11952  *grad_w[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11953  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11954  k*nDOF_trial_element*nSpace+
11955  i*nSpace+
11956  II]
11957  *dS[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
11958  left_ebN_element*nQuadraturePoints_elementBoundary+
11959  k]);
11960  }
11961  }/*k*/
11962  }/*ii*/
11963  /*right flux*/
11964  for(ii=0;ii<nFreeDOF_element_r[right_eN_global];ii++)
11965  {
11966  i = freeLocal_r[right_eN_global*nDOF_test_element+
11967  ii];
11968  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
11969  {
11970  for(jj=0;jj<nFreeDOF_element_u[left_eN_global];jj++)
11971  {
11972  j = freeLocal_u[left_eN_global*nDOF_trial_element+
11973  jj];
11974  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
11975  ii]
11976  +
11977  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
11978  1*2*nDOF_test_X_trial_element+
11979  0*nDOF_test_X_trial_element+
11980  ii*nDOF_trial_element+
11981  jj];
11982  for (II=0;II<nSpace;II++)
11983  for (m=rowptr[II];m<rowptr[II+1];m++)
11984  jac[jacIndex] -= sigma*0.5*(v[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11985  left_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
11986  k*nDOF_trial_element+
11987  j]
11988  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
11989  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
11990  k*nSpace+
11991  colind[m]]
11992  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
11993  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
11994  k*nnz+
11995  m]
11996  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11997  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
11998  k*nDOF_trial_element*nSpace+
11999  i*nSpace+
12000  II]
12001  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
12002  right_ebN_element*nQuadraturePoints_elementBoundary+
12003  k]);
12004  }
12005  for(jj=0;jj<nFreeDOF_element_u[right_eN_global];jj++)
12006  {
12007  j = freeLocal_u[right_eN_global*nDOF_trial_element+
12008  jj];
12009  jacIndex = csrRowIndeces_ru[right_eN_global*nDOF_test_element+
12010  ii]
12011  +
12012  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element+
12013  1*2*nDOF_test_X_trial_element+
12014  1*nDOF_test_X_trial_element+
12015  ii*nDOF_trial_element+
12016  jj];
12017  for (II=0;II<nSpace;II++)
12018  for (m=rowptr[II];m<rowptr[II+1];m++)
12019  jac[jacIndex] += sigma*0.5*(v[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
12020  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element+
12021  k*nDOF_trial_element+j]
12022  *n[left_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
12023  left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
12024  k*nSpace+
12025  colind[m]]
12026  *a[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nnz+
12027  right_ebN_element*nQuadraturePoints_elementBoundary*nnz+
12028  k*nnz+
12029  m]
12030  *grad_w[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
12031  right_ebN_element*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
12032  k*nDOF_trial_element*nSpace+
12033  i*nSpace+
12034  II]
12035  *dS[right_eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
12036  right_ebN_element*nQuadraturePoints_elementBoundary+
12037  k]);
12038  }
12039  }
12040  }
12041  }
12042 }
12043 
12045  int nQuadraturePoints_elementBoundary,
12046  int nDOF_test_element,
12047  int nDOF_trial_element,
12048  int nSpace,
12049  int* rowptr,
12050  int* colind,
12051  int offset_r,
12052  int stride_r,
12053  int offset_u,
12054  int stride_u,
12055  int nFreeVDOF_global,
12056  int* exteriorElementBoundaries,
12057  int* elementBoundaryElements,
12058  int* elementBoundaryLocalElementBoundaries,
12059  int* nFreeDOF_element_r,
12060  int* freeLocal_r,
12061  int* freeGlobal_r,
12062  int* nFreeDOF_element_u,
12063  int* freeLocal_u,
12064  int* freeGlobal_u,
12065  int* csrRowIndeces_ru,
12066  int* csrColumnOffsets_eb_ru,
12067  int* isDOFBoundary,
12068  double sigma,
12069  double* v,
12070  double* n,
12071  double* a,
12072  double* grad_w,
12073  double* dS,
12074  double* jac)
12075 {
12076  int ebNE,ebN,eN_global,ii,i,k,jj,j,jacIndex,II,m,nnz=rowptr[nSpace],nDOF_test_X_trial_element=nDOF_trial_element*nDOF_test_element;
12077  for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
12078  {
12079  ebN = exteriorElementBoundaries[ebNE];
12080  eN_global = elementBoundaryElements[ebN*2+0];
12081  for(ii=0;ii<nFreeDOF_element_r[eN_global];ii++)
12082  {
12083  i = freeLocal_r[eN_global*nDOF_test_element+
12084  ii];
12085  for(k=0;k<nQuadraturePoints_elementBoundary;k++)
12086  {
12087  for(jj=0;jj<nFreeDOF_element_u[eN_global];jj++)
12088  {
12089  j = freeLocal_u[eN_global*nDOF_trial_element+
12090  jj];
12091  jacIndex = csrRowIndeces_ru[eN_global*nDOF_test_element+
12092  ii]
12093  +
12094  csrColumnOffsets_eb_ru[ebN*4*nDOF_test_X_trial_element +
12095  0*2*nDOF_test_X_trial_element +
12096  0*nDOF_test_X_trial_element +
12097  ii*nDOF_trial_element +
12098  jj];
12099  if (isDOFBoundary[ebNE*nQuadraturePoints_elementBoundary+k])
12100  {
12101  for (II=0;II<nSpace;II++)
12102  for (m=rowptr[II];m<rowptr[II+1];m++)
12103  jac[jacIndex]
12104  -= sigma*(v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element+
12105  k*nDOF_trial_element+
12106  j]
12107  *n[ebNE*nQuadraturePoints_elementBoundary*nSpace+
12108  k*nSpace+
12109  colind[m]]
12110  *a[ebNE*nQuadraturePoints_elementBoundary*nnz+
12111  k*nnz+
12112  m]
12113  *grad_w[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element*nSpace+
12114  k*nDOF_trial_element*nSpace+
12115  i*nSpace+
12116  II]
12117  *dS[ebNE*nQuadraturePoints_elementBoundary+
12118  k]);
12119  }
12120  }
12121  }
12122  }
12123  }
12124 }
12125 
12126 void update_f_movingDomain_q(int nElements_global,
12127  int nQuadraturePoints_element,
12128  int nSpace,
12129  double* xt,
12130  double* m,
12131  double* f)
12132 {
12133  int eN,k,I;
12134  for(eN=0;eN<nElements_global;eN++)
12135  for (k=0;k<nQuadraturePoints_element;k++)
12136  for (I=0;I<nSpace;I++)
12137  f[eN*nQuadraturePoints_element*nSpace +
12138  k*nSpace +
12139  I]
12140  -=
12141  m[eN*nQuadraturePoints_element +
12142  k]
12143  *
12144  xt[eN*nQuadraturePoints_element*3 +
12145  k*3 +
12146  I];
12147 }
12148 
12149 void update_f_movingDomain_constantMass_q(int nElements_global,
12150  int nQuadraturePoints_element,
12151  int nSpace,
12152  double* xt,
12153  double* f)
12154 {
12155  int eN,k,I;
12156  for(eN=0;eN<nElements_global;eN++)
12157  for (k=0;k<nQuadraturePoints_element;k++)
12158  for (I=0;I<nSpace;I++)
12159  f[eN*nQuadraturePoints_element*nSpace +
12160  k*nSpace +
12161  I]
12162  -=
12163  xt[eN*nQuadraturePoints_element*3 +
12164  k*3 +
12165  I];
12166 }
12167 
12168 void update_f_movingDomain_ebq(int nElements_global,
12169  int nElementBoundaries_element,
12170  int nQuadraturePoints_elementBoundary,
12171  int nSpace,
12172  double* xt,
12173  double* m,
12174  double* f)
12175 {
12176  int eN,ebN,k,I;
12177  for(eN=0;eN<nElements_global;eN++)
12178  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
12179  for (k=0;k<nQuadraturePoints_elementBoundary;k++)
12180  for (I=0;I<nSpace;I++)
12181  f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
12182  ebN*nQuadraturePoints_elementBoundary*nSpace+
12183  k*nSpace +
12184  I]
12185  -=
12186  m[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
12187  ebN*nQuadraturePoints_elementBoundary+
12188  k]
12189  *
12190  xt[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*3+
12191  ebN*nQuadraturePoints_elementBoundary*3+
12192  k*3 +
12193  I];
12194 }
12195 
12196 void update_f_movingDomain_constantMass_ebq(int nElements_global,
12197  int nElementBoundaries_element,
12198  int nQuadraturePoints_elementBoundary,
12199  int nSpace,
12200  double* xt,
12201  double* f)
12202 {
12203  int eN,ebN,k,I;
12204  for(eN=0;eN<nElements_global;eN++)
12205  for(ebN=0;ebN<nElementBoundaries_element;ebN++)
12206  for (k=0;k<nQuadraturePoints_elementBoundary;k++)
12207  for (I=0;I<nSpace;I++)
12208  f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
12209  ebN*nQuadraturePoints_elementBoundary*nSpace+
12210  k*nSpace +
12211  I]
12212  -=
12213  xt[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*3+
12214  ebN*nQuadraturePoints_elementBoundary*3+
12215  k*3 +
12216  I];
12217 }
12218 
12219 void updateStress_weak(int nElements_global,
12220  int nQuadraturePoints_element,
12221  int nDOF_test_element,
12222  int nSpace,
12223  double* sigma,
12224  double* grad_w_dV,
12225  double* weak_residual_x,
12226  double* weak_residual_y,
12227  double* weak_residual_z)
12228 {
12229  int eN,i,k,I,J,nSpace2=nSpace*nSpace;
12230  for(eN=0;eN<nElements_global;eN++)
12231  for (i=0;i<nDOF_test_element;i++)
12232  for (k=0;k<nQuadraturePoints_element;k++)
12233  for (J=0;J<nSpace;J++)
12234  {
12235  I=0;
12236  weak_residual_x[eN*nDOF_test_element + i]
12237  +=
12238  sigma[eN*nQuadraturePoints_element*nSpace2+
12239  k*nSpace2 +
12240  I*nSpace+
12241  J]
12242  *
12243  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12244  k*nDOF_test_element*nSpace +
12245  i*nSpace+
12246  J];
12247  I=1;
12248  weak_residual_y[eN*nDOF_test_element + i]
12249  +=
12250  sigma[eN*nQuadraturePoints_element*nSpace2+
12251  k*nSpace2 +
12252  I*nSpace+
12253  J]
12254  *
12255  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12256  k*nDOF_test_element*nSpace +
12257  i*nSpace+
12258  J];
12259  I=2;
12260  weak_residual_z[eN*nDOF_test_element + i]
12261  +=
12262  sigma[eN*nQuadraturePoints_element*nSpace2+
12263  k*nSpace2 +
12264  I*nSpace+
12265  J]
12266  *
12267  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12268  k*nDOF_test_element*nSpace +
12269  i*nSpace+
12270  J];
12271  }
12272 }
12273 
12274 void updateStressJacobian_weak(int nElements_global,
12275  int nQuadraturePoints_element,
12276  int nDOF_trial_element,
12277  int nDOF_test_element,
12278  int nSpace,
12279  double* dsigma_xx,
12280  double* dsigma_xy,
12281  double* dsigma_xz,
12282  double* dsigma_yx,
12283  double* dsigma_yy,
12284  double* dsigma_yz,
12285  double* dsigma_zx,
12286  double* dsigma_zy,
12287  double* dsigma_zz,
12288  double* grad_v,
12289  double* grad_w_dV,
12290  double* jacobian_weak_residual_xx,
12291  double* jacobian_weak_residual_xy,
12292  double* jacobian_weak_residual_xz,
12293  double* jacobian_weak_residual_yx,
12294  double* jacobian_weak_residual_yy,
12295  double* jacobian_weak_residual_yz,
12296  double* jacobian_weak_residual_zx,
12297  double* jacobian_weak_residual_zy,
12298  double* jacobian_weak_residual_zz)
12299 {
12300  int eN,i,j,k,I,J,nDOF_test_X_trial_element=nDOF_test_element*nDOF_trial_element,nSpace2=nSpace*nSpace;
12301  for(eN=0;eN<nElements_global;eN++)
12302  for (i=0;i<nDOF_test_element;i++)
12303  for (k=0;k<nQuadraturePoints_element;k++)
12304  for (j=0;j<nDOF_trial_element;j++)
12305  for (I=0;I<nSpace;I++)
12306  for(J=0;J<nSpace;J++)
12307  {
12308  //x
12309  jacobian_weak_residual_xx[eN*nDOF_test_X_trial_element +
12310  i*nDOF_trial_element +
12311  j]
12312  +=
12313  dsigma_xx[eN*nQuadraturePoints_element*nSpace2 +
12314  k*nSpace2+
12315  I*nSpace+
12316  J]
12317  *
12318  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12319  k*nDOF_trial_element*nSpace +
12320  j*nSpace +
12321  J]
12322  *
12323  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12324  k*nDOF_test_element*nSpace +
12325  i*nSpace +
12326  I];
12327  jacobian_weak_residual_xy[eN*nDOF_test_X_trial_element +
12328  i*nDOF_trial_element +
12329  j]
12330  +=
12331  dsigma_xy[eN*nQuadraturePoints_element*nSpace2 +
12332  k*nSpace2+
12333  I*nSpace+
12334  J]
12335  *
12336  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12337  k*nDOF_trial_element*nSpace +
12338  j*nSpace +
12339  J]
12340  *
12341  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12342  k*nDOF_test_element*nSpace +
12343  i*nSpace +
12344  I];
12345  jacobian_weak_residual_xz[eN*nDOF_test_X_trial_element +
12346  i*nDOF_trial_element +
12347  j]
12348  +=
12349  dsigma_xz[eN*nQuadraturePoints_element*nSpace2 +
12350  k*nSpace2+
12351  I*nSpace+
12352  J]
12353  *
12354  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12355  k*nDOF_trial_element*nSpace +
12356  j*nSpace +
12357  J]
12358  *
12359  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12360  k*nDOF_test_element*nSpace +
12361  i*nSpace +
12362  I];
12363  //y
12364  jacobian_weak_residual_yx[eN*nDOF_test_X_trial_element +
12365  i*nDOF_trial_element +
12366  j]
12367  +=
12368  dsigma_yx[eN*nQuadraturePoints_element*nSpace2 +
12369  k*nSpace2+
12370  I*nSpace+
12371  J]
12372  *
12373  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12374  k*nDOF_trial_element*nSpace +
12375  j*nSpace +
12376  J]
12377  *
12378  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12379  k*nDOF_test_element*nSpace +
12380  i*nSpace +
12381  I];
12382  jacobian_weak_residual_yy[eN*nDOF_test_X_trial_element +
12383  i*nDOF_trial_element +
12384  j]
12385  +=
12386  dsigma_yy[eN*nQuadraturePoints_element*nSpace2 +
12387  k*nSpace2+
12388  I*nSpace+
12389  J]
12390  *
12391  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12392  k*nDOF_trial_element*nSpace +
12393  j*nSpace +
12394  J]
12395  *
12396  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12397  k*nDOF_test_element*nSpace +
12398  i*nSpace +
12399  I];
12400  jacobian_weak_residual_yz[eN*nDOF_test_X_trial_element +
12401  i*nDOF_trial_element +
12402  j]
12403  +=
12404  dsigma_yz[eN*nQuadraturePoints_element*nSpace2 +
12405  k*nSpace2+
12406  I*nSpace+
12407  J]
12408  *
12409  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12410  k*nDOF_trial_element*nSpace +
12411  j*nSpace +
12412  J]
12413  *
12414  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12415  k*nDOF_test_element*nSpace +
12416  i*nSpace +
12417  I];
12418  //z
12419  jacobian_weak_residual_zx[eN*nDOF_test_X_trial_element +
12420  i*nDOF_trial_element +
12421  j]
12422  +=
12423  dsigma_zx[eN*nQuadraturePoints_element*nSpace2 +
12424  k*nSpace2+
12425  I*nSpace+
12426  J]
12427  *
12428  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12429  k*nDOF_trial_element*nSpace +
12430  j*nSpace +
12431  J]
12432  *
12433  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12434  k*nDOF_test_element*nSpace +
12435  i*nSpace +
12436  I];
12437  jacobian_weak_residual_zy[eN*nDOF_test_X_trial_element +
12438  i*nDOF_trial_element +
12439  j]
12440  +=
12441  dsigma_zy[eN*nQuadraturePoints_element*nSpace2 +
12442  k*nSpace2+
12443  I*nSpace+
12444  J]
12445  *
12446  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12447  k*nDOF_trial_element*nSpace +
12448  j*nSpace +
12449  J]
12450  *
12451  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12452  k*nDOF_test_element*nSpace +
12453  i*nSpace +
12454  I];
12455  jacobian_weak_residual_zz[eN*nDOF_test_X_trial_element +
12456  i*nDOF_trial_element +
12457  j]
12458  +=
12459  dsigma_zz[eN*nQuadraturePoints_element*nSpace2 +
12460  k*nSpace2+
12461  I*nSpace+
12462  J]
12463  *
12464  grad_v[eN*nQuadraturePoints_element*nDOF_trial_element*nSpace +
12465  k*nDOF_trial_element*nSpace +
12466  j*nSpace +
12467  J]
12468  *
12469  grad_w_dV[eN*nQuadraturePoints_element*nDOF_test_element*nSpace +
12470  k*nDOF_test_element*nSpace +
12471  i*nSpace +
12472  I];
12473  }
12474 }
12475 
12476 /*load nodal degrees of freedom from an element based set of interpolation values*/
12478  int nDOF_element,
12479  int dim_dof,
12480  const int * l2g,
12481  const int * functional_map_element,
12482  const double * interpolationValues,
12483  double * dofs)
12484 {
12485  int eN,i,j,k;
12486 
12487  // printf("dim_dof = %d, nDOF_element = %d\n",dim_dof,nDOF_element);
12488  for (eN = 0; eN < nElements_global; eN++)
12489  {
12490  for (i=0; i < nDOF_element; i++)
12491  {
12492  k = functional_map_element[i]; /*dof i maps to interp value k locally*/
12493  // printf("eN=%d, k=%d, i=%d\n",eN,k,i);
12494  for (j=0; j < dim_dof; j++)
12495  {
12496  // printf("l2g[%d]= %d \n", eN*nDOF_element+i, l2g[eN*nDOF_element+i]);
12497  // printf("l2g[%d]*%d+%d = %d \n", eN*nDOF_element+i, dim_dof, j, l2g[eN*nDOF_element+i]*dim_dof + j);
12498  // printf("interpolationValues[eN*nDOF_element*dim_dof + k*dim_dof + j] = %.2f \n", interpolationValues[eN*nDOF_element*dim_dof + k*dim_dof + j]);
12499  dofs[l2g[eN*nDOF_element+i]*dim_dof + j] = interpolationValues[eN*nDOF_element*dim_dof + k*dim_dof + j];
12500 
12501  }
12502  }
12503  }
12504 }
updateDiffusion_strong_sd
void updateDiffusion_strong_sd(int nElements_global, int nQuadraturePoints_element, int nSpace, int *rowptr, int *colind, double *da, double *grad_phi, double *grad_u, double *strong_residual)
Definition: femIntegrals.c:3153
setExteriorGlobalElementBoundaryVelocityValues
void setExteriorGlobalElementBoundaryVelocityValues(int updateFluxValues, int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *n, double *vn_in, double *v_out)
Definition: femIntegrals.c:7532
calculateShape_X_weightedShape
void calculateShape_X_weightedShape(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *v, double *w_dV, double *v_X_w_dV)
Calcualte the tensor product of trial and test functions at the quadrature points.
Definition: femIntegrals.c:6537
Y
Double * Y
Definition: Headers.h:48
calculateFiniteElementFunctionGradientTensorValues
void calculateFiniteElementFunctionGradientTensorValues(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nComponents, int nSpace, int *l2g, double *dof, double *grad_v_X_grad_w_dV, double *grad_u_X_grad_w_dV)
Loop over all the quadrature points and calculate the tensor product of the solution gradient with th...
Definition: femIntegrals.c:7124
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_2sided_dense
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_2sided_dense(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian_2sided, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary two-sided Hamiltonflux Jacobians at interi...
Definition: femIntegrals.c:5109
parametricMaps_getValues
void parametricMaps_getValues(int nElements_global, int nQuadraturePoints_element, int nDOF_element, int nSpace_global, double *psi, int *l2g, double *nodeArray, double *xArray)
Definition: femIntegrals.c:580
parametricMaps_getPermutationsGlobalExterior
void parametricMaps_getPermutationsGlobalExterior(int nElementBoundaryQuadraturePoints_elementBoundary, int nSpace_global, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *xiArray, int *permutations)
Definition: femIntegrals.c:496
copyGlobalUnknownsToFreeUnknowns
void copyGlobalUnknownsToFreeUnknowns(int nDOF2set, int offset, int stride, const int *globalDOFids, const int *freeDOFids, const double *u, double *free_u)
Definition: femIntegrals.c:11016
calculateGradShape_X_weightedShapeGlobalExteriorTrace
void calculateGradShape_X_weightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_trial_element, int nDOF_test_element, int nSpace, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *grad_v, double *w_dS, double *grad_v_X_w_dS)
Calculate the tensor product of trial function gradients and test functions at the quadrature points.
Definition: femIntegrals.c:6883
updateNumericalDiffusionJacobian
void updateNumericalDiffusionJacobian(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *numDiff, double *grad_v_X_grad_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:4131
parametricMaps_getJacobianValuesTrace2D
void parametricMaps_getJacobianValuesTrace2D(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1095
updateDiffusion_weak_sd
void updateDiffusion_weak_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, int *rowptr, int *colind, double *a, double *grad_phi, double *grad_w_dV, double *weak_residual)
Definition: femIntegrals.c:2714
parametricMaps_getJacobianValuesGlobalExteriorTrace2D
void parametricMaps_getJacobianValuesGlobalExteriorTrace2D(int nQuadraturePoints_element, int nDOF_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1375
calculateInteriorElementBoundaryVelocities
void calculateInteriorElementBoundaryVelocities(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *m, double *a, double *grad_phi, double *f, double *vAverage, double *vJump, double *mAverage, double *mJump)
Definition: femIntegrals.c:7369
calculateGradShape_X_weightedShape
void calculateGradShape_X_weightedShape(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *grad_v, double *w_dV, double *grad_v_X_w_dV)
Calculate the tensor product of trial function gradients and test functions at the quadrature points.
Definition: femIntegrals.c:6601
copyExteriorElementBoundaryValuesFromElementBoundaryValues
void copyExteriorElementBoundaryValuesFromElementBoundaryValues(int nExteriorElementBoundaries_global, int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, const int *exteriorElementBoundaries, const int *elementBoundaryElements, const int *elementBoundaryLocalElementBoundaries, const double *ebq_val, double *ebqe_val)
copy quantity in an elementBoundary quadrature array to one that sits only on exterior boundaries
Definition: femIntegrals.c:10545
updateGlobalJacobianFromElementJacobian_dense
void updateGlobalJacobianFromElementJacobian_dense(int nElements_global, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementJacobian, double *globalJacobian)
Update the global dense jacobian from the element Jacobians.
Definition: femIntegrals.c:4676
sign
#define sign(x, y)
Definition: jf.h:44
updateInteriorElementBoundaryShockCapturingVelocity
void updateInteriorElementBoundaryShockCapturingVelocity(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nQuadraturePoints_element, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *numDiff, double *grad_u, double *velocity)
Calculate the velocity from shock capturing at interior element boundary quadrature points.
Definition: femIntegrals.c:8176
parametricMaps_getInverseValuesGlobalExteriorTrace
void parametricMaps_getInverseValuesGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace_global, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *inverseJacobian, int *l2g, double *nodeArray, double *xArray, double *xiArray)
Definition: femIntegrals.c:766
calculateVelocityQuadrature_MixedForm
void calculateVelocityQuadrature_MixedForm(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, double *A_inv, double *b, double *v, double *V, double *qv, double *qV)
Definition: femIntegrals.c:9136
TR_ALPHA_EXT
#define TR_ALPHA_EXT
Definition: femIntegrals.c:8653
equivalent_polynomials::XY
const int XY(1)
w
#define w(x)
Definition: jf.h:22
calculateWeightedShapeGlobalExteriorTrace
void calculateWeightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_test_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *dSR, double *sqrt_det_g, double *w, double *w_dS)
Weight the traces of the test function with the element boundary integration weights global exterior ...
Definition: femIntegrals.c:6814
updateReactionJacobian_strong
void updateReactionJacobian_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, double *dr, double *v, double *dstrong_residual)
Loop over all the elements and update the strong from of the residual at the quadrature points with t...
Definition: femIntegrals.c:3805
calculateWeightedShapeTrace
void calculateWeightedShapeTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_test_element, double *dSR, double *sqrt_det_g, double *w, double *w_dS)
Weight the traces of the test function with the element boundary integration weights.
Definition: femIntegrals.c:6672
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_eb_dense
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_eb_dense(int *elementNeighbors, int nElements_global, int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at interior boundaries.
Definition: femIntegrals.c:4908
updateHamiltonian_weak
void updateHamiltonian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *H, double *w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:2306
update_f_movingDomain_ebq
void update_f_movingDomain_ebq(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, double *xt, double *m, double *f)
Definition: femIntegrals.c:12168
estimate_mt_lowmem
void estimate_mt_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *v, double *w_dV, double *elementSpatialResidual, double *mt)
Definition: femIntegrals.c:10497
fluxDomainBoundaryIntegral
double fluxDomainBoundaryIntegral(int nExteriorElementBoundaries, int nElementBoundaries_owned, int nQuadraturePoints_elementBoundary, int *flag, int *exteriorElementBoundariesArray, double *dS, double *nValueArray)
Definition: femIntegrals.c:10731
calculateVelocityProjectionMatrixLDG
void calculateVelocityProjectionMatrixLDG(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *vXw_dV, double *A_inv)
Definition: femIntegrals.c:10109
updateDiffusion2_adjoint_sd
void updateDiffusion2_adjoint_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, int *rowptr, int *colind, double *a, double *Hess_w_dV, double *Lstar_w_dV)
Definition: femIntegrals.c:3613
parametricMaps_getJacobianValuesGlobalExteriorTrace2D_movingDomain
void parametricMaps_getJacobianValuesGlobalExteriorTrace2D_movingDomain(int nQuadraturePoints_element, int nDOF_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *xtArray, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1455
updateDiffusion2_strong
void updateDiffusion2_strong(int nElements_global, int nQuadraturePoints_element, int nSpace, double *a, double *Hess_phi, double *strong_residual)
Definition: femIntegrals.c:3413
copyLeftElementBoundaryInfo_movingDomain
void copyLeftElementBoundaryInfo_movingDomain(int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nExteriorElementBoundaries_global, int nInteriorElementBoundaries_global, int *elementBoundaryElementsArray, int *elementBoundaryLocalElementBoundariesArray, int *exteriorElementBoundariesArray, int *interiorElementBoundariesArray, double *xt)
Definition: femIntegrals.c:208
updateGlobalResidualFromElementResidual
void updateGlobalResidualFromElementResidual(int nElements_global, int nDOF_test_element, int offset_r, int stride_r, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, double *elementResidual, double *globalResidual)
Update the global residuals from the element residuals.
Definition: femIntegrals.c:4651
calculateConservationResidual
void calculateConservationResidual(int nElements_global, int nDOF_test_element, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, double *n, double *dS_u, double *elementResidual, double *velocity, double *conservationResidual)
calculate mass conservation error as
Definition: femIntegrals.c:8397
calculateIntegrationWeights
void calculateIntegrationWeights(int nElements_global, int nQuadraturePoints_element, double *abs_det_J, double *referenceWeights, double *weights)
Calculate the physical space integration weights from the reference element weights and Jacobian dete...
Definition: femIntegrals.c:6921
computeC0P1InterpolantNCP1
void computeC0P1InterpolantNCP1(int nElements_global, int nNodes_global, int nNodes_element, int nDOF_element, int dim_dof, const int *elementNodesArray, const int *nodeElementOffsets, const int *nodeElementsArray, const int *l2g, const double *dof, double *nodalAverage)
Definition: femIntegrals.c:10857
equivalent_polynomials::YY
const int YY(4)
updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_dense
void updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_dense(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, int *isDOFBoundary, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:11358
updateExteriorElementBoundaryShockCapturingVelocity
void updateExteriorElementBoundaryShockCapturingVelocity(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nQuadraturePoints_element, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *numDiff, double *grad_u, double *velocity)
Calculate the shock capturing flux at exterior element boundary quadrature points.
Definition: femIntegrals.c:8228
calculateExteriorElementBoundaryStress2D
void calculateExteriorElementBoundaryStress2D(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int *elementBoundaryMaterialTypes, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *p, double *mom_flux_vec_u, double *mom_flux_vec_v, double *dS, double *n, double *F)
Definition: femIntegrals.c:4551
updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_dense_sd
void updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_dense_sd(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:11577
calculateExteriorNumericalTrace_Potential
void calculateExteriorNumericalTrace_Potential(int *isDOFBoundary, int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *phi_bc, double *phi, double *dphi, double *phi_trace, double *dphi_trace_left)
Calculate the trace of the potential on interior element boundaries. Use the arithmetic average.
Definition: femIntegrals.c:8707
updateAdvection_adjoint
void updateAdvection_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *df, double *grad_w_dV, double *Lstar_w_dV)
Loop over all the elements and update the linearized adjoint applied to the weighted test functions w...
Definition: femIntegrals.c:2247
calculateGlobalExteriorElementBoundaryIntegrationWeights
void calculateGlobalExteriorElementBoundaryIntegrationWeights(int nQuadraturePoints_elementBoundary, int nExteriorElementBoundaries_global, double *sqrt_det_g, double *referenceWeights, double *weights)
Definition: femIntegrals.c:6961
updateHamiltonianJacobian_strong
void updateHamiltonianJacobian_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, double *dH, double *grad_v, double *dstrong_residual)
Loop over all the elements and update the Jacobian of the strong form of the residual with the advect...
Definition: femIntegrals.c:2508
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_eb_CSR
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_eb_CSR(int *elementNeighbors, int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_eNebN_ru, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at interior boundaries.
Definition: femIntegrals.c:5902
parametricMaps_getPermutations
void parametricMaps_getPermutations(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nSpace_global, double *xiArray, int *permutations)
Definition: femIntegrals.c:453
updateNumericalDiffusionJacobian_lowmem
void updateNumericalDiffusionJacobian_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *numDiff, double *grad_v, double *grad_w_dV, double *jacobian_weak_residual)
Definition: femIntegrals.c:4161
updatePotential_MixedForm_weak_gwvd
void updatePotential_MixedForm_weak_gwvd(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double epsilon, double *phi, double *w_dV, double *grad_w_dV, double *b, double *mf)
Definition: femIntegrals.c:9066
f
Double f
Definition: Headers.h:64
checkGlobalElementBoundaryAndExteriorElementBoundaryArraysSame
int checkGlobalElementBoundaryAndExteriorElementBoundaryArraysSame(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, double tolerance, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, const double *ebq_global_val, const double *ebqe_val, int *firstBadIndex)
Definition: femIntegrals.c:10959
updateMassJacobian_weak_lowmem
void updateMassJacobian_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *dmt, double *v, double *w_dV, double *jacobian_weak_residual)
Definition: femIntegrals.c:1785
updateGlobalJacobianFromElementJacobian_eb_CSR
void updateGlobalJacobianFromElementJacobian_eb_CSR(int *elementNeighbors, int nElements_global, int nElementBoundaries_element, int nDOF_test_element, int nDOF_trial_element, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double *elementJacobian_eb, double *globalJacobian)
Update the global CSR jacobian from the element Jacobians.
Definition: femIntegrals.c:5587
updateExteriorElementBoundaryDiffusionAdjoint
void updateExteriorElementBoundaryDiffusionAdjoint(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *isDOFBoundary, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double sigma, double *u, double *ub, double *n, double *a, double *grad_w, double *dS, double *residual)
Definition: femIntegrals.c:11118
updateInteriorElementBoundary_MixedForm_weakJacobian
void updateInteriorElementBoundary_MixedForm_weakJacobian(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *n, double *dphi_trace_left, double *dphi_trace_right, double *v, double *w_dS, double *db, double *db_eb)
Update the element boundary flux on interior element boundaries.
Definition: femIntegrals.c:8818
updateDiffusion_adjoint_sd
void updateDiffusion_adjoint_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, int *rowptr, int *colind, double *da, double *grad_phi, double *grad_w_dV, double *Lstar_w_dV)
Definition: femIntegrals.c:3378
updateInteriorElementBoundary_MixedForm_weak
void updateInteriorElementBoundary_MixedForm_weak(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *n, double *phi_trace, double *w_dS, double *b)
Update the element boundary flux on interior element boundaries.
Definition: femIntegrals.c:8754
parametricMaps_getInverseValues
void parametricMaps_getInverseValues(int nElements_global, int nQuadraturePoints_element, int nDOF_element, int nSpace_global, double *inverseJacobian, int *l2g, double *nodeArray, double *xArray, double *xiArray)
Definition: femIntegrals.c:683
updateAdvectionJacobian_strong
void updateAdvectionJacobian_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, double *df, double *grad_v, double *dstrong_residual)
Loop over all the elements and update the Jacobian of the strong form of the residual with the advect...
Definition: femIntegrals.c:2190
updateGlobalExteriorElementBoundaryShockCapturingVelocity
void updateGlobalExteriorElementBoundaryShockCapturingVelocity(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *numDiff, double *grad_u, double *velocity)
Calculate the shock capturing flux at exterior element boundary quadrature points.
Definition: femIntegrals.c:8270
updateDiffusion_weak
void updateDiffusion_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *a, double *grad_phi_X_grad_w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:2634
s
Double s
Definition: Headers.h:84
equivalent_polynomials::XX
const int XX(0)
calculateFiniteElementFunctionValues
void calculateFiniteElementFunctionValues(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nComponents, int *l2g, double *dof, double *v, double *u)
Calculate the values of a multicomponent finite element function at the quadrature points from the de...
Definition: femIntegrals.c:6982
updateDiffusionJacobian_MixedForm_weak_sd
void updateDiffusionJacobian_MixedForm_weak_sd(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, int *rowptr, int *colind, double *a, double *da, double *qV, double *qDV, double *qDV_eb, double *grad_w_dV, double *v, double *jacobian_weak_residual, double *jacobian_weak_residual_eb)
Definition: femIntegrals.c:10343
updateDiffusion_MixedForm_weak
void updateDiffusion_MixedForm_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *a, double *qV, double *grad_w_dV, double *weak_residual)
Definition: femIntegrals.c:10137
calculateInteriorNumericalTrace_Potential
void calculateInteriorNumericalTrace_Potential(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *phi, double *dphi, double *phi_trace, double *dphi_trace_left, double *dphi_trace_right)
Calculate the trace of the potential on interior element boundaries. Use the arithmetic average.
Definition: femIntegrals.c:8658
updateInteriorElementBoundaryDiffusionAdjoint
void updateInteriorElementBoundaryDiffusionAdjoint(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double sigma, double *u, double *n, double *a, double *grad_w, double *dS, double *residual)
Definition: femIntegrals.c:11033
updateNumericalDiffusion_lowmem
void updateNumericalDiffusion_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *numDiff, double *grad_u, double *grad_w_dV, double *weak_residual)
Definition: femIntegrals.c:4059
parametricMaps_getJacobianValuesTrace3D
void parametricMaps_getJacobianValuesTrace3D(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:972
calculateConservationResidualDG
void calculateConservationResidualDG(int nElements_global, int nDOF_test_element, double *elementResidual, double *conservationResidual)
Definition: femIntegrals.c:8376
updateExteriorElementBoundaryDiffusiveVelocity
void updateExteriorElementBoundaryDiffusiveVelocity(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Calculate the diffusive flux at exterior element boundary quadrature points.
Definition: femIntegrals.c:7911
calculateFiniteElementFunctionGradientValuesGlobalExteriorTrace
void calculateFiniteElementFunctionGradientValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary, int nDOF_trial_element, int nComponents, int nSpace, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, int *l2g, double *dof, double *grad_v, double *grad_u)
Definition: femIntegrals.c:7271
updateSubgridErrorJacobian
void updateSubgridErrorJacobian(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *derror, double *Lstar_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:3969
updateGlobalExteriorElementBoundaryDiffusiveVelocity_sd
void updateGlobalExteriorElementBoundaryDiffusiveVelocity_sd(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *rowptr, int *colind, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Definition: femIntegrals.c:8028
parametricFiniteElementSpace_getGradientValuesTrace
void parametricFiniteElementSpace_getGradientValuesTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace_global, double *grad_psi, int *permutations, double *inverseJacobianArray, double *grad_vArray)
Definition: femIntegrals.c:378
L
Double L
Definition: Headers.h:72
calculateFiniteElementFunctionGradientValues
void calculateFiniteElementFunctionGradientValues(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nComponents, int nSpace, int *l2g, double *dof, double *grad_v, double *grad_u)
Calculate the gradient values of a multicomponent finite element function at the quadrature points fr...
Definition: femIntegrals.c:7013
parametricFiniteElementSpace_getValuesGlobalExteriorTrace
void parametricFiniteElementSpace_getValuesGlobalExteriorTrace(int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *psi, double *vArray)
Definition: femIntegrals.c:283
calculateVectorScalarProduct
void calculateVectorScalarProduct(int nElements_global, int nQuadraturePoints_element, int nSpace, double *v, double *s, double *vResult)
Calculate the product of a vector and a scalar at the quadrature points.
Definition: femIntegrals.c:4220
equivalent_polynomials::ZZ
const int ZZ(8)
parametricFiniteElementSpace_getValuesTrace
void parametricFiniteElementSpace_getValuesTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, double *psi, int *permutations, double *vArray)
Definition: femIntegrals.c:259
calculateFiniteElementFunctionHessianValues
void calculateFiniteElementFunctionHessianValues(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nComponents, int nSpace, int *l2g, double *dof, double *Hessian_v, double *Hessian_u)
Definition: femIntegrals.c:7045
n
Int n
Definition: Headers.h:28
updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_eb_CSR
void updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_eb_CSR(int *elementNeighbors, int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_eNebN_ru, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at exterior boundaries only d...
Definition: femIntegrals.c:6187
updateExteriorElementBoundaryFlux
void updateExteriorElementBoundaryFlux(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *flux, double *w_dS, double *residual)
Update the element boundary flux on exterior element boundaries.
Definition: femIntegrals.c:4327
calculateExteriorElementBoundaryStress3D
void calculateExteriorElementBoundaryStress3D(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int *elementBoundaryMaterialTypes, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *p, double *mom_flux_vec_u, double *mom_flux_vec_v, double *mom_flux_vec_w, double *dS, double *n, double *F)
Definition: femIntegrals.c:4470
updateDiffusionJacobian_weak_lowmem
void updateDiffusionJacobian_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, int *l2g, double *a, double *da, double *grad_phi, double *grad_w_dV, double *dphi, double *v, double *grad_v, double *jacobian_weak_residual)
Definition: femIntegrals.c:2890
df
double df(double C, double b, double a, int q, int r)
Definition: analyticalSolutions.c:2209
phi
Double phi
Definition: Headers.h:76
parametricMaps_getJacobianValuesTrace1D
void parametricMaps_getJacobianValuesTrace1D(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1260
updateGlobalExteriorElementBoundaryStressFlux
void updateGlobalExteriorElementBoundaryStressFlux(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *stressFlux, double *w_dS, double *residual)
Definition: femIntegrals.c:4392
calculateCFLADR2speeds
void calculateCFLADR2speeds(int nElements_global, int nQuadraturePoints_element, int nSpace, double *elementDiameter, double *dm, double *df1, double *df2, double *cfl)
Definition: femIntegrals.c:7752
calculateVelocityQuadrature_MixedForm2_vdof_sd
void calculateVelocityQuadrature_MixedForm2_vdof_sd(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, const int *rowptr, const int *colind, double *qa, double *qw_dV, double *b, double *v, double *V, double *qv, double *qV, double *vel_dofs)
Definition: femIntegrals.c:9426
updateMassJacobian_strong
void updateMassJacobian_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, double *dmt, double *v, double *dstrong_residual)
Loop over all the elements and update the Jacobian of the strong from of the residual at the quadratu...
Definition: femIntegrals.c:1873
loadBoundaryFluxIntoGlobalElementBoundaryVelocity
void loadBoundaryFluxIntoGlobalElementBoundaryVelocity(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *fluxElementBoundaries, double *normal, double *flux, double updateCoef, double *velocity)
Definition: femIntegrals.c:8606
calculateTensorScalarProduct
void calculateTensorScalarProduct(int nElements_global, int nQuadraturePoints_element, int nSpace, double *t, double *s, double *tResult)
Calculate the product of a tensor and scalar at the quadrature points.
Definition: femIntegrals.c:4246
updateGlobalJacobianFromElementJacobian_eb_dense
void updateGlobalJacobianFromElementJacobian_eb_dense(int *elementNeighbors, int nElements_global, int nElementBoundaries_element, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementJacobian_eb, double *globalJacobian)
Update the global dense jacobian from the element Jacobians.
Definition: femIntegrals.c:4720
updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_dense_sd
void updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_dense_sd(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, int *isDOFBoundary, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:11768
copyLeftElementBoundaryInfo
void copyLeftElementBoundaryInfo(int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nSpace_global, int nExteriorElementBoundaries_global, int nInteriorElementBoundaries_global, int *elementBoundaryElementsArray, int *elementBoundaryLocalElementBoundariesArray, int *exteriorElementBoundariesArray, int *interiorElementBoundariesArray, double *x, double *n, double *xg, double *ng)
Definition: femIntegrals.c:20
updateSubgridError
void updateSubgridError(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *error, double *Lstar_w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:3909
copyExteriorElementBoundaryValuesToElementBoundaryValues
void copyExteriorElementBoundaryValuesToElementBoundaryValues(int nExteriorElementBoundaries_global, int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, const int *exteriorElementBoundaries, const int *elementBoundaryElements, const int *elementBoundaryLocalElementBoundaries, const double *ebqe_val, double *ebq_val)
copy quantity that sits only on exterior boundaries into an elementBoundary quadrature array
Definition: femIntegrals.c:10578
accumulateExteriorElementPressureIntegrals
void accumulateExteriorElementPressureIntegrals(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int *elementBoundaryMaterialTypes, int *exteriorElementBoundaries, double *p, double *dS, double *P, double *boundaryMeasure)
Definition: femIntegrals.c:4618
updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_dense
void updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_dense(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:11174
checkElementBoundaryAndExteriorElementBoundaryArraysSame
int checkElementBoundaryAndExteriorElementBoundaryArraysSame(int nElementBoundaries_element, int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, double tolerance, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, const double *ebq_val, const double *ebqe_val, int *firstBadIndex)
Definition: femIntegrals.c:10913
femIntegrals.h
A library of functions for computing the discrete finite element formulations.
updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_CSR
void updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_CSR(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:5845
parametricFiniteElementSpace_getGradientValuesGlobalExteriorTrace
void parametricFiniteElementSpace_getGradientValuesGlobalExteriorTrace(int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace_global, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *grad_psi, double *inverseJacobianArray, double *grad_vArray)
Definition: femIntegrals.c:414
calculateFiniteElementFunctionGradientValuesTrace
void calculateFiniteElementFunctionGradientValuesTrace(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_trial_element, int nComponents, int nSpace, int *l2g, double *dof, double *grad_v, double *grad_u)
Calculate the gradients of a multi-component finite element function at the element boundary quadratu...
Definition: femIntegrals.c:7202
updateExteriorElementBoundary_MixedForm_weakJacobian
void updateExteriorElementBoundary_MixedForm_weakJacobian(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *n, double *dphi_trace_left, double *v, double *w_dS, double *db, double *db_eb)
Update the element boundary flux on interior element boundaries.
Definition: femIntegrals.c:8988
updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_CSR_sd
void updateGlobalJacobianFromInteriorElementBoundaryDiffusionAdjoint_CSR_sd(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:11844
dgetrf_
int dgetrf_(int *m, int *n, double *a, int *lda, int *ipiv, int *info)
dgetri_
int dgetri_(int *N, double *A, int *LDA, int *IPIV, double *WORK, int *LWORK, int *INFO)
updateExteriorElementBoundaryAdvectiveVelocity
void updateExteriorElementBoundaryAdvectiveVelocity(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *f, double *velocity)
Update the advective flux at exterior element boundaries.
Definition: femIntegrals.c:8113
calculateWeightedShapeHessians
void calculateWeightedShapeHessians(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *dVR, double *abs_det_jac, double *Hess_w, double *Hess_w_dV)
Definition: femIntegrals.c:6501
num
Int num
Definition: Headers.h:32
updateInteriorElementBoundaryDiffusionAdjoint_sd
void updateInteriorElementBoundaryDiffusionAdjoint_sd(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *rowptr, int *colind, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double sigma, double *u, double *n, double *a, double *grad_w, double *dS, double *residual)
Definition: femIntegrals.c:11433
H
Double H
Definition: Headers.h:65
updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_eb_dense
void updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_eb_dense(int *elementNeighbors, int nElements_global, int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at exterior boundaries only...
Definition: femIntegrals.c:5399
updateDiffusionJacobian_MixedForm_weak
void updateDiffusionJacobian_MixedForm_weak(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *a, double *da, double *qV, double *qDV, double *qDV_eb, double *grad_w_dV, double *v, double *jacobian_weak_residual, double *jacobian_weak_residual_eb)
Definition: femIntegrals.c:10231
updateReaction_strong
void updateReaction_strong(int nElements_global, int nQuadraturePoints_element, double *r, double *strong_residual)
Loop over all the elements and update the strong from of the residual at the quadrature points with t...
Definition: femIntegrals.c:3771
updateInteriorElementBoundaryDiffusiveVelocity_sd
void updateInteriorElementBoundaryDiffusiveVelocity_sd(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *rowptr, int *colind, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Definition: femIntegrals.c:7855
updateHamiltonian_adjoint
void updateHamiltonian_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *dH, double *grad_w_dV, double *Lstar_w_dV)
Loop over all the elements and update the linearized adjoint applied to the weighted test functions w...
Definition: femIntegrals.c:2566
v
Double v
Definition: Headers.h:95
updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_CSR_sd
void updateGlobalJacobianFromExteriorElementBoundaryDiffusionAdjoint_CSR_sd(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, int *isDOFBoundary, double sigma, double *v, double *n, double *a, double *grad_w, double *dS, double *jac)
Definition: femIntegrals.c:12044
update_f_movingDomain_constantMass_q
void update_f_movingDomain_constantMass_q(int nElements_global, int nQuadraturePoints_element, int nSpace, double *xt, double *f)
Definition: femIntegrals.c:12149
calculateShape_X_weightedShapeGlobalExteriorTrace
void calculateShape_X_weightedShapeGlobalExteriorTrace(int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_trial_element, int nDOF_test_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *v, double *w_dS, double *v_X_w_dS)
Calcualte the tensor product of trial and test functions at the quadrature points global exterior bou...
Definition: femIntegrals.c:6850
parametricMaps_getJacobianValuesGlobalExteriorTrace1D
void parametricMaps_getJacobianValuesGlobalExteriorTrace1D(int nQuadraturePoints_element, int nDOF_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1317
computeC0P1InterpolantDGP0
void computeC0P1InterpolantDGP0(int nElements_global, int nNodes_global, int nNodes_element, int nDOF_element, int dim_dof, const int *elementNodesArray, const int *nodeElementOffsets, const int *nodeElementsArray, const int *l2g, const double *dof, double *nodalAverage)
Definition: femIntegrals.c:10823
updateDiffusion2_strong_sd
void updateDiffusion2_strong_sd(int nElements_global, int nQuadraturePoints_element, int nSpace, int *rowptr, int *colind, double *a, double *Hess_phi, double *strong_residual)
Definition: femIntegrals.c:3441
parametricMaps_getValuesTrace
void parametricMaps_getValuesTrace(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_element, int nSpace_global, double *psi, int *l2g, double *nodeArray, double *xArray)
Definition: femIntegrals.c:610
parametricMaps_getInverseValuesTrace
void parametricMaps_getInverseValuesTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace_global, double *inverseJacobian, int *l2g, double *nodeArray, double *xArray, double *xiArray)
Definition: femIntegrals.c:722
updateDiffusion_adjoint
void updateDiffusion_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *da, double *grad_phi, double *grad_w_dV, double *Lstar_w_dV)
Loop over all the elements and update the linearized adjoint applied to the weighted test function wi...
Definition: femIntegrals.c:3344
updateDiffusionJacobian2_strong_sd
void updateDiffusionJacobian2_strong_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int *l2g, double *a, double *da, double *v, double *Hess_phi, double *dphi, double *Hess_v, double *dstrong_residual)
Definition: femIntegrals.c:3525
updatePotential_MixedForm_weakJacobian
void updatePotential_MixedForm_weakJacobian(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *dphi, double *v, double *grad_w_dV, double *db)
Definition: femIntegrals.c:9103
updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_dense
void updateGlobalJacobianFromGlobalExteriorElementBoundaryFluxJacobian_dense(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:5486
updateDiffusionJacobian2_strong
void updateDiffusionJacobian2_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, int *l2g, double *a, double *da, double *v, double *Hess_phi, double *dphi, double *Hess_v, double *dstrong_residual)
Definition: femIntegrals.c:3470
calculateFiniteElementFunctionValuesTrace
void calculateFiniteElementFunctionValuesTrace(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_trial_element, int nComponents, int *l2g, double *dof, double *v, double *u)
Calculate the values of a multi-component finite element function at element boundary quadrature poin...
Definition: femIntegrals.c:7167
calculateElementBoundaryIntegrationWeights
void calculateElementBoundaryIntegrationWeights(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, double *sqrt_det_g, double *referenceWeights, double *weights)
Definition: femIntegrals.c:6939
parametricFiniteElementSpace_getGradientValues
void parametricFiniteElementSpace_getGradientValues(int nElements_global, int nQuadraturePoints_element, int nDOF_element, int nSpace_global, double *grad_psi, double *inverseJacobianArray, double *grad_vArray)
Definition: femIntegrals.c:311
updateReaction_adjoint
void updateReaction_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *dr, double *w_dV, double *Lstar_w_dV)
Loop over all the elements and update the linearized adjoint, applied to the weighted test functions,...
Definition: femIntegrals.c:3852
updateDiffusionJacobian_strong
void updateDiffusionJacobian_strong(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, int *l2g, double *da, double *dphi, double *grad_phi, double *grad_u, double *grad_v, double *dstrong_residual)
Loop over all the elements and update the strong form of the residual with the diffusion term at the ...
Definition: femIntegrals.c:3207
updateAdvection_strong
void updateAdvection_strong(int nElements_global, int nQuadraturePoints_element, int nSpace, double *df, double *grad_u, double *strong_residual)
Loop over all the elements and update the strong form of the residual with the advection term.
Definition: femIntegrals.c:2143
updateNumericalDiffusion
void updateNumericalDiffusion(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *numDiff, double *grad_u_X_grad_w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:4034
pe
Double pe
Definition: Headers.h:75
parametricMaps_getJacobianValues1D
void parametricMaps_getJacobianValues1D(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, int *l2g, double *nodeArray, double *jacobianArray, double *jacobianDeterminantArray, double *jacobianInverseArray)
Definition: femIntegrals.c:928
getPermutationsGlobal
void getPermutationsGlobal(int nElementBoundaries_global, int nElementBoundaryQuadraturePoints_elementBoundary, double *xArray, double *xArrayNew, int *permutations)
Definition: femIntegrals.c:542
u
Double u
Definition: Headers.h:89
calculateVelocityQuadrature_MixedForm2
void calculateVelocityQuadrature_MixedForm2(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, double *qa, double *qw_dV, double *b, double *v, double *V, double *qv, double *qV)
Definition: femIntegrals.c:9210
updateDiffusionJacobian_strong_sd
void updateDiffusionJacobian_strong_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nSpace, int *rowptr, int *colind, int *l2g, double *da, double *dphi, double *grad_phi, double *grad_u, double *grad_v, double *dstrong_residual)
Definition: femIntegrals.c:3258
updateMass_adjoint
void updateMass_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *dmt, double *w_dV, double *Lstar_w_dV)
Loop over all the elements and update the linearized adjoint, applied to the weighted test functions,...
Definition: femIntegrals.c:1921
calculateWeightedPiolaShapeTrace
void calculateWeightedPiolaShapeTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_test_element, double *dSR, double *sqrt_det_g, double *w, double *w_dS)
Definition: femIntegrals.c:6704
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_dense
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_dense(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at interior boundaries.
Definition: femIntegrals.c:4778
fluxDomainBoundaryIntegralFromVector
double fluxDomainBoundaryIntegralFromVector(int nExteriorElementBoundaries, int nElementBoundaries_owned, int nQuadraturePoints_elementBoundary, int nSpace, int *flag, int *exteriorElementBoundaries, double *dS, double *nValueArray, double *normal)
Definition: femIntegrals.c:10756
calculateVelocityQuadrature_MixedForm2_Jacobian
void calculateVelocityQuadrature_MixedForm2_Jacobian(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, double *qa, double *qw_dV, double *db, double *db_eb, double *v, double *DV, double *DV_eb, double *qv, double *qDV, double *qDV_eb)
Definition: femIntegrals.c:9723
updateGlobalExteriorElementBoundaryAdvectiveVelocity
void updateGlobalExteriorElementBoundaryAdvectiveVelocity(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *f, double *velocity)
Update the advective flux at exterior element boundaries.
Definition: femIntegrals.c:8147
calculateExteriorElementBoundaryAverageVelocity
void calculateExteriorElementBoundaryAverageVelocity(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *v, double *vAverage)
Definition: femIntegrals.c:8334
xt
Definition: AddedMass.cpp:7
equivalent_polynomials::YZ
const int YZ(5)
projectFromNodalInterpolationConditions
void projectFromNodalInterpolationConditions(int nElements_global, int nDOF_element, int dim_dof, const int *l2g, const int *functional_map_element, const double *interpolationValues, double *dofs)
Definition: femIntegrals.c:12477
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_2sided_CSR
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_2sided_CSR(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double *elementBoundaryFluxJacobian_2sided, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary two-sided Hamiltonian flux Jacobians at inte...
Definition: femIntegrals.c:6265
parametricMaps_getJacobianValues3D
void parametricMaps_getJacobianValues3D(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, int *l2g, double *nodeArray, double *jacobianArray, double *jacobianDeterminantArray, double *jacobianInverseArray)
Definition: femIntegrals.c:814
calculateCFLADR
void calculateCFLADR(int nElements_global, int nQuadraturePoints_element, int nSpace, double *elementDiameter, double *dm, double *df, double *cfl)
Definition: femIntegrals.c:7716
copyExteriorElementBoundaryValuesFromGlobalElementBoundaryValues
void copyExteriorElementBoundaryValuesFromGlobalElementBoundaryValues(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, const int *exteriorElementBoundaries, const int *elementBoundaryElements, const int *elementBoundaryLocalElementBoundaries, const double *ebq_global_val, double *ebqe_val)
copy quantity that sits only on exterior boundaries from a global elementBoundary quadrature array
Definition: femIntegrals.c:10641
updateAdvectionJacobian_weak
void updateAdvectionJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *df, double *v_X_grad_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:2055
updateAdvection_weak
void updateAdvection_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *f, double *grad_w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:1985
updateDiffusion_weak_lowmem
void updateDiffusion_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *a, double *grad_phi, double *grad_w_dV, double *weak_residual)
Definition: femIntegrals.c:2662
calculateFiniteElementFunctionValuesGlobalExteriorTrace
void calculateFiniteElementFunctionValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary, int nDOF_trial_element, int nComponents, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, int *l2g, double *dof, double *v, double *u)
Definition: femIntegrals.c:7236
calculateVelocityQuadrature_MixedForm2_sd
void calculateVelocityQuadrature_MixedForm2_sd(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, const int *rowptr, const int *colind, double *qa, double *qw_dV, double *b, double *v, double *V, double *qv, double *qV)
Definition: femIntegrals.c:9312
updateMassJacobian_weak
void updateMassJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *dmt, double *v_X_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:1759
parametricMaps_getJacobianValuesGlobalExteriorTrace3D
void parametricMaps_getJacobianValuesGlobalExteriorTrace3D(int nQuadraturePoints_element, int nDOF_element, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1542
calculateWeightedShape
void calculateWeightedShape(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *dVR, double *abs_det_jac, double *w, double *w_dV)
Weight the test function with the integration weights.
Definition: femIntegrals.c:6413
calculateFlowVelocity
void calculateFlowVelocity(int nElements_global, int nQuadraturePoints_element, int nSpace, double *f, double *a, double *grad_phi, double *v)
Calculate the total (advective + diffusive) flow velocity.
Definition: femIntegrals.c:7314
updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_CSR
void updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_CSR(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:5785
updateStress_weak
void updateStress_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *sigma, double *grad_w_dV, double *weak_residual_x, double *weak_residual_y, double *weak_residual_z)
Definition: femIntegrals.c:12219
updateInteriorElementBoundaryFlux
void updateInteriorElementBoundaryFlux(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *flux, double *w_dS, double *residual)
Update the element boundary flux on interior element boundaries.
Definition: femIntegrals.c:4280
updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_CSR
void updateGlobalJacobianFromInteriorElementBoundaryFluxJacobian_CSR(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_ru, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at interior boundaries.
Definition: femIntegrals.c:5643
calculateVelocityQuadrature_MixedForm2_Jacobian_sd
void calculateVelocityQuadrature_MixedForm2_Jacobian_sd(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, const int *rowptr, const int *colind, double *qa, double *qw_dV, double *db, double *db_eb, double *v, double *DV, double *DV_eb, double *qv, double *qDV, double *qDV_eb)
Definition: femIntegrals.c:9911
estimate_mt
void estimate_mt(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *v, double *vXw_dV, double *elementSpatialResidual, double *mt)
Definition: femIntegrals.c:10454
copyGlobalElementBoundaryInfo
void copyGlobalElementBoundaryInfo(int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nSpace_global, int nExteriorElementBoundaries_global, int nInteriorElementBoundaries_global, int *elementBoundaryElementsArray, int *elementBoundaryLocalElementBoundariesArray, int *exteriorElementBoundariesArray, int *interiorElementBoundariesArray, double *x, double *n, double *ebqe_x, double *ebqe_n, double *xg, double *ng)
Definition: femIntegrals.c:103
parametricMaps_getJacobianValues2D
void parametricMaps_getJacobianValues2D(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *grad_psi, int *l2g, double *nodeArray, double *jacobianArray, double *jacobianDeterminantArray, double *jacobianInverseArray)
Definition: femIntegrals.c:877
copyGlobalElementBoundaryVelocityToElementBoundary
void copyGlobalElementBoundaryVelocityToElementBoundary(int nElements_global, int nInteriorElementBoundaries_global, int nExteriorElementBoundaries_global, int nElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *interiorElementBoundaries, int *exteriorElementBoundaries, int *elementBoundaryElementsArray, int *elementBoundaryLocalElementBoundariesArray, double *velocityBoundary_global, double *velocityBoundary_element)
Definition: femIntegrals.c:8542
calculateInteriorElementBoundaryAverageVelocity
void calculateInteriorElementBoundaryAverageVelocity(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *v, double *vAverage)
Definition: femIntegrals.c:8299
scalarSmoothedHeavisideDomainIntegral
double scalarSmoothedHeavisideDomainIntegral(int nElements, int nQuadraturePoints_element, double epsFact, double *elementDiameter, double *dV, double *nValueArray)
Definition: femIntegrals.c:10702
updateHamiltonian_strong
void updateHamiltonian_strong(int nElements_global, int nQuadraturePoints_element, int nSpace, double *dH, double *grad_u, double *strong_residual)
Loop over all the elements and update the strong form of the residual with the advection term.
Definition: femIntegrals.c:2462
updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_eb_dense
void updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_eb_dense(int *elementNeighbors, int nElements_global, int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:5309
calculateWeightedShapeGradients
void calculateWeightedShapeGradients(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *dVR, double *abs_det_jac, double *grad_w, double *grad_w_dV)
Weight the test function with the integration weights.
Definition: femIntegrals.c:6442
updatePotential_MixedForm_weak
void updatePotential_MixedForm_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *phi, double *grad_w_dV, double *b)
Definition: femIntegrals.c:9040
calculateDimensionlessNumbersADR_sd
void calculateDimensionlessNumbersADR_sd(int nElements_global, int nQuadraturePoints_element, int nSpace, int computeDiffusiveTimeStepLimit, int *rowptr, int *colind, double *elementDiameter, double *df, double *a, double *dphi, double *dr, double *dmt, double *pe, double *cfl)
Definition: femIntegrals.c:7647
updateStressJacobian_weak
void updateStressJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *dsigma_xx, double *dsigma_xy, double *dsigma_xz, double *dsigma_yx, double *dsigma_yy, double *dsigma_yz, double *dsigma_zx, double *dsigma_zy, double *dsigma_zz, double *grad_v, double *grad_w_dV, double *jacobian_weak_residual_xx, double *jacobian_weak_residual_xy, double *jacobian_weak_residual_xz, double *jacobian_weak_residual_yx, double *jacobian_weak_residual_yy, double *jacobian_weak_residual_yz, double *jacobian_weak_residual_zx, double *jacobian_weak_residual_zy, double *jacobian_weak_residual_zz)
Definition: femIntegrals.c:12274
updateAddJacobian_CSR
void updateAddJacobian_CSR(int jacIndex, double val, double *jac)
Update a single element of the Jacobian.
Definition: femIntegrals.c:7353
update_f_movingDomain_constantMass_ebq
void update_f_movingDomain_constantMass_ebq(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, double *xt, double *f)
Definition: femIntegrals.c:12196
dgetrs_
int dgetrs_(char *trans, int *n, int *nrhs, double *a, int *lda, int *ipiv, double *b, int *ldb, int *info)
scalarHeavisideDomainIntegral
double scalarHeavisideDomainIntegral(int nElements, int nQuadraturePoints_element, double *dV, double *nValueArray)
Definition: femIntegrals.c:10684
calculateGradShape_X_weightedGradShape
void calculateGradShape_X_weightedGradShape(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *grad_v, double *grad_w_dV, double *grad_v_X_grad_w_dV)
Calculate the tensor product of trial function gradients and test function gradients at the quadratur...
Definition: femIntegrals.c:6635
calculateShape_X_weightedGradShape
void calculateShape_X_weightedGradShape(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *v, double *grad_w_dV, double *v_X_grad_w_dV)
Calculate the tensor product of trial functions and test function gradients at the quadrature points.
Definition: femIntegrals.c:6567
updateGlobalJacobianFromElementJacobian_CSR
void updateGlobalJacobianFromElementJacobian_CSR(int nElements_global, int nDOF_test_element, int nDOF_trial_element, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_ru, double *elementJacobian, double *globalJacobian)
Update the global CSR jacobian from the element Jacobians.
Definition: femIntegrals.c:5547
updateExteriorElementBoundaryDiffusiveVelocity_sd
void updateExteriorElementBoundaryDiffusiveVelocity_sd(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *rowptr, int *colind, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Definition: femIntegrals.c:7951
updateDiffusion_strong
void updateDiffusion_strong(int nElements_global, int nQuadraturePoints_element, int nSpace, double *da, double *grad_phi, double *grad_u, double *strong_residual)
Loop over all the elements and update the strong form of the residual with the diffusion term at the ...
Definition: femIntegrals.c:3125
update_f_movingDomain_q
void update_f_movingDomain_q(int nElements_global, int nQuadraturePoints_element, int nSpace, double *xt, double *m, double *f)
Definition: femIntegrals.c:12126
computeC0P1InterpolantDGP12
void computeC0P1InterpolantDGP12(int nElements_global, int nNodes_global, int nNodes_element, int nDOF_element, int dim_dof, const int *elementNodesArray, const int *nodeElementOffsets, const int *nodeElementsArray, const int *l2g, const double *dof, double *nodalAverage)
Definition: femIntegrals.c:10789
equivalent_polynomials::XZ
const int XZ(2)
updateInteriorElementBoundaryDiffusiveVelocity
void updateInteriorElementBoundaryDiffusiveVelocity(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Calculate the diffusive flux at interior element boundary quadrature points.
Definition: femIntegrals.c:7802
updateDiffusionJacobian_weak_sd
void updateDiffusionJacobian_weak_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, int *rowptr, int *colind, int *l2g, double *a, double *da, double *grad_phi, double *grad_w_dV, double *dphi, double *v, double *grad_v, double *jacobian_weak_residual)
Definition: femIntegrals.c:3023
updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_eb_CSR
void updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_eb_CSR(int *elementNeighbors, int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *csrRowIndeces_ru, int *csrColumnOffsets_eb_eNebN_ru, double *elementBoundaryFluxJacobian_eb, double *w_dS, double *jac)
Update the global CSR Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:6106
parametricMaps_getValuesGlobalExteriorTrace
void parametricMaps_getValuesGlobalExteriorTrace(int nQuadraturePoints_elementBoundary, int nDOF_element, int nSpace_global, int nExteriorElementBoundaries_global, const int *exteriorElementBoundariesArray, const int *elementBoundaryElementsArray, const int *elementBoundaryLocalElementBoundariesArray, double *psi, int *l2g, double *nodeArray, double *xArray)
Definition: femIntegrals.c:644
updateGlobalExteriorElementBoundaryDiffusiveVelocity
void updateGlobalExteriorElementBoundaryDiffusiveVelocity(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *a, double *grad_phi, double *velocity)
Calculate the diffusive flux at exterior element boundary quadrature points.
Definition: femIntegrals.c:7995
updateHamiltonianJacobian_weak
void updateHamiltonianJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *dH, double *grad_v_X_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:2372
updateMass_strong
void updateMass_strong(int nElements_global, int nQuadraturePoints_element, double *mt, double *strong_residual)
Loop over all the elements and update the strong from of the residual at the quadrature points with t...
Definition: femIntegrals.c:1834
r
Double r
Definition: Headers.h:83
scalarDomainIntegral
double scalarDomainIntegral(int nElements, int nQuadraturePoints_element, double *dV, double *nValueArray)
Definition: femIntegrals.c:10668
calculateExteriorElementBoundaryVelocities
void calculateExteriorElementBoundaryVelocities(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *m, double *a, double *grad_phi, double *f, double *vAverage, double *vJump, double *mAverage, double *mJump)
Definition: femIntegrals.c:7461
parametricMaps_getJacobianValuesTrace2D_movingDomain
void parametricMaps_getJacobianValuesTrace2D_movingDomain(int nElements_global, int nElementBoundaries_element, int nQuadraturePoints_element, int nDOF_element, double *xtArray, double *grad_psi, double *boundaryNormals, double *boundaryJacobians, int *l2g, double *nodeArray, double *jacobianInverseArray, double *metricTensorArray, double *metricTensorDeterminantSqrtArray, double *unitNormalArray)
Definition: femIntegrals.c:1173
updateDiffusion_MixedForm_weak_sd
void updateDiffusion_MixedForm_weak_sd(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, int rho_split, int *rowptr, int *colind, double *a, double *qV, double *grad_w_dV, double *velocity, double *weak_residual)
Definition: femIntegrals.c:10169
updateGlobalExteriorElementBoundaryFlux
void updateGlobalExteriorElementBoundaryFlux(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *flux, double *w_dS, double *residual)
Definition: femIntegrals.c:4361
updateMass_weak
void updateMass_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *mt, double *w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:1698
calculateWeightedPiolaShapeGradients
void calculateWeightedPiolaShapeGradients(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *dVR, double *abs_det_jac, double *grad_w, double *grad_w_dV)
THIS SHOULD BE REMOVED BEFORE MERGE.
Definition: femIntegrals.c:6473
calculateShape_X_weightedShapeTrace
void calculateShape_X_weightedShapeTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_trial_element, int nDOF_test_element, double *v, double *w_dS, double *v_X_w_dS)
Calcualte the tensor product of trial and test functions at the quadrature points.
Definition: femIntegrals.c:6740
equivalent_polynomials::ZX
const int ZX(6)
parametricFiniteElementSpace_getHessianValues
void parametricFiniteElementSpace_getHessianValues(int nElements_global, int nQuadraturePoints_element, int nDOF_element, int nSpace_global, double *Hessian_psi, double *inverseJacobianArray, double *Hessian_vArray)
Definition: femIntegrals.c:340
copyFreeUnknownsToGlobalUnknowns
void copyFreeUnknownsToGlobalUnknowns(int nDOF2set, int offset, int stride, const int *globalDOFids, const int *freeDOFids, const double *free_u, double *u)
Definition: femIntegrals.c:10999
updateDiffusionJacobian_weak
void updateDiffusionJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, int *l2g, double *a, double *da, double *grad_phi_X_grad_w_dV, double *dphi, double *v, double *grad_v_X_grad_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:2819
updateExteriorElementBoundaryDiffusionAdjoint_sd
void updateExteriorElementBoundaryDiffusionAdjoint_sd(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *rowptr, int *colind, int *isDOFBoundary, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double sigma, double *u, double *ub, double *n, double *a, double *grad_w, double *dS, double *residual)
Definition: femIntegrals.c:11520
updateAdvectionJacobian_weak_lowmem
void updateAdvectionJacobian_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *df, double *v, double *grad_w_dV, double *jacobian_weak_residual)
Definition: femIntegrals.c:2085
updateReactionJacobian_weak
void updateReactionJacobian_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *dr, double *v_X_w_dV, double *jacobian_weak_residual)
Loop over all the elements and update the element Jacobian with the numerical quadrature approximatio...
Definition: femIntegrals.c:3729
updateHamiltonianJacobian_weak_lowmem
void updateHamiltonianJacobian_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *dH, double *grad_v, double *w_dV, double *jacobian_weak_residual)
Definition: femIntegrals.c:2402
copyExteriorElementBoundaryValuesToGlobalElementBoundaryValues
void copyExteriorElementBoundaryValuesToGlobalElementBoundaryValues(int nExteriorElementBoundaries_global, int nQuadraturePoints_elementBoundary, int nValuesPerQuadraturePoint, const int *exteriorElementBoundaries, const int *elementBoundaryElements, const int *elementBoundaryLocalElementBoundaries, const double *ebqe_val, double *ebq_global_val)
copy quantity that sits only on exterior boundaries into a global elementBoundary quadrature array
Definition: femIntegrals.c:10611
updateExteriorElementBoundary_MixedForm_weak
void updateExteriorElementBoundary_MixedForm_weak(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nSpace, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *n, double *phi_trace, double *w_dS, double *b)
Update the element boundary flux on exterior element boundaries.
Definition: femIntegrals.c:8944
updateInteriorElementBoundaryAdvectiveVelocity
void updateInteriorElementBoundaryAdvectiveVelocity(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nSpace, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *f, double *velocity)
Calculate the advective flux at at interior element boundaries.
Definition: femIntegrals.c:8066
updateInteriorTwoSidedElementBoundaryFlux
void updateInteriorTwoSidedElementBoundaryFlux(int nInteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int *interiorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, double *flux, double *w_dS, double *residual)
Update a two-sided (say nonconservative HJ flux) element boundary flux on interior element boundaries...
Definition: femIntegrals.c:4424
calculateVelocityQuadrature_MixedForm_Jacobian
void calculateVelocityQuadrature_MixedForm_Jacobian(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_element, int nSpace, int nQuadraturePoints_element, double *A_inv, double *db, double *db_eb, double *v, double *DV, double *DV_eb, double *qv, double *qDV, double *qDV_eb)
Definition: femIntegrals.c:9562
zeroJacobian_CSR
void zeroJacobian_CSR(int nNonzeros, double *jac)
Set all the Jacobian entries to 0.0.
Definition: femIntegrals.c:7363
nnz
#define nnz
Definition: Richards.h:9
calculateScalarScalarProduct
void calculateScalarScalarProduct(int nElements_global, int nQuadraturePoints_element, double *s1, double *s2, double *sResult)
Calculate the product of two scalars at the quadrature points.
Definition: femIntegrals.c:4198
updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_dense
void updateGlobalJacobianFromExteriorElementBoundaryFluxJacobian_dense(int nExteriorElementBoundaries_global, int nElementBoundaries_element, int nQuadraturePoints_elementBoundary, int nDOF_test_element, int nDOF_trial_element, int offset_r, int stride_r, int offset_u, int stride_u, int nFreeVDOF_global, int *exteriorElementBoundaries, int *elementBoundaryElements, int *elementBoundaryLocalElementBoundaries, int *nFreeDOF_element_r, int *freeLocal_r, int *freeGlobal_r, int *nFreeDOF_element_u, int *freeLocal_u, int *freeGlobal_u, double *elementBoundaryFluxJacobian, double *w_dS, double *jac)
Update the global dense Jacobian from the element boundary flux Jacobians at exterior boundaries.
Definition: femIntegrals.c:5245
TR_ALPHA
#define TR_ALPHA
Definition: femIntegrals.c:8652
updateReactionJacobian_weak_lowmem
void updateReactionJacobian_weak_lowmem(int nElements_global, int nQuadraturePoints_element, int nDOF_trial_element, int nDOF_test_element, double *dr, double *v, double *w_dV, double *jacobian_weak_residual)
Definition: femIntegrals.c:3740
parametricFiniteElementSpace_getValues
void parametricFiniteElementSpace_getValues(int nElements_global, int nQuadraturePoints_element, int nDOF_element, double *psi, double *vArray)
Definition: femIntegrals.c:241
updateDiffusion2_adjoint
void updateDiffusion2_adjoint(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, int nSpace, double *a, double *Hess_w_dV, double *Lstar_w_dV)
Definition: femIntegrals.c:3580
psi
Double psi
Definition: Headers.h:78
calculateDimensionlessNumbersADR
void calculateDimensionlessNumbersADR(int nElements_global, int nQuadraturePoints_element, int nSpace, int computeDiffusiveTimeStepLimit, double *elementDiameter, double *df, double *a, double *dphi, double *dr, double *dmt, double *pe, double *cfl)
Calculate the Peclet and Courant-Friedrichs-Lewy numbers for the scalar advection-diffusion-reaction ...
Definition: femIntegrals.c:7588
calculateGradShape_X_weightedShapeTrace
void calculateGradShape_X_weightedShapeTrace(int nElements_global, int nElementBoundaries_element, int nElementBoundaryQuadraturePoints_elementBoundary, int nDOF_trial_element, int nDOF_test_element, int nSpace, double *grad_v, double *w_dS, double *grad_v_X_w_dS)
Calculate the tensor product of trial function gradients and test functions at the quadrature points.
Definition: femIntegrals.c:6775
equivalent_polynomials::YX
const int YX(3)
equivalent_polynomials::ZY
const int ZY(7)
updateReaction_weak
void updateReaction_weak(int nElements_global, int nQuadraturePoints_element, int nDOF_test_element, double *r, double *w_dV, double *weak_residual)
Loop over all the elements and update the element weak_residual with the numerical quadrature approxi...
Definition: femIntegrals.c:3680