8 #include "xtensor-python/pyarray.hpp"
10 namespace py = pybind11;
29 template<
class CompKernelType,
31 int nQuadraturePoints_element,
32 int nDOF_mesh_trial_element,
33 int nDOF_trial_element,
34 int nDOF_test_element,
35 int nQuadraturePoints_elementBoundary>
45 std::cout<<
"Constructing SW2D<CompKernelTemplate<"
47 <<nQuadraturePoints_element<<
","
48 <<nDOF_mesh_trial_element<<
","
49 <<nDOF_trial_element<<
","
50 <<nDOF_test_element<<
","
51 <<nQuadraturePoints_elementBoundary<<
">());"
52 <<std::endl<<std::flush;
58 const double grad_b[nSpace],
70 double mass_adv[nSpace],
71 double dmass_adv_h[nSpace],
72 double dmass_adv_u[nSpace],
73 double dmass_adv_v[nSpace],
74 double mom_u_adv[nSpace],
75 double dmom_u_adv_h[nSpace],
76 double dmom_u_adv_u[nSpace],
77 double dmom_u_adv_v[nSpace],
78 double mom_v_adv[nSpace],
79 double dmom_v_adv_h[nSpace],
80 double dmom_v_adv_u[nSpace],
81 double dmom_v_adv_v[nSpace],
82 double mom_u_diff_ten[nSpace],
83 double mom_v_diff_ten[nSpace],
84 double mom_uv_diff_ten[1],
85 double mom_vu_diff_ten[1],
87 double& dmom_u_source_h,
89 double& dmom_v_source_h)
119 mom_u_adv[0]=h*
u*
u + 0.5*g*h*h;
122 dmom_u_adv_h[0]=
u*
u + g*h;
125 dmom_u_adv_u[0]=h*2.0*
u;
133 mom_v_adv[1]=h*
v*
v + 0.5*g*h*h;
136 dmom_v_adv_h[1]=
v*
v + g*h;
142 dmom_v_adv_v[1]=h*2.0*
v;
145 mom_u_diff_ten[0] = 2.0*nu;
146 mom_u_diff_ten[1] = nu;
148 mom_uv_diff_ten[0]=nu;
151 mom_v_diff_ten[0] = nu;
152 mom_v_diff_ten[1] = 2.0*nu;
154 mom_vu_diff_ten[0]=nu;
157 mom_u_source = g*h*grad_b[0];
158 dmom_u_source_h = g*grad_b[0];
160 mom_v_source = g*h*grad_b[1];
161 dmom_v_source_h = g*grad_b[1];
175 double rx[9],ry[9],rxInv[9],ryInv[9],
c=sqrt(fmax(1.0e-8,g*h)),lambdax[3],lambday[3],tauxHat[3],tauyHat[3],taux[9],tauy[9],tauc[9],cflx,cfly,
L[9],hStar=fmax(1.0e-8,h);
181 cflx = (
u+
c)/elementDiameter;
183 cflx = fabs(
u-
c)/elementDiameter;
185 double rn=sqrt(1.0+(
u-
c)*(
u-
c) +
v*
v);
187 rx[1*3+0] = (
u -
c)/rn;
194 rn = sqrt(1.0 + (
u+
c)*(
u+
c) +
v*
v);
196 rx[1*3+2] = (
u +
c)/rn;
199 rxInv[0*3+0] = 1.0 - (
c -
u)/(2.0*
c);
201 rxInv[2*3+0] = (
c-
u)/(2.0*
c);
203 rxInv[0*3+1] = -1.0/(2.0*
c);
205 rxInv[2*3+1] = 1.0/(2.0*
c);
217 tauxHat[0] = 0.5*elementDiameter/(fabs(lambdax[0])+1.0e-8);
218 tauxHat[1] = 0.5*elementDiameter/(fabs(lambdax[1])+1.0e-8);
219 tauxHat[2] = 0.5*elementDiameter/(fabs(lambdax[2])+1.0e-8);
225 rn=sqrt(1.0 +
u*
u+(
v-
c)*(
v-
c));
228 ry[2*3+0] = (
v -
c)/rn;
234 rn = sqrt(1.0 +
u*
u + (
v+
c)*(
v+
c));
237 ry[2*3+2] = (
v +
c)/rn;
239 ryInv[0*3+0] = 1.0 - (
c -
v)/(2*
c);
241 ryInv[2*3+0] = (
c-
v)/(2*
c);
247 ryInv[0*3+2] = -1.0/(2*
c);
249 ryInv[2*3+2] = 1.0/(2*
c);
252 tauyHat[0] = 0.5*elementDiameter/(fabs(lambday[0])+1.0e-8);
253 tauyHat[1] = 0.5*elementDiameter/(fabs(lambday[1])+1.0e-8);
254 tauyHat[2] = 0.5*elementDiameter/(fabs(lambday[2])+1.0e-8);
256 cfly = (
v+
c)/elementDiameter;
258 cfly = fabs(
v-
c)/elementDiameter;
259 cfl = sqrt(cflx*cflx+cfly*cfly);
263 double tmpx[9],tmpy[9];
264 for (
int i=0;i<3;i++)
265 for (
int j=0;j<3;j++)
283 for (
int i=0;i<3;i++)
284 for (
int j=0;j<3;j++)
285 for (
int m=0;m<3;m++)
291 tmpx[i*3+m] += rx[i*3+m]*tauxHat[m];
292 tmpy[i*3+m] += ry[i*3+m]*tauyHat[m];
295 for (
int i=0;i<3;i++)
296 for (
int j=0;j<3;j++)
297 for (
int m=0;m<3;m++)
301 taux[i*3+j] += tmpx[i*3+m]*rx[j*3 + m];
302 tauy[i*3+j] += tmpy[i*3+m]*ry[j*3 + m];
305 for (
int i=0;i<3;i++)
306 for (
int j=0;j<3;j++)
307 tauc[i*3+j] = sqrt(taux[i*3+j]*taux[i*3+j] + tauy[i*3+j]*tauy[i*3+j]);
311 L[1*3+1] = 1.0/hStar;
313 L[2*3+2] = 1.0/hStar;
314 for (
int i=0;i<3;i++)
315 for (
int j=0;j<3;j++)
317 for (
int k=0;k<3;k++)
318 tau[i*3+j] +=
L[i*3+k]*tauc[k*3+j];
345 double c=sqrt(fmax(1.0e-8,g*h)),lambdax[3],lambday[3],cflx,cfly,hStar=fmax(1.0e-8,h),dx,dy,a,ainv;
353 cflx = (
u+
c)/elementDiameter;
355 cflx = fabs(
u-
c)/elementDiameter;
360 cfly = (
v+
c)/elementDiameter;
362 cfly = fabs(
v-
c)/elementDiameter;
364 cfl = sqrt(cflx*cflx+cfly*cfly);
366 dx = sqrt(fabs(area)); dy = sqrt(fabs(area));
367 a = sqrt(
u*
u +
v*
v +
c*
c);
368 ainv = 1.0/(a+1.0e-8);
370 tau_x[0*3+0]=
u; tau_x[0*3+1]=h; tau_x[0*3+2]=0.;
371 tau_x[1*3+0]= h*g; tau_x[1*3+1]=h*
u; tau_x[1*3+2]=0.;
372 tau_x[2*3+0]= 0.; tau_x[2*3+1]=0.; tau_x[2*3+2]=
u*h;
373 for (i=0; i < 9; i++)
374 tau_x[i] *= alpha*dx*ainv;
376 tau_y[0*3+0]=
v; tau_y[0*3+1]=0; tau_y[0*3+2]=h;
377 tau_y[1*3+0]= 0.; tau_y[1*3+1]=h*
v; tau_y[1*3+2]=0.;
378 tau_y[2*3+0]= h*g; tau_y[2*3+1]=0.; tau_y[2*3+2]=
v*h;
379 for (i=0; i < 9; i++)
380 tau_y[i] *= alpha*dy*ainv;
386 const int& isDOFBoundary_u,
387 const int& isDOFBoundary_v,
388 const int& isFluxBoundary_h,
389 const int& isFluxBoundary_u,
390 const int& isFluxBoundary_v,
391 const double n[nSpace],
393 const double bc_f_mass[nSpace],
394 const double bc_f_umom[nSpace],
395 const double bc_f_vmom[nSpace],
396 const double& bc_flux_mass,
397 const double& bc_flux_umom,
398 const double& bc_flux_vmom,
400 const double f_mass[nSpace],
401 const double f_umom[nSpace],
402 const double f_vmom[nSpace],
403 const double df_mass_dh[nSpace],
404 const double df_mass_du[nSpace],
405 const double df_mass_dv[nSpace],
406 const double df_umom_dh[nSpace],
407 const double df_umom_du[nSpace],
408 const double df_umom_dv[nSpace],
409 const double df_vmom_dh[nSpace],
410 const double df_vmom_du[nSpace],
411 const double df_vmom_dv[nSpace],
496 if (isFluxBoundary_h == 1)
502 flux_mass = bc_flux_mass;
504 if (isFluxBoundary_u == 1)
506 flux_umom = bc_flux_umom;
508 if (isFluxBoundary_v == 1)
510 flux_vmom = bc_flux_vmom;
516 const int& isDOFBoundary_u,
517 const int& isDOFBoundary_v,
518 const int& isFluxBoundary_h,
519 const int& isFluxBoundary_u,
520 const int& isFluxBoundary_v,
521 const double n[nSpace],
523 const double bc_f_mass[nSpace],
524 const double bc_f_umom[nSpace],
525 const double bc_f_vmom[nSpace],
526 const double& bc_flux_mass,
527 const double& bc_flux_umom,
528 const double& bc_flux_vmom,
530 const double f_mass[nSpace],
531 const double f_umom[nSpace],
532 const double f_vmom[nSpace],
533 const double df_mass_du[nSpace],
534 const double df_mass_dv[nSpace],
535 const double df_umom_dh[nSpace],
536 const double df_umom_du[nSpace],
537 const double df_umom_dv[nSpace],
538 const double df_vmom_dh[nSpace],
539 const double df_vmom_du[nSpace],
540 const double df_vmom_dv[nSpace],
541 double& dflux_mass_dh,
542 double& dflux_mass_du,
543 double& dflux_mass_dv,
544 double& dflux_umom_dh,
545 double& dflux_umom_du,
546 double& dflux_umom_dv,
547 double& dflux_vmom_dh,
548 double& dflux_vmom_du,
549 double& dflux_vmom_dv)
551 double flowDirection;
564 flowDirection=
n[0]*f_mass[0]+
n[1]*f_mass[1];
637 if (isFluxBoundary_h == 1)
643 if (isFluxBoundary_u == 1)
649 if (isFluxBoundary_v == 1)
733 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
734 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
735 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
736 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
737 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
738 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
739 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
740 xt::pyarray<double>& h_trial_ref = args.
array<
double>(
"h_trial_ref");
741 xt::pyarray<double>& h_grad_trial_ref = args.
array<
double>(
"h_grad_trial_ref");
742 xt::pyarray<double>& h_test_ref = args.
array<
double>(
"h_test_ref");
743 xt::pyarray<double>& h_grad_test_ref = args.
array<
double>(
"h_grad_test_ref");
744 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
745 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
746 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
747 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
748 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
749 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
750 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
751 xt::pyarray<double>& h_trial_trace_ref = args.
array<
double>(
"h_trial_trace_ref");
752 xt::pyarray<double>& h_grad_trial_trace_ref = args.
array<
double>(
"h_grad_trial_trace_ref");
753 xt::pyarray<double>& h_test_trace_ref = args.
array<
double>(
"h_test_trace_ref");
754 xt::pyarray<double>& h_grad_test_trace_ref = args.
array<
double>(
"h_grad_test_trace_ref");
755 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
756 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
757 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
758 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
759 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
760 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
761 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
762 int nElements_global = args.
scalar<
int>(
"nElements_global");
763 double useRBLES = args.
scalar<
double>(
"useRBLES");
764 double useMetrics = args.
scalar<
double>(
"useMetrics");
765 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
766 double nu = args.
scalar<
double>(
"nu");
767 double g = args.
scalar<
double>(
"g");
768 double shockCapturingCoefficient = args.
scalar<
double>(
"shockCapturingCoefficient");
769 xt::pyarray<int>& h_l2g = args.
array<
int>(
"h_l2g");
770 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
771 xt::pyarray<double>& b_dof = args.
array<
double>(
"b_dof");
772 xt::pyarray<double>& h_dof = args.
array<
double>(
"h_dof");
773 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
774 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
775 xt::pyarray<double>& h_dof_sge = args.
array<
double>(
"h_dof_sge");
776 xt::pyarray<double>& u_dof_sge = args.
array<
double>(
"u_dof_sge");
777 xt::pyarray<double>& v_dof_sge = args.
array<
double>(
"v_dof_sge");
778 xt::pyarray<double>& q_mass_acc = args.
array<
double>(
"q_mass_acc");
779 xt::pyarray<double>& q_mom_u_acc = args.
array<
double>(
"q_mom_u_acc");
780 xt::pyarray<double>& q_mom_v_acc = args.
array<
double>(
"q_mom_v_acc");
781 xt::pyarray<double>& q_mass_adv = args.
array<
double>(
"q_mass_adv");
782 xt::pyarray<double>& q_mass_acc_beta_bdf = args.
array<
double>(
"q_mass_acc_beta_bdf");
783 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
784 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
785 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
786 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
787 xt::pyarray<double>& q_numDiff_h = args.
array<
double>(
"q_numDiff_h");
788 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
789 xt::pyarray<double>& q_numDiff_v = args.
array<
double>(
"q_numDiff_v");
790 xt::pyarray<double>& q_numDiff_h_last = args.
array<
double>(
"q_numDiff_h_last");
791 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
792 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
793 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
794 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
795 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
796 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
797 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
798 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
799 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
800 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
801 int offset_h = args.
scalar<
int>(
"offset_h");
802 int offset_u = args.
scalar<
int>(
"offset_u");
803 int offset_v = args.
scalar<
int>(
"offset_v");
804 int stride_h = args.
scalar<
int>(
"stride_h");
805 int stride_u = args.
scalar<
int>(
"stride_u");
806 int stride_v = args.
scalar<
int>(
"stride_v");
807 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
808 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
809 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
810 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
811 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
812 xt::pyarray<int>& isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
813 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
814 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
815 xt::pyarray<int>& isAdvectiveFluxBoundary_h = args.
array<
int>(
"isAdvectiveFluxBoundary_h");
816 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
817 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
818 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
819 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
820 xt::pyarray<double>& ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
821 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
822 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
823 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
824 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
825 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
826 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
827 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
828 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
829 xt::pyarray<double>& q_velocity = args.
array<
double>(
"q_velocity");
830 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
831 xt::pyarray<double>& flux = args.
array<
double>(
"flux");
832 xt::pyarray<double>& elementResidual_h_save = args.
array<
double>(
"elementResidual_h");
836 double globalConservationError=0.0,tauSum=0.0;
837 for(
int eN=0;eN<nElements_global;eN++)
840 register double elementResidual_h[nDOF_test_element],
841 elementResidual_u[nDOF_test_element],
842 elementResidual_v[nDOF_test_element];
843 for (
int i=0;i<nDOF_test_element;i++)
845 int eN_i = eN*nDOF_test_element+i;
846 elementResidual_h_save.data()[eN_i]=0.0;
847 elementResidual_h[i]=0.0;
848 elementResidual_u[i]=0.0;
849 elementResidual_v[i]=0.0;
854 for(
int k=0;k<nQuadraturePoints_element;k++)
857 register int eN_k = eN*nQuadraturePoints_element+k,
858 eN_k_nSpace = eN_k*nSpace,
859 eN_nDOF_trial_element = eN*nDOF_trial_element;
860 register double b=0.0,h=0.0,
u=0.0,
v=0.0,h_sge=0.0,u_sge=0.0,v_sge=0.0,
861 grad_b[nSpace],grad_h[nSpace],grad_u[nSpace],grad_v[nSpace],
874 dmass_adv_h_sge[nSpace],
875 dmass_adv_u_sge[nSpace],
876 dmass_adv_v_sge[nSpace],
878 dmom_u_adv_h[nSpace],
879 dmom_u_adv_u[nSpace],
880 dmom_u_adv_v[nSpace],
881 dmom_u_adv_h_sge[nSpace],
882 dmom_u_adv_u_sge[nSpace],
883 dmom_u_adv_v_sge[nSpace],
885 dmom_v_adv_h[nSpace],
886 dmom_v_adv_u[nSpace],
887 dmom_v_adv_v[nSpace],
888 dmom_v_adv_h_sge[nSpace],
889 dmom_v_adv_u_sge[nSpace],
890 dmom_v_adv_v_sge[nSpace],
891 mom_u_diff_ten[nSpace],
892 mom_v_diff_ten[nSpace],
911 Lstar_h_h[nDOF_test_element],
912 Lstar_u_h[nDOF_test_element],
913 Lstar_v_h[nDOF_test_element],
914 Lstar_h_u[nDOF_test_element],
915 Lstar_u_u[nDOF_test_element],
916 Lstar_v_u[nDOF_test_element],
917 Lstar_h_v[nDOF_test_element],
918 Lstar_u_v[nDOF_test_element],
919 Lstar_v_v[nDOF_test_element],
925 jacInv[nSpace*nSpace],
926 h_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
927 h_test_dV[nDOF_trial_element],vel_test_dV[nDOF_trial_element],
928 h_grad_test_dV[nDOF_test_element*nSpace],vel_grad_test_dV[nDOF_test_element*nSpace],
930 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv, dmom_adv_star[nSpace],dmom_adv_sge[nSpace];
932 ck.calculateMapping_element(eN,
936 mesh_trial_ref.data(),
937 mesh_grad_trial_ref.data(),
942 ck.calculateMappingVelocity_element(eN,
944 mesh_velocity_dof.data(),
946 mesh_trial_ref.data(),
951 dV = fabs(jacDet)*dV_ref.data()[k];
953 ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial);
954 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
956 ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b);
957 ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h);
958 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
959 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
960 ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge);
961 ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge);
962 ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge);
964 ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b);
965 ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h);
966 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
967 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
969 for (
int j=0;j<nDOF_trial_element;j++)
971 h_test_dV[j] = h_test_ref.data()[k*nDOF_trial_element+j]*dV;
972 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
973 for (
int I=0;I<nSpace;I++)
975 h_grad_test_dV[j*nSpace+I] = h_grad_trial[j*nSpace+I]*dV;
976 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
980 q_velocity.data()[eN_k_nSpace+0]=
u;
981 q_velocity.data()[eN_k_nSpace+1]=
v;
1022 q_mass_acc.data()[eN_k] = mass_acc;
1023 q_mom_u_acc.data()[eN_k] = mom_u_acc;
1024 q_mom_v_acc.data()[eN_k] = mom_v_acc;
1026 q_mass_adv.data()[eN_k_nSpace+0] = h*
u;
1027 q_mass_adv.data()[eN_k_nSpace+1] = h*
v;
1051 q_mass_acc_beta_bdf.data()[eN_k],
1057 q_mom_u_acc_beta_bdf.data()[eN_k],
1065 q_mom_v_acc_beta_bdf.data()[eN_k],
1076 dmass_adv_h_sge[0] = dmass_adv_h[0];
1077 dmass_adv_h_sge[1] = dmass_adv_h[1];
1078 dmass_adv_u_sge[0] = dmass_adv_u[0];
1079 dmass_adv_u_sge[1] = dmass_adv_u[1];
1080 dmass_adv_v_sge[0] = dmass_adv_v[0];
1081 dmass_adv_v_sge[1] = dmass_adv_v[1];
1082 dmom_u_adv_h_sge[0] = dmom_u_adv_h[0];
1083 dmom_u_adv_h_sge[1] = dmom_u_adv_h[1];
1084 dmom_u_adv_u_sge[0] = dmom_u_adv_u[0];
1085 dmom_u_adv_u_sge[1] = dmom_u_adv_u[1];
1086 dmom_u_adv_v_sge[0] = dmom_u_adv_v[0];
1087 dmom_u_adv_v_sge[1] = dmom_u_adv_v[1];
1088 dmom_v_adv_h_sge[0] = dmom_v_adv_h[0];
1089 dmom_v_adv_h_sge[1] = dmom_v_adv_h[1];
1090 dmom_v_adv_u_sge[0] = dmom_v_adv_u[0];
1091 dmom_v_adv_u_sge[1] = dmom_v_adv_u[1];
1092 dmom_v_adv_v_sge[0] = dmom_v_adv_v[0];
1093 dmom_v_adv_v_sge[1] = dmom_v_adv_v[1];
1129 dmass_adv_h_sge[0]=u_sge;
1130 dmass_adv_h_sge[1]=v_sge;
1132 dmass_adv_u_sge[0]=h_sge;
1133 dmass_adv_u_sge[1]=0.0;
1135 dmass_adv_v_sge[0]=0.0;
1136 dmass_adv_v_sge[1]=h_sge;
1139 dmom_u_adv_h_sge[0]=u_sge*u_sge + g*h_sge;
1140 dmom_u_adv_h_sge[1]=u_sge*v_sge;
1142 dmom_u_adv_u_sge[0]=h_sge*2.0*u_sge;
1143 dmom_u_adv_u_sge[1]=h_sge*v_sge;
1145 dmom_u_adv_v_sge[0]=0.0;
1146 dmom_u_adv_v_sge[1]=h_sge*u_sge;
1149 dmom_v_adv_h_sge[0]=v_sge*u_sge;
1150 dmom_v_adv_h_sge[1]=v_sge*v_sge + g*h_sge;
1152 dmom_v_adv_u_sge[0]=h_sge*v_sge;
1153 dmom_v_adv_u_sge[1]=0.0;
1155 dmom_v_adv_v_sge[0]=h_sge*u_sge;
1156 dmom_v_adv_v_sge[1]=h_sge*2.0*v_sge;
1158 pdeResidual_h =
ck.Mass_strong(mass_acc_t) +
1159 ck.Advection_strong(dmass_adv_h_sge,grad_h) +
1160 ck.Advection_strong(dmass_adv_u_sge,grad_u) +
1161 ck.Advection_strong(dmass_adv_v_sge,grad_v);
1163 pdeResidual_u =
ck.Mass_strong(mom_u_acc_t) +
1164 ck.Advection_strong(dmom_u_adv_h_sge,grad_h) +
1165 ck.Advection_strong(dmom_u_adv_u_sge,grad_u) +
1166 ck.Advection_strong(dmom_u_adv_v_sge,grad_v) +
1167 ck.Reaction_strong(mom_u_source);
1169 pdeResidual_v =
ck.Mass_strong(mom_v_acc_t) +
1170 ck.Advection_strong(dmom_v_adv_h_sge,grad_h) +
1171 ck.Advection_strong(dmom_v_adv_u_sge,grad_u) +
1172 ck.Advection_strong(dmom_v_adv_v_sge,grad_v) +
1173 ck.Reaction_strong(mom_v_source);
1182 q_cfl.data()[eN_k]);
1183 for (
int i=0;i<9;i++)
1186 subgridError_h = - tau[0*3+0]*pdeResidual_h - tau[0*3+1]*pdeResidual_u - tau[0*3+2]*pdeResidual_v;
1187 subgridError_u = - tau[1*3+0]*pdeResidual_h - tau[1*3+1]*pdeResidual_u - tau[1*3+2]*pdeResidual_v;
1188 subgridError_v = - tau[2*3+0]*pdeResidual_h - tau[2*3+1]*pdeResidual_u - tau[2*3+2]*pdeResidual_v;
1191 for (
int i=0;i<nDOF_test_element;i++)
1193 register int i_nSpace = i*nSpace;
1194 Lstar_h_h[i]=
ck.Advection_adjoint(dmass_adv_h_sge,&h_grad_test_dV[i_nSpace]);
1195 Lstar_u_h[i]=
ck.Advection_adjoint(dmass_adv_u_sge,&h_grad_test_dV[i_nSpace]);
1196 Lstar_v_h[i]=
ck.Advection_adjoint(dmass_adv_v_sge,&h_grad_test_dV[i_nSpace]);
1198 Lstar_h_u[i]=
ck.Advection_adjoint(dmom_u_adv_h_sge,&vel_grad_test_dV[i_nSpace]) +
1199 ck.Reaction_adjoint(dmom_u_source_h,vel_test_dV[i]);
1200 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_u_adv_u_sge,&vel_grad_test_dV[i_nSpace]);
1201 Lstar_v_u[i]=
ck.Advection_adjoint(dmom_u_adv_v_sge,&vel_grad_test_dV[i_nSpace]);
1203 Lstar_h_v[i]=
ck.Advection_adjoint(dmom_v_adv_h_sge,&vel_grad_test_dV[i_nSpace]) +
1204 ck.Reaction_adjoint(dmom_v_source_h,vel_test_dV[i]);
1205 Lstar_u_v[i]=
ck.Advection_adjoint(dmom_v_adv_u_sge,&vel_grad_test_dV[i_nSpace]);
1206 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_v_adv_v_sge,&vel_grad_test_dV[i_nSpace]);
1210 norm_Rv = sqrt(pdeResidual_u*pdeResidual_u + pdeResidual_v*pdeResidual_v);
1212 double norm_grad = 1.0;
1213 q_numDiff_u.data()[eN_k] = 0.5*elementDiameter.data()[eN]*norm_Rv/(norm_grad+1.0e-8);
1214 q_numDiff_v.data()[eN_k] = q_numDiff_u.data()[eN_k];
1224 for(
int i=0;i<nDOF_test_element;i++)
1226 register int i_nSpace=i*nSpace;
1228 elementResidual_h[i] +=
ck.Mass_weak(mass_acc_t,h_test_dV[i]) +
1229 ck.Advection_weak(mass_adv,&h_grad_test_dV[i_nSpace]) +
1230 ck.SubgridError(subgridError_h,Lstar_h_h[i]) +
1231 ck.SubgridError(subgridError_u,Lstar_u_h[i]) +
1232 ck.SubgridError(subgridError_v,Lstar_v_h[i]) +
1233 ck.NumericalDiffusion(q_numDiff_h_last.data()[eN_k],grad_h,&h_grad_test_dV[i_nSpace]);
1235 elementResidual_u[i] +=
ck.Mass_weak(mom_u_acc_t,vel_test_dV[i]) +
1236 ck.Advection_weak(mom_u_adv,&vel_grad_test_dV[i_nSpace]) +
1237 ck.Diffusion_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_u_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
1238 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]) +
1239 ck.Reaction_weak(mom_u_source,vel_test_dV[i]) +
1240 ck.SubgridError(subgridError_h,Lstar_h_u[i]) +
1241 ck.SubgridError(subgridError_u,Lstar_u_u[i]) +
1242 ck.SubgridError(subgridError_v,Lstar_v_u[i]) +
1243 ck.NumericalDiffusion(q_numDiff_u_last.data()[eN_k],grad_u,&vel_grad_test_dV[i_nSpace]);
1245 elementResidual_v[i] +=
ck.Mass_weak(mom_v_acc_t,vel_test_dV[i]) +
1246 ck.Advection_weak(mom_v_adv,&vel_grad_test_dV[i_nSpace]) +
1247 ck.Diffusion_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_v_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
1248 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]) +
1249 ck.Reaction_weak(mom_v_source,vel_test_dV[i]) +
1250 ck.SubgridError(subgridError_h,Lstar_h_v[i]) +
1251 ck.SubgridError(subgridError_u,Lstar_u_v[i]) +
1252 ck.SubgridError(subgridError_v,Lstar_v_v[i]) +
1253 ck.NumericalDiffusion(q_numDiff_v_last.data()[eN_k],grad_v,&vel_grad_test_dV[i_nSpace]);
1259 for(
int i=0;i<nDOF_test_element;i++)
1261 register int eN_i=eN*nDOF_test_element+i;
1263 elementResidual_h_save.data()[eN_i] += elementResidual_h[i];
1265 globalResidual.data()[offset_h+stride_h*h_l2g.data()[eN_i]]+=elementResidual_h[i];
1266 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
1267 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
1270 std::cout<<
"tauSum = "<<tauSum<<std::endl;
1670 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1671 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1672 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1673 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
1674 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
1675 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1676 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1677 xt::pyarray<double>& h_trial_ref = args.
array<
double>(
"h_trial_ref");
1678 xt::pyarray<double>& h_grad_trial_ref = args.
array<
double>(
"h_grad_trial_ref");
1679 xt::pyarray<double>& h_test_ref = args.
array<
double>(
"h_test_ref");
1680 xt::pyarray<double>& h_grad_test_ref = args.
array<
double>(
"h_grad_test_ref");
1681 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
1682 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
1683 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
1684 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
1685 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1686 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1687 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1688 xt::pyarray<double>& h_trial_trace_ref = args.
array<
double>(
"h_trial_trace_ref");
1689 xt::pyarray<double>& h_grad_trial_trace_ref = args.
array<
double>(
"h_grad_trial_trace_ref");
1690 xt::pyarray<double>& h_test_trace_ref = args.
array<
double>(
"h_test_trace_ref");
1691 xt::pyarray<double>& h_grad_test_trace_ref = args.
array<
double>(
"h_grad_test_trace_ref");
1692 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
1693 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
1694 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
1695 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
1696 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1697 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1698 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
1699 int nElements_global = args.
scalar<
int>(
"nElements_global");
1700 double useRBLES = args.
scalar<
double>(
"useRBLES");
1701 double useMetrics = args.
scalar<
double>(
"useMetrics");
1702 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
1703 double nu = args.
scalar<
double>(
"nu");
1704 double g = args.
scalar<
double>(
"g");
1705 double shockCapturingCoefficient = args.
scalar<
double>(
"shockCapturingCoefficient");
1706 xt::pyarray<int>& h_l2g = args.
array<
int>(
"h_l2g");
1707 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
1708 xt::pyarray<double>& b_dof = args.
array<
double>(
"b_dof");
1709 xt::pyarray<double>& h_dof = args.
array<
double>(
"h_dof");
1710 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1711 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
1712 xt::pyarray<double>& h_dof_sge = args.
array<
double>(
"h_dof_sge");
1713 xt::pyarray<double>& u_dof_sge = args.
array<
double>(
"u_dof_sge");
1714 xt::pyarray<double>& v_dof_sge = args.
array<
double>(
"v_dof_sge");
1715 xt::pyarray<double>& q_mass_acc = args.
array<
double>(
"q_mass_acc");
1716 xt::pyarray<double>& q_mom_u_acc = args.
array<
double>(
"q_mom_u_acc");
1717 xt::pyarray<double>& q_mom_v_acc = args.
array<
double>(
"q_mom_v_acc");
1718 xt::pyarray<double>& q_mass_adv = args.
array<
double>(
"q_mass_adv");
1719 xt::pyarray<double>& q_mass_acc_beta_bdf = args.
array<
double>(
"q_mass_acc_beta_bdf");
1720 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
1721 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
1722 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
1723 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
1724 xt::pyarray<double>& q_numDiff_h = args.
array<
double>(
"q_numDiff_h");
1725 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
1726 xt::pyarray<double>& q_numDiff_v = args.
array<
double>(
"q_numDiff_v");
1727 xt::pyarray<double>& q_numDiff_h_last = args.
array<
double>(
"q_numDiff_h_last");
1728 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
1729 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
1730 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
1731 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
1732 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
1733 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
1734 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
1735 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
1736 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
1737 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
1738 int offset_h = args.
scalar<
int>(
"offset_h");
1739 int offset_u = args.
scalar<
int>(
"offset_u");
1740 int offset_v = args.
scalar<
int>(
"offset_v");
1741 int stride_h = args.
scalar<
int>(
"stride_h");
1742 int stride_u = args.
scalar<
int>(
"stride_u");
1743 int stride_v = args.
scalar<
int>(
"stride_v");
1744 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
1745 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1746 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1747 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1748 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1749 xt::pyarray<int>& isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
1750 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1751 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
1752 xt::pyarray<int>& isAdvectiveFluxBoundary_h = args.
array<
int>(
"isAdvectiveFluxBoundary_h");
1753 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
1754 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
1755 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
1756 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
1757 xt::pyarray<double>& ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
1758 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
1759 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
1760 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
1761 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
1762 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
1763 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
1764 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
1765 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
1766 xt::pyarray<double>& q_velocity = args.
array<
double>(
"q_velocity");
1767 xt::pyarray<double>& ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
1768 xt::pyarray<double>& flux = args.
array<
double>(
"flux");
1769 xt::pyarray<double>& elementResidual_h_save = args.
array<
double>(
"elementResidual_h");
1773 double globalConservationError=0.0;
1774 for(
int eN=0;eN<nElements_global;eN++)
1777 register double elementResidual_h[nDOF_test_element],
1778 elementResidual_u[nDOF_test_element],
1779 elementResidual_v[nDOF_test_element];
1780 for (
int i=0;i<nDOF_test_element;i++)
1782 int eN_i = eN*nDOF_test_element+i;
1783 elementResidual_h_save.data()[eN_i]=0.0;
1784 elementResidual_h[i]=0.0;
1785 elementResidual_u[i]=0.0;
1786 elementResidual_v[i]=0.0;
1791 for(
int k=0;k<nQuadraturePoints_element;k++)
1794 register int eN_k = eN*nQuadraturePoints_element+k,
1795 eN_k_nSpace = eN_k*nSpace,
1796 eN_nDOF_trial_element = eN*nDOF_trial_element;
1797 register double b=0.0,h=0.0,
u=0.0,
v=0.0,h_sge=0.0,u_sge=0.0,v_sge=0.0,
1798 grad_b[nSpace],grad_h[nSpace],grad_u[nSpace],grad_v[nSpace],
1808 dmass_adv_h[nSpace],
1809 dmass_adv_u[nSpace],
1810 dmass_adv_v[nSpace],
1811 dmass_adv_h_sge[nSpace],
1812 dmass_adv_u_sge[nSpace],
1813 dmass_adv_v_sge[nSpace],
1815 dmom_u_adv_h[nSpace],
1816 dmom_u_adv_u[nSpace],
1817 dmom_u_adv_v[nSpace],
1818 dmom_u_adv_h_sge[nSpace],
1819 dmom_u_adv_u_sge[nSpace],
1820 dmom_u_adv_v_sge[nSpace],
1822 dmom_v_adv_h[nSpace],
1823 dmom_v_adv_u[nSpace],
1824 dmom_v_adv_v[nSpace],
1825 dmom_v_adv_h_sge[nSpace],
1826 dmom_v_adv_u_sge[nSpace],
1827 dmom_v_adv_v_sge[nSpace],
1828 mom_u_diff_ten[nSpace],
1829 mom_v_diff_ten[nSpace],
1833 dmom_u_source_h=0.0,
1835 dmom_v_source_h=0.0,
1849 Lhat_x[nDOF_test_element],
1850 Lhat_y[nDOF_test_element],
1851 subgridError_hx=0.0,
1852 subgridError_ux=0.0,
1853 subgridError_vx=0.0,
1854 subgridError_hy=0.0,
1855 subgridError_uy=0.0,
1856 subgridError_vy=0.0,
1860 jacInv[nSpace*nSpace],
1861 h_grad_trial[nDOF_trial_element*nSpace],vel_grad_trial[nDOF_trial_element*nSpace],
1862 h_test_dV[nDOF_trial_element],vel_test_dV[nDOF_trial_element],
1863 h_grad_test_dV[nDOF_test_element*nSpace],vel_grad_test_dV[nDOF_test_element*nSpace],
1865 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv, dmom_adv_star[nSpace],dmom_adv_sge[nSpace];
1868 double alpha_tau=0.25;
1869 double include_acc_in_strong_mom = 1.0;
1871 ck.calculateMapping_element(eN,
1875 mesh_trial_ref.data(),
1876 mesh_grad_trial_ref.data(),
1881 ck.calculateMappingVelocity_element(eN,
1883 mesh_velocity_dof.data(),
1885 mesh_trial_ref.data(),
1890 dV = fabs(jacDet)*dV_ref.data()[k];
1892 ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial);
1893 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
1895 ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b);
1896 ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h);
1897 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
1898 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
1899 ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge);
1900 ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge);
1901 ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge);
1903 ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b);
1904 ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h);
1905 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
1906 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
1908 for (
int j=0;j<nDOF_trial_element;j++)
1910 h_test_dV[j] = h_test_ref.data()[k*nDOF_trial_element+j]*dV;
1911 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
1912 for (
int I=0;I<nSpace;I++)
1914 h_grad_test_dV[j*nSpace+I] = h_grad_trial[j*nSpace+I]*dV;
1915 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
1919 q_velocity.data()[eN_k_nSpace+0]=
u;
1920 q_velocity.data()[eN_k_nSpace+1]=
v;
1961 q_mass_acc.data()[eN_k] = mass_acc;
1962 q_mom_u_acc.data()[eN_k] = mom_u_acc;
1963 q_mom_v_acc.data()[eN_k] = mom_v_acc;
1965 q_mass_adv.data()[eN_k_nSpace+0] = h*
u;
1966 q_mass_adv.data()[eN_k_nSpace+1] = h*
v;
1972 q_mass_acc_beta_bdf.data()[eN_k],
1978 q_mom_u_acc_beta_bdf.data()[eN_k],
1986 q_mom_v_acc_beta_bdf.data()[eN_k],
1997 dmass_adv_h_sge[0] = dmass_adv_h[0];
1998 dmass_adv_h_sge[1] = dmass_adv_h[1];
1999 dmass_adv_u_sge[0] = dmass_adv_u[0];
2000 dmass_adv_u_sge[1] = dmass_adv_u[1];
2001 dmass_adv_v_sge[0] = dmass_adv_v[0];
2002 dmass_adv_v_sge[1] = dmass_adv_v[1];
2003 dmom_u_adv_h_sge[0] = dmom_u_adv_h[0];
2004 dmom_u_adv_h_sge[1] = dmom_u_adv_h[1];
2005 dmom_u_adv_u_sge[0] = dmom_u_adv_u[0];
2006 dmom_u_adv_u_sge[1] = dmom_u_adv_u[1];
2007 dmom_u_adv_v_sge[0] = dmom_u_adv_v[0];
2008 dmom_u_adv_v_sge[1] = dmom_u_adv_v[1];
2009 dmom_v_adv_h_sge[0] = dmom_v_adv_h[0];
2010 dmom_v_adv_h_sge[1] = dmom_v_adv_h[1];
2011 dmom_v_adv_u_sge[0] = dmom_v_adv_u[0];
2012 dmom_v_adv_u_sge[1] = dmom_v_adv_u[1];
2013 dmom_v_adv_v_sge[0] = dmom_v_adv_v[0];
2014 dmom_v_adv_v_sge[1] = dmom_v_adv_v[1];
2019 dmass_adv_h_sge[0]=u_sge;
2020 dmass_adv_h_sge[1]=v_sge;
2022 dmass_adv_u_sge[0]=h_sge;
2023 dmass_adv_u_sge[1]=0.0;
2025 dmass_adv_v_sge[0]=0.0;
2026 dmass_adv_v_sge[1]=h_sge;
2029 dmom_u_adv_h_sge[0]=u_sge*u_sge + g*h_sge;
2030 dmom_u_adv_h_sge[1]=u_sge*v_sge;
2032 dmom_u_adv_u_sge[0]=h_sge*2.0*u_sge;
2033 dmom_u_adv_u_sge[1]=h_sge*v_sge;
2035 dmom_u_adv_v_sge[0]=0.0;
2036 dmom_u_adv_v_sge[1]=h_sge*u_sge;
2039 dmom_v_adv_h_sge[0]=v_sge*u_sge;
2040 dmom_v_adv_h_sge[1]=v_sge*v_sge + g*h_sge;
2042 dmom_v_adv_u_sge[0]=h_sge*v_sge;
2043 dmom_v_adv_u_sge[1]=0.0;
2045 dmom_v_adv_v_sge[0]=h_sge*u_sge;
2046 dmom_v_adv_v_sge[1]=h_sge*2.0*v_sge;
2048 pdeResidual_h =
ck.Mass_strong(mass_acc_t) +
2049 ck.Advection_strong(dmass_adv_h_sge,grad_h) +
2050 ck.Advection_strong(dmass_adv_u_sge,grad_u) +
2051 ck.Advection_strong(dmass_adv_v_sge,grad_v);
2053 pdeResidual_u = include_acc_in_strong_mom*
ck.Mass_strong(mom_u_acc_t) +
2054 ck.Advection_strong(dmom_u_adv_h_sge,grad_h) +
2055 ck.Advection_strong(dmom_u_adv_u_sge,grad_u) +
2056 ck.Advection_strong(dmom_u_adv_v_sge,grad_v) +
2057 ck.Reaction_strong(mom_u_source);
2059 pdeResidual_v = include_acc_in_strong_mom*
ck.Mass_strong(mom_v_acc_t) +
2060 ck.Advection_strong(dmom_v_adv_h_sge,grad_h) +
2061 ck.Advection_strong(dmom_v_adv_u_sge,grad_u) +
2062 ck.Advection_strong(dmom_v_adv_v_sge,grad_v) +
2063 ck.Reaction_strong(mom_v_source);
2075 q_cfl.data()[eN_k]);
2077 subgridError_hx = - tau_x[0*3+0]*pdeResidual_h - tau_x[0*3+1]*pdeResidual_u - tau_x[0*3+2]*pdeResidual_v;
2078 subgridError_ux = - tau_x[1*3+0]*pdeResidual_h - tau_x[1*3+1]*pdeResidual_u - tau_x[1*3+2]*pdeResidual_v;
2079 subgridError_vx = - tau_x[2*3+0]*pdeResidual_h - tau_x[2*3+1]*pdeResidual_u - tau_x[2*3+2]*pdeResidual_v;
2081 subgridError_hy = - tau_y[0*3+0]*pdeResidual_h - tau_y[0*3+1]*pdeResidual_u - tau_y[0*3+2]*pdeResidual_v;
2082 subgridError_uy = - tau_y[1*3+0]*pdeResidual_h - tau_y[1*3+1]*pdeResidual_u - tau_y[1*3+2]*pdeResidual_v;
2083 subgridError_vy = - tau_y[2*3+0]*pdeResidual_h - tau_y[2*3+1]*pdeResidual_u - tau_y[2*3+2]*pdeResidual_v;
2086 for (
int i=0;i<nDOF_test_element;i++)
2088 register int i_nSpace = i*nSpace;
2089 Lhat_x[i]= -h_grad_test_dV[i_nSpace];
2090 Lhat_y[i]= -h_grad_test_dV[i_nSpace+1];
2093 norm_Rv = sqrt(pdeResidual_u*pdeResidual_u + pdeResidual_v*pdeResidual_v);
2095 double grad_norm[2] = {1.0,0.0};
2096 ck.calculateNumericalDiffusion(shockCapturingCoefficient,
2097 elementDiameter.data()[eN],
2100 q_numDiff_u.data()[eN_k]);
2103 q_numDiff_v.data()[eN_k] = q_numDiff_u.data()[eN_k];
2113 for(
int i=0;i<nDOF_test_element;i++)
2115 register int i_nSpace=i*nSpace;
2117 elementResidual_h[i] +=
ck.Mass_weak(mass_acc_t,h_test_dV[i]) +
2118 ck.Advection_weak(mass_adv,&h_grad_test_dV[i_nSpace]) +
2120 ck.SubgridError(subgridError_hx,Lhat_x[i]) +
2121 ck.SubgridError(subgridError_hy,Lhat_y[i]) +
2122 ck.NumericalDiffusion(q_numDiff_h_last.data()[eN_k],grad_h,&h_grad_test_dV[i_nSpace]);
2124 elementResidual_u[i] +=
ck.Mass_weak(mom_u_acc_t,vel_test_dV[i]) +
2125 ck.Advection_weak(mom_u_adv,&vel_grad_test_dV[i_nSpace]) +
2126 ck.Diffusion_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_u_diff_ten,grad_u,&vel_grad_test_dV[i_nSpace]) +
2127 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]) +
2128 ck.Reaction_weak(mom_u_source,vel_test_dV[i]) +
2130 ck.SubgridError(subgridError_ux,Lhat_x[i]) +
2131 ck.SubgridError(subgridError_uy,Lhat_y[i]) +
2132 ck.NumericalDiffusion(q_numDiff_u_last.data()[eN_k],grad_u,&vel_grad_test_dV[i_nSpace]);
2134 elementResidual_v[i] +=
ck.Mass_weak(mom_v_acc_t,vel_test_dV[i]) +
2135 ck.Advection_weak(mom_v_adv,&vel_grad_test_dV[i_nSpace]) +
2136 ck.Diffusion_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_v_diff_ten,grad_v,&vel_grad_test_dV[i_nSpace]) +
2137 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]) +
2138 ck.Reaction_weak(mom_v_source,vel_test_dV[i]) +
2140 ck.SubgridError(subgridError_vx,Lhat_x[i]) +
2141 ck.SubgridError(subgridError_vy,Lhat_y[i]) +
2142 ck.NumericalDiffusion(q_numDiff_v_last.data()[eN_k],grad_v,&vel_grad_test_dV[i_nSpace]);
2148 for(
int i=0;i<nDOF_test_element;i++)
2150 register int eN_i=eN*nDOF_test_element+i;
2152 elementResidual_h_save.data()[eN_i] += elementResidual_h[i];
2154 globalResidual.data()[offset_h+stride_h*h_l2g.data()[eN_i]]+=elementResidual_h[i];
2155 globalResidual.data()[offset_u+stride_u*vel_l2g.data()[eN_i]]+=elementResidual_u[i];
2156 globalResidual.data()[offset_v+stride_v*vel_l2g.data()[eN_i]]+=elementResidual_v[i];
2162 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2163 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
2164 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
2165 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
2166 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
2167 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
2168 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
2169 xt::pyarray<double>& h_trial_ref = args.
array<
double>(
"h_trial_ref");
2170 xt::pyarray<double>& h_grad_trial_ref = args.
array<
double>(
"h_grad_trial_ref");
2171 xt::pyarray<double>& h_test_ref = args.
array<
double>(
"h_test_ref");
2172 xt::pyarray<double>& h_grad_test_ref = args.
array<
double>(
"h_grad_test_ref");
2173 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2174 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
2175 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
2176 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
2177 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
2178 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
2179 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
2180 xt::pyarray<double>& h_trial_trace_ref = args.
array<
double>(
"h_trial_trace_ref");
2181 xt::pyarray<double>& h_grad_trial_trace_ref = args.
array<
double>(
"h_grad_trial_trace_ref");
2182 xt::pyarray<double>& h_test_trace_ref = args.
array<
double>(
"h_test_trace_ref");
2183 xt::pyarray<double>& h_grad_test_trace_ref = args.
array<
double>(
"h_grad_test_trace_ref");
2184 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
2185 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
2186 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
2187 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
2188 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
2189 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
2190 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
2191 int nElements_global = args.
scalar<
int>(
"nElements_global");
2192 double useRBLES = args.
scalar<
double>(
"useRBLES");
2193 double useMetrics = args.
scalar<
double>(
"useMetrics");
2194 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
2195 double nu = args.
scalar<
double>(
"nu");
2196 double g = args.
scalar<
double>(
"g");
2197 xt::pyarray<int>& h_l2g = args.
array<
int>(
"h_l2g");
2198 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
2199 xt::pyarray<double>& b_dof = args.
array<
double>(
"b_dof");
2200 xt::pyarray<double>& h_dof = args.
array<
double>(
"h_dof");
2201 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
2202 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
2203 xt::pyarray<double>& h_dof_sge = args.
array<
double>(
"h_dof_sge");
2204 xt::pyarray<double>& u_dof_sge = args.
array<
double>(
"u_dof_sge");
2205 xt::pyarray<double>& v_dof_sge = args.
array<
double>(
"v_dof_sge");
2206 xt::pyarray<double>& q_mass_acc_beta_bdf = args.
array<
double>(
"q_mass_acc_beta_bdf");
2207 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
2208 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
2209 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
2210 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
2211 xt::pyarray<double>& q_numDiff_h_last = args.
array<
double>(
"q_numDiff_h_last");
2212 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
2213 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
2214 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
2215 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
2216 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
2217 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
2218 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
2219 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
2220 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
2221 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
2222 xt::pyarray<int>& csrRowIndeces_h_h = args.
array<
int>(
"csrRowIndeces_h_h");
2223 xt::pyarray<int>& csrColumnOffsets_h_h = args.
array<
int>(
"csrColumnOffsets_h_h");
2224 xt::pyarray<int>& csrRowIndeces_h_u = args.
array<
int>(
"csrRowIndeces_h_u");
2225 xt::pyarray<int>& csrColumnOffsets_h_u = args.
array<
int>(
"csrColumnOffsets_h_u");
2226 xt::pyarray<int>& csrRowIndeces_h_v = args.
array<
int>(
"csrRowIndeces_h_v");
2227 xt::pyarray<int>& csrColumnOffsets_h_v = args.
array<
int>(
"csrColumnOffsets_h_v");
2228 xt::pyarray<int>& csrRowIndeces_u_h = args.
array<
int>(
"csrRowIndeces_u_h");
2229 xt::pyarray<int>& csrColumnOffsets_u_h = args.
array<
int>(
"csrColumnOffsets_u_h");
2230 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
2231 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
2232 xt::pyarray<int>& csrRowIndeces_u_v = args.
array<
int>(
"csrRowIndeces_u_v");
2233 xt::pyarray<int>& csrColumnOffsets_u_v = args.
array<
int>(
"csrColumnOffsets_u_v");
2234 xt::pyarray<int>& csrRowIndeces_v_h = args.
array<
int>(
"csrRowIndeces_v_h");
2235 xt::pyarray<int>& csrColumnOffsets_v_h = args.
array<
int>(
"csrColumnOffsets_v_h");
2236 xt::pyarray<int>& csrRowIndeces_v_u = args.
array<
int>(
"csrRowIndeces_v_u");
2237 xt::pyarray<int>& csrColumnOffsets_v_u = args.
array<
int>(
"csrColumnOffsets_v_u");
2238 xt::pyarray<int>& csrRowIndeces_v_v = args.
array<
int>(
"csrRowIndeces_v_v");
2239 xt::pyarray<int>& csrColumnOffsets_v_v = args.
array<
int>(
"csrColumnOffsets_v_v");
2240 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
2241 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
2242 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
2243 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
2244 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
2245 xt::pyarray<int>& isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
2246 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
2247 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
2248 xt::pyarray<int>& isAdvectiveFluxBoundary_h = args.
array<
int>(
"isAdvectiveFluxBoundary_h");
2249 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
2250 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
2251 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
2252 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
2253 xt::pyarray<double>& ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
2254 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
2255 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
2256 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
2257 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
2258 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
2259 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
2260 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
2261 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
2262 xt::pyarray<int>& csrColumnOffsets_eb_h_h = args.
array<
int>(
"csrColumnOffsets_eb_h_h");
2263 xt::pyarray<int>& csrColumnOffsets_eb_h_u = args.
array<
int>(
"csrColumnOffsets_eb_h_u");
2264 xt::pyarray<int>& csrColumnOffsets_eb_h_v = args.
array<
int>(
"csrColumnOffsets_eb_h_v");
2265 xt::pyarray<int>& csrColumnOffsets_eb_u_h = args.
array<
int>(
"csrColumnOffsets_eb_u_h");
2266 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
2267 xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.
array<
int>(
"csrColumnOffsets_eb_u_v");
2268 xt::pyarray<int>& csrColumnOffsets_eb_v_h = args.
array<
int>(
"csrColumnOffsets_eb_v_h");
2269 xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.
array<
int>(
"csrColumnOffsets_eb_v_u");
2270 xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.
array<
int>(
"csrColumnOffsets_eb_v_v");
2275 for(
int eN=0;eN<nElements_global;eN++)
2277 register double elementJacobian_h_h[nDOF_test_element][nDOF_trial_element],
2278 elementJacobian_h_u[nDOF_test_element][nDOF_trial_element],
2279 elementJacobian_h_v[nDOF_test_element][nDOF_trial_element],
2280 elementJacobian_u_h[nDOF_test_element][nDOF_trial_element],
2281 elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
2282 elementJacobian_u_v[nDOF_test_element][nDOF_trial_element],
2283 elementJacobian_v_h[nDOF_test_element][nDOF_trial_element],
2284 elementJacobian_v_u[nDOF_test_element][nDOF_trial_element],
2285 elementJacobian_v_v[nDOF_test_element][nDOF_trial_element];
2286 for (
int i=0;i<nDOF_test_element;i++)
2287 for (
int j=0;j<nDOF_trial_element;j++)
2289 elementJacobian_h_h[i][j]=0.0;
2290 elementJacobian_h_u[i][j]=0.0;
2291 elementJacobian_h_v[i][j]=0.0;
2292 elementJacobian_u_h[i][j]=0.0;
2293 elementJacobian_u_u[i][j]=0.0;
2294 elementJacobian_u_v[i][j]=0.0;
2295 elementJacobian_v_h[i][j]=0.0;
2296 elementJacobian_v_u[i][j]=0.0;
2297 elementJacobian_v_v[i][j]=0.0;
2299 for (
int k=0;k<nQuadraturePoints_element;k++)
2301 int eN_k = eN*nQuadraturePoints_element+k,
2302 eN_k_nSpace = eN_k*nSpace,
2303 eN_nDOF_trial_element = eN*nDOF_trial_element;
2306 register double b=0.0,
2326 dmass_adv_h[nSpace],
2327 dmass_adv_u[nSpace],
2328 dmass_adv_v[nSpace],
2329 dmass_adv_h_sge[nSpace],
2330 dmass_adv_u_sge[nSpace],
2331 dmass_adv_v_sge[nSpace],
2333 dmom_u_adv_h[nSpace],
2334 dmom_u_adv_u[nSpace],
2335 dmom_u_adv_v[nSpace],
2336 dmom_u_adv_h_sge[nSpace],
2337 dmom_u_adv_u_sge[nSpace],
2338 dmom_u_adv_v_sge[nSpace],
2340 dmom_v_adv_h[nSpace],
2341 dmom_v_adv_u[nSpace],
2342 dmom_v_adv_v[nSpace],
2343 dmom_v_adv_h_sge[nSpace],
2344 dmom_v_adv_u_sge[nSpace],
2345 dmom_v_adv_v_sge[nSpace],
2346 mom_u_diff_ten[nSpace],
2347 mom_v_diff_ten[nSpace],
2351 dmom_u_source_h=0.0,
2353 dmom_v_source_h=0.0,
2366 dpdeResidual_h_h[nDOF_trial_element],
2367 dpdeResidual_h_u[nDOF_trial_element],
2368 dpdeResidual_h_v[nDOF_trial_element],
2369 dpdeResidual_u_h[nDOF_trial_element],
2370 dpdeResidual_u_u[nDOF_trial_element],
2371 dpdeResidual_u_v[nDOF_trial_element],
2372 dpdeResidual_v_h[nDOF_trial_element],
2373 dpdeResidual_v_u[nDOF_trial_element],
2374 dpdeResidual_v_v[nDOF_trial_element],
2375 Lstar_h_h[nDOF_test_element],
2376 Lstar_u_h[nDOF_test_element],
2377 Lstar_v_h[nDOF_test_element],
2378 Lstar_h_u[nDOF_test_element],
2379 Lstar_u_u[nDOF_test_element],
2380 Lstar_v_u[nDOF_test_element],
2381 Lstar_h_v[nDOF_test_element],
2382 Lstar_u_v[nDOF_test_element],
2383 Lstar_v_v[nDOF_test_element],
2387 dsubgridError_h_h[nDOF_trial_element],
2388 dsubgridError_h_u[nDOF_trial_element],
2389 dsubgridError_h_v[nDOF_trial_element],
2390 dsubgridError_u_h[nDOF_trial_element],
2391 dsubgridError_u_u[nDOF_trial_element],
2392 dsubgridError_u_v[nDOF_trial_element],
2393 dsubgridError_v_h[nDOF_trial_element],
2394 dsubgridError_v_u[nDOF_trial_element],
2395 dsubgridError_v_v[nDOF_trial_element],
2396 tau_h=0.0,tau_h0=0.0,tau_h1=0.0,
2397 tau_v=0.0,tau_v0=0.0,tau_v1=0.0,
2400 jacInv[nSpace*nSpace],
2401 h_grad_trial[nDOF_trial_element*nSpace],
2402 vel_grad_trial[nDOF_trial_element*nSpace],
2404 h_test_dV[nDOF_test_element],
2405 vel_test_dV[nDOF_test_element],
2406 h_grad_test_dV[nDOF_test_element*nSpace],
2407 vel_grad_test_dV[nDOF_test_element*nSpace],
2409 G[nSpace*nSpace],G_dd_G,tr_G, dmom_adv_star[nSpace], dmom_adv_sge[nSpace];
2411 ck.calculateMapping_element(eN,
2415 mesh_trial_ref.data(),
2416 mesh_grad_trial_ref.data(),
2421 ck.calculateMappingVelocity_element(eN,
2423 mesh_velocity_dof.data(),
2425 mesh_trial_ref.data(),
2428 dV = fabs(jacDet)*dV_ref.data()[k];
2431 ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial);
2432 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
2434 ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b);
2435 ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h);
2436 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
2437 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
2438 ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge);
2439 ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge);
2440 ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge);
2442 ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b);
2443 ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h);
2444 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
2445 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
2447 for (
int j=0;j<nDOF_trial_element;j++)
2449 h_test_dV[j] = h_test_ref.data()[k*nDOF_trial_element+j]*dV;
2450 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
2451 for (
int I=0;I<nSpace;I++)
2453 h_grad_test_dV[j*nSpace+I] = h_grad_trial[j*nSpace+I]*dV;
2454 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
2521 q_mass_acc_beta_bdf.data()[eN_k],
2527 q_mom_u_acc_beta_bdf.data()[eN_k],
2535 q_mom_v_acc_beta_bdf.data()[eN_k],
2548 dmass_adv_h_sge[0] = dmass_adv_h[0];
2549 dmass_adv_h_sge[1] = dmass_adv_h[1];
2550 dmass_adv_u_sge[0] = dmass_adv_u[0];
2551 dmass_adv_u_sge[1] = dmass_adv_u[1];
2552 dmass_adv_v_sge[0] = dmass_adv_v[0];
2553 dmass_adv_v_sge[1] = dmass_adv_v[1];
2554 dmom_u_adv_h_sge[0] = dmom_u_adv_h[0];
2555 dmom_u_adv_h_sge[1] = dmom_u_adv_h[1];
2556 dmom_u_adv_u_sge[0] = dmom_u_adv_u[0];
2557 dmom_u_adv_u_sge[1] = dmom_u_adv_u[1];
2558 dmom_u_adv_v_sge[0] = dmom_u_adv_v[0];
2559 dmom_u_adv_v_sge[1] = dmom_u_adv_v[1];
2560 dmom_v_adv_h_sge[0] = dmom_v_adv_h[0];
2561 dmom_v_adv_h_sge[1] = dmom_v_adv_h[1];
2562 dmom_v_adv_u_sge[0] = dmom_v_adv_u[0];
2563 dmom_v_adv_u_sge[1] = dmom_v_adv_u[1];
2564 dmom_v_adv_v_sge[0] = dmom_v_adv_v[0];
2565 dmom_v_adv_v_sge[1] = dmom_v_adv_v[1];
2600 dmass_adv_h_sge[0]=u_sge;
2601 dmass_adv_h_sge[1]=v_sge;
2603 dmass_adv_u_sge[0]=h_sge;
2604 dmass_adv_u_sge[1]=0.0;
2606 dmass_adv_v_sge[0]=0.0;
2607 dmass_adv_v_sge[1]=h_sge;
2610 dmom_u_adv_h_sge[0]=u_sge*u_sge + g*h_sge;
2611 dmom_u_adv_h_sge[1]=u_sge*v_sge;
2613 dmom_u_adv_u_sge[0]=h_sge*2.0*u_sge;
2614 dmom_u_adv_u_sge[1]=h_sge*v_sge;
2616 dmom_u_adv_v_sge[0]=0.0;
2617 dmom_u_adv_v_sge[1]=h_sge*u_sge;
2620 dmom_v_adv_h_sge[0]=v_sge*u_sge;
2621 dmom_v_adv_h_sge[1]=v_sge*v_sge + g*h_sge;
2623 dmom_v_adv_u_sge[0]=h_sge*v_sge;
2624 dmom_v_adv_u_sge[1]=0.0;
2626 dmom_v_adv_v_sge[0]=h_sge*u_sge;
2627 dmom_v_adv_v_sge[1]=h_sge*2.0*v_sge;
2630 for (
int j=0;j<nDOF_trial_element;j++)
2632 register int j_nSpace = j*nSpace;
2634 dpdeResidual_h_h[j]=
ck.MassJacobian_strong(dmass_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
2635 ck.AdvectionJacobian_strong(dmass_adv_h_sge,&h_grad_trial[j_nSpace]);
2637 dpdeResidual_h_u[j]=
ck.AdvectionJacobian_strong(dmass_adv_u_sge,&vel_grad_trial[j_nSpace]);
2639 dpdeResidual_h_v[j]=
ck.AdvectionJacobian_strong(dmass_adv_v_sge,&vel_grad_trial[j_nSpace]);
2641 dpdeResidual_u_h[j]=
ck.MassJacobian_strong(dmom_u_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
2642 ck.AdvectionJacobian_strong(dmom_u_adv_h_sge,&h_grad_trial[j_nSpace]) +
2643 ck.ReactionJacobian_strong(dmom_u_source_h,h_trial_ref.data()[k*nDOF_trial_element+j]);
2645 dpdeResidual_u_u[j]=
ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j])+
2646 ck.AdvectionJacobian_strong(dmom_u_adv_u_sge,&vel_grad_trial[j_nSpace]);
2648 dpdeResidual_u_v[j]=
ck.AdvectionJacobian_strong(dmom_u_adv_v_sge,&vel_grad_trial[j_nSpace]);
2650 dpdeResidual_v_h[j]=
ck.MassJacobian_strong(dmom_v_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
2651 ck.AdvectionJacobian_strong(dmom_v_adv_h_sge,&h_grad_trial[j_nSpace])+
2652 ck.ReactionJacobian_strong(dmom_v_source_h,h_trial_ref.data()[k*nDOF_trial_element+j]);
2654 dpdeResidual_v_u[j]=
ck.AdvectionJacobian_strong(dmom_v_adv_u_sge,&vel_grad_trial[j_nSpace]);
2656 dpdeResidual_v_v[j]=
ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j])+
2657 ck.AdvectionJacobian_strong(dmom_v_adv_v_sge,&vel_grad_trial[j_nSpace]);
2668 q_cfl.data()[eN_k]);
2670 for (
int i=0;i<9;i++)
2673 for (
int j=0;j<nDOF_trial_element;j++)
2675 dsubgridError_h_h[j] = - tau[0*3+0]*dpdeResidual_h_h[j] - tau[0*3+1]*dpdeResidual_u_h[j] - tau[0*3+2]*dpdeResidual_v_h[j];
2676 dsubgridError_h_u[j] = - tau[0*3+0]*dpdeResidual_h_u[j] - tau[0*3+1]*dpdeResidual_u_u[j] - tau[0*3+2]*dpdeResidual_v_u[j];
2677 dsubgridError_h_v[j] = - tau[0*3+0]*dpdeResidual_h_v[j] - tau[0*3+1]*dpdeResidual_u_v[j] - tau[0*3+2]*dpdeResidual_v_v[j];
2679 dsubgridError_u_h[j] = - tau[1*3+0]*dpdeResidual_h_h[j] - tau[1*3+1]*dpdeResidual_u_h[j] - tau[1*3+2]*dpdeResidual_v_h[j];
2680 dsubgridError_u_u[j] = - tau[1*3+0]*dpdeResidual_h_u[j] - tau[1*3+1]*dpdeResidual_u_u[j] - tau[1*3+2]*dpdeResidual_v_u[j];
2681 dsubgridError_u_v[j] = - tau[1*3+0]*dpdeResidual_h_v[j] - tau[1*3+1]*dpdeResidual_u_v[j] - tau[1*3+2]*dpdeResidual_v_v[j];
2683 dsubgridError_v_h[j] = - tau[2*3+0]*dpdeResidual_h_h[j] - tau[2*3+1]*dpdeResidual_u_h[j] - tau[2*3+2]*dpdeResidual_v_h[j];
2684 dsubgridError_v_u[j] = - tau[2*3+0]*dpdeResidual_h_u[j] - tau[2*3+1]*dpdeResidual_u_u[j] - tau[2*3+2]*dpdeResidual_v_u[j];
2685 dsubgridError_v_v[j] = - tau[2*3+0]*dpdeResidual_h_v[j] - tau[2*3+1]*dpdeResidual_u_v[j] - tau[2*3+2]*dpdeResidual_v_v[j];
2688 for (
int i=0;i<nDOF_test_element;i++)
2690 register int i_nSpace = i*nSpace;
2691 Lstar_h_h[i]=
ck.Advection_adjoint(dmass_adv_h_sge,&h_grad_test_dV[i_nSpace]);
2692 Lstar_u_h[i]=
ck.Advection_adjoint(dmass_adv_u_sge,&h_grad_test_dV[i_nSpace]);
2693 Lstar_v_h[i]=
ck.Advection_adjoint(dmass_adv_v_sge,&h_grad_test_dV[i_nSpace]);
2695 Lstar_h_u[i]=
ck.Advection_adjoint(dmom_u_adv_h_sge,&vel_grad_test_dV[i_nSpace]) +
2696 ck.Reaction_adjoint(dmom_u_source_h,vel_test_dV[i]);
2697 Lstar_u_u[i]=
ck.Advection_adjoint(dmom_u_adv_u_sge,&vel_grad_test_dV[i_nSpace]);
2698 Lstar_v_u[i]=
ck.Advection_adjoint(dmom_u_adv_v_sge,&vel_grad_test_dV[i_nSpace]);
2700 Lstar_h_v[i]=
ck.Advection_adjoint(dmom_v_adv_h_sge,&vel_grad_test_dV[i_nSpace])+
2701 ck.Reaction_adjoint(dmom_v_source_h,vel_test_dV[i]);
2702 Lstar_u_v[i]=
ck.Advection_adjoint(dmom_v_adv_u_sge,&vel_grad_test_dV[i_nSpace]);
2703 Lstar_v_v[i]=
ck.Advection_adjoint(dmom_v_adv_v_sge,&vel_grad_test_dV[i_nSpace]);
2706 for(
int i=0;i<nDOF_test_element;i++)
2708 register int i_nSpace = i*nSpace;
2709 for(
int j=0;j<nDOF_trial_element;j++)
2711 register int j_nSpace = j*nSpace;
2713 elementJacobian_h_h[i][j] +=
ck.MassJacobian_weak(dmass_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j],h_test_dV[i]) +
2714 ck.AdvectionJacobian_weak(dmass_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
2715 ck.SubgridErrorJacobian(dsubgridError_h_h[j],Lstar_h_h[i]) +
2716 ck.SubgridErrorJacobian(dsubgridError_u_h[j],Lstar_u_h[i]) +
2717 ck.SubgridErrorJacobian(dsubgridError_v_h[j],Lstar_v_h[i]) +
2718 ck.NumericalDiffusionJacobian(q_numDiff_h_last.data()[eN_k],&h_grad_trial[j_nSpace],&h_grad_test_dV[i_nSpace]);
2720 elementJacobian_h_u[i][j] +=
ck.AdvectionJacobian_weak(dmass_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
2721 ck.SubgridErrorJacobian(dsubgridError_h_u[j],Lstar_h_h[i]) +
2722 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_h[i]) +
2723 ck.SubgridErrorJacobian(dsubgridError_v_u[j],Lstar_v_h[i]);
2725 elementJacobian_h_v[i][j] +=
ck.AdvectionJacobian_weak(dmass_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
2726 ck.SubgridErrorJacobian(dsubgridError_h_v[j],Lstar_h_h[i]) +
2727 ck.SubgridErrorJacobian(dsubgridError_u_v[j],Lstar_u_h[i]) +
2728 ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_h[i]);
2731 elementJacobian_u_h[i][j] +=
ck.MassJacobian_weak(dmom_u_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2732 ck.AdvectionJacobian_weak(dmom_u_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2733 ck.ReactionJacobian_weak(dmom_u_source_h,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2734 ck.SubgridErrorJacobian(dsubgridError_h_h[j],Lstar_h_u[i]) +
2735 ck.SubgridErrorJacobian(dsubgridError_u_h[j],Lstar_u_u[i]) +
2736 ck.SubgridErrorJacobian(dsubgridError_v_h[j],Lstar_v_u[i]);
2738 elementJacobian_u_u[i][j] +=
ck.MassJacobian_weak(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2739 ck.AdvectionJacobian_weak(dmom_u_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2740 ck.SimpleDiffusionJacobian_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_u_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
2741 ck.SubgridErrorJacobian(dsubgridError_h_u[j],Lstar_h_u[i]) +
2742 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_u[i]) +
2743 ck.SubgridErrorJacobian(dsubgridError_v_u[j],Lstar_v_u[i]) +
2744 ck.NumericalDiffusionJacobian(q_numDiff_u_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
2746 elementJacobian_u_v[i][j] +=
ck.AdvectionJacobian_weak(dmom_u_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2747 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]) +
2748 ck.SubgridErrorJacobian(dsubgridError_h_v[j],Lstar_h_u[i]) +
2749 ck.SubgridErrorJacobian(dsubgridError_u_v[j],Lstar_u_u[i]) +
2750 ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_u[i]);
2753 elementJacobian_v_h[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_h_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2754 ck.AdvectionJacobian_weak(dmom_v_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2755 ck.ReactionJacobian_weak(dmom_v_source_h,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2756 ck.SubgridErrorJacobian(dsubgridError_h_h[j],Lstar_h_v[i]) +
2757 ck.SubgridErrorJacobian(dsubgridError_u_h[j],Lstar_u_v[i]) +
2758 ck.SubgridErrorJacobian(dsubgridError_v_h[j],Lstar_v_v[i]);
2760 elementJacobian_v_u[i][j] +=
ck.AdvectionJacobian_weak(dmom_v_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2761 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]) +
2762 ck.SubgridErrorJacobian(dsubgridError_h_u[j],Lstar_h_v[i]) +
2763 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u_v[i]) +
2764 ck.SubgridErrorJacobian(dsubgridError_v_u[j],Lstar_v_v[i]);
2766 elementJacobian_v_v[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
2767 ck.AdvectionJacobian_weak(dmom_v_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
2768 ck.SimpleDiffusionJacobian_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_v_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
2769 ck.SubgridErrorJacobian(dsubgridError_h_v[j],Lstar_h_v[i]) +
2770 ck.SubgridErrorJacobian(dsubgridError_u_v[j],Lstar_u_v[i]) +
2771 ck.SubgridErrorJacobian(dsubgridError_v_v[j],Lstar_v_v[i]) +
2772 ck.NumericalDiffusionJacobian(q_numDiff_v_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
2779 for (
int i=0;i<nDOF_test_element;i++)
2781 register int eN_i = eN*nDOF_test_element+i;
2782 for (
int j=0;j<nDOF_trial_element;j++)
2784 register int eN_i_j = eN_i*nDOF_trial_element+j;
2785 globalJacobian.data()[csrRowIndeces_h_h.data()[eN_i] + csrColumnOffsets_h_h.data()[eN_i_j]] += elementJacobian_h_h[i][j];
2786 globalJacobian.data()[csrRowIndeces_h_u.data()[eN_i] + csrColumnOffsets_h_u.data()[eN_i_j]] += elementJacobian_h_u[i][j];
2787 globalJacobian.data()[csrRowIndeces_h_v.data()[eN_i] + csrColumnOffsets_h_v.data()[eN_i_j]] += elementJacobian_h_v[i][j];
2789 globalJacobian.data()[csrRowIndeces_u_h.data()[eN_i] + csrColumnOffsets_u_h.data()[eN_i_j]] += elementJacobian_u_h[i][j];
2790 globalJacobian.data()[csrRowIndeces_u_u.data()[eN_i] + csrColumnOffsets_u_u.data()[eN_i_j]] += elementJacobian_u_u[i][j];
2791 globalJacobian.data()[csrRowIndeces_u_v.data()[eN_i] + csrColumnOffsets_u_v.data()[eN_i_j]] += elementJacobian_u_v[i][j];
2793 globalJacobian.data()[csrRowIndeces_v_h.data()[eN_i] + csrColumnOffsets_v_h.data()[eN_i_j]] += elementJacobian_v_h[i][j];
2794 globalJacobian.data()[csrRowIndeces_v_u.data()[eN_i] + csrColumnOffsets_v_u.data()[eN_i_j]] += elementJacobian_v_u[i][j];
2795 globalJacobian.data()[csrRowIndeces_v_v.data()[eN_i] + csrColumnOffsets_v_v.data()[eN_i_j]] += elementJacobian_v_v[i][j];
2799 std::cout<<
"tauSum = "<<tauSum<<std::endl;
3276 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
3277 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
3278 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
3279 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
3280 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
3281 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
3282 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
3283 xt::pyarray<double>& h_trial_ref = args.
array<
double>(
"h_trial_ref");
3284 xt::pyarray<double>& h_grad_trial_ref = args.
array<
double>(
"h_grad_trial_ref");
3285 xt::pyarray<double>& h_test_ref = args.
array<
double>(
"h_test_ref");
3286 xt::pyarray<double>& h_grad_test_ref = args.
array<
double>(
"h_grad_test_ref");
3287 xt::pyarray<double>& vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
3288 xt::pyarray<double>& vel_grad_trial_ref = args.
array<
double>(
"vel_grad_trial_ref");
3289 xt::pyarray<double>& vel_test_ref = args.
array<
double>(
"vel_test_ref");
3290 xt::pyarray<double>& vel_grad_test_ref = args.
array<
double>(
"vel_grad_test_ref");
3291 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
3292 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
3293 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
3294 xt::pyarray<double>& h_trial_trace_ref = args.
array<
double>(
"h_trial_trace_ref");
3295 xt::pyarray<double>& h_grad_trial_trace_ref = args.
array<
double>(
"h_grad_trial_trace_ref");
3296 xt::pyarray<double>& h_test_trace_ref = args.
array<
double>(
"h_test_trace_ref");
3297 xt::pyarray<double>& h_grad_test_trace_ref = args.
array<
double>(
"h_grad_test_trace_ref");
3298 xt::pyarray<double>& vel_trial_trace_ref = args.
array<
double>(
"vel_trial_trace_ref");
3299 xt::pyarray<double>& vel_grad_trial_trace_ref = args.
array<
double>(
"vel_grad_trial_trace_ref");
3300 xt::pyarray<double>& vel_test_trace_ref = args.
array<
double>(
"vel_test_trace_ref");
3301 xt::pyarray<double>& vel_grad_test_trace_ref = args.
array<
double>(
"vel_grad_test_trace_ref");
3302 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
3303 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
3304 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
3305 int nElements_global = args.
scalar<
int>(
"nElements_global");
3306 double useRBLES = args.
scalar<
double>(
"useRBLES");
3307 double useMetrics = args.
scalar<
double>(
"useMetrics");
3308 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
3309 double nu = args.
scalar<
double>(
"nu");
3310 double g = args.
scalar<
double>(
"g");
3311 xt::pyarray<int>& h_l2g = args.
array<
int>(
"h_l2g");
3312 xt::pyarray<int>& vel_l2g = args.
array<
int>(
"vel_l2g");
3313 xt::pyarray<double>& b_dof = args.
array<
double>(
"b_dof");
3314 xt::pyarray<double>& h_dof = args.
array<
double>(
"h_dof");
3315 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
3316 xt::pyarray<double>& v_dof = args.
array<
double>(
"v_dof");
3317 xt::pyarray<double>& h_dof_sge = args.
array<
double>(
"h_dof_sge");
3318 xt::pyarray<double>& u_dof_sge = args.
array<
double>(
"u_dof_sge");
3319 xt::pyarray<double>& v_dof_sge = args.
array<
double>(
"v_dof_sge");
3320 xt::pyarray<double>& q_mass_acc_beta_bdf = args.
array<
double>(
"q_mass_acc_beta_bdf");
3321 xt::pyarray<double>& q_mom_u_acc_beta_bdf = args.
array<
double>(
"q_mom_u_acc_beta_bdf");
3322 xt::pyarray<double>& q_mom_v_acc_beta_bdf = args.
array<
double>(
"q_mom_v_acc_beta_bdf");
3323 xt::pyarray<double>& q_velocity_sge = args.
array<
double>(
"q_velocity_sge");
3324 xt::pyarray<double>& q_cfl = args.
array<
double>(
"q_cfl");
3325 xt::pyarray<double>& q_numDiff_h_last = args.
array<
double>(
"q_numDiff_h_last");
3326 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
3327 xt::pyarray<double>& q_numDiff_v_last = args.
array<
double>(
"q_numDiff_v_last");
3328 xt::pyarray<int>& sdInfo_u_u_rowptr = args.
array<
int>(
"sdInfo_u_u_rowptr");
3329 xt::pyarray<int>& sdInfo_u_u_colind = args.
array<
int>(
"sdInfo_u_u_colind");
3330 xt::pyarray<int>& sdInfo_u_v_rowptr = args.
array<
int>(
"sdInfo_u_v_rowptr");
3331 xt::pyarray<int>& sdInfo_u_v_colind = args.
array<
int>(
"sdInfo_u_v_colind");
3332 xt::pyarray<int>& sdInfo_v_v_rowptr = args.
array<
int>(
"sdInfo_v_v_rowptr");
3333 xt::pyarray<int>& sdInfo_v_v_colind = args.
array<
int>(
"sdInfo_v_v_colind");
3334 xt::pyarray<int>& sdInfo_v_u_rowptr = args.
array<
int>(
"sdInfo_v_u_rowptr");
3335 xt::pyarray<int>& sdInfo_v_u_colind = args.
array<
int>(
"sdInfo_v_u_colind");
3336 xt::pyarray<int>& csrRowIndeces_h_h = args.
array<
int>(
"csrRowIndeces_h_h");
3337 xt::pyarray<int>& csrColumnOffsets_h_h = args.
array<
int>(
"csrColumnOffsets_h_h");
3338 xt::pyarray<int>& csrRowIndeces_h_u = args.
array<
int>(
"csrRowIndeces_h_u");
3339 xt::pyarray<int>& csrColumnOffsets_h_u = args.
array<
int>(
"csrColumnOffsets_h_u");
3340 xt::pyarray<int>& csrRowIndeces_h_v = args.
array<
int>(
"csrRowIndeces_h_v");
3341 xt::pyarray<int>& csrColumnOffsets_h_v = args.
array<
int>(
"csrColumnOffsets_h_v");
3342 xt::pyarray<int>& csrRowIndeces_u_h = args.
array<
int>(
"csrRowIndeces_u_h");
3343 xt::pyarray<int>& csrColumnOffsets_u_h = args.
array<
int>(
"csrColumnOffsets_u_h");
3344 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
3345 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
3346 xt::pyarray<int>& csrRowIndeces_u_v = args.
array<
int>(
"csrRowIndeces_u_v");
3347 xt::pyarray<int>& csrColumnOffsets_u_v = args.
array<
int>(
"csrColumnOffsets_u_v");
3348 xt::pyarray<int>& csrRowIndeces_v_h = args.
array<
int>(
"csrRowIndeces_v_h");
3349 xt::pyarray<int>& csrColumnOffsets_v_h = args.
array<
int>(
"csrColumnOffsets_v_h");
3350 xt::pyarray<int>& csrRowIndeces_v_u = args.
array<
int>(
"csrRowIndeces_v_u");
3351 xt::pyarray<int>& csrColumnOffsets_v_u = args.
array<
int>(
"csrColumnOffsets_v_u");
3352 xt::pyarray<int>& csrRowIndeces_v_v = args.
array<
int>(
"csrRowIndeces_v_v");
3353 xt::pyarray<int>& csrColumnOffsets_v_v = args.
array<
int>(
"csrColumnOffsets_v_v");
3354 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
3355 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
3356 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
3357 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
3358 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
3359 xt::pyarray<int>& isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
3360 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
3361 xt::pyarray<int>& isDOFBoundary_v = args.
array<
int>(
"isDOFBoundary_v");
3362 xt::pyarray<int>& isAdvectiveFluxBoundary_h = args.
array<
int>(
"isAdvectiveFluxBoundary_h");
3363 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
3364 xt::pyarray<int>& isAdvectiveFluxBoundary_v = args.
array<
int>(
"isAdvectiveFluxBoundary_v");
3365 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
3366 xt::pyarray<int>& isDiffusiveFluxBoundary_v = args.
array<
int>(
"isDiffusiveFluxBoundary_v");
3367 xt::pyarray<double>& ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
3368 xt::pyarray<double>& ebqe_bc_flux_mass_ext = args.
array<
double>(
"ebqe_bc_flux_mass_ext");
3369 xt::pyarray<double>& ebqe_bc_flux_mom_u_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_u_adv_ext");
3370 xt::pyarray<double>& ebqe_bc_flux_mom_v_adv_ext = args.
array<
double>(
"ebqe_bc_flux_mom_v_adv_ext");
3371 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
3372 xt::pyarray<double>& ebqe_bc_flux_u_diff_ext = args.
array<
double>(
"ebqe_bc_flux_u_diff_ext");
3373 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
3374 xt::pyarray<double>& ebqe_bc_v_ext = args.
array<
double>(
"ebqe_bc_v_ext");
3375 xt::pyarray<double>& ebqe_bc_flux_v_diff_ext = args.
array<
double>(
"ebqe_bc_flux_v_diff_ext");
3376 xt::pyarray<int>& csrColumnOffsets_eb_h_h = args.
array<
int>(
"csrColumnOffsets_eb_h_h");
3377 xt::pyarray<int>& csrColumnOffsets_eb_h_u = args.
array<
int>(
"csrColumnOffsets_eb_h_u");
3378 xt::pyarray<int>& csrColumnOffsets_eb_h_v = args.
array<
int>(
"csrColumnOffsets_eb_h_v");
3379 xt::pyarray<int>& csrColumnOffsets_eb_u_h = args.
array<
int>(
"csrColumnOffsets_eb_u_h");
3380 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
3381 xt::pyarray<int>& csrColumnOffsets_eb_u_v = args.
array<
int>(
"csrColumnOffsets_eb_u_v");
3382 xt::pyarray<int>& csrColumnOffsets_eb_v_h = args.
array<
int>(
"csrColumnOffsets_eb_v_h");
3383 xt::pyarray<int>& csrColumnOffsets_eb_v_u = args.
array<
int>(
"csrColumnOffsets_eb_v_u");
3384 xt::pyarray<int>& csrColumnOffsets_eb_v_v = args.
array<
int>(
"csrColumnOffsets_eb_v_v");
3388 for(
int eN=0;eN<nElements_global;eN++)
3390 register double elementJacobian_h_h[nDOF_test_element][nDOF_trial_element],
3391 elementJacobian_h_u[nDOF_test_element][nDOF_trial_element],
3392 elementJacobian_h_v[nDOF_test_element][nDOF_trial_element],
3393 elementJacobian_u_h[nDOF_test_element][nDOF_trial_element],
3394 elementJacobian_u_u[nDOF_test_element][nDOF_trial_element],
3395 elementJacobian_u_v[nDOF_test_element][nDOF_trial_element],
3396 elementJacobian_v_h[nDOF_test_element][nDOF_trial_element],
3397 elementJacobian_v_u[nDOF_test_element][nDOF_trial_element],
3398 elementJacobian_v_v[nDOF_test_element][nDOF_trial_element];
3399 for (
int i=0;i<nDOF_test_element;i++)
3400 for (
int j=0;j<nDOF_trial_element;j++)
3402 elementJacobian_h_h[i][j]=0.0;
3403 elementJacobian_h_u[i][j]=0.0;
3404 elementJacobian_h_v[i][j]=0.0;
3405 elementJacobian_u_h[i][j]=0.0;
3406 elementJacobian_u_u[i][j]=0.0;
3407 elementJacobian_u_v[i][j]=0.0;
3408 elementJacobian_v_h[i][j]=0.0;
3409 elementJacobian_v_u[i][j]=0.0;
3410 elementJacobian_v_v[i][j]=0.0;
3412 for (
int k=0;k<nQuadraturePoints_element;k++)
3414 int eN_k = eN*nQuadraturePoints_element+k,
3415 eN_k_nSpace = eN_k*nSpace,
3416 eN_nDOF_trial_element = eN*nDOF_trial_element;
3419 register double b=0.0,
3439 dmass_adv_h[nSpace],
3440 dmass_adv_u[nSpace],
3441 dmass_adv_v[nSpace],
3442 dmass_adv_h_sge[nSpace],
3443 dmass_adv_u_sge[nSpace],
3444 dmass_adv_v_sge[nSpace],
3446 dmom_u_adv_h[nSpace],
3447 dmom_u_adv_u[nSpace],
3448 dmom_u_adv_v[nSpace],
3449 dmom_u_adv_h_sge[nSpace],
3450 dmom_u_adv_u_sge[nSpace],
3451 dmom_u_adv_v_sge[nSpace],
3453 dmom_v_adv_h[nSpace],
3454 dmom_v_adv_u[nSpace],
3455 dmom_v_adv_v[nSpace],
3456 dmom_v_adv_h_sge[nSpace],
3457 dmom_v_adv_u_sge[nSpace],
3458 dmom_v_adv_v_sge[nSpace],
3459 mom_u_diff_ten[nSpace],
3460 mom_v_diff_ten[nSpace],
3464 dmom_u_source_h=0.0,
3466 dmom_v_source_h=0.0,
3478 dpdeResidual_h_h[nDOF_trial_element],
3479 dpdeResidual_h_u[nDOF_trial_element],
3480 dpdeResidual_h_v[nDOF_trial_element],
3481 dpdeResidual_u_h[nDOF_trial_element],
3482 dpdeResidual_u_u[nDOF_trial_element],
3483 dpdeResidual_u_v[nDOF_trial_element],
3484 dpdeResidual_v_h[nDOF_trial_element],
3485 dpdeResidual_v_u[nDOF_trial_element],
3486 dpdeResidual_v_v[nDOF_trial_element],
3489 Lhat_x[nDOF_test_element],
3490 Lhat_y[nDOF_test_element],
3491 subgridError_hx=0.0,
3492 subgridError_ux=0.0,
3493 subgridError_vx=0.0,
3494 subgridError_hy=0.0,
3495 subgridError_uy=0.0,
3496 subgridError_vy=0.0,
3497 dsubgridError_hx_h[nDOF_trial_element],
3498 dsubgridError_hx_u[nDOF_trial_element],
3499 dsubgridError_hx_v[nDOF_trial_element],
3500 dsubgridError_ux_h[nDOF_trial_element],
3501 dsubgridError_ux_u[nDOF_trial_element],
3502 dsubgridError_ux_v[nDOF_trial_element],
3503 dsubgridError_vx_h[nDOF_trial_element],
3504 dsubgridError_vx_u[nDOF_trial_element],
3505 dsubgridError_vx_v[nDOF_trial_element],
3506 dsubgridError_hy_h[nDOF_trial_element],
3507 dsubgridError_hy_u[nDOF_trial_element],
3508 dsubgridError_hy_v[nDOF_trial_element],
3509 dsubgridError_uy_h[nDOF_trial_element],
3510 dsubgridError_uy_u[nDOF_trial_element],
3511 dsubgridError_uy_v[nDOF_trial_element],
3512 dsubgridError_vy_h[nDOF_trial_element],
3513 dsubgridError_vy_u[nDOF_trial_element],
3514 dsubgridError_vy_v[nDOF_trial_element],
3518 jacInv[nSpace*nSpace],
3519 h_grad_trial[nDOF_trial_element*nSpace],
3520 vel_grad_trial[nDOF_trial_element*nSpace],
3522 h_test_dV[nDOF_test_element],
3523 vel_test_dV[nDOF_test_element],
3524 h_grad_test_dV[nDOF_test_element*nSpace],
3525 vel_grad_test_dV[nDOF_test_element*nSpace],
3527 G[nSpace*nSpace],G_dd_G,tr_G, dmom_adv_star[nSpace], dmom_adv_sge[nSpace];
3530 double alpha_tau=0.25;
3531 double include_acc_in_strong_mom = 1.0;
3533 ck.calculateMapping_element(eN,
3537 mesh_trial_ref.data(),
3538 mesh_grad_trial_ref.data(),
3543 ck.calculateMappingVelocity_element(eN,
3545 mesh_velocity_dof.data(),
3547 mesh_trial_ref.data(),
3550 dV = fabs(jacDet)*dV_ref.data()[k];
3553 ck.gradTrialFromRef(&h_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,h_grad_trial);
3554 ck.gradTrialFromRef(&vel_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,vel_grad_trial);
3556 ck.valFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],b);
3557 ck.valFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h);
3558 ck.valFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
u);
3559 ck.valFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],
v);
3560 ck.valFromDOF(h_dof_sge.data(),&h_l2g.data()[eN_nDOF_trial_element],&h_trial_ref.data()[k*nDOF_trial_element],h_sge);
3561 ck.valFromDOF(u_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],u_sge);
3562 ck.valFromDOF(v_dof_sge.data(),&vel_l2g.data()[eN_nDOF_trial_element],&vel_trial_ref.data()[k*nDOF_trial_element],v_sge);
3564 ck.gradFromDOF(b_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_b);
3565 ck.gradFromDOF(h_dof.data(),&h_l2g.data()[eN_nDOF_trial_element],h_grad_trial,grad_h);
3566 ck.gradFromDOF(u_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_u);
3567 ck.gradFromDOF(v_dof.data(),&vel_l2g.data()[eN_nDOF_trial_element],vel_grad_trial,grad_v);
3569 for (
int j=0;j<nDOF_trial_element;j++)
3571 h_test_dV[j] = h_test_ref.data()[k*nDOF_trial_element+j]*dV;
3572 vel_test_dV[j] = vel_test_ref.data()[k*nDOF_trial_element+j]*dV;
3573 for (
int I=0;I<nSpace;I++)
3575 h_grad_test_dV[j*nSpace+I] = h_grad_trial[j*nSpace+I]*dV;
3576 vel_grad_test_dV[j*nSpace+I] = vel_grad_trial[j*nSpace+I]*dV;
3617 q_mass_acc_beta_bdf.data()[eN_k],
3623 q_mom_u_acc_beta_bdf.data()[eN_k],
3631 q_mom_v_acc_beta_bdf.data()[eN_k],
3644 dmass_adv_h_sge[0] = dmass_adv_h[0];
3645 dmass_adv_h_sge[1] = dmass_adv_h[1];
3646 dmass_adv_u_sge[0] = dmass_adv_u[0];
3647 dmass_adv_u_sge[1] = dmass_adv_u[1];
3648 dmass_adv_v_sge[0] = dmass_adv_v[0];
3649 dmass_adv_v_sge[1] = dmass_adv_v[1];
3650 dmom_u_adv_h_sge[0] = dmom_u_adv_h[0];
3651 dmom_u_adv_h_sge[1] = dmom_u_adv_h[1];
3652 dmom_u_adv_u_sge[0] = dmom_u_adv_u[0];
3653 dmom_u_adv_u_sge[1] = dmom_u_adv_u[1];
3654 dmom_u_adv_v_sge[0] = dmom_u_adv_v[0];
3655 dmom_u_adv_v_sge[1] = dmom_u_adv_v[1];
3656 dmom_v_adv_h_sge[0] = dmom_v_adv_h[0];
3657 dmom_v_adv_h_sge[1] = dmom_v_adv_h[1];
3658 dmom_v_adv_u_sge[0] = dmom_v_adv_u[0];
3659 dmom_v_adv_u_sge[1] = dmom_v_adv_u[1];
3660 dmom_v_adv_v_sge[0] = dmom_v_adv_v[0];
3661 dmom_v_adv_v_sge[1] = dmom_v_adv_v[1];
3666 dmass_adv_h_sge[0]=u_sge;
3667 dmass_adv_h_sge[1]=v_sge;
3669 dmass_adv_u_sge[0]=h_sge;
3670 dmass_adv_u_sge[1]=0.0;
3672 dmass_adv_v_sge[0]=0.0;
3673 dmass_adv_v_sge[1]=h_sge;
3676 dmom_u_adv_h_sge[0]=u_sge*u_sge + g*h_sge;
3677 dmom_u_adv_h_sge[1]=u_sge*v_sge;
3679 dmom_u_adv_u_sge[0]=h_sge*2.0*u_sge;
3680 dmom_u_adv_u_sge[1]=h_sge*v_sge;
3682 dmom_u_adv_v_sge[0]=0.0;
3683 dmom_u_adv_v_sge[1]=h_sge*u_sge;
3686 dmom_v_adv_h_sge[0]=v_sge*u_sge;
3687 dmom_v_adv_h_sge[1]=v_sge*v_sge + g*h_sge;
3689 dmom_v_adv_u_sge[0]=h_sge*v_sge;
3690 dmom_v_adv_u_sge[1]=0.0;
3692 dmom_v_adv_v_sge[0]=h_sge*u_sge;
3693 dmom_v_adv_v_sge[1]=h_sge*2.0*v_sge;
3696 for (
int j=0;j<nDOF_trial_element;j++)
3698 register int j_nSpace = j*nSpace;
3700 dpdeResidual_h_h[j]=
ck.MassJacobian_strong(dmass_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
3701 ck.AdvectionJacobian_strong(dmass_adv_h_sge,&h_grad_trial[j_nSpace]);
3703 dpdeResidual_h_u[j]=
ck.AdvectionJacobian_strong(dmass_adv_u_sge,&vel_grad_trial[j_nSpace]);
3705 dpdeResidual_h_v[j]=
ck.AdvectionJacobian_strong(dmass_adv_v_sge,&vel_grad_trial[j_nSpace]);
3707 dpdeResidual_u_h[j]= include_acc_in_strong_mom*
ck.MassJacobian_strong(dmom_u_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
3708 ck.AdvectionJacobian_strong(dmom_u_adv_h_sge,&h_grad_trial[j_nSpace]) +
3709 ck.ReactionJacobian_strong(dmom_u_source_h,h_trial_ref.data()[k*nDOF_trial_element+j]);
3711 dpdeResidual_u_u[j]= include_acc_in_strong_mom*
ck.MassJacobian_strong(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j])+
3712 ck.AdvectionJacobian_strong(dmom_u_adv_u_sge,&vel_grad_trial[j_nSpace]);
3714 dpdeResidual_u_v[j]=
ck.AdvectionJacobian_strong(dmom_u_adv_v_sge,&vel_grad_trial[j_nSpace]);
3716 dpdeResidual_v_h[j]= include_acc_in_strong_mom*
ck.MassJacobian_strong(dmom_v_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j])+
3717 ck.AdvectionJacobian_strong(dmom_v_adv_h_sge,&h_grad_trial[j_nSpace])+
3718 ck.ReactionJacobian_strong(dmom_v_source_h,h_trial_ref.data()[k*nDOF_trial_element+j]);
3720 dpdeResidual_v_u[j]=
ck.AdvectionJacobian_strong(dmom_v_adv_u_sge,&vel_grad_trial[j_nSpace]);
3722 dpdeResidual_v_v[j]= include_acc_in_strong_mom*
ck.MassJacobian_strong(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j])+
3723 ck.AdvectionJacobian_strong(dmom_v_adv_v_sge,&vel_grad_trial[j_nSpace]);
3737 q_cfl.data()[eN_k]);
3739 for (
int j=0;j<nDOF_trial_element;j++)
3741 dsubgridError_hx_h[j] = - tau_x[0*3+0]*dpdeResidual_h_h[j] - tau_x[0*3+1]*dpdeResidual_u_h[j] - tau_x[0*3+2]*dpdeResidual_v_h[j];
3742 dsubgridError_hx_u[j] = - tau_x[0*3+0]*dpdeResidual_h_u[j] - tau_x[0*3+1]*dpdeResidual_u_u[j] - tau_x[0*3+2]*dpdeResidual_v_u[j];
3743 dsubgridError_hx_v[j] = - tau_x[0*3+0]*dpdeResidual_h_v[j] - tau_x[0*3+1]*dpdeResidual_u_v[j] - tau_x[0*3+2]*dpdeResidual_v_v[j];
3745 dsubgridError_ux_h[j] = - tau_x[1*3+0]*dpdeResidual_h_h[j] - tau_x[1*3+1]*dpdeResidual_u_h[j] - tau_x[1*3+2]*dpdeResidual_v_h[j];
3746 dsubgridError_ux_u[j] = - tau_x[1*3+0]*dpdeResidual_h_u[j] - tau_x[1*3+1]*dpdeResidual_u_u[j] - tau_x[1*3+2]*dpdeResidual_v_u[j];
3747 dsubgridError_ux_v[j] = - tau_x[1*3+0]*dpdeResidual_h_v[j] - tau_x[1*3+1]*dpdeResidual_u_v[j] - tau_x[1*3+2]*dpdeResidual_v_v[j];
3749 dsubgridError_vx_h[j] = - tau_x[2*3+0]*dpdeResidual_h_h[j] - tau_x[2*3+1]*dpdeResidual_u_h[j] - tau_x[2*3+2]*dpdeResidual_v_h[j];
3750 dsubgridError_vx_u[j] = - tau_x[2*3+0]*dpdeResidual_h_u[j] - tau_x[2*3+1]*dpdeResidual_u_u[j] - tau_x[2*3+2]*dpdeResidual_v_u[j];
3751 dsubgridError_vx_v[j] = - tau_x[2*3+0]*dpdeResidual_h_v[j] - tau_x[2*3+1]*dpdeResidual_u_v[j] - tau_x[2*3+2]*dpdeResidual_v_v[j];
3753 dsubgridError_hy_h[j] = - tau_y[0*3+0]*dpdeResidual_h_h[j] - tau_y[0*3+1]*dpdeResidual_u_h[j] - tau_y[0*3+2]*dpdeResidual_v_h[j];
3754 dsubgridError_hy_u[j] = - tau_y[0*3+0]*dpdeResidual_h_u[j] - tau_y[0*3+1]*dpdeResidual_u_u[j] - tau_y[0*3+2]*dpdeResidual_v_u[j];
3755 dsubgridError_hy_v[j] = - tau_y[0*3+0]*dpdeResidual_h_v[j] - tau_y[0*3+1]*dpdeResidual_u_v[j] - tau_y[0*3+2]*dpdeResidual_v_v[j];
3757 dsubgridError_uy_h[j] = - tau_y[1*3+0]*dpdeResidual_h_h[j] - tau_y[1*3+1]*dpdeResidual_u_h[j] - tau_y[1*3+2]*dpdeResidual_v_h[j];
3758 dsubgridError_uy_u[j] = - tau_y[1*3+0]*dpdeResidual_h_u[j] - tau_y[1*3+1]*dpdeResidual_u_u[j] - tau_y[1*3+2]*dpdeResidual_v_u[j];
3759 dsubgridError_uy_v[j] = - tau_y[1*3+0]*dpdeResidual_h_v[j] - tau_y[1*3+1]*dpdeResidual_u_v[j] - tau_y[1*3+2]*dpdeResidual_v_v[j];
3761 dsubgridError_vy_h[j] = - tau_y[2*3+0]*dpdeResidual_h_h[j] - tau_y[2*3+1]*dpdeResidual_u_h[j] - tau_y[2*3+2]*dpdeResidual_v_h[j];
3762 dsubgridError_vy_u[j] = - tau_y[2*3+0]*dpdeResidual_h_u[j] - tau_y[2*3+1]*dpdeResidual_u_u[j] - tau_y[2*3+2]*dpdeResidual_v_u[j];
3763 dsubgridError_vy_v[j] = - tau_y[2*3+0]*dpdeResidual_h_v[j] - tau_y[2*3+1]*dpdeResidual_u_v[j] - tau_y[2*3+2]*dpdeResidual_v_v[j];
3767 for (
int i=0;i<nDOF_test_element;i++)
3769 register int i_nSpace = i*nSpace;
3770 Lhat_x[i]= -h_grad_test_dV[i_nSpace];
3771 Lhat_y[i]= -h_grad_test_dV[i_nSpace+1];
3774 for(
int i=0;i<nDOF_test_element;i++)
3776 register int i_nSpace = i*nSpace;
3777 for(
int j=0;j<nDOF_trial_element;j++)
3779 register int j_nSpace = j*nSpace;
3781 elementJacobian_h_h[i][j] +=
ck.MassJacobian_weak(dmass_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j],h_test_dV[i]) +
3782 ck.AdvectionJacobian_weak(dmass_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
3784 ck.SubgridErrorJacobian(dsubgridError_hx_h[j],Lhat_x[i]) +
3785 ck.SubgridErrorJacobian(dsubgridError_hy_h[j],Lhat_y[i]) +
3786 ck.NumericalDiffusionJacobian(q_numDiff_h_last.data()[eN_k],&h_grad_trial[j_nSpace],&h_grad_test_dV[i_nSpace]);
3788 elementJacobian_h_u[i][j] +=
ck.AdvectionJacobian_weak(dmass_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
3790 ck.SubgridErrorJacobian(dsubgridError_hx_u[j],Lhat_x[i]) +
3791 ck.SubgridErrorJacobian(dsubgridError_hy_u[j],Lhat_y[i]);
3793 elementJacobian_h_v[i][j] +=
ck.AdvectionJacobian_weak(dmass_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&h_grad_test_dV[i_nSpace]) +
3795 ck.SubgridErrorJacobian(dsubgridError_hx_v[j],Lhat_x[i]) +
3796 ck.SubgridErrorJacobian(dsubgridError_hy_v[j],Lhat_y[i]);
3799 elementJacobian_u_h[i][j] +=
ck.MassJacobian_weak(dmom_u_acc_h_t,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3800 ck.AdvectionJacobian_weak(dmom_u_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3801 ck.ReactionJacobian_weak(dmom_u_source_h,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3803 ck.SubgridErrorJacobian(dsubgridError_ux_h[j],Lhat_x[i]) +
3804 ck.SubgridErrorJacobian(dsubgridError_uy_h[j],Lhat_y[i]);
3807 elementJacobian_u_u[i][j] +=
ck.MassJacobian_weak(dmom_u_acc_u_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3808 ck.AdvectionJacobian_weak(dmom_u_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3809 ck.SimpleDiffusionJacobian_weak(sdInfo_u_u_rowptr.data(),sdInfo_u_u_colind.data(),mom_u_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3810 ck.SubgridErrorJacobian(dsubgridError_ux_u[j],Lhat_x[i]) +
3811 ck.SubgridErrorJacobian(dsubgridError_uy_u[j],Lhat_y[i]) +
3812 ck.NumericalDiffusionJacobian(q_numDiff_u_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3814 elementJacobian_u_v[i][j] +=
ck.AdvectionJacobian_weak(dmom_u_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3815 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]) +
3816 ck.SubgridErrorJacobian(dsubgridError_ux_v[j],Lhat_x[i]) +
3817 ck.SubgridErrorJacobian(dsubgridError_uy_v[j],Lhat_y[i]);
3820 elementJacobian_v_h[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_h_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3821 ck.AdvectionJacobian_weak(dmom_v_adv_h,h_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3822 ck.ReactionJacobian_weak(dmom_v_source_h,h_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3823 ck.SubgridErrorJacobian(dsubgridError_vx_h[j],Lhat_x[i]) +
3824 ck.SubgridErrorJacobian(dsubgridError_vy_h[j],Lhat_y[i]);
3827 elementJacobian_v_u[i][j] +=
ck.AdvectionJacobian_weak(dmom_v_adv_u,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3828 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]) +
3829 ck.SubgridErrorJacobian(dsubgridError_vx_u[j],Lhat_x[i]) +
3830 ck.SubgridErrorJacobian(dsubgridError_vy_u[j],Lhat_y[i]);
3833 elementJacobian_v_v[i][j] +=
ck.MassJacobian_weak(dmom_v_acc_v_t,vel_trial_ref.data()[k*nDOF_trial_element+j],vel_test_dV[i]) +
3834 ck.AdvectionJacobian_weak(dmom_v_adv_v,vel_trial_ref.data()[k*nDOF_trial_element+j],&vel_grad_test_dV[i_nSpace]) +
3835 ck.SimpleDiffusionJacobian_weak(sdInfo_v_v_rowptr.data(),sdInfo_v_v_colind.data(),mom_v_diff_ten,&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]) +
3836 ck.SubgridErrorJacobian(dsubgridError_vx_v[j],Lhat_x[i]) +
3837 ck.SubgridErrorJacobian(dsubgridError_vy_v[j],Lhat_y[i]) +
3838 ck.NumericalDiffusionJacobian(q_numDiff_v_last.data()[eN_k],&vel_grad_trial[j_nSpace],&vel_grad_test_dV[i_nSpace]);
3845 for (
int i=0;i<nDOF_test_element;i++)
3847 register int eN_i = eN*nDOF_test_element+i;
3848 for (
int j=0;j<nDOF_trial_element;j++)
3850 register int eN_i_j = eN_i*nDOF_trial_element+j;
3851 globalJacobian.data()[csrRowIndeces_h_h.data()[eN_i] + csrColumnOffsets_h_h.data()[eN_i_j]] += elementJacobian_h_h[i][j];
3852 globalJacobian.data()[csrRowIndeces_h_u.data()[eN_i] + csrColumnOffsets_h_u.data()[eN_i_j]] += elementJacobian_h_u[i][j];
3853 globalJacobian.data()[csrRowIndeces_h_v.data()[eN_i] + csrColumnOffsets_h_v.data()[eN_i_j]] += elementJacobian_h_v[i][j];
3855 globalJacobian.data()[csrRowIndeces_u_h.data()[eN_i] + csrColumnOffsets_u_h.data()[eN_i_j]] += elementJacobian_u_h[i][j];
3856 globalJacobian.data()[csrRowIndeces_u_u.data()[eN_i] + csrColumnOffsets_u_u.data()[eN_i_j]] += elementJacobian_u_u[i][j];
3857 globalJacobian.data()[csrRowIndeces_u_v.data()[eN_i] + csrColumnOffsets_u_v.data()[eN_i_j]] += elementJacobian_u_v[i][j];
3859 globalJacobian.data()[csrRowIndeces_v_h.data()[eN_i] + csrColumnOffsets_v_h.data()[eN_i_j]] += elementJacobian_v_h[i][j];
3860 globalJacobian.data()[csrRowIndeces_v_u.data()[eN_i] + csrColumnOffsets_v_u.data()[eN_i_j]] += elementJacobian_v_u[i][j];
3861 globalJacobian.data()[csrRowIndeces_v_v.data()[eN_i] + csrColumnOffsets_v_v.data()[eN_i_j]] += elementJacobian_v_v[i][j];
4014 int nQuadraturePoints_elementIn,
4015 int nDOF_mesh_trial_elementIn,
4016 int nDOF_trial_elementIn,
4017 int nDOF_test_elementIn,
4018 int nQuadraturePoints_elementBoundaryIn,
4021 return proteus::chooseAndAllocateDiscretization2D<SW2D_base,SW2D,CompKernel>(nSpaceIn,
4022 nQuadraturePoints_elementIn,
4023 nDOF_mesh_trial_elementIn,
4024 nDOF_trial_elementIn,
4025 nDOF_test_elementIn,
4026 nQuadraturePoints_elementBoundaryIn,