9 #include "xtensor-python/pyarray.hpp"
11 namespace py = pybind11;
36 double mu_fr_limiter){}
41 template<
class CompKernelType,
43 int nQuadraturePoints_element,
44 int nDOF_mesh_trial_element,
45 int nDOF_trial_element,
46 int nDOF_test_element,
47 int nQuadraturePoints_elementBoundary>
118 const double grad_k[nSpace],
119 const double grad_omega[nSpace],
120 const double grad_vx[nSpace],
121 const double grad_vy[nSpace],
122 double& inverse_sigma_k,
123 double& inverse_sigma_omega,
131 inverse_sigma_k = 2.0; inverse_sigma_omega=2.0; gamma = 13.0/25.0;
132 const double beta0_star = 0.09;
const double beta0 = 9.0/125.0;
133 double Omega[nSpace][nSpace] = {{0.,0.},
135 double S[nSpace][nSpace] = {{0.,0.},
140 Omega[0][1] = 0.5*(grad_vx[1]-grad_vy[0]);
141 Omega[1][0] =-Omega[0][1];
144 S[0][0] = grad_vx[0]; S[0][1] = 0.5*(grad_vx[1]+grad_vy[0]);
145 S[1][0] = S[0][1]; S[1][1] = grad_vy[1];
147 double chi_omega = 0.0;
148 for (
int i=0; i < nSpace; i++)
149 for (
int k=0; k < nSpace; k++)
150 for (
int j=0; j < nSpace; j++)
151 chi_omega += Omega[i][j]*Omega[j][k]*S[k][i];
153 if (fabs(omega) > div_eps)
155 chi_omega = fabs(chi_omega/(beta0_star*omega*beta0_star*omega*beta0_star*omega));
157 const double f_beta = (1.0+70.0*chi_omega)/(1.0 + 80.0*chi_omega);
165 double chi_k = grad_k[0]*grad_omega[0] + grad_k[1]*grad_omega[1];
166 double f_beta_star = 1.0;
168 const double omega3 = omega*omega*omega;
169 if (fabs(omega3) > div_eps)
171 chi_k = chi_k/omega3;
172 f_beta_star = (1.0 + 680.0*chi_k*chi_k)/(1.0 + 400.0*chi_k*chi_k);
174 else if (chi_k > 0.0)
175 f_beta_star = 680.0/400.0;
177 beta_star = beta0_star*f_beta_star;
182 beta = fmax(0.875*beta0,fmin(beta,beta0));
187 beta_star = fmax(beta0_star,fmin(beta_star,(680.0/400.0)*beta0_star));
199 const double sigma_k,
201 const double grad_vx[nSpace],
202 const double grad_vy[nSpace],
203 const double grad_vz[nSpace],
207 const double& porosity,
211 double q_vos_gradc[nSpace],
217 int dissipation_model_flag,
218 const double grad_k_old[nSpace],
219 const double grad_dissipation[nSpace],
230 double nu_t=0.0,dnu_t_dk=0.0,PiD4=0.0;
231 double gamma_k=0.0,F_k=0.0,sigma_a=sigma_k,kSed=0.,dkSed=0.;
233 const double isKEpsilon = (dissipation_model_flag>=2) ? 0.0 : 1.0;
237 for (
int I=0; I < nSpace; I++)
239 f[I] =
v[I]*k*porosity;
240 df[I] =
v[I]*porosity;
243 double nu = (1.0-H_mu)*
nu_0 + H_mu*
nu_1;
244 const double div_eps = 1.0e-2*fmin(
nu_0,
nu_1);
246 nu_t = isKEpsilon*c_mu*k_old*k_old/(fabs(dissipation)+div_eps)
247 + (1.0-isKEpsilon)*k_old/(fabs(dissipation)+div_eps);
253 nu_t = fmax(nu_t,1.e-4*nu);
255 nu_t = fmin(nu_t,1.0e6*nu);
260 PiD4 = 2.0*(grad_vx[0]*grad_vx[0] +
261 grad_vy[1]*grad_vy[1] +
262 grad_vz[2]*grad_vz[2])
264 (grad_vx[1] + grad_vy[0])*(grad_vx[1] + grad_vy[0])
266 (grad_vx[2] + grad_vz[0])*(grad_vx[2] + grad_vz[0])
268 (grad_vy[2] + grad_vz[1])*(grad_vy[2] + grad_vz[1]);
271 double theta = 1e-10;
275 if (sedFlag == 1 && isKEpsilon > 0)
311 if (dissipation_model_flag==2)
314 double sigma_omega=1.,beta_star=1.,beta=1.,gamma=1.;
329 gamma_k=fmax(beta_star*dissipation,0.0);
332 else if (dissipation_model_flag==3)
335 double beta_star = 0.09;
336 gamma_k=fmax(beta_star*dissipation,0.0);
341 gamma_k = fmax(c_mu*k_old/nu_t,0.0);
346 a = porosity*(nu_t/sigma_a + nu);
347 da_dk = porosity*dnu_t_dk/sigma_a;
350 r = -porosity*F_k + porosity*gamma_k*k +porosity*kSed;
351 dr_dk = porosity*(gamma_k+dkSed);
358 const double grad_k[nSpace],
359 const double grad_omega[nSpace],
360 const double grad_vx[nSpace],
361 const double grad_vy[nSpace],
362 const double grad_vz[nSpace],
363 double& inverse_sigma_k,
364 double& inverse_sigma_omega,
372 inverse_sigma_k = 2.0; inverse_sigma_omega=2.0; gamma = 13.0/25.0;
373 const double beta0_star = 0.09;
const double beta0 = 9.0/125.0;
374 double Omega[nSpace][nSpace] = {{0.,0.,0,},
377 double S[nSpace][nSpace] = {{0.0,0.,0},
382 Omega[0][1] = 0.5*(grad_vx[1]-grad_vy[0]); Omega[0][2] = 0.5*(grad_vx[2]-grad_vz[0]);
383 Omega[1][0] =-Omega[0][1]; Omega[1][2] = 0.5*(grad_vy[2]-grad_vz[1]);
384 Omega[2][0] =-Omega[0][2]; Omega[2][1] =-Omega[1][2];
386 S[0][0] = grad_vx[0]; S[0][1] = 0.5*(grad_vx[1]+grad_vy[0]); S[0][2] = 0.5*(grad_vx[2]+grad_vz[0]);
387 S[1][0] = S[0][1]; S[1][1] = grad_vy[1]; S[1][2] = 0.5*(grad_vy[2] + grad_vz[1]);
388 S[2][0] = S[0][2]; S[2][1] = S[1][2]; S[2][2] = grad_vz[2];
390 double chi_omega = 0.0;
391 for (
int i=0; i < nSpace; i++)
392 for (
int k=0; k < nSpace; k++)
393 for (
int j=0; j < nSpace; j++)
394 chi_omega += Omega[i][j]*Omega[j][k]*S[k][i];
396 if (fabs(omega) > div_eps)
398 chi_omega = fabs(chi_omega/(beta0_star*omega*beta0_star*omega*beta0_star*omega));
400 const double f_beta = (1.0+70.0*chi_omega)/(1.0 + 80.0*chi_omega);
408 double chi_k = grad_k[0]*grad_omega[0] + grad_k[1]*grad_omega[1] + grad_k[2]*grad_omega[2];
409 double f_beta_star = 1.0;
411 const double omega3 = omega*omega*omega;
412 if (fabs(omega3) > div_eps)
414 chi_k = chi_k/omega3;
415 f_beta_star = (1.0 + 680.0*chi_k*chi_k)/(1.0 + 400.0*chi_k*chi_k);
417 else if (chi_k > 0.0)
418 f_beta_star = 680.0/400.0;
420 beta_star = beta0_star*f_beta_star;
425 beta = fmax(0.875*beta0,fmin(beta,beta0));
430 beta_star = fmax(beta0_star,fmin(beta_star,(680.0/400.0)*beta0_star));
440 const double dH[nSpace],
444 double h,nrm_v,oneByAbsdt;
447 for(
int I=0;I<nSpace;I++)
451 oneByAbsdt = fabs(dmt);
452 tau = 1.0/(2.0*nrm_v/h + oneByAbsdt + 1.0e-8);
458 const double G[nSpace*nSpace],
460 const double Ai[nSpace],
465 for(
int I=0;I<nSpace;I++)
466 for (
int J=0;J<nSpace;J++)
467 v_d_Gv += Ai[I]*G[I*nSpace+J]*Ai[J];
469 tau_v = 1.0/sqrt(Ct_sge*A0*A0 + v_d_Gv);
476 const double& elementDiameter,
477 const double& strong_residual,
478 const double grad_u[nSpace],
487 for (
int I=0;I<nSpace;I++)
488 n_grad_u += grad_u[I]*grad_u[I];
489 num = shockCapturingDiffusion*0.5*h*fabs(strong_residual);
490 den = sqrt(n_grad_u) + 1.0e-8;
496 const int& isAdvectiveFluxBoundary_u,
497 const double n[nSpace],
499 const double& bc_flux_u,
501 const double velocity[nSpace],
506 for (
int I=0; I < nSpace; I++)
507 flow +=
n[I]*velocity[I];
509 if (isDOFBoundary_u == 1)
523 else if (isAdvectiveFluxBoundary_u == 1)
556 H = 0.5*(1.0 +
phi/eps + sin(M_PI*
phi/eps)/M_PI);
562 const int& isAdvectiveFluxBoundary,
563 const double n[nSpace],
564 const double velocity[nSpace],
568 for (
int I=0; I < nSpace; I++)
569 flow +=
n[I]*velocity[I];
572 if (isDOFBoundary_u == 1)
583 else if (isAdvectiveFluxBoundary == 1)
597 const int& isDOFBoundary,
598 const int& isDiffusiveFluxBoundary,
602 double grad_psi[nSpace],
609 if (isDiffusiveFluxBoundary)
613 else if (isDOFBoundary)
616 for(
int I=0;I<nSpace;I++)
618 v_I = -a*grad_psi[I];
621 flux += penalty*(
u-bc_u);
631 const int& isDiffusiveFluxBoundary,
635 double grad_psi[nSpace],
636 const double grad_v[nSpace],
639 double& fluxJacobian)
641 if (isDiffusiveFluxBoundary == 0 && isDOFBoundary == 1)
644 for(
int I=0;I<nSpace;I++)
646 fluxJacobian -= (a*grad_v[I] + da*
v*grad_psi[I])*
n[I];
648 fluxJacobian += penalty*
v;
656 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
657 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
658 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
659 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
660 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
661 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
662 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
663 xt::pyarray<double>& u_trial_ref = args.
array<
double>(
"u_trial_ref");
664 xt::pyarray<double>& u_grad_trial_ref = args.
array<
double>(
"u_grad_trial_ref");
665 xt::pyarray<double>& u_test_ref = args.
array<
double>(
"u_test_ref");
666 xt::pyarray<double>& u_grad_test_ref = args.
array<
double>(
"u_grad_test_ref");
667 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
668 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
669 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
670 xt::pyarray<double>& u_trial_trace_ref = args.
array<
double>(
"u_trial_trace_ref");
671 xt::pyarray<double>& u_grad_trial_trace_ref = args.
array<
double>(
"u_grad_trial_trace_ref");
672 xt::pyarray<double>& u_test_trace_ref = args.
array<
double>(
"u_test_trace_ref");
673 xt::pyarray<double>& u_grad_test_trace_ref = args.
array<
double>(
"u_grad_test_trace_ref");
674 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
675 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
676 int nElements_global = args.
scalar<
int>(
"nElements_global");
679 double sigma_k = args.
scalar<
double>(
"sigma_k");
680 double c_mu = args.
scalar<
double>(
"c_mu");
683 double sedFlag = args.
scalar<
int>(
"sedFlag");
684 xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
685 xt::pyarray<double>& q_vos_gradc = args.
array<
double>(
"q_vos_gradc");
686 xt::pyarray<double>& ebqe_q_vos = args.
array<
double>(
"ebqe_q_vos");
687 xt::pyarray<double>& ebqe_q_vos_gradc = args.
array<
double>(
"ebqe_q_vos_gradc");
688 double rho_f = args.
scalar<
double>(
"rho_f");
689 double rho_s = args.
scalar<
double>(
"rho_s");
690 xt::pyarray<double>& vs = args.
array<
double>(
"vs");
691 xt::pyarray<double>& ebqe_vs = args.
array<
double>(
"ebqe_vs");
692 xt::pyarray<double>& g = args.
array<
double>(
"g");
693 int dissipation_model_flag = args.
scalar<
int>(
"dissipation_model_flag");
694 double useMetrics = args.
scalar<
double>(
"useMetrics");
695 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
696 int lag_shockCapturing = args.
scalar<
int>(
"lag_shockCapturing");
697 double shockCapturingDiffusion = args.
scalar<
double>(
"shockCapturingDiffusion");
698 double sc_uref = args.
scalar<
double>(
"sc_uref");
699 double sc_alpha = args.
scalar<
double>(
"sc_alpha");
700 xt::pyarray<int>& u_l2g = args.
array<
int>(
"u_l2g");
701 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
702 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
703 xt::pyarray<double>& u_dof_old = args.
array<
double>(
"u_dof_old");
704 xt::pyarray<double>& velocity = args.
array<
double>(
"velocity");
705 xt::pyarray<double>& phi_ls = args.
array<
double>(
"phi_ls");
706 xt::pyarray<double>& q_dissipation = args.
array<
double>(
"q_dissipation");
707 xt::pyarray<double>& q_grad_dissipation = args.
array<
double>(
"q_grad_dissipation");
708 xt::pyarray<double>& q_porosity = args.
array<
double>(
"q_porosity");
709 xt::pyarray<double>& velocity_dof_u = args.
array<
double>(
"velocity_dof_u");
710 xt::pyarray<double>& velocity_dof_v = args.
array<
double>(
"velocity_dof_v");
711 xt::pyarray<double>& velocity_dof_w = args.
array<
double>(
"velocity_dof_w");
712 xt::pyarray<double>& q_m = args.
array<
double>(
"q_m");
713 xt::pyarray<double>& q_u = args.
array<
double>(
"q_u");
714 xt::pyarray<double>& q_grad_u = args.
array<
double>(
"q_grad_u");
715 xt::pyarray<double>& q_m_betaBDF = args.
array<
double>(
"q_m_betaBDF");
716 xt::pyarray<double>& cfl = args.
array<
double>(
"cfl");
717 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
718 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
719 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
720 int offset_u = args.
scalar<
int>(
"offset_u");
721 int stride_u = args.
scalar<
int>(
"stride_u");
722 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
723 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
724 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
725 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
726 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
727 xt::pyarray<double>& ebqe_velocity_ext = args.
array<
double>(
"ebqe_velocity_ext");
728 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
729 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
730 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
731 xt::pyarray<double>& ebqe_bc_advectiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_advectiveFlux_u_ext");
732 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
733 xt::pyarray<double>& ebqe_bc_diffusiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_diffusiveFlux_u_ext");
734 xt::pyarray<double>& ebqe_phi = args.
array<
double>(
"ebqe_phi");
735 double epsFact = args.
scalar<
double>(
"epsFact");
736 xt::pyarray<double>& ebqe_dissipation = args.
array<
double>(
"ebqe_dissipation");
737 xt::pyarray<double>& ebqe_porosity = args.
array<
double>(
"ebqe_porosity");
738 xt::pyarray<double>& ebqe_u = args.
array<
double>(
"ebqe_u");
739 xt::pyarray<double>& ebqe_flux = args.
array<
double>(
"ebqe_flux");
751 for(
int eN=0;eN<nElements_global;eN++)
754 register double elementResidual_u[nDOF_test_element];
755 for (
int i=0;i<nDOF_test_element;i++)
757 elementResidual_u[i]=0.0;
760 for (
int k=0;k<nQuadraturePoints_element;k++)
763 register int eN_k = eN*nQuadraturePoints_element+k,
764 eN_k_nSpace = eN_k*nSpace,
765 eN_nDOF_trial_element = eN*nDOF_trial_element;
766 register double u=0.0,u_old=0.0,grad_u[nSpace],grad_u_old[nSpace],
768 f[nSpace],
df[nSpace],df_minus_da_grad_u[nSpace],
772 grad_vx[nSpace],grad_vy[nSpace],grad_vz[nSpace],
774 Lstar_u[nDOF_test_element],
776 tau=0.0,tau0=0.0,tau1=0.0,
777 numDiff0=0.0,numDiff1=0.0,
780 jacInv[nSpace*nSpace],
781 u_grad_trial[nDOF_trial_element*nSpace],
782 u_test_dV[nDOF_trial_element],
783 u_grad_test_dV[nDOF_test_element*nSpace],
785 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv;
805 ck.calculateMapping_element(eN,
809 mesh_trial_ref.data(),
810 mesh_grad_trial_ref.data(),
815 ck.calculateMappingVelocity_element(eN,
817 mesh_velocity_dof.data(),
819 mesh_trial_ref.data(),
822 dV = fabs(jacDet)*dV_ref[k];
823 ck.calculateG(jacInv,G,G_dd_G,tr_G);
825 ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial);
827 ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],
u);
828 ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old);
831 ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u);
832 ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u_old);
835 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx);
836 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy);
837 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz);
842 for (
int j=0;j<nDOF_trial_element;j++)
844 u_test_dV[j] = u_test_ref[k*nDOF_trial_element+j]*dV;
845 for (
int I=0;I<nSpace;I++)
847 u_grad_test_dV[j*nSpace+I] = u_grad_trial[j*nSpace+I]*dV;
870 &q_vos_gradc[eN_k_nSpace],
876 dissipation_model_flag,
878 &q_grad_dissipation[eN_k_nSpace],
890 f[0] -= MOVING_DOMAIN*m*
xt;
891 f[1] -= MOVING_DOMAIN*m*yt;
892 f[2] -= MOVING_DOMAIN*m*zt;
893 df[0] -= MOVING_DOMAIN*dm*
xt;
894 df[1] -= MOVING_DOMAIN*dm*yt;
895 df[2] -= MOVING_DOMAIN*dm*zt;
898 df_minus_da_grad_u[0] =
df[0] - da*grad_u[0];
899 df_minus_da_grad_u[1] =
df[1] - da*grad_u[1];
900 df_minus_da_grad_u[2] =
df[2] - da*grad_u[2];
914 pdeResidual_u =
ck.Mass_strong(m_t) +
ck.Advection_strong(df_minus_da_grad_u,grad_u)
915 +
ck.Reaction_strong(
r);
917 for (
int i=0;i<nDOF_test_element;i++)
921 register int i_nSpace = i*nSpace;
922 Lstar_u[i] =
ck.Advection_adjoint(df_minus_da_grad_u,&u_grad_test_dV[i_nSpace]) +
923 ck.Reaction_adjoint(dr,u_test_dV[i]);
934 tau = useMetrics*tau1+(1.0-useMetrics)*tau0;
936 subgridError_u = -tau*pdeResidual_u;
942 ck.calculateNumericalDiffusion(shockCapturingDiffusion,elementDiameter[eN],pdeResidual_u,grad_u,numDiff0);
943 ck.calculateNumericalDiffusion(shockCapturingDiffusion,sc_uref, sc_alpha,G,G_dd_G,pdeResidual_u,grad_u,numDiff1);
944 q_numDiff_u[eN_k] = useMetrics*numDiff1+(1.0-useMetrics)*numDiff0;
949 for(
int i=0;i<nDOF_test_element;i++)
951 register int eN_k_i=eN_k*nDOF_test_element+i,
952 eN_k_i_nSpace = eN_k_i*nSpace,
955 elementResidual_u[i] +=
ck.Mass_weak(m_t,u_test_dV[i]) +
956 ck.Advection_weak(
f,&u_grad_test_dV[i_nSpace]) +
957 ck.SubgridError(subgridError_u,Lstar_u[i]) +
958 ck.NumericalDiffusion(a,grad_u,&u_grad_test_dV[i_nSpace]) +
959 ck.NumericalDiffusion(q_numDiff_u_last[eN_k],grad_u,&u_grad_test_dV[i_nSpace]) +
960 ck.Reaction_weak(
r,u_test_dV[i]);
970 for (
int I=0; I < nSpace; I++)
972 q_grad_u[eN_k_nSpace + I] = grad_u[I];
978 for(
int i=0;i<nDOF_test_element;i++)
980 register int eN_i=eN*nDOF_test_element+i;
982 globalResidual[offset_u+stride_u*u_l2g[eN_i]] += elementResidual_u[i];
991 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
993 register int ebN = exteriorElementBoundariesArray[ebNE],
994 eN = elementBoundaryElementsArray[ebN*2+0],
995 ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0],
996 eN_nDOF_trial_element = eN*nDOF_trial_element;
997 register double elementResidual_u[nDOF_test_element];
998 for (
int i=0;i<nDOF_test_element;i++)
1000 elementResidual_u[i]=0.0;
1002 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1004 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1005 ebNE_kb_nSpace = ebNE_kb*nSpace,
1006 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1007 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1008 register double u_ext=0.0,u_old_ext,
1009 grad_u_ext[nSpace],grad_vx_ext[nSpace],grad_vy_ext[nSpace],grad_vz_ext[nSpace],
1010 grad_u_old_ext[nSpace],grad_dissipation_ext_dummy[nSpace],
1015 a_ext=0.0,da_ext=0.0,
1016 r_ext=0.0,dr_ext=0.0,
1018 diffusive_flux_ext=0.0,
1020 bc_grad_u_ext[nSpace],
1025 jac_ext[nSpace*nSpace],
1027 jacInv_ext[nSpace*nSpace],
1028 boundaryJac[nSpace*(nSpace-1)],
1029 metricTensor[(nSpace-1)*(nSpace-1)],
1030 metricTensorDetSqrt,
1032 u_test_dS[nDOF_test_element],
1033 u_grad_trial_trace[nDOF_trial_element*nSpace],
1034 normal[3],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
1035 G[nSpace*nSpace],G_dd_G,tr_G;
1040 ck.calculateMapping_elementBoundary(eN,
1046 mesh_trial_trace_ref.data(),
1047 mesh_grad_trial_trace_ref.data(),
1048 boundaryJac_ref.data(),
1054 metricTensorDetSqrt,
1058 ck.calculateMappingVelocity_elementBoundary(eN,
1062 mesh_velocity_dof.data(),
1064 mesh_trial_trace_ref.data(),
1065 xt_ext,yt_ext,zt_ext,
1070 dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref[kb];
1073 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1076 ck.gradTrialFromRef(&u_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace);
1078 ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
1079 ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext);
1080 ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext);
1081 ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext);
1084 grad_dissipation_ext_dummy[0] = 0.0; grad_dissipation_ext_dummy[1] = 0.0; grad_dissipation_ext_dummy[2] = 0.0;
1087 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext);
1088 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext);
1089 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext);
1093 for (
int j=0;j<nDOF_trial_element;j++)
1095 u_test_dS[j] = u_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
1100 bc_u_ext = isDOFBoundary_u[ebNE_kb]*ebqe_bc_u_ext[ebNE_kb]+(1-isDOFBoundary_u[ebNE_kb])*u_ext;
1116 ebqe_dissipation[ebNE_kb],
1117 ebqe_porosity[ebNE_kb],
1120 ebqe_q_vos[ebNE_kb],
1121 &ebqe_q_vos_gradc[ebNE_kb_nSpace],
1124 &ebqe_vs[ebNE_kb_nSpace],
1127 dissipation_model_flag,
1129 grad_dissipation_ext_dummy,
1150 ebqe_dissipation[ebNE_kb],
1151 ebqe_porosity[ebNE_kb],
1154 ebqe_q_vos[ebNE_kb],
1155 &ebqe_q_vos_gradc[ebNE_kb_nSpace],
1158 &ebqe_vs[ebNE_kb_nSpace],
1161 dissipation_model_flag,
1163 grad_dissipation_ext_dummy,
1175 double velocity_ext[nSpace];
1176 velocity_ext[0] = ebqe_velocity_ext[ebNE_kb_nSpace+0] - MOVING_DOMAIN*xt_ext;
1177 velocity_ext[1] = ebqe_velocity_ext[ebNE_kb_nSpace+1] - MOVING_DOMAIN*yt_ext;
1178 velocity_ext[2] = ebqe_velocity_ext[ebNE_kb_nSpace+2] - MOVING_DOMAIN*zt_ext;
1183 isAdvectiveFluxBoundary_u[ebNE_kb],
1186 ebqe_bc_advectiveFlux_u_ext[ebNE_kb],
1192 const double bc_diffusive_flux = ebqe_bc_diffusiveFlux_u_ext[ebNE_kb];
1194 isDOFBoundary_u[ebNE_kb],
1195 isDiffusiveFluxBoundary_u[ebNE_kb],
1201 ebqe_penalty_ext[ebNE_kb],
1202 diffusive_flux_ext);
1205 flux_ext += diffusive_flux_ext;
1206 ebqe_flux[ebNE_kb] = flux_ext;
1209 ebqe_u[ebNE_kb] = u_ext;
1211 ebqe_u[ebNE_kb] = bc_u_ext;
1215 for (
int i=0;i<nDOF_test_element;i++)
1217 int ebNE_kb_i = ebNE_kb*nDOF_test_element+i;
1219 elementResidual_u[i] +=
ck.ExteriorElementBoundaryFlux(flux_ext,u_test_dS[i]);
1225 for (
int i=0;i<nDOF_test_element;i++)
1227 int eN_i = eN*nDOF_test_element+i;
1229 globalResidual[offset_u+stride_u*u_l2g[eN_i]] += elementResidual_u[i];
1236 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1237 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1238 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1239 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
1240 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
1241 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1242 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1243 xt::pyarray<double>& u_trial_ref = args.
array<
double>(
"u_trial_ref");
1244 xt::pyarray<double>& u_grad_trial_ref = args.
array<
double>(
"u_grad_trial_ref");
1245 xt::pyarray<double>& u_test_ref = args.
array<
double>(
"u_test_ref");
1246 xt::pyarray<double>& u_grad_test_ref = args.
array<
double>(
"u_grad_test_ref");
1247 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1248 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1249 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1250 xt::pyarray<double>& u_trial_trace_ref = args.
array<
double>(
"u_trial_trace_ref");
1251 xt::pyarray<double>& u_grad_trial_trace_ref = args.
array<
double>(
"u_grad_trial_trace_ref");
1252 xt::pyarray<double>& u_test_trace_ref = args.
array<
double>(
"u_test_trace_ref");
1253 xt::pyarray<double>& u_grad_test_trace_ref = args.
array<
double>(
"u_grad_test_trace_ref");
1254 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1255 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1256 int nElements_global = args.
scalar<
int>(
"nElements_global");
1259 double sigma_k = args.
scalar<
double>(
"sigma_k");
1260 double c_mu = args.
scalar<
double>(
"c_mu");
1263 int dissipation_model_flag = args.
scalar<
int>(
"dissipation_model_flag");
1264 double useMetrics = args.
scalar<
double>(
"useMetrics");
1265 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
1266 int lag_shockCapturing = args.
scalar<
int>(
"lag_shockCapturing");
1267 double shockCapturingDiffusion = args.
scalar<
double>(
"shockCapturingDiffusion");
1268 xt::pyarray<int>& u_l2g = args.
array<
int>(
"u_l2g");
1269 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
1270 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1271 xt::pyarray<double>& u_dof_old = args.
array<
double>(
"u_dof_old");
1272 xt::pyarray<double>& velocity = args.
array<
double>(
"velocity");
1273 xt::pyarray<double>& phi_ls = args.
array<
double>(
"phi_ls");
1274 xt::pyarray<double>& q_dissipation = args.
array<
double>(
"q_dissipation");
1275 xt::pyarray<double>& q_grad_dissipation = args.
array<
double>(
"q_grad_dissipation");
1276 xt::pyarray<double>& q_porosity = args.
array<
double>(
"q_porosity");
1277 double sedFlag = args.
scalar<
int>(
"sedFlag");
1278 xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
1279 xt::pyarray<double>& q_vos_gradc = args.
array<
double>(
"q_vos_gradc");
1280 xt::pyarray<double>& ebqe_q_vos = args.
array<
double>(
"ebqe_q_vos");
1281 xt::pyarray<double>& ebqe_q_vos_gradc = args.
array<
double>(
"ebqe_q_vos_gradc");
1282 double rho_f = args.
scalar<
double>(
"rho_f");
1283 double rho_s = args.
scalar<
double>(
"rho_s");
1284 xt::pyarray<double>& vs = args.
array<
double>(
"vs");
1285 xt::pyarray<double>& ebqe_vs = args.
array<
double>(
"ebqe_vs");
1286 xt::pyarray<double>& g = args.
array<
double>(
"g");
1287 xt::pyarray<double>& velocity_dof_u = args.
array<
double>(
"velocity_dof_u");
1288 xt::pyarray<double>& velocity_dof_v = args.
array<
double>(
"velocity_dof_v");
1289 xt::pyarray<double>& velocity_dof_w = args.
array<
double>(
"velocity_dof_w");
1290 xt::pyarray<double>& q_m_betaBDF = args.
array<
double>(
"q_m_betaBDF");
1291 xt::pyarray<double>& cfl = args.
array<
double>(
"cfl");
1292 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
1293 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
1294 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
1295 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
1296 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
1297 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1298 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1299 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1300 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1301 xt::pyarray<double>& ebqe_velocity_ext = args.
array<
double>(
"ebqe_velocity_ext");
1302 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1303 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
1304 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
1305 xt::pyarray<double>& ebqe_bc_advectiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_advectiveFlux_u_ext");
1306 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
1307 xt::pyarray<double>& ebqe_bc_diffusiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_diffusiveFlux_u_ext");
1308 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
1309 xt::pyarray<double>& ebqe_phi = args.
array<
double>(
"ebqe_phi");
1310 double epsFact = args.
scalar<
double>(
"epsFact");
1311 xt::pyarray<double>& ebqe_dissipation = args.
array<
double>(
"ebqe_dissipation");
1312 xt::pyarray<double>& ebqe_porosity = args.
array<
double>(
"ebqe_porosity");
1313 double Ct_sge = 4.0;
1318 for(
int eN=0;eN<nElements_global;eN++)
1320 register double elementJacobian_u_u[nDOF_test_element][nDOF_trial_element];
1321 for (
int i=0;i<nDOF_test_element;i++)
1322 for (
int j=0;j<nDOF_trial_element;j++)
1324 elementJacobian_u_u[i][j]=0.0;
1326 for (
int k=0;k<nQuadraturePoints_element;k++)
1328 int eN_k = eN*nQuadraturePoints_element+k,
1329 eN_k_nSpace = eN_k*nSpace,
1330 eN_nDOF_trial_element = eN*nDOF_trial_element;
1333 register double u=0.0,u_old,
1334 grad_u[nSpace],grad_vx[nSpace],grad_vy[nSpace],grad_vz[nSpace],grad_u_old[nSpace],
1335 m=0.0,dm=0.0,a=0.0,da=0.0,
r=0.0,dr=0.0,
1336 f[nSpace],
df[nSpace],df_minus_da_grad_u[nSpace],
1338 dpdeResidual_u_u[nDOF_trial_element],
1339 Lstar_u[nDOF_test_element],
1340 dsubgridError_u_u[nDOF_trial_element],
1341 tau=0.0,tau0=0.0,tau1=0.0,
1344 jacInv[nSpace*nSpace],
1345 u_grad_trial[nDOF_trial_element*nSpace],
1347 u_test_dV[nDOF_test_element],
1348 u_grad_test_dV[nDOF_test_element*nSpace],
1350 G[nSpace*nSpace],G_dd_G,tr_G;
1372 ck.calculateMapping_element(eN,
1376 mesh_trial_ref.data(),
1377 mesh_grad_trial_ref.data(),
1382 ck.calculateMappingVelocity_element(eN,
1384 mesh_velocity_dof.data(),
1386 mesh_trial_ref.data(),
1389 dV = fabs(jacDet)*dV_ref[k];
1390 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1392 ck.gradTrialFromRef(&u_grad_trial_ref[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial);
1394 ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],
u);
1395 ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_ref[k*nDOF_trial_element],u_old);
1397 ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_u);
1400 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vx);
1401 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vy);
1402 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial,grad_vz);
1406 for (
int j=0;j<nDOF_trial_element;j++)
1408 u_test_dV[j] = u_test_ref[k*nDOF_trial_element+j]*dV;
1409 for (
int I=0;I<nSpace;I++)
1411 u_grad_test_dV[j*nSpace+I] = u_grad_trial[j*nSpace+I]*dV;
1429 q_dissipation[eN_k],
1434 &q_vos_gradc[eN_k_nSpace],
1440 dissipation_model_flag,
1442 &q_grad_dissipation[eN_k_nSpace],
1454 f[0] -= MOVING_DOMAIN*m*
xt;
1455 f[1] -= MOVING_DOMAIN*m*yt;
1456 f[2] -= MOVING_DOMAIN*m*zt;
1457 df[0] -= MOVING_DOMAIN*dm*
xt;
1458 df[1] -= MOVING_DOMAIN*dm*yt;
1459 df[2] -= MOVING_DOMAIN*dm*zt;
1464 df_minus_da_grad_u[0] =
df[0] - da*grad_u[0];
1465 df_minus_da_grad_u[1] =
df[1] - da*grad_u[1];
1466 df_minus_da_grad_u[2] =
df[2] - da*grad_u[2];
1481 for (
int i=0;i<nDOF_test_element;i++)
1485 register int i_nSpace = i*nSpace;
1486 Lstar_u[i]=
ck.Advection_adjoint(df_minus_da_grad_u,&u_grad_test_dV[i_nSpace])
1487 +
ck.Reaction_adjoint(dr,u_test_dV[i]);
1490 for (
int j=0;j<nDOF_trial_element;j++)
1494 int j_nSpace = j*nSpace;
1495 dpdeResidual_u_u[j]=
ck.MassJacobian_strong(dm_t,u_trial_ref[k*nDOF_trial_element+j]) +
1496 ck.AdvectionJacobian_strong(df_minus_da_grad_u,&u_grad_trial[j_nSpace]) +
1497 ck.ReactionJacobian_strong(dr,u_trial_ref[k*nDOF_trial_element+j]);
1512 tau = useMetrics*tau1+(1.0-useMetrics)*tau0;
1514 for(
int j=0;j<nDOF_trial_element;j++)
1515 dsubgridError_u_u[j] = -tau*dpdeResidual_u_u[j];
1516 for(
int i=0;i<nDOF_test_element;i++)
1520 for(
int j=0;j<nDOF_trial_element;j++)
1524 int j_nSpace = j*nSpace;
1525 int i_nSpace = i*nSpace;
1526 elementJacobian_u_u[i][j] +=
ck.MassJacobian_weak(dm_t,u_trial_ref[k*nDOF_trial_element+j],u_test_dV[i]) +
1527 ck.AdvectionJacobian_weak(df_minus_da_grad_u,u_trial_ref[k*nDOF_trial_element+j],&u_grad_test_dV[i_nSpace]) +
1528 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u[i]) +
1529 ck.NumericalDiffusionJacobian(a,&u_grad_trial[j_nSpace],&u_grad_test_dV[i_nSpace]) +
1530 ck.NumericalDiffusionJacobian(q_numDiff_u_last[eN_k],&u_grad_trial[j_nSpace],&u_grad_test_dV[i_nSpace]) +
1531 ck.ReactionJacobian_weak(dr,u_trial_ref[k*nDOF_trial_element+j],u_test_dV[i]);
1538 for (
int i=0;i<nDOF_test_element;i++)
1540 int eN_i = eN*nDOF_test_element+i;
1541 for (
int j=0;j<nDOF_trial_element;j++)
1543 int eN_i_j = eN_i*nDOF_trial_element+j;
1544 globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += elementJacobian_u_u[i][j];
1551 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1553 register int ebN = exteriorElementBoundariesArray[ebNE];
1554 register int eN = elementBoundaryElementsArray[ebN*2+0],
1555 ebN_local = elementBoundaryLocalElementBoundariesArray[ebN*2+0],
1556 eN_nDOF_trial_element = eN*nDOF_trial_element;
1557 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1559 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1560 ebNE_kb_nSpace = ebNE_kb*nSpace,
1561 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1562 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1564 register double u_ext=0.0,u_old_ext=0.0,
1566 grad_vx_ext[nSpace],grad_vy_ext[nSpace],grad_vz_ext[nSpace],
1567 grad_u_old_ext[nSpace],grad_dissipation_ext_dummy[nSpace],
1573 a_ext=0.0,da_ext=0.0,r_ext=0.0,dr_ext=0.0,
1580 fluxJacobian_u_u[nDOF_trial_element],
1581 diffusiveFluxJacobian_u_u[nDOF_trial_element],
1582 jac_ext[nSpace*nSpace],
1584 jacInv_ext[nSpace*nSpace],
1585 boundaryJac[nSpace*(nSpace-1)],
1586 metricTensor[(nSpace-1)*(nSpace-1)],
1587 metricTensorDetSqrt,
1589 u_test_dS[nDOF_test_element],
1590 u_grad_trial_trace[nDOF_trial_element*nSpace],
1591 normal[3],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
1592 G[nSpace*nSpace],G_dd_G,tr_G;
1614 ck.calculateMapping_elementBoundary(eN,
1620 mesh_trial_trace_ref.data(),
1621 mesh_grad_trial_trace_ref.data(),
1622 boundaryJac_ref.data(),
1628 metricTensorDetSqrt,
1632 ck.calculateMappingVelocity_elementBoundary(eN,
1636 mesh_velocity_dof.data(),
1638 mesh_trial_trace_ref.data(),
1639 xt_ext,yt_ext,zt_ext,
1644 dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref[kb];
1646 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1649 ck.gradTrialFromRef(&u_grad_trial_trace_ref[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace);
1651 ck.valFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_ext);
1652 ck.valFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],&u_trial_trace_ref[ebN_local_kb*nDOF_test_element],u_old_ext);
1653 ck.gradFromDOF(u_dof.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext);
1654 ck.gradFromDOF(u_dof_old.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext);
1657 grad_dissipation_ext_dummy[0] = 0.0; grad_dissipation_ext_dummy[1] = 0.0; grad_dissipation_ext_dummy[2] = 0.0;
1660 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext);
1661 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext);
1662 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext);
1666 for (
int j=0;j<nDOF_trial_element;j++)
1668 u_test_dS[j] = u_test_trace_ref[ebN_local_kb*nDOF_test_element+j]*dS;
1673 bc_u_ext = isDOFBoundary_u[ebNE_kb]*ebqe_bc_u_ext[ebNE_kb]+(1-isDOFBoundary_u[ebNE_kb])*u_ext;
1689 ebqe_dissipation[ebNE_kb],
1690 ebqe_porosity[ebNE_kb],
1693 ebqe_q_vos[ebNE_kb],
1694 &ebqe_q_vos_gradc[ebNE_kb_nSpace],
1697 &ebqe_vs[ebNE_kb_nSpace],
1700 dissipation_model_flag,
1702 grad_dissipation_ext_dummy,
1723 ebqe_dissipation[ebNE_kb],
1724 ebqe_porosity[ebNE_kb],
1727 ebqe_q_vos[ebNE_kb],
1728 &ebqe_q_vos_gradc[ebNE_kb_nSpace],
1731 &ebqe_vs[ebNE_kb_nSpace],
1734 dissipation_model_flag,
1736 grad_dissipation_ext_dummy,
1748 double velocity_ext[nSpace];
1749 velocity_ext[0] = ebqe_velocity_ext[ebNE_kb_nSpace+0] - MOVING_DOMAIN*xt_ext;
1750 velocity_ext[1] = ebqe_velocity_ext[ebNE_kb_nSpace+1] - MOVING_DOMAIN*yt_ext;
1751 velocity_ext[2] = ebqe_velocity_ext[ebNE_kb_nSpace+2] - MOVING_DOMAIN*zt_ext;
1756 isAdvectiveFluxBoundary_u[ebNE_kb],
1763 for (
int j=0;j<nDOF_trial_element;j++)
1766 register int ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
1769 isDiffusiveFluxBoundary_u[ebNE_kb],
1774 &u_grad_trial_trace[j*nSpace],
1775 u_trial_trace_ref[ebN_local_kb_j],
1776 ebqe_penalty_ext[ebNE_kb],
1777 diffusiveFluxJacobian_u_u[j]);
1780 fluxJacobian_u_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_u_u_ext,u_trial_trace_ref[ebN_local_kb_j]);
1785 for (
int i=0;i<nDOF_test_element;i++)
1787 register int eN_i = eN*nDOF_test_element+i;
1789 for (
int j=0;j<nDOF_trial_element;j++)
1793 globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] += fluxJacobian_u_u[j]*u_test_dS[i]
1794 + diffusiveFluxJacobian_u_u[j]*u_test_dS[i];
1803 int nQuadraturePoints_elementIn,
1804 int nDOF_mesh_trial_elementIn,
1805 int nDOF_trial_elementIn,
1806 int nDOF_test_elementIn,
1807 int nQuadraturePoints_elementBoundaryIn,
1812 double packFraction,
1825 double mu_fr_limiter)
1829 proteus::chooseAndAllocateDiscretization<Kappa_base,Kappa,CompKernel>
1831 nQuadraturePoints_elementIn,
1832 nDOF_mesh_trial_elementIn,
1833 nDOF_trial_elementIn,
1834 nDOF_test_elementIn,
1835 nQuadraturePoints_elementBoundaryIn,