7 #include PROTEUS_LAPACK_H
17 assert(fabs(A[0][0]) > 0.0);
18 AI[0][0] = 1.0/A[0][0];
22 detA = A[0][0]*A[1][1]-A[0][1]*A[1][0];
23 assert(fabs(detA) > 0.0);
25 AI[0][0] = detAinv*A[1][1]; AI[0][1] =-detAinv*A[0][1];
26 AI[1][0] =-detAinv*A[1][0]; AI[1][1] = detAinv*A[0][0];
31 A[0][0]*(A[1][1]*A[2][2]-A[2][1]*A[1][2])-
32 A[0][1]*(A[1][0]*A[2][2]-A[2][0]*A[1][2])+
33 A[0][2]*(A[1][0]*A[2][1]-A[2][0]*A[1][1]);
34 assert(fabs(detA) > 0.0);
36 AI[0][0] = detAinv*(A[1][1]*A[2][2]-A[1][2]*A[2][1]);
37 AI[0][1] = detAinv*(A[0][2]*A[2][1]-A[0][1]*A[2][2]);
38 AI[0][2] = detAinv*(A[0][1]*A[1][2]-A[0][2]*A[1][1]);
40 AI[1][0] = detAinv*(A[1][2]*A[2][0]-A[1][0]*A[2][2]);
41 AI[1][1] = detAinv*(A[0][0]*A[2][2]-A[0][2]*A[2][0]);
42 AI[1][2] = detAinv*(A[0][2]*A[1][0]-A[0][0]*A[1][2]);
44 AI[2][0] = detAinv*(A[1][0]*A[2][1]-A[1][1]*A[2][0]);
45 AI[2][1] = detAinv*(A[0][1]*A[2][0]-A[0][0]*A[2][1]);
46 AI[2][2] = detAinv*(A[0][0]*A[1][1]-A[0][1]*A[1][0]);
52 int nQuadraturePoints_element,
53 int nDOF_test_element,
54 int nElementBoundaries_element,
55 int nQuadraturePoints_elementBoundary,
57 int * nFreeDOF_element,
58 int * freeLocal_element,
62 double * elementBarycenters,
166 int eN,ebN,I,J,i,k,ebN_free,ebN_dir;
167 int nSpace2 = nSpace*nSpace;
168 int nDOF_RT0V_element = nSpace+1;
169 double volume,area,volFact,areaFact;
170 double ah[3][3] = {{0.0,0.0,0.0},
173 double vecf[3] = {0.0,0.0,0.0};
174 double rh[4] = {0.0,0.0,0.0,0.0};
175 double mth[4] = {0.0,0.0,0.0,0.0};
177 double G_E[3][3] = {{0.0,0.0,0.0},
180 double G_Ei[3][3]={{0.0,0.0,0.0},
183 double rhs_c[3] ={0.0,0.0,0.0};
184 double c_E[3] = {0.0,0.0,0.0};
186 double dDim = (double) nSpace;
189 assert(nDOF_test_element == nSpace+1);
190 volFact = 1.0; areaFact = 1.0;
195 volFact = 1.0/6.0; areaFact = 0.5;
203 for (eN = 0; eN < nElements_global; eN++)
206 rh[0] = 0.0; rh[1] = 0.0; rh[2] = 0.0; rh[3] = 0.0; rbar = 0.0;
207 mth[0]= 0.0; mth[1]= 0.0; mth[2] = 0.0; mth[3] = 0.0; mtbar= 0.0;
208 vecf[0]=0.0; vecf[1] = 0.0; vecf[2] = 0.0;
209 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
210 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
211 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
214 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
216 for (k = 0; k < nQuadraturePoints_element; k++)
219 for (I = 0; I < nSpace; I++)
222 f[eN*nQuadraturePoints_element*nSpace +
228 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
230 for (J = 0; J < nSpace; J++)
233 a[eN*nQuadraturePoints_element*nSpace2 +
240 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
244 for (i = 0; i < nDOF_test_element; i++)
247 r[eN*nQuadraturePoints_element + k]
249 w_dV_r[eN*nQuadraturePoints_element*nDOF_test_element +
250 k*nDOF_test_element +
254 mt[eN*nQuadraturePoints_element + k]
256 w_dV_m[eN*nQuadraturePoints_element*nDOF_test_element +
257 k*nDOF_test_element +
263 for (i = 0; i < nDOF_test_element; i++)
265 rbar += rh[i]/volume; mtbar += mth[i]/volume;
267 b_E = (-rbar - mtbar)/dDim;
269 rt0vdofs[eN*nDOF_RT0V_element + nSpace] = b_E;
271 for (I=0; I < nSpace; I++)
273 rt0vdofs[eN*nDOF_RT0V_element + I] = 0.0;
274 for (J=0; J < nSpace; J++)
277 rt0vdofs[eN*nDOF_RT0V_element + I] -=
280 gradu[eN*nQuadraturePoints_element*nSpace +
288 rt0vdofs[eN*nDOF_RT0V_element + I] += vecf[I];
290 rt0vdofs[eN*nDOF_RT0V_element + I] -=
293 elementBarycenters[eN*3 + I];
303 rhs_c[0] = 0.0; rhs_c[1] = 0.0; rhs_c[2] = 0.0;
304 G_E[0][0] = 1.0; G_E[0][1] = 0.0; G_E[0][2] = 0.0;
305 G_E[1][0] = 0.0; G_E[1][1] = 1.0; G_E[1][2] = 0.0;
306 G_E[2][0] = 0.0; G_E[2][1] = 0.0; G_E[2][2] = 1.0;
309 if (nFreeDOF_element[eN] < ebN_free)
310 ebN_free = nFreeDOF_element[eN];
311 for (i = 0; i < ebN_free; i++)
313 ebN = freeLocal_element[eN*nDOF_test_element + i];
315 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
316 ebN*nQuadraturePoints_elementBoundary + 0]
319 for (I = 0; I < nSpace; I++)
323 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
324 ebN*nQuadraturePoints_elementBoundary*nSpace +
328 rhs_c[i] = -rh[ebN] + volume*rbar/(dDim+1.) -mth[ebN] + mtbar*volume/(dDim+1.);
349 while (ebN_free < nSpace && ebN < nElementBoundaries_element)
356 for (k = 0; k < ebN_free; k++)
358 if (ebN == freeLocal_element[eN*nDOF_test_element + k])
364 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
365 ebN*nQuadraturePoints_elementBoundary + 0]
368 for (I = 0; I < nSpace; I++)
372 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
373 ebN*nQuadraturePoints_elementBoundary*nSpace +
376 rhs_c[ebN_free] = 0.0;
382 assert (ebN_free >= nSpace);
393 for (I = 0; I < nSpace; I++)
396 for (J = 0; J < nSpace; J++)
397 c_E[I] += G_Ei[I][J]*rhs_c[J];
409 for (I = 0; I < nSpace; I++)
410 rt0vdofs[eN*nDOF_RT0V_element + I] += c_E[I];
415 int nQuadraturePoints_element,
416 int nDOF_test_element,
417 int nElementBoundaries_element,
418 int nQuadraturePoints_elementBoundary,
422 int * nFreeDOF_element,
423 int * freeLocal_element,
427 double * elementBarycenters,
531 int eN,ebN,I,J,i,k,ebN_free,ebN_dir;
532 int m,
nnz=rowptr[nSpace];
533 int nDOF_RT0V_element = nSpace+1;
534 double volume,area,volFact,areaFact;
535 double ah[3][3] = {{0.0,0.0,0.0},
538 double vecf[3] = {0.0,0.0,0.0};
539 double rh[4] = {0.0,0.0,0.0,0.0};
540 double mth[4] = {0.0,0.0,0.0,0.0};
542 double G_E[3][3] = {{0.0,0.0,0.0},
545 double G_Ei[3][3]={{0.0,0.0,0.0},
548 double rhs_c[3] ={0.0,0.0,0.0};
549 double c_E[3] = {0.0,0.0,0.0};
551 double dDim = (double) nSpace;
554 assert(nDOF_test_element == nSpace+1);
555 volFact = 1.0; areaFact = 1.0;
560 volFact = 1.0/6.0; areaFact = 0.5;
568 for (eN = 0; eN < nElements_global; eN++)
571 rh[0] = 0.0; rh[1] = 0.0; rh[2] = 0.0; rh[3] = 0.0; rbar = 0.0;
572 mth[0]= 0.0; mth[1]= 0.0; mth[2] = 0.0; mth[3] = 0.0; mtbar= 0.0;
573 vecf[0]=0.0; vecf[1] = 0.0; vecf[2] = 0.0;
574 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
575 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
576 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
579 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
581 for (k = 0; k < nQuadraturePoints_element; k++)
584 for (I = 0; I < nSpace; I++)
587 f[eN*nQuadraturePoints_element*nSpace +
593 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
595 for (m=rowptr[I];m<rowptr[I+1];m++)
598 a[eN*nQuadraturePoints_element*
nnz+
604 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
608 for (i = 0; i < nDOF_test_element; i++)
611 r[eN*nQuadraturePoints_element + k]
613 w_dV_r[eN*nQuadraturePoints_element*nDOF_test_element +
614 k*nDOF_test_element +
618 mt[eN*nQuadraturePoints_element + k]
620 w_dV_m[eN*nQuadraturePoints_element*nDOF_test_element +
621 k*nDOF_test_element +
627 for (i = 0; i < nDOF_test_element; i++)
629 rbar += rh[i]/volume; mtbar += mth[i]/volume;
631 b_E = (-rbar - mtbar)/dDim;
633 rt0vdofs[eN*nDOF_RT0V_element + nSpace] = b_E;
635 for (I=0; I < nSpace; I++)
637 rt0vdofs[eN*nDOF_RT0V_element + I] = 0.0;
638 for (J=0; J < nSpace; J++)
641 rt0vdofs[eN*nDOF_RT0V_element + I] -=
644 gradu[eN*nQuadraturePoints_element*nSpace +
652 rt0vdofs[eN*nDOF_RT0V_element + I] += vecf[I];
654 rt0vdofs[eN*nDOF_RT0V_element + I] -=
657 elementBarycenters[eN*3 + I];
667 rhs_c[0] = 0.0; rhs_c[1] = 0.0; rhs_c[2] = 0.0;
668 G_E[0][0] = 1.0; G_E[0][1] = 0.0; G_E[0][2] = 0.0;
669 G_E[1][0] = 0.0; G_E[1][1] = 1.0; G_E[1][2] = 0.0;
670 G_E[2][0] = 0.0; G_E[2][1] = 0.0; G_E[2][2] = 1.0;
673 if (nFreeDOF_element[eN] < ebN_free)
674 ebN_free = nFreeDOF_element[eN];
675 for (i = 0; i < ebN_free; i++)
677 ebN = freeLocal_element[eN*nDOF_test_element + i];
679 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
680 ebN*nQuadraturePoints_elementBoundary + 0]
683 for (I = 0; I < nSpace; I++)
687 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
688 ebN*nQuadraturePoints_elementBoundary*nSpace +
692 rhs_c[i] = -rh[ebN] + volume*rbar/(dDim+1.) -mth[ebN] + mtbar*volume/(dDim+1.);
713 while (ebN_free < nSpace && ebN < nElementBoundaries_element)
720 for (k = 0; k < ebN_free; k++)
722 if (ebN == freeLocal_element[eN*nDOF_test_element + k])
728 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
729 ebN*nQuadraturePoints_elementBoundary + 0]
732 for (I = 0; I < nSpace; I++)
736 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
737 ebN*nQuadraturePoints_elementBoundary*nSpace +
740 rhs_c[ebN_free] = 0.0;
746 assert (ebN_free >= nSpace);
757 for (I = 0; I < nSpace; I++)
760 for (J = 0; J < nSpace; J++)
761 c_E[I] += G_Ei[I][J]*rhs_c[J];
773 for (I = 0; I < nSpace; I++)
774 rt0vdofs[eN*nDOF_RT0V_element + I] += c_E[I];
779 int nQuadraturePoints_element,
780 int nDOF_test_element,
781 int nElementBoundaries_element,
782 int nQuadraturePoints_elementBoundary,
784 int * nFreeDOF_element,
785 int * freeLocal_element,
789 double * elementBarycenters,
803 int eN,ebN,I,J,i,k,ebN_free,ebN_dir;
804 int nSpace2 = nSpace*nSpace;
805 int nDOF_RT0V_element = nSpace+1;
806 double volume,area,volFact,areaFact;
807 double ah[3][3] = {{0.0,0.0,0.0},
810 double vecf[3] = {0.0,0.0,0.0};
811 double rh[4] = {0.0,0.0,0.0,0.0};
813 double G_E[3][3] = {{0.0,0.0,0.0},
816 double G_Ei[3][3]={{0.0,0.0,0.0},
819 double rhs_c[3] ={0.0,0.0,0.0};
820 double c_E[3] = {0.0,0.0,0.0};
822 double dDim = (double) nSpace;
825 assert(nDOF_test_element == nSpace+1);
826 volFact = 1.0; areaFact = 1.0;
831 volFact = 1.0/6.0; areaFact = 0.5;
842 for (eN = 0; eN < nElements_global; eN++)
845 rh[0] = 0.0; rh[1] = 0.0; rh[2] = 0.0; rh[3] = 0.0; rbar = 0.0;
846 vecf[0]=0.0; vecf[1] = 0.0; vecf[2] = 0.0;
847 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
848 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
849 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
852 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
854 for (k = 0; k < nQuadraturePoints_element; k++)
857 for (I = 0; I < nSpace; I++)
860 f[eN*nQuadraturePoints_element*nSpace +
866 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
868 for (J = 0; J < nSpace; J++)
871 a[eN*nQuadraturePoints_element*nSpace2 +
878 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
882 for (i = 0; i < nDOF_test_element; i++)
885 r[eN*nQuadraturePoints_element + k]
887 w_dV_r[eN*nQuadraturePoints_element*nDOF_test_element +
888 k*nDOF_test_element +
895 for (i = 0; i < nDOF_test_element; i++)
897 rbar += rh[i]/volume;
901 rt0vdofs[eN*nDOF_RT0V_element + nSpace] = b_E;
903 for (I=0; I < nSpace; I++)
905 rt0vdofs[eN*nDOF_RT0V_element + I] = 0.0;
906 for (J=0; J < nSpace; J++)
909 rt0vdofs[eN*nDOF_RT0V_element + I] -=
912 gradu[eN*nQuadraturePoints_element*nSpace +
920 rt0vdofs[eN*nDOF_RT0V_element + I] += vecf[I];
922 rt0vdofs[eN*nDOF_RT0V_element + I] -=
925 elementBarycenters[eN*3 + I];
935 rhs_c[0] = 0.0; rhs_c[1] = 0.0; rhs_c[2] = 0.0;
936 G_E[0][0] = 1.0; G_E[0][1] = 0.0; G_E[0][2] = 0.0;
937 G_E[1][0] = 0.0; G_E[1][1] = 1.0; G_E[1][2] = 0.0;
938 G_E[2][0] = 0.0; G_E[2][1] = 0.0; G_E[2][2] = 1.0;
941 if (nFreeDOF_element[eN] < ebN_free)
942 ebN_free = nFreeDOF_element[eN];
943 for (i = 0; i < ebN_free; i++)
945 ebN = freeLocal_element[eN*nDOF_test_element + i];
947 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
948 ebN*nQuadraturePoints_elementBoundary + 0]
951 for (I = 0; I < nSpace; I++)
955 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
956 ebN*nQuadraturePoints_elementBoundary*nSpace +
960 rhs_c[i] = -rh[ebN] + volume*rbar/(dDim+1.);
981 while (ebN_free < nSpace && ebN < nElementBoundaries_element)
988 for (k = 0; k < ebN_free; k++)
990 if (ebN == freeLocal_element[eN*nDOF_test_element + k])
996 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
997 ebN*nQuadraturePoints_elementBoundary + 0]
1000 for (I = 0; I < nSpace; I++)
1004 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
1005 ebN*nQuadraturePoints_elementBoundary*nSpace +
1008 rhs_c[ebN_free] = 0.0;
1014 assert (ebN_free >= nSpace);
1025 for (I = 0; I < nSpace; I++)
1028 for (J = 0; J < nSpace; J++)
1029 c_E[I] += G_Ei[I][J]*rhs_c[J];
1041 for (I = 0; I < nSpace; I++)
1042 rt0vdofs[eN*nDOF_RT0V_element + I] += c_E[I];
1047 int nQuadraturePoints_element,
1048 int nDOF_test_element,
1049 int nElementBoundaries_element,
1050 int nQuadraturePoints_elementBoundary,
1054 int * nFreeDOF_element,
1055 int * freeLocal_element,
1057 double * sqrt_det_g,
1059 double * elementBarycenters,
1073 int eN,ebN,I,J,i,k,ebN_free,ebN_dir;
1074 int m,
nnz=rowptr[nSpace];
1075 int nDOF_RT0V_element = nSpace+1;
1076 double volume,area,volFact,areaFact;
1077 double ah[3][3] = {{0.0,0.0,0.0},
1080 double vecf[3] = {0.0,0.0,0.0};
1081 double rh[4] = {0.0,0.0,0.0,0.0};
1083 double G_E[3][3] = {{0.0,0.0,0.0},
1086 double G_Ei[3][3]={{0.0,0.0,0.0},
1089 double rhs_c[3] ={0.0,0.0,0.0};
1090 double c_E[3] = {0.0,0.0,0.0};
1092 double dDim = (double) nSpace;
1095 assert(nDOF_test_element == nSpace+1);
1096 volFact = 1.0; areaFact = 1.0;
1101 volFact = 1.0/6.0; areaFact = 0.5;
1112 for (eN = 0; eN < nElements_global; eN++)
1115 rh[0] = 0.0; rh[1] = 0.0; rh[2] = 0.0; rh[3] = 0.0; rbar = 0.0;
1116 vecf[0]=0.0; vecf[1] = 0.0; vecf[2] = 0.0;
1117 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
1118 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
1119 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
1122 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
1124 for (k = 0; k < nQuadraturePoints_element; k++)
1127 for (I = 0; I < nSpace; I++)
1130 f[eN*nQuadraturePoints_element*nSpace +
1136 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
1138 for (m=rowptr[I];m<rowptr[I+1];m++)
1141 a[eN*nQuadraturePoints_element*
nnz+
1147 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
1151 for (i = 0; i < nDOF_test_element; i++)
1154 r[eN*nQuadraturePoints_element + k]
1156 w_dV_r[eN*nQuadraturePoints_element*nDOF_test_element +
1157 k*nDOF_test_element +
1164 for (i = 0; i < nDOF_test_element; i++)
1166 rbar += rh[i]/volume;
1170 rt0vdofs[eN*nDOF_RT0V_element + nSpace] = b_E;
1172 for (I=0; I < nSpace; I++)
1174 rt0vdofs[eN*nDOF_RT0V_element + I] = 0.0;
1175 for (J=0; J < nSpace; J++)
1178 rt0vdofs[eN*nDOF_RT0V_element + I] -=
1181 gradu[eN*nQuadraturePoints_element*nSpace +
1189 rt0vdofs[eN*nDOF_RT0V_element + I] += vecf[I];
1191 rt0vdofs[eN*nDOF_RT0V_element + I] -=
1194 elementBarycenters[eN*3 + I];
1204 rhs_c[0] = 0.0; rhs_c[1] = 0.0; rhs_c[2] = 0.0;
1205 G_E[0][0] = 1.0; G_E[0][1] = 0.0; G_E[0][2] = 0.0;
1206 G_E[1][0] = 0.0; G_E[1][1] = 1.0; G_E[1][2] = 0.0;
1207 G_E[2][0] = 0.0; G_E[2][1] = 0.0; G_E[2][2] = 1.0;
1210 if (nFreeDOF_element[eN] < ebN_free)
1211 ebN_free = nFreeDOF_element[eN];
1212 for (i = 0; i < ebN_free; i++)
1214 ebN = freeLocal_element[eN*nDOF_test_element + i];
1216 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1217 ebN*nQuadraturePoints_elementBoundary + 0]
1220 for (I = 0; I < nSpace; I++)
1224 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
1225 ebN*nQuadraturePoints_elementBoundary*nSpace +
1229 rhs_c[i] = -rh[ebN] + volume*rbar/(dDim+1.);
1250 while (ebN_free < nSpace && ebN < nElementBoundaries_element)
1257 for (k = 0; k < ebN_free; k++)
1259 if (ebN == freeLocal_element[eN*nDOF_test_element + k])
1265 area = sqrt_det_g[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1266 ebN*nQuadraturePoints_elementBoundary + 0]
1269 for (I = 0; I < nSpace; I++)
1273 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
1274 ebN*nQuadraturePoints_elementBoundary*nSpace +
1277 rhs_c[ebN_free] = 0.0;
1283 assert (ebN_free >= nSpace);
1294 for (I = 0; I < nSpace; I++)
1297 for (J = 0; J < nSpace; J++)
1298 c_E[I] += G_Ei[I][J]*rhs_c[J];
1310 for (I = 0; I < nSpace; I++)
1311 rt0vdofs[eN*nDOF_RT0V_element + I] += c_E[I];
1316 int nQuadraturePoints_element,
1338 int nSpace2 = nSpace*nSpace;
1339 int nDOF_RT0V_element = nSpace+1;
1340 double volume,volFact;
1341 double ah[3][3] = {{0.0,0.0,0.0},
1357 for (eN = 0; eN < nElements_global; eN++)
1359 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
1360 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
1361 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
1364 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
1366 for (k = 0; k < nQuadraturePoints_element; k++)
1369 for (I = 0; I < nSpace; I++)
1371 for (J = 0; J < nSpace; J++)
1374 a[eN*nQuadraturePoints_element*nSpace2 +
1381 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
1387 for (I=0; I < nSpace; I++)
1389 for (J=0; J < nSpace; J++)
1392 rt0vdofs[eN*nDOF_RT0V_element + I] -=
1395 gradphi[eN*nQuadraturePoints_element*nSpace +
1410 int nQuadraturePoints_element,
1434 int m,
nnz=rowptr[nSpace];
1435 int nDOF_RT0V_element = nSpace+1;
1436 double volume,volFact;
1437 double ah[3][3] = {{0.0,0.0,0.0},
1453 for (eN = 0; eN < nElements_global; eN++)
1455 ah[0][0] = 0.0; ah[0][1]=0.0; ah[0][2] = 0.0;
1456 ah[1][0] = 0.0; ah[1][1]=0.0; ah[1][2] = 0.0;
1457 ah[2][0] = 0.0; ah[2][1]=0.0; ah[2][2] = 0.0;
1460 volume = fabs(detJ[eN*nQuadraturePoints_element + 0])*volFact;
1462 for (k = 0; k < nQuadraturePoints_element; k++)
1465 for (I = 0; I < nSpace; I++)
1467 for(m=rowptr[I];m<rowptr[I+1];m++)
1470 a[eN*nQuadraturePoints_element*
nnz+
1476 fabs(detJ[eN*nQuadraturePoints_element + k])/volume;
1482 for (I=0; I < nSpace; I++)
1484 for (J=0; J < nSpace; J++)
1487 rt0vdofs[eN*nDOF_RT0V_element + I] -=
1490 gradphi[eN*nQuadraturePoints_element*nSpace +
1505 int nPoints_element,
1508 double * rt0vdofs_element,
1525 int nDOF_RT0V_element = nSpace+1;
1527 for (eN = 0; eN < nElements_global; eN++)
1530 b_T = rt0vdofs_element[eN*nDOF_RT0V_element + nSpace];
1531 for (k = 0; k < nPoints_element; k++)
1533 for (I = 0; I < nSpace; I++)
1535 v_element[eN*nPoints_element*nSpace + k*nSpace + I] =
1536 rt0vdofs_element[eN*nDOF_RT0V_element + I] +
1537 b_T * x_element[eN*nPoints_element*3 + k*3 + I];
1544 int nElementBoundaries_element,
1545 int nPoints_elementBoundary,
1547 double * x_elementBoundary,
1548 double * rt0vdofs_element,
1549 double * v_elementBoundary)
1567 int nDOF_RT0V_element = nSpace+1;
1569 for (eN = 0; eN < nElements_global; eN++)
1572 b_T = rt0vdofs_element[eN*nDOF_RT0V_element + nSpace];
1573 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
1575 for (k = 0; k < nPoints_elementBoundary; k++)
1577 for (I = 0; I < nSpace; I++)
1579 v_elementBoundary[eN*nElementBoundaries_element*nPoints_elementBoundary*nSpace +
1580 ebN*nPoints_elementBoundary*nSpace +
1583 rt0vdofs_element[eN*nDOF_RT0V_element + I] +
1584 b_T * x_elementBoundary[eN*nElementBoundaries_element*nPoints_elementBoundary*3 +
1585 ebN*nPoints_elementBoundary*3 +
1594 int nPoints_elementBoundary,
1596 int * elementBoundaryElementsArray,
1597 double * x_elementBoundary_global,
1598 double * rt0vdofs_element,
1599 double * v_elementBoundary_global)
1618 int nDOF_RT0V_element = nSpace+1;
1620 for (ebN = 0; ebN < nElementBoundaries_global; ebN++)
1622 eN = elementBoundaryElementsArray[ebN*2 + 0];
1623 b_T = rt0vdofs_element[eN*nDOF_RT0V_element + nSpace];
1624 for (k = 0; k < nPoints_elementBoundary; k++)
1626 for (I = 0; I < nSpace; I++)
1628 v_elementBoundary_global[ebN*nPoints_elementBoundary*nSpace + k*nSpace + I] =
1629 rt0vdofs_element[eN*nDOF_RT0V_element + I] +
1630 b_T * x_elementBoundary_global[ebN*nPoints_elementBoundary*3 + k*3 + I];
1637 int nPoints_elementBoundary,
1639 int * elementBoundaryElementsArray,
1640 int * exteriorElementBoundariesArray,
1641 double * x_elementBoundary_global,
1642 double * rt0vdofs_element,
1643 double * v_elementBoundary_global)
1661 int ebNE,ebN,eN,I,k;
1662 int nDOF_RT0V_element = nSpace+1;
1664 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1666 ebN = exteriorElementBoundariesArray[ebNE];
1667 eN = elementBoundaryElementsArray[ebN*2 + 0];
1668 b_T = rt0vdofs_element[eN*nDOF_RT0V_element + nSpace];
1669 for (k = 0; k < nPoints_elementBoundary; k++)
1671 for (I = 0; I < nSpace; I++)
1673 v_elementBoundary_global[ebNE*nPoints_elementBoundary*nSpace + k*nSpace + I] =
1674 rt0vdofs_element[eN*nDOF_RT0V_element + I] +
1675 b_T * x_elementBoundary_global[ebNE*nPoints_elementBoundary*3 + k*3 + I];
1683 int nQuadraturePoints_element,
1684 int nElementBoundaries_element,
1685 int nQuadraturePoints_elementBoundary,
1687 double * uQuadratureWeights_element,
1688 double * elementBarycenters,
1689 double * aElementQuadratureWeights,
1691 double * uQuadratureWeights_elementBoundary,
1695 double * x_elementBoundary,
1696 double * u_elementBoundary,
1702 double * rt0potential)
1729 int nSpace2 = nSpace*nSpace;
1730 int nDOF_RT0V_element = nSpace+1;
1731 double volume,vmass,bndsum,adot,ahqInvI,xdotn,gravsum;
1732 double ah[3][3] = {{0.0,0.0,0.0},
1735 double ahInv[3][3] = {{0.0,0.0,0.0},
1738 double vecc[3] = {0.0,0.0,0.0};
1740 double dDim = nSpace;
1741 for (eN = 0; eN < nElements_global; eN++)
1744 for (k = 0; k < nQuadraturePoints_element; k++)
1746 volume += uQuadratureWeights_element[eN*nQuadraturePoints_element + k];
1751 for (I = 0; I < nSpace; I++)
1753 for (J = 0; J < nSpace; J++)
1758 for (k = 0; k < nQuadraturePoints_element; k++)
1761 a[eN*nQuadraturePoints_element*nSpace2 +
1766 aElementQuadratureWeights[k]*fabs(detJ[eN*nQuadraturePoints_element+k]);
1768 ah[I][J] = ah[I][J]/volume;
1771 for (k = 0; k < nQuadraturePoints_element; k++)
1774 f[eN*nQuadraturePoints_element*nSpace +
1777 aElementQuadratureWeights[k]*fabs(detJ[eN*nQuadraturePoints_element+k]);
1779 vecc[I] = vecc[I]/volume;
1791 for (k = 0; k < nQuadraturePoints_element; k++)
1794 for (I = 0; I < nSpace; I++)
1797 for (J = 0; J < nSpace; J++)
1798 ahqInvI+= ahInv[I][J]*(rt0vdofs[eN*nDOF_RT0V_element + J]
1800 rt0vdofs[eN*nDOF_RT0V_element + nSpace]
1802 x[eN*nQuadraturePoints_element*3 +
1805 adot += ahqInvI*x[eN*nQuadraturePoints_element*3 +
1808 vmass += adot*uQuadratureWeights_element[eN*nQuadraturePoints_element + k];
1812 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
1814 for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
1817 for (I = 0; I < nSpace; I++)
1820 x_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*3 +
1821 ebN*nQuadraturePoints_elementBoundary*3 +
1824 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
1825 ebN*nQuadraturePoints_elementBoundary*nSpace +
1828 bndsum += u_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1829 ebN*nQuadraturePoints_elementBoundary + k]
1831 * uQuadratureWeights_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1832 ebN*nQuadraturePoints_elementBoundary + k];
1836 for (I=0; I < nSpace; I++)
1837 gravsum -= vecc[I]*elementBarycenters[eN*3 + I]*volume;
1838 rt0potential[eN] = (bndsum + vmass + gravsum)/(dDim*volume);
1843 int nQuadraturePoints_element,
1844 int nElementBoundaries_element,
1845 int nQuadraturePoints_elementBoundary,
1849 double * uQuadratureWeights_element,
1850 double * elementBarycenters,
1851 double * aElementQuadratureWeights,
1853 double * uQuadratureWeights_elementBoundary,
1857 double * x_elementBoundary,
1858 double * u_elementBoundary,
1864 double * rt0potential)
1891 int m,
nnz=rowptr[nSpace];
1892 int nDOF_RT0V_element = nSpace+1;
1893 double volume,vmass,bndsum,adot,ahqInvI,xdotn,gravsum;
1894 double ah[3][3] = {{0.0,0.0,0.0},
1897 double ahInv[3][3] = {{0.0,0.0,0.0},
1900 double vecc[3] = {0.0,0.0,0.0};
1902 double dDim = nSpace;
1903 for (eN = 0; eN < nElements_global; eN++)
1906 for (k = 0; k < nQuadraturePoints_element; k++)
1908 volume += uQuadratureWeights_element[eN*nQuadraturePoints_element + k];
1913 for (I = 0; I < nSpace; I++)
1915 for(m=rowptr[I];m<rowptr[I+1];m++)
1919 ah[I][colind[m]] = 0.0;
1920 for (k = 0; k < nQuadraturePoints_element; k++)
1923 a[eN*nQuadraturePoints_element*
nnz+
1927 aElementQuadratureWeights[k]*fabs(detJ[eN*nQuadraturePoints_element+k]);
1929 ah[I][colind[m]] = ah[I][colind[m]]/volume;
1932 for (k = 0; k < nQuadraturePoints_element; k++)
1935 f[eN*nQuadraturePoints_element*nSpace +
1938 aElementQuadratureWeights[k]*fabs(detJ[eN*nQuadraturePoints_element+k]);
1940 vecc[I] = vecc[I]/volume;
1952 for (k = 0; k < nQuadraturePoints_element; k++)
1955 for (I = 0; I < nSpace; I++)
1958 for (J = 0; J < nSpace; J++)
1959 ahqInvI+= ahInv[I][J]*(rt0vdofs[eN*nDOF_RT0V_element + J]
1961 rt0vdofs[eN*nDOF_RT0V_element + nSpace]
1963 x[eN*nQuadraturePoints_element*3 +
1966 adot += ahqInvI*x[eN*nQuadraturePoints_element*3 +
1969 vmass += adot*uQuadratureWeights_element[eN*nQuadraturePoints_element + k];
1973 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
1975 for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
1978 for (I = 0; I < nSpace; I++)
1981 x_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*3 +
1982 ebN*nQuadraturePoints_elementBoundary*3 +
1985 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
1986 ebN*nQuadraturePoints_elementBoundary*nSpace +
1989 bndsum += u_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1990 ebN*nQuadraturePoints_elementBoundary + k]
1992 * uQuadratureWeights_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
1993 ebN*nQuadraturePoints_elementBoundary + k];
1997 for (I=0; I < nSpace; I++)
1998 gravsum -= vecc[I]*elementBarycenters[eN*3 + I]*volume;
1999 rt0potential[eN] = (bndsum + vmass + gravsum)/(dDim*volume);
2004 int nElementBoundaries_element,
2005 int nQuadraturePoints_elementBoundary,
2007 double * elementBoundaryQuadratureWeights,
2009 double * v_elementBoundary,
2010 double * rt0vdofs_element)
2034 double fluxsum,dotk;
2035 int nDOF_RT0V_element = nSpace+1;
2038 for (eN = 0; eN < nElements_global; eN++)
2040 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2045 for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
2048 for (I=0; I < nSpace; I++)
2051 v_elementBoundary[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
2052 ebN*nQuadraturePoints_elementBoundary*nSpace+
2055 n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
2056 ebN*nQuadraturePoints_elementBoundary*nSpace+
2069 fluxsum += dotk*elementBoundaryQuadratureWeights[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
2070 ebN*nQuadraturePoints_elementBoundary+
2073 area += elementBoundaryQuadratureWeights[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
2074 ebN*nQuadraturePoints_elementBoundary+
2077 rt0vdofs_element[eN*nDOF_RT0V_element + ebN] = fluxsum;
2085 int nElementBoundaries_element,
2086 int nQuadraturePoints_elementBoundary,
2087 int nDOF_RT0V_element,
2088 int* elementBoundaryElementsArray,
2089 int* elementBoundariesArray,
2090 double * elementBoundaryQuadratureWeights,
2091 double * flux_elementBoundary,
2092 double * rt0vdofs_element)
2115 int eN,ebN,ebN_global,k;
2116 double fluxsum,
sign;
2117 for (eN = 0; eN < nElements_global; eN++)
2119 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2121 ebN_global = elementBoundariesArray[eN*nElementBoundaries_element+ebN];
2124 if(elementBoundaryElementsArray[2*ebN_global+1] == eN)
2126 for (k = 0; k < nQuadraturePoints_elementBoundary; k++)
2128 fluxsum +=
sign*flux_elementBoundary[ebN_global*nQuadraturePoints_elementBoundary+
2131 elementBoundaryQuadratureWeights[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
2132 ebN*nQuadraturePoints_elementBoundary+
2135 rt0vdofs_element[eN*nDOF_RT0V_element + ebN] = fluxsum;
2144 int nElementBoundaries_element,
2145 int nPoints_element,
2147 int nDetVals_element,
2149 int * elementNodesArray,
2152 double * rt0vdofs_element,
2172 int nDOF_RT0V_element = nSpace+1;
2173 double volFact,dvolInv;
2174 double ddim = nSpace;
2175 double volume = 0.0;
2177 if (nSpace > 1) volFact = 0.5;
2178 if (nSpace > 2) volFact = 1.0/6.0;
2180 for (eN = 0; eN < nElements_global; eN++)
2182 volume = volFact*abs_det_J[eN*nDetVals_element + 0];
2183 assert(volume > 0.0);
2184 dvolInv = 1.0/(ddim*volume);
2186 for (k = 0; k < nPoints_element; k++)
2188 for (I = 0; I < nSpace; I++)
2190 v_element[eN*nPoints_element*nSpace + k*nSpace + I] = 0.0;
2191 for (j = 0; j < nElementBoundaries_element; j++)
2193 jg = elementNodesArray[eN*nElementBoundaries_element + j];
2194 v_element[eN*nPoints_element*nSpace + k*nSpace + I] +=
2195 rt0vdofs_element[eN*nDOF_RT0V_element + j]
2198 *(x_element[eN*nPoints_element*3 + k*3 + I]- nodeArray[jg*3 + I]);
2210 int nElementBoundaries_element,
2211 int nPoints_elementBoundary,
2213 int nDetVals_element,
2215 int * elementNodesArray,
2217 double * x_elementBoundary,
2218 double * rt0vdofs_element,
2219 double * v_elementBoundary)
2237 int eN,ebN,I,k,j,jg;
2238 int nDOF_RT0V_element = nSpace+1;
2239 double volFact,dvolInv;
2240 double ddim = nSpace;
2241 double volume = 0.0;
2243 if (nSpace > 1) volFact = 0.5;
2244 if (nSpace > 2) volFact = 1.0/6.0;
2246 for (eN = 0; eN < nElements_global; eN++)
2248 volume = volFact*abs_det_J[eN*nDetVals_element + 0];
2249 assert(volume > 0.0);
2250 dvolInv = 1.0/(ddim*volume);
2251 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2253 for (k = 0; k < nPoints_elementBoundary; k++)
2255 for (I = 0; I < nSpace; I++)
2257 v_elementBoundary[eN*nElementBoundaries_element*nPoints_elementBoundary*nSpace +
2258 ebN*nPoints_elementBoundary*nSpace+
2259 k*nSpace + I] = 0.0;
2260 for (j = 0; j < nElementBoundaries_element; j++)
2262 jg = elementNodesArray[eN*nElementBoundaries_element + j];
2263 v_elementBoundary[eN*nElementBoundaries_element*nPoints_elementBoundary*nSpace +
2264 ebN*nPoints_elementBoundary*nSpace+
2266 rt0vdofs_element[eN*nDOF_RT0V_element + j]
2269 *(x_elementBoundary[eN*nElementBoundaries_element*nPoints_elementBoundary*3 + ebN*nPoints_elementBoundary*3+k*3 + I]- nodeArray[jg*3 + I]);
2278 int nPoints_elementBoundary_global,
2280 int nDetVals_element,
2282 int *elementNodesArray,
2283 int *elementBoundaryElementsArray,
2285 double * x_elementBoundary_global,
2286 double * rt0vdofs_element,
2287 double * v_elementBoundary_global)
2305 int eN,ebN,I,k,j,jg;
2306 int nDOF_RT0V_element = nSpace+1;
2307 double volFact,dvolInv;
2308 double ddim = nSpace;
2309 double volume = 0.0;
2311 if (nSpace > 1) volFact = 0.5;
2312 if (nSpace > 2) volFact = 1.0/6.0;
2314 for (ebN = 0; ebN < nElementBoundaries_global; ebN++)
2316 eN = elementBoundaryElementsArray[ebN*2 + 0];
2317 volume = volFact*abs_det_J[eN*nDetVals_element + 0];
2318 assert(volume > 0.0);
2319 dvolInv = 1.0/(ddim*volume);
2320 for (k = 0; k < nPoints_elementBoundary_global; k++)
2322 for (I = 0; I < nSpace; I++)
2324 v_elementBoundary_global[ebN*nPoints_elementBoundary_global*nSpace +
2327 for (j = 0; j < nDOF_RT0V_element; j++)
2329 jg = elementNodesArray[eN*nDOF_RT0V_element + j];
2330 v_elementBoundary_global[ebN*nPoints_elementBoundary_global*nSpace+k*nSpace + I] +=
2331 rt0vdofs_element[eN*nDOF_RT0V_element + j]
2334 *(x_elementBoundary_global[ebN*nPoints_elementBoundary_global*3+k*3 + I]- nodeArray[jg*3 + I]);
2341 int nPoints_elementBoundary_global,
2343 int nDetVals_element,
2345 int *elementNodesArray,
2346 int *elementBoundaryElementsArray,
2347 int* exteriorElementBoundariesArray,
2350 double * rt0vdofs_element,
2369 int eN,ebN,ebNE,I,k,j,jg;
2370 int nDOF_RT0V_element = nSpace+1;
2371 double volFact,dvolInv;
2372 double ddim = nSpace;
2373 double volume = 0.0;
2375 if (nSpace > 1) volFact = 0.5;
2376 if (nSpace > 2) volFact = 1.0/6.0;
2377 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
2379 ebN = exteriorElementBoundariesArray[ebNE];
2380 eN = elementBoundaryElementsArray[ebN*2 + 0];
2381 volume = volFact*abs_det_J[eN*nDetVals_element + 0];
2382 assert(volume > 0.0);
2383 dvolInv = 1.0/(ddim*volume);
2384 for (k = 0; k < nPoints_elementBoundary_global; k++)
2386 for (I = 0; I < nSpace; I++)
2388 v_ebqe[ebNE*nPoints_elementBoundary_global*nSpace +
2391 for (j = 0; j < nDOF_RT0V_element; j++)
2393 jg = elementNodesArray[eN*nDOF_RT0V_element + j];
2394 v_ebqe[ebNE*nPoints_elementBoundary_global*nSpace+k*nSpace + I] +=
2395 rt0vdofs_element[eN*nDOF_RT0V_element + j]
2398 *(x_ebqe[ebNE*nPoints_elementBoundary_global*3+k*3 + I]- nodeArray[jg*3 + I]);
2406 int nElementBoundaries_element,
2409 int nDetVals_element,
2410 const double * nodeArray,
2411 const int * elementNodesArray,
2412 const double * abs_det_J,
2414 const int * element_locations,
2415 const double * rt0vdofs_element,
2435 int nDOF_RT0V_element = nSpace+1;
2436 double volFact,dvolInv;
2437 double ddim = nSpace;
2438 double volume = 0.0;
2440 if (nSpace > 1) volFact = 0.5;
2441 if (nSpace > 2) volFact = 1.0/6.0;
2442 for (k = 0; k < nPoints; k++)
2444 eN = element_locations[k];
2445 assert(0 <= eN && eN < nElements_global);
2446 volume = volFact*abs_det_J[eN*nDetVals_element + 0];
2447 assert(volume > 0.0);
2448 dvolInv = 1.0/(ddim*volume);
2449 for (I = 0; I < nSpace; I++)
2451 v_element[k*nSpace + I] = 0.0;
2452 for (j = 0; j < nElementBoundaries_element; j++)
2454 jg = elementNodesArray[eN*nElementBoundaries_element + j];
2455 v_element[k*nSpace + I] +=
2456 rt0vdofs_element[eN*nDOF_RT0V_element + j]
2459 *(x[k*3 + I]- nodeArray[jg*3 + I]);
2470 int nElementBoundaries_element,
2471 int nQuadraturePoints_elementBoundary,
2473 int nDOFs_test_element,
2474 int nDOFs_trial_element,
2479 double * BDMprojectionMat_element)
2505 int eN,ebN,
s,j,k,l,kp,irow,ibq,nVDOFs_element2,nSimplex;
2506 int TRANSPOSE_FOR_LAPACK=1;
2508 nSimplex = nSpace+1;
2509 assert(nVDOFs_element == nSpace*(nSpace+1));
2510 assert(nSimplex == nDOFs_trial_element);
2511 assert(nSimplex == nDOFs_test_element);
2512 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
2519 for (eN=0; eN < nElements_global; eN++)
2521 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2523 for (
s = 0;
s < nSpace;
s++)
2525 irow = ebN*nSpace +
s;
2526 for (j = 0; j < nVDOFs_element; j++)
2530 kp= (ebN+
s+1) % nSimplex;
2535 if (TRANSPOSE_FOR_LAPACK > 0)
2536 BDMprojectionMat_element[eN*nVDOFs_element2 + irow + j*nVDOFs_element] = 0.0;
2538 BDMprojectionMat_element[eN*nVDOFs_element2 + irow*nVDOFs_element + j] = 0.0;
2539 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
2543 ebq_n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
2544 ebN*nQuadraturePoints_elementBoundary*nSpace+
2548 w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_test_element+
2549 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
2550 ibq*nDOFs_test_element+
2553 ebq_v[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_trial_element+
2554 ebN*nQuadraturePoints_elementBoundary*nDOFs_trial_element+
2555 ibq*nDOFs_trial_element+
2557 if (TRANSPOSE_FOR_LAPACK > 0)
2558 BDMprojectionMat_element[eN*nVDOFs_element2 + irow + j*nVDOFs_element] += pval;
2560 BDMprojectionMat_element[eN*nVDOFs_element2 + irow*nVDOFs_element + j] += pval;
2572 int nElementBoundaries_element,
2573 int nQuadraturePoints_elementBoundary,
2575 int nDOFs_test_element,
2576 int nDOFs_trial_element,
2581 double * BDMprojectionMat_element)
2627 int eN,ebN,
s,j,k,l,kp,irow,ibq,nVDOFs_element2,nSimplex;
2628 int TRANSPOSE_FOR_LAPACK=1;
2630 nSimplex = nSpace+1;
2631 assert(nVDOFs_element == nSpace*(nSpace+1));
2632 assert(nSimplex == nDOFs_trial_element);
2633 assert(nSimplex == nDOFs_test_element);
2634 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
2644 for (eN=0; eN < nElements_global; eN++)
2646 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2648 for (
s = 0;
s < nSpace;
s++)
2650 irow = ebN*nSpace +
s;
2651 for (j = 0; j < nVDOFs_element; j++)
2655 kp= (ebN+
s+1) % nSimplex;
2663 if (TRANSPOSE_FOR_LAPACK > 0)
2664 BDMprojectionMat_element[eN*nVDOFs_element2 + irow + j*nVDOFs_element] = 0.0;
2666 BDMprojectionMat_element[eN*nVDOFs_element2 + irow*nVDOFs_element + j] = 0.0;
2667 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
2671 ebq_n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
2672 ebN*nQuadraturePoints_elementBoundary*nSpace+
2676 w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_test_element+
2677 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
2678 ibq*nDOFs_test_element+
2681 ebq_v[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_trial_element+
2682 ebN*nQuadraturePoints_elementBoundary*nDOFs_trial_element+
2683 ibq*nDOFs_trial_element+
2685 if (TRANSPOSE_FOR_LAPACK > 0){
2686 BDMprojectionMat_element[eN*nVDOFs_element2 + irow + j*nVDOFs_element] += pval;
2689 BDMprojectionMat_element[eN*nVDOFs_element2 + irow*nVDOFs_element + j] += pval;
2710 int nElements_global,
2711 int nElementBoundaries_element,
2712 int nQuadraturePoints_elementBoundary,
2713 int nQuadraturePoints_elementInterior,
2715 int nDOFs_test_element,
2716 int nDOFs_trial_boundary_element,
2717 int nDOFs_trial_interior_element,
2723 double * BDMprojectionMat_element,
2724 double * q_basis_vals,
2725 double * w_int_test_grads,
2726 double * w_int_div_free,
2727 double * piola_trial_fun)
2735 int eN,ebN,
s,i,j,k,l,kp,irow,ibq,nSimplex;
2736 int dof, dof_edge, boundary_dof;
2738 int TRANSPOSE_FOR_LAPACK=1;
2739 double pval, pvalx, pvaly;
2740 nSimplex = nSpace+1;
2741 assert(degree == 2);
2743 int interiorPspace = nDOFs_trial_interior_element;
2746 dof = (degree+1)*(degree+2);
2747 dof_edge = degree + 1;
2748 boundary_dof = nElementBoundaries_element*dof_edge;
2751 else if (nSpace == 3){
2752 dof = (degree+1)*(degree+2)*(degree+3) / 2;
2753 dof_edge = degree*(degree+1);
2754 boundary_dof = nElementBoundaries_element*dof_edge;
2761 int interior_dof = dof - boundary_dof;
2765 for (eN=0; eN < nElements_global; eN++)
2769 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
2771 for (
s = 0;
s < dof_edge;
s++)
2773 irow = ebN*dof_edge +
s;
2775 for (j = 0; j < dof; j++)
2780 kp = edgeFlags[ebN*dof_edge+
s];
2782 if (TRANSPOSE_FOR_LAPACK > 0)
2783 BDMprojectionMat_element[eN*dof*dof + irow + j*nVDOFs_element] = 0.;
2785 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j] = 0.;
2787 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
2791 ebq_n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace +
2792 ebN*nQuadraturePoints_elementBoundary*nSpace+
2796 w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary* nDOFs_test_element+
2797 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
2798 ibq*nDOFs_test_element+
2801 ebq_v[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_trial_boundary_element+
2802 ebN*nQuadraturePoints_elementBoundary*nDOFs_trial_boundary_element+
2803 ibq*nDOFs_trial_boundary_element+
2807 if (TRANSPOSE_FOR_LAPACK > 0)
2808 BDMprojectionMat_element[eN*dof*dof + irow + j*nVDOFs_element] += pval;
2810 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j] += pval;
2820 for (
s = 0;
s < interiorPspace-1;
s++){
2822 irow = boundary_dof +
s;
2823 for (j=0; j < (dof/nSpace); j++){
2826 if (TRANSPOSE_FOR_LAPACK > 0){
2827 for (i = 0; i < nSpace; i++){
2828 BDMprojectionMat_element[eN*dof*dof + irow + j*dof*nSpace + i*dof] = 0.0;
2833 for (i = 0; i < nSpace; i++){
2834 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j + i] = 0.0;
2838 for (ibq=0; ibq < nQuadraturePoints_elementInterior; ibq++){
2841 for (i = 0; i < nSpace; i++){
2843 if (TRANSPOSE_FOR_LAPACK > 0){
2845 BDMprojectionMat_element[eN*dof*dof + irow + j*dof*nSpace + i*dof] +=
2847 q_basis_vals[eN* (dof/nSpace) *nQuadraturePoints_elementInterior +
2848 ibq*nDOFs_test_element +
2850 * w_int_test_grads[eN*nSpace*interiorPspace*nQuadraturePoints_elementInterior+
2852 ibq* nSpace *interiorPspace + i];
2856 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j] += pval;
2857 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j + 1] += pval;
2867 irow = boundary_dof + interiorPspace - 1;
2868 for (j=0; j < dof; j++){
2870 if (TRANSPOSE_FOR_LAPACK > 0){
2871 for (
s = 0;
s < num_div_free;
s++){
2872 BDMprojectionMat_element[eN*dof*dof + (irow +
s) + j*nVDOFs_element] = 0.0;
2876 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j] = 0.0;
2878 for (ibq=0; ibq<nQuadraturePoints_elementInterior; ibq++)
2881 if (TRANSPOSE_FOR_LAPACK > 0){
2882 for(
s = 0;
s < num_div_free;
s++){
2883 for (i=0 ; i < nSpace; i++){
2884 BDMprojectionMat_element[eN*dof*dof + (irow +
s) + j*nVDOFs_element] +=
2886 w_int_div_free[eN * nQuadraturePoints_elementInterior * nSpace * num_div_free +
2887 ibq * nSpace * num_div_free +
2891 * piola_trial_fun[eN * nQuadraturePoints_elementInterior * dof * nSpace +
2892 ibq * dof * nSpace +
2899 BDMprojectionMat_element[eN*dof*dof + irow*nVDOFs_element + j] = 0.0;
2908 double *BDMprojectionMat_element,
2909 int *BDMprojectionMatPivots_element)
2911 PROTEUS_LAPACK_INTEGER INFO=0;
2912 int eN,i,nVDOFs_element2;
2913 PROTEUS_LAPACK_INTEGER pivots_element[12];
2914 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
2915 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
2916 for (eN = 0; eN < nElements_global; eN++)
2920 &BDMprojectionMat_element[eN*nVDOFs_element2],
2927 for (i = 0; i < nVDOFs_element; i++)
2928 BDMprojectionMatPivots_element[eN*nVDOFs_element+i] = (
int) pivots_element[i];
2937 double *BDMprojectionMat_element,
2938 int *BDMprojectionMatPivots_element)
2940 PROTEUS_LAPACK_INTEGER INFO=0;
2941 int eN,i,nVDOFs_element2;
2942 PROTEUS_LAPACK_INTEGER pivots_element[30];
2943 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
2944 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
2945 for (eN = 0; eN < nElements_global; eN++)
2949 &BDMprojectionMat_element[eN*nVDOFs_element2],
2956 for (i = 0; i < nVDOFs_element; i++)
2957 BDMprojectionMatPivots_element[eN*nVDOFs_element+i] = (
int) pivots_element[i];
2965 int nElementBoundaries_element,
2966 int nQuadraturePoints_elementBoundary,
2968 int nDOFs_test_element,
2970 double * BDMprojectionMatFact_element,
2971 int* BDMprojectionMatPivots_element,
2974 double * ebq_velocity,
2975 double * p1_velocity_dofs)
2994 PROTEUS_LAPACK_INTEGER INFO=0,NRHS=1;
2996 int eN,ebN,
s,irow,kp,ibq,J,nSimplex,nVDOFs_element2;
2998 PROTEUS_LAPACK_INTEGER pivots_element[12];
2999 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
3001 nSimplex = nSpace+1;
3002 assert(nVDOFs_element == nSpace*(nSpace+1));
3003 assert(nSimplex == nDOFs_test_element);
3004 assert(BDMprojectionMatPivots_element);
3005 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
3007 for (eN = 0; eN < nElements_global; eN++)
3009 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
3011 for (
s = 0;
s < nSpace;
s++)
3013 irow = ebN*nSpace +
s;
3014 kp = (ebN+
s+1) % nSimplex;
3016 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
3018 for (J = 0; J < nSpace; J++)
3021 ebq_n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3022 ebN*nQuadraturePoints_elementBoundary*nSpace+
3026 ebq_velocity[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3027 ebN*nQuadraturePoints_elementBoundary*nSpace+
3030 * w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3031 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3032 ibq*nDOFs_test_element+
3036 p1_velocity_dofs[eN*nVDOFs_element+irow] = btmp;
3039 for (irow = 0; irow < nVDOFs_element; irow++)
3040 pivots_element[irow] = BDMprojectionMatPivots_element[eN*nVDOFs_element+irow];
3044 &BDMprojectionMatFact_element[eN*nVDOFs_element2],
3047 &p1_velocity_dofs[eN*nVDOFs_element],
3055 int nElementBoundaries_element,
3056 int nQuadraturePoints_elementBoundary,
3057 int nQuadraturePoints_elementInterior,
3059 int nDOFs_test_element,
3061 int nDOFs_trial_interior_element,
3062 double * BDMprojectionMatFact_element,
3063 int* BDMprojectionMatPivots_element,
3067 double * w_interior_grads,
3068 double * w_interior_divfree,
3069 double * ebq_velocity,
3070 double * q_velocity,
3071 double * p1_velocity_dofs)
3092 PROTEUS_LAPACK_INTEGER INFO=0,NRHS=1;
3094 int eN,ebN,
s,irow,kp,ibq,j,dof_edge,num_div_free,boundary_dof,dof;
3095 double btmp,pvalx,pvaly;
3096 PROTEUS_LAPACK_INTEGER pivots_element[30];
3097 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
3101 int interiorPspace = nDOFs_trial_interior_element;
3104 dof = (degree+1)*(degree+2);
3105 dof_edge = degree + 1;
3106 boundary_dof = nElementBoundaries_element*dof_edge;
3109 else if (nSpace == 3){
3110 dof = (degree+1)*(degree+2)*(degree+3) / 2;
3111 dof_edge = degree*(degree+1);
3112 boundary_dof = nElementBoundaries_element*dof_edge;
3119 assert(nVDOFs_element == dof);
3120 assert(BDMprojectionMatPivots_element);
3122 for (eN = 0; eN < nElements_global; eN++)
3125 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
3127 for (
s = 0;
s < dof_edge;
s++)
3129 irow = ebN*dof_edge +
s;
3130 kp = edgeFlags[ebN*dof_edge +
s];
3133 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
3135 for (j = 0; j < nSpace; j++) {
3138 ebq_n[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3139 ebN*nQuadraturePoints_elementBoundary*nSpace+
3143 ebq_velocity[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3144 ebN*nQuadraturePoints_elementBoundary*nSpace+
3147 * w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3148 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3149 ibq*nDOFs_test_element+
3154 p1_velocity_dofs[eN*nVDOFs_element+irow] = btmp;
3160 for (
s = 0;
s < interiorPspace-1;
s++){
3162 irow = boundary_dof +
s;
3163 p1_velocity_dofs[eN*nVDOFs_element+irow] = 0. ;
3165 for (ibq=0; ibq < nQuadraturePoints_elementInterior; ibq++){
3168 for (j = 0 ; j < nSpace; j++){
3170 p1_velocity_dofs[eN*nVDOFs_element+irow] +=
3172 q_velocity[eN*nQuadraturePoints_elementInterior*nSpace +
3175 w_interior_grads[eN*nSpace*interiorPspace*nQuadraturePoints_elementInterior +
3177 ibq * nSpace * interiorPspace +
3186 irow = boundary_dof + interiorPspace - 1;
3187 for (
s = 0 ;
s < num_div_free ;
s++){
3188 p1_velocity_dofs[eN*nVDOFs_element + (irow +
s) ] = 0.0 ;
3191 for (ibq = 0; ibq < nQuadraturePoints_elementInterior; ibq++){
3192 for (
s = 0 ;
s < num_div_free ;
s++){
3193 for (j = 0 ; j < nSpace ; j++){
3195 p1_velocity_dofs[eN*nVDOFs_element + (irow +
s) ] +=
3197 q_velocity[eN * nQuadraturePoints_elementInterior * nSpace +
3201 w_interior_divfree[eN * nQuadraturePoints_elementInterior * num_div_free * nSpace+
3202 ibq * num_div_free * nSpace +
3214 int nElementBoundaries_element,
3215 int nQuadraturePoints_elementBoundary,
3217 int nDOFs_test_element,
3219 double * BDMprojectionMatFact_element,
3220 int* BDMprojectionMatPivots_element,
3223 double * w_interior_gradients,
3224 double * q_velocity,
3225 double * ebq_velocity,
3226 double * p1_velocity_dofs)
3233 PROTEUS_LAPACK_INTEGER INFO=0,NRHS=1;
3235 int eN,ebN,
s,irow,kp,ibq,J,nSimplex,nVDOFs_element2;
3237 PROTEUS_LAPACK_INTEGER pivots_element[30];
3238 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
3240 for (eN = 0; eN < nElements_global; eN++)
3243 for (irow = 0; irow < nVDOFs_element; irow++)
3244 pivots_element[irow] = BDMprojectionMatPivots_element[eN*nVDOFs_element+irow];
3249 &BDMprojectionMatFact_element[eN*nVDOFs_element*nVDOFs_element],
3252 &p1_velocity_dofs[eN*nVDOFs_element],
3262 int nElementBoundaries_element,
3263 int nQuadraturePoints_elementBoundary,
3264 int nDOFs_test_element,
3266 double * BDMprojectionMatFact_element,
3267 int* BDMprojectionMatPivots_element,
3268 int* elementBoundaryElementsArray,
3269 int* elementBoundariesArray,
3271 double * ebq_global_flux,
3272 double * p1_velocity_dofs)
3291 PROTEUS_LAPACK_INTEGER INFO=0,NRHS=1;
3293 int eN,ebN,ebN_global,nSpace,
s,irow,kp,ibq,nSimplex,nVDOFs_element2;
3295 PROTEUS_LAPACK_INTEGER pivots_element[12];
3296 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER) nVDOFs_element);
3298 nSimplex = nDOFs_test_element;
3299 nSpace = nSimplex - 1;
3300 assert(nVDOFs_element == nSpace*(nSpace+1));
3301 assert(nSimplex == nDOFs_test_element);
3302 assert(BDMprojectionMatPivots_element);
3303 nVDOFs_element2 = nVDOFs_element*nVDOFs_element;
3305 for (eN = 0; eN < nElements_global; eN++)
3307 for (ebN = 0; ebN < nElementBoundaries_element; ebN++)
3309 ebN_global = elementBoundariesArray[eN*nElementBoundaries_element+ebN];
3311 if(elementBoundaryElementsArray[2*ebN_global+1] == eN)
3313 for (
s = 0;
s < nSimplex;
s++)
3315 irow = ebN*nSpace +
s;
3316 kp = (ebN+
s+1) % nSimplex;
3318 for (ibq = 0; ibq < nQuadraturePoints_elementBoundary; ibq++)
3320 btmp +=
sign*ebq_global_flux[ebN_global*nQuadraturePoints_elementBoundary+ibq]
3322 w_dS_f[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3323 ebN*nQuadraturePoints_elementBoundary*nDOFs_test_element+
3324 ibq*nDOFs_test_element+
3327 p1_velocity_dofs[eN*nVDOFs_element+irow] = btmp;
3330 for (irow = 0; irow < nVDOFs_element; irow++)
3331 pivots_element[irow] = BDMprojectionMatPivots_element[eN*nVDOFs_element+irow];
3335 &BDMprojectionMatFact_element[eN*nVDOFs_element2],
3338 &p1_velocity_dofs[eN*nVDOFs_element],
3346 int nQuadraturePoints_element,
3348 int nDOF_trial_element,
3351 double * p1_velocity_dofs,
3352 double * q_velocity)
3365 for (eN = 0; eN < nElements_global; eN++)
3367 for (iq = 0; iq < nQuadraturePoints_element; iq++)
3369 for (
id = 0;
id < nSpace;
id++)
3371 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] = 0.0;
3372 for (k = 0; k < nSpace+1; k++)
3374 j =
id*(nSpace+1) + k;
3375 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] +=
3376 q_v[eN*nQuadraturePoints_element*nDOF_trial_element + iq*nDOF_trial_element + k]
3378 p1_velocity_dofs[eN*nVDOF_element + j];
3387 int nQuadraturePoints_element,
3389 int nDOF_trial_element,
3392 double * p1_velocity_dofs,
3393 double * q_velocity)
3406 for (eN = 0; eN < nElements_global; eN++)
3408 for (iq = 0; iq < nQuadraturePoints_element; iq++)
3410 for (
id = 0;
id < nSpace;
id++)
3412 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] = 0.0;
3413 for (k = 0; k < nSpace+1; k++)
3416 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] +=
3417 q_v[eN*nQuadraturePoints_element*nDOF_trial_element + iq*nDOF_trial_element + k]
3419 p1_velocity_dofs[eN*nVDOF_element + j];
3428 int nQuadraturePoints_element,
3430 int nDOF_trial_element,
3433 double * p1_velocity_dofs,
3434 double * q_velocity)
3446 for (eN = 0; eN < nElements_global; eN++)
3448 for (iq = 0; iq < nQuadraturePoints_element; iq++)
3450 for (
id = 0;
id < nSpace;
id++)
3452 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] = 0.0;
3453 for (k = 0; k < nDOF_trial_element; k++)
3456 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] +=
3457 q_v[eN*nQuadraturePoints_element*nDOF_trial_element + iq*nDOF_trial_element + k]
3459 p1_velocity_dofs[eN*nVDOF_element + j];
3469 int nQuadraturePoints_element,
3471 int nDOF_trial_element,
3474 double * velocity_dofs,
3475 double * q_velocity)
3483 for (eN = 0; eN < nElements_global; eN++)
3485 for (iq = 0; iq < nQuadraturePoints_element; iq++)
3487 for (
id = 0;
id < nSpace;
id++)
3489 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] = 0.0;
3491 for (k=0; k < nDOF_trial_element; k++)
3495 q_velocity[eN*nQuadraturePoints_element*nSpace + iq*nSpace + id] +=
3496 q_v[eN*nQuadraturePoints_element*nDOF_trial_element + iq*nDOF_trial_element + k]
3498 velocity_dofs[eN*nVDOF_element + j];
3507 int nQuadraturePoints_elementBoundary,
3509 int nDOF_trial_element,
3511 int *elementBoundaryElementsArray,
3512 int *exteriorElementBoundariesArray,
3514 double * p1_velocity_dofs,
3515 double * ebqe_velocity)
3526 int ebN,ebNE,eN,iq,id,k,j;
3528 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3530 ebN = exteriorElementBoundariesArray[ebNE];
3531 eN = elementBoundaryElementsArray[ebN*2 + 0];
3533 for (iq = 0; iq < nQuadraturePoints_elementBoundary; iq++)
3535 for (
id = 0;
id < nSpace;
id++)
3537 ebqe_velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] = 0.0;
3538 for (k = 0; k < nSpace+1; k++)
3541 ebqe_velocity[ebNE*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] +=
3542 ebqe_v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element + iq*nDOF_trial_element + k]
3544 p1_velocity_dofs[eN*nVDOF_element + j];
3552 int nQuadraturePoints_elementBoundary,
3554 int nDOF_trial_element,
3556 int *elementBoundaryElementsArray,
3557 int *exteriorElementBoundariesArray,
3559 double * p1_velocity_dofs,
3560 double * ebq_global_velocity)
3571 int ebN,ebNE,eN,iq,id,k,j;
3573 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3575 ebN = exteriorElementBoundariesArray[ebNE];
3576 eN = elementBoundaryElementsArray[ebN*2 + 0];
3578 for (iq = 0; iq < nQuadraturePoints_elementBoundary; iq++)
3580 for (
id = 0;
id < nSpace;
id++)
3582 ebq_global_velocity[ebN*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] = 0.0;
3583 for (k = 0; k < nSpace+1; k++)
3586 ebq_global_velocity[ebN*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] +=
3587 ebqe_v[ebNE*nQuadraturePoints_elementBoundary*nDOF_trial_element + iq*nDOF_trial_element + k]
3589 p1_velocity_dofs[eN*nVDOF_element + j];
3598 int nBoundaries_Element,
3599 int nQuadraturePoints_elementBoundary,
3601 int nDOF_trial_element,
3603 int *elementBoundaryElementsArray,
3604 int *exteriorElementBoundariesArray,
3606 double * p1_velocity_dofs,
3607 double * ebq_velocity)
3618 int ebN,eN,iq,id,k,j;
3620 for (eN = 0; eN < nElements_global; eN++)
3623 for (ebN=0; ebN < nBoundaries_Element; ebN ++)
3625 for (iq = 0; iq < nQuadraturePoints_elementBoundary; iq++)
3627 for (
id = 0;
id < nSpace;
id++)
3629 ebq_velocity[eN*nBoundaries_Element*nQuadraturePoints_elementBoundary*nSpace
3630 + ebN*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] = 0.0;
3631 for (k = 0; k < nSpace+1; k++)
3634 ebq_velocity[eN*ebN*nQuadraturePoints_elementBoundary*nSpace
3635 + nBoundaries_Element*nQuadraturePoints_elementBoundary*nSpace + iq*nSpace + id] +=
3636 ebq_v[eN*nBoundaries_Element*nQuadraturePoints_elementBoundary*nDOF_trial_element
3637 + ebN*nQuadraturePoints_elementBoundary*iq*nDOF_trial_element + k]
3639 p1_velocity_dofs[eN*nVDOF_element + j];
3652 int nInteriorElementBoundaries_global,
3653 int nExteriorElementBoundaries_global,
3654 int nElementBoundaries_element,
3655 int nQuadraturePoints_elementBoundary,
3658 int* interiorElementBoundaries,
3659 int* exteriorElementBoundaries,
3660 int* elementBoundaryElements,
3661 int* elementBoundaryLocalElementBoundaries,
3662 int* exteriorElementBoundariesToSkip,
3665 double* elementResidual,
3667 double* conservationResidual)
3669 int ebNI,ebNE,ebN,eN,nN,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,k,I;
3670 register double flux,ds;
3674 for (eN = 0; eN < nElements_global; eN++)
3676 for (nN = 0; nN < nNodes_element; nN++)
3678 conservationResidual[eN] += elementResidual[eN*nNodes_element + nN];
3683 for (ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
3685 ebN = interiorElementBoundaries[ebNI];
3686 left_eN = elementBoundaryElements[ebN*2+0];
3687 right_eN = elementBoundaryElements[ebN*2+1];
3688 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
3689 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
3692 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
3694 ds = dS[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
3695 left_ebN_element*nQuadraturePoints_elementBoundary+
3697 for (I = 0; I < nSpace; I++)
3699 flux+= velocity[ebN*nQuadraturePoints_elementBoundary*nSpace+
3703 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
3710 conservationResidual[left_eN] += flux;
3711 conservationResidual[right_eN]-= flux;
3715 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3717 if (!exteriorElementBoundariesToSkip[ebNE])
3719 ebN = exteriorElementBoundaries[ebNE];
3720 eN = elementBoundaryElements[ebN*2+0];
3721 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
3723 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
3725 ds = dS[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
3726 ebN_element*nQuadraturePoints_elementBoundary+
3728 for (I = 0; I < nSpace; I++)
3730 flux+= velocity[ebN*nQuadraturePoints_elementBoundary*nSpace+
3734 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
3741 conservationResidual[eN] += flux;
3747 int nElementBoundaries_global,
3748 int nInteriorElementBoundaries_global,
3749 int nExteriorElementBoundaries_global,
3750 int nElementBoundaries_element,
3751 int nQuadraturePoints_elementBoundary,
3753 int* interiorElementBoundaries,
3754 int* exteriorElementBoundaries,
3755 int* elementBoundaryElements,
3756 int* elementBoundaryLocalElementBoundaries,
3761 double* fluxCorrection,
3762 double* conservationResidual)
3764 int ebNI,ebN,left_eN,right_eN,left_ebN_element,right_ebN_element;
3765 register double area,areaFact,F_ebN;
3770 for (ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
3772 ebN = interiorElementBoundaries[ebNI];
3773 left_eN = elementBoundaryElements[ebN*2+0];
3774 right_eN = elementBoundaryElements[ebN*2+1];
3775 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
3776 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
3778 area = areaFact*sqrt_det_g[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary +
3779 left_ebN_element*nQuadraturePoints_elementBoundary + 0];
3780 F_ebN = alpha[ebN*2+0]*conservationResidual[left_eN]
3781 + alpha[ebN*2+1]*conservationResidual[right_eN];
3783 fluxCorrection[ebN] += F_ebN;
3786 conservationResidual[left_eN] -= area*F_ebN;
3787 conservationResidual[right_eN]+= area*F_ebN;
3796 int nElementBoundaries_global,
3797 int nInteriorElementBoundaries_global,
3798 int nExteriorElementBoundaries_global,
3799 int nElementBoundaries_element,
3800 int nQuadraturePoints_elementBoundary,
3802 int* interiorElementBoundaries,
3803 int* exteriorElementBoundaries,
3804 int* elementBoundaryElements,
3805 int* elementBoundaryLocalElementBoundaries,
3808 double* fluxCorrection,
3809 double* vConservative,
3810 double* vConservative_element)
3812 int eN,ebN_element,ebNI,ebNE,ebN,left_eN,right_eN,left_ebN_element,right_ebN_element,k,I;
3814 for (ebN = 0; ebN < nElementBoundaries_global; ebN++)
3816 for (k=0; k < nQuadraturePoints_elementBoundary; k++)
3818 for (I=0; I < nSpace; I++)
3820 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace +
3822 -= fluxCorrection[ebN]
3823 * normal[ebN*nQuadraturePoints_elementBoundary*nSpace +
3829 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
3831 ebN = interiorElementBoundaries[ebNI];
3832 left_eN = elementBoundaryElements[ebN*2+0];
3833 right_eN = elementBoundaryElements[ebN*2+1];
3834 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
3835 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
3836 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
3837 for(I=0;I<nSpace;I++)
3839 vConservative_element[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3840 left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
3844 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
3847 vConservative_element[right_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3848 right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
3852 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
3857 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
3859 ebN = exteriorElementBoundaries[ebNE];
3860 eN = elementBoundaryElements[ebN*2+0];
3861 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
3862 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
3863 for(I=0;I<nSpace;I++)
3865 vConservative_element[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
3866 ebN_element*nQuadraturePoints_elementBoundary*nSpace+
3870 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
3878 int nInteriorElementBoundaries_global,
3879 int nExteriorElementBoundaries_global,
3880 int* interiorElementBoundaries,
3881 int* exteriorElementBoundaries,
3882 int* elementBoundaryElements,
3885 double* fluxCorrection)
3893 int ebNI,ebNE,ebN,eN_left,eN_right;
3894 double V_left,V_right,w_left,w_right;
3895 for (ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
3897 ebN = interiorElementBoundaries[ebNI];
3898 eN_left = elementBoundaryElements[ebN*2 + 0];
3899 eN_right= elementBoundaryElements[ebN*2 + 1];
3900 V_left = pwcV[eN_left];
3901 V_right = pwcV[eN_right];
3902 w_left = pwcW[ebN*2 + 0];
3903 w_right = pwcW[ebN*2 + 1];
3904 fluxCorrection[ebN] = V_left*w_left + V_right*w_right;
3906 for (ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3908 ebN = exteriorElementBoundaries[ebNE];
3909 eN_left = elementBoundaryElements[ebN*2 + 0];
3910 V_left = pwcV[eN_left];
3911 w_left = pwcW[ebN*2 + 0];
3912 fluxCorrection[ebN] = V_left*w_left;
3924 int* nElements_node,
3925 int* nodeStarElementsArray,
3926 int* nodeStarElementNeighborsArray,
3928 int** subdomain_dim_p,
3929 double *** subdomain_L_p,
3930 double *** subdomain_R_p,
3931 double *** subdomain_U_p,
3932 PROTEUS_LAPACK_INTEGER*** subdomain_pivots_p,
3933 PROTEUS_LAPACK_INTEGER*** subdomain_column_pivots_p)
3939 double** subdomain_R;
3940 double** subdomain_U;
3941 double** subdomain_L;
3942 PROTEUS_LAPACK_INTEGER** subdomain_pivots;
3943 PROTEUS_LAPACK_INTEGER** subdomain_column_pivots;
3948 *subdomain_dim_p = (
int*) malloc(N*
sizeof(
int));
3949 *subdomain_pivots_p = (PROTEUS_LAPACK_INTEGER**)malloc(N*
sizeof(PROTEUS_LAPACK_INTEGER*));
3950 *subdomain_column_pivots_p = (PROTEUS_LAPACK_INTEGER**)malloc(N*
sizeof(PROTEUS_LAPACK_INTEGER*));
3951 *subdomain_R_p = (
double**)malloc(N*
sizeof(
double*));
3952 *subdomain_U_p = (
double**)malloc(N*
sizeof(
double*));
3953 *subdomain_L_p = (
double**)malloc(N*
sizeof(
double*));
3955 if ( (*subdomain_dim_p == NULL) ||
3956 (*subdomain_R_p == NULL) ||
3957 (*subdomain_U_p == NULL) ||
3958 (*subdomain_L_p == NULL) ||
3959 (*subdomain_pivots_p == NULL) ||
3960 (*subdomain_column_pivots_p == NULL))
3965 subdomain_dim = *subdomain_dim_p;
3966 subdomain_pivots = *subdomain_pivots_p;
3967 subdomain_column_pivots = *subdomain_column_pivots_p;
3968 subdomain_R = *subdomain_R_p;
3969 subdomain_U = *subdomain_U_p;
3970 subdomain_L = *subdomain_L_p;
3973 for (I = 0; I < N; I++)
3975 subdomain_dim[I] = nElements_node[I];
3976 subdomain_pivots[I] = (PROTEUS_LAPACK_INTEGER*) malloc(subdomain_dim[I]*
sizeof(PROTEUS_LAPACK_INTEGER));
3977 subdomain_column_pivots[I] = (PROTEUS_LAPACK_INTEGER*) malloc(subdomain_dim[I]*
sizeof(PROTEUS_LAPACK_INTEGER));
3978 subdomain_R[I] = (
double*) malloc(subdomain_dim[I]*
sizeof(
double));
3979 subdomain_U[I] = (
double*) malloc(subdomain_dim[I]*
sizeof(
double));
3980 subdomain_L[I] = (
double*) malloc(subdomain_dim[I]*subdomain_dim[I]*
sizeof(
double));
3982 if ((subdomain_pivots[I] == NULL) ||
3983 (subdomain_column_pivots[I] == NULL) ||
3984 (subdomain_R[I] == NULL) ||
3985 (subdomain_U[I] == NULL) ||
3986 (subdomain_L[I] == NULL))
3997 int * subdomain_dim,
3998 double ** subdomain_L,
3999 double ** subdomain_R,
4000 double ** subdomain_U,
4001 PROTEUS_LAPACK_INTEGER** subdomain_pivots,
4002 PROTEUS_LAPACK_INTEGER** subdomain_column_pivots)
4005 free(subdomain_dim);
4006 for (I = 0; I < N; I++)
4008 free(subdomain_pivots[I]);
4009 free(subdomain_column_pivots[I]);
4010 free(subdomain_R[I]);
4011 free(subdomain_U[I]);
4012 free(subdomain_L[I]);
4014 free(subdomain_pivots);
4015 free(subdomain_column_pivots);
4020 subdomain_pivots = 0;
4021 subdomain_column_pivots = 0;
4031 assert(nodeStarFactor);
4032 for (I = 0; I < nodeStarFactor->
N; I++)
4039 int * other_subdomain_dim,
4040 double ** other_subdomain_L,
4041 double ** other_subdomain_R,
4042 double ** other_subdomain_U,
4043 PROTEUS_LAPACK_INTEGER** other_subdomain_pivots,
4044 PROTEUS_LAPACK_INTEGER** other_subdomain_column_pivots,
4046 int** subdomain_dim_p,
4047 double *** subdomain_L_p,
4048 double *** subdomain_R_p,
4049 double *** subdomain_U_p,
4050 PROTEUS_LAPACK_INTEGER*** subdomain_pivots_p,
4051 PROTEUS_LAPACK_INTEGER*** subdomain_column_pivots_p)
4056 double** subdomain_R;
4057 double** subdomain_U;
4058 double** subdomain_L;
4059 PROTEUS_LAPACK_INTEGER** subdomain_pivots;
4060 PROTEUS_LAPACK_INTEGER** subdomain_column_pivots;
4064 realloc = other_N != *N_p;
4067 for (I=0; I < other_N; I++)
4069 realloc = realloc || (other_subdomain_dim[I] != (*subdomain_dim_p)[I]);
4075 printf(
"nodeStar_copy needs to reaalloc self_N=%d other_N=%d \n",*N_p,other_N);
4081 *subdomain_pivots_p,
4082 *subdomain_column_pivots_p);
4088 *subdomain_dim_p = (
int*)malloc(N*
sizeof(
int));
4089 *subdomain_pivots_p = (PROTEUS_LAPACK_INTEGER**)malloc(N*
sizeof(PROTEUS_LAPACK_INTEGER*));
4090 *subdomain_column_pivots_p = (PROTEUS_LAPACK_INTEGER**)malloc(N*
sizeof(PROTEUS_LAPACK_INTEGER*));
4091 *subdomain_R_p = (
double**)malloc(N*
sizeof(
double*));
4092 *subdomain_U_p = (
double**)malloc(N*
sizeof(
double*));
4093 *subdomain_L_p = (
double**)malloc(N*
sizeof(
double*));
4095 if ( (*subdomain_dim_p == NULL) ||
4096 (*subdomain_R_p == NULL) ||
4097 (*subdomain_U_p == NULL) ||
4098 (*subdomain_L_p == NULL) ||
4099 (*subdomain_pivots_p == NULL) ||
4100 (*subdomain_column_pivots_p == NULL) )
4104 subdomain_dim = *subdomain_dim_p;
4105 subdomain_pivots = *subdomain_pivots_p;
4106 subdomain_column_pivots = *subdomain_column_pivots_p;
4107 subdomain_R = *subdomain_R_p;
4108 subdomain_U = *subdomain_U_p;
4109 subdomain_L = *subdomain_L_p;
4112 for (I = 0; I < N; I++)
4114 subdomain_dim[I] = other_subdomain_dim[I];
4115 subdomain_pivots[I] = (PROTEUS_LAPACK_INTEGER*)malloc(subdomain_dim[I]*
sizeof(PROTEUS_LAPACK_INTEGER));
4116 subdomain_column_pivots[I] = (PROTEUS_LAPACK_INTEGER*)malloc(subdomain_dim[I]*
sizeof(PROTEUS_LAPACK_INTEGER));
4117 subdomain_R[I] = (
double*)malloc(subdomain_dim[I]*
sizeof(
double));
4118 subdomain_U[I] = (
double*)malloc(subdomain_dim[I]*
sizeof(
double));
4119 subdomain_L[I] = (
double*)malloc(subdomain_dim[I]*subdomain_dim[I]*
sizeof(
double));
4121 if ((subdomain_pivots[I] == NULL) ||
4122 (subdomain_column_pivots[I] == NULL) ||
4123 (subdomain_R[I] == NULL) ||
4124 (subdomain_U[I] == NULL) ||
4125 (subdomain_L[I] == NULL))
4133 subdomain_dim = *subdomain_dim_p;
4134 subdomain_pivots = *subdomain_pivots_p;
4135 subdomain_column_pivots = *subdomain_column_pivots_p;
4136 subdomain_R = *subdomain_R_p;
4137 subdomain_U = *subdomain_U_p;
4138 subdomain_L = *subdomain_L_p;
4144 for (I = 0; I < N; I++)
4146 assert(subdomain_dim[I] == other_subdomain_dim[I]);
4147 for (i = 0; i < subdomain_dim[I]; i++)
4149 subdomain_pivots[I][i] = other_subdomain_pivots[I][i];
4150 subdomain_column_pivots[I][i] = other_subdomain_column_pivots[I][i];
4151 subdomain_R[I][i] = other_subdomain_R[I][i];
4152 subdomain_U[I][i] = other_subdomain_U[I][i];
4154 for (i = 0; i < subdomain_dim[I]*subdomain_dim[I]; i++)
4155 subdomain_L[I][i] = other_subdomain_L[I][i];
4186 int nInteriorElementBoundaries_global,
4187 int nExteriorElementBoundaries_global,
4188 int nElementBoundaries_element,
4189 int nQuadraturePoints_elementBoundary,
4193 int* interiorElementBoundaries,
4194 int* exteriorElementBoundaries,
4195 int* elementBoundaryElements,
4196 int* elementBoundaryLocalElementBoundaries,
4199 int* nodeStarElements,
4200 int* nodeStarElementNeighbors,
4201 int* nElements_node,
4202 int* fluxElementBoundaries,
4203 double* elementResidual,
4209 double* conservationResidual,
4210 double* vConservative,
4211 double* vConservative_element)
4213 int ebNI,ebNE,ebN,eN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,k,I;
4214 register double flux,fluxAverage,fluxCorrection,dx=0.0;
4216 double ** starR, ** starU;
4224 memset(conservationResidual,0,
sizeof(
double)*nElements_global);
4229 assert(nodeStarFactor);
4233 for (eN=0;eN<nElements_global;eN++)
4235 for (nN=0;nN<nNodes_element;nN++)
4237 nN_global = dofMapl2g[eN*nDOF_element+
4239 eN_star = nodeStarElements[eN*nNodes_element+
4241 starR[nN_global][eN_star]
4243 elementResidual[eN*nNodes_element+
4245 conservationResidual[eN]
4247 elementResidual[eN*nNodes_element+
4260 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4262 ebN = interiorElementBoundaries[ebNI];
4263 left_eN = elementBoundaryElements[ebN*2+0];
4264 right_eN = elementBoundaryElements[ebN*2+1];
4265 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4266 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4273 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4277 dx = dX[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
4278 left_ebN_element*nQuadraturePoints_elementBoundary+
4283 for (I=0;I<nSpace;I++)
4285 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4289 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
4300 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
4304 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4308 for (nN=0;nN<nNodes_element;nN++)
4311 nN_global = dofMapl2g[left_eN*nDOF_element+
4313 left_eN_star = nodeStarElements[left_eN*nNodes_element+
4317 if (nN != left_ebN_element)
4319 right_eN_star = nodeStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
4320 nN*nElementBoundaries_element+
4322 fluxCorrection = (starU[nN_global][left_eN_star]
4324 starU[nN_global][right_eN_star])
4326 w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4327 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4330 for (I=0;I<nSpace;I++)
4332 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4338 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4342 flux = (fluxAverage*
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4343 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4346 + fluxCorrection)*dx;
4347 starR[nN_global][left_eN_star]
4349 starR[nN_global][right_eN_star]
4351 conservationResidual[left_eN] += flux;
4352 conservationResidual[right_eN] -= flux;
4366 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4368 ebN = exteriorElementBoundaries[ebNE];
4369 eN = elementBoundaryElements[ebN*2+0];
4370 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4372 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4375 dx = dX[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
4376 ebN_element*nQuadraturePoints_elementBoundary+
4380 for (I=0;I<nSpace;I++)
4382 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4386 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
4396 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
4400 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4404 for (nN=0;nN<nNodes_element;nN++)
4406 nN_global = dofMapl2g[eN*nDOF_element+
4408 eN_star = nodeStarElements[eN*nNodes_element+
4413 if (nN != ebN_element && !fluxElementBoundaries[ebNE])
4415 fluxCorrection = starU[nN_global][eN_star]
4417 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4418 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4421 for (I=0;I<nSpace;I++)
4422 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4427 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4432 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4433 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4438 starR[nN_global][eN_star]
4440 conservationResidual[eN] += flux;
4456 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4458 ebN = interiorElementBoundaries[ebNI];
4459 left_eN = elementBoundaryElements[ebN*2+0];
4460 right_eN = elementBoundaryElements[ebN*2+1];
4461 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4462 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4463 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4464 for(I=0;I<nSpace;I++)
4466 vConservative_element[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
4467 left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
4471 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4474 vConservative_element[right_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
4475 right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
4479 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4499 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4501 ebN = exteriorElementBoundaries[ebNE];
4502 eN = elementBoundaryElements[ebN*2+0];
4503 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4504 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4505 for(I=0;I<nSpace;I++)
4507 vConservative_element[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
4508 ebN_element*nQuadraturePoints_elementBoundary*nSpace+
4512 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4548 int nNodes_internal,
4549 int nElements_global,
4550 int nInteriorElementBoundaries_global,
4551 int nExteriorElementBoundaries_global,
4552 int nElementBoundaries_element,
4553 int nQuadraturePoints_elementBoundary,
4557 int* interiorElementBoundaries,
4558 int* exteriorElementBoundaries,
4559 int* elementBoundaryElements,
4560 int* elementBoundaryLocalElementBoundaries,
4563 int* dofStarElements,
4564 int* dofStarElementNeighbors,
4565 int* nElements_node,
4567 int* fluxElementBoundaries,
4568 int* fluxBoundaryNodes,
4574 int eN,ebNI,ebNE,ebN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,nNI,k;
4575 PROTEUS_LAPACK_INTEGER INFO=0;
4576 register double wflux;
4579 double ** starJacobian = nodeStarFactor->
subdomain_L;
4586 assert(nodeStarFactor);
4587 for (nN = 0; nN < nDOF_global; nN++)
4589 for(ii=0; ii < subdomain_dim[nN]; ii++)
4591 starPivots[nN][ii]=0;
4592 starColPivots[nN][ii]=0;
4593 for (jj=0; jj < subdomain_dim[nN]; jj++)
4594 starJacobian[nN][ii + jj*subdomain_dim[nN]] = 0.0;
4599 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4601 ebN = interiorElementBoundaries[ebNI];
4602 left_eN = elementBoundaryElements[ebN*2+0];
4603 right_eN = elementBoundaryElements[ebN*2+1];
4604 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4605 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4606 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4608 for (nN=0;nN<nNodes_element;nN++)
4610 nN_global = dofMapl2g[left_eN*nDOF_element+
4612 left_eN_star = dofStarElements[left_eN*nNodes_element+
4616 if (nN != left_ebN_element)
4618 right_eN_star = dofStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
4619 nN*nElementBoundaries_element+
4621 wflux =
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4622 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4626 starJacobian[nN_global][left_eN_star+
4627 left_eN_star*subdomain_dim[nN_global]]
4629 starJacobian[nN_global][left_eN_star+
4630 right_eN_star*subdomain_dim[nN_global]]
4632 starJacobian[nN_global][right_eN_star+
4633 left_eN_star*subdomain_dim[nN_global]]
4635 starJacobian[nN_global][right_eN_star+
4636 right_eN_star*subdomain_dim[nN_global]]
4644 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
4646 ebN = exteriorElementBoundaries[ebNE];
4647 eN = elementBoundaryElements[ebN*2+0];
4648 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4649 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4651 for (nN=0;nN<nNodes_element;nN++)
4653 nN_global = dofMapl2g[eN*nDOF_element+
4655 eN_star = dofStarElements[eN*nNodes_element+
4664 if (nN != ebN_element && !fluxElementBoundaries[ebNE])
4666 starJacobian[nN_global][eN_star+
4667 eN_star*nElements_node[nN_global]]
4669 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4670 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4678 for (nNI=0;nNI<nNodes_internal;nNI++)
4680 nN = internalNodes[nNI];
4681 starJacobian[nN][0]=1.0;
4682 for (eN=1;eN<nElements_node[nN];eN++)
4683 starJacobian[nN][eN*subdomain_dim[nN]]
4687 for (nN=0; nN < nDOF_global; nN++)
4689 if (fluxBoundaryNodes[nN]==1)
4691 starJacobian[nN][0]=1.0;
4692 for (eN=1;eN<nElements_node[nN];eN++)
4693 starJacobian[nN][eN*subdomain_dim[nN]]
4703 for (nN=0;nN<nDOF_global;nN++)
4705 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);
4739 int nNodes_internal,
4740 int* nElements_node,
4742 int* fluxBoundaryNodes,
4746 PROTEUS_LAPACK_INTEGER NRHS=1,INFO=0;
4757 for (nN=0;nN<nNodes_global;nN++)
4758 for(eN=0;eN<subdomain_dim[nN];eN++)
4759 starU[nN][eN] = -starR[nN][eN];
4761 for (nNI=0;nNI<nNodes_internal;nNI++)
4763 nN = internalNodes[nNI];
4767 for (nN=0; nN < nNodes_global; nN++)
4769 if (fluxBoundaryNodes[nN] == 1)
4775 for (nN=0;nN<nNodes_global;nN++)
4777 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);
4802 int* nElements_node,
4806 PROTEUS_LAPACK_INTEGER NRHS=1,INFO=0;
4817 for (nN=0;nN<nNodes_global;nN++)
4818 for(eN=0;eN<subdomain_dim[nN];eN++)
4819 starU[nN][eN] = -starR[nN][eN];
4821 for (nN=0;nN<nNodes_global;nN++)
4823 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);
4835 int nElements_global,
4836 int nInteriorElementBoundaries_global,
4837 int nExteriorElementBoundaries_global,
4838 int nElementBoundaries_element,
4839 int nQuadraturePoints_elementBoundary,
4842 int* interiorElementBoundaries,
4843 int* exteriorElementBoundaries,
4844 int* elementBoundaryElements,
4845 int* elementBoundaryLocalElementBoundaries,
4847 int* nodeStarElements,
4848 int* nodeStarElementNeighbors,
4849 int* nElements_node,
4850 int* fluxElementBoundaries,
4851 double* elementResidual,
4857 double* conservationResidual,
4858 double* vConservative,
4859 double* vConservative_element)
4862 int ebNI,ebNE,ebN,eN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,k,I;
4863 register double flux,fluxAverage,fluxCorrection,dx=0.0;
4865 double ** starR, ** starU;
4873 memset(conservationResidual,0,
sizeof(
double)*nElements_global);
4874 memset(vConservative,0,
sizeof(
double)*(nInteriorElementBoundaries_global+nExteriorElementBoundaries_global)*nQuadraturePoints_elementBoundary*nSpace);
4879 assert(nodeStarFactor);
4883 for (nN=nNodes_owned;nN<nodeStarFactor->
N;nN++)
4889 for (eN=0;eN<nElements_global;eN++)
4891 for (nN=0;nN<nNodes_element;nN++)
4893 nN_global = elementNodes[eN*nNodes_element+
4895 eN_star = nodeStarElements[eN*nNodes_element+
4897 starR[nN_global][eN_star]
4899 elementResidual[eN*nNodes_element+
4901 conservationResidual[eN]
4903 elementResidual[eN*nNodes_element+
4916 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
4918 ebN = interiorElementBoundaries[ebNI];
4919 left_eN = elementBoundaryElements[ebN*2+0];
4920 right_eN = elementBoundaryElements[ebN*2+1];
4921 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
4922 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
4923 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
4927 dx = dX[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
4928 left_ebN_element*nQuadraturePoints_elementBoundary+
4933 for (I=0;I<nSpace;I++)
4938 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
4942 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4946 for (nN=0;nN<nNodes_element;nN++)
4948 nN_global = elementNodes[left_eN*nNodes_element+
4950 left_eN_star = nodeStarElements[left_eN*nNodes_element+
4954 if (nN != left_ebN_element)
4956 right_eN_star = nodeStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
4957 nN*nElementBoundaries_element+
4959 fluxCorrection = (starU[nN_global][left_eN_star]
4961 starU[nN_global][right_eN_star])
4963 w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4964 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4967 for (I=0;I<nSpace;I++)
4969 if (nN_global < nNodes_owned)
4971 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
4977 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
4982 flux = (fluxAverage*
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
4983 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
4986 + fluxCorrection)*dx;
4987 starR[nN_global][left_eN_star]
4989 starR[nN_global][right_eN_star]
4991 conservationResidual[left_eN] += flux;
4992 conservationResidual[right_eN] -= flux;
5006 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5008 ebN = exteriorElementBoundaries[ebNE];
5009 eN = elementBoundaryElements[ebN*2+0];
5010 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5012 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5015 dx = dX[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
5016 ebN_element*nQuadraturePoints_elementBoundary+
5020 for (I=0;I<nSpace;I++)
5023 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
5027 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5031 for (nN=0;nN<nNodes_element;nN++)
5033 nN_global = elementNodes[eN*nNodes_element+
5035 eN_star = nodeStarElements[eN*nNodes_element+
5040 if (nN != ebN_element && !fluxElementBoundaries[ebNE])
5042 fluxCorrection = starU[nN_global][eN_star]
5044 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5045 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5048 if (nN_global < nNodes_owned)
5050 for (I=0;I<nSpace;I++)
5052 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5057 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5064 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5065 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5070 starR[nN_global][eN_star]
5072 conservationResidual[eN] += flux;
5080 int nInteriorElementBoundaries_global,
5081 int nExteriorElementBoundaries_global,
5082 int nElementBoundaries_element,
5083 int nQuadraturePoints_elementBoundary,
5086 int* interiorElementBoundaries,
5087 int* exteriorElementBoundaries,
5088 int* elementBoundaryElements,
5089 int* elementBoundaryLocalElementBoundaries,
5090 int* skipflag_elementBoundaries,
5091 double* elementResidual,
5094 double* conservationResidual,
5095 double* vConservative)
5097 int ebNI,ebNE,ebN,eN,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,nN,k,I;
5098 register double flux,divergence=0.0;
5099 memset(conservationResidual,0,
sizeof(
double)*nElements_global);
5112 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5114 ebN = interiorElementBoundaries[ebNI];
5115 left_eN = elementBoundaryElements[ebN*2+0];
5116 right_eN = elementBoundaryElements[ebN*2+1];
5117 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5118 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5119 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5122 for (I=0;I<nSpace;I++)
5126 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5130 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5134 flux*=dX[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
5135 left_ebN_element*nQuadraturePoints_elementBoundary+
5137 conservationResidual[left_eN] += flux;
5138 conservationResidual[right_eN] -= flux;
5142 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5144 ebN = exteriorElementBoundaries[ebNE];
5145 eN = elementBoundaryElements[ebN*2+0];
5146 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5147 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5150 for (I=0;I<nSpace;I++)
5153 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5157 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5161 flux*=dX[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
5162 ebN_element*nQuadraturePoints_elementBoundary+
5164 conservationResidual[eN] += flux;
5172 int nNodes_internal,
5173 int nElements_global,
5174 int nInteriorElementBoundaries_global,
5175 int nExteriorElementBoundaries_global,
5176 int nElementBoundaries_element,
5177 int nQuadraturePoints_elementBoundary,
5180 int* interiorElementBoundaries,
5181 int* exteriorElementBoundaries,
5182 int* elementBoundaryElements,
5183 int* elementBoundaryLocalElementBoundaries,
5185 int* nodeStarElements,
5186 int* nodeStarElementNeighbors,
5187 int* nElements_node,
5189 int* fluxElementBoundaries,
5190 int* fluxBoundaryNodes,
5196 int eN,ebNI,ebNE,ebN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,nNI,k;
5197 PROTEUS_LAPACK_INTEGER INFO=0;
5198 register double wflux;
5201 double ** starJacobian = nodeStarFactor->
subdomain_L;
5208 assert(nodeStarFactor);
5209 for (nN = 0; nN < nNodes_global; nN++)
5211 for(ii=0; ii < subdomain_dim[nN]; ii++)
5213 starPivots[nN][ii]=0;
5214 starColPivots[nN][ii]=0;
5215 for (jj=0; jj < subdomain_dim[nN]; jj++)
5216 starJacobian[nN][ii + jj*subdomain_dim[nN]] = 0.0;
5220 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5222 ebN = interiorElementBoundaries[ebNI];
5223 left_eN = elementBoundaryElements[ebN*2+0];
5224 right_eN = elementBoundaryElements[ebN*2+1];
5225 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5226 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5227 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5229 for (nN=0;nN<nNodes_element;nN++)
5231 nN_global = elementNodes[left_eN*nNodes_element+
5233 left_eN_star = nodeStarElements[left_eN*nNodes_element+
5237 if (nN != left_ebN_element && nN_global < nNodes_owned)
5239 right_eN_star = nodeStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
5240 nN*nElementBoundaries_element+
5242 wflux =
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5243 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5247 starJacobian[nN_global][left_eN_star+
5248 left_eN_star*subdomain_dim[nN_global]]
5250 starJacobian[nN_global][left_eN_star+
5251 right_eN_star*subdomain_dim[nN_global]]
5253 starJacobian[nN_global][right_eN_star+
5254 left_eN_star*subdomain_dim[nN_global]]
5256 starJacobian[nN_global][right_eN_star+
5257 right_eN_star*subdomain_dim[nN_global]]
5264 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5266 ebN = exteriorElementBoundaries[ebNE];
5267 eN = elementBoundaryElements[ebN*2+0];
5268 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5269 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5271 for (nN=0;nN<nNodes_element;nN++)
5273 nN_global = elementNodes[eN*nNodes_element+
5275 eN_star = nodeStarElements[eN*nNodes_element+
5284 if (nN != ebN_element && !fluxElementBoundaries[ebNE] && nN_global < nNodes_owned)
5286 starJacobian[nN_global][eN_star+
5287 eN_star*nElements_node[nN_global]]
5289 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5290 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5298 for (nNI=0;nNI<nNodes_internal;nNI++)
5300 nN = internalNodes[nNI];
5301 if (nN < nNodes_owned)
5303 starJacobian[nN][0]=1.0;
5304 for (eN=1;eN<nElements_node[nN];eN++)
5305 starJacobian[nN][eN*subdomain_dim[nN]]
5310 for (nN=0; nN < nNodes_owned; nN++)
5312 if (fluxBoundaryNodes[nN]==1)
5314 starJacobian[nN][0]=1.0;
5315 for (eN=1;eN<nElements_node[nN];eN++)
5316 starJacobian[nN][eN*subdomain_dim[nN]]
5326 for (nN=0;nN<nNodes_owned;nN++)
5328 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);
5347 printf(
"velPP jac dgetrf INFO=%d nN=%d \n",(
int)(INFO),nN);
5348 for (ii=0;ii<nE_n;ii++)
5350 for(jj=0;jj<nE_n;jj++)
5353 printf(
"%12.5e \t",starJacobian[nN][ii*nE_n + jj]);
5363 int nNodes_internal,
5364 int* nElements_node,
5366 int* fluxBoundaryNodes,
5370 PROTEUS_LAPACK_INTEGER NRHS=1,INFO=0;
5381 for (nN=0;nN<nNodes_owned;nN++)
5382 for(eN=0;eN<subdomain_dim[nN];eN++)
5383 starU[nN][eN] = -starR[nN][eN];
5385 for (nNI=0;nNI<nNodes_internal;nNI++)
5387 nN = internalNodes[nNI];
5388 if (nN < nNodes_owned)
5392 for (nN=0; nN < nNodes_owned; nN++)
5394 if (fluxBoundaryNodes[nN] == 1)
5400 for (nN=0;nN<nNodes_owned;nN++)
5402 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);
5426 int nElements_global,
5429 int* nodeStarElements,
5431 double* subdomain_U)
5433 int eN,nN,eN_star,nN_global;
5435 for (eN=0;eN<nElements_global;eN++)
5436 for (nN=0;nN<nNodes_element;nN++)
5438 nN_global = elementNodes[eN*nNodes_element+
5440 eN_star = nodeStarElements[eN*nNodes_element+
5442 starU[nN_global][eN_star]
5444 subdomain_U[eN*nNodes_element+
5450 int nElements_global,
5453 int* nodeStarElements,
5455 double* subdomain_U)
5457 int eN,nN,eN_star,nN_global;
5459 for (eN=0;eN<nElements_global;eN++)
5460 for (nN=0;nN<nNodes_element;nN++)
5463 nN_global = elementNodes[eN*nNodes_element+
5465 eN_star = nodeStarElements[eN*nNodes_element+
5467 if (nN_global < max_nN_owned)
5468 subdomain_U[eN*nNodes_element+
5470 starU[nN_global][eN_star];
5473 subdomain_U[eN*nNodes_element+
5483 int nElementBoundaries_element,
5484 int nQuadraturePoints_elementBoundary,
5485 int nDOF_test_element,
5486 int* exteriorElementBoundaries,
5487 int* elementBoundaryElements,
5488 int* elementBoundaryLocalElementBoundaries,
5489 int* skipflag_elementBoundaries,
5494 int ebNE,ebN,eN_global,ebN_element,i,k;
5495 for(ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5497 ebN = exteriorElementBoundaries[ebNE];
5498 eN_global = elementBoundaryElements[ebN*2+0];
5499 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5500 if (skipflag_elementBoundaries[ebNE] == 0)
5502 for(i=0;i<nDOF_test_element;i++)
5503 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5514 residual[eN_global*nDOF_test_element+
5517 flux[ebN*nQuadraturePoints_elementBoundary+
5520 w_dS[eN_global*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5521 ebN_element*nQuadraturePoints_elementBoundary*nDOF_test_element+
5522 k*nDOF_test_element+
5542 for (k = 0; k < nPoints; k++)
5544 for (I = 0; I < nSpace; I++)
5546 velocity[k*nSpace + I] *= updateCoef;
5547 velocity[k*nSpace + I] +=
f[k*nSpace + I];
5556 const double* grad_phi,
5566 const int nSpace2 = nSpace*nSpace;
5567 for (k = 0; k < nPoints; k++)
5569 for (I = 0; I < nSpace; I++)
5571 velocity[k*nSpace + I] *= updateCoef;
5572 for (J=0; J < nSpace; J++)
5574 velocity[k*nSpace + I] -=
5575 a[k*nSpace2 + I*nSpace + J]
5577 grad_phi[k*nSpace + J];
5589 const double* grad_phi,
5599 const int nnz=rowptr[nSpace];
5600 for (k = 0; k < nPoints; k++)
5602 for (I = 0; I < nSpace; I++)
5604 velocity[k*nSpace + I] *= updateCoef;
5605 for(m=rowptr[I];m<rowptr[I+1];m++)
5607 velocity[k*nSpace + I] -=
5610 grad_phi[k*nSpace + colind[m]];
5616 void calculateElementResidualPWL(
int nElements,
int nDOF_element_res,
int nDOF_element_resPWL,
double* alpha,
double* elementResidual,
double* elementResidualPWL)
5619 memset(elementResidualPWL,0,
sizeof(
double)*nElements*nDOF_element_resPWL);
5620 for(eN=0;eN<nElements;eN++)
5621 for(i=0;i<nDOF_element_resPWL;i++)
5622 for(j=0;j<nDOF_element_res;j++)
5623 elementResidualPWL[eN*nDOF_element_resPWL+i] += alpha[i*nDOF_element_res+j]*elementResidual[eN*nDOF_element_res+j];
5650 int nInteriorElementBoundaries_global,
5651 int nExteriorElementBoundaries_global,
5652 int nElementBoundaries_element,
5653 int nQuadraturePoints_elementBoundary,
5656 int* interiorElementBoundaries,
5657 int* exteriorElementBoundaries,
5658 int* elementBoundaryElements,
5659 int* elementBoundaryLocalElementBoundaries,
5661 int* nodeStarElements,
5662 int* nodeStarElementNeighbors,
5663 int* nElements_node,
5664 int* fluxElementBoundaries,
5665 double* elementResidual,
5671 double* conservationResidual,
5672 double* vConservative,
5673 double* vConservative_element)
5675 int ebNI,ebNE,ebN,eN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,k,I;
5676 register double flux,fluxAverage,fluxCorrection,dx=0.0;
5678 double ** starR, ** starU;
5686 memset(conservationResidual,0,
sizeof(
double)*nElements_global);
5691 assert(nodeStarFactor);
5696 for (eN=0;eN<nElements_global;eN++)
5698 for (nN=0;nN<nNodes_element;nN++)
5700 nN_global = elementNodes[eN*nNodes_element+
5702 eN_star = nodeStarElements[eN*nNodes_element+
5704 starR[nN_global][eN_star]
5706 elementResidual[eN*nNodes_element+
5708 conservationResidual[eN]
5710 elementResidual[eN*nNodes_element+
5723 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5725 ebN = interiorElementBoundaries[ebNI];
5726 left_eN = elementBoundaryElements[ebN*2+0];
5727 right_eN = elementBoundaryElements[ebN*2+1];
5728 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5729 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5730 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5734 dx = dX[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
5735 left_ebN_element*nQuadraturePoints_elementBoundary+
5740 for (I=0;I<nSpace;I++)
5742 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5746 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
5757 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
5761 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5765 for (nN=0;nN<nNodes_element;nN++)
5767 nN_global = elementNodes[left_eN*nNodes_element+
5769 left_eN_star = nodeStarElements[left_eN*nNodes_element+
5773 if (nN != left_ebN_element && !fluxElementBoundaries[ebN])
5775 right_eN_star = nodeStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
5776 nN*nElementBoundaries_element+
5778 fluxCorrection = (starU[nN_global][left_eN_star]
5780 starU[nN_global][right_eN_star])
5782 w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5783 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5786 for (I=0;I<nSpace;I++)
5788 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5794 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5798 flux = (fluxAverage*
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5799 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5802 + fluxCorrection)*dx;
5803 starR[nN_global][left_eN_star]
5805 starR[nN_global][right_eN_star]
5807 conservationResidual[left_eN] += flux;
5808 conservationResidual[right_eN] -= flux;
5822 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5824 ebN = exteriorElementBoundaries[ebNE];
5825 eN = elementBoundaryElements[ebN*2+0];
5826 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5828 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5831 dx = dX[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary+
5832 ebN_element*nQuadraturePoints_elementBoundary+
5836 for (I=0;I<nSpace;I++)
5838 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5842 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
5852 vAverage[ebN*nQuadraturePoints_elementBoundary*nSpace+
5856 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5860 for (nN=0;nN<nNodes_element;nN++)
5862 nN_global = elementNodes[eN*nNodes_element+
5864 eN_star = nodeStarElements[eN*nNodes_element+
5869 if (nN != ebN_element && !fluxElementBoundaries[ebN])
5871 fluxCorrection = starU[nN_global][eN_star]
5873 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5874 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5877 for (I=0;I<nSpace;I++)
5878 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5883 normal[ebN*nQuadraturePoints_elementBoundary*nSpace+
5888 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
5889 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
5894 starR[nN_global][eN_star]
5896 conservationResidual[eN] += flux;
5912 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
5914 ebN = interiorElementBoundaries[ebNI];
5915 left_eN = elementBoundaryElements[ebN*2+0];
5916 right_eN = elementBoundaryElements[ebN*2+1];
5917 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5918 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
5919 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5920 for(I=0;I<nSpace;I++)
5922 vConservative_element[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
5923 left_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
5927 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5930 vConservative_element[right_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
5931 right_ebN_element*nQuadraturePoints_elementBoundary*nSpace+
5935 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
5954 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
5956 ebN = exteriorElementBoundaries[ebNE];
5957 eN = elementBoundaryElements[ebN*2+0];
5958 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
5959 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
5960 for(I=0;I<nSpace;I++)
5962 vConservative_element[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nSpace+
5963 ebN_element*nQuadraturePoints_elementBoundary*nSpace+
5967 vConservative[ebN*nQuadraturePoints_elementBoundary*nSpace+
6006 int nElements_global,
6007 int nInteriorElementBoundaries_global,
6008 int nExteriorElementBoundaries_global,
6009 int nElementBoundaries_element,
6010 int nQuadraturePoints_elementBoundary,
6013 int* interiorElementBoundaries,
6014 int* exteriorElementBoundaries,
6015 int* elementBoundaryElements,
6016 int* elementBoundaryLocalElementBoundaries,
6018 int* nodeStarElements,
6019 int* nodeStarElementNeighbors,
6020 int* nElements_node,
6021 int* fluxElementBoundaries,
6027 int eN,ebNI,ebNE,ebN,eN_star,left_eN,right_eN,ebN_element,left_ebN_element,right_ebN_element,left_eN_star,right_eN_star,nN,nN_global,nNI,k;
6028 PROTEUS_LAPACK_INTEGER INFO=0;
6029 register double wflux;
6032 double ** starJacobian = nodeStarFactor->
subdomain_L;
6039 assert(nodeStarFactor);
6040 for (nN = 0; nN < nNodes_global; nN++)
6042 for(ii=0; ii < subdomain_dim[nN]; ii++)
6044 starPivots[nN][ii]=0;
6045 starColPivots[nN][ii]=0;
6046 for (jj=0; jj < subdomain_dim[nN]; jj++)
6047 starJacobian[nN][ii + jj*subdomain_dim[nN]] = 0.0;
6051 for (ebNI=0;ebNI<nInteriorElementBoundaries_global;ebNI++)
6053 ebN = interiorElementBoundaries[ebNI];
6054 left_eN = elementBoundaryElements[ebN*2+0];
6055 right_eN = elementBoundaryElements[ebN*2+1];
6056 left_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
6057 right_ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+1];
6058 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6060 for (nN=0;nN<nNodes_element;nN++)
6062 nN_global = elementNodes[left_eN*nNodes_element+
6064 left_eN_star = nodeStarElements[left_eN*nNodes_element+
6069 if (nN != left_ebN_element && !fluxElementBoundaries[ebN])
6071 right_eN_star = nodeStarElementNeighbors[left_eN*nNodes_element*nElementBoundaries_element+
6072 nN*nElementBoundaries_element+
6074 wflux =
w[left_eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
6075 left_ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
6079 starJacobian[nN_global][left_eN_star+
6080 left_eN_star*subdomain_dim[nN_global]]
6082 starJacobian[nN_global][left_eN_star+
6083 right_eN_star*subdomain_dim[nN_global]]
6085 starJacobian[nN_global][right_eN_star+
6086 left_eN_star*subdomain_dim[nN_global]]
6088 starJacobian[nN_global][right_eN_star+
6089 right_eN_star*subdomain_dim[nN_global]]
6096 for (ebNE=0;ebNE<nExteriorElementBoundaries_global;ebNE++)
6098 ebN = exteriorElementBoundaries[ebNE];
6099 eN = elementBoundaryElements[ebN*2+0];
6100 ebN_element = elementBoundaryLocalElementBoundaries[ebN*2+0];
6101 for(k=0;k<nQuadraturePoints_elementBoundary;k++)
6103 for (nN=0;nN<nNodes_element;nN++)
6105 nN_global = elementNodes[eN*nNodes_element+
6107 eN_star = nodeStarElements[eN*nNodes_element+
6113 if (nN != ebN_element && !fluxElementBoundaries[ebN])
6115 starJacobian[nN_global][eN_star+
6116 eN_star*nElements_node[nN_global]]
6118 w[eN*nElementBoundaries_element*nQuadraturePoints_elementBoundary*nNodes_element+
6119 ebN_element*nQuadraturePoints_elementBoundary*nNodes_element+
6128 for (nN=0;nN<nNodes_global;nN++)
6130 PROTEUS_LAPACK_INTEGER nE_n = ((PROTEUS_LAPACK_INTEGER)subdomain_dim[nN]);