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 const double grad_vz[nSpace],
123 double& inverse_sigma_k,
124 double& inverse_sigma_omega,
132 inverse_sigma_k = 2.0; inverse_sigma_omega=2.0; gamma = 13.0/25.0;
133 const double beta0_star = 0.09;
const double beta0 = 9.0/125.0;
134 double Omega[nSpace][nSpace] = {{0.,0.,0,},
137 double S[nSpace][nSpace] = {{0.0,0.,0.},
142 Omega[0][1] = 0.5*(grad_vx[1]-grad_vy[0]); Omega[0][2] = 0.5*(grad_vx[2]-grad_vz[0]);
143 Omega[1][0] =-Omega[0][1]; Omega[1][2] = 0.5*(grad_vy[2]-grad_vz[1]);
144 Omega[2][0] =-Omega[0][2]; Omega[2][1] =-Omega[1][2];
146 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]);
147 S[1][0] = S[0][1]; S[1][1] = grad_vy[1]; S[1][2] = 0.5*(grad_vy[2] + grad_vz[1]);
148 S[2][0] = S[0][2]; S[2][1] = S[1][2]; S[2][2] = grad_vz[2];
150 double chi_omega = 0.0;
151 for (
int i=0; i < nSpace; i++)
152 for (
int k=0; k < nSpace; k++)
153 for (
int j=0; j < nSpace; j++)
154 chi_omega += Omega[i][j]*Omega[j][k]*S[k][i];
155 if (fabs(omega) > div_eps)
157 chi_omega = fabs(chi_omega/(beta0_star*omega*beta0_star*omega*beta0_star*omega));
159 const double f_beta = (1.0+70.0*chi_omega)/(1.0 + 80.0*chi_omega);
166 double chi_k = grad_k[0]*grad_omega[0] + grad_k[1]*grad_omega[1] + grad_k[2]*grad_omega[2];
167 double f_beta_star = 1.0;
169 const double omega3 = omega*omega*omega;
170 if (fabs(omega3) > div_eps)
172 chi_k = chi_k/omega3;
173 f_beta_star = (1.0 + 680.0*chi_k*chi_k)/(1.0 + 400.0*chi_k*chi_k);
175 else if (chi_k > 0.0)
176 f_beta_star = 680.0/400.0;
178 beta_star = beta0_star*f_beta_star;
183 beta = fmax(0.875*beta0,fmin(beta,beta0));
188 beta_star = fmax(beta0_star,fmin(beta_star,(680.0/400.0)*beta0_star));
200 const double sigma_e,
205 const double grad_vx[nSpace],
206 const double grad_vy[nSpace],
207 const double grad_vz[nSpace],
208 const double& dissipation,
209 const double& dissipation_old,
211 const double& porosity,
215 double q_vos_gradc[nSpace],
221 int dissipation_model_flag,
222 const double grad_k[nSpace],
223 const double grad_dissipation_old[nSpace],
233 double nu_t=0.0,dnu_t_de=0.0,PiD4=0.0,disp=0.0,ddisp_de=0.0;
235 double gamma_e=0.0,F_e=0.0, gamma_production=0.0,sigma_a=sigma_e,
236 dgamma_e_d_dissipation=0.0, dF_e_d_dissipation=0.0;
238 const double isKEpsilon = (dissipation_model_flag>=2) ? 0.0 : 1.0;
239 m = dissipation*porosity;
242 for (
int I=0; I < nSpace; I++)
244 f[I] =
v[I]*porosity*dissipation;
245 df[I] =
v[I]*porosity;
248 double nu = (1.0-H_mu)*
nu_0 + H_mu*
nu_1;
249 const double div_eps = 1.0e-2*fmin(
nu_0,
nu_1);
251 nu_t = isKEpsilon*c_mu*k*k/(fabs(dissipation_old)+div_eps)
252 + (1.0-isKEpsilon)*k/(fabs(dissipation_old)+div_eps);
259 nu_t = fmax(nu_t,1.e-4*nu);
261 nu_t = fmin(nu_t,1.0e6*nu);
264 PiD4 = 2.0*(grad_vx[0]*grad_vx[0] +
265 grad_vy[1]*grad_vy[1] +
266 grad_vz[2]*grad_vz[2])
268 (grad_vx[1] + grad_vy[0])*(grad_vx[1] + grad_vy[0])
270 (grad_vx[2] + grad_vz[0])*(grad_vx[2] + grad_vz[0])
272 (grad_vy[2] + grad_vz[1])*(grad_vy[2] + grad_vz[1]);
275 double theta = 1e-10;
279 if (sedFlag == 1 && isKEpsilon > 0)
298 if (dissipation_model_flag==2)
301 double sigma_k=1.,beta_star=1.,beta=1.0;
306 grad_dissipation_old,
319 dgamma_e_d_dissipation = 0.0;
320 gamma_e = fmax(beta*k/nu_t,0.0);
326 dF_e_d_dissipation=0.0;
327 F_e = fmax(PiD4*gamma_production,0.0);
331 else if (dissipation_model_flag==3)
334 gamma_production = 5.0/9.0;
335 double beta = 3.0/40.0;
337 dgamma_e_d_dissipation = 0.0;
338 gamma_e = fmax(beta*k/nu_t,0.0);
341 dF_e_d_dissipation=0.0;
342 F_e = fmax(PiD4*gamma_production,0.0);
348 gamma_e = fmax(c_2*dissipation_old/(k+div_eps),0.0);
349 dgamma_e_d_dissipation = 0.0;
350 F_e = fmax(c_1*PiD4*k,0.0);
351 dF_e_d_dissipation=0.0;
355 a = porosity*(nu_t/sigma_a + nu);
356 da_de = porosity*dnu_t_de/sigma_a;
358 r = -porosity*F_e + porosity*gamma_e*dissipation+porosity*dSed*dissipation;
359 dr_de = -porosity*dF_e_d_dissipation + porosity*gamma_e + porosity*dgamma_e_d_dissipation+porosity*dSed;
366 const double dH[nSpace],
370 double h,nrm_v,oneByAbsdt;
373 for(
int I=0;I<nSpace;I++)
377 oneByAbsdt = fabs(dmt);
378 tau = 1.0/(2.0*nrm_v/h + oneByAbsdt + 1.0e-8);
384 const double G[nSpace*nSpace],
386 const double Ai[nSpace],
391 for(
int I=0;I<nSpace;I++)
392 for (
int J=0;J<nSpace;J++)
393 v_d_Gv += Ai[I]*G[I*nSpace+J]*Ai[J];
395 tau_v = 1.0/sqrt(Ct_sge*A0*A0 + v_d_Gv);
402 const double& elementDiameter,
403 const double& strong_residual,
404 const double grad_u[nSpace],
413 for (
int I=0;I<nSpace;I++)
414 n_grad_u += grad_u[I]*grad_u[I];
415 num = shockCapturingDiffusion*0.5*h*fabs(strong_residual);
416 den = sqrt(n_grad_u) + 1.0e-8;
422 const int& isAdvectiveFluxBoundary_u,
423 const double n[nSpace],
425 const double& bc_flux_u,
427 const double velocity[nSpace],
432 for (
int I=0; I < nSpace; I++)
433 flow +=
n[I]*velocity[I];
435 if (isDOFBoundary_u == 1)
449 else if (isAdvectiveFluxBoundary_u == 1)
482 H = 0.5*(1.0 +
phi/eps + sin(M_PI*
phi/eps)/M_PI);
488 const int& isAdvectiveFluxBoundary,
489 const double n[nSpace],
490 const double velocity[nSpace],
494 for (
int I=0; I < nSpace; I++)
495 flow +=
n[I]*velocity[I];
498 if (isDOFBoundary_u == 1)
509 else if (isAdvectiveFluxBoundary == 1)
523 const int& isDOFBoundary,
524 const int& isDiffusiveFluxBoundary,
528 double grad_psi[nSpace],
535 if (isDiffusiveFluxBoundary)
539 else if (isDOFBoundary)
542 for(
int I=0;I<nSpace;I++)
544 v_I = -a*grad_psi[I];
547 flux += penalty*(
u-bc_u);
557 const int& isDiffusiveFluxBoundary,
561 double grad_psi[nSpace],
562 const double grad_v[nSpace],
565 double& fluxJacobian)
567 if (isDiffusiveFluxBoundary == 0 && isDOFBoundary == 1)
570 for(
int I=0;I<nSpace;I++)
572 fluxJacobian -= (a*grad_v[I] + da*
v*grad_psi[I])*
n[I];
574 fluxJacobian += penalty*
v;
582 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
583 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
584 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
585 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
586 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
587 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
588 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
589 xt::pyarray<double>& u_trial_ref = args.
array<
double>(
"u_trial_ref");
590 xt::pyarray<double>& u_grad_trial_ref = args.
array<
double>(
"u_grad_trial_ref");
591 xt::pyarray<double>& u_test_ref = args.
array<
double>(
"u_test_ref");
592 xt::pyarray<double>& u_grad_test_ref = args.
array<
double>(
"u_grad_test_ref");
593 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
594 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
595 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
596 xt::pyarray<double>& u_trial_trace_ref = args.
array<
double>(
"u_trial_trace_ref");
597 xt::pyarray<double>& u_grad_trial_trace_ref = args.
array<
double>(
"u_grad_trial_trace_ref");
598 xt::pyarray<double>& u_test_trace_ref = args.
array<
double>(
"u_test_trace_ref");
599 xt::pyarray<double>& u_grad_test_trace_ref = args.
array<
double>(
"u_grad_test_trace_ref");
600 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
601 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
602 int nElements_global = args.
scalar<
int>(
"nElements_global");
605 double sigma_e = args.
scalar<
double>(
"sigma_e");
606 double c_mu = args.
scalar<
double>(
"c_mu");
607 double c_1 = args.
scalar<
double>(
"c_1");
608 double c_2 = args.
scalar<
double>(
"c_2");
609 double c_e = args.
scalar<
double>(
"c_e");
612 double sedFlag = args.
scalar<
int>(
"sedFlag");
613 xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
614 xt::pyarray<double>& q_vos_gradc = args.
array<
double>(
"q_vos_gradc");
615 xt::pyarray<double>& ebqe_q_vos = args.
array<
double>(
"ebqe_q_vos");
616 xt::pyarray<double>& ebqe_q_vos_gradc = args.
array<
double>(
"ebqe_q_vos_gradc");
617 double rho_f = args.
scalar<
double>(
"rho_f");
618 double rho_s = args.
scalar<
double>(
"rho_s");
619 xt::pyarray<double>& vs = args.
array<
double>(
"vs");
620 xt::pyarray<double>& ebqe_vs = args.
array<
double>(
"ebqe_vs");
621 xt::pyarray<double>& g = args.
array<
double>(
"g");
622 int dissipation_model_flag = args.
scalar<
int>(
"dissipation_model_flag");
623 double useMetrics = args.
scalar<
double>(
"useMetrics");
624 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
625 int lag_shockCapturing = args.
scalar<
int>(
"lag_shockCapturing");
626 double shockCapturingDiffusion = args.
scalar<
double>(
"shockCapturingDiffusion");
627 double sc_uref = args.
scalar<
double>(
"sc_uref");
628 double sc_alpha = args.
scalar<
double>(
"sc_alpha");
629 xt::pyarray<int>& u_l2g = args.
array<
int>(
"u_l2g");
630 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
631 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
632 xt::pyarray<double>& u_dof_old = args.
array<
double>(
"u_dof_old");
633 xt::pyarray<double>& velocity = args.
array<
double>(
"velocity");
634 xt::pyarray<double>& phi_ls = args.
array<
double>(
"phi_ls");
635 xt::pyarray<double>& q_kappa = args.
array<
double>(
"q_kappa");
636 xt::pyarray<double>& q_grad_kappa = args.
array<
double>(
"q_grad_kappa");
637 xt::pyarray<double>& q_porosity = args.
array<
double>(
"q_porosity");
638 xt::pyarray<double>& velocity_dof_u = args.
array<
double>(
"velocity_dof_u");
639 xt::pyarray<double>& velocity_dof_v = args.
array<
double>(
"velocity_dof_v");
640 xt::pyarray<double>& velocity_dof_w = args.
array<
double>(
"velocity_dof_w");
641 xt::pyarray<double>& q_m = args.
array<
double>(
"q_m");
642 xt::pyarray<double>& q_u = args.
array<
double>(
"q_u");
643 xt::pyarray<double>& q_grad_u = args.
array<
double>(
"q_grad_u");
644 xt::pyarray<double>& q_m_betaBDF = args.
array<
double>(
"q_m_betaBDF");
645 xt::pyarray<double>& cfl = args.
array<
double>(
"cfl");
646 xt::pyarray<double>& q_numDiff_u = args.
array<
double>(
"q_numDiff_u");
647 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
648 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
649 int offset_u = args.
scalar<
int>(
"offset_u");
650 int stride_u = args.
scalar<
int>(
"stride_u");
651 xt::pyarray<double>& globalResidual = args.
array<
double>(
"globalResidual");
652 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
653 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
654 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
655 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
656 xt::pyarray<double>& ebqe_velocity_ext = args.
array<
double>(
"ebqe_velocity_ext");
657 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
658 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
659 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
660 xt::pyarray<double>& ebqe_bc_advectiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_advectiveFlux_u_ext");
661 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
662 xt::pyarray<double>& ebqe_bc_diffusiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_diffusiveFlux_u_ext");
663 xt::pyarray<double>& ebqe_phi = args.
array<
double>(
"ebqe_phi");
664 double epsFact = args.
scalar<
double>(
"epsFact");
665 xt::pyarray<double>& ebqe_kappa = args.
array<
double>(
"ebqe_kappa");
666 xt::pyarray<double>& ebqe_porosity = args.
array<
double>(
"ebqe_porosity");
667 xt::pyarray<double>& ebqe_u = args.
array<
double>(
"ebqe_u");
668 xt::pyarray<double>& ebqe_flux = args.
array<
double>(
"ebqe_flux");
681 for(
int eN=0;eN<nElements_global;eN++)
684 register double elementResidual_u[nDOF_test_element];
685 for (
int i=0;i<nDOF_test_element;i++)
687 elementResidual_u[i]=0.0;
690 for (
int k=0;k<nQuadraturePoints_element;k++)
693 register int eN_k = eN*nQuadraturePoints_element+k,
694 eN_k_nSpace = eN_k*nSpace,
695 eN_nDOF_trial_element = eN*nDOF_trial_element;
696 register double u=0.0,u_old=0.0,
697 grad_u[nSpace],grad_u_old[nSpace],
699 f[nSpace],
df[nSpace],df_minus_da_grad_u[nSpace],
703 grad_vx[nSpace],grad_vy[nSpace],grad_vz[nSpace],
705 Lstar_u[nDOF_test_element],
707 tau=0.0,tau0=0.0,tau1=0.0,
708 numDiff0=0.0,numDiff1=0.0,
711 jacInv[nSpace*nSpace],
712 u_grad_trial[nDOF_trial_element*nSpace],
713 u_test_dV[nDOF_trial_element],
714 u_grad_test_dV[nDOF_test_element*nSpace],
716 G[nSpace*nSpace],G_dd_G,tr_G,norm_Rv;
736 ck.calculateMapping_element(eN,
740 mesh_trial_ref.data(),
741 mesh_grad_trial_ref.data(),
746 ck.calculateMappingVelocity_element(eN,
748 mesh_velocity_dof.data(),
750 mesh_trial_ref.data(),
753 dV = fabs(jacDet)*dV_ref.data()[k];
754 ck.calculateG(jacInv,G,G_dd_G,tr_G);
756 ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial);
758 ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],
u);
759 ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u_old);
761 ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u);
762 ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u_old);
765 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vx);
766 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vy);
767 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vz);
772 for (
int j=0;j<nDOF_trial_element;j++)
774 u_test_dV[j] = u_test_ref.data()[k*nDOF_trial_element+j]*dV;
775 for (
int I=0;I<nSpace;I++)
777 u_grad_test_dV[j*nSpace+I] = u_grad_trial[j*nSpace+I]*dV;
798 q_kappa.data()[eN_k],
799 q_porosity.data()[eN_k],
803 &q_vos_gradc.data()[eN_k_nSpace],
806 &vs.data()[eN_k_nSpace],
809 dissipation_model_flag,
810 &q_grad_kappa.data()[eN_k_nSpace],
823 f[0] -= MOVING_DOMAIN*m*
xt;
824 f[1] -= MOVING_DOMAIN*m*yt;
825 f[2] -= MOVING_DOMAIN*m*zt;
826 df[0] -= MOVING_DOMAIN*dm*
xt;
827 df[1] -= MOVING_DOMAIN*dm*yt;
828 df[2] -= MOVING_DOMAIN*dm*zt;
831 df_minus_da_grad_u[0] =
df[0] - da*grad_u[0];
832 df_minus_da_grad_u[1] =
df[1] - da*grad_u[1];
833 df_minus_da_grad_u[2] =
df[2] - da*grad_u[2];
838 q_m_betaBDF.data()[eN_k],
847 pdeResidual_u =
ck.Mass_strong(m_t) +
ck.Advection_strong(df_minus_da_grad_u,grad_u)
848 +
ck.Reaction_strong(
r);
850 for (
int i=0;i<nDOF_test_element;i++)
854 register int i_nSpace = i*nSpace;
855 Lstar_u[i] =
ck.Advection_adjoint(df_minus_da_grad_u,&u_grad_test_dV[i_nSpace]) +
856 ck.Reaction_adjoint(dr,u_test_dV[i]);
867 tau = useMetrics*tau1+(1.0-useMetrics)*tau0;
869 subgridError_u = -tau*pdeResidual_u;
875 ck.calculateNumericalDiffusion(shockCapturingDiffusion,elementDiameter.data()[eN],pdeResidual_u,grad_u,numDiff0);
876 ck.calculateNumericalDiffusion(shockCapturingDiffusion,sc_uref, sc_alpha,G,G_dd_G,pdeResidual_u,grad_u,numDiff1);
877 q_numDiff_u.data()[eN_k] = useMetrics*numDiff1+(1.0-useMetrics)*numDiff0;
882 for(
int i=0;i<nDOF_test_element;i++)
884 register int eN_k_i=eN_k*nDOF_test_element+i,
885 eN_k_i_nSpace = eN_k_i*nSpace,
888 elementResidual_u[i] +=
ck.Mass_weak(m_t,u_test_dV[i]) +
889 ck.Advection_weak(
f,&u_grad_test_dV[i_nSpace]) +
890 ck.SubgridError(subgridError_u,Lstar_u[i]) +
891 ck.NumericalDiffusion(a,grad_u,&u_grad_test_dV[i_nSpace]) +
892 ck.NumericalDiffusion(q_numDiff_u_last.data()[eN_k],grad_u,&u_grad_test_dV[i_nSpace]) +
893 ck.Reaction_weak(
r,u_test_dV[i]);
901 q_u.data()[eN_k] =
u;
902 q_m.data()[eN_k] = m;
903 for (
int I=0; I < nSpace; I++)
904 q_grad_u.data()[eN_k_nSpace+I] = grad_u[I];
909 for(
int i=0;i<nDOF_test_element;i++)
911 register int eN_i=eN*nDOF_test_element+i;
913 globalResidual.data()[offset_u+stride_u*u_l2g.data()[eN_i]] += elementResidual_u[i];
922 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
924 register int ebN = exteriorElementBoundariesArray.data()[ebNE],
925 eN = elementBoundaryElementsArray.data()[ebN*2+0],
926 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
927 eN_nDOF_trial_element = eN*nDOF_trial_element;
928 register double elementResidual_u[nDOF_test_element];
929 for (
int i=0;i<nDOF_test_element;i++)
931 elementResidual_u[i]=0.0;
933 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
935 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
936 ebNE_kb_nSpace = ebNE_kb*nSpace,
937 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
938 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
939 register double u_ext=0.0,u_old_ext=0.0,
940 grad_u_ext[nSpace],grad_vx_ext[nSpace],grad_vy_ext[nSpace],grad_vz_ext[nSpace],
941 grad_u_old_ext[nSpace],grad_kappa_ext_dummy[nSpace],
946 a_ext=0.0,da_ext=0.0,
947 r_ext=0.0,dr_ext=0.0,
949 diffusive_flux_ext=0.0,
951 bc_grad_u_ext[nSpace],
956 jac_ext[nSpace*nSpace],
958 jacInv_ext[nSpace*nSpace],
959 boundaryJac[nSpace*(nSpace-1)],
960 metricTensor[(nSpace-1)*(nSpace-1)],
963 u_test_dS[nDOF_test_element],
964 u_grad_trial_trace[nDOF_trial_element*nSpace],
965 normal[3],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
966 G[nSpace*nSpace],G_dd_G,tr_G;
971 ck.calculateMapping_elementBoundary(eN,
977 mesh_trial_trace_ref.data(),
978 mesh_grad_trial_trace_ref.data(),
979 boundaryJac_ref.data(),
989 ck.calculateMappingVelocity_elementBoundary(eN,
993 mesh_velocity_dof.data(),
995 mesh_trial_trace_ref.data(),
996 xt_ext,yt_ext,zt_ext,
1001 dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref.data()[kb];
1004 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1007 ck.gradTrialFromRef(&u_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace);
1009 ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
1010 ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_old_ext);
1011 ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext);
1012 ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext);
1015 grad_kappa_ext_dummy[0] = 0.0; grad_kappa_ext_dummy[1] = 0.0; grad_kappa_ext_dummy[2] = 0.0;
1019 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext);
1020 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext);
1021 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext);
1025 for (
int j=0;j<nDOF_trial_element;j++)
1027 u_test_dS[j] = u_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
1032 bc_u_ext = isDOFBoundary_u.data()[ebNE_kb]*ebqe_bc_u_ext.data()[ebNE_kb]+(1-isDOFBoundary_u.data()[ebNE_kb])*u_ext;
1038 ebqe_phi.data()[ebNE_kb],
1051 ebqe_kappa.data()[ebNE_kb],
1052 ebqe_porosity.data()[ebNE_kb],
1055 ebqe_q_vos.data()[ebNE_kb],
1056 &ebqe_q_vos_gradc.data()[ebNE_kb_nSpace],
1059 &ebqe_vs.data()[ebNE_kb_nSpace],
1062 dissipation_model_flag,
1063 grad_kappa_ext_dummy,
1075 ebqe_phi.data()[ebNE_kb],
1088 ebqe_kappa.data()[ebNE_kb],
1089 ebqe_porosity.data()[ebNE_kb],
1092 ebqe_q_vos.data()[ebNE_kb],
1093 &ebqe_q_vos_gradc.data()[ebNE_kb_nSpace],
1096 &ebqe_vs.data()[ebNE_kb_nSpace],
1099 dissipation_model_flag,
1100 grad_kappa_ext_dummy,
1113 double velocity_ext[nSpace];
1114 velocity_ext[0] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+0] - MOVING_DOMAIN*xt_ext;
1115 velocity_ext[1] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+1] - MOVING_DOMAIN*yt_ext;
1116 velocity_ext[2] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+2] - MOVING_DOMAIN*zt_ext;
1121 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
1124 ebqe_bc_advectiveFlux_u_ext.data()[ebNE_kb],
1130 const double bc_diffusive_flux = ebqe_bc_diffusiveFlux_u_ext.data()[ebNE_kb];
1132 isDOFBoundary_u.data()[ebNE_kb],
1133 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
1139 ebqe_penalty_ext.data()[ebNE_kb],
1140 diffusive_flux_ext);
1143 flux_ext += diffusive_flux_ext;
1144 ebqe_flux.data()[ebNE_kb] = flux_ext;
1147 ebqe_u.data()[ebNE_kb] = u_ext;
1149 ebqe_u.data()[ebNE_kb] = bc_u_ext;
1153 for (
int i=0;i<nDOF_test_element;i++)
1155 int ebNE_kb_i = ebNE_kb*nDOF_test_element+i;
1157 elementResidual_u[i] +=
ck.ExteriorElementBoundaryFlux(flux_ext,u_test_dS[i]);
1163 for (
int i=0;i<nDOF_test_element;i++)
1165 int eN_i = eN*nDOF_test_element+i;
1167 globalResidual.data()[offset_u+stride_u*u_l2g.data()[eN_i]] += elementResidual_u[i];
1174 xt::pyarray<double>& mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
1175 xt::pyarray<double>& mesh_grad_trial_ref = args.
array<
double>(
"mesh_grad_trial_ref");
1176 xt::pyarray<double>& mesh_dof = args.
array<
double>(
"mesh_dof");
1177 xt::pyarray<double>& mesh_velocity_dof = args.
array<
double>(
"mesh_velocity_dof");
1178 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
1179 xt::pyarray<int>& mesh_l2g = args.
array<
int>(
"mesh_l2g");
1180 xt::pyarray<double>& dV_ref = args.
array<
double>(
"dV_ref");
1181 xt::pyarray<double>& u_trial_ref = args.
array<
double>(
"u_trial_ref");
1182 xt::pyarray<double>& u_grad_trial_ref = args.
array<
double>(
"u_grad_trial_ref");
1183 xt::pyarray<double>& u_test_ref = args.
array<
double>(
"u_test_ref");
1184 xt::pyarray<double>& u_grad_test_ref = args.
array<
double>(
"u_grad_test_ref");
1185 xt::pyarray<double>& mesh_trial_trace_ref = args.
array<
double>(
"mesh_trial_trace_ref");
1186 xt::pyarray<double>& mesh_grad_trial_trace_ref = args.
array<
double>(
"mesh_grad_trial_trace_ref");
1187 xt::pyarray<double>& dS_ref = args.
array<
double>(
"dS_ref");
1188 xt::pyarray<double>& u_trial_trace_ref = args.
array<
double>(
"u_trial_trace_ref");
1189 xt::pyarray<double>& u_grad_trial_trace_ref = args.
array<
double>(
"u_grad_trial_trace_ref");
1190 xt::pyarray<double>& u_test_trace_ref = args.
array<
double>(
"u_test_trace_ref");
1191 xt::pyarray<double>& u_grad_test_trace_ref = args.
array<
double>(
"u_grad_test_trace_ref");
1192 xt::pyarray<double>& normal_ref = args.
array<
double>(
"normal_ref");
1193 xt::pyarray<double>& boundaryJac_ref = args.
array<
double>(
"boundaryJac_ref");
1194 int nElements_global = args.
scalar<
int>(
"nElements_global");
1197 double sigma_e = args.
scalar<
double>(
"sigma_e");
1198 double c_mu = args.
scalar<
double>(
"c_mu");
1199 double c_1 = args.
scalar<
double>(
"c_1");
1200 double c_2 = args.
scalar<
double>(
"c_2");
1201 double c_e = args.
scalar<
double>(
"c_e");
1204 int dissipation_model_flag = args.
scalar<
int>(
"dissipation_model_flag");
1205 double useMetrics = args.
scalar<
double>(
"useMetrics");
1206 double alphaBDF = args.
scalar<
double>(
"alphaBDF");
1207 int lag_shockCapturing = args.
scalar<
int>(
"lag_shockCapturing");
1208 double shockCapturingDiffusion = args.
scalar<
double>(
"shockCapturingDiffusion");
1209 xt::pyarray<int>& u_l2g = args.
array<
int>(
"u_l2g");
1210 xt::pyarray<double>& elementDiameter = args.
array<
double>(
"elementDiameter");
1211 xt::pyarray<double>& u_dof = args.
array<
double>(
"u_dof");
1212 xt::pyarray<double>& u_dof_old = args.
array<
double>(
"u_dof_old");
1213 xt::pyarray<double>& velocity = args.
array<
double>(
"velocity");
1214 xt::pyarray<double>& phi_ls = args.
array<
double>(
"phi_ls");
1215 xt::pyarray<double>& q_kappa = args.
array<
double>(
"q_kappa");
1216 xt::pyarray<double>& q_grad_kappa = args.
array<
double>(
"q_grad_kappa");
1217 xt::pyarray<double>& q_porosity = args.
array<
double>(
"q_porosity");
1218 double sedFlag = args.
scalar<
int>(
"sedFlag");
1219 xt::pyarray<double>& q_vos = args.
array<
double>(
"q_vos");
1220 xt::pyarray<double>& q_vos_gradc = args.
array<
double>(
"q_vos_gradc");
1221 xt::pyarray<double>& ebqe_q_vos = args.
array<
double>(
"ebqe_q_vos");
1222 xt::pyarray<double>& ebqe_q_vos_gradc = args.
array<
double>(
"ebqe_q_vos_gradc");
1223 double rho_f = args.
scalar<
double>(
"rho_f");
1224 double rho_s = args.
scalar<
double>(
"rho_s");
1225 xt::pyarray<double>& vs = args.
array<
double>(
"vs");
1226 xt::pyarray<double>& ebqe_vs = args.
array<
double>(
"ebqe_vs");
1227 xt::pyarray<double>& g = args.
array<
double>(
"g");
1228 xt::pyarray<double>& velocity_dof_u = args.
array<
double>(
"velocity_dof_u");
1229 xt::pyarray<double>& velocity_dof_v = args.
array<
double>(
"velocity_dof_v");
1230 xt::pyarray<double>& velocity_dof_w = args.
array<
double>(
"velocity_dof_w");
1231 xt::pyarray<double>& q_m_betaBDF = args.
array<
double>(
"q_m_betaBDF");
1232 xt::pyarray<double>& cfl = args.
array<
double>(
"cfl");
1233 xt::pyarray<double>& q_numDiff_u_last = args.
array<
double>(
"q_numDiff_u_last");
1234 xt::pyarray<double>& ebqe_penalty_ext = args.
array<
double>(
"ebqe_penalty_ext");
1235 xt::pyarray<int>& csrRowIndeces_u_u = args.
array<
int>(
"csrRowIndeces_u_u");
1236 xt::pyarray<int>& csrColumnOffsets_u_u = args.
array<
int>(
"csrColumnOffsets_u_u");
1237 xt::pyarray<double>& globalJacobian = args.
array<
double>(
"globalJacobian");
1238 int nExteriorElementBoundaries_global = args.
scalar<
int>(
"nExteriorElementBoundaries_global");
1239 xt::pyarray<int>& exteriorElementBoundariesArray = args.
array<
int>(
"exteriorElementBoundariesArray");
1240 xt::pyarray<int>& elementBoundaryElementsArray = args.
array<
int>(
"elementBoundaryElementsArray");
1241 xt::pyarray<int>& elementBoundaryLocalElementBoundariesArray = args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
1242 xt::pyarray<double>& ebqe_velocity_ext = args.
array<
double>(
"ebqe_velocity_ext");
1243 xt::pyarray<int>& isDOFBoundary_u = args.
array<
int>(
"isDOFBoundary_u");
1244 xt::pyarray<double>& ebqe_bc_u_ext = args.
array<
double>(
"ebqe_bc_u_ext");
1245 xt::pyarray<int>& isAdvectiveFluxBoundary_u = args.
array<
int>(
"isAdvectiveFluxBoundary_u");
1246 xt::pyarray<double>& ebqe_bc_advectiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_advectiveFlux_u_ext");
1247 xt::pyarray<int>& isDiffusiveFluxBoundary_u = args.
array<
int>(
"isDiffusiveFluxBoundary_u");
1248 xt::pyarray<double>& ebqe_bc_diffusiveFlux_u_ext = args.
array<
double>(
"ebqe_bc_diffusiveFlux_u_ext");
1249 xt::pyarray<int>& csrColumnOffsets_eb_u_u = args.
array<
int>(
"csrColumnOffsets_eb_u_u");
1250 xt::pyarray<double>& ebqe_phi = args.
array<
double>(
"ebqe_phi");
1251 double epsFact = args.
scalar<
double>(
"epsFact");
1252 xt::pyarray<double>& ebqe_kappa = args.
array<
double>(
"ebqe_kappa");
1253 xt::pyarray<double>& ebqe_porosity = args.
array<
double>(
"ebqe_porosity");
1254 double Ct_sge = 4.0;
1259 for(
int eN=0;eN<nElements_global;eN++)
1261 register double elementJacobian_u_u[nDOF_test_element][nDOF_trial_element];
1262 for (
int i=0;i<nDOF_test_element;i++)
1263 for (
int j=0;j<nDOF_trial_element;j++)
1265 elementJacobian_u_u[i][j]=0.0;
1267 for (
int k=0;k<nQuadraturePoints_element;k++)
1269 int eN_k = eN*nQuadraturePoints_element+k,
1270 eN_k_nSpace = eN_k*nSpace,
1271 eN_nDOF_trial_element = eN*nDOF_trial_element;
1274 register double u=0.0,u_old=0.0,
1275 grad_u[nSpace],grad_vx[nSpace],grad_vy[nSpace],grad_vz[nSpace],grad_u_old[nSpace],
1276 m=0.0,dm=0.0,a=0.0,da=0.0,
r=0.0,dr=0.0,
1277 f[nSpace],
df[nSpace],df_minus_da_grad_u[nSpace],
1279 dpdeResidual_u_u[nDOF_trial_element],
1280 Lstar_u[nDOF_test_element],
1281 dsubgridError_u_u[nDOF_trial_element],
1282 tau=0.0,tau0=0.0,tau1=0.0,
1285 jacInv[nSpace*nSpace],
1286 u_grad_trial[nDOF_trial_element*nSpace],
1288 u_test_dV[nDOF_test_element],
1289 u_grad_test_dV[nDOF_test_element*nSpace],
1291 G[nSpace*nSpace],G_dd_G,tr_G;
1313 ck.calculateMapping_element(eN,
1317 mesh_trial_ref.data(),
1318 mesh_grad_trial_ref.data(),
1323 ck.calculateMappingVelocity_element(eN,
1325 mesh_velocity_dof.data(),
1327 mesh_trial_ref.data(),
1330 dV = fabs(jacDet)*dV_ref.data()[k];
1331 ck.calculateG(jacInv,G,G_dd_G,tr_G);
1333 ck.gradTrialFromRef(&u_grad_trial_ref.data()[k*nDOF_trial_element*nSpace],jacInv,u_grad_trial);
1335 ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],
u);
1336 ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_ref.data()[k*nDOF_trial_element],u_old);
1338 ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u);
1339 ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_u_old);
1342 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vx);
1343 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vy);
1344 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial,grad_vz);
1348 for (
int j=0;j<nDOF_trial_element;j++)
1350 u_test_dV[j] = u_test_ref.data()[k*nDOF_trial_element+j]*dV;
1351 for (
int I=0;I<nSpace;I++)
1353 u_grad_test_dV[j*nSpace+I] = u_grad_trial[j*nSpace+I]*dV;
1361 phi_ls.data()[eN_k],
1374 q_kappa.data()[eN_k],
1375 q_porosity.data()[eN_k],
1379 &q_vos_gradc.data()[eN_k_nSpace],
1382 &vs.data()[eN_k_nSpace],
1385 dissipation_model_flag,
1386 &q_grad_kappa.data()[eN_k_nSpace],
1399 f[0] -= MOVING_DOMAIN*m*
xt;
1400 f[1] -= MOVING_DOMAIN*m*yt;
1401 f[2] -= MOVING_DOMAIN*m*zt;
1402 df[0] -= MOVING_DOMAIN*dm*
xt;
1403 df[1] -= MOVING_DOMAIN*dm*yt;
1404 df[2] -= MOVING_DOMAIN*dm*zt;
1409 df_minus_da_grad_u[0] =
df[0] - da*grad_u[0];
1410 df_minus_da_grad_u[1] =
df[1] - da*grad_u[1];
1411 df_minus_da_grad_u[2] =
df[2] - da*grad_u[2];
1417 q_m_betaBDF.data()[eN_k],
1426 for (
int i=0;i<nDOF_test_element;i++)
1430 register int i_nSpace = i*nSpace;
1431 Lstar_u[i]=
ck.Advection_adjoint(df_minus_da_grad_u,&u_grad_test_dV[i_nSpace])
1432 +
ck.Reaction_adjoint(dr,u_test_dV[i]);
1435 for (
int j=0;j<nDOF_trial_element;j++)
1439 int j_nSpace = j*nSpace;
1440 dpdeResidual_u_u[j]=
ck.MassJacobian_strong(dm_t,u_trial_ref.data()[k*nDOF_trial_element+j]) +
1441 ck.AdvectionJacobian_strong(df_minus_da_grad_u,&u_grad_trial[j_nSpace]) +
1442 ck.ReactionJacobian_strong(dr,u_trial_ref.data()[k*nDOF_trial_element+j]);
1457 tau = useMetrics*tau1+(1.0-useMetrics)*tau0;
1459 for(
int j=0;j<nDOF_trial_element;j++)
1460 dsubgridError_u_u[j] = -tau*dpdeResidual_u_u[j];
1461 for(
int i=0;i<nDOF_test_element;i++)
1465 for(
int j=0;j<nDOF_trial_element;j++)
1469 int j_nSpace = j*nSpace;
1470 int i_nSpace = i*nSpace;
1471 elementJacobian_u_u[i][j] +=
ck.MassJacobian_weak(dm_t,u_trial_ref.data()[k*nDOF_trial_element+j],u_test_dV[i]) +
1472 ck.AdvectionJacobian_weak(df_minus_da_grad_u,u_trial_ref.data()[k*nDOF_trial_element+j],&u_grad_test_dV[i_nSpace]) +
1473 ck.SubgridErrorJacobian(dsubgridError_u_u[j],Lstar_u[i]) +
1474 ck.NumericalDiffusionJacobian(a,&u_grad_trial[j_nSpace],&u_grad_test_dV[i_nSpace]) +
1475 ck.NumericalDiffusionJacobian(q_numDiff_u_last.data()[eN_k],&u_grad_trial[j_nSpace],&u_grad_test_dV[i_nSpace]) +
1476 ck.ReactionJacobian_weak(dr,u_trial_ref.data()[k*nDOF_trial_element+j],u_test_dV[i]);
1483 for (
int i=0;i<nDOF_test_element;i++)
1485 int eN_i = eN*nDOF_test_element+i;
1486 for (
int j=0;j<nDOF_trial_element;j++)
1488 int eN_i_j = eN_i*nDOF_trial_element+j;
1489 globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_u_u[eN_i_j]] += elementJacobian_u_u[i][j];
1496 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++)
1498 register int ebN = exteriorElementBoundariesArray.data()[ebNE];
1499 register int eN = elementBoundaryElementsArray.data()[ebN*2+0],
1500 ebN_local = elementBoundaryLocalElementBoundariesArray.data()[ebN*2+0],
1501 eN_nDOF_trial_element = eN*nDOF_trial_element;
1502 for (
int kb=0;kb<nQuadraturePoints_elementBoundary;kb++)
1504 register int ebNE_kb = ebNE*nQuadraturePoints_elementBoundary+kb,
1505 ebNE_kb_nSpace = ebNE_kb*nSpace,
1506 ebN_local_kb = ebN_local*nQuadraturePoints_elementBoundary+kb,
1507 ebN_local_kb_nSpace = ebN_local_kb*nSpace;
1509 register double u_ext=0.0,u_old_ext=0.0,
1511 grad_vx_ext[nSpace],grad_vy_ext[nSpace],grad_vz_ext[nSpace],
1512 grad_u_old_ext[nSpace],grad_kappa_ext_dummy[nSpace],
1518 a_ext=0.0,da_ext=0.0,r_ext=0.0,dr_ext=0.0,
1525 fluxJacobian_u_u[nDOF_trial_element],
1526 diffusiveFluxJacobian_u_u[nDOF_trial_element],
1527 jac_ext[nSpace*nSpace],
1529 jacInv_ext[nSpace*nSpace],
1530 boundaryJac[nSpace*(nSpace-1)],
1531 metricTensor[(nSpace-1)*(nSpace-1)],
1532 metricTensorDetSqrt,
1534 u_test_dS[nDOF_test_element],
1535 u_grad_trial_trace[nDOF_trial_element*nSpace],
1536 normal[3],x_ext,y_ext,z_ext,xt_ext,yt_ext,zt_ext,integralScaling,
1537 G[nSpace*nSpace],G_dd_G,tr_G;
1559 ck.calculateMapping_elementBoundary(eN,
1565 mesh_trial_trace_ref.data(),
1566 mesh_grad_trial_trace_ref.data(),
1567 boundaryJac_ref.data(),
1573 metricTensorDetSqrt,
1577 ck.calculateMappingVelocity_elementBoundary(eN,
1581 mesh_velocity_dof.data(),
1583 mesh_trial_trace_ref.data(),
1584 xt_ext,yt_ext,zt_ext,
1589 dS = ((1.0-MOVING_DOMAIN)*metricTensorDetSqrt + MOVING_DOMAIN*integralScaling)*dS_ref.data()[kb];
1591 ck.calculateG(jacInv_ext,G,G_dd_G,tr_G);
1594 ck.gradTrialFromRef(&u_grad_trial_trace_ref.data()[ebN_local_kb_nSpace*nDOF_trial_element],jacInv_ext,u_grad_trial_trace);
1596 ck.valFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_ext);
1597 ck.valFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],&u_trial_trace_ref.data()[ebN_local_kb*nDOF_test_element],u_old_ext);
1598 ck.gradFromDOF(u_dof.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_ext);
1599 ck.gradFromDOF(u_dof_old.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_u_old_ext);
1602 grad_kappa_ext_dummy[0] = 0.0; grad_kappa_ext_dummy[1] = 0.0; grad_kappa_ext_dummy[2] = 0.0;
1606 ck.gradFromDOF(velocity_dof_u.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vx_ext);
1607 ck.gradFromDOF(velocity_dof_v.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vy_ext);
1608 ck.gradFromDOF(velocity_dof_w.data(),&u_l2g.data()[eN_nDOF_trial_element],u_grad_trial_trace,grad_vz_ext);
1612 for (
int j=0;j<nDOF_trial_element;j++)
1614 u_test_dS[j] = u_test_trace_ref.data()[ebN_local_kb*nDOF_test_element+j]*dS;
1619 bc_u_ext = isDOFBoundary_u.data()[ebNE_kb]*ebqe_bc_u_ext.data()[ebNE_kb]+(1-isDOFBoundary_u.data()[ebNE_kb])*u_ext;
1625 ebqe_phi.data()[ebNE_kb],
1638 ebqe_kappa.data()[ebNE_kb],
1639 ebqe_porosity.data()[ebNE_kb],
1642 ebqe_q_vos.data()[ebNE_kb],
1643 &ebqe_q_vos_gradc.data()[ebNE_kb_nSpace],
1646 &ebqe_vs.data()[ebNE_kb_nSpace],
1649 dissipation_model_flag,
1650 grad_kappa_ext_dummy,
1662 ebqe_phi.data()[ebNE_kb],
1675 ebqe_kappa.data()[ebNE_kb],
1676 ebqe_porosity.data()[ebNE_kb],
1679 ebqe_q_vos.data()[ebNE_kb],
1680 &ebqe_q_vos_gradc.data()[ebNE_kb_nSpace],
1683 &ebqe_vs.data()[ebNE_kb_nSpace],
1686 dissipation_model_flag,
1687 grad_kappa_ext_dummy,
1700 double velocity_ext[nSpace];
1701 velocity_ext[0] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+0] - MOVING_DOMAIN*xt_ext;
1702 velocity_ext[1] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+1] - MOVING_DOMAIN*yt_ext;
1703 velocity_ext[2] = ebqe_velocity_ext.data()[ebNE_kb_nSpace+2] - MOVING_DOMAIN*zt_ext;
1708 isAdvectiveFluxBoundary_u.data()[ebNE_kb],
1715 for (
int j=0;j<nDOF_trial_element;j++)
1718 register int ebN_local_kb_j=ebN_local_kb*nDOF_trial_element+j;
1721 isDiffusiveFluxBoundary_u.data()[ebNE_kb],
1726 &u_grad_trial_trace[j*nSpace],
1727 u_trial_trace_ref.data()[ebN_local_kb_j],
1728 ebqe_penalty_ext.data()[ebNE_kb],
1729 diffusiveFluxJacobian_u_u[j]);
1732 fluxJacobian_u_u[j]=
ck.ExteriorNumericalAdvectiveFluxJacobian(dflux_u_u_ext,u_trial_trace_ref.data()[ebN_local_kb_j]);
1737 for (
int i=0;i<nDOF_test_element;i++)
1739 register int eN_i = eN*nDOF_test_element+i;
1741 for (
int j=0;j<nDOF_trial_element;j++)
1745 globalJacobian[csrRowIndeces_u_u[eN_i] + csrColumnOffsets_eb_u_u[ebN_i_j]] += fluxJacobian_u_u[j]*u_test_dS[i]
1746 + diffusiveFluxJacobian_u_u[j]*u_test_dS[i];
1755 int nQuadraturePoints_elementIn,
1756 int nDOF_mesh_trial_elementIn,
1757 int nDOF_trial_elementIn,
1758 int nDOF_test_elementIn,
1759 int nQuadraturePoints_elementBoundaryIn,
1764 double packFraction,
1777 double mu_fr_limiter)
1781 proteus::chooseAndAllocateDiscretization<Dissipation_base,Dissipation,CompKernel>
1783 nQuadraturePoints_elementIn,
1784 nDOF_mesh_trial_elementIn,
1785 nDOF_trial_elementIn,
1786 nDOF_test_elementIn,
1787 nQuadraturePoints_elementBoundaryIn,