Skip to content

Commit bef2a1e

Browse files
committed
measure the heat flux used in BCs instead of computing from the normal gradient
1 parent cde8892 commit bef2a1e

File tree

3 files changed

+57
-23
lines changed

3 files changed

+57
-23
lines changed

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2363,6 +2363,7 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23632363
const su2double Beta = config->GetAoS() * PI_NUMBER / 180.0;
23642364
const su2double RefLength = config->GetRefLength();
23652365
const su2double RefHeatFlux = config->GetHeat_Flux_Ref();
2366+
const su2double RefTemperature = config->GetTemperature_Ref();
23662367
const su2double Gas_Constant = config->GetGas_ConstantND();
23672368
auto Origin = config->GetRefOriginMoment(0);
23682369

@@ -2396,6 +2397,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23962397
Marker_Tag = config->GetMarker_All_TagBound(iMarker);
23972398
if (!config->GetViscous_Wall(iMarker)) continue;
23982399

2400+
const bool py_custom = config->GetMarker_All_PyCustom(iMarker);
2401+
23992402
/*--- Obtain the origin for the moment computation for a particular marker ---*/
24002403

24012404
const auto Monitoring = config->GetMarker_All_Monitoring(iMarker);
@@ -2506,26 +2509,55 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25062509

25072510
/*--- Compute total and maximum heat flux on the wall ---*/
25082511

2509-
su2double dTdn = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
2510-
2511-
if (!nemo){
2512-
2512+
if (!nemo) {
25132513
if (FlowRegime == ENUM_REGIME::COMPRESSIBLE) {
2514-
25152514
Cp = (Gamma / Gamma_Minus_One) * Gas_Constant;
25162515
thermal_conductivity = Cp * Viscosity / Prandtl_Lam;
25172516
}
25182517
if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE) {
2519-
if (!energy) dTdn = 0.0;
25202518
thermal_conductivity = nodes->GetThermalConductivity(iPoint);
25212519
}
2522-
HeatFlux[iMarker][iVertex] = -thermal_conductivity * dTdn * RefHeatFlux;
25232520

2521+
if (config->GetMarker_All_KindBC(iMarker) == BC_TYPE::HEAT_FLUX) {
2522+
if (py_custom) {
2523+
HeatFlux[iMarker][iVertex] = geometry->GetCustomBoundaryHeatFlux(iMarker, iVertex);
2524+
} else {
2525+
HeatFlux[iMarker][iVertex] = config->GetWall_HeatFlux(Marker_Tag);
2526+
if (config->GetIntegrated_HeatFlux()) {
2527+
HeatFlux[iMarker][iVertex] /= geometry->GetSurfaceArea(config, iMarker);
2528+
}
2529+
}
2530+
} else if (config->GetMarker_All_KindBC(iMarker) == BC_TYPE::ISOTHERMAL) {
2531+
su2double Twall = 0.0;
2532+
if (py_custom) {
2533+
Twall = geometry->GetCustomBoundaryTemperature(iMarker, iVertex) / RefTemperature;
2534+
} else {
2535+
Twall = config->GetIsothermal_Temperature(Marker_Tag) / RefTemperature;
2536+
}
2537+
iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();
2538+
Coord_Normal = geometry->nodes->GetCoord(iPointNormal);
2539+
su2double Vec_ij[MAXNDIM] = {0.0};
2540+
GeometryToolbox::Distance(nDim, Coord, Coord_Normal, Vec_ij);
2541+
2542+
/*--- Prevent divisions by 0 by limiting the normal projection. ---*/
2543+
const su2double dist_ij = fmax(
2544+
fabs(GeometryToolbox::DotProduct(int(MAXNDIM), Vec_ij, UnitNormal)),
2545+
fmax(0.05 * GeometryToolbox::Norm(int(MAXNDIM), Vec_ij), EPS));
2546+
2547+
const su2double There = nodes->GetTemperature(iPointNormal);
2548+
2549+
HeatFlux[iMarker][iVertex] = -thermal_conductivity * (There - Twall) / dist_ij * RefHeatFlux;
2550+
} else {
2551+
su2double dTdn = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
2552+
if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE && !energy) dTdn = 0.0;
2553+
HeatFlux[iMarker][iVertex] = -thermal_conductivity * dTdn * RefHeatFlux;
2554+
}
25242555
} else {
25252556

25262557
const auto& thermal_conductivity_tr = nodes->GetThermalConductivity(iPoint);
25272558
const auto& thermal_conductivity_ve = nodes->GetThermalConductivity_ve(iPoint);
25282559

2560+
const su2double dTdn = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
25292561
const su2double dTvedn = -GeometryToolbox::DotProduct(nDim, Grad_Temp_ve, UnitNormal);
25302562

25312563
/*--- Surface energy balance: trans-rot heat flux, vib-el heat flux ---*/

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -472,18 +472,21 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con
472472

473473
const auto Coord_i = geometry->nodes->GetCoord(iPoint);
474474
const auto Coord_j = geometry->nodes->GetCoord(Point_Normal);
475-
su2double Edge_Vector[MAXNDIM];
475+
su2double Edge_Vector[MAXNDIM] = {0.0};
476476
GeometryToolbox::Distance(nDim, Coord_j, Coord_i, Edge_Vector);
477-
su2double dist_ij_2 = GeometryToolbox::SquaredNorm(nDim, Edge_Vector);
478-
su2double dist_ij = sqrt(dist_ij_2);
477+
478+
/*--- Prevent divisions by 0 by limiting the normal projection. ---*/
479+
const su2double dist_ij = fmax(
480+
fabs(GeometryToolbox::DotProduct(int(MAXNDIM), Edge_Vector, Normal)) / Area,
481+
fmax(0.05 * GeometryToolbox::Norm(int(MAXNDIM), Edge_Vector), EPS));
479482

480483
/*--- Compute the normal gradient in temperature using Twall ---*/
481484

482-
su2double dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij;
485+
const su2double dTdn = -(nodes->GetTemperature(Point_Normal) - Twall)/dist_ij;
483486

484487
/*--- Get thermal conductivity ---*/
485488

486-
su2double thermal_conductivity = nodes->GetThermalConductivity(iPoint);
489+
const su2double thermal_conductivity = nodes->GetThermalConductivity(iPoint);
487490

488491
/*--- Apply a weak boundary condition for the energy equation.
489492
Compute the residual due to the prescribed heat flux. ---*/
@@ -493,10 +496,7 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con
493496
/*--- Jacobian contribution for temperature equation. ---*/
494497

495498
if (implicit) {
496-
su2double proj_vector_ij = 0.0;
497-
if (dist_ij_2 > 0.0)
498-
proj_vector_ij = GeometryToolbox::DotProduct(nDim, Edge_Vector, Normal) / dist_ij_2;
499-
Jacobian.AddVal2Diag(iPoint, nDim+1, thermal_conductivity*proj_vector_ij);
499+
Jacobian.AddVal2Diag(iPoint, nDim+1, thermal_conductivity * Area / dist_ij);
500500
}
501501
break;
502502
} // switch

