9 #include "xtensor-python/pyarray.hpp"
11 namespace py = pybind11;
13 static const double DM=0.0;
14 static const double DM2=0.0;
15 static const double DM3=1.0;
39 double mu_fr_limiter){}
45 template<
class CompKernelType,
47 int nQuadraturePoints_element,
48 int nDOF_mesh_trial_element,
49 int nDOF_trial_element,
50 int nDOF_test_element,
51 int nQuadraturePoints_elementBoundary>
128 H = 0.5*(1.0 +
phi/eps + sin(M_PI*
phi/eps)/M_PI);
138 + 0.5*(eps + 0.5*eps*eps/eps - eps*cos(M_PI*eps/eps)/(M_PI*M_PI)) \
139 - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI));
147 HI = 0.5*(
phi + 0.5*
phi*
phi/eps - eps*cos(M_PI*
phi/eps)/(M_PI*M_PI)) \
148 - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI));
161 d = 0.5*(1.0 + cos(M_PI*
phi/eps))/eps;
175 const double smagorinskyConstant,
176 const int turbulenceClosureModel,
177 const double g[nSpace],
181 const double n[nSpace],
185 const double grad_p[nSpace],
186 const double grad_u[nSpace],
187 const double grad_v[nSpace],
188 const double grad_w[nSpace],
195 double& eddy_viscosity,
197 double& dmom_u_acc_u,
199 double& dmom_v_acc_v,
201 double& dmom_w_acc_w,
202 double mass_adv[nSpace],
203 double dmass_adv_u[nSpace],
204 double dmass_adv_v[nSpace],
205 double dmass_adv_w[nSpace],
206 double mom_u_adv[nSpace],
207 double dmom_u_adv_u[nSpace],
208 double dmom_u_adv_v[nSpace],
209 double dmom_u_adv_w[nSpace],
210 double mom_v_adv[nSpace],
211 double dmom_v_adv_u[nSpace],
212 double dmom_v_adv_v[nSpace],
213 double dmom_v_adv_w[nSpace],
214 double mom_w_adv[nSpace],
215 double dmom_w_adv_u[nSpace],
216 double dmom_w_adv_v[nSpace],
217 double dmom_w_adv_w[nSpace],
218 double mom_uu_diff_ten[nSpace],
219 double mom_vv_diff_ten[nSpace],
220 double mom_ww_diff_ten[nSpace],
221 double mom_uv_diff_ten[1],
222 double mom_uw_diff_ten[1],
223 double mom_vu_diff_ten[1],
224 double mom_vw_diff_ten[1],
225 double mom_wu_diff_ten[1],
226 double mom_wv_diff_ten[1],
227 double& mom_u_source,
228 double& mom_v_source,
229 double& mom_w_source,
231 double dmom_u_ham_grad_p[nSpace],
232 double dmom_u_ham_grad_u[nSpace],
234 double dmom_v_ham_grad_p[nSpace],
235 double dmom_v_ham_grad_v[nSpace],
237 double dmom_w_ham_grad_p[nSpace],
238 double dmom_w_ham_grad_w[nSpace])
240 double rho,rho_f,H_rho;
372 mom_uu_diff_ten[0] =0.0;
373 mom_uu_diff_ten[1] =0.0;
374 mom_uu_diff_ten[2] =0.0;
376 mom_uv_diff_ten[0]=0.0;
378 mom_uw_diff_ten[0]=0.0;
381 mom_vv_diff_ten[0] =0.0;
382 mom_vv_diff_ten[1] =0.0;
383 mom_vv_diff_ten[2] =0.0;
385 mom_vu_diff_ten[0]=0.0;
387 mom_vw_diff_ten[0]=0.0;
390 mom_ww_diff_ten[0] =0.0;
391 mom_ww_diff_ten[1] =0.0;
392 mom_ww_diff_ten[2] =0.0;
394 mom_wu_diff_ten[0]=0.0;
396 mom_wv_diff_ten[0]=0.0;
399 mom_u_source = -rho*g[0];
400 mom_v_source = -rho*g[1];
401 mom_w_source = -rho*g[2];
404 mom_u_source += (rho-rho_f)*g[0];
405 mom_v_source += (rho-rho_f)*g[1];
406 mom_w_source += (rho-rho_f)*g[2];
410 mom_u_ham = grad_p[0];
411 dmom_u_ham_grad_p[0]=1.0;
412 dmom_u_ham_grad_p[1]=0.0;
413 dmom_u_ham_grad_p[2]=0.0;
416 mom_v_ham = grad_p[1];
417 dmom_v_ham_grad_p[0]=0.0;
418 dmom_v_ham_grad_p[1]=1.0;
419 dmom_v_ham_grad_p[2]=0.0;
422 mom_w_ham = grad_p[2];
423 dmom_w_ham_grad_p[0]=0.0;
424 dmom_w_ham_grad_p[1]=0.0;
425 dmom_w_ham_grad_p[2]=1.0;
428 mom_u_ham += rho*(uStar*grad_u[0]+vStar*grad_u[1]+wStar*grad_u[2]);
429 dmom_u_ham_grad_u[0]= rho*uStar;
430 dmom_u_ham_grad_u[1]= rho*vStar;
431 dmom_u_ham_grad_u[2]= rho*wStar;
434 mom_v_ham += rho*(uStar*grad_v[0]+vStar*grad_v[1]+wStar*grad_v[2]);
435 dmom_v_ham_grad_v[0]= rho*uStar;
436 dmom_v_ham_grad_v[1]= rho*vStar;
437 dmom_v_ham_grad_v[2]= rho*wStar;
440 mom_w_ham += rho*(uStar*grad_w[0]+vStar*grad_w[1]+wStar*grad_w[2]);
441 dmom_w_ham_grad_w[0]= rho*uStar;
442 dmom_w_ham_grad_w[1]= rho*vStar;
443 dmom_w_ham_grad_w[2]= rho*wStar;
453 const double eps_rho,
474 const double uStar_f,
475 const double vStar_f,
476 const double wStar_f,
477 double& mom_u_source,
478 double& mom_v_source,
479 double& mom_w_source,
480 double dmom_u_source[nSpace],
481 double dmom_v_source[nSpace],
482 double dmom_w_source[nSpace],
487 double rhoFluid,nuFluid,H_mu,viscosity;
489 nuFluid =
nu_0*(1.0-H_mu)+
nu_1*H_mu;
495 double solid_velocity[3]={uStar,vStar,wStar}, fluid_velocity[3]={uStar_f,vStar_f,wStar_f};
501 double one_by_vos = 2.0*vos/(vos*vos + fmax(1.0e-8,vos*vos));
503 mom_u_source += new_beta*((
u-u_f) + one_by_vos*nu_t*gradC_x/
closure.
sigmaC_);
504 mom_v_source += new_beta*((
v-v_f) + one_by_vos*nu_t*gradC_y/
closure.
sigmaC_);
505 mom_w_source += new_beta*((
w-w_f) + one_by_vos*nu_t*gradC_z/
closure.
sigmaC_);
507 dmom_u_source[0] = new_beta;
508 dmom_u_source[1] = 0.0;
509 dmom_u_source[2] = 0.0;
511 dmom_v_source[0] = 0.0;
512 dmom_v_source[1] = new_beta;
513 dmom_v_source[2] = 0.0;
515 dmom_w_source[0] = 0.0;
516 dmom_w_source[1] = 0.0;
517 dmom_w_source[2] = new_beta;
525 double& mom_u_source,
526 double& mom_v_source,
527 double& mom_w_source,
528 double dmom_u_source[nSpace],
529 double dmom_v_source[nSpace],
530 double dmom_w_source[nSpace])
535 double dVos = vos - meanPack;
537 double packPenalty = 1e6;
538 mom_u_source += sigma * packPenalty*
u;
539 mom_v_source += sigma * packPenalty*
v;
540 mom_w_source += sigma * packPenalty*
v;
541 dmom_u_source[0] += sigma * packPenalty;
542 dmom_v_source[1] += sigma * packPenalty;
543 dmom_w_source[2] += sigma * packPenalty;
552 const double grad_vos[nSpace],
553 double& mom_u_source,
554 double& mom_v_source,
555 double& mom_w_source)
559 mom_u_source +=
coeff * grad_vos[0];
560 mom_v_source +=
coeff * grad_vos[1];
561 mom_w_source +=
coeff * grad_vos[2];
566 const double mu_fr_last,
569 const double eps_rho,
579 const double grad_u[nSpace],
580 const double grad_v[nSpace],
581 const double grad_w[nSpace],
582 double mom_uu_diff_ten[nSpace],
583 double mom_uv_diff_ten[1],
584 double mom_uw_diff_ten[1],
585 double mom_vv_diff_ten[nSpace],
586 double mom_vu_diff_ten[1],
587 double mom_vw_diff_ten[1],
588 double mom_ww_diff_ten[nSpace],
589 double mom_wu_diff_ten[1],
590 double mom_wv_diff_ten[1])
593 grad_u[0], grad_u[1], grad_u[2],
594 grad_v[0], grad_v[1], grad_v[2],
595 grad_w[0], grad_w[1], grad_w[2]);
596 double mu_fr = LAG_MU_FR*mu_fr_last + (1.0 - LAG_MU_FR)*mu_fr_new;
598 mom_uu_diff_ten[0] += 2. * mu_fr * (2./3.);
599 mom_uu_diff_ten[1] += mu_fr;
600 mom_uu_diff_ten[2] += mu_fr;
602 mom_uv_diff_ten[0] += mu_fr;
603 mom_uw_diff_ten[0] += mu_fr;
605 mom_vv_diff_ten[0] += mu_fr;
606 mom_vv_diff_ten[1] += 2. * mu_fr * (2./3.) ;
607 mom_vv_diff_ten[2] += mu_fr;
609 mom_vu_diff_ten[0] += mu_fr;
610 mom_vw_diff_ten[0] += mu_fr;
612 mom_ww_diff_ten[0] += mu_fr;
613 mom_ww_diff_ten[1] += mu_fr;
614 mom_ww_diff_ten[2] += 2. * mu_fr * (2./3.) ;
616 mom_wu_diff_ten[0] += mu_fr;
617 mom_wv_diff_ten[0] += mu_fr;
624 const double &elementDiameter,
627 const double df[nSpace],
634 double h, oneByAbsdt, density, viscosity, nrm_df;
635 h = hFactor * elementDiameter;
639 for (
int I = 0; I < nSpace; I++)
641 nrm_df +=
df[I] *
df[I];
643 nrm_df = sqrt(nrm_df);
646 cfl = nrm_df / (fabs(h * density));
650 cfl = nrm_df / fabs(h );
652 oneByAbsdt = fabs(dmt);
653 tau_v = 1.0 / (4.0 * viscosity / (h * h) + 2.0 * nrm_df / h + oneByAbsdt);
654 tau_p = (4.0 * viscosity + 2.0 * nrm_df * h + oneByAbsdt * h * h) / pfac;
658 const double &Cd_sge,
659 const double G[nSpace * nSpace],
660 const double &G_dd_G,
663 const double Ai[nSpace],
671 for (
int I = 0; I < nSpace; I++)
672 for (
int J = 0; J < nSpace; J++)
673 v_d_Gv += Ai[I] * G[I * nSpace + J] * Ai[J];
674 tau_v = 1.0 / sqrt(Ct_sge * A0 * A0 + v_d_Gv + Cd_sge * Kij * Kij * G_dd_G + 1.0e-12);
675 tau_p = 1.0 / (pfac * tr_G * tau_v);
680 const double &pdeResidualP,
681 const double &pdeResidualU,
682 const double &pdeResidualV,
683 const double &pdeResidualW,
684 double &subgridErrorP,
685 double &subgridErrorU,
686 double &subgridErrorV,
687 double &subgridErrorW)
690 subgridErrorP = -tau_p * pdeResidualP;
692 subgridErrorU = -tau_v*pdeResidualU;
693 subgridErrorV = -tau_v*pdeResidualV;
694 subgridErrorW = -tau_v*pdeResidualW;
699 const double dpdeResidualP_du[nDOF_trial_element],
700 const double dpdeResidualP_dv[nDOF_trial_element],
701 const double dpdeResidualP_dw[nDOF_trial_element],
702 const double dpdeResidualU_dp[nDOF_trial_element],
703 const double dpdeResidualU_du[nDOF_trial_element],
704 const double dpdeResidualV_dp[nDOF_trial_element],
705 const double dpdeResidualV_dv[nDOF_trial_element],
706 const double dpdeResidualW_dp[nDOF_trial_element],
707 const double dpdeResidualW_dw[nDOF_trial_element],
708 double dsubgridErrorP_du[nDOF_trial_element],
709 double dsubgridErrorP_dv[nDOF_trial_element],
710 double dsubgridErrorP_dw[nDOF_trial_element],
711 double dsubgridErrorU_dp[nDOF_trial_element],
712 double dsubgridErrorU_du[nDOF_trial_element],
713 double dsubgridErrorV_dp[nDOF_trial_element],
714 double dsubgridErrorV_dv[nDOF_trial_element],
715 double dsubgridErrorW_dp[nDOF_trial_element],
716 double dsubgridErrorW_dw[nDOF_trial_element])
718 for (
int j = 0; j < nDOF_trial_element; j++)
721 dsubgridErrorP_du[j] = -tau_p*dpdeResidualP_du[j];
722 dsubgridErrorP_dv[j] = -tau_p*dpdeResidualP_dv[j];
723 dsubgridErrorP_dw[j] = -tau_p*dpdeResidualP_dw[j];
726 dsubgridErrorU_dp[j] = -tau_v*dpdeResidualU_dp[j];
727 dsubgridErrorU_du[j] = -tau_v*dpdeResidualU_du[j];
729 dsubgridErrorV_dp[j] = -tau_v*dpdeResidualV_dp[j];
730 dsubgridErrorV_dv[j] = -tau_v*dpdeResidualV_dv[j];
732 dsubgridErrorW_dp[j] = -tau_v*dpdeResidualW_dp[j];
733 dsubgridErrorW_dw[j] = -tau_v*dpdeResidualW_dw[j];
739 const int& isDOFBoundary_u,
740 const int& isDOFBoundary_v,
741 const int& isDOFBoundary_w,
742 const int& isFluxBoundary_p,
743 const int& isFluxBoundary_u,
744 const int& isFluxBoundary_v,
745 const int& isFluxBoundary_w,
746 const double& oneByRho,
747 const double& bc_oneByRho,
748 const double n[nSpace],
754 const double bc_f_mass[nSpace],
755 const double bc_f_umom[nSpace],
756 const double bc_f_vmom[nSpace],
757 const double bc_f_wmom[nSpace],
758 const double& bc_flux_mass,
759 const double& bc_flux_umom,
760 const double& bc_flux_vmom,
761 const double& bc_flux_wmom,
766 const double f_mass[nSpace],
767 const double f_umom[nSpace],
768 const double f_vmom[nSpace],
769 const double f_wmom[nSpace],
770 const double df_mass_du[nSpace],
771 const double df_mass_dv[nSpace],
772 const double df_mass_dw[nSpace],
773 const double df_umom_dp[nSpace],
774 const double df_umom_du[nSpace],
775 const double df_umom_dv[nSpace],
776 const double df_umom_dw[nSpace],
777 const double df_vmom_dp[nSpace],
778 const double df_vmom_du[nSpace],
779 const double df_vmom_dv[nSpace],
780 const double df_vmom_dw[nSpace],
781 const double df_wmom_dp[nSpace],
782 const double df_wmom_du[nSpace],
783 const double df_wmom_dv[nSpace],
784 const double df_wmom_dw[nSpace],
789 double* velocity_star,
792 double flowSpeedNormal;
797 flowSpeedNormal=(
n[0]*velocity_star[0] +
798 n[1]*velocity_star[1] +
799 n[2]*velocity_star[2]);
803 if (isDOFBoundary_u != 1)
805 flux_mass +=
n[0]*f_mass[0];
809 flux_mass +=
n[0]*f_mass[0];
810 if (flowSpeedNormal < 0.0)
812 flux_umom+=flowSpeedNormal*(bc_u -
u);
816 if (isDOFBoundary_v != 1)
818 flux_mass+=
n[1]*f_mass[1];
822 flux_mass+=
n[1]*f_mass[1];
823 if (flowSpeedNormal < 0.0)
825 flux_vmom+=flowSpeedNormal*(bc_v -
v);
829 if (isDOFBoundary_w != 1)
831 flux_mass+=
n[2]*f_mass[2];
835 flux_mass +=
n[2]*f_mass[2];
836 if (flowSpeedNormal < 0.0)
838 flux_wmom+=flowSpeedNormal*(bc_w -
w);
855 if (isFluxBoundary_u == 1)
857 flux_umom = bc_flux_umom;
858 velocity[0] = bc_flux_umom;
860 if (isFluxBoundary_v == 1)
862 flux_vmom = bc_flux_vmom;
863 velocity[1] = bc_flux_umom;
865 if (isFluxBoundary_w == 1)
867 flux_wmom = bc_flux_wmom;
868 velocity[2] = bc_flux_wmom;
874 const int& isDOFBoundary_u,
875 const int& isDOFBoundary_v,
876 const int& isDOFBoundary_w,
877 const int& isFluxBoundary_p,
878 const int& isFluxBoundary_u,
879 const int& isFluxBoundary_v,
880 const int& isFluxBoundary_w,
881 const double& oneByRho,
882 const double n[nSpace],
888 const double bc_f_mass[nSpace],
889 const double bc_f_umom[nSpace],
890 const double bc_f_vmom[nSpace],
891 const double bc_f_wmom[nSpace],
892 const double& bc_flux_mass,
893 const double& bc_flux_umom,
894 const double& bc_flux_vmom,
895 const double& bc_flux_wmom,
900 const double f_mass[nSpace],
901 const double f_umom[nSpace],
902 const double f_vmom[nSpace],
903 const double f_wmom[nSpace],
904 const double df_mass_du[nSpace],
905 const double df_mass_dv[nSpace],
906 const double df_mass_dw[nSpace],
907 const double df_umom_dp[nSpace],
908 const double df_umom_du[nSpace],
909 const double df_umom_dv[nSpace],
910 const double df_umom_dw[nSpace],
911 const double df_vmom_dp[nSpace],
912 const double df_vmom_du[nSpace],
913 const double df_vmom_dv[nSpace],
914 const double df_vmom_dw[nSpace],
915 const double df_wmom_dp[nSpace],
916 const double df_wmom_du[nSpace],
917 const double df_wmom_dv[nSpace],
918 const double df_wmom_dw[nSpace],
919 double& dflux_mass_du,
920 double& dflux_mass_dv,
921 double& dflux_mass_dw,
922 double& dflux_umom_dp,
923 double& dflux_umom_du,
924 double& dflux_umom_dv,
925 double& dflux_umom_dw,
926 double& dflux_vmom_dp,
927 double& dflux_vmom_du,
928 double& dflux_vmom_dv,
929 double& dflux_vmom_dw,
930 double& dflux_wmom_dp,
931 double& dflux_wmom_du,
932 double& dflux_wmom_dv,
933 double& dflux_wmom_dw,
934 double* velocity_star)
936 double flowSpeedNormal;
955 flowSpeedNormal=(
n[0]*velocity_star[0] +
956 n[1]*velocity_star[1] +
957 n[2]*velocity_star[2]);
958 if (isDOFBoundary_u != 1)
960 dflux_mass_du +=
n[0]*df_mass_du[0];
964 dflux_mass_du +=
n[0]*df_mass_du[0];
965 if (flowSpeedNormal < 0.0)
966 dflux_umom_du -= flowSpeedNormal;
968 if (isDOFBoundary_v != 1)
970 dflux_mass_dv +=
n[1]*df_mass_dv[1];
974 dflux_mass_dv +=
n[1]*df_mass_dv[1];
975 if (flowSpeedNormal < 0.0)
976 dflux_vmom_dv -= flowSpeedNormal;
978 if (isDOFBoundary_w != 1)
980 dflux_mass_dw+=
n[2]*df_mass_dw[2];
984 dflux_mass_dw +=
n[2]*df_mass_dw[2];
985 if (flowSpeedNormal < 0.0)
986 dflux_wmom_dw -= flowSpeedNormal;
1000 if (isFluxBoundary_u == 1)
1002 dflux_umom_dp = 0.0;
1003 dflux_umom_du = 0.0;
1004 dflux_umom_dv = 0.0;
1005 dflux_umom_dw = 0.0;
1007 if (isFluxBoundary_v == 1)
1009 dflux_vmom_dp = 0.0;
1010 dflux_vmom_du = 0.0;
1011 dflux_vmom_dv = 0.0;
1012 dflux_vmom_dw = 0.0;
1014 if (isFluxBoundary_w == 1)
1016 dflux_wmom_dp = 0.0;
1017 dflux_wmom_du = 0.0;
1018 dflux_wmom_dv = 0.0;
1019 dflux_wmom_dw = 0.0;
1028 const int& isDOFBoundary,
1029 const int& isFluxBoundary,
1030 const double n[nSpace],
1033 const double& bc_flux,
1035 const double grad_potential[nSpace],
1037 const double& penalty,
1040 double diffusiveVelocityComponent_I,penaltyFlux,max_a;
1041 if(isFluxBoundary == 1)
1045 else if(isDOFBoundary == 1)
1049 for(
int I=0;I<nSpace;I++)
1051 diffusiveVelocityComponent_I=0.0;
1052 for(
int m=rowptr[I];m<rowptr[I+1];m++)
1054 diffusiveVelocityComponent_I -= a[m]*grad_potential[colind[m]];
1055 max_a = fmax(max_a,a[m]);
1057 flux+= diffusiveVelocityComponent_I*
n[I];
1059 penaltyFlux = max_a*penalty*(
u-bc_u);
1060 flux += penaltyFlux;
1077 const int& isDOFBoundary,
1078 const int& isFluxBoundary,
1079 const double n[nSpace],
1082 const double grad_v[nSpace],
1083 const double& penalty)
1085 double dvel_I,tmp=0.0,max_a=0.0;
1086 if(isFluxBoundary==0 && isDOFBoundary==1)
1088 for(
int I=0;I<nSpace;I++)
1091 for(
int m=rowptr[I];m<rowptr[I+1];m++)
1093 dvel_I -= a[m]*grad_v[colind[m]];
1094 max_a = fmax(max_a,a[m]);
1098 tmp +=max_a*penalty*
v;
1107 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1108 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1109 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1110 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
1111 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
1112 double PSTAB = args.
scalar<
double>(
"PSTAB");
1113 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1114 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1115 xt::pyarray<double>& p_trial_ref = args.
array<
double>(
"p_trial_ref");
1116 xt::pyarray<double>& p_grad_trial_ref = args.
array<
double>(
"p_grad_trial_ref");
1117 xt::pyarray<double>& p_test_ref = args.
array<
double>(
"p_test_ref");
1118 xt::pyarray<double>& p_grad_test_ref = args.
array<
double>(
"p_grad_test_ref");
1119 xt::pyarray<double>& q_p = args.
array<
double>(
"q_p");
1120 xt::pyarray<double>& q_grad_p = args.
array<
double>(
"q_grad_p");
1121 xt::pyarray<double>& ebqe_p = args.
array<
double>(
"ebqe_p");
1122 xt::pyarray<double>& ebqe_grad_p = args.
array<
double>(
"ebqe_grad_p");
1123 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
1124 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
1125 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
1126 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
1127 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1128 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1129 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1130 xt::pyarray<double>& p_trial_trace_ref = args.
array<
double>(
"p_trial_trace_ref");
1131 xt::pyarray<double>& p_grad_trial_trace_ref = args.
array<
double>(
"p_grad_trial_trace_ref");
1132 xt::pyarray<double>& p_test_trace_ref = args.
array<
double>(
"p_test_trace_ref");
1133 xt::pyarray<double>& p_grad_test_trace_ref = args.
array<
double>(
"p_grad_test_trace_ref");
1134 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
1135 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
1136 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
1137 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
1138 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1139 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1140 double eb_adjoint_sigma = args.
scalar<
double>(
"eb_adjoint_sigma");
1141 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
1142 xt::pyarray<double>& nodeDiametersArray = args.
array<
double>(
"nodeDiametersArray");
1143 double hFactor = args.
scalar<
double>(
"hFactor");
1144 int nElements_global = args.
scalar<
int>(
"nElements_global");
1145 int nElementBoundaries_owned = args.
scalar<
int>(
"nElementBoundaries_owned");
1146 double useRBLES = args.
scalar<
double>(
"useRBLES");
1147 double useMetrics = args.
scalar<
double>(
"useMetrics");
1148 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
1149 double epsFact_rho = args.
scalar<
double>(
"epsFact_rho");
1150 double epsFact_mu = args.
scalar<
double>(
"epsFact_mu");
1151 double sigma = args.
scalar<
double>(
"sigma");
1156 double rho_s = args.
scalar<
double>(
"rho_s");
1157 double smagorinskyConstant = args.
scalar<
double>(
"smagorinskyConstant");
1158 int turbulenceClosureModel = args.
scalar<
int>(
"turbulenceClosureModel");
1159 double Ct_sge = args.
scalar<
double>(
"Ct_sge");
1160 double Cd_sge = args.
scalar<
double>(
"Cd_sge");
1161 double C_dc = args.
scalar<
double>(
"C_dc");
1162 double C_b = args.
scalar<
double>(
"C_b");
1163 const xt::pyarray<double>& eps_solid = args.
array<
double>(
"eps_solid");
1164 const xt::pyarray<double>& q_velocity_fluid = args.
array<
double>(
"q_velocity_fluid");
1165 const xt::pyarray<double>& q_velocityStar_fluid = args.
array<
double>(
"q_velocityStar_fluid");
1166 const xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
1167 const xt::pyarray<double>& q_dvos_dt = args.
array<
double>(
"q_dvos_dt");
1168 const xt::pyarray<double>& q_grad_vos = args.
array<
double>(
"q_grad_vos");
1169 const xt::pyarray<double>& q_dragAlpha = args.
array<
double>(
"q_dragAlpha");
1170 const xt::pyarray<double>& q_dragBeta = args.
array<
double>(
"q_dragBeta");
1171 const xt::pyarray<double>& q_mass_source = args.
array<
double>(
"q_mass_source");
1172 const xt::pyarray<double>& q_turb_var_0 = args.
array<
double>(
"q_turb_var_0");
1173 const xt::pyarray<double>& q_turb_var_1 = args.
array<
double>(
"q_turb_var_1");
1174 const xt::pyarray<double>& q_turb_var_grad_0 = args.
array<
double>(
"q_turb_var_grad_0");
1175 xt::pyarray<double>& q_eddy_viscosity = args.
array<
double>(
"q_eddy_viscosity");
1176 xt::pyarray<int>& p_l2g = args.
array<
int>(
"p_l2g");
1177 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
1178 xt::pyarray<double>& p_dof = args.
array<
double>(
"p_dof");
1179 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1180 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
1181 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
1182 xt::pyarray<double>& g = args.
array<
double>(
"g");
1183 const double useVF = args.
scalar<
double>(
"useVF");
1184 xt::pyarray<double>& vf = args.
array<
double>(
"vf");
1185 xt::pyarray<double>&
phi = args.
array<
double>(
"phi");
1186 xt::pyarray<double>& normal_phi = args.
array<
double>(
"normal_phi");
1187 xt::pyarray<double>& kappa_phi = args.
array<
double>(
"kappa_phi");
1188 xt::pyarray<double>& q_mom_u_acc = args.
array<
double>(
"q_mom_u_acc");
1189 xt::pyarray<double>& q_mom_v_acc = args.
array<
double>(
"q_mom_v_acc");
1190 xt::pyarray<double>& q_mom_w_acc = args.
array<
double>(
"q_mom_w_acc");
1191 xt::pyarray<double>& q_mass_adv = args.
array<
double>(
"q_mass_adv");
1192 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
1193 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
1194 xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.
array<
double>(
"q_mom_w_acc_beta_bdf");
1195 xt::pyarray<double>& q_dV = args.
array<
double>(
"q_dV");
1196 xt::pyarray<double>& q_dV_last = args.
array<
double>(
"q_dV_last");
1197 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
1198 xt::pyarray<double>& ebqe_velocity_star = args.
array<
double>(
"ebqe_velocity_star");
1199 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
1200 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
1201 xt::pyarray<double>& q_numDiff_v = args.
array<
double>(
"q_numDiff_v");
1202 xt::pyarray<double>& q_numDiff_w = args.
array<
double>(
"q_numDiff_w");
1203 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
1204 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
1205 xt::pyarray<double>& q_numDiff_w_last = args.
array<
double>(
"q_numDiff_w_last");
1206 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
1207 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
1208 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
1209 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
1210 xt::pyarray<int>& sdInfo_u_w_rowptr = args.
array<
int>(
"sdInfo_u_w_rowptr");
1211 xt::pyarray<int>& sdInfo_u_w_colind = args.
array<
int>(
"sdInfo_u_w_colind");
1212 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
1213 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
1214 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
1215 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
1216 xt::pyarray<int>& sdInfo_v_w_rowptr = args.
array<
int>(
"sdInfo_v_w_rowptr");
1217 xt::pyarray<int>& sdInfo_v_w_colind = args.
array<
int>(
"sdInfo_v_w_colind");
1218 xt::pyarray<int>& sdInfo_w_w_rowptr = args.
array<
int>(
"sdInfo_w_w_rowptr");
1219 xt::pyarray<int>& sdInfo_w_w_colind = args.
array<
int>(
"sdInfo_w_w_colind");
1220 xt::pyarray<int>& sdInfo_w_u_rowptr = args.
array<
int>(
"sdInfo_w_u_rowptr");
1221 xt::pyarray<int>& sdInfo_w_u_colind = args.
array<
int>(
"sdInfo_w_u_colind");
1222 xt::pyarray<int>& sdInfo_w_v_rowptr = args.
array<
int>(
"sdInfo_w_v_rowptr");
1223 xt::pyarray<int>& sdInfo_w_v_colind = args.
array<
int>(
"sdInfo_w_v_colind");
1224 int offset_p = args.
scalar<
int>(
"offset_p");
1225 int offset_u = args.
scalar<
int>(
"offset_u");
1226 int offset_v = args.
scalar<
int>(
"offset_v");
1227 int offset_w = args.
scalar<
int>(
"offset_w");
1228 int stride_p = args.
scalar<
int>(
"stride_p");
1229 int stride_u = args.
scalar<
int>(
"stride_u");
1230 int stride_v = args.
scalar<
int>(
"stride_v");
1231 int stride_w = args.
scalar<
int>(
"stride_w");
1232 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
1233 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1234 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1235 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1236 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1237 xt::pyarray<double>& ebqe_vf_ext = args.
array<
double>(
"ebqe_vf_ext");
1238 xt::pyarray<double>& bc_ebqe_vf_ext = args.
array<
double>(
"bc_ebqe_vf_ext");
1239 xt::pyarray<double>& ebqe_phi_ext = args.
array<
double>(
"ebqe_phi_ext");
1240 xt::pyarray<double>& bc_ebqe_phi_ext = args.
array<
double>(
"bc_ebqe_phi_ext");
1241 xt::pyarray<double>& ebqe_normal_phi_ext = args.
array<
double>(
"ebqe_normal_phi_ext");
1242 xt::pyarray<double>& ebqe_kappa_phi_ext = args.
array<
double>(
"ebqe_kappa_phi_ext");
1243 const xt::pyarray<double>& ebqe_vos_ext = args.
array<
double>(
"ebqe_vos_ext");
1244 const xt::pyarray<double>& ebqe_turb_var_0 = args.
array<
double>(
"ebqe_turb_var_0");
1245 const xt::pyarray<double>& ebqe_turb_var_1 = args.
array<
double>(
"ebqe_turb_var_1");
1246 xt::pyarray<int>& isDOFBoundary_p = args.
array<
int>(
"isDOFBoundary_p");
1247 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1248 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
1249 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
1250 xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.
array<
int>(
"isAdvectiveFluxBoundary_p");
1251 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
1252 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
1253 xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.
array<
int>(
"isAdvectiveFluxBoundary_w");
1254 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
1255 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
1256 xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.
array<
int>(
"isDiffusiveFluxBoundary_w");
1257 xt::pyarray<double>& ebqe_bc_p_ext = args.
array<
double>(
"ebqe_bc_p_ext");
1258 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
1259 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
1260 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
1261 xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_w_adv_ext");
1262 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
1263 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
1264 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
1265 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
1266 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
1267 xt::pyarray<double>& ebqe_bc_w_ext = args.
array<
double>(
"ebqe_bc_w_ext");
1268 xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.
array<
double>(
"ebqe_bc_flux_w_diff_ext");
1269 xt::pyarray<double>& q_x = args.
array<
double>(
"q_x");
1270 xt::pyarray<double>& q_velocity = args.
array<
double>(
"q_velocity");
1271 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
1272 xt::pyarray<double>& flux = args.
array<
double>(
"flux");
1273 xt::pyarray<double>& elementResidual_p_save = args.
array<
double>(
"elementResidual_p_save");
1274 xt::pyarray<int>& elementFlags = args.
array<
int>(
"elementFlags");
1275 xt::pyarray<int>& boundaryFlags = args.
array<
int>(
"boundaryFlags");
1276 xt::pyarray<double>& barycenters = args.
array<
double>(
"barycenters");
1277 xt::pyarray<double>& wettedAreas = args.
array<
double>(
"wettedAreas");
1278 xt::pyarray<double>& netForces_p = args.
array<
double>(
"netForces_p");
1279 xt::pyarray<double>& netForces_v = args.
array<
double>(
"netForces_v");
1280 xt::pyarray<double>& netMoments = args.
array<
double>(
"netMoments");
1281 xt::pyarray<double>& ncDrag = args.
array<
double>(
"ncDrag");
1282 double LAG_MU_FR = args.
scalar<
double>(
"LAG_MU_FR");
1283 xt::pyarray<double>& q_mu_fr_last = args.
array<
double>(
"q_mu_fr_last");
1284 xt::pyarray<double>& q_mu_fr = args.
array<
double>(
"q_mu_fr");
1288 for(
int eN=0;eN<nElements_global;eN++)
1291 register double elementResidual_u[nDOF_test_element],
1292 elementResidual_v[nDOF_test_element],
1293 elementResidual_w[nDOF_test_element],
1294 mom_u_source_i[nDOF_test_element],
1295 mom_v_source_i[nDOF_test_element],
1296 mom_w_source_i[nDOF_test_element],
1298 double mesh_volume_conservation_element=0.0;
1299 for (
int i=0;i<nDOF_test_element;i++)
1301 int eN_i = eN*nDOF_test_element+i;
1302 elementResidual_p_save.data()[eN_i]=0.0;
1303 elementResidual_u[i]=0.0;
1304 elementResidual_v[i]=0.0;
1305 elementResidual_w[i]=0.0;
1306 mom_u_source_i[i]=0.0;
1307 mom_v_source_i[i]=0.0;
1308 mom_w_source_i[i]=0.0;
1313 for(
int k=0;k<nQuadraturePoints_element;k++)
1316 register int eN_k = eN*nQuadraturePoints_element+k,
1317 eN_k_nSpace = eN_k*nSpace,
1319 eN_nDOF_trial_element = eN*nDOF_trial_element;
1320 register double p=0.0,
u=0.0,
v=0.0,
w=0.0,
1321 grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],grad_vos[nSpace],
1329 dmass_adv_u[nSpace],
1330 dmass_adv_v[nSpace],
1331 dmass_adv_w[nSpace],
1333 dmom_u_adv_u[nSpace],
1334 dmom_u_adv_v[nSpace],
1335 dmom_u_adv_w[nSpace],
1337 dmom_v_adv_u[nSpace],
1338 dmom_v_adv_v[nSpace],
1339 dmom_v_adv_w[nSpace],
1341 dmom_w_adv_u[nSpace],
1342 dmom_w_adv_v[nSpace],
1343 dmom_w_adv_w[nSpace],
1344 mom_uu_diff_ten[nSpace],
1345 mom_vv_diff_ten[nSpace],
1346 mom_ww_diff_ten[nSpace],
1357 dmom_u_ham_grad_p[nSpace],
1358 dmom_u_ham_grad_u[nSpace],
1360 dmom_v_ham_grad_p[nSpace],
1361 dmom_v_ham_grad_v[nSpace],
1363 dmom_w_ham_grad_p[nSpace],
1364 dmom_w_ham_grad_w[nSpace],
1375 Lstar_u_u[nDOF_test_element],
1376 Lstar_v_v[nDOF_test_element],
1377 Lstar_w_w[nDOF_test_element],
1378 Lstar_p_w[nDOF_test_element],
1383 tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
1384 tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
1387 jacInv[nSpace*nSpace],
1388 vel_grad_trial[nDOF_trial_element*nSpace],
1389 vel_test_dV[nDOF_trial_element],
1390 vel_grad_test_dV[nDOF_test_element*nSpace],
1396 dmom_u_source[nSpace],
1397 dmom_v_source[nSpace],
1398 dmom_w_source[nSpace],
1400 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv,h_phi, dmom_adv_star[nSpace],dmom_adv_sge[nSpace];
1402 ck.calculateMapping_element(eN,
1406 mesh_trial_ref.data(),
1407 mesh_grad_trial_ref.data(),
1412 ck.calculateH_element(eN,
1414 nodeDiametersArray.data(),
1416 mesh_trial_ref.data(),
1418 ck.calculateMappingVelocity_element(eN,
1420 mesh_velocity_dof.data(),
1422 mesh_trial_ref.data(),
1427 dV = fabs(jacDet)*dV_ref.data()[k];
1428 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1431 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
1432 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
1436 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
1439 p = q_p.data()[eN_k];
1440 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
1441 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
1442 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
w);
1445 for (
int I=0;I<nSpace;I++)
1446 grad_p[I] = q_grad_p.data()[eN_k_nSpace + I];
1447 for (
int I=0;I<nSpace;I++)
1448 grad_vos[I] = q_grad_vos.data()[eN_k_nSpace + I];
1449 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
1450 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
1451 ck.gradFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_w);
1453 vos = q_vos.data()[eN_k];
1455 for (
int j=0;j<nDOF_trial_element;j++)
1458 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
1459 for (
int I=0;I<nSpace;I++)
1462 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
1466 double div_mesh_velocity=0.0;
1467 int NDOF_MESH_TRIAL_ELEMENT=4;
1468 for (
int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
1470 int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
1471 div_mesh_velocity +=
1472 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+0]*vel_grad_trial[j*nSpace+0] +
1473 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+1]*vel_grad_trial[j*nSpace+1] +
1474 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+2]*vel_grad_trial[j*nSpace+2];
1476 mesh_volume_conservation_element += (alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity)*dV;
1477 div_mesh_velocity =
DM3*div_mesh_velocity + (1.0-
DM3)*alphaBDF*(dV-q_dV_last.data()[eN_k])/dV;
1481 q_x.data()[eN_k_3d+0]=x;
1482 q_x.data()[eN_k_3d+1]=y;
1483 q_x.data()[eN_k_3d+2]=
z;
1495 elementDiameter.data()[eN],
1496 smagorinskyConstant,
1497 turbulenceClosureModel,
1502 &normal_phi.data()[eN_k_nSpace],
1503 kappa_phi.data()[eN_k],
1515 q_velocity_sge.data()[eN_k_nSpace+0],
1516 q_velocity_sge.data()[eN_k_nSpace+1],
1517 q_velocity_sge.data()[eN_k_nSpace+2],
1518 q_eddy_viscosity.data()[eN_k],
1563 mass_source = q_mass_source.data()[eN_k];
1564 for (
int I=0;I<nSpace;I++)
1566 dmom_u_source[I] = 0.0;
1567 dmom_v_source[I] = 0.0;
1568 dmom_w_source[I] = 0.0;
1575 q_dragAlpha.data()[eN_k],
1576 q_dragBeta.data()[eN_k],
1583 q_eddy_viscosity.data()[eN_k],
1590 q_velocity_sge.data()[eN_k_nSpace+0],
1591 q_velocity_sge.data()[eN_k_nSpace+1],
1592 q_velocity_sge.data()[eN_k_nSpace+2],
1593 eps_solid.data()[elementFlags.data()[eN]],
1595 q_velocity_fluid.data()[eN_k_nSpace+0],
1596 q_velocity_fluid.data()[eN_k_nSpace+1],
1597 q_velocity_fluid.data()[eN_k_nSpace+2],
1598 q_velocityStar_fluid.data()[eN_k_nSpace+0],
1599 q_velocityStar_fluid.data()[eN_k_nSpace+1],
1600 q_velocityStar_fluid.data()[eN_k_nSpace+2],
1607 q_grad_vos.data()[eN_k_nSpace+0],
1608 q_grad_vos.data()[eN_k_nSpace+1],
1609 q_grad_vos.data()[eN_k_nSpace+2]);
1617 q_mu_fr_last.data()[eN_k],
1618 q_mu_fr.data()[eN_k],
1646 q_mom_u_acc.data()[eN_k] = mom_u_acc;
1647 q_mom_v_acc.data()[eN_k] = mom_v_acc;
1648 q_mom_w_acc.data()[eN_k] = mom_w_acc;
1650 q_mass_adv.data()[eN_k_nSpace+0] =
u;
1651 q_mass_adv.data()[eN_k_nSpace+1] =
v;
1652 q_mass_adv.data()[eN_k_nSpace+2] =
w;
1656 mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*
xt;
1657 mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
1658 mom_u_adv[2] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*zt;
1659 dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*
xt;
1660 dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
1661 dmom_u_adv_u[2] -= MOVING_DOMAIN*dmom_u_acc_u*zt;
1663 mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*
xt;
1664 mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
1665 mom_v_adv[2] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*zt;
1666 dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*
xt;
1667 dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
1668 dmom_v_adv_v[2] -= MOVING_DOMAIN*dmom_v_acc_v*zt;
1670 mom_w_adv[0] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*
xt;
1671 mom_w_adv[1] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*yt;
1672 mom_w_adv[2] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*zt;
1673 dmom_w_adv_w[0] -= MOVING_DOMAIN*dmom_w_acc_w*
xt;
1674 dmom_w_adv_w[1] -= MOVING_DOMAIN*dmom_w_acc_w*yt;
1675 dmom_w_adv_w[2] -= MOVING_DOMAIN*dmom_w_acc_w*zt;
1679 if (q_dV_last.data()[eN_k] <= -100)
1680 q_dV_last.data()[eN_k] = dV;
1681 q_dV.data()[eN_k] = dV;
1683 q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
1689 q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
1695 q_mom_w_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
1705 ck.Mass_strong(q_dvos_dt.data()[eN_k]) +
1706 ck.Advection_strong(dmass_adv_u,grad_u) +
1707 ck.Advection_strong(dmass_adv_v,grad_v) +
1708 ck.Advection_strong(dmass_adv_w,grad_w) +
1709 DM2*MOVING_DOMAIN*
ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) +
1711 ck.Reaction_strong(mass_source);
1714 dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt);
1715 dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
1716 dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt);
1719 ck.Mass_strong(mom_u_acc_t) +
1720 ck.Advection_strong(dmom_adv_sge,grad_u) +
1721 ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
1722 ck.Reaction_strong(mom_u_source) -
1723 ck.Reaction_strong(
u*div_mesh_velocity);
1726 ck.Mass_strong(mom_v_acc_t) +
1727 ck.Advection_strong(dmom_adv_sge,grad_v) +
1728 ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
1729 ck.Reaction_strong(mom_v_source) -
1730 ck.Reaction_strong(
v*div_mesh_velocity);
1732 pdeResidual_w =
ck.Mass_strong(mom_w_acc_t) +
1733 ck.Advection_strong(dmom_adv_sge,grad_w) +
1734 ck.Hamiltonian_strong(dmom_w_ham_grad_p,grad_p) +
1735 ck.Reaction_strong(mom_w_source) -
1736 ck.Reaction_strong(
w*div_mesh_velocity);
1740 double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
1742 elementDiameter.data()[eN],
1747 dmom_u_ham_grad_p[0],
1750 q_cfl.data()[eN_k]);
1757 dmom_u_ham_grad_p[0],
1760 q_cfl.data()[eN_k]);
1762 tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
1763 tau_p = PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
1776 dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt + useRBLES*subgridError_u);
1777 dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
1778 dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w);
1780 mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+0]);
1781 mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+0]);
1782 mom_u_adv[2] += dmom_u_acc_u*(useRBLES*subgridError_w*q_velocity_sge.data()[eN_k_nSpace+0]);
1785 for (
int i=0;i<nDOF_test_element;i++)
1787 register int i_nSpace = i*nSpace;
1792 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
1793 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
1794 Lstar_w_w[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
1795 Lstar_p_w[i]=
ck.Hamiltonian_adjoint(dmom_w_ham_grad_p,&vel_grad_test_dV[i_nSpace]);
1798 Lstar_u_u[i]+=
ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
1799 Lstar_v_v[i]+=
ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
1800 Lstar_w_w[i]+=
ck.Reaction_adjoint(dmom_w_source[2],vel_test_dV[i]);
1804 norm_Rv = sqrt(pdeResidual_u*pdeResidual_u + pdeResidual_v*pdeResidual_v + pdeResidual_w*pdeResidual_w);
1805 q_numDiff_u.data()[eN_k] = C_dc*norm_Rv*(useMetrics/sqrt(G_dd_G+1.0e-12) +
1806 (1.0-useMetrics)*hFactor*hFactor*elementDiameter.data()[eN]*elementDiameter.data()[eN]);
1807 q_numDiff_v.data()[eN_k] = q_numDiff_u.data()[eN_k];
1808 q_numDiff_w.data()[eN_k] = q_numDiff_u.data()[eN_k];
1812 q_velocity.data()[eN_k_nSpace+0]=
u;
1813 q_velocity.data()[eN_k_nSpace+1]=
v;
1814 q_velocity.data()[eN_k_nSpace+2]=
w;
1815 for(
int i=0;i<nDOF_test_element;i++)
1817 register int i_nSpace=i*nSpace;
1835 elementResidual_u[i] +=
1836 ck.Mass_weak(mom_u_acc_t,vel_test_dV[i]) +
1837 ck.Advection_weak(mom_u_adv,&vel_grad_test_dV[i_nSpace]) +
1838 ck.Diffusion_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_uu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
1839 ck.Diffusion_weak(sdInfo_u_v_rowptr.data(),sdInfo_u_v_colind.data(),mom_uv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
1840 ck.Diffusion_weak(sdInfo_u_w_rowptr.data(),sdInfo_u_w_colind.data(),mom_uw_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) +
1841 ck.Reaction_weak(mom_u_source,vel_test_dV[i]) +
1842 ck.Hamiltonian_weak(mom_u_ham,vel_test_dV[i]) +
1844 ck.SubgridError(subgridError_u,Lstar_u_u[i]) +
1845 ck.NumericalDiffusion(q_numDiff_u_last.data()[eN_k],grad_u,&vel_grad_test_dV[i_nSpace]);
1846 mom_u_source_i[i] +=
ck.Reaction_weak(mom_u_source,vel_test_dV[i]);
1848 elementResidual_v[i] +=
1849 ck.Mass_weak(mom_v_acc_t,vel_test_dV[i]) +
1850 ck.Advection_weak(mom_v_adv,&vel_grad_test_dV[i_nSpace]) +
1851 ck.Diffusion_weak(sdInfo_v_u_rowptr.data(),sdInfo_v_u_colind.data(),mom_vu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
1852 ck.Diffusion_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_vv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
1853 ck.Diffusion_weak(sdInfo_v_w_rowptr.data(),sdInfo_v_w_colind.data(),mom_vw_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) +
1854 ck.Reaction_weak(mom_v_source,vel_test_dV[i]) +
1855 ck.Hamiltonian_weak(mom_v_ham,vel_test_dV[i]) +
1857 ck.SubgridError(subgridError_v,Lstar_v_v[i]) +
1858 ck.NumericalDiffusion(q_numDiff_v_last.data()[eN_k],grad_v,&vel_grad_test_dV[i_nSpace]);
1859 mom_v_source_i[i] +=
ck.Reaction_weak(mom_v_source,vel_test_dV[i]);
1861 elementResidual_w[i] +=
1862 ck.Mass_weak(mom_w_acc_t,vel_test_dV[i]) +
1863 ck.Advection_weak(mom_w_adv,&vel_grad_test_dV[i_nSpace]) +
1864 ck.Diffusion_weak(sdInfo_w_u_rowptr.data(),sdInfo_w_u_colind.data(),mom_wu_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
1865 ck.Diffusion_weak(sdInfo_w_v_rowptr.data(),sdInfo_w_v_colind.data(),mom_wv_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
1866 ck.Diffusion_weak(sdInfo_w_w_rowptr.data(),sdInfo_w_w_colind.data(),mom_ww_diff_ten,grad_w,&vel_grad_test_dV[i_nSpace]) +
1867 ck.Reaction_weak(mom_w_source,vel_test_dV[i]) +
1868 ck.Hamiltonian_weak(mom_w_ham,vel_test_dV[i]) +
1869 ck.SubgridError(subgridError_p,Lstar_p_w[i]) +
1870 ck.SubgridError(subgridError_w,Lstar_w_w[i]) +
1871 ck.NumericalDiffusion(q_numDiff_w_last.data()[eN_k],grad_w,&vel_grad_test_dV[i_nSpace]);
1872 mom_w_source_i[i] +=
ck.Reaction_weak(mom_w_source,vel_test_dV[i]);
1878 for(
int i=0;i<nDOF_test_element;i++)
1880 register int eN_i=eN*nDOF_test_element+i;
1885 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
1886 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
1887 globalResidual.data()[offset_w+stride_w*vel_l2g.data()[eN_i]]+=elementResidual_w[i];
1888 ncDrag.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=mom_u_source_i[i];
1889 ncDrag.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=mom_v_source_i[i];
1890 ncDrag.data()[offset_w+stride_w*vel_l2g.data()[eN_i]]+=mom_w_source_i[i];
1903 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1905 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
1906 eN = elementBoundaryElementsArray.data()[ebN*2+0],
1907 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
1908 eN_nDOF_trial_element = eN*nDOF_trial_element;
1909 register double elementResidual_u[nDOF_test_element],
1910 elementResidual_v[nDOF_test_element],
1911 elementResidual_w[nDOF_test_element],
1913 for (
int i=0;i<nDOF_test_element;i++)
1915 elementResidual_u[i]=0.0;
1916 elementResidual_v[i]=0.0;
1917 elementResidual_w[i]=0.0;
1919 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1921 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1922 ebNE_kb_nSpace = ebNE_kb*nSpace,
1923 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1924 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1925 register double p_ext=0.0,
1934 dmom_u_acc_u_ext=0.0,
1936 dmom_v_acc_v_ext=0.0,
1938 dmom_w_acc_w_ext=0.0,
1939 mass_adv_ext[nSpace],
1940 dmass_adv_u_ext[nSpace],
1941 dmass_adv_v_ext[nSpace],
1942 dmass_adv_w_ext[nSpace],
1943 mom_u_adv_ext[nSpace],
1944 dmom_u_adv_u_ext[nSpace],
1945 dmom_u_adv_v_ext[nSpace],
1946 dmom_u_adv_w_ext[nSpace],
1947 mom_v_adv_ext[nSpace],
1948 dmom_v_adv_u_ext[nSpace],
1949 dmom_v_adv_v_ext[nSpace],
1950 dmom_v_adv_w_ext[nSpace],
1951 mom_w_adv_ext[nSpace],
1952 dmom_w_adv_u_ext[nSpace],
1953 dmom_w_adv_v_ext[nSpace],
1954 dmom_w_adv_w_ext[nSpace],
1955 mom_uu_diff_ten_ext[nSpace],
1956 mom_vv_diff_ten_ext[nSpace],
1957 mom_ww_diff_ten_ext[nSpace],
1958 mom_uv_diff_ten_ext[1],
1959 mom_uw_diff_ten_ext[1],
1960 mom_vu_diff_ten_ext[1],
1961 mom_vw_diff_ten_ext[1],
1962 mom_wu_diff_ten_ext[1],
1963 mom_wv_diff_ten_ext[1],
1964 mom_u_source_ext=0.0,
1965 mom_v_source_ext=0.0,
1966 mom_w_source_ext=0.0,
1968 dmom_u_ham_grad_p_ext[nSpace],
1969 dmom_u_ham_grad_u_ext[nSpace],
1971 dmom_v_ham_grad_p_ext[nSpace],
1972 dmom_v_ham_grad_v_ext[nSpace],
1974 dmom_w_ham_grad_p_ext[nSpace],
1975 dmom_w_ham_grad_w_ext[nSpace],
1976 dmom_u_adv_p_ext[nSpace],
1977 dmom_v_adv_p_ext[nSpace],
1978 dmom_w_adv_p_ext[nSpace],
1980 flux_mom_u_adv_ext=0.0,
1981 flux_mom_v_adv_ext=0.0,
1982 flux_mom_w_adv_ext=0.0,
1983 flux_mom_uu_diff_ext=0.0,
1984 flux_mom_uv_diff_ext=0.0,
1985 flux_mom_uw_diff_ext=0.0,
1986 flux_mom_vu_diff_ext=0.0,
1987 flux_mom_vv_diff_ext=0.0,
1988 flux_mom_vw_diff_ext=0.0,
1989 flux_mom_wu_diff_ext=0.0,
1990 flux_mom_wv_diff_ext=0.0,
1991 flux_mom_ww_diff_ext=0.0,
1996 bc_mom_u_acc_ext=0.0,
1997 bc_dmom_u_acc_u_ext=0.0,
1998 bc_mom_v_acc_ext=0.0,
1999 bc_dmom_v_acc_v_ext=0.0,
2000 bc_mom_w_acc_ext=0.0,
2001 bc_dmom_w_acc_w_ext=0.0,
2002 bc_mass_adv_ext[nSpace],
2003 bc_dmass_adv_u_ext[nSpace],
2004 bc_dmass_adv_v_ext[nSpace],
2005 bc_dmass_adv_w_ext[nSpace],
2006 bc_mom_u_adv_ext[nSpace],
2007 bc_dmom_u_adv_u_ext[nSpace],
2008 bc_dmom_u_adv_v_ext[nSpace],
2009 bc_dmom_u_adv_w_ext[nSpace],
2010 bc_mom_v_adv_ext[nSpace],
2011 bc_dmom_v_adv_u_ext[nSpace],
2012 bc_dmom_v_adv_v_ext[nSpace],
2013 bc_dmom_v_adv_w_ext[nSpace],
2014 bc_mom_w_adv_ext[nSpace],
2015 bc_dmom_w_adv_u_ext[nSpace],
2016 bc_dmom_w_adv_v_ext[nSpace],
2017 bc_dmom_w_adv_w_ext[nSpace],
2018 bc_mom_uu_diff_ten_ext[nSpace],
2019 bc_mom_vv_diff_ten_ext[nSpace],
2020 bc_mom_ww_diff_ten_ext[nSpace],
2021 bc_mom_uv_diff_ten_ext[1],
2022 bc_mom_uw_diff_ten_ext[1],
2023 bc_mom_vu_diff_ten_ext[1],
2024 bc_mom_vw_diff_ten_ext[1],
2025 bc_mom_wu_diff_ten_ext[1],
2026 bc_mom_wv_diff_ten_ext[1],
2027 bc_mom_u_source_ext=0.0,
2028 bc_mom_v_source_ext=0.0,
2029 bc_mom_w_source_ext=0.0,
2030 bc_mom_u_ham_ext=0.0,
2031 bc_dmom_u_ham_grad_p_ext[nSpace],
2032 bc_dmom_u_ham_grad_u_ext[nSpace],
2033 bc_mom_v_ham_ext=0.0,
2034 bc_dmom_v_ham_grad_p_ext[nSpace],
2035 bc_dmom_v_ham_grad_v_ext[nSpace],
2036 bc_mom_w_ham_ext=0.0,
2037 bc_dmom_w_ham_grad_p_ext[nSpace],
2038 bc_dmom_w_ham_grad_w_ext[nSpace],
2039 jac_ext[nSpace*nSpace],
2041 jacInv_ext[nSpace*nSpace],
2042 boundaryJac[nSpace*(nSpace-1)],
2043 metricTensor[(nSpace-1)*(nSpace-1)],
2044 metricTensorDetSqrt,
2045 dS,vel_test_dS[nDOF_test_element],
2046 vel_grad_trial_trace[nDOF_trial_element*nSpace],
2047 vel_grad_test_dS[nDOF_trial_element*nSpace],
2048 normal[3],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
2052 G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty,
2053 force_x,force_y,force_z,force_p_x,force_p_y,force_p_z,force_v_x,force_v_y,force_v_z,r_x,r_y,r_z;
2055 ck.calculateMapping_elementBoundary(eN,
2061 mesh_trial_trace_ref.data(),
2062 mesh_grad_trial_trace_ref.data(),
2063 boundaryJac_ref.data(),
2069 metricTensorDetSqrt,
2073 ck.calculateMappingVelocity_elementBoundary(eN,
2077 mesh_velocity_dof.data(),
2079 mesh_trial_trace_ref.data(),
2080 xt_ext,yt_ext,zt_ext,
2092 dS = metricTensorDetSqrt*dS_ref.data()[kb];
2095 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
2096 ck.calculateGScale(G,&ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],h_phi);
2098 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
2099 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
2104 ck.gradTrialFromRef(&vel_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
2108 p_ext = ebqe_p.data()[ebNE_kb];
2109 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
2110 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],v_ext);
2111 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],w_ext);
2113 for (
int I=0;I<nSpace;I++)
2114 grad_p_ext[I] = ebqe_grad_p.data()[ebNE_kb_nSpace + I];
2115 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
2116 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
2117 ck.gradFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_w_ext);
2119 for (
int j=0;j<nDOF_trial_element;j++)
2122 vel_test_dS[j] = vel_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
2123 for (
int I=0;I<nSpace;I++)
2124 vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;
2126 bc_p_ext = isDOFBoundary_p.data()[ebNE_kb]*ebqe_bc_p_ext.data()[ebNE_kb]+(1-isDOFBoundary_p.data()[ebNE_kb])*p_ext;
2129 bc_u_ext = isDOFBoundary_u.data()[ebNE_kb]*(ebqe_bc_u_ext.data()[ebNE_kb] + MOVING_DOMAIN*xt_ext) + (1-isDOFBoundary_u.data()[ebNE_kb])*u_ext;
2130 bc_v_ext = isDOFBoundary_v.data()[ebNE_kb]*(ebqe_bc_v_ext.data()[ebNE_kb] + MOVING_DOMAIN*yt_ext) + (1-isDOFBoundary_v.data()[ebNE_kb])*v_ext;
2131 bc_w_ext = isDOFBoundary_w.data()[ebNE_kb]*(ebqe_bc_w_ext.data()[ebNE_kb] + MOVING_DOMAIN*zt_ext) + (1-isDOFBoundary_w.data()[ebNE_kb])*w_ext;
2133 vos_ext = ebqe_vos_ext.data()[ebNE_kb];
2138 double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.);
2147 elementDiameter.data()[eN],
2148 smagorinskyConstant,
2149 turbulenceClosureModel,
2152 ebqe_vf_ext.data()[ebNE_kb],
2153 ebqe_phi_ext.data()[ebNE_kb],
2154 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
2155 ebqe_kappa_phi_ext.data()[ebNE_kb],
2167 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
2168 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2169 ebqe_velocity_star.data()[ebNE_kb_nSpace+2],
2193 mom_uu_diff_ten_ext,
2194 mom_vv_diff_ten_ext,
2195 mom_ww_diff_ten_ext,
2196 mom_uv_diff_ten_ext,
2197 mom_uw_diff_ten_ext,
2198 mom_vu_diff_ten_ext,
2199 mom_vw_diff_ten_ext,
2200 mom_wu_diff_ten_ext,
2201 mom_wv_diff_ten_ext,
2206 dmom_u_ham_grad_p_ext,
2207 dmom_u_ham_grad_u_ext,
2209 dmom_v_ham_grad_p_ext,
2210 dmom_v_ham_grad_v_ext,
2212 dmom_w_ham_grad_p_ext,
2213 dmom_w_ham_grad_w_ext);
2222 elementDiameter.data()[eN],
2223 smagorinskyConstant,
2224 turbulenceClosureModel,
2227 bc_ebqe_vf_ext.data()[ebNE_kb],
2228 bc_ebqe_phi_ext.data()[ebNE_kb],
2229 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
2230 ebqe_kappa_phi_ext.data()[ebNE_kb],
2242 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
2243 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2244 ebqe_velocity_star.data()[ebNE_kb_nSpace+2],
2245 bc_eddy_viscosity_ext,
2247 bc_dmom_u_acc_u_ext,
2249 bc_dmom_v_acc_v_ext,
2251 bc_dmom_w_acc_w_ext,
2257 bc_dmom_u_adv_u_ext,
2258 bc_dmom_u_adv_v_ext,
2259 bc_dmom_u_adv_w_ext,
2261 bc_dmom_v_adv_u_ext,
2262 bc_dmom_v_adv_v_ext,
2263 bc_dmom_v_adv_w_ext,
2265 bc_dmom_w_adv_u_ext,
2266 bc_dmom_w_adv_v_ext,
2267 bc_dmom_w_adv_w_ext,
2268 bc_mom_uu_diff_ten_ext,
2269 bc_mom_vv_diff_ten_ext,
2270 bc_mom_ww_diff_ten_ext,
2271 bc_mom_uv_diff_ten_ext,
2272 bc_mom_uw_diff_ten_ext,
2273 bc_mom_vu_diff_ten_ext,
2274 bc_mom_vw_diff_ten_ext,
2275 bc_mom_wu_diff_ten_ext,
2276 bc_mom_wv_diff_ten_ext,
2277 bc_mom_u_source_ext,
2278 bc_mom_v_source_ext,
2279 bc_mom_w_source_ext,
2281 bc_dmom_u_ham_grad_p_ext,
2282 bc_dmom_u_ham_grad_u_ext,
2284 bc_dmom_v_ham_grad_p_ext,
2285 bc_dmom_v_ham_grad_v_ext,
2287 bc_dmom_w_ham_grad_p_ext,
2288 bc_dmom_w_ham_grad_w_ext);
2295 mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext;
2296 mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
2297 mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*zt_ext;
2298 dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
2299 dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
2300 dmom_u_adv_u_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*zt_ext;
2302 mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
2303 mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
2304 mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*zt_ext;
2305 dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
2306 dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
2307 dmom_v_adv_v_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*zt_ext;
2309 mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*xt_ext;
2310 mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*yt_ext;
2311 mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*zt_ext;
2312 dmom_w_adv_w_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*xt_ext;
2313 dmom_w_adv_w_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*yt_ext;
2314 dmom_w_adv_w_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*zt_ext;
2317 bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext;
2318 bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
2319 bc_mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*zt_ext;
2321 bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
2322 bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
2323 bc_mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*zt_ext;
2325 bc_mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*xt_ext;
2326 bc_mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*yt_ext;
2327 bc_mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*zt_ext;
2331 ck.calculateGScale(G,normal,h_penalty);
2332 penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb];
2334 isDOFBoundary_u.data()[ebNE_kb],
2335 isDOFBoundary_v.data()[ebNE_kb],
2336 isDOFBoundary_w.data()[ebNE_kb],
2337 isAdvectiveFluxBoundary_p.data()[ebNE_kb],
2338 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
2339 isAdvectiveFluxBoundary_v.data()[ebNE_kb],
2340 isAdvectiveFluxBoundary_w.data()[ebNE_kb],
2341 dmom_u_ham_grad_p_ext[0],
2342 bc_dmom_u_ham_grad_p_ext[0],
2353 ebqe_bc_flux_mass_ext.data()[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]+zt_ext*normal[2]),
2354 ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb],
2355 ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb],
2356 ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb],
2384 &ebqe_velocity_star.data()[ebNE_kb_nSpace],
2385 &ebqe_velocity.data()[ebNE_kb_nSpace]);
2387 ebqe_phi_ext.data()[ebNE_kb],
2388 sdInfo_u_u_rowptr.data(),
2389 sdInfo_u_u_colind.data(),
2390 isDOFBoundary_u.data()[ebNE_kb],
2391 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2393 bc_mom_uu_diff_ten_ext,
2395 ebqe_bc_flux_u_diff_ext.data()[ebNE_kb],
2396 mom_uu_diff_ten_ext,
2400 flux_mom_uu_diff_ext);
2402 ebqe_phi_ext.data()[ebNE_kb],
2403 sdInfo_u_v_rowptr.data(),
2404 sdInfo_u_v_colind.data(),
2405 isDOFBoundary_v.data()[ebNE_kb],
2406 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2408 bc_mom_uv_diff_ten_ext,
2411 mom_uv_diff_ten_ext,
2415 flux_mom_uv_diff_ext);
2417 ebqe_phi_ext.data()[ebNE_kb],
2418 sdInfo_u_w_rowptr.data(),
2419 sdInfo_u_w_colind.data(),
2420 isDOFBoundary_w.data()[ebNE_kb],
2421 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2423 bc_mom_uw_diff_ten_ext,
2426 mom_uw_diff_ten_ext,
2430 flux_mom_uw_diff_ext);
2432 ebqe_phi_ext.data()[ebNE_kb],
2433 sdInfo_v_u_rowptr.data(),
2434 sdInfo_v_u_colind.data(),
2435 isDOFBoundary_u.data()[ebNE_kb],
2436 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2438 bc_mom_vu_diff_ten_ext,
2441 mom_vu_diff_ten_ext,
2445 flux_mom_vu_diff_ext);
2447 ebqe_phi_ext.data()[ebNE_kb],
2448 sdInfo_v_v_rowptr.data(),
2449 sdInfo_v_v_colind.data(),
2450 isDOFBoundary_v.data()[ebNE_kb],
2451 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2453 bc_mom_vv_diff_ten_ext,
2455 ebqe_bc_flux_v_diff_ext.data()[ebNE_kb],
2456 mom_vv_diff_ten_ext,
2460 flux_mom_vv_diff_ext);
2462 ebqe_phi_ext.data()[ebNE_kb],
2463 sdInfo_v_w_rowptr.data(),
2464 sdInfo_v_w_colind.data(),
2465 isDOFBoundary_w.data()[ebNE_kb],
2466 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2468 bc_mom_vw_diff_ten_ext,
2471 mom_vw_diff_ten_ext,
2475 flux_mom_vw_diff_ext);
2477 ebqe_phi_ext.data()[ebNE_kb],
2478 sdInfo_w_u_rowptr.data(),
2479 sdInfo_w_u_colind.data(),
2480 isDOFBoundary_u.data()[ebNE_kb],
2481 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2483 bc_mom_wu_diff_ten_ext,
2486 mom_wu_diff_ten_ext,
2490 flux_mom_wu_diff_ext);
2492 ebqe_phi_ext.data()[ebNE_kb],
2493 sdInfo_w_v_rowptr.data(),
2494 sdInfo_w_v_colind.data(),
2495 isDOFBoundary_v.data()[ebNE_kb],
2496 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2498 bc_mom_wv_diff_ten_ext,
2501 mom_wv_diff_ten_ext,
2505 flux_mom_wv_diff_ext);
2507 ebqe_phi_ext.data()[ebNE_kb],
2508 sdInfo_w_w_rowptr.data(),
2509 sdInfo_w_w_colind.data(),
2510 isDOFBoundary_w.data()[ebNE_kb],
2511 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2513 bc_mom_ww_diff_ten_ext,
2515 ebqe_bc_flux_w_diff_ext.data()[ebNE_kb],
2516 mom_ww_diff_ten_ext,
2520 flux_mom_ww_diff_ext);
2521 flux.data()[ebN*nQuadraturePoints_elementBoundary+kb] = flux_mass_ext;
2529 if (ebN < nElementBoundaries_owned)
2531 force_v_x = (flux_mom_u_adv_ext + flux_mom_uu_diff_ext + flux_mom_uv_diff_ext + flux_mom_uw_diff_ext)/dmom_u_ham_grad_p_ext[0];
2532 force_v_y = (flux_mom_v_adv_ext + flux_mom_vu_diff_ext + flux_mom_vv_diff_ext + flux_mom_vw_diff_ext)/dmom_u_ham_grad_p_ext[0];
2533 force_v_z = (flux_mom_w_adv_ext + flux_mom_wu_diff_ext + flux_mom_wv_diff_ext + flux_mom_ww_diff_ext)/dmom_u_ham_grad_p_ext[0];
2535 force_p_x = p_ext*normal[0];
2536 force_p_y = p_ext*normal[1];
2537 force_p_z = p_ext*normal[2];
2539 force_x = force_p_x + force_v_x;
2540 force_y = force_p_y + force_v_y;
2541 force_z = force_p_z + force_v_z;
2543 r_x = x_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+0];
2544 r_y = y_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+1];
2545 r_z = z_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+2];
2547 wettedAreas.data()[boundaryFlags.data()[ebN]] += dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]);
2549 netForces_p.data()[3*boundaryFlags.data()[ebN]+0] += force_p_x*dS;
2550 netForces_p.data()[3*boundaryFlags.data()[ebN]+1] += force_p_y*dS;
2551 netForces_p.data()[3*boundaryFlags.data()[ebN]+2] += force_p_z*dS;
2553 netForces_v.data()[3*boundaryFlags.data()[ebN]+0] += force_v_x*dS;
2554 netForces_v.data()[3*boundaryFlags.data()[ebN]+1] += force_v_y*dS;
2555 netForces_v.data()[3*boundaryFlags.data()[ebN]+2] += force_v_z*dS;
2557 netMoments.data()[3*boundaryFlags.data()[ebN]+0] += (r_y*force_z - r_z*force_y)*dS;
2558 netMoments.data()[3*boundaryFlags.data()[ebN]+1] += (r_z*force_x - r_x*force_z)*dS;
2559 netMoments.data()[3*boundaryFlags.data()[ebN]+2] += (r_x*force_y - r_y*force_x)*dS;
2564 for (
int i=0;i<nDOF_test_element;i++)
2570 elementResidual_u[i] +=
ck.ExteriorElementBoundaryFlux(flux_mom_u_adv_ext,vel_test_dS[i])+
2571 ck.ExteriorElementBoundaryFlux(flux_mom_uu_diff_ext,vel_test_dS[i])+
2572 ck.ExteriorElementBoundaryFlux(flux_mom_uv_diff_ext,vel_test_dS[i])+
2573 ck.ExteriorElementBoundaryFlux(flux_mom_uw_diff_ext,vel_test_dS[i])+
2574 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb],
2575 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2580 sdInfo_u_u_rowptr.data(),
2581 sdInfo_u_u_colind.data(),
2582 mom_uu_diff_ten_ext,
2583 &vel_grad_test_dS[i*nSpace])+
2584 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb],
2585 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2590 sdInfo_u_v_rowptr.data(),
2591 sdInfo_u_v_colind.data(),
2592 mom_uv_diff_ten_ext,
2593 &vel_grad_test_dS[i*nSpace])+
2594 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb],
2595 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2600 sdInfo_u_w_rowptr.data(),
2601 sdInfo_u_w_colind.data(),
2602 mom_uw_diff_ten_ext,
2603 &vel_grad_test_dS[i*nSpace]);
2604 elementResidual_v[i] +=
ck.ExteriorElementBoundaryFlux(flux_mom_v_adv_ext,vel_test_dS[i]) +
2605 ck.ExteriorElementBoundaryFlux(flux_mom_vu_diff_ext,vel_test_dS[i])+
2606 ck.ExteriorElementBoundaryFlux(flux_mom_vv_diff_ext,vel_test_dS[i])+
2607 ck.ExteriorElementBoundaryFlux(flux_mom_vw_diff_ext,vel_test_dS[i])+
2608 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb],
2609 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2614 sdInfo_v_u_rowptr.data(),
2615 sdInfo_v_u_colind.data(),
2616 mom_vu_diff_ten_ext,
2617 &vel_grad_test_dS[i*nSpace])+
2618 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb],
2619 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2624 sdInfo_v_v_rowptr.data(),
2625 sdInfo_v_v_colind.data(),
2626 mom_vv_diff_ten_ext,
2627 &vel_grad_test_dS[i*nSpace])+
2628 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb],
2629 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2634 sdInfo_v_w_rowptr.data(),
2635 sdInfo_v_w_colind.data(),
2636 mom_vw_diff_ten_ext,
2637 &vel_grad_test_dS[i*nSpace]);
2639 elementResidual_w[i] +=
ck.ExteriorElementBoundaryFlux(flux_mom_w_adv_ext,vel_test_dS[i]) +
2640 ck.ExteriorElementBoundaryFlux(flux_mom_wu_diff_ext,vel_test_dS[i])+
2641 ck.ExteriorElementBoundaryFlux(flux_mom_wv_diff_ext,vel_test_dS[i])+
2642 ck.ExteriorElementBoundaryFlux(flux_mom_ww_diff_ext,vel_test_dS[i])+
2643 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb],
2644 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2649 sdInfo_w_u_rowptr.data(),
2650 sdInfo_w_u_colind.data(),
2651 mom_wu_diff_ten_ext,
2652 &vel_grad_test_dS[i*nSpace])+
2653 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb],
2654 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2659 sdInfo_w_v_rowptr.data(),
2660 sdInfo_w_v_colind.data(),
2661 mom_wv_diff_ten_ext,
2662 &vel_grad_test_dS[i*nSpace])+
2663 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_w.data()[ebNE_kb],
2664 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
2669 sdInfo_w_w_rowptr.data(),
2670 sdInfo_w_w_colind.data(),
2671 mom_ww_diff_ten_ext,
2672 &vel_grad_test_dS[i*nSpace]);
2678 for (
int i=0;i<nDOF_test_element;i++)
2680 int eN_i = eN*nDOF_test_element+i;
2685 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
2686 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
2687 globalResidual.data()[offset_w+stride_w*vel_l2g.data()[eN_i]]+=elementResidual_w[i];
2698 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2699 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
2700 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
2701 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
2702 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
2703 double PSTAB = args.
scalar<
double>(
"PSTAB");
2704 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
2705 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
2706 xt::pyarray<double>& p_trial_ref = args.
array<
double>(
"p_trial_ref");
2707 xt::pyarray<double>& p_grad_trial_ref = args.
array<
double>(
"p_grad_trial_ref");
2708 xt::pyarray<double>& p_test_ref = args.
array<
double>(
"p_test_ref");
2709 xt::pyarray<double>& p_grad_test_ref = args.
array<
double>(
"p_grad_test_ref");
2710 xt::pyarray<double>& q_p = args.
array<
double>(
"q_p");
2711 xt::pyarray<double>& q_grad_p = args.
array<
double>(
"q_grad_p");
2712 xt::pyarray<double>& ebqe_p = args.
array<
double>(
"ebqe_p");
2713 xt::pyarray<double>& ebqe_grad_p = args.
array<
double>(
"ebqe_grad_p");
2714 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2715 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
2716 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
2717 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
2718 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
2719 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
2720 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
2721 xt::pyarray<double>& p_trial_trace_ref = args.
array<
double>(
"p_trial_trace_ref");
2722 xt::pyarray<double>& p_grad_trial_trace_ref = args.
array<
double>(
"p_grad_trial_trace_ref");
2723 xt::pyarray<double>& p_test_trace_ref = args.
array<
double>(
"p_test_trace_ref");
2724 xt::pyarray<double>& p_grad_test_trace_ref = args.
array<
double>(
"p_grad_test_trace_ref");
2725 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
2726 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
2727 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
2728 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
2729 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
2730 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
2731 double eb_adjoint_sigma = args.
scalar<
double>(
"eb_adjoint_sigma");
2732 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
2733 xt::pyarray<double>& nodeDiametersArray = args.
array<
double>(
"nodeDiametersArray");
2734 double hFactor = args.
scalar<
double>(
"hFactor");
2735 int nElements_global = args.
scalar<
int>(
"nElements_global");
2736 double useRBLES = args.
scalar<
double>(
"useRBLES");
2737 double useMetrics = args.
scalar<
double>(
"useMetrics");
2738 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
2739 double epsFact_rho = args.
scalar<
double>(
"epsFact_rho");
2740 double epsFact_mu = args.
scalar<
double>(
"epsFact_mu");
2741 double sigma = args.
scalar<
double>(
"sigma");
2746 double rho_s = args.
scalar<
double>(
"rho_s");
2747 double smagorinskyConstant = args.
scalar<
double>(
"smagorinskyConstant");
2748 int turbulenceClosureModel = args.
scalar<
int>(
"turbulenceClosureModel");
2749 double Ct_sge = args.
scalar<
double>(
"Ct_sge");
2750 double Cd_sge = args.
scalar<
double>(
"Cd_sge");
2751 double C_dg = args.
scalar<
double>(
"C_dg");
2752 double C_b = args.
scalar<
double>(
"C_b");
2753 const xt::pyarray<double>& eps_solid = args.
array<
double>(
"eps_solid");
2754 const xt::pyarray<double>& q_velocity_fluid = args.
array<
double>(
"q_velocity_fluid");
2755 const xt::pyarray<double>& q_velocityStar_fluid = args.
array<
double>(
"q_velocityStar_fluid");
2756 const xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
2757 const xt::pyarray<double>& q_dvos_dt = args.
array<
double>(
"q_dvos_dt");
2758 const xt::pyarray<double>& q_grad_vos = args.
array<
double>(
"q_grad_vos");
2759 const xt::pyarray<double>& q_dragAlpha = args.
array<
double>(
"q_dragAlpha");
2760 const xt::pyarray<double>& q_dragBeta = args.
array<
double>(
"q_dragBeta");
2761 const xt::pyarray<double>& q_mass_source = args.
array<
double>(
"q_mass_source");
2762 const xt::pyarray<double>& q_turb_var_0 = args.
array<
double>(
"q_turb_var_0");
2763 const xt::pyarray<double>& q_turb_var_1 = args.
array<
double>(
"q_turb_var_1");
2764 const xt::pyarray<double>& q_turb_var_grad_0 = args.
array<
double>(
"q_turb_var_grad_0");
2765 xt::pyarray<int>& p_l2g = args.
array<
int>(
"p_l2g");
2766 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
2767 xt::pyarray<double>& p_dof = args.
array<
double>(
"p_dof");
2768 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
2769 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
2770 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
2771 xt::pyarray<double>& g = args.
array<
double>(
"g");
2772 const double useVF = args.
scalar<
double>(
"useVF");
2773 xt::pyarray<double>& vf = args.
array<
double>(
"vf");
2774 xt::pyarray<double>&
phi = args.
array<
double>(
"phi");
2775 xt::pyarray<double>& normal_phi = args.
array<
double>(
"normal_phi");
2776 xt::pyarray<double>& kappa_phi = args.
array<
double>(
"kappa_phi");
2777 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
2778 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
2779 xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.
array<
double>(
"q_mom_w_acc_beta_bdf");
2780 xt::pyarray<double>& q_dV = args.
array<
double>(
"q_dV");
2781 xt::pyarray<double>& q_dV_last = args.
array<
double>(
"q_dV_last");
2782 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
2783 xt::pyarray<double>& ebqe_velocity_star = args.
array<
double>(
"ebqe_velocity_star");
2784 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
2785 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
2786 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
2787 xt::pyarray<double>& q_numDiff_w_last = args.
array<
double>(
"q_numDiff_w_last");
2788 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
2789 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
2790 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
2791 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
2792 xt::pyarray<int>& sdInfo_u_w_rowptr = args.
array<
int>(
"sdInfo_u_w_rowptr");
2793 xt::pyarray<int>& sdInfo_u_w_colind = args.
array<
int>(
"sdInfo_u_w_colind");
2794 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
2795 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
2796 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
2797 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
2798 xt::pyarray<int>& sdInfo_v_w_rowptr = args.
array<
int>(
"sdInfo_v_w_rowptr");
2799 xt::pyarray<int>& sdInfo_v_w_colind = args.
array<
int>(
"sdInfo_v_w_colind");
2800 xt::pyarray<int>& sdInfo_w_w_rowptr = args.
array<
int>(
"sdInfo_w_w_rowptr");
2801 xt::pyarray<int>& sdInfo_w_w_colind = args.
array<
int>(
"sdInfo_w_w_colind");
2802 xt::pyarray<int>& sdInfo_w_u_rowptr = args.
array<
int>(
"sdInfo_w_u_rowptr");
2803 xt::pyarray<int>& sdInfo_w_u_colind = args.
array<
int>(
"sdInfo_w_u_colind");
2804 xt::pyarray<int>& sdInfo_w_v_rowptr = args.
array<
int>(
"sdInfo_w_v_rowptr");
2805 xt::pyarray<int>& sdInfo_w_v_colind = args.
array<
int>(
"sdInfo_w_v_colind");
2806 xt::pyarray<int>& csrRowIndeces_p_p = args.
array<
int>(
"csrRowIndeces_p_p");
2807 xt::pyarray<int>& csrColumnOffsets_p_p = args.
array<
int>(
"csrColumnOffsets_p_p");
2808 xt::pyarray<int>& csrRowIndeces_p_u = args.
array<
int>(
"csrRowIndeces_p_u");
2809 xt::pyarray<int>& csrColumnOffsets_p_u = args.
array<
int>(
"csrColumnOffsets_p_u");
2810 xt::pyarray<int>& csrRowIndeces_p_v = args.
array<
int>(
"csrRowIndeces_p_v");
2811 xt::pyarray<int>& csrColumnOffsets_p_v = args.
array<
int>(
"csrColumnOffsets_p_v");
2812 xt::pyarray<int>& csrRowIndeces_p_w = args.
array<
int>(
"csrRowIndeces_p_w");
2813 xt::pyarray<int>& csrColumnOffsets_p_w = args.
array<
int>(
"csrColumnOffsets_p_w");
2814 xt::pyarray<int>& csrRowIndeces_u_p = args.
array<
int>(
"csrRowIndeces_u_p");
2815 xt::pyarray<int>& csrColumnOffsets_u_p = args.
array<
int>(
"csrColumnOffsets_u_p");
2816 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
2817 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
2818 xt::pyarray<int>& csrRowIndeces_u_v = args.
array<
int>(
"csrRowIndeces_u_v");
2819 xt::pyarray<int>& csrColumnOffsets_u_v = args.
array<
int>(
"csrColumnOffsets_u_v");
2820 xt::pyarray<int>& csrRowIndeces_u_w = args.
array<
int>(
"csrRowIndeces_u_w");
2821 xt::pyarray<int>& csrColumnOffsets_u_w = args.
array<
int>(
"csrColumnOffsets_u_w");
2822 xt::pyarray<int>& csrRowIndeces_v_p = args.
array<
int>(
"csrRowIndeces_v_p");
2823 xt::pyarray<int>& csrColumnOffsets_v_p = args.
array<
int>(
"csrColumnOffsets_v_p");
2824 xt::pyarray<int>& csrRowIndeces_v_u = args.
array<
int>(
"csrRowIndeces_v_u");
2825 xt::pyarray<int>& csrColumnOffsets_v_u = args.
array<
int>(
"csrColumnOffsets_v_u");
2826 xt::pyarray<int>& csrRowIndeces_v_v = args.
array<
int>(
"csrRowIndeces_v_v");
2827 xt::pyarray<int>& csrColumnOffsets_v_v = args.
array<
int>(
"csrColumnOffsets_v_v");
2828 xt::pyarray<int>& csrRowIndeces_v_w = args.
array<
int>(
"csrRowIndeces_v_w");
2829 xt::pyarray<int>& csrColumnOffsets_v_w = args.
array<
int>(
"csrColumnOffsets_v_w");
2830 xt::pyarray<int>& csrRowIndeces_w_p = args.
array<
int>(
"csrRowIndeces_w_p");
2831 xt::pyarray<int>& csrColumnOffsets_w_p = args.
array<
int>(
"csrColumnOffsets_w_p");
2832 xt::pyarray<int>& csrRowIndeces_w_u = args.
array<
int>(
"csrRowIndeces_w_u");
2833 xt::pyarray<int>& csrColumnOffsets_w_u = args.
array<
int>(
"csrColumnOffsets_w_u");
2834 xt::pyarray<int>& csrRowIndeces_w_v = args.
array<
int>(
"csrRowIndeces_w_v");
2835 xt::pyarray<int>& csrColumnOffsets_w_v = args.
array<
int>(
"csrColumnOffsets_w_v");
2836 xt::pyarray<int>& csrRowIndeces_w_w = args.
array<
int>(
"csrRowIndeces_w_w");
2837 xt::pyarray<int>& csrColumnOffsets_w_w = args.
array<
int>(
"csrColumnOffsets_w_w");
2838 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
2839 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
2840 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
2841 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
2842 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
2843 xt::pyarray<double>& ebqe_vf_ext = args.
array<
double>(
"ebqe_vf_ext");
2844 xt::pyarray<double>& bc_ebqe_vf_ext = args.
array<
double>(
"bc_ebqe_vf_ext");
2845 xt::pyarray<double>& ebqe_phi_ext = args.
array<
double>(
"ebqe_phi_ext");
2846 xt::pyarray<double>& bc_ebqe_phi_ext = args.
array<
double>(
"bc_ebqe_phi_ext");
2847 xt::pyarray<double>& ebqe_normal_phi_ext = args.
array<
double>(
"ebqe_normal_phi_ext");
2848 xt::pyarray<double>& ebqe_kappa_phi_ext = args.
array<
double>(
"ebqe_kappa_phi_ext");
2849 const xt::pyarray<double>& ebqe_vos_ext = args.
array<
double>(
"ebqe_vos_ext");
2850 const xt::pyarray<double>& ebqe_turb_var_0 = args.
array<
double>(
"ebqe_turb_var_0");
2851 const xt::pyarray<double>& ebqe_turb_var_1 = args.
array<
double>(
"ebqe_turb_var_1");
2852 xt::pyarray<int>& isDOFBoundary_p = args.
array<
int>(
"isDOFBoundary_p");
2853 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
2854 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
2855 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
2856 xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.
array<
int>(
"isAdvectiveFluxBoundary_p");
2857 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
2858 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
2859 xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.
array<
int>(
"isAdvectiveFluxBoundary_w");
2860 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
2861 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
2862 xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.
array<
int>(
"isDiffusiveFluxBoundary_w");
2863 xt::pyarray<double>& ebqe_bc_p_ext = args.
array<
double>(
"ebqe_bc_p_ext");
2864 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
2865 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
2866 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
2867 xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_w_adv_ext");
2868 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
2869 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
2870 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
2871 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
2872 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
2873 xt::pyarray<double>& ebqe_bc_w_ext = args.
array<
double>(
"ebqe_bc_w_ext");
2874 xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.
array<
double>(
"ebqe_bc_flux_w_diff_ext");
2875 xt::pyarray<int>& csrColumnOffsets_eb_p_p = args.
array<
int>(
"csrColumnOffsets_eb_p_p");
2876 xt::pyarray<int>& csrColumnOffsets_eb_p_u = args.
array<
int>(
"csrColumnOffsets_eb_p_u");
2877 xt::pyarray<int>& csrColumnOffsets_eb_p_v = args.
array<
int>(
"csrColumnOffsets_eb_p_v");
2878 xt::pyarray<int>& csrColumnOffsets_eb_p_w = args.
array<
int>(
"csrColumnOffsets_eb_p_w");
2879 xt::pyarray<int>& csrColumnOffsets_eb_u_p = args.
array<
int>(
"csrColumnOffsets_eb_u_p");
2880 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
2881 xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.
array<
int>(
"csrColumnOffsets_eb_u_v");
2882 xt::pyarray<int>& csrColumnOffsets_eb_u_w = args.
array<
int>(
"csrColumnOffsets_eb_u_w");
2883 xt::pyarray<int>& csrColumnOffsets_eb_v_p = args.
array<
int>(
"csrColumnOffsets_eb_v_p");
2884 xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.
array<
int>(
"csrColumnOffsets_eb_v_u");
2885 xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.
array<
int>(
"csrColumnOffsets_eb_v_v");
2886 xt::pyarray<int>& csrColumnOffsets_eb_v_w = args.
array<
int>(
"csrColumnOffsets_eb_v_w");
2887 xt::pyarray<int>& csrColumnOffsets_eb_w_p = args.
array<
int>(
"csrColumnOffsets_eb_w_p");
2888 xt::pyarray<int>& csrColumnOffsets_eb_w_u = args.
array<
int>(
"csrColumnOffsets_eb_w_u");
2889 xt::pyarray<int>& csrColumnOffsets_eb_w_v = args.
array<
int>(
"csrColumnOffsets_eb_w_v");
2890 xt::pyarray<int>& csrColumnOffsets_eb_w_w = args.
array<
int>(
"csrColumnOffsets_eb_w_w");
2891 xt::pyarray<int>& elementFlags = args.
array<
int>(
"elementFlags");
2892 double LAG_MU_FR = args.
scalar<
double>(
"LAG_MU_FR");
2893 xt::pyarray<double>& q_mu_fr_last = args.
array<
double>(
"q_mu_fr_last");
2894 xt::pyarray<double>& q_mu_fr = args.
array<
double>(
"q_mu_fr");
2898 for(
int eN=0;eN<nElements_global;eN++)
2900 register double eps_rho,eps_mu;
2902 register double elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
2903 elementJacobian_u_v[nDOF_test_element][nDOF_trial_element],
2904 elementJacobian_u_w[nDOF_test_element][nDOF_trial_element],
2905 elementJacobian_v_u[nDOF_test_element][nDOF_trial_element],
2906 elementJacobian_v_v[nDOF_test_element][nDOF_trial_element],
2907 elementJacobian_v_w[nDOF_test_element][nDOF_trial_element],
2908 elementJacobian_w_u[nDOF_test_element][nDOF_trial_element],
2909 elementJacobian_w_v[nDOF_test_element][nDOF_trial_element],
2910 elementJacobian_w_w[nDOF_test_element][nDOF_trial_element];
2911 for (
int i=0;i<nDOF_test_element;i++)
2912 for (
int j=0;j<nDOF_trial_element;j++)
2915 elementJacobian_u_u[i][j]=0.0;
2916 elementJacobian_u_v[i][j]=0.0;
2917 elementJacobian_u_w[i][j]=0.0;
2918 elementJacobian_v_u[i][j]=0.0;
2919 elementJacobian_v_v[i][j]=0.0;
2920 elementJacobian_v_w[i][j]=0.0;
2921 elementJacobian_w_u[i][j]=0.0;
2922 elementJacobian_w_v[i][j]=0.0;
2923 elementJacobian_w_w[i][j]=0.0;
2926 for (
int k=0;k<nQuadraturePoints_element;k++)
2928 int eN_k = eN*nQuadraturePoints_element+k,
2929 eN_k_nSpace = eN_k*nSpace,
2930 eN_nDOF_trial_element = eN*nDOF_trial_element;
2933 register double p=0.0,
u=0.0,
v=0.0,
w=0.0,
2934 grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],grad_vos[nSpace],
2942 dmass_adv_u[nSpace],
2943 dmass_adv_v[nSpace],
2944 dmass_adv_w[nSpace],
2946 dmom_u_adv_u[nSpace],
2947 dmom_u_adv_v[nSpace],
2948 dmom_u_adv_w[nSpace],
2950 dmom_v_adv_u[nSpace],
2951 dmom_v_adv_v[nSpace],
2952 dmom_v_adv_w[nSpace],
2954 dmom_w_adv_u[nSpace],
2955 dmom_w_adv_v[nSpace],
2956 dmom_w_adv_w[nSpace],
2957 mom_uu_diff_ten[nSpace],
2958 mom_vv_diff_ten[nSpace],
2959 mom_ww_diff_ten[nSpace],
2970 dmom_u_ham_grad_p[nSpace],
2971 dmom_u_ham_grad_u[nSpace],
2973 dmom_v_ham_grad_p[nSpace],
2974 dmom_v_ham_grad_v[nSpace],
2976 dmom_w_ham_grad_p[nSpace],
2977 dmom_w_ham_grad_w[nSpace],
2988 dpdeResidual_p_u[nDOF_trial_element],dpdeResidual_p_v[nDOF_trial_element],dpdeResidual_p_w[nDOF_trial_element],
2989 dpdeResidual_u_p[nDOF_trial_element],dpdeResidual_u_u[nDOF_trial_element],
2990 dpdeResidual_v_p[nDOF_trial_element],dpdeResidual_v_v[nDOF_trial_element],
2991 dpdeResidual_w_p[nDOF_trial_element],dpdeResidual_w_w[nDOF_trial_element],
2992 Lstar_u_u[nDOF_test_element],
2993 Lstar_v_v[nDOF_test_element],
2994 Lstar_w_w[nDOF_test_element],
2999 dsubgridError_p_u[nDOF_trial_element],
3000 dsubgridError_p_v[nDOF_trial_element],
3001 dsubgridError_p_w[nDOF_trial_element],
3002 dsubgridError_u_p[nDOF_trial_element],
3003 dsubgridError_u_u[nDOF_trial_element],
3004 dsubgridError_v_p[nDOF_trial_element],
3005 dsubgridError_v_v[nDOF_trial_element],
3006 dsubgridError_w_p[nDOF_trial_element],
3007 dsubgridError_w_w[nDOF_trial_element],
3008 tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
3009 tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
3012 jacInv[nSpace*nSpace],
3013 p_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
3015 vel_test_dV[nDOF_test_element],
3016 vel_grad_test_dV[nDOF_test_element*nSpace],
3021 dmom_u_source[nSpace],
3022 dmom_v_source[nSpace],
3023 dmom_w_source[nSpace],
3026 G[nSpace*nSpace],G_dd_G,tr_G,h_phi, dmom_adv_star[nSpace], dmom_adv_sge[nSpace];
3028 ck.calculateMapping_element(eN,
3032 mesh_trial_ref.data(),
3033 mesh_grad_trial_ref.data(),
3038 ck.calculateH_element(eN,
3040 nodeDiametersArray.data(),
3042 mesh_trial_ref.data(),
3044 ck.calculateMappingVelocity_element(eN,
3046 mesh_velocity_dof.data(),
3048 mesh_trial_ref.data(),
3053 dV = fabs(jacDet)*dV_ref.data()[k];
3054 ck.calculateG(jacInv,G,G_dd_G,tr_G);
3057 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3058 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3062 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
3065 p = q_p.data()[eN_k];
3066 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
3067 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
3068 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
w);
3071 for (
int I=0;I<nSpace;I++)
3072 grad_p[I] = q_grad_p.data()[eN_k_nSpace+I];
3073 for (
int I=0;I<nSpace;I++)
3074 grad_vos[I] = q_grad_vos.data()[eN_k_nSpace + I];
3075 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
3076 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
3077 ck.gradFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_w);
3079 vos = q_vos.data()[eN_k];
3081 for (
int j=0;j<nDOF_trial_element;j++)
3084 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
3085 for (
int I=0;I<nSpace;I++)
3088 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
3092 double div_mesh_velocity=0.0;
3093 int NDOF_MESH_TRIAL_ELEMENT=4;
3094 for (
int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
3096 int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
3097 div_mesh_velocity +=
3098 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+0]*vel_grad_trial[j*3+0] +
3099 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+1]*vel_grad_trial[j*3+1] +
3100 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+2]*vel_grad_trial[j*3+2];
3102 div_mesh_velocity =
DM3*div_mesh_velocity + (1.0-
DM3)*alphaBDF*(dV-q_dV_last.data()[eN_k])/dV;
3109 double eddy_viscosity(0.);
3118 elementDiameter.data()[eN],
3119 smagorinskyConstant,
3120 turbulenceClosureModel,
3125 &normal_phi.data()[eN_k_nSpace],
3126 kappa_phi.data()[eN_k],
3138 q_velocity_sge.data()[eN_k_nSpace+0],
3139 q_velocity_sge.data()[eN_k_nSpace+1],
3140 q_velocity_sge.data()[eN_k_nSpace+2],
3186 mass_source = q_mass_source.data()[eN_k];
3187 for (
int I=0;I<nSpace;I++)
3189 dmom_u_source[I] = 0.0;
3190 dmom_v_source[I] = 0.0;
3191 dmom_w_source[I] = 0.0;
3197 q_dragAlpha.data()[eN_k],
3198 q_dragBeta.data()[eN_k],
3212 q_velocity_sge.data()[eN_k_nSpace+0],
3213 q_velocity_sge.data()[eN_k_nSpace+1],
3214 q_velocity_sge.data()[eN_k_nSpace+2],
3215 eps_solid.data()[elementFlags.data()[eN]],
3217 q_velocity_fluid.data()[eN_k_nSpace+0],
3218 q_velocity_fluid.data()[eN_k_nSpace+1],
3219 q_velocity_fluid.data()[eN_k_nSpace+2],
3220 q_velocityStar_fluid.data()[eN_k_nSpace+0],
3221 q_velocityStar_fluid.data()[eN_k_nSpace+1],
3222 q_velocityStar_fluid.data()[eN_k_nSpace+2],
3229 q_grad_vos.data()[eN_k_nSpace+0],
3230 q_grad_vos.data()[eN_k_nSpace+1],
3231 q_grad_vos.data()[eN_k_nSpace+2]);
3233 double mu_fr_tmp=0.0;
3240 q_mu_fr_last.data()[eN_k],
3268 mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*
xt;
3269 mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
3270 mom_u_adv[2] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*zt;
3271 dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*
xt;
3272 dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
3273 dmom_u_adv_u[2] -= MOVING_DOMAIN*dmom_u_acc_u*zt;
3275 mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*
xt;
3276 mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
3277 mom_v_adv[2] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*zt;
3278 dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*
xt;
3279 dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
3280 dmom_v_adv_v[2] -= MOVING_DOMAIN*dmom_v_acc_v*zt;
3282 mom_w_adv[0] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*
xt;
3283 mom_w_adv[1] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*yt;
3284 mom_w_adv[2] -= MOVING_DOMAIN*dmom_w_acc_w*mom_w_acc*zt;
3285 dmom_w_adv_w[0] -= MOVING_DOMAIN*dmom_w_acc_w*
xt;
3286 dmom_w_adv_w[1] -= MOVING_DOMAIN*dmom_w_acc_w*yt;
3287 dmom_w_adv_w[2] -= MOVING_DOMAIN*dmom_w_acc_w*zt;
3292 q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
3298 q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
3304 q_mom_w_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
3313 mom_u_acc_t *= dmom_u_acc_u;
3314 mom_v_acc_t *= dmom_v_acc_v;
3315 mom_w_acc_t *= dmom_w_acc_w;
3318 dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt);
3319 dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
3320 dmom_adv_sge[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt);
3325 ck.Mass_strong(q_dvos_dt.data()[eN_k]) +
3326 ck.Advection_strong(dmass_adv_u,grad_u) +
3327 ck.Advection_strong(dmass_adv_v,grad_v) +
3328 ck.Advection_strong(dmass_adv_w,grad_w) +
3329 DM2*MOVING_DOMAIN*
ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) +
3331 ck.Reaction_strong(mass_source);
3335 ck.Mass_strong(mom_u_acc_t) +
3336 ck.Advection_strong(dmom_adv_sge,grad_u) +
3337 ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
3338 ck.Reaction_strong(mom_u_source) -
3339 ck.Reaction_strong(
u*div_mesh_velocity);
3342 ck.Mass_strong(mom_v_acc_t) +
3343 ck.Advection_strong(dmom_adv_sge,grad_v) +
3344 ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
3345 ck.Reaction_strong(mom_v_source) -
3346 ck.Reaction_strong(
v*div_mesh_velocity);
3349 ck.Mass_strong(mom_w_acc_t) +
3350 ck.Advection_strong(dmom_adv_sge,grad_w) +
3351 ck.Hamiltonian_strong(dmom_w_ham_grad_p,grad_p) +
3352 ck.Reaction_strong(mom_w_source) -
3353 ck.Reaction_strong(
w*div_mesh_velocity);
3356 for (
int j=0;j<nDOF_trial_element;j++)
3358 register int j_nSpace = j*nSpace;
3359 dpdeResidual_p_u[j]=
ck.AdvectionJacobian_strong(dmass_adv_u,&vel_grad_trial[j_nSpace]);
3360 dpdeResidual_p_v[j]=
ck.AdvectionJacobian_strong(dmass_adv_v,&vel_grad_trial[j_nSpace]);
3361 dpdeResidual_p_w[j]=
ck.AdvectionJacobian_strong(dmass_adv_w,&vel_grad_trial[j_nSpace]);
3363 dpdeResidual_u_p[j]=
ck.HamiltonianJacobian_strong(dmom_u_ham_grad_p,&p_grad_trial[j_nSpace]);
3364 dpdeResidual_u_u[j]=
ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j]) +
3365 ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
3366 ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]);
3368 dpdeResidual_v_p[j]=
ck.HamiltonianJacobian_strong(dmom_v_ham_grad_p,&p_grad_trial[j_nSpace]);
3369 dpdeResidual_v_v[j]=
ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j]) +
3370 ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
3371 ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]);
3373 dpdeResidual_w_p[j]=
ck.HamiltonianJacobian_strong(dmom_w_ham_grad_p,&p_grad_trial[j_nSpace]);
3374 dpdeResidual_w_w[j]=
ck.MassJacobian_strong(dmom_w_acc_w_t,vel_trial_ref.data()[k*nDOF_trial_element+j]) +
3375 ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
3376 ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]);
3379 dpdeResidual_u_u[j]+=
ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j]);
3380 dpdeResidual_v_v[j]+=
ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j]);
3381 dpdeResidual_w_w[j]+=
ck.ReactionJacobian_strong(dmom_w_source[2],vel_trial_ref.data()[k*nDOF_trial_element+j]);
3386 double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
3388 elementDiameter.data()[eN],
3393 dmom_u_ham_grad_p[0],
3396 q_cfl.data()[eN_k]);
3403 dmom_u_ham_grad_p[0],
3406 q_cfl.data()[eN_k]);
3409 tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
3410 tau_p = PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
3443 dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt + useRBLES*subgridError_u);
3444 dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
3445 dmom_adv_star[2] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+2] - MOVING_DOMAIN*zt + useRBLES*subgridError_w);
3448 for (
int i=0;i<nDOF_test_element;i++)
3450 register int i_nSpace = i*nSpace;
3451 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
3452 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
3453 Lstar_w_w[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
3455 Lstar_u_u[i]+=
ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
3456 Lstar_v_v[i]+=
ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
3457 Lstar_w_w[i]+=
ck.Reaction_adjoint(dmom_w_source[2],vel_test_dV[i]);
3461 dmom_u_adv_u[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
3462 dmom_u_adv_u[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
3463 dmom_u_adv_u[2] += dmom_u_acc_u*(useRBLES*subgridError_w);
3465 dmom_v_adv_v[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
3466 dmom_v_adv_v[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
3467 dmom_v_adv_v[2] += dmom_u_acc_u*(useRBLES*subgridError_w);
3469 dmom_w_adv_w[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
3470 dmom_w_adv_w[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
3471 dmom_w_adv_w[2] += dmom_u_acc_u*(useRBLES*subgridError_w);
3475 for(
int i=0;i<nDOF_test_element;i++)
3477 register int i_nSpace = i*nSpace;
3478 for(
int j=0;j<nDOF_trial_element;j++)
3480 register int j_nSpace = j*nSpace;
3494 elementJacobian_u_u[i][j] +=
3495 ck.MassJacobian_weak(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3496 ck.HamiltonianJacobian_weak(dmom_u_ham_grad_u,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
3497 ck.AdvectionJacobian_weak(dmom_u_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3498 ck.SimpleDiffusionJacobian_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_uu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3500 ck.ReactionJacobian_weak(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3503 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_u[i]) +
3504 ck.NumericalDiffusionJacobian(q_numDiff_u_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3505 elementJacobian_u_v[i][j] +=
ck.AdvectionJacobian_weak(dmom_u_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3506 ck.SimpleDiffusionJacobian_weak(sdInfo_u_v_rowptr.data(),sdInfo_u_v_colind.data(),mom_uv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3508 ck.ReactionJacobian_weak(dmom_u_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3511 elementJacobian_u_w[i][j] +=
ck.AdvectionJacobian_weak(dmom_u_adv_w,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3512 ck.SimpleDiffusionJacobian_weak(sdInfo_u_w_rowptr.data(),sdInfo_u_w_colind.data(),mom_uw_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3514 ck.ReactionJacobian_weak(dmom_u_source[2],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3520 elementJacobian_v_u[i][j] +=
ck.AdvectionJacobian_weak(dmom_v_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3521 ck.SimpleDiffusionJacobian_weak(sdInfo_v_u_rowptr.data(),sdInfo_v_u_colind.data(),mom_vu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3523 ck.ReactionJacobian_weak(dmom_v_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3526 elementJacobian_v_v[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3527 ck.HamiltonianJacobian_weak(dmom_v_ham_grad_v,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
3528 ck.AdvectionJacobian_weak(dmom_v_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3529 ck.SimpleDiffusionJacobian_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_vv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3531 ck.ReactionJacobian_weak(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3534 ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_v[i]) +
3535 ck.NumericalDiffusionJacobian(q_numDiff_v_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3536 elementJacobian_v_w[i][j] +=
ck.AdvectionJacobian_weak(dmom_v_adv_w,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3537 ck.SimpleDiffusionJacobian_weak(sdInfo_v_w_rowptr.data(),sdInfo_v_w_colind.data(),mom_vw_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3539 ck.ReactionJacobian_weak(dmom_v_source[2],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3545 elementJacobian_w_u[i][j] +=
ck.AdvectionJacobian_weak(dmom_w_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3546 ck.SimpleDiffusionJacobian_weak(sdInfo_w_u_rowptr.data(),sdInfo_w_u_colind.data(),mom_wu_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3548 ck.ReactionJacobian_weak(dmom_w_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3551 elementJacobian_w_v[i][j] +=
ck.AdvectionJacobian_weak(dmom_w_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3552 ck.SimpleDiffusionJacobian_weak(sdInfo_w_v_rowptr.data(),sdInfo_w_v_colind.data(),mom_wv_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3554 ck.ReactionJacobian_weak(dmom_w_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3557 elementJacobian_w_w[i][j] +=
ck.MassJacobian_weak(dmom_w_acc_w_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3558 ck.HamiltonianJacobian_weak(dmom_w_ham_grad_w,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
3559 ck.AdvectionJacobian_weak(dmom_w_adv_w,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3560 ck.SimpleDiffusionJacobian_weak(sdInfo_w_w_rowptr.data(),sdInfo_w_w_colind.data(),mom_ww_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3562 ck.ReactionJacobian_weak(dmom_w_source[2],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3565 ck.SubgridErrorJacobian(dsubgridError_w_w[j],Lstar_w_w[i]) +
3566 ck.NumericalDiffusionJacobian(q_numDiff_w_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3573 for (
int i=0;i<nDOF_test_element;i++)
3575 register int eN_i = eN*nDOF_test_element+i;
3576 for (
int j=0;j<nDOF_trial_element;j++)
3578 register int eN_i_j = eN_i*nDOF_trial_element+j;
3585 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += elementJacobian_u_u[i][j];
3586 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_u_v[eN_i_j]] += elementJacobian_u_v[i][j];
3587 globalJacobian.data()[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_u_w[eN_i_j]] += elementJacobian_u_w[i][j];
3590 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_v_u[eN_i_j]] += elementJacobian_v_u[i][j];
3591 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_v_v[eN_i_j]] += elementJacobian_v_v[i][j];
3592 globalJacobian.data()[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_v_w[eN_i_j]] += elementJacobian_v_w[i][j];
3595 globalJacobian.data()[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_w_u[eN_i_j]] += elementJacobian_w_u[i][j];
3596 globalJacobian.data()[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_w_v[eN_i_j]] += elementJacobian_w_v[i][j];
3597 globalJacobian.data()[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_w_w[eN_i_j]] += elementJacobian_w_w[i][j];
3604 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3606 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
3607 eN = elementBoundaryElementsArray.data()[ebN*2+0],
3608 eN_nDOF_trial_element = eN*nDOF_trial_element,
3609 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0];
3610 register double eps_rho,eps_mu;
3611 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
3613 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
3614 ebNE_kb_nSpace = ebNE_kb*nSpace,
3615 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
3616 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
3618 register double p_ext=0.0,
3627 dmom_u_acc_u_ext=0.0,
3629 dmom_v_acc_v_ext=0.0,
3631 dmom_w_acc_w_ext=0.0,
3632 mass_adv_ext[nSpace],
3633 dmass_adv_u_ext[nSpace],
3634 dmass_adv_v_ext[nSpace],
3635 dmass_adv_w_ext[nSpace],
3636 mom_u_adv_ext[nSpace],
3637 dmom_u_adv_u_ext[nSpace],
3638 dmom_u_adv_v_ext[nSpace],
3639 dmom_u_adv_w_ext[nSpace],
3640 mom_v_adv_ext[nSpace],
3641 dmom_v_adv_u_ext[nSpace],
3642 dmom_v_adv_v_ext[nSpace],
3643 dmom_v_adv_w_ext[nSpace],
3644 mom_w_adv_ext[nSpace],
3645 dmom_w_adv_u_ext[nSpace],
3646 dmom_w_adv_v_ext[nSpace],
3647 dmom_w_adv_w_ext[nSpace],
3648 mom_uu_diff_ten_ext[nSpace],
3649 mom_vv_diff_ten_ext[nSpace],
3650 mom_ww_diff_ten_ext[nSpace],
3651 mom_uv_diff_ten_ext[1],
3652 mom_uw_diff_ten_ext[1],
3653 mom_vu_diff_ten_ext[1],
3654 mom_vw_diff_ten_ext[1],
3655 mom_wu_diff_ten_ext[1],
3656 mom_wv_diff_ten_ext[1],
3657 mom_u_source_ext=0.0,
3658 mom_v_source_ext=0.0,
3659 mom_w_source_ext=0.0,
3661 dmom_u_ham_grad_p_ext[nSpace],
3662 dmom_u_ham_grad_u_ext[nSpace],
3664 dmom_v_ham_grad_p_ext[nSpace],
3665 dmom_v_ham_grad_v_ext[nSpace],
3667 dmom_w_ham_grad_p_ext[nSpace],
3668 dmom_w_ham_grad_w_ext[nSpace],
3669 dmom_u_adv_p_ext[nSpace],
3670 dmom_v_adv_p_ext[nSpace],
3671 dmom_w_adv_p_ext[nSpace],
3672 dflux_mass_u_ext=0.0,
3673 dflux_mass_v_ext=0.0,
3674 dflux_mass_w_ext=0.0,
3675 dflux_mom_u_adv_p_ext=0.0,
3676 dflux_mom_u_adv_u_ext=0.0,
3677 dflux_mom_u_adv_v_ext=0.0,
3678 dflux_mom_u_adv_w_ext=0.0,
3679 dflux_mom_v_adv_p_ext=0.0,
3680 dflux_mom_v_adv_u_ext=0.0,
3681 dflux_mom_v_adv_v_ext=0.0,
3682 dflux_mom_v_adv_w_ext=0.0,
3683 dflux_mom_w_adv_p_ext=0.0,
3684 dflux_mom_w_adv_u_ext=0.0,
3685 dflux_mom_w_adv_v_ext=0.0,
3686 dflux_mom_w_adv_w_ext=0.0,
3691 bc_mom_u_acc_ext=0.0,
3692 bc_dmom_u_acc_u_ext=0.0,
3693 bc_mom_v_acc_ext=0.0,
3694 bc_dmom_v_acc_v_ext=0.0,
3695 bc_mom_w_acc_ext=0.0,
3696 bc_dmom_w_acc_w_ext=0.0,
3697 bc_mass_adv_ext[nSpace],
3698 bc_dmass_adv_u_ext[nSpace],
3699 bc_dmass_adv_v_ext[nSpace],
3700 bc_dmass_adv_w_ext[nSpace],
3701 bc_mom_u_adv_ext[nSpace],
3702 bc_dmom_u_adv_u_ext[nSpace],
3703 bc_dmom_u_adv_v_ext[nSpace],
3704 bc_dmom_u_adv_w_ext[nSpace],
3705 bc_mom_v_adv_ext[nSpace],
3706 bc_dmom_v_adv_u_ext[nSpace],
3707 bc_dmom_v_adv_v_ext[nSpace],
3708 bc_dmom_v_adv_w_ext[nSpace],
3709 bc_mom_w_adv_ext[nSpace],
3710 bc_dmom_w_adv_u_ext[nSpace],
3711 bc_dmom_w_adv_v_ext[nSpace],
3712 bc_dmom_w_adv_w_ext[nSpace],
3713 bc_mom_uu_diff_ten_ext[nSpace],
3714 bc_mom_vv_diff_ten_ext[nSpace],
3715 bc_mom_ww_diff_ten_ext[nSpace],
3716 bc_mom_uv_diff_ten_ext[1],
3717 bc_mom_uw_diff_ten_ext[1],
3718 bc_mom_vu_diff_ten_ext[1],
3719 bc_mom_vw_diff_ten_ext[1],
3720 bc_mom_wu_diff_ten_ext[1],
3721 bc_mom_wv_diff_ten_ext[1],
3722 bc_mom_u_source_ext=0.0,
3723 bc_mom_v_source_ext=0.0,
3724 bc_mom_w_source_ext=0.0,
3725 bc_mom_u_ham_ext=0.0,
3726 bc_dmom_u_ham_grad_p_ext[nSpace],
3727 bc_dmom_u_ham_grad_u_ext[nSpace],
3728 bc_mom_v_ham_ext=0.0,
3729 bc_dmom_v_ham_grad_p_ext[nSpace],
3730 bc_dmom_v_ham_grad_v_ext[nSpace],
3731 bc_mom_w_ham_ext=0.0,
3732 bc_dmom_w_ham_grad_p_ext[nSpace],
3733 bc_dmom_w_ham_grad_w_ext[nSpace],
3734 fluxJacobian_u_u[nDOF_trial_element],
3735 fluxJacobian_u_v[nDOF_trial_element],
3736 fluxJacobian_u_w[nDOF_trial_element],
3737 fluxJacobian_v_u[nDOF_trial_element],
3738 fluxJacobian_v_v[nDOF_trial_element],
3739 fluxJacobian_v_w[nDOF_trial_element],
3740 fluxJacobian_w_u[nDOF_trial_element],
3741 fluxJacobian_w_v[nDOF_trial_element],
3742 fluxJacobian_w_w[nDOF_trial_element],
3743 jac_ext[nSpace*nSpace],
3745 jacInv_ext[nSpace*nSpace],
3746 boundaryJac[nSpace*(nSpace-1)],
3747 metricTensor[(nSpace-1)*(nSpace-1)],
3748 metricTensorDetSqrt,
3749 vel_grad_trial_trace[nDOF_trial_element*nSpace],
3751 vel_test_dS[nDOF_test_element],
3753 x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
3754 vel_grad_test_dS[nDOF_trial_element*nSpace],
3758 G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty;
3759 ck.calculateMapping_elementBoundary(eN,
3765 mesh_trial_trace_ref.data(),
3766 mesh_grad_trial_trace_ref.data(),
3767 boundaryJac_ref.data(),
3773 metricTensorDetSqrt,
3777 ck.calculateMappingVelocity_elementBoundary(eN,
3781 mesh_velocity_dof.data(),
3783 mesh_trial_trace_ref.data(),
3784 xt_ext,yt_ext,zt_ext,
3790 dS = metricTensorDetSqrt*dS_ref.data()[kb];
3791 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
3792 ck.calculateGScale(G,&ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],h_phi);
3794 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3795 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3800 ck.gradTrialFromRef(&vel_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
3803 p_ext = ebqe_p.data()[ebNE_kb];
3804 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
3805 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],v_ext);
3806 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],w_ext);
3808 for (
int I=0;I<nSpace;I++)
3809 grad_p_ext[I] = ebqe_grad_p.data()[ebNE_kb_nSpace+I];
3810 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
3811 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
3812 ck.gradFromDOF(w_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_w_ext);
3814 for (
int j=0;j<nDOF_trial_element;j++)
3817 vel_test_dS[j] = vel_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
3818 for (
int I=0;I<nSpace;I++)
3819 vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;
3824 bc_p_ext = isDOFBoundary_p.data()[ebNE_kb]*ebqe_bc_p_ext.data()[ebNE_kb]+(1-isDOFBoundary_p.data()[ebNE_kb])*p_ext;
3826 bc_u_ext = isDOFBoundary_u.data()[ebNE_kb]*(ebqe_bc_u_ext.data()[ebNE_kb] + MOVING_DOMAIN*xt_ext) + (1-isDOFBoundary_u.data()[ebNE_kb])*u_ext;
3827 bc_v_ext = isDOFBoundary_v.data()[ebNE_kb]*(ebqe_bc_v_ext.data()[ebNE_kb] + MOVING_DOMAIN*yt_ext) + (1-isDOFBoundary_v.data()[ebNE_kb])*v_ext;
3828 bc_w_ext = isDOFBoundary_w.data()[ebNE_kb]*(ebqe_bc_w_ext.data()[ebNE_kb] + MOVING_DOMAIN*zt_ext) + (1-isDOFBoundary_w.data()[ebNE_kb])*w_ext;
3830 vos_ext = ebqe_vos_ext.data()[ebNE_kb];
3835 double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.);
3844 elementDiameter.data()[eN],
3845 smagorinskyConstant,
3846 turbulenceClosureModel,
3849 ebqe_vf_ext.data()[ebNE_kb],
3850 ebqe_phi_ext.data()[ebNE_kb],
3851 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
3852 ebqe_kappa_phi_ext.data()[ebNE_kb],
3864 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
3865 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3866 ebqe_velocity_star.data()[ebNE_kb_nSpace+2],
3890 mom_uu_diff_ten_ext,
3891 mom_vv_diff_ten_ext,
3892 mom_ww_diff_ten_ext,
3893 mom_uv_diff_ten_ext,
3894 mom_uw_diff_ten_ext,
3895 mom_vu_diff_ten_ext,
3896 mom_vw_diff_ten_ext,
3897 mom_wu_diff_ten_ext,
3898 mom_wv_diff_ten_ext,
3903 dmom_u_ham_grad_p_ext,
3904 dmom_u_ham_grad_u_ext,
3906 dmom_v_ham_grad_p_ext,
3907 dmom_v_ham_grad_v_ext,
3909 dmom_w_ham_grad_p_ext,
3910 dmom_w_ham_grad_w_ext);
3919 elementDiameter.data()[eN],
3920 smagorinskyConstant,
3921 turbulenceClosureModel,
3924 bc_ebqe_vf_ext.data()[ebNE_kb],
3925 bc_ebqe_phi_ext.data()[ebNE_kb],
3926 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
3927 ebqe_kappa_phi_ext.data()[ebNE_kb],
3939 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
3940 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3941 ebqe_velocity_star.data()[ebNE_kb_nSpace+2],
3942 bc_eddy_viscosity_ext,
3944 bc_dmom_u_acc_u_ext,
3946 bc_dmom_v_acc_v_ext,
3948 bc_dmom_w_acc_w_ext,
3954 bc_dmom_u_adv_u_ext,
3955 bc_dmom_u_adv_v_ext,
3956 bc_dmom_u_adv_w_ext,
3958 bc_dmom_v_adv_u_ext,
3959 bc_dmom_v_adv_v_ext,
3960 bc_dmom_v_adv_w_ext,
3962 bc_dmom_w_adv_u_ext,
3963 bc_dmom_w_adv_v_ext,
3964 bc_dmom_w_adv_w_ext,
3965 bc_mom_uu_diff_ten_ext,
3966 bc_mom_vv_diff_ten_ext,
3967 bc_mom_ww_diff_ten_ext,
3968 bc_mom_uv_diff_ten_ext,
3969 bc_mom_uw_diff_ten_ext,
3970 bc_mom_vu_diff_ten_ext,
3971 bc_mom_vw_diff_ten_ext,
3972 bc_mom_wu_diff_ten_ext,
3973 bc_mom_wv_diff_ten_ext,
3974 bc_mom_u_source_ext,
3975 bc_mom_v_source_ext,
3976 bc_mom_w_source_ext,
3978 bc_dmom_u_ham_grad_p_ext,
3979 bc_dmom_u_ham_grad_u_ext,
3981 bc_dmom_v_ham_grad_p_ext,
3982 bc_dmom_v_ham_grad_v_ext,
3984 bc_dmom_w_ham_grad_p_ext,
3985 bc_dmom_w_ham_grad_w_ext);
3990 mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext;
3991 mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
3992 mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*zt_ext;
3993 dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
3994 dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
3995 dmom_u_adv_u_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*zt_ext;
3997 mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
3998 mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
3999 mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*zt_ext;
4000 dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
4001 dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
4002 dmom_v_adv_v_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*zt_ext;
4004 mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*xt_ext;
4005 mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*yt_ext;
4006 mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*mom_w_acc_ext*zt_ext;
4007 dmom_w_adv_w_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*xt_ext;
4008 dmom_w_adv_w_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*yt_ext;
4009 dmom_w_adv_w_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*zt_ext;
4012 bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext;
4013 bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
4014 bc_mom_u_adv_ext[2] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*zt_ext;
4016 bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
4017 bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
4018 bc_mom_v_adv_ext[2] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*zt_ext;
4020 bc_mom_w_adv_ext[0] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*xt_ext;
4021 bc_mom_w_adv_ext[1] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*yt_ext;
4022 bc_mom_w_adv_ext[2] -= MOVING_DOMAIN*dmom_w_acc_w_ext*bc_mom_w_acc_ext*zt_ext;
4027 isDOFBoundary_u.data()[ebNE_kb],
4028 isDOFBoundary_v.data()[ebNE_kb],
4029 isDOFBoundary_w.data()[ebNE_kb],
4030 isAdvectiveFluxBoundary_p.data()[ebNE_kb],
4031 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
4032 isAdvectiveFluxBoundary_v.data()[ebNE_kb],
4033 isAdvectiveFluxBoundary_w.data()[ebNE_kb],
4034 dmom_u_ham_grad_p_ext[0],
4045 ebqe_bc_flux_mass_ext.data()[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]+zt_ext*normal[2]),
4046 ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb],
4047 ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb],
4048 ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb],
4075 dflux_mom_u_adv_p_ext,
4076 dflux_mom_u_adv_u_ext,
4077 dflux_mom_u_adv_v_ext,
4078 dflux_mom_u_adv_w_ext,
4079 dflux_mom_v_adv_p_ext,
4080 dflux_mom_v_adv_u_ext,
4081 dflux_mom_v_adv_v_ext,
4082 dflux_mom_v_adv_w_ext,
4083 dflux_mom_w_adv_p_ext,
4084 dflux_mom_w_adv_u_ext,
4085 dflux_mom_w_adv_v_ext,
4086 dflux_mom_w_adv_w_ext,
4087 &ebqe_velocity_star.data()[ebNE_kb_nSpace]);
4091 ck.calculateGScale(G,normal,h_penalty);
4092 penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb];
4093 for (
int j=0;j<nDOF_trial_element;j++)
4095 register int j_nSpace = j*nSpace,ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
4102 fluxJacobian_u_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_u_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4104 ebqe_phi_ext.data()[ebNE_kb],
4105 sdInfo_u_u_rowptr.data(),
4106 sdInfo_u_u_colind.data(),
4107 isDOFBoundary_u.data()[ebNE_kb],
4108 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4110 mom_uu_diff_ten_ext,
4111 vel_trial_trace_ref.data()[ebN_local_kb_j],
4112 &vel_grad_trial_trace[j_nSpace],
4114 fluxJacobian_u_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_v_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4116 ebqe_phi_ext.data()[ebNE_kb],
4117 sdInfo_u_v_rowptr.data(),
4118 sdInfo_u_v_colind.data(),
4119 isDOFBoundary_v.data()[ebNE_kb],
4120 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4122 mom_uv_diff_ten_ext,
4123 vel_trial_trace_ref.data()[ebN_local_kb_j],
4124 &vel_grad_trial_trace[j_nSpace],
4126 fluxJacobian_u_w[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_w_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4128 ebqe_phi_ext.data()[ebNE_kb],
4129 sdInfo_u_w_rowptr.data(),
4130 sdInfo_u_w_colind.data(),
4131 isDOFBoundary_w.data()[ebNE_kb],
4132 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4134 mom_uw_diff_ten_ext,
4135 vel_trial_trace_ref.data()[ebN_local_kb_j],
4136 &vel_grad_trial_trace[j_nSpace],
4140 fluxJacobian_v_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_u_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4142 ebqe_phi_ext.data()[ebNE_kb],
4143 sdInfo_v_u_rowptr.data(),
4144 sdInfo_v_u_colind.data(),
4145 isDOFBoundary_u.data()[ebNE_kb],
4146 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4148 mom_vu_diff_ten_ext,
4149 vel_trial_trace_ref.data()[ebN_local_kb_j],
4150 &vel_grad_trial_trace[j_nSpace],
4152 fluxJacobian_v_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_v_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4154 ebqe_phi_ext.data()[ebNE_kb],
4155 sdInfo_v_v_rowptr.data(),
4156 sdInfo_v_v_colind.data(),
4157 isDOFBoundary_v.data()[ebNE_kb],
4158 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4160 mom_vv_diff_ten_ext,
4161 vel_trial_trace_ref.data()[ebN_local_kb_j],
4162 &vel_grad_trial_trace[j_nSpace],
4164 fluxJacobian_v_w[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_w_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4166 ebqe_phi_ext.data()[ebNE_kb],
4167 sdInfo_v_w_rowptr.data(),
4168 sdInfo_v_w_colind.data(),
4169 isDOFBoundary_w.data()[ebNE_kb],
4170 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4172 mom_vw_diff_ten_ext,
4173 vel_trial_trace_ref.data()[ebN_local_kb_j],
4174 &vel_grad_trial_trace[j_nSpace],
4178 fluxJacobian_w_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_u_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4180 ebqe_phi_ext.data()[ebNE_kb],
4181 sdInfo_w_u_rowptr.data(),
4182 sdInfo_w_u_colind.data(),
4183 isDOFBoundary_u.data()[ebNE_kb],
4184 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4186 mom_wu_diff_ten_ext,
4187 vel_trial_trace_ref.data()[ebN_local_kb_j],
4188 &vel_grad_trial_trace[j_nSpace],
4190 fluxJacobian_w_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_v_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4192 ebqe_phi_ext.data()[ebNE_kb],
4193 sdInfo_w_v_rowptr.data(),
4194 sdInfo_w_v_colind.data(),
4195 isDOFBoundary_v.data()[ebNE_kb],
4196 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4198 mom_wv_diff_ten_ext,
4199 vel_trial_trace_ref.data()[ebN_local_kb_j],
4200 &vel_grad_trial_trace[j_nSpace],
4202 fluxJacobian_w_w[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_w_adv_w_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4204 ebqe_phi_ext.data()[ebNE_kb],
4205 sdInfo_w_w_rowptr.data(),
4206 sdInfo_w_w_colind.data(),
4207 isDOFBoundary_w.data()[ebNE_kb],
4208 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4210 mom_ww_diff_ten_ext,
4211 vel_trial_trace_ref.data()[ebN_local_kb_j],
4212 &vel_grad_trial_trace[j_nSpace],
4218 for (
int i=0;i<nDOF_test_element;i++)
4220 register int eN_i = eN*nDOF_test_element+i;
4221 for (
int j=0;j<nDOF_trial_element;j++)
4223 register int ebN_i_j = ebN*4*
nDOF_test_X_trial_element + i*nDOF_trial_element + j,ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
4231 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
4232 fluxJacobian_u_u[j]*vel_test_dS[i]+
4233 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u.data()[ebNE_kb],
4234 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4236 vel_trial_trace_ref.data()[ebN_local_kb_j],
4238 sdInfo_u_u_rowptr.data(),
4239 sdInfo_u_u_colind.data(),
4240 mom_uu_diff_ten_ext,
4241 &vel_grad_test_dS[i*nSpace]);
4242 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] +=
4243 fluxJacobian_u_v[j]*vel_test_dS[i]+
4244 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v.data()[ebNE_kb],
4245 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4247 vel_trial_trace_ref.data()[ebN_local_kb_j],
4249 sdInfo_u_v_rowptr.data(),
4250 sdInfo_u_v_colind.data(),
4251 mom_uv_diff_ten_ext,
4252 &vel_grad_test_dS[i*nSpace]);
4253 globalJacobian.data()[csrRowIndeces_u_w[eN_i] + csrColumnOffsets_eb_u_w[ebN_i_j]] += fluxJacobian_u_w[j]*vel_test_dS[i]+
4254 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w.data()[ebNE_kb],
4255 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4257 vel_trial_trace_ref.data()[ebN_local_kb_j],
4259 sdInfo_u_w_rowptr.data(),
4260 sdInfo_u_w_colind.data(),
4261 mom_uw_diff_ten_ext,
4262 &vel_grad_test_dS[i*nSpace]);
4265 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] +=
4266 fluxJacobian_v_u[j]*vel_test_dS[i]+
4267 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u.data()[ebNE_kb],
4268 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4270 vel_trial_trace_ref.data()[ebN_local_kb_j],
4272 sdInfo_v_u_rowptr.data(),
4273 sdInfo_v_u_colind.data(),
4274 mom_vu_diff_ten_ext,
4275 &vel_grad_test_dS[i*nSpace]);
4276 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
4277 fluxJacobian_v_v[j]*vel_test_dS[i]+
4278 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v.data()[ebNE_kb],
4279 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4281 vel_trial_trace_ref.data()[ebN_local_kb_j],
4283 sdInfo_v_v_rowptr.data(),
4284 sdInfo_v_v_colind.data(),
4285 mom_vv_diff_ten_ext,
4286 &vel_grad_test_dS[i*nSpace]);
4287 globalJacobian.data()[csrRowIndeces_v_w[eN_i] + csrColumnOffsets_eb_v_w[ebN_i_j]] += fluxJacobian_v_w[j]*vel_test_dS[i]+
4288 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w.data()[ebNE_kb],
4289 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4291 vel_trial_trace_ref.data()[ebN_local_kb_j],
4293 sdInfo_v_w_rowptr.data(),
4294 sdInfo_v_w_colind.data(),
4295 mom_vw_diff_ten_ext,
4296 &vel_grad_test_dS[i*nSpace]);
4299 globalJacobian.data()[csrRowIndeces_w_u[eN_i] + csrColumnOffsets_eb_w_u[ebN_i_j]] += fluxJacobian_w_u[j]*vel_test_dS[i]+
4300 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u.data()[ebNE_kb],
4301 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4303 vel_trial_trace_ref.data()[ebN_local_kb_j],
4305 sdInfo_w_u_rowptr.data(),
4306 sdInfo_w_u_colind.data(),
4307 mom_wu_diff_ten_ext,
4308 &vel_grad_test_dS[i*nSpace]);
4309 globalJacobian.data()[csrRowIndeces_w_v[eN_i] + csrColumnOffsets_eb_w_v[ebN_i_j]] += fluxJacobian_w_v[j]*vel_test_dS[i]+
4310 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v.data()[ebNE_kb],
4311 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4313 vel_trial_trace_ref.data()[ebN_local_kb_j],
4315 sdInfo_w_v_rowptr.data(),
4316 sdInfo_w_v_colind.data(),
4317 mom_wv_diff_ten_ext,
4318 &vel_grad_test_dS[i*nSpace]);
4319 globalJacobian.data()[csrRowIndeces_w_w[eN_i] + csrColumnOffsets_eb_w_w[ebN_i_j]] += fluxJacobian_w_w[j]*vel_test_dS[i]+
4320 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_w.data()[ebNE_kb],
4321 isDiffusiveFluxBoundary_w.data()[ebNE_kb],
4323 vel_trial_trace_ref.data()[ebN_local_kb_j],
4325 sdInfo_w_w_rowptr.data(),
4326 sdInfo_w_w_colind.data(),
4327 mom_ww_diff_ten_ext,
4328 &vel_grad_test_dS[i*nSpace]);
4337 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
4338 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
4339 int nInteriorElementBoundaries_global = args.
scalar<
int>(
"nInteriorElementBoundaries_global");
4340 xt::pyarray<int>& interiorElementBoundariesArray = args.
array<
int>(
"interiorElementBoundariesArray");
4341 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
4342 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
4343 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
4344 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
4345 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
4346 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
4347 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
4348 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
4349 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
4350 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
4351 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
4352 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
4353 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
4354 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
4355 xt::pyarray<double>& vos_dof = args.
array<
double>(
"vos_dof");
4356 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
4357 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
4358 xt::pyarray<double>& velocityAverage = args.
array<
double>(
"velocityAverage");
4359 int permutations[nQuadraturePoints_elementBoundary];
4360 double xArray_left[nQuadraturePoints_elementBoundary*3],
4361 xArray_right[nQuadraturePoints_elementBoundary*3];
4362 for (
int i=0;i<nQuadraturePoints_elementBoundary;i++)
4364 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
4366 register int ebN = exteriorElementBoundariesArray.data()[ebNE];
4367 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4369 register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace,
4370 ebNE_kb_nSpace = ebNE*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
4371 velocityAverage.data()[ebN_kb_nSpace+0]=ebqe_velocity.data()[ebNE_kb_nSpace+0];
4372 velocityAverage.data()[ebN_kb_nSpace+1]=ebqe_velocity.data()[ebNE_kb_nSpace+1];
4373 velocityAverage.data()[ebN_kb_nSpace+2]=ebqe_velocity.data()[ebNE_kb_nSpace+2];
4376 for (
int ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
4378 register int ebN = interiorElementBoundariesArray.data()[ebNI],
4379 left_eN_global = elementBoundaryElementsArray.data()[ebN*2+0],
4380 left_ebN_element = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
4381 right_eN_global = elementBoundaryElementsArray.data()[ebN*2+1],
4382 right_ebN_element = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+1],
4383 left_eN_nDOF_trial_element = left_eN_global*nDOF_trial_element,
4384 right_eN_nDOF_trial_element = right_eN_global*nDOF_trial_element;
4385 double jac[nSpace*nSpace],
4387 jacInv[nSpace*nSpace],
4388 boundaryJac[nSpace*(nSpace-1)],
4389 metricTensor[(nSpace-1)*(nSpace-1)],
4390 metricTensorDetSqrt,
4393 xt,yt,zt,integralScaling;
4395 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4397 ck.calculateMapping_elementBoundary(left_eN_global,
4400 left_ebN_element*nQuadraturePoints_elementBoundary+kb,
4403 mesh_trial_trace_ref.data(),
4404 mesh_grad_trial_trace_ref.data(),
4405 boundaryJac_ref.data(),
4411 metricTensorDetSqrt,
4415 xArray_left[kb*3+0] = x;
4416 xArray_left[kb*3+1] = y;
4417 xArray_left[kb*3+2] =
z;
4418 ck.calculateMapping_elementBoundary(right_eN_global,
4421 right_ebN_element*nQuadraturePoints_elementBoundary+kb,
4424 mesh_trial_trace_ref.data(),
4425 mesh_grad_trial_trace_ref.data(),
4426 boundaryJac_ref.data(),
4432 metricTensorDetSqrt,
4436 ck.calculateMappingVelocity_elementBoundary(left_eN_global,
4439 left_ebN_element*nQuadraturePoints_elementBoundary+kb,
4440 mesh_velocity_dof.data(),
4442 mesh_trial_trace_ref.data(),
4448 xArray_right[kb*3+0] = x;
4449 xArray_right[kb*3+1] = y;
4450 xArray_right[kb*3+2] =
z;
4452 for (
int kb_left=0;kb_left<nQuadraturePoints_elementBoundary;kb_left++)
4454 double errorNormMin = 1.0;
4455 for (
int kb_right=0;kb_right<nQuadraturePoints_elementBoundary;kb_right++)
4457 double errorNorm=0.0;
4458 for (
int I=0;I<nSpace;I++)
4460 errorNorm += fabs(xArray_left[kb_left*3+I]
4462 xArray_right[kb_right*3+I]);
4464 if (errorNorm < errorNormMin)
4466 permutations[kb_right] = kb_left;
4467 errorNormMin = errorNorm;
4471 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4473 register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
4474 register double u_left=0.0,
4482 register int left_kb = kb,
4483 right_kb = permutations[kb],
4484 left_ebN_element_kb_nDOF_test_element=(left_ebN_element*nQuadraturePoints_elementBoundary+left_kb)*nDOF_test_element,
4485 right_ebN_element_kb_nDOF_test_element=(right_ebN_element*nQuadraturePoints_elementBoundary+right_kb)*nDOF_test_element;
4489 ck.valFromDOF(vos_dof.data(),&vel_l2g.data()[left_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[left_ebN_element_kb_nDOF_test_element],vos_left);
4490 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[left_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[left_ebN_element_kb_nDOF_test_element],u_left);
4491 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[left_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[left_ebN_element_kb_nDOF_test_element],v_left);
4492 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[left_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[left_ebN_element_kb_nDOF_test_element],w_left);
4494 ck.valFromDOF(vos_dof.data(),&vel_l2g.data()[right_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[right_ebN_element_kb_nDOF_test_element],vos_right);
4495 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[right_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[right_ebN_element_kb_nDOF_test_element],u_right);
4496 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[right_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[right_ebN_element_kb_nDOF_test_element],v_right);
4497 ck.valFromDOF(w_dof.data(),&vel_l2g.data()[right_eN_nDOF_trial_element],&vel_trial_trace_ref.data()[right_ebN_element_kb_nDOF_test_element],w_right);
4499 velocityAverage.data()[ebN_kb_nSpace+0]=0.5*(u_left + u_right);
4500 velocityAverage.data()[ebN_kb_nSpace+1]=0.5*(v_left + v_right);
4501 velocityAverage.data()[ebN_kb_nSpace+2]=0.5*(w_left + w_right);
4508 int nQuadraturePoints_elementIn,
4509 int nDOF_mesh_trial_elementIn,
4510 int nDOF_trial_elementIn,
4511 int nDOF_test_elementIn,
4512 int nQuadraturePoints_elementBoundaryIn,
4517 double packFraction,
4530 double mu_fr_limiter)
4532 cppRANS3PSed_base* rvalue = proteus::chooseAndAllocateDiscretization<cppRANS3PSed_base,cppRANS3PSed,CompKernel>(nSpaceIn,
4533 nQuadraturePoints_elementIn,
4534 nDOF_mesh_trial_elementIn,
4535 nDOF_trial_elementIn,
4536 nDOF_test_elementIn,
4537 nQuadraturePoints_elementBoundaryIn,