9 #include "xtensor-python/pyarray.hpp"
11 namespace py = pybind11;
17 #define TURB_FORCE_FAC 1.0
41 double mu_fr_limiter){}
48 template<
class CompKernelType,
50 int nQuadraturePoints_element,
51 int nDOF_mesh_trial_element,
52 int nDOF_trial_element,
53 int nDOF_test_element,
54 int nQuadraturePoints_elementBoundary>
100 double mu_fr_limiter)
131 H = 0.5*(1.0 +
phi/eps + sin(M_PI*
phi/eps)/M_PI);
141 + 0.5*(eps + 0.5*eps*eps/eps - eps*cos(M_PI*eps/eps)/(M_PI*M_PI)) \
142 - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI));
150 HI = 0.5*(
phi + 0.5*
phi*
phi/eps - eps*cos(M_PI*
phi/eps)/(M_PI*M_PI)) \
151 - 0.5*((-eps) + 0.5*(-eps)*(-eps)/eps - eps*cos(M_PI*(-eps)/eps)/(M_PI*M_PI));
164 d = 0.5*(1.0 + cos(M_PI*
phi/eps))/eps;
178 const double smagorinskyConstant,
179 const int turbulenceClosureModel,
180 const double g[nSpace],
184 const double n[nSpace],
188 const double grad_p[nSpace],
189 const double grad_u[nSpace],
190 const double grad_v[nSpace],
191 const double grad_w[nSpace],
198 double& eddy_viscosity,
200 double& dmom_u_acc_u,
202 double& dmom_v_acc_v,
204 double& dmom_w_acc_w,
205 double mass_adv[nSpace],
206 double dmass_adv_u[nSpace],
207 double dmass_adv_v[nSpace],
208 double dmass_adv_w[nSpace],
209 double mom_u_adv[nSpace],
210 double dmom_u_adv_u[nSpace],
211 double dmom_u_adv_v[nSpace],
212 double dmom_u_adv_w[nSpace],
213 double mom_v_adv[nSpace],
214 double dmom_v_adv_u[nSpace],
215 double dmom_v_adv_v[nSpace],
216 double dmom_v_adv_w[nSpace],
217 double mom_w_adv[nSpace],
218 double dmom_w_adv_u[nSpace],
219 double dmom_w_adv_v[nSpace],
220 double dmom_w_adv_w[nSpace],
221 double mom_uu_diff_ten[nSpace],
222 double mom_vv_diff_ten[nSpace],
223 double mom_ww_diff_ten[nSpace],
224 double mom_uv_diff_ten[1],
225 double mom_uw_diff_ten[1],
226 double mom_vu_diff_ten[1],
227 double mom_vw_diff_ten[1],
228 double mom_wu_diff_ten[1],
229 double mom_wv_diff_ten[1],
230 double& mom_u_source,
231 double& mom_v_source,
232 double& mom_w_source,
234 double dmom_u_ham_grad_p[nSpace],
235 double dmom_u_ham_grad_u[nSpace],
237 double dmom_v_ham_grad_p[nSpace],
238 double dmom_v_ham_grad_v[nSpace],
240 double dmom_w_ham_grad_p[nSpace],
241 double dmom_w_ham_grad_w[nSpace])
243 double rho,rho_f,H_rho;
371 mom_uu_diff_ten[0] =0.0;
372 mom_uu_diff_ten[1] =0.0;
375 mom_uv_diff_ten[0]=0.0;
380 mom_vv_diff_ten[0] =0.0;
381 mom_vv_diff_ten[1] =0.0;
384 mom_vu_diff_ten[0]=0.0;
398 mom_u_source = -rho*g[0];
399 mom_v_source = -rho*g[1];
403 mom_u_source += (rho-rho_f)*g[0];
404 mom_v_source += (rho-rho_f)*g[1];
409 mom_u_ham = grad_p[0];
410 dmom_u_ham_grad_p[0]=1.0;
411 dmom_u_ham_grad_p[1]=0.0;
415 mom_v_ham = grad_p[1];
416 dmom_v_ham_grad_p[0]=0.0;
417 dmom_v_ham_grad_p[1]=1.0;
427 mom_u_ham += rho*(uStar*grad_u[0]+vStar*grad_u[1]);
428 dmom_u_ham_grad_u[0]= rho*uStar;
429 dmom_u_ham_grad_u[1]= rho*vStar;
433 mom_v_ham += rho*(uStar*grad_v[0]+vStar*grad_v[1]);
434 dmom_v_ham_grad_v[0]= rho*uStar;
435 dmom_v_ham_grad_v[1]= rho*vStar;
452 const double eps_rho,
473 const double uStar_f,
474 const double vStar_f,
475 const double wStar_f,
476 double& mom_u_source,
477 double& mom_v_source,
478 double& mom_w_source,
479 double dmom_u_source[nSpace],
480 double dmom_v_source[nSpace],
481 double dmom_w_source[nSpace],
486 double rhoFluid, nuFluid,H_mu,viscosity;
488 nuFluid =
nu_0*(1.0-H_mu)+
nu_1*H_mu;
494 double solid_velocity[2]={uStar,vStar}, fluid_velocity[2]={uStar_f, vStar_f};
502 double beta2 = 156976.4;
503 double one_by_vos = 2.0*vos/(vos*vos + fmax(1.0e-8,vos*vos));
513 dmom_u_source[0] = new_beta + (1.0-
DRAG_FAC)*beta2;
514 dmom_u_source[1] = 0.0;
517 dmom_v_source[0] = 0.0;
518 dmom_v_source[1] = new_beta + (1.0-
DRAG_FAC)*beta2;
531 double& mom_u_source,
532 double& mom_v_source,
533 double& mom_w_source,
534 double dmom_u_source[nSpace],
535 double dmom_v_source[nSpace],
536 double dmom_w_source[nSpace])
541 double dVos = vos - meanPack;
543 double packPenalty = 1e6;
544 mom_u_source += sigma * packPenalty*
u;
545 mom_v_source += sigma * packPenalty*
v;
546 dmom_u_source[0] += sigma * packPenalty;
547 dmom_v_source[1] += sigma * packPenalty;
555 const double grad_vos[nSpace],
556 double& mom_u_source,
557 double& mom_v_source,
558 double& mom_w_source)
561 double one_by_vos = 2.0*vos/(vos*vos + fmax(1.0e-8,vos*vos));
563 mom_u_source +=
coeff * grad_vos[0]*one_by_vos;
564 mom_v_source +=
coeff * grad_vos[1]*one_by_vos;
571 const double mu_fr_last,
574 const double eps_rho,
584 const double grad_u[nSpace],
585 const double grad_v[nSpace],
586 const double grad_w[nSpace],
587 double mom_uu_diff_ten[nSpace],
588 double mom_uv_diff_ten[1],
589 double mom_uw_diff_ten[1],
590 double mom_vv_diff_ten[nSpace],
591 double mom_vu_diff_ten[1],
592 double mom_vw_diff_ten[1],
593 double mom_ww_diff_ten[nSpace],
594 double mom_wu_diff_ten[1],
595 double mom_wv_diff_ten[1])
597 double one_by_vos = 2.0*vos/(vos*vos + fmax(1.0e-8,vos*vos));
600 grad_u[0], grad_u[1], 0.,
601 grad_v[0], grad_v[1], 0.,
602 0., 0. , 0.)*one_by_vos;
603 double mu_fr = LAG_MU_FR*mu_fr_last + (1.0 - LAG_MU_FR)*mu_fr_new;
605 mom_uu_diff_ten[0] += 2. * mu_fr * (2./3.);
606 mom_uu_diff_ten[1] += mu_fr;
609 mom_uv_diff_ten[0] += mu_fr;
612 mom_vv_diff_ten[0] += mu_fr;
613 mom_vv_diff_ten[1] += 2. * mu_fr * (2./3.) ;
616 mom_vu_diff_ten[0] += mu_fr;
632 const double &elementDiameter,
635 const double df[nSpace],
642 double h, oneByAbsdt, density, viscosity, nrm_df;
643 h = hFactor * elementDiameter;
647 for (
int I = 0; I < nSpace; I++)
649 nrm_df +=
df[I] *
df[I];
651 nrm_df = sqrt(nrm_df);
654 cfl = nrm_df / (fabs(h * density));
658 cfl = nrm_df / fabs(h );
660 oneByAbsdt = fabs(dmt);
661 tau_v = 1.0 / (4.0 * viscosity / (h * h) + 2.0 * nrm_df / h + oneByAbsdt);
662 tau_p = (4.0 * viscosity + 2.0 * nrm_df * h + oneByAbsdt * h * h) / pfac;
666 const double &Cd_sge,
667 const double G[nSpace * nSpace],
668 const double &G_dd_G,
671 const double Ai[nSpace],
679 for (
int I = 0; I < nSpace; I++)
680 for (
int J = 0; J < nSpace; J++)
681 v_d_Gv += Ai[I] * G[I * nSpace + J] * Ai[J];
682 tau_v = 1.0 / sqrt(Ct_sge * A0 * A0 + v_d_Gv + Cd_sge * Kij * Kij * G_dd_G + 1.0e-12);
683 tau_p = 1.0 / (pfac * tr_G * tau_v);
688 const double &pdeResidualP,
689 const double &pdeResidualU,
690 const double &pdeResidualV,
691 const double &pdeResidualW,
692 double &subgridErrorP,
693 double &subgridErrorU,
694 double &subgridErrorV,
695 double &subgridErrorW)
698 subgridErrorP = -tau_p * pdeResidualP;
700 subgridErrorU = -tau_v * pdeResidualU;
701 subgridErrorV = -tau_v * pdeResidualV;
707 const double dpdeResidualP_du[nDOF_trial_element],
708 const double dpdeResidualP_dv[nDOF_trial_element],
709 const double dpdeResidualP_dw[nDOF_trial_element],
710 const double dpdeResidualU_dp[nDOF_trial_element],
711 const double dpdeResidualU_du[nDOF_trial_element],
712 const double dpdeResidualV_dp[nDOF_trial_element],
713 const double dpdeResidualV_dv[nDOF_trial_element],
714 const double dpdeResidualW_dp[nDOF_trial_element],
715 const double dpdeResidualW_dw[nDOF_trial_element],
716 double dsubgridErrorP_du[nDOF_trial_element],
717 double dsubgridErrorP_dv[nDOF_trial_element],
718 double dsubgridErrorP_dw[nDOF_trial_element],
719 double dsubgridErrorU_dp[nDOF_trial_element],
720 double dsubgridErrorU_du[nDOF_trial_element],
721 double dsubgridErrorV_dp[nDOF_trial_element],
722 double dsubgridErrorV_dv[nDOF_trial_element],
723 double dsubgridErrorW_dp[nDOF_trial_element],
724 double dsubgridErrorW_dw[nDOF_trial_element])
726 for (
int j = 0; j < nDOF_trial_element; j++)
729 dsubgridErrorP_du[j] = -tau_p * dpdeResidualP_du[j];
730 dsubgridErrorP_dv[j] = -tau_p * dpdeResidualP_dv[j];
734 dsubgridErrorU_dp[j] = -tau_v * dpdeResidualU_dp[j];
735 dsubgridErrorU_du[j] = -tau_v * dpdeResidualU_du[j];
737 dsubgridErrorV_dp[j] = -tau_v * dpdeResidualV_dp[j];
738 dsubgridErrorV_dv[j] = -tau_v * dpdeResidualV_dv[j];
747 const int& isDOFBoundary_u,
748 const int& isDOFBoundary_v,
749 const int& isDOFBoundary_w,
750 const int& isFluxBoundary_p,
751 const int& isFluxBoundary_u,
752 const int& isFluxBoundary_v,
753 const int& isFluxBoundary_w,
754 const double& oneByRho,
755 const double& bc_oneByRho,
756 const double n[nSpace],
762 const double bc_f_mass[nSpace],
763 const double bc_f_umom[nSpace],
764 const double bc_f_vmom[nSpace],
765 const double bc_f_wmom[nSpace],
766 const double& bc_flux_mass,
767 const double& bc_flux_umom,
768 const double& bc_flux_vmom,
769 const double& bc_flux_wmom,
774 const double f_mass[nSpace],
775 const double f_umom[nSpace],
776 const double f_vmom[nSpace],
777 const double f_wmom[nSpace],
778 const double df_mass_du[nSpace],
779 const double df_mass_dv[nSpace],
780 const double df_mass_dw[nSpace],
781 const double df_umom_dp[nSpace],
782 const double df_umom_du[nSpace],
783 const double df_umom_dv[nSpace],
784 const double df_umom_dw[nSpace],
785 const double df_vmom_dp[nSpace],
786 const double df_vmom_du[nSpace],
787 const double df_vmom_dv[nSpace],
788 const double df_vmom_dw[nSpace],
789 const double df_wmom_dp[nSpace],
790 const double df_wmom_du[nSpace],
791 const double df_wmom_dv[nSpace],
792 const double df_wmom_dw[nSpace],
797 double* velocity_star,
800 double flowSpeedNormal;
805 flowSpeedNormal=(
n[0]*velocity_star[0] +
806 n[1]*velocity_star[1]);
811 if (isDOFBoundary_u != 1)
813 flux_mass +=
n[0]*f_mass[0];
817 flux_mass +=
n[0]*f_mass[0];
818 if (flowSpeedNormal < 0.0)
820 flux_umom+=flowSpeedNormal*(bc_u -
u);
824 if (isDOFBoundary_v != 1)
826 flux_mass+=
n[1]*f_mass[1];
830 flux_mass+=
n[1]*f_mass[1];
831 if (flowSpeedNormal < 0.0)
833 flux_vmom+=flowSpeedNormal*(bc_v -
v);
860 if (isFluxBoundary_u == 1)
862 flux_umom = bc_flux_umom;
863 velocity[0] = bc_flux_umom;
865 if (isFluxBoundary_v == 1)
867 flux_vmom = bc_flux_vmom;
868 velocity[1] = bc_flux_umom;
878 const int& isDOFBoundary_u,
879 const int& isDOFBoundary_v,
880 const int& isDOFBoundary_w,
881 const int& isFluxBoundary_p,
882 const int& isFluxBoundary_u,
883 const int& isFluxBoundary_v,
884 const int& isFluxBoundary_w,
885 const double& oneByRho,
886 const double n[nSpace],
892 const double bc_f_mass[nSpace],
893 const double bc_f_umom[nSpace],
894 const double bc_f_vmom[nSpace],
895 const double bc_f_wmom[nSpace],
896 const double& bc_flux_mass,
897 const double& bc_flux_umom,
898 const double& bc_flux_vmom,
899 const double& bc_flux_wmom,
904 const double f_mass[nSpace],
905 const double f_umom[nSpace],
906 const double f_vmom[nSpace],
907 const double f_wmom[nSpace],
908 const double df_mass_du[nSpace],
909 const double df_mass_dv[nSpace],
910 const double df_mass_dw[nSpace],
911 const double df_umom_dp[nSpace],
912 const double df_umom_du[nSpace],
913 const double df_umom_dv[nSpace],
914 const double df_umom_dw[nSpace],
915 const double df_vmom_dp[nSpace],
916 const double df_vmom_du[nSpace],
917 const double df_vmom_dv[nSpace],
918 const double df_vmom_dw[nSpace],
919 const double df_wmom_dp[nSpace],
920 const double df_wmom_du[nSpace],
921 const double df_wmom_dv[nSpace],
922 const double df_wmom_dw[nSpace],
923 double& dflux_mass_du,
924 double& dflux_mass_dv,
925 double& dflux_mass_dw,
926 double& dflux_umom_dp,
927 double& dflux_umom_du,
928 double& dflux_umom_dv,
929 double& dflux_umom_dw,
930 double& dflux_vmom_dp,
931 double& dflux_vmom_du,
932 double& dflux_vmom_dv,
933 double& dflux_vmom_dw,
934 double& dflux_wmom_dp,
935 double& dflux_wmom_du,
936 double& dflux_wmom_dv,
937 double& dflux_wmom_dw,
938 double* velocity_star)
940 double flowSpeedNormal;
959 flowSpeedNormal=(
n[0]*velocity_star[0] +
960 n[1]*velocity_star[1]);
961 if (isDOFBoundary_u != 1)
963 dflux_mass_du +=
n[0]*df_mass_du[0];
967 dflux_mass_du +=
n[0]*df_mass_du[0];
968 if (flowSpeedNormal < 0.0)
969 dflux_umom_du -= flowSpeedNormal;
971 if (isDOFBoundary_v != 1)
973 dflux_mass_dv +=
n[1]*df_mass_dv[1];
977 dflux_mass_dv +=
n[1]*df_mass_dv[1];
978 if (flowSpeedNormal < 0.0)
979 dflux_vmom_dv -= flowSpeedNormal;
1013 if (isFluxBoundary_u == 1)
1015 dflux_umom_dp = 0.0;
1016 dflux_umom_du = 0.0;
1017 dflux_umom_dv = 0.0;
1020 if (isFluxBoundary_v == 1)
1022 dflux_vmom_dp = 0.0;
1023 dflux_vmom_du = 0.0;
1024 dflux_vmom_dv = 0.0;
1041 const int& isDOFBoundary,
1042 const int& isFluxBoundary,
1043 const double n[nSpace],
1046 const double& bc_flux,
1048 const double grad_potential[nSpace],
1050 const double& penalty,
1053 double diffusiveVelocityComponent_I,penaltyFlux,max_a;
1054 if(isFluxBoundary == 1)
1058 else if(isDOFBoundary == 1)
1062 for(
int I=0;I<nSpace;I++)
1064 diffusiveVelocityComponent_I=0.0;
1065 for(
int m=rowptr[I];m<rowptr[I+1];m++)
1067 diffusiveVelocityComponent_I -= a[m]*grad_potential[colind[m]];
1068 max_a = fmax(max_a,a[m]);
1070 flux+= diffusiveVelocityComponent_I*
n[I];
1072 penaltyFlux = max_a*penalty*(
u-bc_u);
1073 flux += penaltyFlux;
1089 const int& isDOFBoundary,
1090 const int& isFluxBoundary,
1091 const double n[nSpace],
1094 const double grad_v[nSpace],
1095 const double& penalty)
1097 double dvel_I,tmp=0.0,max_a=0.0;
1098 if(isFluxBoundary==0 && isDOFBoundary==1)
1100 for(
int I=0;I<nSpace;I++)
1103 for(
int m=rowptr[I];m<rowptr[I+1];m++)
1105 dvel_I -= a[m]*grad_v[colind[m]];
1106 max_a = fmax(max_a,a[m]);
1110 tmp +=max_a*penalty*
v;
1119 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1120 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1121 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1122 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
1123 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
1124 double PSTAB = args.
scalar<
double>(
"PSTAB");
1125 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1126 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1127 xt::pyarray<double>& p_trial_ref = args.
array<
double>(
"p_trial_ref");
1128 xt::pyarray<double>& p_grad_trial_ref = args.
array<
double>(
"p_grad_trial_ref");
1129 xt::pyarray<double>& p_test_ref = args.
array<
double>(
"p_test_ref");
1130 xt::pyarray<double>& p_grad_test_ref = args.
array<
double>(
"p_grad_test_ref");
1131 xt::pyarray<double>& q_p = args.
array<
double>(
"q_p");
1132 xt::pyarray<double>& q_grad_p = args.
array<
double>(
"q_grad_p");
1133 xt::pyarray<double>& ebqe_p = args.
array<
double>(
"ebqe_p");
1134 xt::pyarray<double>& ebqe_grad_p = args.
array<
double>(
"ebqe_grad_p");
1135 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
1136 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
1137 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
1138 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
1139 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1140 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1141 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1142 xt::pyarray<double>& p_trial_trace_ref = args.
array<
double>(
"p_trial_trace_ref");
1143 xt::pyarray<double>& p_grad_trial_trace_ref = args.
array<
double>(
"p_grad_trial_trace_ref");
1144 xt::pyarray<double>& p_test_trace_ref = args.
array<
double>(
"p_test_trace_ref");
1145 xt::pyarray<double>& p_grad_test_trace_ref = args.
array<
double>(
"p_grad_test_trace_ref");
1146 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
1147 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
1148 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
1149 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
1150 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1151 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1152 double eb_adjoint_sigma = args.
scalar<
double>(
"eb_adjoint_sigma");
1153 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
1154 xt::pyarray<double>& nodeDiametersArray = args.
array<
double>(
"nodeDiametersArray");
1155 double hFactor = args.
scalar<
double>(
"hFactor");
1156 int nElements_global = args.
scalar<
int>(
"nElements_global");
1157 int nElementBoundaries_owned = args.
scalar<
int>(
"nElementBoundaries_owned");
1158 double useRBLES = args.
scalar<
double>(
"useRBLES");
1159 double useMetrics = args.
scalar<
double>(
"useMetrics");
1160 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
1161 double epsFact_rho = args.
scalar<
double>(
"epsFact_rho");
1162 double epsFact_mu = args.
scalar<
double>(
"epsFact_mu");
1163 double sigma = args.
scalar<
double>(
"sigma");
1168 double rho_s = args.
scalar<
double>(
"rho_s");
1169 double smagorinskyConstant = args.
scalar<
double>(
"smagorinskyConstant");
1170 int turbulenceClosureModel = args.
scalar<
int>(
"turbulenceClosureModel");
1171 double Ct_sge = args.
scalar<
double>(
"Ct_sge");
1172 double Cd_sge = args.
scalar<
double>(
"Cd_sge");
1173 double C_dc = args.
scalar<
double>(
"C_dc");
1174 double C_b = args.
scalar<
double>(
"C_b");
1175 const xt::pyarray<double>& eps_solid = args.
array<
double>(
"eps_solid");
1176 const xt::pyarray<double>& q_velocity_fluid = args.
array<
double>(
"q_velocity_fluid");
1177 const xt::pyarray<double>& q_velocityStar_fluid = args.
array<
double>(
"q_velocityStar_fluid");
1178 const xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
1179 const xt::pyarray<double>& q_dvos_dt = args.
array<
double>(
"q_dvos_dt");
1180 const xt::pyarray<double>& q_grad_vos = args.
array<
double>(
"q_grad_vos");
1181 const xt::pyarray<double>& q_dragAlpha = args.
array<
double>(
"q_dragAlpha");
1182 const xt::pyarray<double>& q_dragBeta = args.
array<
double>(
"q_dragBeta");
1183 const xt::pyarray<double>& q_mass_source = args.
array<
double>(
"q_mass_source");
1184 const xt::pyarray<double>& q_turb_var_0 = args.
array<
double>(
"q_turb_var_0");
1185 const xt::pyarray<double>& q_turb_var_1 = args.
array<
double>(
"q_turb_var_1");
1186 const xt::pyarray<double>& q_turb_var_grad_0 = args.
array<
double>(
"q_turb_var_grad_0");
1187 xt::pyarray<double>& q_eddy_viscosity = args.
array<
double>(
"q_eddy_viscosity");
1188 xt::pyarray<int>& p_l2g = args.
array<
int>(
"p_l2g");
1189 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
1190 xt::pyarray<double>& p_dof = args.
array<
double>(
"p_dof");
1191 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1192 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
1193 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
1194 xt::pyarray<double>& g = args.
array<
double>(
"g");
1195 const double useVF = args.
scalar<
double>(
"useVF");
1196 xt::pyarray<double>& vf = args.
array<
double>(
"vf");
1197 xt::pyarray<double>&
phi = args.
array<
double>(
"phi");
1198 xt::pyarray<double>& normal_phi = args.
array<
double>(
"normal_phi");
1199 xt::pyarray<double>& kappa_phi = args.
array<
double>(
"kappa_phi");
1200 xt::pyarray<double>& q_mom_u_acc = args.
array<
double>(
"q_mom_u_acc");
1201 xt::pyarray<double>& q_mom_v_acc = args.
array<
double>(
"q_mom_v_acc");
1202 xt::pyarray<double>& q_mom_w_acc = args.
array<
double>(
"q_mom_w_acc");
1203 xt::pyarray<double>& q_mass_adv = args.
array<
double>(
"q_mass_adv");
1204 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
1205 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
1206 xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.
array<
double>(
"q_mom_w_acc_beta_bdf");
1207 xt::pyarray<double>& q_dV = args.
array<
double>(
"q_dV");
1208 xt::pyarray<double>& q_dV_last = args.
array<
double>(
"q_dV_last");
1209 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
1210 xt::pyarray<double>& ebqe_velocity_star = args.
array<
double>(
"ebqe_velocity_star");
1211 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
1212 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
1213 xt::pyarray<double>& q_numDiff_v = args.
array<
double>(
"q_numDiff_v");
1214 xt::pyarray<double>& q_numDiff_w = args.
array<
double>(
"q_numDiff_w");
1215 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
1216 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
1217 xt::pyarray<double>& q_numDiff_w_last = args.
array<
double>(
"q_numDiff_w_last");
1218 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
1219 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
1220 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
1221 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
1222 xt::pyarray<int>& sdInfo_u_w_rowptr = args.
array<
int>(
"sdInfo_u_w_rowptr");
1223 xt::pyarray<int>& sdInfo_u_w_colind = args.
array<
int>(
"sdInfo_u_w_colind");
1224 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
1225 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
1226 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
1227 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
1228 xt::pyarray<int>& sdInfo_v_w_rowptr = args.
array<
int>(
"sdInfo_v_w_rowptr");
1229 xt::pyarray<int>& sdInfo_v_w_colind = args.
array<
int>(
"sdInfo_v_w_colind");
1230 xt::pyarray<int>& sdInfo_w_w_rowptr = args.
array<
int>(
"sdInfo_w_w_rowptr");
1231 xt::pyarray<int>& sdInfo_w_w_colind = args.
array<
int>(
"sdInfo_w_w_colind");
1232 xt::pyarray<int>& sdInfo_w_u_rowptr = args.
array<
int>(
"sdInfo_w_u_rowptr");
1233 xt::pyarray<int>& sdInfo_w_u_colind = args.
array<
int>(
"sdInfo_w_u_colind");
1234 xt::pyarray<int>& sdInfo_w_v_rowptr = args.
array<
int>(
"sdInfo_w_v_rowptr");
1235 xt::pyarray<int>& sdInfo_w_v_colind = args.
array<
int>(
"sdInfo_w_v_colind");
1236 int offset_p = args.
scalar<
int>(
"offset_p");
1237 int offset_u = args.
scalar<
int>(
"offset_u");
1238 int offset_v = args.
scalar<
int>(
"offset_v");
1239 int offset_w = args.
scalar<
int>(
"offset_w");
1240 int stride_p = args.
scalar<
int>(
"stride_p");
1241 int stride_u = args.
scalar<
int>(
"stride_u");
1242 int stride_v = args.
scalar<
int>(
"stride_v");
1243 int stride_w = args.
scalar<
int>(
"stride_w");
1244 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
1245 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1246 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1247 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1248 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1249 xt::pyarray<double>& ebqe_vf_ext = args.
array<
double>(
"ebqe_vf_ext");
1250 xt::pyarray<double>& bc_ebqe_vf_ext = args.
array<
double>(
"bc_ebqe_vf_ext");
1251 xt::pyarray<double>& ebqe_phi_ext = args.
array<
double>(
"ebqe_phi_ext");
1252 xt::pyarray<double>& bc_ebqe_phi_ext = args.
array<
double>(
"bc_ebqe_phi_ext");
1253 xt::pyarray<double>& ebqe_normal_phi_ext = args.
array<
double>(
"ebqe_normal_phi_ext");
1254 xt::pyarray<double>& ebqe_kappa_phi_ext = args.
array<
double>(
"ebqe_kappa_phi_ext");
1255 const xt::pyarray<double>& ebqe_vos_ext = args.
array<
double>(
"ebqe_vos_ext");
1256 const xt::pyarray<double>& ebqe_turb_var_0 = args.
array<
double>(
"ebqe_turb_var_0");
1257 const xt::pyarray<double>& ebqe_turb_var_1 = args.
array<
double>(
"ebqe_turb_var_1");
1258 xt::pyarray<int>& isDOFBoundary_p = args.
array<
int>(
"isDOFBoundary_p");
1259 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1260 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
1261 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
1262 xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.
array<
int>(
"isAdvectiveFluxBoundary_p");
1263 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
1264 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
1265 xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.
array<
int>(
"isAdvectiveFluxBoundary_w");
1266 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
1267 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
1268 xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.
array<
int>(
"isDiffusiveFluxBoundary_w");
1269 xt::pyarray<double>& ebqe_bc_p_ext = args.
array<
double>(
"ebqe_bc_p_ext");
1270 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
1271 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
1272 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
1273 xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_w_adv_ext");
1274 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
1275 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
1276 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
1277 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
1278 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
1279 xt::pyarray<double>& ebqe_bc_w_ext = args.
array<
double>(
"ebqe_bc_w_ext");
1280 xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.
array<
double>(
"ebqe_bc_flux_w_diff_ext");
1281 xt::pyarray<double>& q_x = args.
array<
double>(
"q_x");
1282 xt::pyarray<double>& q_velocity = args.
array<
double>(
"q_velocity");
1283 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
1284 xt::pyarray<double>& flux = args.
array<
double>(
"flux");
1285 xt::pyarray<double>& elementResidual_p_save = args.
array<
double>(
"elementResidual_p_save");
1286 xt::pyarray<int>& elementFlags = args.
array<
int>(
"elementFlags");
1287 xt::pyarray<int>& boundaryFlags = args.
array<
int>(
"boundaryFlags");
1288 xt::pyarray<double>& barycenters = args.
array<
double>(
"barycenters");
1289 xt::pyarray<double>& wettedAreas = args.
array<
double>(
"wettedAreas");
1290 xt::pyarray<double>& netForces_p = args.
array<
double>(
"netForces_p");
1291 xt::pyarray<double>& netForces_v = args.
array<
double>(
"netForces_v");
1292 xt::pyarray<double>& netMoments = args.
array<
double>(
"netMoments");
1293 xt::pyarray<double>& ncDrag = args.
array<
double>(
"ncDrag");
1294 double LAG_MU_FR = args.
scalar<
double>(
"LAG_MU_FR");
1295 xt::pyarray<double>& q_mu_fr_last = args.
array<
double>(
"q_mu_fr_last");
1296 xt::pyarray<double>& q_mu_fr = args.
array<
double>(
"q_mu_fr");
1300 for(
int eN=0;eN<nElements_global;eN++)
1303 register double elementResidual_u[nDOF_test_element],
1304 elementResidual_v[nDOF_test_element],
1306 mom_u_source_i[nDOF_test_element],
1307 mom_v_source_i[nDOF_test_element],
1309 double mesh_volume_conservation_element=0.0;
1310 for (
int i=0;i<nDOF_test_element;i++)
1312 int eN_i = eN*nDOF_test_element+i;
1313 elementResidual_p_save[eN_i]=0.0;
1314 elementResidual_u[i]=0.0;
1315 elementResidual_v[i]=0.0;
1317 mom_u_source_i[i]=0.0;
1318 mom_v_source_i[i]=0.0;
1323 for(
int k=0;k<nQuadraturePoints_element;k++)
1326 register int eN_k = eN*nQuadraturePoints_element+k,
1327 eN_k_nSpace = eN_k*nSpace,
1329 eN_nDOF_trial_element = eN*nDOF_trial_element;
1330 register double p=0.0,
u=0.0,
v=0.0,
w=0.0,
1331 grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],grad_vos[nSpace],
1339 dmass_adv_u[nSpace],
1340 dmass_adv_v[nSpace],
1341 dmass_adv_w[nSpace],
1343 dmom_u_adv_u[nSpace],
1344 dmom_u_adv_v[nSpace],
1345 dmom_u_adv_w[nSpace],
1347 dmom_v_adv_u[nSpace],
1348 dmom_v_adv_v[nSpace],
1349 dmom_v_adv_w[nSpace],
1351 dmom_w_adv_u[nSpace],
1352 dmom_w_adv_v[nSpace],
1353 dmom_w_adv_w[nSpace],
1354 mom_uu_diff_ten[nSpace],
1355 mom_vv_diff_ten[nSpace],
1356 mom_ww_diff_ten[nSpace],
1367 dmom_u_ham_grad_p[nSpace],
1368 dmom_u_ham_grad_u[nSpace],
1370 dmom_v_ham_grad_p[nSpace],
1371 dmom_v_ham_grad_v[nSpace],
1373 dmom_w_ham_grad_p[nSpace],
1374 dmom_w_ham_grad_w[nSpace],
1383 Lstar_u_u[nDOF_test_element],
1384 Lstar_v_v[nDOF_test_element],
1389 tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
1390 tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
1393 jacInv[nSpace*nSpace],
1394 vel_grad_trial[nDOF_trial_element*nSpace],
1395 vel_test_dV[nDOF_trial_element],
1396 vel_grad_test_dV[nDOF_test_element*nSpace],
1402 dmom_u_source[nSpace],
1403 dmom_v_source[nSpace],
1404 dmom_w_source[nSpace],
1406 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv,h_phi, dmom_adv_star[nSpace],dmom_adv_sge[nSpace];
1408 ck.calculateMapping_element(eN,
1412 mesh_trial_ref.data(),
1413 mesh_grad_trial_ref.data(),
1418 ck.calculateH_element(eN,
1420 nodeDiametersArray.data(),
1422 mesh_trial_ref.data(),
1424 ck.calculateMappingVelocity_element(eN,
1426 mesh_velocity_dof.data(),
1428 mesh_trial_ref.data(),
1433 dV = fabs(jacDet)*dV_ref.data()[k];
1434 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1437 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
1438 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
1442 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
1445 p = q_p.data()[eN_k];
1446 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
1447 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
1451 for (
int I=0;I<nSpace;I++)
1452 grad_p[I] = q_grad_p.data()[eN_k_nSpace + I];
1453 for (
int I=0;I<nSpace;I++)
1454 grad_vos[I] = q_grad_vos.data()[eN_k_nSpace + I];
1455 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
1456 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
1459 vos = q_vos.data()[eN_k];
1461 for (
int j=0;j<nDOF_trial_element;j++)
1464 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
1465 for (
int I=0;I<nSpace;I++)
1468 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
1472 double div_mesh_velocity=0.0;
1473 int NDOF_MESH_TRIAL_ELEMENT=3;
1474 for (
int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
1476 int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
1477 div_mesh_velocity +=
1478 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+0]*vel_grad_trial[j*nSpace+0] +
1479 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+1]*vel_grad_trial[j*nSpace+1];
1481 mesh_volume_conservation_element += (alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity)*dV;
1482 div_mesh_velocity =
DM3*div_mesh_velocity + (1.0-
DM3)*alphaBDF*(dV-q_dV_last.data()[eN_k])/dV;
1486 q_x.data()[eN_k_3d+0]=x;
1487 q_x.data()[eN_k_3d+1]=y;
1500 elementDiameter.data()[eN],
1501 smagorinskyConstant,
1502 turbulenceClosureModel,
1507 &normal_phi.data()[eN_k_nSpace],
1508 kappa_phi.data()[eN_k],
1520 q_velocity_sge.data()[eN_k_nSpace+0],
1521 q_velocity_sge.data()[eN_k_nSpace+1],
1522 q_velocity_sge.data()[eN_k_nSpace+1],
1523 q_eddy_viscosity.data()[eN_k],
1568 mass_source = q_mass_source.data()[eN_k];
1569 for (
int I=0;I<nSpace;I++)
1571 dmom_u_source[I] = 0.0;
1572 dmom_v_source[I] = 0.0;
1573 dmom_w_source[I] = 0.0;
1579 q_dragAlpha.data()[eN_k],
1580 q_dragBeta.data()[eN_k],
1587 q_eddy_viscosity.data()[eN_k],
1594 q_velocity_sge.data()[eN_k_nSpace+0],
1595 q_velocity_sge.data()[eN_k_nSpace+1],
1596 q_velocity_sge.data()[eN_k_nSpace+1],
1597 eps_solid.data()[elementFlags.data()[eN]],
1599 q_velocity_fluid.data()[eN_k_nSpace+0],
1600 q_velocity_fluid.data()[eN_k_nSpace+1],
1601 q_velocity_fluid.data()[eN_k_nSpace+1],
1602 q_velocityStar_fluid.data()[eN_k_nSpace+0],
1603 q_velocityStar_fluid.data()[eN_k_nSpace+1],
1604 q_velocityStar_fluid.data()[eN_k_nSpace+1],
1611 q_grad_vos.data()[eN_k_nSpace+0],
1612 q_grad_vos.data()[eN_k_nSpace+1],
1613 q_grad_vos.data()[eN_k_nSpace+1]);
1621 q_mu_fr_last.data()[eN_k],
1622 q_mu_fr.data()[eN_k],
1650 q_mom_u_acc.data()[eN_k] = mom_u_acc;
1651 q_mom_v_acc.data()[eN_k] = mom_v_acc;
1654 q_mass_adv.data()[eN_k_nSpace+0] =
u;
1655 q_mass_adv.data()[eN_k_nSpace+1] =
v;
1660 mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*
xt;
1661 mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
1663 dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*
xt;
1664 dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
1667 mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*
xt;
1668 mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
1670 dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*
xt;
1671 dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
1683 if (q_dV_last.data()[eN_k] <= -100)
1684 q_dV_last.data()[eN_k] = dV;
1685 q_dV.data()[eN_k] = dV;
1687 q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
1693 q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
1707 mom_u_acc_t *= dmom_u_acc_u;
1708 mom_v_acc_t *= dmom_v_acc_v;
1714 ck.Mass_strong(q_dvos_dt.data()[eN_k]) +
1715 ck.Advection_strong(dmass_adv_u,grad_u) +
1716 ck.Advection_strong(dmass_adv_v,grad_v) +
1718 DM2*MOVING_DOMAIN*
ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) +
1720 ck.Reaction_strong(mass_source);
1723 dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt);
1724 dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
1728 ck.Mass_strong(mom_u_acc_t) +
1729 ck.Advection_strong(dmom_adv_sge,grad_u) +
1730 ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
1731 ck.Reaction_strong(mom_u_source) -
1732 ck.Reaction_strong(
u*div_mesh_velocity);
1735 ck.Mass_strong(mom_v_acc_t) +
1736 ck.Advection_strong(dmom_adv_sge,grad_v) +
1737 ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
1738 ck.Reaction_strong(mom_v_source) -
1739 ck.Reaction_strong(
v*div_mesh_velocity);
1749 double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
1751 elementDiameter.data()[eN],
1756 dmom_u_ham_grad_p[0],
1759 q_cfl.data()[eN_k]);
1766 dmom_u_ham_grad_p[0],
1769 q_cfl.data()[eN_k]);
1771 tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
1772 tau_p = PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
1785 dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt + useRBLES*subgridError_u);
1786 dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
1789 mom_u_adv[0] += dmom_u_acc_u*(useRBLES*subgridError_u*q_velocity_sge.data()[eN_k_nSpace+0]);
1790 mom_u_adv[1] += dmom_u_acc_u*(useRBLES*subgridError_v*q_velocity_sge.data()[eN_k_nSpace+0]);
1794 for (
int i=0;i<nDOF_test_element;i++)
1796 register int i_nSpace = i*nSpace;
1801 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
1802 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
1807 Lstar_u_u[i]+=
ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
1808 Lstar_v_v[i]+=
ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
1813 norm_Rv = sqrt(pdeResidual_u*pdeResidual_u + pdeResidual_v*pdeResidual_v);
1814 q_numDiff_u.data()[eN_k] = C_dc*norm_Rv*(useMetrics/sqrt(G_dd_G+1.0e-12) +
1815 (1.0-useMetrics)*hFactor*hFactor*elementDiameter.data()[eN]*elementDiameter.data()[eN]);
1816 q_numDiff_v.data()[eN_k] = q_numDiff_u.data()[eN_k];
1817 q_numDiff_w.data()[eN_k] = q_numDiff_u.data()[eN_k];
1819 q_velocity.data()[eN_k_nSpace+0]=
u;
1820 q_velocity.data()[eN_k_nSpace+1]=
v;
1822 for(
int i=0;i<nDOF_test_element;i++)
1824 register int i_nSpace=i*nSpace;
1842 elementResidual_u[i] +=
1843 ck.Mass_weak(mom_u_acc_t,vel_test_dV[i]) +
1844 ck.Advection_weak(mom_u_adv,&vel_grad_test_dV[i_nSpace]) +
1845 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]) +
1846 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]) +
1848 ck.Reaction_weak(mom_u_source,vel_test_dV[i]) +
1849 ck.Hamiltonian_weak(mom_u_ham,vel_test_dV[i]) +
1851 ck.SubgridError(subgridError_u,Lstar_u_u[i]) +
1852 ck.NumericalDiffusion(q_numDiff_u_last.data()[eN_k],grad_u,&vel_grad_test_dV[i_nSpace]);
1853 mom_u_source_i[i] +=
ck.Reaction_weak(mom_u_source,vel_test_dV[i]);
1855 elementResidual_v[i] +=
1856 ck.Mass_weak(mom_v_acc_t,vel_test_dV[i]) +
1857 ck.Advection_weak(mom_v_adv,&vel_grad_test_dV[i_nSpace]) +
1858 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]) +
1859 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]) +
1861 ck.Reaction_weak(mom_v_source,vel_test_dV[i]) +
1862 ck.Hamiltonian_weak(mom_v_ham,vel_test_dV[i]) +
1864 ck.SubgridError(subgridError_v,Lstar_v_v[i]) +
1865 ck.NumericalDiffusion(q_numDiff_v_last.data()[eN_k],grad_v,&vel_grad_test_dV[i_nSpace]);
1866 mom_v_source_i[i] +=
ck.Reaction_weak(mom_v_source,vel_test_dV[i]);
1884 for(
int i=0;i<nDOF_test_element;i++)
1886 register int eN_i=eN*nDOF_test_element+i;
1891 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
1892 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
1893 ncDrag.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=mom_u_source_i[i];
1894 ncDrag.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=mom_v_source_i[i];
1908 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1910 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
1911 eN = elementBoundaryElementsArray.data()[ebN*2+0],
1912 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
1913 eN_nDOF_trial_element = eN*nDOF_trial_element;
1914 register double elementResidual_u[nDOF_test_element],
1915 elementResidual_v[nDOF_test_element],
1918 for (
int i=0;i<nDOF_test_element;i++)
1920 elementResidual_u[i]=0.0;
1921 elementResidual_v[i]=0.0;
1924 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1926 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1927 ebNE_kb_nSpace = ebNE_kb*nSpace,
1928 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1929 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1930 register double p_ext=0.0,
1939 dmom_u_acc_u_ext=0.0,
1941 dmom_v_acc_v_ext=0.0,
1943 dmom_w_acc_w_ext=0.0,
1944 mass_adv_ext[nSpace],
1945 dmass_adv_u_ext[nSpace],
1946 dmass_adv_v_ext[nSpace],
1947 dmass_adv_w_ext[nSpace],
1948 mom_u_adv_ext[nSpace],
1949 dmom_u_adv_u_ext[nSpace],
1950 dmom_u_adv_v_ext[nSpace],
1951 dmom_u_adv_w_ext[nSpace],
1952 mom_v_adv_ext[nSpace],
1953 dmom_v_adv_u_ext[nSpace],
1954 dmom_v_adv_v_ext[nSpace],
1955 dmom_v_adv_w_ext[nSpace],
1956 mom_w_adv_ext[nSpace],
1957 dmom_w_adv_u_ext[nSpace],
1958 dmom_w_adv_v_ext[nSpace],
1959 dmom_w_adv_w_ext[nSpace],
1960 mom_uu_diff_ten_ext[nSpace],
1961 mom_vv_diff_ten_ext[nSpace],
1962 mom_ww_diff_ten_ext[nSpace],
1963 mom_uv_diff_ten_ext[1],
1964 mom_uw_diff_ten_ext[1],
1965 mom_vu_diff_ten_ext[1],
1966 mom_vw_diff_ten_ext[1],
1967 mom_wu_diff_ten_ext[1],
1968 mom_wv_diff_ten_ext[1],
1969 mom_u_source_ext=0.0,
1970 mom_v_source_ext=0.0,
1971 mom_w_source_ext=0.0,
1973 dmom_u_ham_grad_p_ext[nSpace],
1974 dmom_u_ham_grad_u_ext[nSpace],
1976 dmom_v_ham_grad_p_ext[nSpace],
1977 dmom_v_ham_grad_v_ext[nSpace],
1979 dmom_w_ham_grad_p_ext[nSpace],
1980 dmom_w_ham_grad_w_ext[nSpace],
1981 dmom_u_adv_p_ext[nSpace],
1982 dmom_v_adv_p_ext[nSpace],
1983 dmom_w_adv_p_ext[nSpace],
1985 flux_mom_u_adv_ext=0.0,
1986 flux_mom_v_adv_ext=0.0,
1987 flux_mom_w_adv_ext=0.0,
1988 flux_mom_uu_diff_ext=0.0,
1989 flux_mom_uv_diff_ext=0.0,
1990 flux_mom_uw_diff_ext=0.0,
1991 flux_mom_vu_diff_ext=0.0,
1992 flux_mom_vv_diff_ext=0.0,
1993 flux_mom_vw_diff_ext=0.0,
1998 bc_mom_u_acc_ext=0.0,
1999 bc_dmom_u_acc_u_ext=0.0,
2000 bc_mom_v_acc_ext=0.0,
2001 bc_dmom_v_acc_v_ext=0.0,
2002 bc_mom_w_acc_ext=0.0,
2003 bc_dmom_w_acc_w_ext=0.0,
2004 bc_mass_adv_ext[nSpace],
2005 bc_dmass_adv_u_ext[nSpace],
2006 bc_dmass_adv_v_ext[nSpace],
2007 bc_dmass_adv_w_ext[nSpace],
2008 bc_mom_u_adv_ext[nSpace],
2009 bc_dmom_u_adv_u_ext[nSpace],
2010 bc_dmom_u_adv_v_ext[nSpace],
2011 bc_dmom_u_adv_w_ext[nSpace],
2012 bc_mom_v_adv_ext[nSpace],
2013 bc_dmom_v_adv_u_ext[nSpace],
2014 bc_dmom_v_adv_v_ext[nSpace],
2015 bc_dmom_v_adv_w_ext[nSpace],
2016 bc_mom_w_adv_ext[nSpace],
2017 bc_dmom_w_adv_u_ext[nSpace],
2018 bc_dmom_w_adv_v_ext[nSpace],
2019 bc_dmom_w_adv_w_ext[nSpace],
2020 bc_mom_uu_diff_ten_ext[nSpace],
2021 bc_mom_vv_diff_ten_ext[nSpace],
2022 bc_mom_ww_diff_ten_ext[nSpace],
2023 bc_mom_uv_diff_ten_ext[1],
2024 bc_mom_uw_diff_ten_ext[1],
2025 bc_mom_vu_diff_ten_ext[1],
2026 bc_mom_vw_diff_ten_ext[1],
2027 bc_mom_wu_diff_ten_ext[1],
2028 bc_mom_wv_diff_ten_ext[1],
2029 bc_mom_u_source_ext=0.0,
2030 bc_mom_v_source_ext=0.0,
2031 bc_mom_w_source_ext=0.0,
2032 bc_mom_u_ham_ext=0.0,
2033 bc_dmom_u_ham_grad_p_ext[nSpace],
2034 bc_dmom_u_ham_grad_u_ext[nSpace],
2035 bc_mom_v_ham_ext=0.0,
2036 bc_dmom_v_ham_grad_p_ext[nSpace],
2037 bc_dmom_v_ham_grad_v_ext[nSpace],
2038 bc_mom_w_ham_ext=0.0,
2039 bc_dmom_w_ham_grad_p_ext[nSpace],
2040 bc_dmom_w_ham_grad_w_ext[nSpace],
2041 jac_ext[nSpace*nSpace],
2043 jacInv_ext[nSpace*nSpace],
2044 boundaryJac[nSpace*(nSpace-1)],
2045 metricTensor[(nSpace-1)*(nSpace-1)],
2046 metricTensorDetSqrt,
2047 dS,vel_test_dS[nDOF_test_element],
2048 vel_grad_trial_trace[nDOF_trial_element*nSpace],
2049 vel_grad_test_dS[nDOF_trial_element*nSpace],
2050 normal[2],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
2054 G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty,
2055 force_x,force_y,force_p_x,force_p_y,force_v_x,force_v_y,r_x,r_y;
2057 ck.calculateMapping_elementBoundary(eN,
2063 mesh_trial_trace_ref.data(),
2064 mesh_grad_trial_trace_ref.data(),
2065 boundaryJac_ref.data(),
2071 metricTensorDetSqrt,
2075 ck.calculateMappingVelocity_elementBoundary(eN,
2079 mesh_velocity_dof.data(),
2081 mesh_trial_trace_ref.data(),
2082 xt_ext,yt_ext,zt_ext,
2094 dS = metricTensorDetSqrt*dS_ref.data()[kb];
2097 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
2098 ck.calculateGScale(G,&ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],h_phi);
2100 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
2101 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
2106 ck.gradTrialFromRef(&vel_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
2110 p_ext = ebqe_p.data()[ebNE_kb];
2111 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);
2112 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);
2115 for (
int I=0;I<nSpace;I++)
2116 grad_p_ext[I] = ebqe_grad_p.data()[ebNE_kb_nSpace + I];
2117 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
2118 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
2121 for (
int j=0;j<nDOF_trial_element;j++)
2124 vel_test_dS[j] = vel_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
2125 for (
int I=0;I<nSpace;I++)
2126 vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;
2128 bc_p_ext = isDOFBoundary_p.data()[ebNE_kb]*ebqe_bc_p_ext.data()[ebNE_kb]+(1-isDOFBoundary_p.data()[ebNE_kb])*p_ext;
2130 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;
2131 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;
2134 vos_ext = ebqe_vos_ext.data()[ebNE_kb];
2139 double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.);
2148 elementDiameter.data()[eN],
2149 smagorinskyConstant,
2150 turbulenceClosureModel,
2153 ebqe_vf_ext.data()[ebNE_kb],
2154 ebqe_phi_ext.data()[ebNE_kb],
2155 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
2156 ebqe_kappa_phi_ext.data()[ebNE_kb],
2168 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
2169 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2170 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2194 mom_uu_diff_ten_ext,
2195 mom_vv_diff_ten_ext,
2196 mom_ww_diff_ten_ext,
2197 mom_uv_diff_ten_ext,
2198 mom_uw_diff_ten_ext,
2199 mom_vu_diff_ten_ext,
2200 mom_vw_diff_ten_ext,
2201 mom_wu_diff_ten_ext,
2202 mom_wv_diff_ten_ext,
2207 dmom_u_ham_grad_p_ext,
2208 dmom_u_ham_grad_u_ext,
2210 dmom_v_ham_grad_p_ext,
2211 dmom_v_ham_grad_v_ext,
2213 dmom_w_ham_grad_p_ext,
2214 dmom_w_ham_grad_w_ext);
2223 elementDiameter.data()[eN],
2224 smagorinskyConstant,
2225 turbulenceClosureModel,
2228 bc_ebqe_vf_ext.data()[ebNE_kb],
2229 bc_ebqe_phi_ext.data()[ebNE_kb],
2230 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
2231 ebqe_kappa_phi_ext.data()[ebNE_kb],
2243 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
2244 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2245 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
2246 bc_eddy_viscosity_ext,
2248 bc_dmom_u_acc_u_ext,
2250 bc_dmom_v_acc_v_ext,
2252 bc_dmom_w_acc_w_ext,
2258 bc_dmom_u_adv_u_ext,
2259 bc_dmom_u_adv_v_ext,
2260 bc_dmom_u_adv_w_ext,
2262 bc_dmom_v_adv_u_ext,
2263 bc_dmom_v_adv_v_ext,
2264 bc_dmom_v_adv_w_ext,
2266 bc_dmom_w_adv_u_ext,
2267 bc_dmom_w_adv_v_ext,
2268 bc_dmom_w_adv_w_ext,
2269 bc_mom_uu_diff_ten_ext,
2270 bc_mom_vv_diff_ten_ext,
2271 bc_mom_ww_diff_ten_ext,
2272 bc_mom_uv_diff_ten_ext,
2273 bc_mom_uw_diff_ten_ext,
2274 bc_mom_vu_diff_ten_ext,
2275 bc_mom_vw_diff_ten_ext,
2276 bc_mom_wu_diff_ten_ext,
2277 bc_mom_wv_diff_ten_ext,
2278 bc_mom_u_source_ext,
2279 bc_mom_v_source_ext,
2280 bc_mom_w_source_ext,
2282 bc_dmom_u_ham_grad_p_ext,
2283 bc_dmom_u_ham_grad_u_ext,
2285 bc_dmom_v_ham_grad_p_ext,
2286 bc_dmom_v_ham_grad_v_ext,
2288 bc_dmom_w_ham_grad_p_ext,
2289 bc_dmom_w_ham_grad_w_ext);
2296 mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext;
2297 mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
2299 dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
2300 dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
2303 mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
2304 mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
2306 dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
2307 dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
2319 bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext;
2320 bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
2323 bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
2324 bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
2333 ck.calculateGScale(G,normal,h_penalty);
2334 penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb];
2336 isDOFBoundary_u.data()[ebNE_kb],
2337 isDOFBoundary_v.data()[ebNE_kb],
2338 isDOFBoundary_w.data()[ebNE_kb],
2339 isAdvectiveFluxBoundary_p.data()[ebNE_kb],
2340 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
2341 isAdvectiveFluxBoundary_v.data()[ebNE_kb],
2342 isAdvectiveFluxBoundary_w.data()[ebNE_kb],
2343 dmom_u_ham_grad_p_ext[0],
2344 bc_dmom_u_ham_grad_p_ext[0],
2355 ebqe_bc_flux_mass_ext.data()[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),
2356 ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb],
2357 ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb],
2358 ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb],
2386 &ebqe_velocity_star.data()[ebNE_kb_nSpace],
2387 &ebqe_velocity.data()[ebNE_kb_nSpace]);
2389 ebqe_phi_ext.data()[ebNE_kb],
2390 sdInfo_u_u_rowptr.data(),
2391 sdInfo_u_u_colind.data(),
2392 isDOFBoundary_u.data()[ebNE_kb],
2393 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2395 bc_mom_uu_diff_ten_ext,
2397 ebqe_bc_flux_u_diff_ext.data()[ebNE_kb],
2398 mom_uu_diff_ten_ext,
2402 flux_mom_uu_diff_ext);
2404 ebqe_phi_ext.data()[ebNE_kb],
2405 sdInfo_u_v_rowptr.data(),
2406 sdInfo_u_v_colind.data(),
2407 isDOFBoundary_v.data()[ebNE_kb],
2408 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2410 bc_mom_uv_diff_ten_ext,
2413 mom_uv_diff_ten_ext,
2417 flux_mom_uv_diff_ext);
2434 ebqe_phi_ext.data()[ebNE_kb],
2435 sdInfo_v_u_rowptr.data(),
2436 sdInfo_v_u_colind.data(),
2437 isDOFBoundary_u.data()[ebNE_kb],
2438 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2440 bc_mom_vu_diff_ten_ext,
2443 mom_vu_diff_ten_ext,
2447 flux_mom_vu_diff_ext);
2449 ebqe_phi_ext.data()[ebNE_kb],
2450 sdInfo_v_v_rowptr.data(),
2451 sdInfo_v_v_colind.data(),
2452 isDOFBoundary_v.data()[ebNE_kb],
2453 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2455 bc_mom_vv_diff_ten_ext,
2457 ebqe_bc_flux_v_diff_ext.data()[ebNE_kb],
2458 mom_vv_diff_ten_ext,
2462 flux_mom_vv_diff_ext);
2523 flux.data()[ebN*nQuadraturePoints_elementBoundary+kb] = flux_mass_ext;
2531 if (ebN < nElementBoundaries_owned)
2533 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];
2534 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];
2537 force_p_x = p_ext*normal[0];
2538 force_p_y = p_ext*normal[1];
2541 force_x = force_p_x + force_v_x;
2542 force_y = force_p_y + force_v_y;
2545 r_x = x_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+0];
2546 r_y = y_ext - barycenters.data()[3*boundaryFlags.data()[ebN]+1];
2549 wettedAreas.data()[boundaryFlags.data()[ebN]] += dS*(1.0-ebqe_vf_ext.data()[ebNE_kb]);
2551 netForces_p.data()[3*boundaryFlags.data()[ebN]+0] += force_p_x*dS;
2552 netForces_p.data()[3*boundaryFlags.data()[ebN]+1] += force_p_y*dS;
2555 netForces_v.data()[3*boundaryFlags.data()[ebN]+0] += force_v_x*dS;
2556 netForces_v.data()[3*boundaryFlags.data()[ebN]+1] += force_v_y*dS;
2561 netMoments.data()[3*boundaryFlags.data()[ebN]+2] += (r_x*force_y - r_y*force_x)*dS;
2566 for (
int i=0;i<nDOF_test_element;i++)
2572 elementResidual_u[i] +=
2573 ck.ExteriorElementBoundaryFlux(flux_mom_u_adv_ext,vel_test_dS[i])+
2574 ck.ExteriorElementBoundaryFlux(flux_mom_uu_diff_ext,vel_test_dS[i])+
2575 ck.ExteriorElementBoundaryFlux(flux_mom_uv_diff_ext,vel_test_dS[i])+
2576 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb],
2577 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2582 sdInfo_u_u_rowptr.data(),
2583 sdInfo_u_u_colind.data(),
2584 mom_uu_diff_ten_ext,
2585 &vel_grad_test_dS[i*nSpace])+
2586 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb],
2587 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
2592 sdInfo_u_v_rowptr.data(),
2593 sdInfo_u_v_colind.data(),
2594 mom_uv_diff_ten_ext,
2595 &vel_grad_test_dS[i*nSpace]);
2606 elementResidual_v[i] +=
ck.ExteriorElementBoundaryFlux(flux_mom_v_adv_ext,vel_test_dS[i]) +
2607 ck.ExteriorElementBoundaryFlux(flux_mom_vu_diff_ext,vel_test_dS[i])+
2608 ck.ExteriorElementBoundaryFlux(flux_mom_vv_diff_ext,vel_test_dS[i])+
2609 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_u.data()[ebNE_kb],
2610 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2615 sdInfo_v_u_rowptr.data(),
2616 sdInfo_v_u_colind.data(),
2617 mom_vu_diff_ten_ext,
2618 &vel_grad_test_dS[i*nSpace])+
2619 ck.ExteriorElementBoundaryDiffusionAdjoint(isDOFBoundary_v.data()[ebNE_kb],
2620 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
2625 sdInfo_v_v_rowptr.data(),
2626 sdInfo_v_v_colind.data(),
2627 mom_vv_diff_ten_ext,
2628 &vel_grad_test_dS[i*nSpace]);
2679 for (
int i=0;i<nDOF_test_element;i++)
2681 int eN_i = eN*nDOF_test_element+i;
2686 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
2687 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
2699 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2700 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
2701 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
2702 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
2703 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
2704 double PSTAB = args.
scalar<
double>(
"PSTAB");
2705 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
2706 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
2707 xt::pyarray<double>& p_trial_ref = args.
array<
double>(
"p_trial_ref");
2708 xt::pyarray<double>& p_grad_trial_ref = args.
array<
double>(
"p_grad_trial_ref");
2709 xt::pyarray<double>& p_test_ref = args.
array<
double>(
"p_test_ref");
2710 xt::pyarray<double>& p_grad_test_ref = args.
array<
double>(
"p_grad_test_ref");
2711 xt::pyarray<double>& q_p = args.
array<
double>(
"q_p");
2712 xt::pyarray<double>& q_grad_p = args.
array<
double>(
"q_grad_p");
2713 xt::pyarray<double>& ebqe_p = args.
array<
double>(
"ebqe_p");
2714 xt::pyarray<double>& ebqe_grad_p = args.
array<
double>(
"ebqe_grad_p");
2715 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2716 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
2717 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
2718 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
2719 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
2720 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
2721 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
2722 xt::pyarray<double>& p_trial_trace_ref = args.
array<
double>(
"p_trial_trace_ref");
2723 xt::pyarray<double>& p_grad_trial_trace_ref = args.
array<
double>(
"p_grad_trial_trace_ref");
2724 xt::pyarray<double>& p_test_trace_ref = args.
array<
double>(
"p_test_trace_ref");
2725 xt::pyarray<double>& p_grad_test_trace_ref = args.
array<
double>(
"p_grad_test_trace_ref");
2726 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
2727 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
2728 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
2729 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
2730 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
2731 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
2732 double eb_adjoint_sigma = args.
scalar<
double>(
"eb_adjoint_sigma");
2733 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
2734 xt::pyarray<double>& nodeDiametersArray = args.
array<
double>(
"nodeDiametersArray");
2735 double hFactor = args.
scalar<
double>(
"hFactor");
2736 int nElements_global = args.
scalar<
int>(
"nElements_global");
2737 double useRBLES = args.
scalar<
double>(
"useRBLES");
2738 double useMetrics = args.
scalar<
double>(
"useMetrics");
2739 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
2740 double epsFact_rho = args.
scalar<
double>(
"epsFact_rho");
2741 double epsFact_mu = args.
scalar<
double>(
"epsFact_mu");
2742 double sigma = args.
scalar<
double>(
"sigma");
2747 double rho_s = args.
scalar<
double>(
"rho_s");
2748 double smagorinskyConstant = args.
scalar<
double>(
"smagorinskyConstant");
2749 int turbulenceClosureModel = args.
scalar<
int>(
"turbulenceClosureModel");
2750 double Ct_sge = args.
scalar<
double>(
"Ct_sge");
2751 double Cd_sge = args.
scalar<
double>(
"Cd_sge");
2752 double C_dg = args.
scalar<
double>(
"C_dg");
2753 double C_b = args.
scalar<
double>(
"C_b");
2754 const xt::pyarray<double>& eps_solid = args.
array<
double>(
"eps_solid");
2755 const xt::pyarray<double>& q_velocity_fluid = args.
array<
double>(
"q_velocity_fluid");
2756 const xt::pyarray<double>& q_velocityStar_fluid = args.
array<
double>(
"q_velocityStar_fluid");
2757 const xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
2758 const xt::pyarray<double>& q_dvos_dt = args.
array<
double>(
"q_dvos_dt");
2759 const xt::pyarray<double>& q_grad_vos = args.
array<
double>(
"q_grad_vos");
2760 const xt::pyarray<double>& q_dragAlpha = args.
array<
double>(
"q_dragAlpha");
2761 const xt::pyarray<double>& q_dragBeta = args.
array<
double>(
"q_dragBeta");
2762 const xt::pyarray<double>& q_mass_source = args.
array<
double>(
"q_mass_source");
2763 const xt::pyarray<double>& q_turb_var_0 = args.
array<
double>(
"q_turb_var_0");
2764 const xt::pyarray<double>& q_turb_var_1 = args.
array<
double>(
"q_turb_var_1");
2765 const xt::pyarray<double>& q_turb_var_grad_0 = args.
array<
double>(
"q_turb_var_grad_0");
2766 xt::pyarray<int>& p_l2g = args.
array<
int>(
"p_l2g");
2767 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
2768 xt::pyarray<double>& p_dof = args.
array<
double>(
"p_dof");
2769 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
2770 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
2771 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
2772 xt::pyarray<double>& g = args.
array<
double>(
"g");
2773 const double useVF = args.
scalar<
double>(
"useVF");
2774 xt::pyarray<double>& vf = args.
array<
double>(
"vf");
2775 xt::pyarray<double>&
phi = args.
array<
double>(
"phi");
2776 xt::pyarray<double>& normal_phi = args.
array<
double>(
"normal_phi");
2777 xt::pyarray<double>& kappa_phi = args.
array<
double>(
"kappa_phi");
2778 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
2779 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
2780 xt::pyarray<double>& q_mom_w_acc_beta_bdf = args.
array<
double>(
"q_mom_w_acc_beta_bdf");
2781 xt::pyarray<double>& q_dV = args.
array<
double>(
"q_dV");
2782 xt::pyarray<double>& q_dV_last = args.
array<
double>(
"q_dV_last");
2783 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
2784 xt::pyarray<double>& ebqe_velocity_star = args.
array<
double>(
"ebqe_velocity_star");
2785 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
2786 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
2787 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
2788 xt::pyarray<double>& q_numDiff_w_last = args.
array<
double>(
"q_numDiff_w_last");
2789 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
2790 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
2791 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
2792 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
2793 xt::pyarray<int>& sdInfo_u_w_rowptr = args.
array<
int>(
"sdInfo_u_w_rowptr");
2794 xt::pyarray<int>& sdInfo_u_w_colind = args.
array<
int>(
"sdInfo_u_w_colind");
2795 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
2796 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
2797 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
2798 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
2799 xt::pyarray<int>& sdInfo_v_w_rowptr = args.
array<
int>(
"sdInfo_v_w_rowptr");
2800 xt::pyarray<int>& sdInfo_v_w_colind = args.
array<
int>(
"sdInfo_v_w_colind");
2801 xt::pyarray<int>& sdInfo_w_w_rowptr = args.
array<
int>(
"sdInfo_w_w_rowptr");
2802 xt::pyarray<int>& sdInfo_w_w_colind = args.
array<
int>(
"sdInfo_w_w_colind");
2803 xt::pyarray<int>& sdInfo_w_u_rowptr = args.
array<
int>(
"sdInfo_w_u_rowptr");
2804 xt::pyarray<int>& sdInfo_w_u_colind = args.
array<
int>(
"sdInfo_w_u_colind");
2805 xt::pyarray<int>& sdInfo_w_v_rowptr = args.
array<
int>(
"sdInfo_w_v_rowptr");
2806 xt::pyarray<int>& sdInfo_w_v_colind = args.
array<
int>(
"sdInfo_w_v_colind");
2807 xt::pyarray<int>& csrRowIndeces_p_p = args.
array<
int>(
"csrRowIndeces_p_p");
2808 xt::pyarray<int>& csrColumnOffsets_p_p = args.
array<
int>(
"csrColumnOffsets_p_p");
2809 xt::pyarray<int>& csrRowIndeces_p_u = args.
array<
int>(
"csrRowIndeces_p_u");
2810 xt::pyarray<int>& csrColumnOffsets_p_u = args.
array<
int>(
"csrColumnOffsets_p_u");
2811 xt::pyarray<int>& csrRowIndeces_p_v = args.
array<
int>(
"csrRowIndeces_p_v");
2812 xt::pyarray<int>& csrColumnOffsets_p_v = args.
array<
int>(
"csrColumnOffsets_p_v");
2813 xt::pyarray<int>& csrRowIndeces_p_w = args.
array<
int>(
"csrRowIndeces_p_w");
2814 xt::pyarray<int>& csrColumnOffsets_p_w = args.
array<
int>(
"csrColumnOffsets_p_w");
2815 xt::pyarray<int>& csrRowIndeces_u_p = args.
array<
int>(
"csrRowIndeces_u_p");
2816 xt::pyarray<int>& csrColumnOffsets_u_p = args.
array<
int>(
"csrColumnOffsets_u_p");
2817 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
2818 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
2819 xt::pyarray<int>& csrRowIndeces_u_v = args.
array<
int>(
"csrRowIndeces_u_v");
2820 xt::pyarray<int>& csrColumnOffsets_u_v = args.
array<
int>(
"csrColumnOffsets_u_v");
2821 xt::pyarray<int>& csrRowIndeces_u_w = args.
array<
int>(
"csrRowIndeces_u_w");
2822 xt::pyarray<int>& csrColumnOffsets_u_w = args.
array<
int>(
"csrColumnOffsets_u_w");
2823 xt::pyarray<int>& csrRowIndeces_v_p = args.
array<
int>(
"csrRowIndeces_v_p");
2824 xt::pyarray<int>& csrColumnOffsets_v_p = args.
array<
int>(
"csrColumnOffsets_v_p");
2825 xt::pyarray<int>& csrRowIndeces_v_u = args.
array<
int>(
"csrRowIndeces_v_u");
2826 xt::pyarray<int>& csrColumnOffsets_v_u = args.
array<
int>(
"csrColumnOffsets_v_u");
2827 xt::pyarray<int>& csrRowIndeces_v_v = args.
array<
int>(
"csrRowIndeces_v_v");
2828 xt::pyarray<int>& csrColumnOffsets_v_v = args.
array<
int>(
"csrColumnOffsets_v_v");
2829 xt::pyarray<int>& csrRowIndeces_v_w = args.
array<
int>(
"csrRowIndeces_v_w");
2830 xt::pyarray<int>& csrColumnOffsets_v_w = args.
array<
int>(
"csrColumnOffsets_v_w");
2831 xt::pyarray<int>& csrRowIndeces_w_p = args.
array<
int>(
"csrRowIndeces_w_p");
2832 xt::pyarray<int>& csrColumnOffsets_w_p = args.
array<
int>(
"csrColumnOffsets_w_p");
2833 xt::pyarray<int>& csrRowIndeces_w_u = args.
array<
int>(
"csrRowIndeces_w_u");
2834 xt::pyarray<int>& csrColumnOffsets_w_u = args.
array<
int>(
"csrColumnOffsets_w_u");
2835 xt::pyarray<int>& csrRowIndeces_w_v = args.
array<
int>(
"csrRowIndeces_w_v");
2836 xt::pyarray<int>& csrColumnOffsets_w_v = args.
array<
int>(
"csrColumnOffsets_w_v");
2837 xt::pyarray<int>& csrRowIndeces_w_w = args.
array<
int>(
"csrRowIndeces_w_w");
2838 xt::pyarray<int>& csrColumnOffsets_w_w = args.
array<
int>(
"csrColumnOffsets_w_w");
2839 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
2840 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
2841 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
2842 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
2843 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
2844 xt::pyarray<double>& ebqe_vf_ext = args.
array<
double>(
"ebqe_vf_ext");
2845 xt::pyarray<double>& bc_ebqe_vf_ext = args.
array<
double>(
"bc_ebqe_vf_ext");
2846 xt::pyarray<double>& ebqe_phi_ext = args.
array<
double>(
"ebqe_phi_ext");
2847 xt::pyarray<double>& bc_ebqe_phi_ext = args.
array<
double>(
"bc_ebqe_phi_ext");
2848 xt::pyarray<double>& ebqe_normal_phi_ext = args.
array<
double>(
"ebqe_normal_phi_ext");
2849 xt::pyarray<double>& ebqe_kappa_phi_ext = args.
array<
double>(
"ebqe_kappa_phi_ext");
2850 const xt::pyarray<double>& ebqe_vos_ext = args.
array<
double>(
"ebqe_vos_ext");
2851 const xt::pyarray<double>& ebqe_turb_var_0 = args.
array<
double>(
"ebqe_turb_var_0");
2852 const xt::pyarray<double>& ebqe_turb_var_1 = args.
array<
double>(
"ebqe_turb_var_1");
2853 xt::pyarray<int>& isDOFBoundary_p = args.
array<
int>(
"isDOFBoundary_p");
2854 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
2855 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
2856 xt::pyarray<int>& isDOFBoundary_w = args.
array<
int>(
"isDOFBoundary_w");
2857 xt::pyarray<int>& isAdvectiveFluxBoundary_p = args.
array<
int>(
"isAdvectiveFluxBoundary_p");
2858 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
2859 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
2860 xt::pyarray<int>& isAdvectiveFluxBoundary_w = args.
array<
int>(
"isAdvectiveFluxBoundary_w");
2861 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
2862 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
2863 xt::pyarray<int>& isDiffusiveFluxBoundary_w = args.
array<
int>(
"isDiffusiveFluxBoundary_w");
2864 xt::pyarray<double>& ebqe_bc_p_ext = args.
array<
double>(
"ebqe_bc_p_ext");
2865 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
2866 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
2867 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
2868 xt::pyarray<double>& ebqe_bc_flux_mom_w_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_w_adv_ext");
2869 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
2870 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
2871 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
2872 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
2873 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
2874 xt::pyarray<double>& ebqe_bc_w_ext = args.
array<
double>(
"ebqe_bc_w_ext");
2875 xt::pyarray<double>& ebqe_bc_flux_w_diff_ext = args.
array<
double>(
"ebqe_bc_flux_w_diff_ext");
2876 xt::pyarray<int>& csrColumnOffsets_eb_p_p = args.
array<
int>(
"csrColumnOffsets_eb_p_p");
2877 xt::pyarray<int>& csrColumnOffsets_eb_p_u = args.
array<
int>(
"csrColumnOffsets_eb_p_u");
2878 xt::pyarray<int>& csrColumnOffsets_eb_p_v = args.
array<
int>(
"csrColumnOffsets_eb_p_v");
2879 xt::pyarray<int>& csrColumnOffsets_eb_p_w = args.
array<
int>(
"csrColumnOffsets_eb_p_w");
2880 xt::pyarray<int>& csrColumnOffsets_eb_u_p = args.
array<
int>(
"csrColumnOffsets_eb_u_p");
2881 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
2882 xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.
array<
int>(
"csrColumnOffsets_eb_u_v");
2883 xt::pyarray<int>& csrColumnOffsets_eb_u_w = args.
array<
int>(
"csrColumnOffsets_eb_u_w");
2884 xt::pyarray<int>& csrColumnOffsets_eb_v_p = args.
array<
int>(
"csrColumnOffsets_eb_v_p");
2885 xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.
array<
int>(
"csrColumnOffsets_eb_v_u");
2886 xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.
array<
int>(
"csrColumnOffsets_eb_v_v");
2887 xt::pyarray<int>& csrColumnOffsets_eb_v_w = args.
array<
int>(
"csrColumnOffsets_eb_v_w");
2888 xt::pyarray<int>& csrColumnOffsets_eb_w_p = args.
array<
int>(
"csrColumnOffsets_eb_w_p");
2889 xt::pyarray<int>& csrColumnOffsets_eb_w_u = args.
array<
int>(
"csrColumnOffsets_eb_w_u");
2890 xt::pyarray<int>& csrColumnOffsets_eb_w_v = args.
array<
int>(
"csrColumnOffsets_eb_w_v");
2891 xt::pyarray<int>& csrColumnOffsets_eb_w_w = args.
array<
int>(
"csrColumnOffsets_eb_w_w");
2892 xt::pyarray<int>& elementFlags = args.
array<
int>(
"elementFlags");
2893 double LAG_MU_FR = args.
scalar<
double>(
"LAG_MU_FR");
2894 xt::pyarray<double>& q_mu_fr_last = args.
array<
double>(
"q_mu_fr_last");
2895 xt::pyarray<double>& q_mu_fr = args.
array<
double>(
"q_mu_fr");
2899 for(
int eN=0;eN<nElements_global;eN++)
2901 register double eps_rho,eps_mu;
2903 register double elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
2904 elementJacobian_u_v[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 for (
int i=0;i<nDOF_test_element;i++)
2908 for (
int j=0;j<nDOF_trial_element;j++)
2911 elementJacobian_u_u[i][j]=0.0;
2912 elementJacobian_u_v[i][j]=0.0;
2913 elementJacobian_v_u[i][j]=0.0;
2914 elementJacobian_v_v[i][j]=0.0;
2917 for (
int k=0;k<nQuadraturePoints_element;k++)
2919 int eN_k = eN*nQuadraturePoints_element+k,
2920 eN_k_nSpace = eN_k*nSpace,
2921 eN_nDOF_trial_element = eN*nDOF_trial_element;
2924 register double p=0.0,
u=0.0,
v=0.0,
w=0.0,
2925 grad_p[nSpace],grad_u[nSpace],grad_v[nSpace],grad_w[nSpace],grad_vos[nSpace],
2933 dmass_adv_u[nSpace],
2934 dmass_adv_v[nSpace],
2935 dmass_adv_w[nSpace],
2937 dmom_u_adv_u[nSpace],
2938 dmom_u_adv_v[nSpace],
2939 dmom_u_adv_w[nSpace],
2941 dmom_v_adv_u[nSpace],
2942 dmom_v_adv_v[nSpace],
2943 dmom_v_adv_w[nSpace],
2945 dmom_w_adv_u[nSpace],
2946 dmom_w_adv_v[nSpace],
2947 dmom_w_adv_w[nSpace],
2948 mom_uu_diff_ten[nSpace],
2949 mom_vv_diff_ten[nSpace],
2950 mom_ww_diff_ten[nSpace],
2961 dmom_u_ham_grad_p[nSpace],
2962 dmom_u_ham_grad_u[nSpace],
2964 dmom_v_ham_grad_p[nSpace],
2965 dmom_v_ham_grad_v[nSpace],
2967 dmom_w_ham_grad_p[nSpace],
2968 dmom_w_ham_grad_w[nSpace],
2977 dpdeResidual_p_u[nDOF_trial_element],dpdeResidual_p_v[nDOF_trial_element],dpdeResidual_p_w[nDOF_trial_element],
2978 dpdeResidual_u_p[nDOF_trial_element],dpdeResidual_u_u[nDOF_trial_element],
2979 dpdeResidual_v_p[nDOF_trial_element],dpdeResidual_v_v[nDOF_trial_element],
2980 dpdeResidual_w_p[nDOF_trial_element],dpdeResidual_w_w[nDOF_trial_element],
2981 Lstar_u_u[nDOF_test_element],
2982 Lstar_v_v[nDOF_test_element],
2987 dsubgridError_p_u[nDOF_trial_element],
2988 dsubgridError_p_v[nDOF_trial_element],
2989 dsubgridError_p_w[nDOF_trial_element],
2990 dsubgridError_u_p[nDOF_trial_element],
2991 dsubgridError_u_u[nDOF_trial_element],
2992 dsubgridError_v_p[nDOF_trial_element],
2993 dsubgridError_v_v[nDOF_trial_element],
2994 dsubgridError_w_p[nDOF_trial_element],
2995 dsubgridError_w_w[nDOF_trial_element],
2996 tau_p=0.0,tau_p0=0.0,tau_p1=0.0,
2997 tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
3000 jacInv[nSpace*nSpace],
3001 p_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
3003 vel_test_dV[nDOF_test_element],
3004 vel_grad_test_dV[nDOF_test_element*nSpace],
3009 dmom_u_source[nSpace],
3010 dmom_v_source[nSpace],
3011 dmom_w_source[nSpace],
3014 G[nSpace*nSpace],G_dd_G,tr_G,h_phi, dmom_adv_star[nSpace], dmom_adv_sge[nSpace];
3016 ck.calculateMapping_element(eN,
3020 mesh_trial_ref.data(),
3021 mesh_grad_trial_ref.data(),
3026 ck.calculateH_element(eN,
3028 nodeDiametersArray.data(),
3030 mesh_trial_ref.data(),
3032 ck.calculateMappingVelocity_element(eN,
3034 mesh_velocity_dof.data(),
3036 mesh_trial_ref.data(),
3041 dV = fabs(jacDet)*dV_ref.data()[k];
3042 ck.calculateG(jacInv,G,G_dd_G,tr_G);
3045 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3046 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3050 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
3053 p = q_p.data()[eN_k];
3054 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
3055 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
3059 for (
int I=0;I<nSpace;I++)
3060 grad_p[I] = q_grad_p.data()[eN_k_nSpace+I];
3061 for (
int I=0;I<nSpace;I++)
3062 grad_vos[I] = q_grad_vos.data()[eN_k_nSpace + I];
3063 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
3064 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
3067 vos = q_vos.data()[eN_k];
3069 for (
int j=0;j<nDOF_trial_element;j++)
3072 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
3073 for (
int I=0;I<nSpace;I++)
3076 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
3080 double div_mesh_velocity=0.0;
3081 int NDOF_MESH_TRIAL_ELEMENT=3;
3082 for (
int j=0;j<NDOF_MESH_TRIAL_ELEMENT;j++)
3084 int eN_j=eN*NDOF_MESH_TRIAL_ELEMENT+j;
3085 div_mesh_velocity +=
3086 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+0]*vel_grad_trial[j*2+0] +
3087 mesh_velocity_dof.data()[mesh_l2g.data()[eN_j]*3+1]*vel_grad_trial[j*2+1];
3089 div_mesh_velocity =
DM3*div_mesh_velocity + (1.0-
DM3)*alphaBDF*(dV-q_dV_last.data()[eN_k])/dV;
3096 double eddy_viscosity(0.);
3105 elementDiameter.data()[eN],
3106 smagorinskyConstant,
3107 turbulenceClosureModel,
3112 &normal_phi.data()[eN_k_nSpace],
3113 kappa_phi.data()[eN_k],
3125 q_velocity_sge.data()[eN_k_nSpace+0],
3126 q_velocity_sge.data()[eN_k_nSpace+1],
3127 q_velocity_sge.data()[eN_k_nSpace+1],
3173 mass_source = q_mass_source.data()[eN_k];
3174 for (
int I=0;I<nSpace;I++)
3176 dmom_u_source[I] = 0.0;
3177 dmom_v_source[I] = 0.0;
3178 dmom_w_source[I] = 0.0;
3184 q_dragAlpha.data()[eN_k],
3185 q_dragBeta.data()[eN_k],
3199 q_velocity_sge.data()[eN_k_nSpace+0],
3200 q_velocity_sge.data()[eN_k_nSpace+1],
3201 q_velocity_sge.data()[eN_k_nSpace+1],
3202 eps_solid.data()[elementFlags.data()[eN]],
3204 q_velocity_fluid.data()[eN_k_nSpace+0],
3205 q_velocity_fluid.data()[eN_k_nSpace+1],
3206 q_velocity_fluid.data()[eN_k_nSpace+1],
3207 q_velocityStar_fluid.data()[eN_k_nSpace+0],
3208 q_velocityStar_fluid.data()[eN_k_nSpace+1],
3209 q_velocityStar_fluid.data()[eN_k_nSpace+1],
3216 q_grad_vos.data()[eN_k_nSpace+0],
3217 q_grad_vos.data()[eN_k_nSpace+1],
3218 q_grad_vos.data()[eN_k_nSpace+1]);
3220 double mu_fr_tmp=0.0;
3227 q_mu_fr_last.data()[eN_k],
3255 mom_u_adv[0] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*
xt;
3256 mom_u_adv[1] -= MOVING_DOMAIN*dmom_u_acc_u*mom_u_acc*yt;
3258 dmom_u_adv_u[0] -= MOVING_DOMAIN*dmom_u_acc_u*
xt;
3259 dmom_u_adv_u[1] -= MOVING_DOMAIN*dmom_u_acc_u*yt;
3262 mom_v_adv[0] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*
xt;
3263 mom_v_adv[1] -= MOVING_DOMAIN*dmom_v_acc_v*mom_v_acc*yt;
3265 dmom_v_adv_v[0] -= MOVING_DOMAIN*dmom_v_acc_v*
xt;
3266 dmom_v_adv_v[1] -= MOVING_DOMAIN*dmom_v_acc_v*yt;
3279 q_mom_u_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
3285 q_mom_v_acc_beta_bdf.data()[eN_k]*q_dV_last.data()[eN_k]/dV,
3300 mom_u_acc_t *= dmom_u_acc_u;
3301 mom_v_acc_t *= dmom_v_acc_v;
3304 dmom_adv_sge[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt);
3305 dmom_adv_sge[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt);
3311 ck.Mass_strong(q_dvos_dt.data()[eN_k]) +
3312 ck.Advection_strong(dmass_adv_u,grad_u) +
3313 ck.Advection_strong(dmass_adv_v,grad_v) +
3315 DM2*MOVING_DOMAIN*
ck.Reaction_strong(alphaBDF*(dV-q_dV_last.data()[eN_k])/dV - div_mesh_velocity) +
3317 ck.Reaction_strong(mass_source);
3321 ck.Mass_strong(mom_u_acc_t) +
3322 ck.Advection_strong(dmom_adv_sge,grad_u) +
3323 ck.Hamiltonian_strong(dmom_u_ham_grad_p,grad_p) +
3324 ck.Reaction_strong(mom_u_source) -
3325 ck.Reaction_strong(
u*div_mesh_velocity);
3328 ck.Mass_strong(mom_v_acc_t) +
3329 ck.Advection_strong(dmom_adv_sge,grad_v) +
3330 ck.Hamiltonian_strong(dmom_v_ham_grad_p,grad_p) +
3331 ck.Reaction_strong(mom_v_source) -
3332 ck.Reaction_strong(
v*div_mesh_velocity);
3342 for (
int j=0;j<nDOF_trial_element;j++)
3344 register int j_nSpace = j*nSpace;
3345 dpdeResidual_p_u[j]=
ck.AdvectionJacobian_strong(dmass_adv_u,&vel_grad_trial[j_nSpace]);
3346 dpdeResidual_p_v[j]=
ck.AdvectionJacobian_strong(dmass_adv_v,&vel_grad_trial[j_nSpace]);
3349 dpdeResidual_u_p[j]=
ck.HamiltonianJacobian_strong(dmom_u_ham_grad_p,&p_grad_trial[j_nSpace]);
3350 dpdeResidual_u_u[j]=
ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j]) +
3351 ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
3352 ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]);
3354 dpdeResidual_v_p[j]=
ck.HamiltonianJacobian_strong(dmom_v_ham_grad_p,&p_grad_trial[j_nSpace]);
3355 dpdeResidual_v_v[j]=
ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j]) +
3356 ck.AdvectionJacobian_strong(dmom_adv_sge,&vel_grad_trial[j_nSpace]) -
3357 ck.ReactionJacobian_strong(div_mesh_velocity,vel_trial_ref.data()[k*nDOF_trial_element+j]);
3365 dpdeResidual_u_u[j]+=
ck.ReactionJacobian_strong(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j]);
3366 dpdeResidual_v_v[j]+=
ck.ReactionJacobian_strong(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j]);
3372 double tmpR=dmom_u_acc_u_t + dmom_u_source[0];
3374 elementDiameter.data()[eN],
3379 dmom_u_ham_grad_p[0],
3382 q_cfl.data()[eN_k]);
3389 dmom_u_ham_grad_p[0],
3392 q_cfl.data()[eN_k]);
3395 tau_v = useMetrics*tau_v1+(1.0-useMetrics)*tau_v0;
3396 tau_p = PSTAB*(useMetrics*tau_p1+(1.0-useMetrics)*tau_p0);
3429 dmom_adv_star[0] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+0] - MOVING_DOMAIN*
xt + useRBLES*subgridError_u);
3430 dmom_adv_star[1] = dmom_u_acc_u*(q_velocity_sge.data()[eN_k_nSpace+1] - MOVING_DOMAIN*yt + useRBLES*subgridError_v);
3434 for (
int i=0;i<nDOF_test_element;i++)
3436 register int i_nSpace = i*nSpace;
3437 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
3438 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_adv_star,&vel_grad_test_dV[i_nSpace]);
3440 Lstar_u_u[i]+=
ck.Reaction_adjoint(dmom_u_source[0],vel_test_dV[i]);
3441 Lstar_v_v[i]+=
ck.Reaction_adjoint(dmom_v_source[1],vel_test_dV[i]);
3445 dmom_u_adv_u[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
3446 dmom_u_adv_u[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
3449 dmom_v_adv_v[0] += dmom_u_acc_u*(useRBLES*subgridError_u);
3450 dmom_v_adv_v[1] += dmom_u_acc_u*(useRBLES*subgridError_v);
3459 for(
int i=0;i<nDOF_test_element;i++)
3461 register int i_nSpace = i*nSpace;
3462 for(
int j=0;j<nDOF_trial_element;j++)
3464 register int j_nSpace = j*nSpace;
3478 elementJacobian_u_u[i][j] +=
3479 ck.MassJacobian_weak(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3480 ck.HamiltonianJacobian_weak(dmom_u_ham_grad_u,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
3481 ck.AdvectionJacobian_weak(dmom_u_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3482 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]) +
3484 ck.ReactionJacobian_weak(dmom_u_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3487 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_u[i]) +
3488 ck.NumericalDiffusionJacobian(q_numDiff_u_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3489 elementJacobian_u_v[i][j] +=
3490 ck.AdvectionJacobian_weak(dmom_u_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3491 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]) +
3493 ck.ReactionJacobian_weak(dmom_u_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3505 elementJacobian_v_u[i][j] +=
3506 ck.AdvectionJacobian_weak(dmom_v_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3507 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]) +
3509 ck.ReactionJacobian_weak(dmom_v_source[0],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]);
3512 elementJacobian_v_v[i][j] +=
3513 ck.MassJacobian_weak(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3514 ck.HamiltonianJacobian_weak(dmom_v_ham_grad_v,&vel_grad_trial[j_nSpace],vel_test_dV[i]) +
3515 ck.AdvectionJacobian_weak(dmom_v_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3516 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]) +
3518 ck.ReactionJacobian_weak(dmom_v_source[1],vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3521 ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_v[i]) +
3522 ck.NumericalDiffusionJacobian(q_numDiff_v_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3560 for (
int i=0;i<nDOF_test_element;i++)
3562 register int eN_i = eN*nDOF_test_element+i;
3563 for (
int j=0;j<nDOF_trial_element;j++)
3565 register int eN_i_j = eN_i*nDOF_trial_element+j;
3572 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += elementJacobian_u_u[i][j];
3573 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_u_v[eN_i_j]] += elementJacobian_u_v[i][j];
3577 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_v_u[eN_i_j]] += elementJacobian_v_u[i][j];
3578 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_v_v[eN_i_j]] += elementJacobian_v_v[i][j];
3591 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
3593 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
3594 eN = elementBoundaryElementsArray.data()[ebN*2+0],
3595 eN_nDOF_trial_element = eN*nDOF_trial_element,
3596 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0];
3597 register double eps_rho,eps_mu;
3598 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
3600 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
3601 ebNE_kb_nSpace = ebNE_kb*nSpace,
3602 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
3603 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
3605 register double p_ext=0.0,
3614 dmom_u_acc_u_ext=0.0,
3616 dmom_v_acc_v_ext=0.0,
3618 dmom_w_acc_w_ext=0.0,
3619 mass_adv_ext[nSpace],
3620 dmass_adv_u_ext[nSpace],
3621 dmass_adv_v_ext[nSpace],
3622 dmass_adv_w_ext[nSpace],
3623 mom_u_adv_ext[nSpace],
3624 dmom_u_adv_u_ext[nSpace],
3625 dmom_u_adv_v_ext[nSpace],
3626 dmom_u_adv_w_ext[nSpace],
3627 mom_v_adv_ext[nSpace],
3628 dmom_v_adv_u_ext[nSpace],
3629 dmom_v_adv_v_ext[nSpace],
3630 dmom_v_adv_w_ext[nSpace],
3631 mom_w_adv_ext[nSpace],
3632 dmom_w_adv_u_ext[nSpace],
3633 dmom_w_adv_v_ext[nSpace],
3634 dmom_w_adv_w_ext[nSpace],
3635 mom_uu_diff_ten_ext[nSpace],
3636 mom_vv_diff_ten_ext[nSpace],
3637 mom_ww_diff_ten_ext[nSpace],
3638 mom_uv_diff_ten_ext[1],
3639 mom_uw_diff_ten_ext[1],
3640 mom_vu_diff_ten_ext[1],
3641 mom_vw_diff_ten_ext[1],
3642 mom_wu_diff_ten_ext[1],
3643 mom_wv_diff_ten_ext[1],
3644 mom_u_source_ext=0.0,
3645 mom_v_source_ext=0.0,
3646 mom_w_source_ext=0.0,
3648 dmom_u_ham_grad_p_ext[nSpace],
3649 dmom_u_ham_grad_u_ext[nSpace],
3651 dmom_v_ham_grad_p_ext[nSpace],
3652 dmom_v_ham_grad_v_ext[nSpace],
3654 dmom_w_ham_grad_p_ext[nSpace],
3655 dmom_w_ham_grad_w_ext[nSpace],
3656 dmom_u_adv_p_ext[nSpace],
3657 dmom_v_adv_p_ext[nSpace],
3658 dmom_w_adv_p_ext[nSpace],
3659 dflux_mass_u_ext=0.0,
3660 dflux_mass_v_ext=0.0,
3661 dflux_mass_w_ext=0.0,
3662 dflux_mom_u_adv_p_ext=0.0,
3663 dflux_mom_u_adv_u_ext=0.0,
3664 dflux_mom_u_adv_v_ext=0.0,
3665 dflux_mom_u_adv_w_ext=0.0,
3666 dflux_mom_v_adv_p_ext=0.0,
3667 dflux_mom_v_adv_u_ext=0.0,
3668 dflux_mom_v_adv_v_ext=0.0,
3669 dflux_mom_v_adv_w_ext=0.0,
3670 dflux_mom_w_adv_p_ext=0.0,
3671 dflux_mom_w_adv_u_ext=0.0,
3672 dflux_mom_w_adv_v_ext=0.0,
3673 dflux_mom_w_adv_w_ext=0.0,
3678 bc_mom_u_acc_ext=0.0,
3679 bc_dmom_u_acc_u_ext=0.0,
3680 bc_mom_v_acc_ext=0.0,
3681 bc_dmom_v_acc_v_ext=0.0,
3682 bc_mom_w_acc_ext=0.0,
3683 bc_dmom_w_acc_w_ext=0.0,
3684 bc_mass_adv_ext[nSpace],
3685 bc_dmass_adv_u_ext[nSpace],
3686 bc_dmass_adv_v_ext[nSpace],
3687 bc_dmass_adv_w_ext[nSpace],
3688 bc_mom_u_adv_ext[nSpace],
3689 bc_dmom_u_adv_u_ext[nSpace],
3690 bc_dmom_u_adv_v_ext[nSpace],
3691 bc_dmom_u_adv_w_ext[nSpace],
3692 bc_mom_v_adv_ext[nSpace],
3693 bc_dmom_v_adv_u_ext[nSpace],
3694 bc_dmom_v_adv_v_ext[nSpace],
3695 bc_dmom_v_adv_w_ext[nSpace],
3696 bc_mom_w_adv_ext[nSpace],
3697 bc_dmom_w_adv_u_ext[nSpace],
3698 bc_dmom_w_adv_v_ext[nSpace],
3699 bc_dmom_w_adv_w_ext[nSpace],
3700 bc_mom_uu_diff_ten_ext[nSpace],
3701 bc_mom_vv_diff_ten_ext[nSpace],
3702 bc_mom_ww_diff_ten_ext[nSpace],
3703 bc_mom_uv_diff_ten_ext[1],
3704 bc_mom_uw_diff_ten_ext[1],
3705 bc_mom_vu_diff_ten_ext[1],
3706 bc_mom_vw_diff_ten_ext[1],
3707 bc_mom_wu_diff_ten_ext[1],
3708 bc_mom_wv_diff_ten_ext[1],
3709 bc_mom_u_source_ext=0.0,
3710 bc_mom_v_source_ext=0.0,
3711 bc_mom_w_source_ext=0.0,
3712 bc_mom_u_ham_ext=0.0,
3713 bc_dmom_u_ham_grad_p_ext[nSpace],
3714 bc_dmom_u_ham_grad_u_ext[nSpace],
3715 bc_mom_v_ham_ext=0.0,
3716 bc_dmom_v_ham_grad_p_ext[nSpace],
3717 bc_dmom_v_ham_grad_v_ext[nSpace],
3718 bc_mom_w_ham_ext=0.0,
3719 bc_dmom_w_ham_grad_p_ext[nSpace],
3720 bc_dmom_w_ham_grad_w_ext[nSpace],
3721 fluxJacobian_u_u[nDOF_trial_element],
3722 fluxJacobian_u_v[nDOF_trial_element],
3723 fluxJacobian_v_u[nDOF_trial_element],
3724 fluxJacobian_v_v[nDOF_trial_element],
3725 jac_ext[nSpace*nSpace],
3727 jacInv_ext[nSpace*nSpace],
3728 boundaryJac[nSpace*(nSpace-1)],
3729 metricTensor[(nSpace-1)*(nSpace-1)],
3730 metricTensorDetSqrt,
3731 vel_grad_trial_trace[nDOF_trial_element*nSpace],
3733 vel_test_dS[nDOF_test_element],
3735 x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
3736 vel_grad_test_dS[nDOF_trial_element*nSpace],
3740 G[nSpace*nSpace],G_dd_G,tr_G,h_phi,h_penalty,penalty;
3741 ck.calculateMapping_elementBoundary(eN,
3747 mesh_trial_trace_ref.data(),
3748 mesh_grad_trial_trace_ref.data(),
3749 boundaryJac_ref.data(),
3755 metricTensorDetSqrt,
3759 ck.calculateMappingVelocity_elementBoundary(eN,
3763 mesh_velocity_dof.data(),
3765 mesh_trial_trace_ref.data(),
3766 xt_ext,yt_ext,zt_ext,
3772 dS = metricTensorDetSqrt*dS_ref.data()[kb];
3773 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
3774 ck.calculateGScale(G,&ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],h_phi);
3776 eps_rho = epsFact_rho*(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3777 eps_mu = epsFact_mu *(useMetrics*h_phi+(1.0-useMetrics)*elementDiameter.data()[eN]);
3782 ck.gradTrialFromRef(&vel_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,vel_grad_trial_trace);
3785 p_ext = ebqe_p.data()[ebNE_kb];
3786 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);
3787 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);
3790 for (
int I=0;I<nSpace;I++)
3791 grad_p_ext[I] = ebqe_grad_p.data()[ebNE_kb_nSpace+I];
3792 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_u_ext);
3793 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial_trace,grad_v_ext);
3796 for (
int j=0;j<nDOF_trial_element;j++)
3799 vel_test_dS[j] = vel_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
3800 for (
int I=0;I<nSpace;I++)
3801 vel_grad_test_dS[j*nSpace+I] = vel_grad_trial_trace[j*nSpace+I]*dS;
3806 bc_p_ext = isDOFBoundary_p.data()[ebNE_kb]*ebqe_bc_p_ext.data()[ebNE_kb]+(1-isDOFBoundary_p.data()[ebNE_kb])*p_ext;
3808 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;
3809 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;
3812 vos_ext = ebqe_vos_ext.data()[ebNE_kb];
3817 double eddy_viscosity_ext(0.),bc_eddy_viscosity_ext(0.);
3826 elementDiameter.data()[eN],
3827 smagorinskyConstant,
3828 turbulenceClosureModel,
3831 ebqe_vf_ext.data()[ebNE_kb],
3832 ebqe_phi_ext.data()[ebNE_kb],
3833 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
3834 ebqe_kappa_phi_ext.data()[ebNE_kb],
3846 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
3847 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3848 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3872 mom_uu_diff_ten_ext,
3873 mom_vv_diff_ten_ext,
3874 mom_ww_diff_ten_ext,
3875 mom_uv_diff_ten_ext,
3876 mom_uw_diff_ten_ext,
3877 mom_vu_diff_ten_ext,
3878 mom_vw_diff_ten_ext,
3879 mom_wu_diff_ten_ext,
3880 mom_wv_diff_ten_ext,
3885 dmom_u_ham_grad_p_ext,
3886 dmom_u_ham_grad_u_ext,
3888 dmom_v_ham_grad_p_ext,
3889 dmom_v_ham_grad_v_ext,
3891 dmom_w_ham_grad_p_ext,
3892 dmom_w_ham_grad_w_ext);
3901 elementDiameter.data()[eN],
3902 smagorinskyConstant,
3903 turbulenceClosureModel,
3906 bc_ebqe_vf_ext.data()[ebNE_kb],
3907 bc_ebqe_phi_ext.data()[ebNE_kb],
3908 &ebqe_normal_phi_ext.data()[ebNE_kb_nSpace],
3909 ebqe_kappa_phi_ext.data()[ebNE_kb],
3921 ebqe_velocity_star.data()[ebNE_kb_nSpace+0],
3922 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3923 ebqe_velocity_star.data()[ebNE_kb_nSpace+1],
3924 bc_eddy_viscosity_ext,
3926 bc_dmom_u_acc_u_ext,
3928 bc_dmom_v_acc_v_ext,
3930 bc_dmom_w_acc_w_ext,
3936 bc_dmom_u_adv_u_ext,
3937 bc_dmom_u_adv_v_ext,
3938 bc_dmom_u_adv_w_ext,
3940 bc_dmom_v_adv_u_ext,
3941 bc_dmom_v_adv_v_ext,
3942 bc_dmom_v_adv_w_ext,
3944 bc_dmom_w_adv_u_ext,
3945 bc_dmom_w_adv_v_ext,
3946 bc_dmom_w_adv_w_ext,
3947 bc_mom_uu_diff_ten_ext,
3948 bc_mom_vv_diff_ten_ext,
3949 bc_mom_ww_diff_ten_ext,
3950 bc_mom_uv_diff_ten_ext,
3951 bc_mom_uw_diff_ten_ext,
3952 bc_mom_vu_diff_ten_ext,
3953 bc_mom_vw_diff_ten_ext,
3954 bc_mom_wu_diff_ten_ext,
3955 bc_mom_wv_diff_ten_ext,
3956 bc_mom_u_source_ext,
3957 bc_mom_v_source_ext,
3958 bc_mom_w_source_ext,
3960 bc_dmom_u_ham_grad_p_ext,
3961 bc_dmom_u_ham_grad_u_ext,
3963 bc_dmom_v_ham_grad_p_ext,
3964 bc_dmom_v_ham_grad_v_ext,
3966 bc_dmom_w_ham_grad_p_ext,
3967 bc_dmom_w_ham_grad_w_ext);
3972 mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*xt_ext;
3973 mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*mom_u_acc_ext*yt_ext;
3975 dmom_u_adv_u_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*xt_ext;
3976 dmom_u_adv_u_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*yt_ext;
3979 mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*xt_ext;
3980 mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*mom_v_acc_ext*yt_ext;
3982 dmom_v_adv_v_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*xt_ext;
3983 dmom_v_adv_v_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*yt_ext;
3995 bc_mom_u_adv_ext[0] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*xt_ext;
3996 bc_mom_u_adv_ext[1] -= MOVING_DOMAIN*dmom_u_acc_u_ext*bc_mom_u_acc_ext*yt_ext;
3999 bc_mom_v_adv_ext[0] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*xt_ext;
4000 bc_mom_v_adv_ext[1] -= MOVING_DOMAIN*dmom_v_acc_v_ext*bc_mom_v_acc_ext*yt_ext;
4010 isDOFBoundary_u.data()[ebNE_kb],
4011 isDOFBoundary_v.data()[ebNE_kb],
4012 isDOFBoundary_w.data()[ebNE_kb],
4013 isAdvectiveFluxBoundary_p.data()[ebNE_kb],
4014 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
4015 isAdvectiveFluxBoundary_v.data()[ebNE_kb],
4016 isAdvectiveFluxBoundary_w.data()[ebNE_kb],
4017 dmom_u_ham_grad_p_ext[0],
4028 ebqe_bc_flux_mass_ext.data()[ebNE_kb]+MOVING_DOMAIN*(xt_ext*normal[0]+yt_ext*normal[1]),
4029 ebqe_bc_flux_mom_u_adv_ext.data()[ebNE_kb],
4030 ebqe_bc_flux_mom_v_adv_ext.data()[ebNE_kb],
4031 ebqe_bc_flux_mom_w_adv_ext.data()[ebNE_kb],
4058 dflux_mom_u_adv_p_ext,
4059 dflux_mom_u_adv_u_ext,
4060 dflux_mom_u_adv_v_ext,
4061 dflux_mom_u_adv_w_ext,
4062 dflux_mom_v_adv_p_ext,
4063 dflux_mom_v_adv_u_ext,
4064 dflux_mom_v_adv_v_ext,
4065 dflux_mom_v_adv_w_ext,
4066 dflux_mom_w_adv_p_ext,
4067 dflux_mom_w_adv_u_ext,
4068 dflux_mom_w_adv_v_ext,
4069 dflux_mom_w_adv_w_ext,
4070 &ebqe_velocity_star.data()[ebNE_kb_nSpace]);
4074 ck.calculateGScale(G,normal,h_penalty);
4075 penalty = useMetrics*C_b/h_penalty + (1.0-useMetrics)*ebqe_penalty_ext.data()[ebNE_kb];
4076 for (
int j=0;j<nDOF_trial_element;j++)
4078 register int j_nSpace = j*nSpace,ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
4085 fluxJacobian_u_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_u_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4087 ebqe_phi_ext.data()[ebNE_kb],
4088 sdInfo_u_u_rowptr.data(),
4089 sdInfo_u_u_colind.data(),
4090 isDOFBoundary_u.data()[ebNE_kb],
4091 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4093 mom_uu_diff_ten_ext,
4094 vel_trial_trace_ref.data()[ebN_local_kb_j],
4095 &vel_grad_trial_trace[j_nSpace],
4097 fluxJacobian_u_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_u_adv_v_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4099 ebqe_phi_ext.data()[ebNE_kb],
4100 sdInfo_u_v_rowptr.data(),
4101 sdInfo_u_v_colind.data(),
4102 isDOFBoundary_v.data()[ebNE_kb],
4103 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4105 mom_uv_diff_ten_ext,
4106 vel_trial_trace_ref.data()[ebN_local_kb_j],
4107 &vel_grad_trial_trace[j_nSpace],
4123 fluxJacobian_v_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_u_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4125 ebqe_phi_ext.data()[ebNE_kb],
4126 sdInfo_v_u_rowptr.data(),
4127 sdInfo_v_u_colind.data(),
4128 isDOFBoundary_u.data()[ebNE_kb],
4129 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4131 mom_vu_diff_ten_ext,
4132 vel_trial_trace_ref.data()[ebN_local_kb_j],
4133 &vel_grad_trial_trace[j_nSpace],
4135 fluxJacobian_v_v[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_mom_v_adv_v_ext,vel_trial_trace_ref.data()[ebN_local_kb_j]) +
4137 ebqe_phi_ext.data()[ebNE_kb],
4138 sdInfo_v_v_rowptr.data(),
4139 sdInfo_v_v_colind.data(),
4140 isDOFBoundary_v.data()[ebNE_kb],
4141 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4143 mom_vv_diff_ten_ext,
4144 vel_trial_trace_ref.data()[ebN_local_kb_j],
4145 &vel_grad_trial_trace[j_nSpace],
4201 for (
int i=0;i<nDOF_test_element;i++)
4203 register int eN_i = eN*nDOF_test_element+i;
4204 for (
int j=0;j<nDOF_trial_element;j++)
4206 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;
4214 globalJacobian.data()[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] +=
4215 fluxJacobian_u_u[j]*vel_test_dS[i]+
4216 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u.data()[ebNE_kb],
4217 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4219 vel_trial_trace_ref.data()[ebN_local_kb_j],
4221 sdInfo_u_u_rowptr.data(),
4222 sdInfo_u_u_colind.data(),
4223 mom_uu_diff_ten_ext,
4224 &vel_grad_test_dS[i*nSpace]);
4225 globalJacobian.data()[csrRowIndeces_u_v[eN_i] + csrColumnOffsets_eb_u_v[ebN_i_j]] +=
4226 fluxJacobian_u_v[j]*vel_test_dS[i]+
4227 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v.data()[ebNE_kb],
4228 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
4230 vel_trial_trace_ref.data()[ebN_local_kb_j],
4232 sdInfo_u_v_rowptr.data(),
4233 sdInfo_u_v_colind.data(),
4234 mom_uv_diff_ten_ext,
4235 &vel_grad_test_dS[i*nSpace]);
4248 globalJacobian.data()[csrRowIndeces_v_u[eN_i] + csrColumnOffsets_eb_v_u[ebN_i_j]] +=
4249 fluxJacobian_v_u[j]*vel_test_dS[i]+
4250 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_u.data()[ebNE_kb],
4251 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4253 vel_trial_trace_ref.data()[ebN_local_kb_j],
4255 sdInfo_v_u_rowptr.data(),
4256 sdInfo_v_u_colind.data(),
4257 mom_vu_diff_ten_ext,
4258 &vel_grad_test_dS[i*nSpace]);
4259 globalJacobian.data()[csrRowIndeces_v_v[eN_i] + csrColumnOffsets_eb_v_v[ebN_i_j]] +=
4260 fluxJacobian_v_v[j]*vel_test_dS[i]+
4261 ck.ExteriorElementBoundaryDiffusionAdjointJacobian(isDOFBoundary_v.data()[ebNE_kb],
4262 isDiffusiveFluxBoundary_v.data()[ebNE_kb],
4264 vel_trial_trace_ref.data()[ebN_local_kb_j],
4266 sdInfo_v_v_rowptr.data(),
4267 sdInfo_v_v_colind.data(),
4268 mom_vv_diff_ten_ext,
4269 &vel_grad_test_dS[i*nSpace]);
4319 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
4320 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
4321 int nInteriorElementBoundaries_global = args.
scalar<
int>(
"nInteriorElementBoundaries_global");
4322 xt::pyarray<int>& interiorElementBoundariesArray = args.
array<
int>(
"interiorElementBoundariesArray");
4323 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
4324 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
4325 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
4326 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
4327 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
4328 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
4329 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
4330 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
4331 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
4332 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
4333 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
4334 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
4335 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
4336 xt::pyarray<double>& w_dof = args.
array<
double>(
"w_dof");
4337 xt::pyarray<double>& vos_dof = args.
array<
double>(
"vos_dof");
4338 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
4339 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
4340 xt::pyarray<double>& velocityAverage = args.
array<
double>(
"velocityAverage");
4341 int permutations[nQuadraturePoints_elementBoundary];
4342 double xArray_left[nQuadraturePoints_elementBoundary*2],
4343 xArray_right[nQuadraturePoints_elementBoundary*2];
4344 for (
int i=0;i<nQuadraturePoints_elementBoundary;i++)
4346 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
4348 register int ebN = exteriorElementBoundariesArray.data()[ebNE];
4349 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4351 register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace,
4352 ebNE_kb_nSpace = ebNE*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
4353 velocityAverage.data()[ebN_kb_nSpace+0]=ebqe_velocity.data()[ebNE_kb_nSpace+0];
4354 velocityAverage.data()[ebN_kb_nSpace+1]=ebqe_velocity.data()[ebNE_kb_nSpace+1];
4357 for (
int ebNI = 0; ebNI < nInteriorElementBoundaries_global; ebNI++)
4359 register int ebN = interiorElementBoundariesArray.data()[ebNI],
4360 left_eN_global = elementBoundaryElementsArray.data()[ebN*2+0],
4361 left_ebN_element = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
4362 right_eN_global = elementBoundaryElementsArray.data()[ebN*2+1],
4363 right_ebN_element = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+1],
4364 left_eN_nDOF_trial_element = left_eN_global*nDOF_trial_element,
4365 right_eN_nDOF_trial_element = right_eN_global*nDOF_trial_element;
4366 double jac[nSpace*nSpace],
4368 jacInv[nSpace*nSpace],
4369 boundaryJac[nSpace*(nSpace-1)],
4370 metricTensor[(nSpace-1)*(nSpace-1)],
4371 metricTensorDetSqrt,
4374 xt,yt,zt,integralScaling;
4376 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4378 ck.calculateMapping_elementBoundary(left_eN_global,
4381 left_ebN_element*nQuadraturePoints_elementBoundary+kb,
4384 mesh_trial_trace_ref.data(),
4385 mesh_grad_trial_trace_ref.data(),
4386 boundaryJac_ref.data(),
4392 metricTensorDetSqrt,
4396 xArray_left[kb*2+0] = x;
4397 xArray_left[kb*2+1] = y;
4399 ck.calculateMapping_elementBoundary(right_eN_global,
4402 right_ebN_element*nQuadraturePoints_elementBoundary+kb,
4405 mesh_trial_trace_ref.data(),
4406 mesh_grad_trial_trace_ref.data(),
4407 boundaryJac_ref.data(),
4413 metricTensorDetSqrt,
4417 ck.calculateMappingVelocity_elementBoundary(left_eN_global,
4420 left_ebN_element*nQuadraturePoints_elementBoundary+kb,
4421 mesh_velocity_dof.data(),
4423 mesh_trial_trace_ref.data(),
4429 xArray_right[kb*2+0] = x;
4430 xArray_right[kb*2+1] = y;
4433 for (
int kb_left=0;kb_left<nQuadraturePoints_elementBoundary;kb_left++)
4435 double errorNormMin = 1.0;
4436 for (
int kb_right=0;kb_right<nQuadraturePoints_elementBoundary;kb_right++)
4438 double errorNorm=0.0;
4439 for (
int I=0;I<nSpace;I++)
4441 errorNorm += fabs(xArray_left[kb_left*2+I]
4443 xArray_right[kb_right*2+I]);
4445 if (errorNorm < errorNormMin)
4447 permutations[kb_right] = kb_left;
4448 errorNormMin = errorNorm;
4452 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
4454 register int ebN_kb_nSpace = ebN*nQuadraturePoints_elementBoundary*nSpace+kb*nSpace;
4455 register double u_left=0.0,
4461 register int left_kb = kb,
4462 right_kb = permutations[kb],
4463 left_ebN_element_kb_nDOF_test_element=(left_ebN_element*nQuadraturePoints_elementBoundary+left_kb)*nDOF_test_element,
4464 right_ebN_element_kb_nDOF_test_element=(right_ebN_element*nQuadraturePoints_elementBoundary+right_kb)*nDOF_test_element;
4468 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);
4469 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);
4470 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);
4473 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);
4474 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);
4475 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);
4478 velocityAverage.data()[ebN_kb_nSpace+0]=0.5*(u_left + u_right);
4479 velocityAverage.data()[ebN_kb_nSpace+1]=0.5*(v_left + v_right);
4488 int nQuadraturePoints_elementIn,
4489 int nDOF_mesh_trial_elementIn,
4490 int nDOF_trial_elementIn,
4491 int nDOF_test_elementIn,
4492 int nQuadraturePoints_elementBoundaryIn,
4497 double packFraction,
4510 double mu_fr_limiter)
4515 nQuadraturePoints_elementIn,
4516 nDOF_mesh_trial_elementIn,
4517 nDOF_trial_elementIn,
4518 nDOF_test_elementIn,
4519 nQuadraturePoints_elementBoundaryIn,