virtual void compute_numerical_flux(PhysData& left, PhysData& right, const RealVectorNDIM& unit_normal, RealVectorNEQS& flux, Real& wave_speed) { set_meanflow_properties(left); // Compute left and right fluxes PHYS::compute_properties(left.coord, left.solution, dummy_grads, p); PHYS::flux(p , unit_normal, flux_left); PHYS::compute_properties(left.coord, right.solution, dummy_grads, p); PHYS::flux(p , unit_normal, flux_right); // Compute the averaged properties sol_avg.noalias() = 0.5*(left.solution+right.solution); PHYS::compute_properties(left.coord, sol_avg, dummy_grads, p); // Compute absolute jacobian using averaged properties PHYS::flux_jacobian_eigen_structure(p,unit_normal,right_eigenvectors,left_eigenvectors,eigenvalues); abs_jacobian.noalias() = right_eigenvectors * eigenvalues.cwiseAbs().asDiagonal() * left_eigenvectors; // flux = central flux - upwind flux flux.noalias() = 0.5*(flux_left + flux_right); flux.noalias() -= 0.5*abs_jacobian*(right.solution-left.solution); wave_speed = eigenvalues.cwiseAbs().maxCoeff(); }
virtual void compute_numerical_flux(PhysData& left, PhysData& right, const RealVectorNDIM& unit_normal, RealVectorNEQS& flux, Real& wave_speed) { Real P; compute_transformation_velocity(left.coord,m_Vt); // computation of the left and right properties // std::cout << "left" << std::endl; compute_properties(left, properties_left); // std::cout << "right " << std::endl; compute_properties(right, properties_right); cf3_assert(properties_left[0]>0); // computation of the left and right roe variables and roe average roe_var_left[0] = std::sqrt(properties_left[0]); // sqrt(rho) roe_var_left[1] = roe_var_left[0] * properties_left[1]; // sqrt(rho)*u roe_var_left[2] = roe_var_left[0] * properties_left[2]; // sqrt(rho)*v roe_var_left[3] = roe_var_left[0] * properties_left[3]; // sqrt(rho)*H cf3_assert(properties_right[0]>0); roe_var_right[0] = std::sqrt(properties_right[0]); // sqrt(rho) roe_var_right[1] = roe_var_right[0] * properties_right[1]; // sqrt(rho)*u roe_var_right[2] = roe_var_right[0] * properties_right[2]; // sqrt(rho)*v roe_var_right[3] = roe_var_right[0] * properties_right[3]; // sqrt(rho)*H roe_avg.noalias() = 0.5*(roe_var_left + roe_var_right); cf3_assert(roe_avg[0]>0); cf3_assert(roe_avg[3]>=0); properties_roe[0] = roe_avg[0]*roe_avg[0]; //rho properties_roe[1] = roe_avg[1]/roe_avg[0]; //u properties_roe[2] = roe_avg[2]/roe_avg[0]; //v properties_roe[3] = roe_avg[3]/roe_avg[0]; //H // P = properties_roe[0] * (gamma - 1.)/gamma*(properties_roe[3]-0.5 // *(properties_roe[1]*properties_roe[1] + properties_roe[2]*properties_roe[2]) + 0.5*(Vt[0] * Vt[0] + Vt[1] * Vt[1])); // //(gamma-1)/gamma * rho (H-0.5*(uu+vv)+0.5*Vt*Vt) P = properties_roe[0]*(properties_roe[3] - 0.5*(properties_roe[1]*properties_roe[1] + properties_roe[2]*properties_roe[2]) + 0.5*(m_Vt[0]*m_Vt[0] + m_Vt[1]*m_Vt[1])); P *= ((gamma-1)/gamma); cf3_assert(P>0); const Real nx = unit_normal[XX]; const Real ny = unit_normal[YY]; const Real rho = properties_roe[0]; cf3_assert(rho>0); const Real u = properties_roe[1]; const Real v = properties_roe[2]; const Real H = properties_roe[3]; const Real a = std::sqrt(gamma * P / rho); const Real a2 = gamma * P / rho; cf3_assert(a2>=0); cf3_assert(a>=0); const Real gamma_minus_1 = gamma - 1.; const Real uuvv = u*u + v*v; const Real half_gm1_v2 = 0.5 * gamma_minus_1 * uuvv; const Real inv_rho = 1./rho; const Real inv_a = 1. / a; const Real inv_a2 = inv_a * inv_a; const Real um = u * nx + v * ny; const Real ra = 0.5 * rho * inv_a; const Real coeffM2 = half_gm1_v2 * inv_a2; const Real uDivA = gamma_minus_1 * u * inv_a; const Real vDivA = gamma_minus_1 * v * inv_a; const Real rho_a = rho * a; cf3_assert(rho_a>=0); const Real gm1_ov_rhoa = gamma_minus_1 / rho_a; // matrix of right eigen vectors R right_eigenvectors(0,0) = 1.; right_eigenvectors(0,1) = 0.; right_eigenvectors(0,2) = ra; right_eigenvectors(0,3) = ra; right_eigenvectors(1,0) = u; right_eigenvectors(1,1) = rho * ny; right_eigenvectors(1,2) = ra*(u + a*nx); right_eigenvectors(1,3) = ra*(u - a*nx); right_eigenvectors(2,0) = v; right_eigenvectors(2,1) = -rho*nx; right_eigenvectors(2,2) = ra*(v + a*ny); right_eigenvectors(2,3) = ra*(v - a*ny); right_eigenvectors(3,0) = 0.5 * uuvv; right_eigenvectors(3,1) = rho * (u*ny - v*nx); right_eigenvectors(3,2) = ra*(H + a*um); right_eigenvectors(3,3) = ra*(H - a*um); // matrix of left eigen vectors L = R.inverse(); left_eigenvectors(0,0) = 1.- coeffM2; left_eigenvectors(0,1) = uDivA*inv_a; left_eigenvectors(0,2) = vDivA*inv_a; left_eigenvectors(0,3) = -gamma_minus_1 * inv_a2; left_eigenvectors(1,0) = inv_rho * (v*nx - u*ny); left_eigenvectors(1,1) = inv_rho * ny; left_eigenvectors(1,2) = -inv_rho * nx; left_eigenvectors(1,3) = 0.0; left_eigenvectors(2,0) = a*inv_rho * (coeffM2 - um*inv_a); left_eigenvectors(2,1) = inv_rho * (nx - uDivA); left_eigenvectors(2,2) = inv_rho * (ny - vDivA); left_eigenvectors(2,3) = gm1_ov_rhoa; left_eigenvectors(3,0) = a*inv_rho*(coeffM2 + um*inv_a); left_eigenvectors(3,1) = -inv_rho*(nx + uDivA); left_eigenvectors(3,2) = -inv_rho*(ny + vDivA); left_eigenvectors(3,3) = gm1_ov_rhoa; // diagonal matrix of eigen values eigenvalues[0] = um; eigenvalues[1] = um; eigenvalues[2] = um + a; eigenvalues[3] = um - a; //abs_jacobian nog te definieren abs_jacobian.noalias() = right_eigenvectors * eigenvalues.cwiseAbs().asDiagonal() * left_eigenvectors; // Compute left and right fluxes Real um_left = (properties_left[1]*nx + properties_left[2]*ny); Real um_right = (properties_right[1]*nx + properties_right[2]*ny); Real uuvv_left = properties_left[1]*properties_left[1] + properties_left[2]*properties_left[2]; Real uuvv_right = properties_right[1]*properties_right[1] + properties_right[2]*properties_right[2]; Real P_left = (gamma - 1.)/gamma * properties_left[0]*(properties_left[3] - 0.5*uuvv_left + 0.5 * (m_Vt[0] * m_Vt[0] + m_Vt[1] * m_Vt[1])); Real P_right = (gamma - 1.)/gamma * properties_right[0]*(properties_right[3] - 0.5*uuvv_right + 0.5 * (m_Vt[0] * m_Vt[0] + m_Vt[1] * m_Vt[1])); flux_left[0] = properties_left[0] * um_left; flux_left[1] = flux_left[0] * properties_left[1] + P_left*nx; flux_left[2] = flux_left[0] * properties_left[2] + P_left*ny; flux_left[3] = flux_left[0] * properties_left[3]; flux_right[0] = properties_right[0] * um_right; flux_right[1] = flux_right[0] * properties_right[1] + P_right*nx; flux_right[2] = flux_right[0] * properties_right[2] + P_right*ny; flux_right[3] = flux_right[0] * properties_right[3] ; flux.noalias() = 0.5*(flux_left + flux_right); flux.noalias() -= 0.5*abs_jacobian*(right.solution-left.solution); wave_speed = eigenvalues.cwiseAbs().maxCoeff(); }