@@ -2392,9 +2392,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23922392
23932393 unsigned long iVertex, iPoint, iPointNormal;
23942394 unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
2395- unsigned short T_INDEX = 0 , TVE_INDEX = 0 , VEL_INDEX = 0 ;
2396- su2double Viscosity = 0.0 , WallDist[3 ] = {0.0 }, Area, TauNormal, dTn, dTven,
2397- GradTemperature, Density = 0.0 , WallDistMod, FrictionVel,
2395+ unsigned short T_INDEX = 0 , TVE_INDEX = 0 , VEL_INDEX = 0 , RHOS_INDEX = 0 ;
2396+ su2double Viscosity = 0.0 , WallDist[3 ] = {0.0 }, Area, Density = 0.0 , GradTemperature = 0.0 ,
23982397 UnitNormal[3 ] = {0.0 }, TauElem[3 ] = {0.0 }, TauTangent[3 ] = {0.0 }, Tau[3 ][3 ] = {{0.0 }}, Cp,
23992398 thermal_conductivity, MaxNorm = 8.0 , Grad_Vel[3 ][3 ] = {{0.0 }}, Grad_Temp[3 ] = {0.0 }, AxiFactor;
24002399 const su2double *Coord = nullptr , *Coord_Normal = nullptr , *Normal = nullptr ;
@@ -2527,30 +2526,25 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25272526 /* --- Compute wall shear stress (using the stress tensor). Compute wall skin friction coefficient, and heat flux
25282527 * on the wall ---*/
25292528
2530- TauNormal = 0.0 ;
2531- for (iDim = 0 ; iDim < nDim; iDim++) TauNormal += TauElem[iDim] * UnitNormal[iDim];
2529+ su2double TauNormal = GeometryToolbox::DotProduct (nDim, TauElem, UnitNormal);
25322530
2533- WallShearStress[iMarker][iVertex] = 0.0 ;
25342531 for (iDim = 0 ; iDim < nDim; iDim++) {
25352532 TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim];
25362533 /* --- in case of wall functions, we have computed the skin friction in the turbulence solver --- */
25372534 /* --- Note that in the wall model, we switch off the computation when the computed y+ < 5 --- */
25382535 /* --- We put YPlus to 1.0 so we have to compute skinfriction and the actual y+ in that case as well --- */
25392536 if (!wallfunctions || (wallfunctions && YPlus[iMarker][iVertex] < 5.0 ))
25402537 CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric;
2541-
2542- WallShearStress[iMarker][iVertex] += TauTangent[iDim] * TauTangent[iDim];
25432538 }
2544- WallShearStress[iMarker][iVertex] = sqrt (WallShearStress[iMarker][iVertex] );
2539+ WallShearStress[iMarker][iVertex] = GeometryToolbox::Norm (nDim, TauTangent );
25452540
25462541 for (iDim = 0 ; iDim < nDim; iDim++) WallDist[iDim] = (Coord[iDim] - Coord_Normal[iDim]);
2547- WallDistMod = 0.0 ;
2548- for (iDim = 0 ; iDim < nDim; iDim++) WallDistMod += WallDist[iDim] * WallDist[iDim];
2549- WallDistMod = sqrt (WallDistMod);
2542+
2543+ su2double WallDistMod = GeometryToolbox::Norm (nDim, WallDist);
25502544
25512545 /* --- Compute y+ and non-dimensional velocity ---*/
25522546
2553- FrictionVel = sqrt (fabs (WallShearStress[iMarker][iVertex]) / Density);
2547+ su2double FrictionVel = sqrt (fabs (WallShearStress[iMarker][iVertex]) / Density);
25542548
25552549 /* --- in case of wall functions, we have computed YPlus in the turbulence class --- */
25562550 /* --- Note that we do not recompute y+ when y+<5 because y+ can become > 5 again --- */
@@ -2562,35 +2556,41 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25622556 // / TODO: Move these ifs to specialized functions.
25632557 if (!nemo){
25642558
2565- GradTemperature = 0.0 ;
2566-
25672559 if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) {
2568- for (iDim = 0 ; iDim < nDim; iDim++) GradTemperature -= Grad_Temp[iDim] * UnitNormal[iDim] ;
2560+ GradTemperature = - GeometryToolbox::DotProduct ( nDim, Grad_Temp, UnitNormal) ;
25692561
25702562 Cp = (Gamma / Gamma_Minus_One) * Gas_Constant;
25712563 thermal_conductivity = Cp * Viscosity / Prandtl_Lam;
25722564 }
25732565 if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE) {
25742566 if (energy)
2575- for (iDim = 0 ; iDim < nDim; iDim++) GradTemperature -= Grad_Temp[iDim] * UnitNormal[iDim] ;
2567+ GradTemperature = - GeometryToolbox::DotProduct ( nDim, Grad_Temp, UnitNormal) ;
25762568
25772569 thermal_conductivity = nodes->GetThermalConductivity (iPoint);
25782570 }
2579-
25802571 HeatFlux[iMarker][iVertex] = -thermal_conductivity * GradTemperature * RefHeatFlux;
25812572
25822573 } else {
25832574
2584- const auto thermal_conductivity_tr = nodes->GetThermalConductivity (iPoint);
2585- const auto thermal_conductivity_ve = nodes->GetThermalConductivity_ve (iPoint);
2586- const auto Grad_PrimVar = nodes->GetGradient_Primitive (iPoint);
2587-
2588- dTn = 0.0 ; dTven = 0.0 ;
2589- for (iDim = 0 ; iDim < nDim; iDim++) {
2590- dTn += Grad_PrimVar[T_INDEX][iDim]*UnitNormal[iDim];
2591- dTven += Grad_PrimVar[TVE_INDEX][iDim]*UnitNormal[iDim];
2592- }
2593- HeatFlux[iMarker][iVertex] = thermal_conductivity_tr*dTn + thermal_conductivity_ve*dTven;
2575+ unsigned short iSpecies, nSpecies = config->GetnSpecies ();
2576+
2577+ const auto & thermal_conductivity_tr = nodes->GetThermalConductivity (iPoint);
2578+ const auto & thermal_conductivity_ve = nodes->GetThermalConductivity_ve (iPoint);
2579+ const auto & Grad_PrimVar = nodes->GetGradient_Primitive (iPoint);
2580+ const auto & Ds = nodes->GetDiffusionCoeff (iPoint);
2581+ const auto & hs = nodes->GetEnthalpys (iPoint);
2582+
2583+ /* --- Compute enthalpy transport to surface due to mass diffusion ---*/
2584+ su2double sumJhs = 0.0 ;
2585+ for (iSpecies = 0 ; iSpecies < nSpecies; iSpecies++)
2586+ sumJhs += Ds[iSpecies]*hs[iSpecies]*GeometryToolbox::DotProduct (nDim, Grad_PrimVar[RHOS_INDEX+iSpecies], UnitNormal);
2587+
2588+ su2double dTn = GeometryToolbox::DotProduct (nDim, Grad_PrimVar[T_INDEX], UnitNormal);
2589+ su2double dTven = GeometryToolbox::DotProduct (nDim, Grad_PrimVar[TVE_INDEX], UnitNormal);
2590+
2591+ /* --- Surface energy balance: trans-rot heat flux, vib-el heat flux,
2592+ enthalpy transport due to mass diffusion ---*/
2593+ HeatFlux[iMarker][iVertex] = thermal_conductivity_tr*dTn + thermal_conductivity_ve*dTven + sumJhs;
25942594 }
25952595
25962596 /* --- Note that y+, and heat are computed at the
0 commit comments