//********************************************************************** PHX_EVALUATE_FIELDS(Equations,workset) { for (int i=0; i < residual_temp.size(); ++i) residual_temp[i] = 0.0; for (int i=0; i < residual_vel.size(); ++i) residual_vel[i] = 0.0; std::vector<Element_Linear2D>::iterator element = workset.begin; for (std::size_t cell = 0; cell < workset.num_cells; ++cell,++element) { const Kokkos::View<double**,PHX::Device> phi = element->basisFunctions(); const Kokkos::View<double***,PHX::Device> grad_phi = element->basisFunctionGradientsRealSpace(); const Kokkos::View<double*,PHX::Device> det_jac = element->detJacobian(); const Kokkos::View<double*,PHX::Device> weights = element->quadratureWeights(); for (int node = 0; node < element->numNodes(); ++node) { for (int qp = 0; qp < num_qp; ++qp) { residual_temp(cell,node) += det_jac(qp) * weights(qp) * ( grad_phi(qp,node,0) * grad_temp(cell,qp,0) + grad_phi(qp,node,1) * grad_temp(cell,qp,1) + 1000.0 * phi(qp,node) * temp(cell,qp) * vel(cell,qp) ); residual_vel(cell,node) += det_jac(qp) * weights(qp) * ( grad_phi(qp,node,0) * grad_vel(cell,qp,0) + grad_phi(qp,node,1) * grad_vel(cell,qp,1) + 1000.0 * phi(qp,node) * temp(cell,qp) * vel(cell,qp) ); } } } // std::cout << "Temp Residual" << std::endl; // residual_temp.print(std::cout,true); // std::cout << "Vx Residual" << std::endl; // residual_vel.print(std::cout,true); }
void CFDDataPack::reinitViscous() { grad_rho = duh[0]; grad_mom = RealTensor(duh[1], duh[2], duh[3]); for (int a = 0; a < 3; ++a) for (int b = 0; b < 3; ++b) grad_vel(a, b) = (grad_mom(a, b) - vel(a)*grad_rho(b))/r; tau = grad_vel + grad_vel.transpose(); vel_div = grad_vel.tr(); tau(0, 0) -= 2./3*vel_div; tau(1, 1) -= 2./3*vel_div; tau(2, 2) -= 2./3*vel_div; if(_cfd_problem._vis_type == 0) vis = 0.0; else if(_cfd_problem._vis_type == 1) vis = 1.0; else if(_cfd_problem._vis_type == 2) { Real t_ref(288), t_s(110.4); vis = pow(t/t_ref, 1.5)*(t_ref+t_s)/(t+t_s); } else mooseError("不可知的粘性模型"); tau *= vis/_reynolds; grad_enthalpy = (duh[4]-uh[4]/uh[0] * duh[0])/r - grad_vel.transpose() * vel; grad_enthalpy *= (vis/_reynolds)*(_gamma/_prandtl); invis_flux[0] = r*vel; invis_flux[1] = mom(0)*vel; invis_flux[1](0) += p; invis_flux[2] = mom(1)*vel; invis_flux[2](1) += p; invis_flux[3] = mom(2)*vel; invis_flux[3](2) += p; invis_flux[4] = r*h*vel; vis_flux[0].zero(); vis_flux[1] = tau.row(0); vis_flux[2] = tau.row(1); vis_flux[3] = tau.row(2); vis_flux[4] = tau * vel + grad_enthalpy; }