SU2_CFD/src/solvers/CNSSolver.cpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,22 +672,25 @@ void CNSSolver::BC_Isothermal_Wall_Generic(CGeometry *geometry, CSolver **solver
672672

673673
const auto Coord_i = geometry->nodes->GetCoord(iPoint);
674674
const auto Coord_j = geometry->nodes->GetCoord(Point_Normal);
675+
su2double Vec_ij[MAXNDIM] = {0.0};
676+
GeometryToolbox::Distance(nDim, Coord_i, Coord_j, Vec_ij);
675677

676-
su2double dist_ij = GeometryToolbox::Distance(nDim, Coord_i, Coord_j);
678+
/*--- Prevent divisions by 0 by limiting the normal projection. ---*/
679+
const su2double dist_ij = fmax(
680+
fabs(GeometryToolbox::DotProduct(int(MAXNDIM), Vec_ij, UnitNormal)),
681+
fmax(0.05 * GeometryToolbox::Norm(int(MAXNDIM), Vec_ij), EPS));
677682

678683
/*--- Store the corrected velocity at the wall which will
679684
be zero (v = 0), unless there is grid motion (v = u_wall)---*/
680685

681686
if (dynamic_grid) {
682687
nodes->SetVelocity_Old(iPoint, geometry->nodes->GetGridVel(iPoint));
683-
}
684-
else {
688+
} else {
685689
su2double zero[MAXNDIM] = {0.0};
686690
nodes->SetVelocity_Old(iPoint, zero);
687691
}
688692

689-
for (auto iDim = 0u; iDim < nDim; iDim++)
690-
LinSysRes(iPoint, iDim+1) = 0.0;
693+
for (auto iDim = 0u; iDim < nDim; iDim++) LinSysRes(iPoint, iDim+1) = 0.0;
691694
nodes->SetVel_ResTruncError_Zero(iPoint);
692695

693696
/*--- Get transport coefficients ---*/
@@ -708,8 +711,7 @@ void CNSSolver::BC_Isothermal_Wall_Generic(CGeometry *geometry, CSolver **solver
708711
if (cht_mode) {
709712
Twall = GetCHTWallTemperature(config, val_marker, iVertex, dist_ij,
710713
thermal_conductivity, There, Temperature_Ref);
711-
}
712-
else if (config->GetMarker_All_PyCustom(val_marker)) {
714+
} else if (config->GetMarker_All_PyCustom(val_marker)) {
713715
Twall = geometry->GetCustomBoundaryTemperature(val_marker, iVertex) / Temperature_Ref;
714716
}
715717

0 commit comments

Comments
 (0)