Skip to content

Commit 397c228

Browse files
committed
recover old sign convention and use helper function
1 parent 016df92 commit 397c228

File tree

4 files changed

+18
-28
lines changed

4 files changed

+18
-28
lines changed

Common/include/toolboxes/geometry_toolbox.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,14 @@ inline T Norm(Int nDim, const T* a) {
7979
return sqrt(SquaredNorm(nDim, a));
8080
}
8181

82+
/*! \brief dn = max(abs(n.(a-b)), 0.05 * ||a-b|| */
83+
template <class T, typename Int>
84+
inline T NormalDistance(Int nDim, const T* n, const T* a, const T* b) {
85+
T d[3] = {0};
86+
Distance(nDim, a, b, d);
87+
return fmax(fabs(DotProduct(nDim, n, d)), 0.05 * Norm(nDim, d));
88+
}
89+
8290
/*! \brief c = a x b */
8391
template <class T>
8492
inline void CrossProduct(const T* a, const T* b, T* c) {

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2520,9 +2520,9 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25202520

25212521
if (config->GetMarker_All_KindBC(iMarker) == BC_TYPE::HEAT_FLUX) {
25222522
if (py_custom) {
2523-
HeatFlux[iMarker][iVertex] = geometry->GetCustomBoundaryHeatFlux(iMarker, iVertex);
2523+
HeatFlux[iMarker][iVertex] = -geometry->GetCustomBoundaryHeatFlux(iMarker, iVertex);
25242524
} else {
2525-
HeatFlux[iMarker][iVertex] = config->GetWall_HeatFlux(Marker_Tag);
2525+
HeatFlux[iMarker][iVertex] = -config->GetWall_HeatFlux(Marker_Tag);
25262526
if (config->GetIntegrated_HeatFlux()) {
25272527
HeatFlux[iMarker][iVertex] /= geometry->GetSurfaceArea(config, iMarker);
25282528
}
@@ -2536,21 +2536,13 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25362536
}
25372537
iPointNormal = geometry->vertex[iMarker][iVertex]->GetNormal_Neighbor();
25382538
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-
2539+
const su2double dist_ij = GeometryToolbox::NormalDistance(nDim, UnitNormal, Coord, Coord_Normal);
25472540
const su2double There = nodes->GetTemperature(iPointNormal);
2548-
2549-
HeatFlux[iMarker][iVertex] = -thermal_conductivity * (There - Twall) / dist_ij * RefHeatFlux;
2541+
HeatFlux[iMarker][iVertex] = thermal_conductivity * (There - Twall) / dist_ij * RefHeatFlux;
25502542
} else {
2551-
su2double dTdn = -GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
2543+
su2double dTdn = GeometryToolbox::DotProduct(nDim, Grad_Temp, UnitNormal);
25522544
if (FlowRegime == ENUM_REGIME::INCOMPRESSIBLE && !energy) dTdn = 0.0;
2553-
HeatFlux[iMarker][iVertex] = -thermal_conductivity * dTdn * RefHeatFlux;
2545+
HeatFlux[iMarker][iVertex] = thermal_conductivity * dTdn * RefHeatFlux;
25542546
}
25552547
} else {
25562548

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -472,13 +472,9 @@ 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] = {0.0};
476-
GeometryToolbox::Distance(nDim, Coord_j, Coord_i, Edge_Vector);
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));
475+
su2double UnitNormal[MAXNDIM] = {0.0};
476+
for (auto iDim = 0u; iDim < nDim; ++iDim) UnitNormal[iDim] = Normal[iDim] / Area;
477+
const su2double dist_ij = GeometryToolbox::NormalDistance(nDim, UnitNormal, Coord_i, Coord_j);
482478

483479
/*--- Compute the normal gradient in temperature using Twall ---*/
484480

SU2_CFD/src/solvers/CNSSolver.cpp

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -672,13 +672,7 @@ 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);
677-
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));
675+
const su2double dist_ij = GeometryToolbox::NormalDistance(nDim, UnitNormal, Coord_i, Coord_j);
682676

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

0 commit comments

Comments
 (0)