13 int nQuadraturePoints_element,
14 int nDOF_trial_element,
19 double* dsubgridError)
22 for(eN=0;eN<nElements_global;eN++)
23 for (k=0;k<nQuadraturePoints_element;k++)
25 subgridError[eN*nQuadraturePoints_element+
27 -tau[eN*nQuadraturePoints_element+
30 pdeResidual[eN*nQuadraturePoints_element+
32 for (j=0;j<nDOF_trial_element;j++)
33 dsubgridError[eN*nQuadraturePoints_element*nDOF_trial_element+
37 -tau[eN*nQuadraturePoints_element+
40 dpdeResidual[eN*nQuadraturePoints_element*nDOF_trial_element+
50 int nQuadraturePoints_element,
52 double* elementDiameter,
64 int eN,k,I,J,nSpace2=nSpace*nSpace;
65 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3],alpha,beta;
66 for(eN=0;eN<nElements_global;eN++)
68 h = elementDiameter[eN];
69 for (k=0;k<nQuadraturePoints_element;k++)
75 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
81 da[eN*nQuadraturePoints_element*nSpace2 +
86 grad_phi[eN*nQuadraturePoints_element*nSpace +
91 Vlin += vlin[I]*vlin[I];
96 A_II = a[eN*nQuadraturePoints_element*nSpace2 +
100 Alin = (A_II > Alin) ? A_II : Alin;
102 Alin*=dphi[eN*nQuadraturePoints_element +
107 cfl[eN*nQuadraturePoints_element +
110 cfl[eN*nQuadraturePoints_element +
112 num = 0.5*Vlin*h + 1.0e-8;
113 den = Alin +
num*1.0e-8;
114 pe[eN*nQuadraturePoints_element +
116 tau[eN*nQuadraturePoints_element + k]=0.5*h*(
117 1.0/tanh(
pe[eN*nQuadraturePoints_element+
119 1.0/
pe[eN*nQuadraturePoints_element+
133 int nQuadraturePoints_element,
137 double* elementDiameter,
149 int eN,k,I,J,m,
nnz=rowptr[nSpace];
150 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3],alpha,beta;
151 for(eN=0;eN<nElements_global;eN++)
153 h = elementDiameter[eN];
154 for (k=0;k<nQuadraturePoints_element;k++)
158 for(I=0;I<nSpace;I++)
160 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
163 for(J=0;J<nSpace;J++)
166 da[eN*nQuadraturePoints_element*
nnz+
170 grad_phi[eN*nQuadraturePoints_element*nSpace +
174 for(I=0;I<nSpace;I++)
175 Vlin += vlin[I]*vlin[I];
178 for(I=0;I<nSpace;I++)
180 for(m=rowptr[I];m<rowptr[I+1];m++)
184 A_II = a[eN*nQuadraturePoints_element*
nnz+
187 Alin = (A_II > Alin) ? A_II : Alin;
191 Alin*=dphi[eN*nQuadraturePoints_element +
196 cfl[eN*nQuadraturePoints_element +
199 cfl[eN*nQuadraturePoints_element +
201 num = 0.5*Vlin*h + 1.0e-8;
202 den = Alin +
num*1.0e-8;
203 pe[eN*nQuadraturePoints_element +
205 tau[eN*nQuadraturePoints_element + k]=0.5*h*(
206 1.0/tanh(
pe[eN*nQuadraturePoints_element+
208 1.0/
pe[eN*nQuadraturePoints_element+
225 int nQuadraturePoints_element,
227 double* elementDiameter,
239 int eN,k,I,J,nSpace2=nSpace*nSpace;
240 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3],tauMax;
241 for(eN=0;eN<nElements_global;eN++)
243 h = elementDiameter[eN];
245 for (k=0;k<nQuadraturePoints_element;k++)
249 for(I=0;I<nSpace;I++)
251 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
254 for(J=0;J<nSpace;J++)
257 da[eN*nQuadraturePoints_element*nSpace2 +
262 grad_phi[eN*nQuadraturePoints_element*nSpace +
266 for(I=0;I<nSpace;I++)
267 Vlin += vlin[I]*vlin[I];
270 for(I=0;I<nSpace;I++)
272 A_II = a[eN*nQuadraturePoints_element*nSpace2 +
276 Alin = (A_II > Alin) ? A_II : Alin;
278 Alin*=dphi[eN*nQuadraturePoints_element +
283 cfl[eN*nQuadraturePoints_element +
286 cfl[eN*nQuadraturePoints_element +
288 num = 0.5*Vlin*h + 1.0e-8;
289 den = Alin +
num*1.0e-8;
290 pe[eN*nQuadraturePoints_element +
292 tau[eN*nQuadraturePoints_element + k]=1.0/((2.0*Vlin/h)+
294 fabs(dr[eN*nQuadraturePoints_element +
296 fabs(dmt[eN*nQuadraturePoints_element +
305 int nQuadraturePoints_element,
309 double* elementDiameter,
321 int eN,k,I,m,
nnz=rowptr[nSpace];
322 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3],tauMax;
323 for(eN=0;eN<nElements_global;eN++)
325 h = elementDiameter[eN];
327 for (k=0;k<nQuadraturePoints_element;k++)
331 for(I=0;I<nSpace;I++)
333 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
336 for(m=rowptr[I];m<rowptr[I+1];m++)
339 da[eN*nQuadraturePoints_element*
nnz+
343 grad_phi[eN*nQuadraturePoints_element*nSpace +
347 for(I=0;I<nSpace;I++)
348 Vlin += vlin[I]*vlin[I];
351 for(I=0;I<nSpace;I++)
353 for(m=rowptr[I];m<rowptr[I+1];m++)
357 A_II = a[eN*nQuadraturePoints_element*
nnz+
360 Alin = (A_II > Alin) ? A_II : Alin;
364 Alin*=dphi[eN*nQuadraturePoints_element +
369 cfl[eN*nQuadraturePoints_element +
372 cfl[eN*nQuadraturePoints_element +
374 num = 0.5*Vlin*h + 1.0e-8;
375 den = Alin +
num*1.0e-8;
376 pe[eN*nQuadraturePoints_element +
378 tau[eN*nQuadraturePoints_element + k]=1.0/((2.0*Vlin/h)+
380 fabs(dr[eN*nQuadraturePoints_element +
382 fabs(dmt[eN*nQuadraturePoints_element +
395 int nQuadraturePoints_element,
397 double* elementDiameter,
409 int eN,k,I,J,nSpace2=nSpace*nSpace;
410 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3];
411 for(eN=0;eN<nElements_global;eN++)
413 h = elementDiameter[eN];
414 for (k=0;k<nQuadraturePoints_element;k++)
418 for(I=0;I<nSpace;I++)
420 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
423 for(J=0;J<nSpace;J++)
427 da[eN*nQuadraturePoints_element*nSpace2 +
432 grad_phi[eN*nQuadraturePoints_element*nSpace +
437 for(I=0;I<nSpace;I++)
438 Vlin += vlin[I]*vlin[I];
441 for(I=0;I<nSpace;I++)
443 A_II = a[eN*nQuadraturePoints_element*nSpace2 +
447 Alin = (A_II > Alin) ? A_II : Alin;
449 Alin*=dphi[eN*nQuadraturePoints_element +
454 cfl[eN*nQuadraturePoints_element +
457 cfl[eN*nQuadraturePoints_element +
459 num = 0.5*Vlin*h + 1.0e-8;
460 den = Alin +
num*1.0e-8;
463 tau[eN*nQuadraturePoints_element +
465 =1.0/sqrt((2.0*Vlin/h)*(2.0*Vlin/h)+
466 9.0*(4.0*Alin/(h*h))*(4.0*Alin/(h*h)) +
467 dr[eN*nQuadraturePoints_element +
470 dr[eN*nQuadraturePoints_element +
473 dmt[eN*nQuadraturePoints_element +
476 dmt[eN*nQuadraturePoints_element +
478 pe[eN*nQuadraturePoints_element +
485 int nQuadraturePoints_element,
489 double* elementDiameter,
501 int eN,k,I,m,
nnz=rowptr[nSpace];
502 double h,Vlin,Alin,A_II,
num,den,cfl1,cfl2,vlin[3];
503 for(eN=0;eN<nElements_global;eN++)
505 h = elementDiameter[eN];
506 for (k=0;k<nQuadraturePoints_element;k++)
510 for(I=0;I<nSpace;I++)
512 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
515 for(m=rowptr[I];m<rowptr[I+1];m++)
519 da[eN*nQuadraturePoints_element*
nnz+
523 grad_phi[eN*nQuadraturePoints_element*nSpace +
528 for(I=0;I<nSpace;I++)
529 Vlin += vlin[I]*vlin[I];
532 for(I=0;I<nSpace;I++)
534 for(m=rowptr[I];m<rowptr[I+1];m++)
538 A_II = a[eN*nQuadraturePoints_element*
nnz+
541 Alin = (A_II > Alin) ? A_II : Alin;
545 Alin*=dphi[eN*nQuadraturePoints_element +
550 cfl[eN*nQuadraturePoints_element +
553 cfl[eN*nQuadraturePoints_element +
555 num = 0.5*Vlin*h + 1.0e-8;
556 den = Alin +
num*1.0e-8;
559 tau[eN*nQuadraturePoints_element +
561 =1.0/sqrt((2.0*Vlin/h)*(2.0*Vlin/h)+
562 9.0*(4.0*Alin/(h*h))*(4.0*Alin/(h*h)) +
563 dr[eN*nQuadraturePoints_element +
566 dr[eN*nQuadraturePoints_element +
569 dmt[eN*nQuadraturePoints_element +
572 dmt[eN*nQuadraturePoints_element +
574 pe[eN*nQuadraturePoints_element +
581 int nQuadraturePoints_element,
595 int eN,k,I,J,K,nSpace2=nSpace*nSpace;
596 double Vlin,Alin,A_II,cfl1,cfl2,vlin[3],G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g;
597 for(eN=0;eN<nElements_global;eN++)
599 for (k=0;k<nQuadraturePoints_element;k++)
603 for(I=0;I<nSpace;I++)
605 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
608 for(J=0;J<nSpace;J++)
612 da[eN*nQuadraturePoints_element*nSpace2 +
617 grad_phi[eN*nQuadraturePoints_element*nSpace +
625 for (I=0;I<nSpace;I++)
629 for (J=0;J<nSpace;J++)
632 for (K=0;K<nSpace;K++)
633 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
638 inverseJ[eN*nQuadraturePoints_element*nSpace2+
645 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
646 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
658 for(I=0;I<nSpace;I++)
660 A_II = a[eN*nQuadraturePoints_element*nSpace2 +
664 Alin = (A_II > Alin) ? A_II : Alin;
666 Alin*=dphi[eN*nQuadraturePoints_element +
668 CI_nu2_G_ddot_G*=CI*Alin*Alin;
669 cfl1 = 0.5*sqrt(v_dot_Gv);
670 cfl2 = 0.25*sqrt(CI_nu2_G_ddot_G);
672 cfl[eN*nQuadraturePoints_element +
675 cfl[eN*nQuadraturePoints_element +
677 tau[eN*nQuadraturePoints_element +
681 4.0*dr[eN*nQuadraturePoints_element +
684 dr[eN*nQuadraturePoints_element +
687 4.0*dmt[eN*nQuadraturePoints_element +
690 dmt[eN*nQuadraturePoints_element +
693 pe[eN*nQuadraturePoints_element +
694 k] = sqrt(v_dot_Gv)/sqrt(CI_nu2_G_ddot_G);
700 int nQuadraturePoints_element,
716 int eN,k,I,J,K,m,
nnz=rowptr[nSpace],nSpace2=nSpace*nSpace;
717 double Vlin,Alin,A_II,cfl1,cfl2,vlin[3],G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g;
718 for(eN=0;eN<nElements_global;eN++)
720 for (k=0;k<nQuadraturePoints_element;k++)
724 for(I=0;I<nSpace;I++)
726 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
729 for(m=rowptr[I];m<rowptr[I+1];m++)
733 da[eN*nQuadraturePoints_element*
nnz+
737 grad_phi[eN*nQuadraturePoints_element*nSpace +
745 for (I=0;I<nSpace;I++)
749 for (J=0;J<nSpace;J++)
752 for (K=0;K<nSpace;K++)
753 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
758 inverseJ[eN*nQuadraturePoints_element*nSpace2+
765 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
766 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
778 for(I=0;I<nSpace;I++)
780 for(m=rowptr[I];m<rowptr[I+1];m++)
784 A_II = a[eN*nQuadraturePoints_element*
nnz +
786 Alin = (A_II > Alin) ? A_II : Alin;
790 Alin*=dphi[eN*nQuadraturePoints_element +
792 CI_nu2_G_ddot_G*=CI*Alin*Alin;
793 cfl1 = 0.5*sqrt(v_dot_Gv);
794 cfl2 = 0.25*sqrt(CI_nu2_G_ddot_G);
796 cfl[eN*nQuadraturePoints_element +
799 cfl[eN*nQuadraturePoints_element +
801 tau[eN*nQuadraturePoints_element +
805 4.0*dr[eN*nQuadraturePoints_element +
808 dr[eN*nQuadraturePoints_element +
811 4.0*dmt[eN*nQuadraturePoints_element +
814 dmt[eN*nQuadraturePoints_element +
817 pe[eN*nQuadraturePoints_element +
818 k] = sqrt(v_dot_Gv)/sqrt(CI_nu2_G_ddot_G);
827 int nQuadraturePoints_element,
830 double* elementDiameter,
842 if(stabilization ==
'2')
843 calculateSubgridError_ADR_tau_2(nElements_global, nQuadraturePoints_element, nSpace, elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
844 else if(stabilization ==
'1')
845 calculateSubgridError_ADR_tau_1(nElements_global, nQuadraturePoints_element, nSpace, elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
846 else if(stabilization ==
'p')
847 calculateSubgridError_ADR_tau_p(nElements_global, nQuadraturePoints_element, nSpace, elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
852 int nQuadraturePoints_element,
857 double* elementDiameter,
869 if(stabilization ==
'2')
870 calculateSubgridError_ADR_tau_2_sd(nElements_global, nQuadraturePoints_element, nSpace, rowptr,colind,elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
871 else if(stabilization ==
'1')
872 calculateSubgridError_ADR_tau_1_sd(nElements_global, nQuadraturePoints_element, nSpace, rowptr,colind,elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
873 else if(stabilization ==
'p')
874 calculateSubgridError_ADR_tau_p_sd(nElements_global, nQuadraturePoints_element, nSpace, rowptr,colind,elementDiameter, dmt,
df, a, da, grad_phi, dphi, dr,
pe, cfl, tau);
881 int nQuadraturePoints_element,
883 double* elementDiameter,
891 for(eN=0;eN<nElements_global;eN++)
893 h = elementDiameter[eN];
894 for (k=0;k<nQuadraturePoints_element;k++)
897 for(I=0;I<nSpace;I++)
900 df[eN*nQuadraturePoints_element*nSpace +
904 df[eN*nQuadraturePoints_element*nSpace +
909 cfl[eN*nQuadraturePoints_element +
911 tau[eN*nQuadraturePoints_element +
914 fabs(dmt[eN*nQuadraturePoints_element +
924 int nQuadraturePoints_element,
926 double* elementDiameter,
934 for(eN=0;eN<nElements_global;eN++)
936 h = elementDiameter[eN];
937 for (k=0;k<nQuadraturePoints_element;k++)
940 for(I=0;I<nSpace;I++)
943 df[eN*nQuadraturePoints_element*nSpace +
947 df[eN*nQuadraturePoints_element*nSpace +
952 cfl[eN*nQuadraturePoints_element +
954 tau[eN*nQuadraturePoints_element +
956 =1.0/sqrt((2.0*Vlin/h)*(2.0*Vlin/h)+
957 dmt[eN*nQuadraturePoints_element +
960 dmt[eN*nQuadraturePoints_element +
972 int nQuadraturePoints_element,
975 double* elementDiameter,
981 if(stabilization ==
'2')
983 else if(stabilization ==
'1')
991 int nQuadraturePoints_element,
992 int nDOF_trial_element,
994 double* elementDiameter,
996 double* pdeResidualU,
997 double* dpdeResidualU_dp,
998 double* dpdeResidualU_du,
999 double* pdeResidualV,
1000 double* dpdeResidualV_dp,
1001 double* dpdeResidualV_dv,
1002 double* subgridErrorU,
1003 double* dsubgridErrorU_dp,
1004 double* dsubgridErrorU_du,
1005 double* subgridErrorV,
1006 double* dsubgridErrorV_dp,
1007 double* dsubgridErrorV_dv)
1009 int eN,k,nSpace2=nSpace*nSpace,j;
1010 double h,viscosity,tau1;
1011 for(eN=0;eN<nElements_global;eN++)
1013 h = elementDiameter[eN];
1014 for (k=0;k<nQuadraturePoints_element;k++)
1016 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
1018 tau1 = h*h/(12.0*viscosity);
1019 subgridErrorU[eN*nQuadraturePoints_element+
1023 pdeResidualU[eN*nQuadraturePoints_element+
1025 subgridErrorV[eN*nQuadraturePoints_element+
1029 pdeResidualV[eN*nQuadraturePoints_element+
1031 for (j=0;j<nDOF_trial_element;j++)
1034 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1035 k*nDOF_trial_element+
1039 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1040 k*nDOF_trial_element+
1042 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1043 k*nDOF_trial_element+
1047 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1048 k*nDOF_trial_element+
1051 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1052 k*nDOF_trial_element+
1056 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1057 k*nDOF_trial_element+
1059 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1060 k*nDOF_trial_element+
1064 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1065 k*nDOF_trial_element+
1073 int nQuadraturePoints_element,
1074 int nDOF_trial_element,
1076 double* elementDiameter,
1078 double* pdeResidualU,
1079 double* dpdeResidualU_dp,
1080 double* dpdeResidualU_du,
1081 double* pdeResidualV,
1082 double* dpdeResidualV_dp,
1083 double* dpdeResidualV_dv,
1084 double* subgridErrorU,
1085 double* dsubgridErrorU_dp,
1086 double* dsubgridErrorU_du,
1087 double* subgridErrorV,
1088 double* dsubgridErrorV_dp,
1089 double* dsubgridErrorV_dv)
1091 int eN,k,nSpace2=nSpace*nSpace,j;
1092 double h,viscosity,tau1;
1093 for(eN=0;eN<nElements_global;eN++)
1095 h = elementDiameter[eN];
1096 for (k=0;k<nQuadraturePoints_element;k++)
1098 viscosity = a[eN*nQuadraturePoints_element*nSpace +
1100 tau1 = h*h/(12.0*viscosity);
1101 subgridErrorU[eN*nQuadraturePoints_element+
1105 pdeResidualU[eN*nQuadraturePoints_element+
1107 subgridErrorV[eN*nQuadraturePoints_element+
1111 pdeResidualV[eN*nQuadraturePoints_element+
1113 for (j=0;j<nDOF_trial_element;j++)
1116 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1117 k*nDOF_trial_element+
1121 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1122 k*nDOF_trial_element+
1124 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1125 k*nDOF_trial_element+
1129 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1130 k*nDOF_trial_element+
1133 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1134 k*nDOF_trial_element+
1138 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1139 k*nDOF_trial_element+
1141 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1142 k*nDOF_trial_element+
1146 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1147 k*nDOF_trial_element+
1158 int nQuadraturePoints_element,
1159 int nDOF_trial_element,
1161 double* elementDiameter,
1163 double* pdeResidualU,
1164 double* dpdeResidualU_dp,
1165 double* dpdeResidualU_du,
1166 double* pdeResidualV,
1167 double* dpdeResidualV_dp,
1168 double* dpdeResidualV_dv,
1169 double* pdeResidualW,
1170 double* dpdeResidualW_dp,
1171 double* dpdeResidualW_dw,
1172 double* subgridErrorU,
1173 double* dsubgridErrorU_dp,
1174 double* dsubgridErrorU_du,
1175 double* subgridErrorV,
1176 double* dsubgridErrorV_dp,
1177 double* dsubgridErrorV_dv,
1178 double* subgridErrorW,
1179 double* dsubgridErrorW_dp,
1180 double* dsubgridErrorW_dw)
1182 int eN,k,nSpace2=nSpace*nSpace,j;
1183 double h,viscosity,tau1;
1184 for(eN=0;eN<nElements_global;eN++)
1186 h = elementDiameter[eN];
1187 for (k=0;k<nQuadraturePoints_element;k++)
1189 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
1191 tau1 = h*h/(12.0*viscosity);
1192 subgridErrorU[eN*nQuadraturePoints_element+
1196 pdeResidualU[eN*nQuadraturePoints_element+
1198 subgridErrorV[eN*nQuadraturePoints_element+
1202 pdeResidualV[eN*nQuadraturePoints_element+
1204 subgridErrorW[eN*nQuadraturePoints_element+
1208 pdeResidualW[eN*nQuadraturePoints_element+
1210 for (j=0;j<nDOF_trial_element;j++)
1213 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1214 k*nDOF_trial_element+
1218 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1219 k*nDOF_trial_element+
1221 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1222 k*nDOF_trial_element+
1226 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1227 k*nDOF_trial_element+
1230 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1231 k*nDOF_trial_element+
1235 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1236 k*nDOF_trial_element+
1238 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1239 k*nDOF_trial_element+
1243 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1244 k*nDOF_trial_element+
1247 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1248 k*nDOF_trial_element+
1252 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1253 k*nDOF_trial_element+
1255 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1256 k*nDOF_trial_element+
1260 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1261 k*nDOF_trial_element+
1269 int nQuadraturePoints_element,
1270 int nDOF_trial_element,
1272 double* elementDiameter,
1274 double* pdeResidualU,
1275 double* dpdeResidualU_dp,
1276 double* dpdeResidualU_du,
1277 double* pdeResidualV,
1278 double* dpdeResidualV_dp,
1279 double* dpdeResidualV_dv,
1280 double* pdeResidualW,
1281 double* dpdeResidualW_dp,
1282 double* dpdeResidualW_dw,
1283 double* subgridErrorU,
1284 double* dsubgridErrorU_dp,
1285 double* dsubgridErrorU_du,
1286 double* subgridErrorV,
1287 double* dsubgridErrorV_dp,
1288 double* dsubgridErrorV_dv,
1289 double* subgridErrorW,
1290 double* dsubgridErrorW_dp,
1291 double* dsubgridErrorW_dw)
1293 int eN,k,nSpace2=nSpace*nSpace,j;
1294 double h,viscosity,tau1;
1295 for(eN=0;eN<nElements_global;eN++)
1297 h = elementDiameter[eN];
1298 for (k=0;k<nQuadraturePoints_element;k++)
1300 viscosity = a[eN*nQuadraturePoints_element*nSpace +
1302 tau1 = h*h/(12.0*viscosity);
1303 subgridErrorU[eN*nQuadraturePoints_element+
1307 pdeResidualU[eN*nQuadraturePoints_element+
1309 subgridErrorV[eN*nQuadraturePoints_element+
1313 pdeResidualV[eN*nQuadraturePoints_element+
1315 subgridErrorW[eN*nQuadraturePoints_element+
1319 pdeResidualW[eN*nQuadraturePoints_element+
1321 for (j=0;j<nDOF_trial_element;j++)
1324 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1325 k*nDOF_trial_element+
1329 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1330 k*nDOF_trial_element+
1332 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1333 k*nDOF_trial_element+
1337 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1338 k*nDOF_trial_element+
1341 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1342 k*nDOF_trial_element+
1346 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1347 k*nDOF_trial_element+
1349 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1350 k*nDOF_trial_element+
1354 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1355 k*nDOF_trial_element+
1358 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1359 k*nDOF_trial_element+
1363 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1364 k*nDOF_trial_element+
1366 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1367 k*nDOF_trial_element+
1371 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1372 k*nDOF_trial_element+
1383 int nQuadraturePoints_element,
1384 int nDOF_trial_element,
1386 double* elementDiameter,
1388 double* pdeResidualP,
1389 double* dpdeResidualP_du,
1390 double* dpdeResidualP_dv,
1391 double* pdeResidualU,
1392 double* dpdeResidualU_dp,
1393 double* dpdeResidualU_du,
1394 double* pdeResidualV,
1395 double* dpdeResidualV_dp,
1396 double* dpdeResidualV_dv,
1397 double* subgridErrorP,
1398 double* dsubgridErrorP_du,
1399 double* dsubgridErrorP_dv,
1400 double* subgridErrorU,
1401 double* dsubgridErrorU_dp,
1402 double* dsubgridErrorU_du,
1403 double* subgridErrorV,
1404 double* dsubgridErrorV_dp,
1405 double* dsubgridErrorV_dv)
1407 int eN,k,nSpace2=nSpace*nSpace,j;
1408 double h,viscosity,tau1,tau2;
1409 for(eN=0;eN<nElements_global;eN++)
1411 h = elementDiameter[eN];
1412 for (k=0;k<nQuadraturePoints_element;k++)
1414 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
1417 tau1 = h*h/(12.0*viscosity);
1418 subgridErrorU[eN*nQuadraturePoints_element+
1422 pdeResidualU[eN*nQuadraturePoints_element+
1424 subgridErrorV[eN*nQuadraturePoints_element+
1428 pdeResidualV[eN*nQuadraturePoints_element+
1431 tau2 = 6.0*viscosity;
1432 subgridErrorP[eN*nQuadraturePoints_element+
1435 *pdeResidualP[eN*nQuadraturePoints_element+
1437 for (j=0;j<nDOF_trial_element;j++)
1441 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1442 k*nDOF_trial_element+
1446 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1447 k*nDOF_trial_element+
1449 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1450 k*nDOF_trial_element+
1454 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1455 k*nDOF_trial_element+
1458 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1459 k*nDOF_trial_element+
1463 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1464 k*nDOF_trial_element+
1466 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1467 k*nDOF_trial_element+
1471 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1472 k*nDOF_trial_element+
1475 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1476 k*nDOF_trial_element+
1481 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1482 k*nDOF_trial_element+
1484 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1485 k*nDOF_trial_element+
1490 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1491 k*nDOF_trial_element+
1499 int nQuadraturePoints_element,
1500 int nDOF_trial_element,
1502 double* elementDiameter,
1504 double* pdeResidualP,
1505 double* dpdeResidualP_du,
1506 double* dpdeResidualP_dv,
1507 double* pdeResidualU,
1508 double* dpdeResidualU_dp,
1509 double* dpdeResidualU_du,
1510 double* pdeResidualV,
1511 double* dpdeResidualV_dp,
1512 double* dpdeResidualV_dv,
1513 double* subgridErrorP,
1514 double* dsubgridErrorP_du,
1515 double* dsubgridErrorP_dv,
1516 double* subgridErrorU,
1517 double* dsubgridErrorU_dp,
1518 double* dsubgridErrorU_du,
1519 double* subgridErrorV,
1520 double* dsubgridErrorV_dp,
1521 double* dsubgridErrorV_dv)
1523 int eN,k,nSpace2=nSpace*nSpace,j;
1524 double h,viscosity,tau1,tau2;
1525 for(eN=0;eN<nElements_global;eN++)
1527 h = elementDiameter[eN];
1528 for (k=0;k<nQuadraturePoints_element;k++)
1530 viscosity = a[eN*nQuadraturePoints_element*nSpace +
1533 tau1 = h*h/(12.0*viscosity);
1534 subgridErrorU[eN*nQuadraturePoints_element+
1538 pdeResidualU[eN*nQuadraturePoints_element+
1540 subgridErrorV[eN*nQuadraturePoints_element+
1544 pdeResidualV[eN*nQuadraturePoints_element+
1547 tau2 = 6.0*viscosity;
1548 subgridErrorP[eN*nQuadraturePoints_element+
1551 *pdeResidualP[eN*nQuadraturePoints_element+
1553 for (j=0;j<nDOF_trial_element;j++)
1557 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1558 k*nDOF_trial_element+
1562 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1563 k*nDOF_trial_element+
1565 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1566 k*nDOF_trial_element+
1570 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1571 k*nDOF_trial_element+
1574 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1575 k*nDOF_trial_element+
1579 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1580 k*nDOF_trial_element+
1582 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1583 k*nDOF_trial_element+
1587 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1588 k*nDOF_trial_element+
1591 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1592 k*nDOF_trial_element+
1597 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1598 k*nDOF_trial_element+
1600 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1601 k*nDOF_trial_element+
1606 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1607 k*nDOF_trial_element+
1618 int nQuadraturePoints_element,
1619 int nDOF_trial_element,
1621 double* elementDiameter,
1623 double* pdeResidualP,
1624 double* dpdeResidualP_du,
1625 double* dpdeResidualP_dv,
1626 double* dpdeResidualP_dw,
1627 double* pdeResidualU,
1628 double* dpdeResidualU_dp,
1629 double* dpdeResidualU_du,
1630 double* pdeResidualV,
1631 double* dpdeResidualV_dp,
1632 double* dpdeResidualV_dv,
1633 double* pdeResidualW,
1634 double* dpdeResidualW_dp,
1635 double* dpdeResidualW_dw,
1636 double* subgridErrorP,
1637 double* dsubgridErrorP_du,
1638 double* dsubgridErrorP_dv,
1639 double* dsubgridErrorP_dw,
1640 double* subgridErrorU,
1641 double* dsubgridErrorU_dp,
1642 double* dsubgridErrorU_du,
1643 double* subgridErrorV,
1644 double* dsubgridErrorV_dp,
1645 double* dsubgridErrorV_dv,
1646 double* subgridErrorW,
1647 double* dsubgridErrorW_dp,
1648 double* dsubgridErrorW_dw)
1650 int eN,k,nSpace2=nSpace*nSpace,j;
1651 double h,viscosity,tau1,tau2;
1652 for(eN=0;eN<nElements_global;eN++)
1654 h = elementDiameter[eN];
1655 for (k=0;k<nQuadraturePoints_element;k++)
1657 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
1660 tau1 = h*h/(12.0*viscosity);
1661 subgridErrorU[eN*nQuadraturePoints_element+
1665 pdeResidualU[eN*nQuadraturePoints_element+
1667 subgridErrorV[eN*nQuadraturePoints_element+
1671 pdeResidualV[eN*nQuadraturePoints_element+
1673 subgridErrorW[eN*nQuadraturePoints_element+
1677 pdeResidualW[eN*nQuadraturePoints_element+
1680 tau2 = 6.0*viscosity;
1681 subgridErrorP[eN*nQuadraturePoints_element+
1684 *pdeResidualP[eN*nQuadraturePoints_element+
1686 for (j=0;j<nDOF_trial_element;j++)
1690 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1691 k*nDOF_trial_element+
1695 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1696 k*nDOF_trial_element+
1698 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1699 k*nDOF_trial_element+
1703 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1704 k*nDOF_trial_element+
1707 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1708 k*nDOF_trial_element+
1712 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1713 k*nDOF_trial_element+
1715 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1716 k*nDOF_trial_element+
1720 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1721 k*nDOF_trial_element+
1724 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1725 k*nDOF_trial_element+
1729 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1730 k*nDOF_trial_element+
1732 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1733 k*nDOF_trial_element+
1737 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1738 k*nDOF_trial_element+
1741 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1742 k*nDOF_trial_element+
1747 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1748 k*nDOF_trial_element+
1750 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1751 k*nDOF_trial_element+
1756 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1757 k*nDOF_trial_element+
1764 int nQuadraturePoints_element,
1765 int nDOF_trial_element,
1767 double* elementDiameter,
1769 double* pdeResidualP,
1770 double* dpdeResidualP_du,
1771 double* dpdeResidualP_dv,
1772 double* dpdeResidualP_dw,
1773 double* pdeResidualU,
1774 double* dpdeResidualU_dp,
1775 double* dpdeResidualU_du,
1776 double* pdeResidualV,
1777 double* dpdeResidualV_dp,
1778 double* dpdeResidualV_dv,
1779 double* pdeResidualW,
1780 double* dpdeResidualW_dp,
1781 double* dpdeResidualW_dw,
1782 double* subgridErrorP,
1783 double* dsubgridErrorP_du,
1784 double* dsubgridErrorP_dv,
1785 double* dsubgridErrorP_dw,
1786 double* subgridErrorU,
1787 double* dsubgridErrorU_dp,
1788 double* dsubgridErrorU_du,
1789 double* subgridErrorV,
1790 double* dsubgridErrorV_dp,
1791 double* dsubgridErrorV_dv,
1792 double* subgridErrorW,
1793 double* dsubgridErrorW_dp,
1794 double* dsubgridErrorW_dw)
1796 int eN,k,nSpace2=nSpace*nSpace,j;
1797 double h,viscosity,tau1,tau2;
1798 for(eN=0;eN<nElements_global;eN++)
1800 h = elementDiameter[eN];
1801 for (k=0;k<nQuadraturePoints_element;k++)
1803 viscosity = a[eN*nQuadraturePoints_element*nSpace +
1806 tau1 = h*h/(12.0*viscosity);
1807 subgridErrorU[eN*nQuadraturePoints_element+
1811 pdeResidualU[eN*nQuadraturePoints_element+
1813 subgridErrorV[eN*nQuadraturePoints_element+
1817 pdeResidualV[eN*nQuadraturePoints_element+
1819 subgridErrorW[eN*nQuadraturePoints_element+
1823 pdeResidualW[eN*nQuadraturePoints_element+
1826 tau2 = 6.0*viscosity;
1827 subgridErrorP[eN*nQuadraturePoints_element+
1830 *pdeResidualP[eN*nQuadraturePoints_element+
1832 for (j=0;j<nDOF_trial_element;j++)
1836 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1837 k*nDOF_trial_element+
1841 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1842 k*nDOF_trial_element+
1844 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1845 k*nDOF_trial_element+
1849 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1850 k*nDOF_trial_element+
1853 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1854 k*nDOF_trial_element+
1858 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1859 k*nDOF_trial_element+
1861 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1862 k*nDOF_trial_element+
1866 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1867 k*nDOF_trial_element+
1870 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1871 k*nDOF_trial_element+
1875 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
1876 k*nDOF_trial_element+
1878 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1879 k*nDOF_trial_element+
1883 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
1884 k*nDOF_trial_element+
1887 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1888 k*nDOF_trial_element+
1893 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
1894 k*nDOF_trial_element+
1896 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1897 k*nDOF_trial_element+
1902 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
1903 k*nDOF_trial_element+
1915 int nQuadraturePoints_element,
1918 double* elementDiameter,
1927 int eN,k,nSpace2=nSpace*nSpace,I;
1928 double h,oneByAbsdt,density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v;
1929 for(eN=0;eN<nElements_global;eN++)
1931 h = hFactor*elementDiameter[eN];
1933 for (k=0;k<nQuadraturePoints_element;k++)
1935 density = dm[eN*nQuadraturePoints_element+
1937 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
1941 for(I=0;I<nSpace;I++)
1942 nrm_v+=
f[eN*nQuadraturePoints_element*nSpace+
1945 f[eN*nQuadraturePoints_element*nSpace+
1948 nrm_v = sqrt(nrm_v);
1949 Re_max = fmax(nrm_v*h/(viscosity/density),Re_max);
1950 CFL_max = fmax(nrm_v/h,CFL_max);
1951 cfl[eN*nQuadraturePoints_element+k] = nrm_v/h;
1954 oneByAbsdt = 10.0*(density*nrm_v/h);
1958 oneByAbsdt = fabs(dmt[eN*nQuadraturePoints_element+k]);
1960 tau0[eN*nQuadraturePoints_element+k] = 1.0/(4.0*viscosity/(h*h) +
1961 2.0*density*nrm_v/h +
1963 tau1[eN*nQuadraturePoints_element+k] = 4.0*viscosity +
1964 2.0*density*nrm_v*h+
1966 printf(
"nrm_v %12.5e tau_v %12.5e tau_p %12.5e \n",nrm_v,tau0[eN*nQuadraturePoints_element+k],tau1[eN*nQuadraturePoints_element+k]);
2021 int nQuadraturePoints_element,
2024 double* elementDiameter,
2033 int eN,k,nSpace2=nSpace*nSpace,I;
2034 double h,oneByAbsdt,density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v;
2035 for(eN=0;eN<nElements_global;eN++)
2037 h = hFactor*elementDiameter[eN];
2039 for (k=0;k<nQuadraturePoints_element;k++)
2041 density = dm[eN*nQuadraturePoints_element+
2043 viscosity = a[eN*nQuadraturePoints_element*nSpace +
2046 for(I=0;I<nSpace;I++)
2047 nrm_v+=
f[eN*nQuadraturePoints_element*nSpace+
2050 f[eN*nQuadraturePoints_element*nSpace+
2053 nrm_v = sqrt(nrm_v);
2054 Re_max = fmax(nrm_v*h/(viscosity/density),Re_max);
2055 CFL_max = fmax(nrm_v/h,CFL_max);
2056 cfl[eN*nQuadraturePoints_element+k] = nrm_v/h;
2059 oneByAbsdt = 10.0*(density*nrm_v/h);
2063 oneByAbsdt = fabs(dmt[eN*nQuadraturePoints_element+k]);
2065 tau0[eN*nQuadraturePoints_element+k] = 1.0/(4.0*viscosity/(h*h) +
2066 2.0*density*nrm_v/h +
2068 tau1[eN*nQuadraturePoints_element+k] = 4.0*viscosity +
2069 2.0*density*nrm_v*h+
2126 int nQuadraturePoints_element,
2137 int eN,k,nSpace2=nSpace*nSpace,I,J,K;
2138 double density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v,G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g,den;
2139 for(eN=0;eN<nElements_global;eN++)
2141 for (k=0;k<nQuadraturePoints_element;k++)
2144 CI_nu2_G_ddot_G=0.0;
2146 for (I=0;I<nSpace;I++)
2150 for (J=0;J<nSpace;J++)
2153 for (K=0;K<nSpace;K++)
2154 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2159 inverseJ[eN*nQuadraturePoints_element*nSpace2+
2165 f[eN*nQuadraturePoints_element*nSpace+
2168 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
2169 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2175 v_dot_Gv +=
f[eN*nQuadraturePoints_element*nSpace+
2182 density = dm[eN*nQuadraturePoints_element+
2186 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
2189 CI_nu2_G_ddot_G*=CI*viscosity*viscosity;
2190 cfl[eN*nQuadraturePoints_element+k] = sqrt(v_dot_Gv);
2191 den = sqrt(4.0*dmt[eN*nQuadraturePoints_element+k]*dmt[eN*nQuadraturePoints_element+k]+
2200 tau0[eN*nQuadraturePoints_element+k] = 1.0/den;
2201 tau1[eN*nQuadraturePoints_element+k] = sqrt(v_dot_Gv+CI_nu2_G_ddot_G)/g_dot_g;
2206 tau0[eN*nQuadraturePoints_element+k] = 0.0;
2207 tau1[eN*nQuadraturePoints_element+k] = 0.0;
2216 int nQuadraturePoints_element,
2227 int eN,k,nSpace2=nSpace*nSpace,I,J,K;
2228 double density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v,G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g,den;
2229 for(eN=0;eN<nElements_global;eN++)
2231 for (k=0;k<nQuadraturePoints_element;k++)
2234 CI_nu2_G_ddot_G=0.0;
2236 for (I=0;I<nSpace;I++)
2240 for (J=0;J<nSpace;J++)
2243 for (K=0;K<nSpace;K++)
2244 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2249 inverseJ[eN*nQuadraturePoints_element*nSpace2+
2255 f[eN*nQuadraturePoints_element*nSpace+
2258 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
2259 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2265 v_dot_Gv +=
f[eN*nQuadraturePoints_element*nSpace+
2272 density = dm[eN*nQuadraturePoints_element+
2276 viscosity = a[eN*nQuadraturePoints_element*nSpace +
2278 CI_nu2_G_ddot_G*=CI*viscosity*viscosity;
2279 cfl[eN*nQuadraturePoints_element+k] = sqrt(v_dot_Gv);
2280 den = sqrt(4.0*dmt[eN*nQuadraturePoints_element+k]*dmt[eN*nQuadraturePoints_element+k]+
2289 tau0[eN*nQuadraturePoints_element+k] = 1.0/den;
2290 tau1[eN*nQuadraturePoints_element+k] = sqrt(v_dot_Gv+CI_nu2_G_ddot_G)/g_dot_g;
2295 tau0[eN*nQuadraturePoints_element+k] = 0.0;
2296 tau1[eN*nQuadraturePoints_element+k] = 0.0;
2305 int nQuadraturePoints_element,
2317 int eN,k,nSpace2=nSpace*nSpace,I,J,K;
2318 double h,density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v,G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0,g_I,g_dot_g,den;
2319 for(eN=0;eN<nElements_global;eN++)
2321 for (k=0;k<nQuadraturePoints_element;k++)
2324 CI_nu2_G_ddot_G=0.0;
2326 for (I=0;I<nSpace;I++)
2330 for (J=0;J<nSpace;J++)
2333 for (K=0;K<nSpace;K++)
2334 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2339 inverseJ[eN*nQuadraturePoints_element*nSpace2+
2345 f[eN*nQuadraturePoints_element*nSpace+
2348 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
2349 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2355 v_dot_Gv +=
f[eN*nQuadraturePoints_element*nSpace+
2362 density = dm[eN*nQuadraturePoints_element+
2364 viscosity = 0.5*a[eN*nQuadraturePoints_element*nSpace2 +
2366 CI_nu2_G_ddot_G*=CI*viscosity*viscosity;
2367 nrm_v = sqrt(v_dot_Gv);
2368 Re_max = fmax(nrm_v/(viscosity/density),Re_max);
2369 CFL_max = fmax(nrm_v,CFL_max);
2370 cfl[eN*nQuadraturePoints_element+k] = nrm_v/h;
2371 den = sqrt(4.0*dmt[eN*nQuadraturePoints_element+k]*dmt[eN*nQuadraturePoints_element+k]+
2372 4.0*dr[eN*nQuadraturePoints_element+k]*dr[eN*nQuadraturePoints_element+k]+
2378 tau0[eN*nQuadraturePoints_element+k] = 1.0/den;
2379 tau1[eN*nQuadraturePoints_element+k] = 1.0/(tau0[eN*nQuadraturePoints_element+k]*g_dot_g);
2383 tau0[eN*nQuadraturePoints_element+k] = 0.0;
2384 tau1[eN*nQuadraturePoints_element+k] = 0.0;
2401 int nQuadraturePoints_element,
2413 int eN,k,nSpace2=nSpace*nSpace,I,J,K;
2414 double h,density,viscosity,Re_max=0.0,CFL_max=0.0,nrm_v,G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0,g_I,g_dot_g,den;
2415 for(eN=0;eN<nElements_global;eN++)
2417 for (k=0;k<nQuadraturePoints_element;k++)
2420 CI_nu2_G_ddot_G=0.0;
2422 for (I=0;I<nSpace;I++)
2426 for (J=0;J<nSpace;J++)
2429 for (K=0;K<nSpace;K++)
2430 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2435 inverseJ[eN*nQuadraturePoints_element*nSpace2+
2441 f[eN*nQuadraturePoints_element*nSpace+
2444 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
2445 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
2451 v_dot_Gv +=
f[eN*nQuadraturePoints_element*nSpace+
2458 density = dm[eN*nQuadraturePoints_element+
2460 viscosity = 0.5*a[eN*nQuadraturePoints_element*nSpace +
2462 CI_nu2_G_ddot_G*=CI*viscosity*viscosity;
2463 nrm_v = sqrt(v_dot_Gv);
2464 Re_max = fmax(nrm_v/(viscosity/density),Re_max);
2465 CFL_max = fmax(nrm_v,CFL_max);
2466 cfl[eN*nQuadraturePoints_element+k] = nrm_v/h;
2467 den = sqrt(4.0*dmt[eN*nQuadraturePoints_element+k]*dmt[eN*nQuadraturePoints_element+k]+
2468 4.0*dr[eN*nQuadraturePoints_element+k]*dr[eN*nQuadraturePoints_element+k]+
2474 tau0[eN*nQuadraturePoints_element+k] = 1.0/den;
2475 tau1[eN*nQuadraturePoints_element+k] = 1.0/(tau0[eN*nQuadraturePoints_element+k]*g_dot_g);
2479 tau0[eN*nQuadraturePoints_element+k] = 0.0;
2480 tau1[eN*nQuadraturePoints_element+k] = 0.0;
2500 int nQuadraturePoints_element,
2501 int nDOF_trial_element,
2505 double* pdeResidualP,
2506 double* dpdeResidualP_du,
2507 double* dpdeResidualP_dv,
2508 double* pdeResidualU,
2509 double* dpdeResidualU_dp,
2510 double* dpdeResidualU_du,
2511 double* dpdeResidualU_dv,
2512 double* pdeResidualV,
2513 double* dpdeResidualV_dp,
2514 double* dpdeResidualV_du,
2515 double* dpdeResidualV_dv,
2516 double* subgridErrorP,
2517 double* dsubgridErrorP_du,
2518 double* dsubgridErrorP_dv,
2519 double* subgridErrorU,
2520 double* dsubgridErrorU_dp,
2521 double* dsubgridErrorU_du,
2522 double* dsubgridErrorU_dv,
2523 double* subgridErrorV,
2524 double* dsubgridErrorV_dp,
2525 double* dsubgridErrorV_du,
2526 double* dsubgridErrorV_dv)
2529 for(eN=0;eN<nElements_global;eN++)
2531 for (k=0;k<nQuadraturePoints_element;k++)
2534 subgridErrorU[eN*nQuadraturePoints_element+
2536 -tau0[eN*nQuadraturePoints_element+k]
2538 pdeResidualU[eN*nQuadraturePoints_element+
2540 subgridErrorV[eN*nQuadraturePoints_element+
2542 -tau0[eN*nQuadraturePoints_element+k]
2544 pdeResidualV[eN*nQuadraturePoints_element+
2547 subgridErrorP[eN*nQuadraturePoints_element+
2549 -tau1[eN*nQuadraturePoints_element+k]
2550 *pdeResidualP[eN*nQuadraturePoints_element+
2552 for (j=0;j<nDOF_trial_element;j++)
2556 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2557 k*nDOF_trial_element+
2559 -tau0[eN*nQuadraturePoints_element+k]
2561 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2562 k*nDOF_trial_element+
2564 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2565 k*nDOF_trial_element+
2567 -tau0[eN*nQuadraturePoints_element+k]
2569 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2570 k*nDOF_trial_element+
2572 dsubgridErrorU_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2573 k*nDOF_trial_element+
2575 -tau0[eN*nQuadraturePoints_element+k]
2577 dpdeResidualU_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2578 k*nDOF_trial_element+
2581 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2582 k*nDOF_trial_element+
2584 -tau0[eN*nQuadraturePoints_element+k]
2586 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2587 k*nDOF_trial_element+
2589 dsubgridErrorV_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2590 k*nDOF_trial_element+
2592 -tau0[eN*nQuadraturePoints_element+k]
2594 dpdeResidualV_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2595 k*nDOF_trial_element+
2597 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2598 k*nDOF_trial_element+
2600 -tau0[eN*nQuadraturePoints_element+k]
2602 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2603 k*nDOF_trial_element+
2606 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2607 k*nDOF_trial_element+
2610 -tau1[eN*nQuadraturePoints_element+k]
2612 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2613 k*nDOF_trial_element+
2615 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2616 k*nDOF_trial_element+
2619 -tau1[eN*nQuadraturePoints_element+k]
2621 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2622 k*nDOF_trial_element+
2633 int nQuadraturePoints_element,
2635 double* elementDiameter,
2641 int eN,k,nSpace2=nSpace*nSpace;
2642 double h,viscosity,density;
2643 for(eN=0;eN<nElements_global;eN++)
2645 h = elementDiameter[eN];
2646 for (k=0;k<nQuadraturePoints_element;k++)
2648 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
2650 density = pfac[eN*nQuadraturePoints_element*nSpace+k*nSpace+0];
2651 tau0[eN*nQuadraturePoints_element+k] = 1.0/(4.0*viscosity/(h*h));
2652 tau1[eN*nQuadraturePoints_element+k] = 4.0*viscosity/density;
2658 int nQuadraturePoints_element,
2660 double* elementDiameter,
2667 double h,viscosity, density;
2668 for(eN=0;eN<nElements_global;eN++)
2670 h = elementDiameter[eN];
2671 for (k=0;k<nQuadraturePoints_element;k++)
2673 viscosity = a[eN*nQuadraturePoints_element*nSpace*nSpace +
2675 density = pfac[eN*nQuadraturePoints_element*nSpace+k*nSpace+0];
2676 tau0[eN*nQuadraturePoints_element+k] = 1.0/(4.0*viscosity/(h*h));
2677 tau1[eN*nQuadraturePoints_element+k] = 4.0*viscosity/density;
2686 int nQuadraturePoints_element,
2687 int nDOF_trial_element,
2691 double* pdeResidualP,
2692 double* dpdeResidualP_du,
2693 double* dpdeResidualP_dv,
2694 double* pdeResidualU,
2695 double* dpdeResidualU_dp,
2696 double* dpdeResidualU_du,
2697 double* pdeResidualV,
2698 double* dpdeResidualV_dp,
2699 double* dpdeResidualV_dv,
2700 double* subgridErrorP,
2701 double* dsubgridErrorP_du,
2702 double* dsubgridErrorP_dv,
2703 double* subgridErrorU,
2704 double* dsubgridErrorU_dp,
2705 double* dsubgridErrorU_du,
2706 double* subgridErrorV,
2707 double* dsubgridErrorV_dp,
2708 double* dsubgridErrorV_dv)
2711 for(eN=0;eN<nElements_global;eN++)
2713 for (k=0;k<nQuadraturePoints_element;k++)
2716 subgridErrorU[eN*nQuadraturePoints_element+
2718 -tau0[eN*nQuadraturePoints_element+k]
2720 pdeResidualU[eN*nQuadraturePoints_element+
2722 subgridErrorV[eN*nQuadraturePoints_element+
2724 -tau0[eN*nQuadraturePoints_element+k]
2726 pdeResidualV[eN*nQuadraturePoints_element+
2729 subgridErrorP[eN*nQuadraturePoints_element+
2731 -tau1[eN*nQuadraturePoints_element+k]
2732 *pdeResidualP[eN*nQuadraturePoints_element+
2734 for (j=0;j<nDOF_trial_element;j++)
2738 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2739 k*nDOF_trial_element+
2741 -tau0[eN*nQuadraturePoints_element+k]
2743 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2744 k*nDOF_trial_element+
2746 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2747 k*nDOF_trial_element+
2749 -tau0[eN*nQuadraturePoints_element+k]
2751 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2752 k*nDOF_trial_element+
2755 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2756 k*nDOF_trial_element+
2758 -tau0[eN*nQuadraturePoints_element+k]
2760 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2761 k*nDOF_trial_element+
2763 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2764 k*nDOF_trial_element+
2766 -tau0[eN*nQuadraturePoints_element+k]
2768 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2769 k*nDOF_trial_element+
2772 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2773 k*nDOF_trial_element+
2776 -tau1[eN*nQuadraturePoints_element+k]
2778 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2779 k*nDOF_trial_element+
2781 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2782 k*nDOF_trial_element+
2785 -tau1[eN*nQuadraturePoints_element+k]
2787 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2788 k*nDOF_trial_element+
2798 int nQuadraturePoints_element,
2799 int nDOF_trial_element,
2803 double* pdeResidualP,
2804 double* dpdeResidualP_du,
2805 double* dpdeResidualP_dv,
2806 double* dpdeResidualP_dw,
2807 double* pdeResidualU,
2808 double* dpdeResidualU_dp,
2809 double* dpdeResidualU_du,
2810 double* pdeResidualV,
2811 double* dpdeResidualV_dp,
2812 double* dpdeResidualV_dv,
2813 double* pdeResidualW,
2814 double* dpdeResidualW_dp,
2815 double* dpdeResidualW_dw,
2816 double* subgridErrorP,
2817 double* dsubgridErrorP_du,
2818 double* dsubgridErrorP_dv,
2819 double* dsubgridErrorP_dw,
2820 double* subgridErrorU,
2821 double* dsubgridErrorU_dp,
2822 double* dsubgridErrorU_du,
2823 double* subgridErrorV,
2824 double* dsubgridErrorV_dp,
2825 double* dsubgridErrorV_dv,
2826 double* subgridErrorW,
2827 double* dsubgridErrorW_dp,
2828 double* dsubgridErrorW_dw)
2831 for(eN=0;eN<nElements_global;eN++)
2833 for (k=0;k<nQuadraturePoints_element;k++)
2836 subgridErrorU[eN*nQuadraturePoints_element+
2838 -tau0[eN*nQuadraturePoints_element+k]
2840 pdeResidualU[eN*nQuadraturePoints_element+
2842 subgridErrorV[eN*nQuadraturePoints_element+
2844 -tau0[eN*nQuadraturePoints_element+k]
2846 pdeResidualV[eN*nQuadraturePoints_element+
2848 subgridErrorW[eN*nQuadraturePoints_element+
2850 -tau0[eN*nQuadraturePoints_element+k]
2852 pdeResidualW[eN*nQuadraturePoints_element+
2855 subgridErrorP[eN*nQuadraturePoints_element+
2857 -tau1[eN*nQuadraturePoints_element+k]
2858 *pdeResidualP[eN*nQuadraturePoints_element+
2860 for (j=0;j<nDOF_trial_element;j++)
2864 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2865 k*nDOF_trial_element+
2867 -tau0[eN*nQuadraturePoints_element+k]
2869 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2870 k*nDOF_trial_element+
2872 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2873 k*nDOF_trial_element+
2875 -tau0[eN*nQuadraturePoints_element+k]
2877 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2878 k*nDOF_trial_element+
2881 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2882 k*nDOF_trial_element+
2884 -tau0[eN*nQuadraturePoints_element+k]
2886 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2887 k*nDOF_trial_element+
2889 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2890 k*nDOF_trial_element+
2892 -tau0[eN*nQuadraturePoints_element+k]
2894 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2895 k*nDOF_trial_element+
2898 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2899 k*nDOF_trial_element+
2901 -tau0[eN*nQuadraturePoints_element+k]
2903 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
2904 k*nDOF_trial_element+
2906 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
2907 k*nDOF_trial_element+
2909 -tau0[eN*nQuadraturePoints_element+k]
2911 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
2912 k*nDOF_trial_element+
2915 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2916 k*nDOF_trial_element+
2919 -tau1[eN*nQuadraturePoints_element+k]
2921 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
2922 k*nDOF_trial_element+
2924 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2925 k*nDOF_trial_element+
2928 -tau1[eN*nQuadraturePoints_element+k]
2930 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
2931 k*nDOF_trial_element+
2933 dsubgridErrorP_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
2934 k*nDOF_trial_element+
2937 -tau1[eN*nQuadraturePoints_element+k]
2939 dpdeResidualP_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
2940 k*nDOF_trial_element+
2951 int nQuadraturePoints_element,
2952 int nDOF_trial_element,
2956 double* pdeResidualP,
2957 double* dpdeResidualP_du,
2958 double* dpdeResidualP_dv,
2959 double* dpdeResidualP_dw,
2960 double* pdeResidualU,
2961 double* dpdeResidualU_dp,
2962 double* dpdeResidualU_du,
2963 double* dpdeResidualU_dv,
2964 double* dpdeResidualU_dw,
2965 double* pdeResidualV,
2966 double* dpdeResidualV_dp,
2967 double* dpdeResidualV_du,
2968 double* dpdeResidualV_dv,
2969 double* dpdeResidualV_dw,
2970 double* pdeResidualW,
2971 double* dpdeResidualW_dp,
2972 double* dpdeResidualW_du,
2973 double* dpdeResidualW_dv,
2974 double* dpdeResidualW_dw,
2975 double* subgridErrorP,
2976 double* dsubgridErrorP_du,
2977 double* dsubgridErrorP_dv,
2978 double* dsubgridErrorP_dw,
2979 double* subgridErrorU,
2980 double* dsubgridErrorU_dp,
2981 double* dsubgridErrorU_du,
2982 double* dsubgridErrorU_dv,
2983 double* dsubgridErrorU_dw,
2984 double* subgridErrorV,
2985 double* dsubgridErrorV_dp,
2986 double* dsubgridErrorV_du,
2987 double* dsubgridErrorV_dv,
2988 double* dsubgridErrorV_dw,
2989 double* subgridErrorW,
2990 double* dsubgridErrorW_dp,
2991 double* dsubgridErrorW_du,
2992 double* dsubgridErrorW_dv,
2993 double* dsubgridErrorW_dw)
2995 int eN,k,nSpace2=nSpace*nSpace,j;
2996 for(eN=0;eN<nElements_global;eN++)
2998 for (k=0;k<nQuadraturePoints_element;k++)
3001 subgridErrorU[eN*nQuadraturePoints_element+
3003 -tau0[eN*nQuadraturePoints_element+k]
3005 pdeResidualU[eN*nQuadraturePoints_element+
3007 subgridErrorV[eN*nQuadraturePoints_element+
3009 -tau0[eN*nQuadraturePoints_element+k]
3011 pdeResidualV[eN*nQuadraturePoints_element+
3013 subgridErrorW[eN*nQuadraturePoints_element+
3015 -tau0[eN*nQuadraturePoints_element+k]
3017 pdeResidualW[eN*nQuadraturePoints_element+
3020 subgridErrorP[eN*nQuadraturePoints_element+
3022 -tau1[eN*nQuadraturePoints_element+k]
3023 *pdeResidualP[eN*nQuadraturePoints_element+
3025 for (j=0;j<nDOF_trial_element;j++)
3029 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3030 k*nDOF_trial_element+
3032 -tau0[eN*nQuadraturePoints_element+k]
3034 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3035 k*nDOF_trial_element+
3037 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3038 k*nDOF_trial_element+
3040 -tau0[eN*nQuadraturePoints_element+k]
3042 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3043 k*nDOF_trial_element+
3045 dsubgridErrorU_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3046 k*nDOF_trial_element+
3048 -tau0[eN*nQuadraturePoints_element+k]
3050 dpdeResidualU_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3051 k*nDOF_trial_element+
3053 dsubgridErrorU_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3054 k*nDOF_trial_element+
3056 -tau0[eN*nQuadraturePoints_element+k]
3058 dpdeResidualU_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3059 k*nDOF_trial_element+
3062 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3063 k*nDOF_trial_element+
3065 -tau0[eN*nQuadraturePoints_element+k]
3067 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3068 k*nDOF_trial_element+
3070 dsubgridErrorV_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3071 k*nDOF_trial_element+
3073 -tau0[eN*nQuadraturePoints_element+k]
3075 dpdeResidualV_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3076 k*nDOF_trial_element+
3078 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3079 k*nDOF_trial_element+
3081 -tau0[eN*nQuadraturePoints_element+k]
3083 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3084 k*nDOF_trial_element+
3086 dsubgridErrorV_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3087 k*nDOF_trial_element+
3089 -tau0[eN*nQuadraturePoints_element+k]
3091 dpdeResidualV_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3092 k*nDOF_trial_element+
3095 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3096 k*nDOF_trial_element+
3098 -tau0[eN*nQuadraturePoints_element+k]
3100 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3101 k*nDOF_trial_element+
3103 dsubgridErrorW_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3104 k*nDOF_trial_element+
3106 -tau0[eN*nQuadraturePoints_element+k]
3108 dpdeResidualW_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3109 k*nDOF_trial_element+
3111 dsubgridErrorW_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3112 k*nDOF_trial_element+
3114 -tau0[eN*nQuadraturePoints_element+k]
3116 dpdeResidualW_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3117 k*nDOF_trial_element+
3119 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3120 k*nDOF_trial_element+
3122 -tau0[eN*nQuadraturePoints_element+k]
3124 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3125 k*nDOF_trial_element+
3128 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3129 k*nDOF_trial_element+
3132 -tau1[eN*nQuadraturePoints_element+k]
3134 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3135 k*nDOF_trial_element+
3137 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3138 k*nDOF_trial_element+
3141 -tau1[eN*nQuadraturePoints_element+k]
3143 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3144 k*nDOF_trial_element+
3146 dsubgridErrorP_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3147 k*nDOF_trial_element+
3150 -tau1[eN*nQuadraturePoints_element+k]
3152 dpdeResidualP_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3153 k*nDOF_trial_element+
3164 int nQuadraturePoints_element,
3165 int nDOF_trial_element,
3167 double* elementDiameter,
3171 double* pdeResidualP,
3172 double* dpdeResidualP_du,
3173 double* dpdeResidualP_dv,
3174 double* dpdeResidualP_dw,
3175 double* pdeResidualU,
3176 double* dpdeResidualU_dp,
3177 double* dpdeResidualU_du,
3178 double* pdeResidualV,
3179 double* dpdeResidualV_dp,
3180 double* dpdeResidualV_dv,
3181 double* pdeResidualW,
3182 double* dpdeResidualW_dp,
3183 double* dpdeResidualW_dw,
3184 double* subgridErrorP,
3185 double* dsubgridErrorP_du,
3186 double* dsubgridErrorP_dv,
3187 double* dsubgridErrorP_dw,
3188 double* subgridErrorU,
3189 double* dsubgridErrorU_dp,
3190 double* dsubgridErrorU_du,
3191 double* subgridErrorV,
3192 double* dsubgridErrorV_dp,
3193 double* dsubgridErrorV_dv,
3194 double* subgridErrorW,
3195 double* dsubgridErrorW_dp,
3196 double* dsubgridErrorW_dw)
3198 int eN,k,nSpace2=nSpace*nSpace,j;
3199 double h,viscosity,tau1,tau2;
3200 for(eN=0;eN<nElements_global;eN++)
3202 h = elementDiameter[eN];
3203 for (k=0;k<nQuadraturePoints_element;k++)
3205 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
3208 tau1 = h*h/(12.0*viscosity);
3209 subgridErrorU[eN*nQuadraturePoints_element+
3213 pdeResidualU[eN*nQuadraturePoints_element+
3215 subgridErrorV[eN*nQuadraturePoints_element+
3219 pdeResidualV[eN*nQuadraturePoints_element+
3221 subgridErrorW[eN*nQuadraturePoints_element+
3225 pdeResidualW[eN*nQuadraturePoints_element+
3228 tau2 = 6.0*viscosity;
3229 subgridErrorP[eN*nQuadraturePoints_element+
3232 *pdeResidualP[eN*nQuadraturePoints_element+
3234 for (j=0;j<nDOF_trial_element;j++)
3238 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3239 k*nDOF_trial_element+
3243 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3244 k*nDOF_trial_element+
3246 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3247 k*nDOF_trial_element+
3251 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3252 k*nDOF_trial_element+
3255 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3256 k*nDOF_trial_element+
3260 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3261 k*nDOF_trial_element+
3263 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3264 k*nDOF_trial_element+
3268 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3269 k*nDOF_trial_element+
3272 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3273 k*nDOF_trial_element+
3277 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3278 k*nDOF_trial_element+
3280 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3281 k*nDOF_trial_element+
3285 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3286 k*nDOF_trial_element+
3289 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3290 k*nDOF_trial_element+
3295 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3296 k*nDOF_trial_element+
3298 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3299 k*nDOF_trial_element+
3304 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3305 k*nDOF_trial_element+
3313 int nQuadraturePoints_element,
3314 int nDOF_trial_element,
3316 double* elementDiameter,
3320 double* pdeResidualP,
3321 double* dpdeResidualP_du,
3322 double* dpdeResidualP_dv,
3323 double* dpdeResidualP_dw,
3324 double* pdeResidualU,
3325 double* dpdeResidualU_dp,
3326 double* dpdeResidualU_du,
3327 double* pdeResidualV,
3328 double* dpdeResidualV_dp,
3329 double* dpdeResidualV_dv,
3330 double* pdeResidualW,
3331 double* dpdeResidualW_dp,
3332 double* dpdeResidualW_dw,
3333 double* subgridErrorP,
3334 double* dsubgridErrorP_du,
3335 double* dsubgridErrorP_dv,
3336 double* dsubgridErrorP_dw,
3337 double* subgridErrorU,
3338 double* dsubgridErrorU_dp,
3339 double* dsubgridErrorU_du,
3340 double* subgridErrorV,
3341 double* dsubgridErrorV_dp,
3342 double* dsubgridErrorV_dv,
3343 double* subgridErrorW,
3344 double* dsubgridErrorW_dp,
3345 double* dsubgridErrorW_dw)
3348 double h,viscosity,tau1,tau2;
3349 for(eN=0;eN<nElements_global;eN++)
3351 h = elementDiameter[eN];
3352 for (k=0;k<nQuadraturePoints_element;k++)
3354 viscosity = a[eN*nQuadraturePoints_element*nSpace +
3357 tau1 = h*h/(12.0*viscosity);
3358 subgridErrorU[eN*nQuadraturePoints_element+
3362 pdeResidualU[eN*nQuadraturePoints_element+
3364 subgridErrorV[eN*nQuadraturePoints_element+
3368 pdeResidualV[eN*nQuadraturePoints_element+
3370 subgridErrorW[eN*nQuadraturePoints_element+
3374 pdeResidualW[eN*nQuadraturePoints_element+
3377 tau2 = 6.0*viscosity;
3378 subgridErrorP[eN*nQuadraturePoints_element+
3381 *pdeResidualP[eN*nQuadraturePoints_element+
3383 for (j=0;j<nDOF_trial_element;j++)
3387 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3388 k*nDOF_trial_element+
3392 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3393 k*nDOF_trial_element+
3395 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3396 k*nDOF_trial_element+
3400 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3401 k*nDOF_trial_element+
3404 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3405 k*nDOF_trial_element+
3409 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3410 k*nDOF_trial_element+
3412 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3413 k*nDOF_trial_element+
3417 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3418 k*nDOF_trial_element+
3421 dsubgridErrorW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3422 k*nDOF_trial_element+
3426 dpdeResidualW_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3427 k*nDOF_trial_element+
3429 dsubgridErrorW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3430 k*nDOF_trial_element+
3434 dpdeResidualW_dw[eN*nQuadraturePoints_element*nDOF_trial_element+
3435 k*nDOF_trial_element+
3438 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3439 k*nDOF_trial_element+
3444 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3445 k*nDOF_trial_element+
3447 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3448 k*nDOF_trial_element+
3453 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3454 k*nDOF_trial_element+
3465 int nQuadraturePoints_element,
3466 int nDOF_trial_element,
3468 double* elementDiameter,
3472 double* pdeResidualP,
3473 double* dpdeResidualP_du,
3474 double* dpdeResidualP_dv,
3475 double* pdeResidualU,
3476 double* dpdeResidualU_dp,
3477 double* dpdeResidualU_du,
3478 double* pdeResidualV,
3479 double* dpdeResidualV_dp,
3480 double* dpdeResidualV_dv,
3481 double* subgridErrorP,
3482 double* dsubgridErrorP_dp,
3483 double* dsubgridErrorP_du,
3484 double* dsubgridErrorP_dv,
3485 double* subgridErrorU,
3486 double* dsubgridErrorU_dp,
3487 double* dsubgridErrorU_du,
3488 double* dsubgridErrorU_dv,
3489 double* subgridErrorV,
3490 double* dsubgridErrorV_dp,
3491 double* dsubgridErrorV_du,
3492 double* dsubgridErrorV_dv)
3494 int eN,k,nSpace2=nSpace*nSpace,j;
3495 double h,velocity_norm,viscosity,tau1,tau2,
U,V;
3496 for(eN=0;eN<nElements_global;eN++)
3498 h = elementDiameter[eN];
3499 for (k=0;k<nQuadraturePoints_element;k++)
3501 U =
u[eN*nQuadraturePoints_element+
3503 V =
v[eN*nQuadraturePoints_element+
3505 velocity_norm = sqrt(
U*
U + V*V);
3506 viscosity = a[eN*nQuadraturePoints_element*nSpace2 +
3508 tau1 = 1.0/(4.0*viscosity/(h*h)+2.0*velocity_norm/h+1.0e-8);
3509 tau2 = 4.0*viscosity+2.0*velocity_norm*h;
3541 tau1 = h*h/(12.0*viscosity);
3542 subgridErrorU[eN*nQuadraturePoints_element+
3546 pdeResidualU[eN*nQuadraturePoints_element+
3548 subgridErrorV[eN*nQuadraturePoints_element+
3552 pdeResidualV[eN*nQuadraturePoints_element+
3555 tau2 = 6.0*viscosity;
3556 subgridErrorP[eN*nQuadraturePoints_element+
3559 *pdeResidualP[eN*nQuadraturePoints_element+
3561 for (j=0;j<nDOF_trial_element;j++)
3658 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3659 k*nDOF_trial_element+
3663 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3664 k*nDOF_trial_element+
3666 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3667 k*nDOF_trial_element+
3671 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3672 k*nDOF_trial_element+
3675 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3676 k*nDOF_trial_element+
3680 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3681 k*nDOF_trial_element+
3683 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3684 k*nDOF_trial_element+
3688 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3689 k*nDOF_trial_element+
3692 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3693 k*nDOF_trial_element+
3698 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3699 k*nDOF_trial_element+
3701 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3702 k*nDOF_trial_element+
3707 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3708 k*nDOF_trial_element+
3716 int nQuadraturePoints_element,
3717 int nDOF_trial_element,
3719 double* elementDiameter,
3723 double* pdeResidualP,
3724 double* dpdeResidualP_du,
3725 double* dpdeResidualP_dv,
3726 double* pdeResidualU,
3727 double* dpdeResidualU_dp,
3728 double* dpdeResidualU_du,
3729 double* pdeResidualV,
3730 double* dpdeResidualV_dp,
3731 double* dpdeResidualV_dv,
3732 double* subgridErrorP,
3733 double* dsubgridErrorP_dp,
3734 double* dsubgridErrorP_du,
3735 double* dsubgridErrorP_dv,
3736 double* subgridErrorU,
3737 double* dsubgridErrorU_dp,
3738 double* dsubgridErrorU_du,
3739 double* dsubgridErrorU_dv,
3740 double* subgridErrorV,
3741 double* dsubgridErrorV_dp,
3742 double* dsubgridErrorV_du,
3743 double* dsubgridErrorV_dv)
3746 double h,velocity_norm,viscosity,tau1,tau2,
U,V;
3747 for(eN=0;eN<nElements_global;eN++)
3749 h = elementDiameter[eN];
3750 for (k=0;k<nQuadraturePoints_element;k++)
3752 U =
u[eN*nQuadraturePoints_element+
3754 V =
v[eN*nQuadraturePoints_element+
3756 velocity_norm = sqrt(
U*
U + V*V);
3757 viscosity = a[eN*nQuadraturePoints_element*nSpace +
3759 tau1 = 1.0/(4.0*viscosity/(h*h)+2.0*velocity_norm/h+1.0e-8);
3760 tau2 = 4.0*viscosity+2.0*velocity_norm*h;
3792 tau1 = h*h/(12.0*viscosity);
3793 subgridErrorU[eN*nQuadraturePoints_element+
3797 pdeResidualU[eN*nQuadraturePoints_element+
3799 subgridErrorV[eN*nQuadraturePoints_element+
3803 pdeResidualV[eN*nQuadraturePoints_element+
3806 tau2 = 6.0*viscosity;
3807 subgridErrorP[eN*nQuadraturePoints_element+
3810 *pdeResidualP[eN*nQuadraturePoints_element+
3812 for (j=0;j<nDOF_trial_element;j++)
3909 dsubgridErrorU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3910 k*nDOF_trial_element+
3914 dpdeResidualU_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3915 k*nDOF_trial_element+
3917 dsubgridErrorU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3918 k*nDOF_trial_element+
3922 dpdeResidualU_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3923 k*nDOF_trial_element+
3926 dsubgridErrorV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3927 k*nDOF_trial_element+
3931 dpdeResidualV_dp[eN*nQuadraturePoints_element*nDOF_trial_element+
3932 k*nDOF_trial_element+
3934 dsubgridErrorV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3935 k*nDOF_trial_element+
3939 dpdeResidualV_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3940 k*nDOF_trial_element+
3943 dsubgridErrorP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3944 k*nDOF_trial_element+
3949 dpdeResidualP_du[eN*nQuadraturePoints_element*nDOF_trial_element+
3950 k*nDOF_trial_element+
3952 dsubgridErrorP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3953 k*nDOF_trial_element+
3958 dpdeResidualP_dv[eN*nQuadraturePoints_element*nDOF_trial_element+
3959 k*nDOF_trial_element+
3967 int nQuadraturePoints_element,
3969 double* elementDiameter,
3977 for(eN=0;eN<nElements_global;eN++)
3979 for (k=0;k<nQuadraturePoints_element;k++)
3981 u = hu[eN*nQuadraturePoints_element+k]/fmax(h[eN*nQuadraturePoints_element+k],1.0e-8);
3982 c = sqrt(fabs(g*h[eN*nQuadraturePoints_element+k]));
3983 cfl_1[eN*nQuadraturePoints_element+k] = (
u-
c)/elementDiameter[eN];
3984 cfl_2[eN*nQuadraturePoints_element+k] = (
u+
c)/elementDiameter[eN];
3989 int nQuadraturePoints_element,
3991 double* elementDiameter,
4001 for(eN=0;eN<nElements_global;eN++)
4003 for (k=0;k<nQuadraturePoints_element;k++)
4005 u = hu[eN*nQuadraturePoints_element+k]/fmax(h[eN*nQuadraturePoints_element+k],1.0e-8);
4006 v = hv[eN*nQuadraturePoints_element+k]/fmax(h[eN*nQuadraturePoints_element+k],1.0e-8);
4007 speed = sqrt(
u*
u +
v*
v);
4008 c = sqrt(fabs(g*h[eN*nQuadraturePoints_element+k]));
4009 cfl_1[eN*nQuadraturePoints_element+k] = (speed-
c)/elementDiameter[eN];
4010 cfl_2[eN*nQuadraturePoints_element+k] = speed/elementDiameter[eN];
4011 cfl_3[eN*nQuadraturePoints_element+k] = (speed+
c)/elementDiameter[eN];
4018 int nQuadraturePoints_element,
4023 double* elementDiameter,
4027 int eN,k,I,m,
nnz=rowptr[nSpace];
4028 double h,A_max,A_II,tauMax,heps;
4029 for(eN=0;eN<nElements_global;eN++)
4031 h = elementDiameter[eN];
4033 for (k=0;k<nQuadraturePoints_element;k++)
4037 for(I=0;I<nSpace;I++)
4039 for(m=rowptr[I];m<rowptr[I+1];m++)
4043 A_II = a[eN*nQuadraturePoints_element*
nnz+
4046 A_max = (A_II > A_max) ? A_II : A_max;
4052 heps = h/(A_max*dt);
4053 heps = (heps > 20.0) ? 20.0 : heps;
4055 tau[eN*nQuadraturePoints_element + k]=dt + 6.0*A_max*dt*dt/(h*h)*(1.0-cosh(heps))/(2.0+cosh(heps));
4065 int nQuadraturePoints_element,
4067 double* tau_gradient,
4068 double* grad_pdeResidual,
4069 double* grad_subgridError)
4072 for(eN=0;eN<nElements_global;eN++)
4073 for (k=0;k<nQuadraturePoints_element;k++)
4075 for (I=0; I < nSpace; I++)
4077 grad_subgridError[eN*nQuadraturePoints_element*nSpace+
4079 -tau_gradient[eN*nQuadraturePoints_element+
4082 grad_pdeResidual[eN*nQuadraturePoints_element*nSpace+
4092 int nQuadraturePoints_element,
4105 double* tau_gradient)
4107 int eN,k,I,J,K,nSpace2=nSpace*nSpace;
4108 double Vlin,Alin,A_II,cfl1,cfl2,Pe,Da,vlin[3],G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g;
4109 double h_e,tau_00,tau_11,t_00,t_11,coshGamma;
4110 for(eN=0;eN<nElements_global;eN++)
4112 for (k=0;k<nQuadraturePoints_element;k++)
4116 for(I=0;I<nSpace;I++)
4118 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
4121 for(J=0;J<nSpace;J++)
4125 da[eN*nQuadraturePoints_element*nSpace2 +
4130 grad_phi[eN*nQuadraturePoints_element*nSpace +
4136 CI_nu2_G_ddot_G=0.0;
4138 for (I=0;I<nSpace;I++)
4142 for (J=0;J<nSpace;J++)
4145 for (K=0;K<nSpace;K++)
4146 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
4151 inverseJ[eN*nQuadraturePoints_element*nSpace2+
4158 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
4159 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
4171 for(I=0;I<nSpace;I++)
4173 A_II = a[eN*nQuadraturePoints_element*nSpace2 +
4177 Alin = (A_II > Alin) ? A_II : Alin;
4179 Alin*=dphi[eN*nQuadraturePoints_element +
4181 CI_nu2_G_ddot_G*=CI*Alin*Alin;
4183 h_e = sqrt(g_dot_g);
4184 cfl1 = 0.5*sqrt(v_dot_Gv);
4185 cfl2 = 0.25*sqrt(CI_nu2_G_ddot_G);
4186 Pe = sqrt(v_dot_Gv)/sqrt(CI_nu2_G_ddot_G);
4187 Da = (dmt[eN*nQuadraturePoints_element + k] + dr[eN*nQuadraturePoints_element + k])/(cfl1 + 1.0e-12);
4191 if (fabs(Da) < 1.0e-8)
4194 tau_00 = 1.0/sqrt(v_dot_Gv +
4198 else if (Da > Pe*10.0)
4200 tau_00 = 0.5/dmt[eN*nQuadraturePoints_element + k];
4201 tau_11 = h_e*h_e/(12.0*dmt[eN*nQuadraturePoints_element + k]);
4203 else if (cfl1 < 1.0e-8)
4205 if (Pe*(2.0*Da + Pe) < 0.0)
4206 coshGamma = cos(sqrt(Pe*(-2.0*Da - Pe)));
4207 else if (Pe*(2.0*Da + Pe) > 1000.0)
4208 coshGamma = cosh(100.0);
4210 coshGamma = cosh(sqrt(Pe*(2.0*Da + Pe)));
4212 tau_00 = -1.0/dmt[eN*nQuadraturePoints_element + k]*1.0/(-2.0 - Pe*Da/(coshGamma - 1.0 - 2.0*Pe*Da) + 1.0e-8);
4213 tau_11 = -h_e*h_e/(dmt[eN*nQuadraturePoints_element + k]*6.0)*(-1.0 - 6.0/(2.0*Pe*Da) + 3.0*coshGamma -Pe*Da/(-2.0 + 2.0*coshGamma - Pe*Da));
4217 t_00 = fmin(Pe/6.0,fmin(0.5/Da,0.5));
4218 t_11 = fmin(Pe/60.0,fmin(-1.0/(12.0*Da),1.0/24.0));
4221 tau_11 = t_11/cfl1/(h_e*h_e);
4223 assert(tau_11 <= 0.0);
4224 assert(tau_00 >= 0.0);
4226 tau[eN*nQuadraturePoints_element + k] = tau_00;
4227 tau_gradient[eN*nQuadraturePoints_element + k] = tau_11;
4230 cfl[eN*nQuadraturePoints_element +
4233 cfl[eN*nQuadraturePoints_element +
4236 pe[eN*nQuadraturePoints_element +
4237 k] = sqrt(v_dot_Gv)/sqrt(CI_nu2_G_ddot_G);
4245 int nQuadraturePoints_element,
4260 double* tau_gradient)
4262 int eN,k,I,J,K,m,
nnz=rowptr[nSpace],nSpace2=nSpace*nSpace;
4263 double Vlin,Alin,A_II,cfl1,cfl2,vlin[3],G_IJ,v_dot_Gv,CI_nu2_G_ddot_G,Gv_I,CI=36.0*36.0,g_I,g_dot_g;
4264 double Da,h_e,tau_00,tau_11,t_00,t_11,coshGamma,Pe,sinhAlpha,coshAlpha,PeEval,gamma2,gam2Eval,DaEval;
4265 for(eN=0;eN<nElements_global;eN++)
4267 for (k=0;k<nQuadraturePoints_element;k++)
4271 for(I=0;I<nSpace;I++)
4273 vlin[I] =
df[eN*nQuadraturePoints_element*nSpace +
4276 for(m=rowptr[I];m<rowptr[I+1];m++)
4280 da[eN*nQuadraturePoints_element*
nnz+
4284 grad_phi[eN*nQuadraturePoints_element*nSpace +
4290 CI_nu2_G_ddot_G=0.0;
4292 for (I=0;I<nSpace;I++)
4296 for (J=0;J<nSpace;J++)
4299 for (K=0;K<nSpace;K++)
4300 G_IJ +=inverseJ[eN*nQuadraturePoints_element*nSpace2+
4305 inverseJ[eN*nQuadraturePoints_element*nSpace2+
4312 CI_nu2_G_ddot_G+=G_IJ*G_IJ;
4313 g_I+=inverseJ[eN*nQuadraturePoints_element*nSpace2+
4325 for(I=0;I<nSpace;I++)
4327 for(m=rowptr[I];m<rowptr[I+1];m++)
4331 A_II = a[eN*nQuadraturePoints_element*
nnz +
4333 Alin = (A_II > Alin) ? A_II : Alin;
4337 Alin*=dphi[eN*nQuadraturePoints_element +
4339 CI_nu2_G_ddot_G*=CI*Alin*Alin;
4341 h_e = 1.0/sqrt(g_dot_g);
4342 cfl1 = sqrt(v_dot_Gv);
4343 cfl2 = 0.25*sqrt(CI_nu2_G_ddot_G);
4344 Pe = sqrt(v_dot_Gv)/(sqrt(CI_nu2_G_ddot_G)+1.0e-12);
4345 Da = (dmt[eN*nQuadraturePoints_element + k] + dr[eN*nQuadraturePoints_element + k])/(cfl1 + 1.0e-12);
4349 if (fabs(Da) < 1.0e-8)
4352 tau_00 = 1.0/sqrt(v_dot_Gv +
4359 else if (Da > Pe*10.0)
4361 tau_00 = 0.5/(dmt[eN*nQuadraturePoints_element + k]+dr[eN*nQuadraturePoints_element + k]);
4362 tau_11 = -h_e*h_e/(12.0*(dmt[eN*nQuadraturePoints_element + k] + dr[eN*nQuadraturePoints_element + k]));
4369 else if (cfl1 < 1.0e-8)
4371 if (Pe*(2.0*Da + Pe) < 0.0)
4372 coshGamma = cos(sqrt(Pe*(-2.0*Da - Pe)));
4373 else if (Pe*(2.0*Da + Pe) > 1000.0)
4374 coshGamma = cosh(100.0);
4376 coshGamma = cosh(sqrt(Pe*(2.0*Da + Pe)));
4378 tau_00 = -1.0/dmt[eN*nQuadraturePoints_element + k]*1.0/(-2.0 - Pe*Da/(coshGamma - 1.0 - 2.0*Pe*Da) + 1.0e-8);
4379 tau_11 = -h_e*h_e/(dmt[eN*nQuadraturePoints_element + k]*6.0)*(-1.0 - 6.0/(2.0*Pe*Da) + 3.0*coshGamma -Pe*Da/(-2.0 + 2.0*coshGamma - Pe*Da));
4384 else if (Da >= 0.0 && 0)
4386 t_00 = fmin(Pe/6.0,fmin(0.5/Da,0.5));
4387 t_11 = fmin(Pe/60.0,fmin(1.0/(12.0*Da),1.0/24.0));
4390 tau_11 = h_e*h_e*t_11/cfl1;
4392 printf(
"Sangalli general reduced formula Da= %12.5e Pe=%12.5e cfl=%12.5e t_11=%12.5e tau_11=%12.5e t_00=%12.5e tau_00=%12.5e \n",Da,Pe,cfl1,t_11,tau_11,t_00,tau_00);
4397 PeEval = fmin(Pe,10.0);
4403 gamma2 = PeEval*(-2.0*DaEval + PeEval);
4406 coshGamma = cos(sqrt(PeEval*(2.0*DaEval - PeEval)));
4408 coshGamma = cosh(sqrt(gamma2));
4409 sinhAlpha = sinh(PeEval);
4410 coshAlpha = cosh(PeEval);
4412 t_00 = 1.0/(-2.0*DaEval + DaEval*DaEval*sinhAlpha/(-coshAlpha + coshGamma + DaEval*sinhAlpha));
4413 t_11 = (-3.0 -DaEval*DaEval + 3.0*DaEval/(PeEval+1.0e-12) + DaEval*(3.0*DaEval * coshGamma + sinhAlpha*(-3.0 + DaEval*DaEval))/
4414 (-2.0*coshAlpha + 2.0*coshGamma + DaEval*sinhAlpha))/(6.0*DaEval*DaEval*DaEval + 1.0e-12);
4440 tau_11 = h_e*h_e*t_11/cfl1;
4442 printf(
"\t Sangalli general h_e= %12.5e Da= %12.5e DaEval= %12.5e Pe=%12.5e PeEval= %12.5e cfl=%12.5e \n\t gamma2= %12.5e coshGamma=%12.5e sinhAlpha=%12.5e coshAlpha=%12.5e \n\t t_11=%12.5e tau_11=%12.5e t_00= %12.5e tau_00=%12.5e \n",h_e,Da,DaEval,Pe,PeEval,cfl1,gamma2,coshGamma,sinhAlpha,coshAlpha,t_11,tau_11,t_00,tau_00);
4450 printf(
"Sangalli tau_11 = %12.5e > 0 switching ",tau_11);
4451 t_11 = fmin(Pe/60.0,fmin(1.0/(12.0*Da),1.0/24.0));
4453 tau_11 = h_e*h_e*t_11/cfl1;
4455 printf(
"tau_11 = %12.5e \n",tau_11);
4459 assert(tau_11 <= 0.0);
4460 assert(tau_00 >= 0.0);
4462 tau[eN*nQuadraturePoints_element + k] = tau_00;
4463 tau_gradient[eN*nQuadraturePoints_element + k] = tau_11;
4466 cfl[eN*nQuadraturePoints_element +
4469 cfl[eN*nQuadraturePoints_element +
4472 pe[eN*nQuadraturePoints_element +
4473 k] = sqrt(v_dot_Gv)/sqrt(CI_nu2_G_ddot_G);