Skip to content

Commit 93f78c4

Browse files
authored
Merge pull request #1360 from bigfooted/fix_wallfunctions
Cleanup wall functions and add user controls
2 parents d8cfe78 + d492fb4 commit 93f78c4

34 files changed

Lines changed: 825 additions & 266 deletions

Common/include/CConfig.hpp

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -821,10 +821,13 @@ class CConfig {
821821
Pressure_Thermodynamic, /*!< \brief Thermodynamic pressure of the fluid. */
822822
Temperature_FreeStream, /*!< \brief Total temperature of the fluid. */
823823
Temperature_ve_FreeStream; /*!< \brief Total vibrational-electronic temperature of the fluid. */
824-
su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */
825-
Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */
826-
wallModelKappa, /*!< \brief von Karman constant kappa for turbulence wall modeling */
827-
wallModelB, /*!< \brief constant B for turbulence wall modeling */
824+
unsigned short wallModel_MaxIter; /*!< \brief maximum number of iterations for the Newton method for the wall model */
825+
su2double wallModel_Kappa, /*!< \brief von Karman constant kappa for turbulence wall modeling */
826+
wallModel_B, /*!< \brief constant B for turbulence wall modeling */
827+
wallModel_RelFac, /*!< \brief relaxation factor for the Newton method used in the wall model */
828+
wallModel_MinYplus; /*!< \brief minimum Y+ value, below which the wall model is not used anymore */
829+
su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number for the gas. */
830+
Prandtl_Turb, /*!< \brief Turbulent Prandtl number for the gas. */
828831
Length_Ref, /*!< \brief Reference length for non-dimensionalization. */
829832
Pressure_Ref, /*!< \brief Reference pressure for non-dimensionalization. */
830833
Temperature_Ref, /*!< \brief Reference temperature for non-dimensionalization.*/
@@ -833,7 +836,7 @@ class CConfig {
833836
Velocity_Ref, /*!< \brief Reference velocity for non-dimensionalization.*/
834837
Time_Ref, /*!< \brief Reference time for non-dimensionalization. */
835838
Viscosity_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */
836-
Conductivity_Ref, /*!< \brief Reference conductivity for non-dimensionalization. */
839+
Thermal_Conductivity_Ref, /*!< \brief Reference conductivity for non-dimensionalization. */
837840
Energy_Ref, /*!< \brief Reference viscosity for non-dimensionalization. */
838841
Wall_Temperature, /*!< \brief Temperature at an isotropic wall in Kelvin. */
839842
Omega_Ref, /*!< \brief Reference angular velocity for non-dimensionalization. */
@@ -1671,13 +1674,31 @@ class CConfig {
16711674
* \brief Get the value of the von Karman constant kappa for turbulence wall modeling.
16721675
* \return von Karman constant.
16731676
*/
1674-
su2double GetwallModelKappa(void) const { return wallModelKappa; }
1677+
su2double GetwallModel_Kappa() const { return wallModel_Kappa; }
16751678

16761679
/*!
1677-
* \brief Get the value of the von Karman constant kappa for turbulence wall modeling.
1678-
* \return von Karman constant.
1680+
* \brief Get the value of the max. number of Newton iterations for turbulence wall modeling.
1681+
* \return Max number of iterations.
1682+
*/
1683+
unsigned short GetwallModel_MaxIter() const { return wallModel_MaxIter; }
1684+
1685+
/*!
1686+
* \brief Get the value of the relaxation factor for turbulence wall modeling.
1687+
* \return Relaxation factor.
1688+
*/
1689+
su2double GetwallModel_RelFac() const { return wallModel_RelFac; }
1690+
1691+
/*!
1692+
* \brief Get the value of the minimum Y+ value below which the wall function is deactivated.
1693+
* \return Minimum Y+ value.
1694+
*/
1695+
su2double GetwallModel_MinYPlus() const { return wallModel_MinYplus; }
1696+
1697+
/*!
1698+
* \brief Get the value of the wall model constant B for turbulence wall modeling.
1699+
* \return Wall model constant B.
16791700
*/
1680-
su2double GetwallModelB(void) const { return wallModelB; }
1701+
su2double GetwallModel_B() const { return wallModel_B; }
16811702

16821703
/*!
16831704
* \brief Get the value of the thermal diffusivity for solids.
@@ -1753,10 +1774,10 @@ class CConfig {
17531774
su2double GetFan_Poly_Eff(void) const { return Fan_Poly_Eff; }
17541775

17551776
/*!
1756-
* \brief Get the value of the reference conductivity for non-dimensionalization.
1757-
* \return Reference conductivity for non-dimensionalization.
1777+
* \brief Get the value of the reference thermal conductivity for non-dimensionalization.
1778+
* \return Reference thermal conductivity for non-dimensionalization.
17581779
*/
1759-
su2double GetConductivity_Ref(void) const { return Conductivity_Ref; }
1780+
su2double GetThermal_Conductivity_Ref(void) const { return Thermal_Conductivity_Ref; }
17601781

17611782
/*!
17621783
* \brief Get the value of the reference angular velocity for non-dimensionalization.
@@ -2376,7 +2397,7 @@ class CConfig {
23762397
* \brief Set the reference conductivity for nondimensionalization.
23772398
* \param[in] val_conductivity_ref - Value of the reference conductivity.
23782399
*/
2379-
void SetConductivity_Ref(su2double val_conductivity_ref) { Conductivity_Ref = val_conductivity_ref; }
2400+
void SetConductivity_Ref(su2double val_conductivity_ref) { Thermal_Conductivity_Ref = val_conductivity_ref; }
23802401

23812402
/*!
23822403
* \brief Set the nondimensionalized freestream pressure.

Common/src/CConfig.cpp

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,10 +1223,20 @@ void CConfig::SetConfig_Options() {
12231223
addDoubleOption("PRANDTL_LAM", Prandtl_Lam, 0.72);
12241224
/*!\brief PRANDTL_TURB \n DESCRIPTION: Turbulent Prandtl number (0.9 (air), only for compressible flows) \n DEFAULT 0.90 \ingroup Config*/
12251225
addDoubleOption("PRANDTL_TURB", Prandtl_Turb, 0.90);
1226-
/*!\brief WALLMODELKAPPA \n DESCRIPTION: von Karman constant used for the wall model \n DEFAULT 0.41 \ingroup Config*/
1227-
addDoubleOption("WALLMODELKAPPA", wallModelKappa, 0.41);
1228-
/*!\brief WALLMODELB \n DESCRIPTION: constant B used for the wall model \n DEFAULT 5.0 \ingroup Config*/
1229-
addDoubleOption("WALLMODELB", wallModelB, 5.5);
1226+
1227+
/*--- Options related to wall models. ---*/
1228+
1229+
/*!\brief WALLMODEL_KAPPA \n DESCRIPTION: von Karman constant used for the wall model \n DEFAULT 0.41 \ingroup Config*/
1230+
addDoubleOption("WALLMODEL_KAPPA", wallModel_Kappa, 0.41);
1231+
/*!\brief WALLMODEL_MAXITER \n DESCRIPTION: Max iterations used for the wall model \n DEFAULT 200 \ingroup Config*/
1232+
addUnsignedShortOption("WALLMODEL_MAXITER", wallModel_MaxIter, 200);
1233+
/*!\brief WALLMODEL_RELFAC \n DESCRIPTION: Relaxation factor used for the wall model \n DEFAULT 0.5 \ingroup Config*/
1234+
addDoubleOption("WALLMODEL_RELFAC", wallModel_RelFac, 0.5);
1235+
/*!\brief WALLMODEL_MINYPLUS \n DESCRIPTION: lower limit for Y+ used for the wall model \n DEFAULT 5.0 \ingroup Config*/
1236+
addDoubleOption("WALLMODEL_MINYPLUS", wallModel_MinYplus, 5.0);
1237+
/*!\brief WALLMODEL_B \n DESCRIPTION: constant B used for the wall model \n DEFAULT 5.5 \ingroup Config*/
1238+
addDoubleOption("WALLMODEL_B", wallModel_B, 5.5);
1239+
12301240
/*!\brief BULK_MODULUS \n DESCRIPTION: Value of the Bulk Modulus \n DEFAULT 1.42E5 \ingroup Config*/
12311241
addDoubleOption("BULK_MODULUS", Bulk_Modulus, 1.42E5);
12321242
/* DESCRIPTION: Epsilon^2 multipier in Beta calculation for incompressible preconditioner. */
@@ -3295,11 +3305,18 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
32953305
if (Kind_WallFunctions[iMarker] != WALL_FUNCTIONS::NONE)
32963306
Wall_Functions = true;
32973307

3298-
if ((Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::ADAPTIVE_FUNCTION) || (Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::SCALABLE_FUNCTION)
3299-
|| (Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL))
3300-
3308+
if ((Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::ADAPTIVE_FUNCTION) ||
3309+
(Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::SCALABLE_FUNCTION) ||
3310+
(Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::NONEQUILIBRIUM_MODEL))
33013311
SU2_MPI::Error(string("For RANS problems, use NONE, STANDARD_WALL_FUNCTION or EQUILIBRIUM_WALL_MODEL.\n"), CURRENT_FUNCTION);
33023312

3313+
if (Kind_WallFunctions[iMarker] == WALL_FUNCTIONS::STANDARD_FUNCTION) {
3314+
if (!((Kind_Solver == RANS) || (Kind_Solver == INC_RANS)))
3315+
SU2_MPI::Error(string("Wall model STANDARD_FUNCTION only available for RANS or INC_RANS.\n"), CURRENT_FUNCTION);
3316+
if (nRough_Wall != 0)
3317+
SU2_MPI::Error(string("Wall model STANDARD_FUNCTION and WALL_ROUGHNESS migh not be compatible. Checking required!\n"), CURRENT_FUNCTION);
3318+
}
3319+
33033320
}
33043321
}
33053322

Common/src/wall_model.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ CWallModel::CWallModel(CConfig *config) {
4141
Pr_lam = config->GetPrandtl_Lam();
4242
Pr_turb = config->GetPrandtl_Turb();
4343

44-
karman = config->GetwallModelKappa(); // von Karman constant -> k = 0.41; or 0.38;
44+
karman = config->GetwallModel_Kappa(); // von Karman constant -> k = 0.41; or 0.38;
4545
}
4646

4747
void CWallModel::WallShearStressAndHeatFlux(const su2double rhoExchange,

SU2_CFD/include/numerics/CNumerics.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1554,7 +1554,7 @@ class CNumerics {
15541554
* \param[in] val_tauwall_i - Tauwall at point i
15551555
* \param[in] val_tauwall_j - Tauwall at point j
15561556
*/
1557-
inline virtual void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) { }
1557+
inline virtual void SetTau_Wall(su2double val_tauwall_i, su2double val_tauwall_j) { }
15581558

15591559
/*!
15601560
* \brief - Calculate the central/upwind blending function for a face

SU2_CFD/include/numerics/flow/flow_diffusion.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class CAvgGrad_Base : public CNumerics {
186186
* \param[in] val_tauwall_i - Value of the wall shear stress at point i.
187187
* \param[in] val_tauwall_j - Value of the wall shear stress at point j.
188188
*/
189-
inline void SetTauWall(su2double val_tauwall_i, su2double val_tauwall_j) override {
189+
inline void SetTau_Wall(su2double val_tauwall_i, su2double val_tauwall_j) override {
190190
TauWall_i = val_tauwall_i;
191191
TauWall_j = val_tauwall_j;
192192
}

SU2_CFD/include/numerics_simd/flow/diffusion/common.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ FORCEINLINE void addQCR(const MatrixType& grad, MatrixDbl<nDim>& tau) {
151151

152152
/*!
153153
* \brief Scale the stress tensor according to the target (from a
154-
* wall function) magnitute in the tangential direction.
154+
* wall function) magnitude in the tangential direction.
155155
*/
156156
template<class Container, size_t nDim>
157157
FORCEINLINE void addTauWall(Int iPoint, Int jPoint,

SU2_CFD/include/numerics_simd/flow/diffusion/viscous_fluxes.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ class CCompressibleViscousFluxBase : public CNumericsSIMD {
159159
addPerturbedRSM(avgV, avgGrad, turb_ke, tau,
160160
uq_eigval_comp, uq_permute, uq_delta_b, uq_urlx);
161161
}
162-
if(wallFun) addTauWall(iPoint, jPoint, solution.GetTauWall(), unitNormal, tau);
162+
163+
if(wallFun) addTauWall(iPoint, jPoint, solution.GetTau_Wall(), unitNormal, tau);
163164

164165
Double cond = derived->thermalConductivity(avgV);
165166
VectorDbl<nDim> heatFlux;

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ void CFVMFlowSolverBase<V, R>::Viscous_Residual_impl(unsigned long iEdge, CGeome
443443

444444
/*--- Wall shear stress values (wall functions) ---*/
445445

446-
numerics->SetTauWall(nodes->GetTauWall(iPoint),
447-
nodes->GetTauWall(jPoint));
446+
numerics->SetTau_Wall(nodes->GetTau_Wall(iPoint),
447+
nodes->GetTau_Wall(jPoint));
448448

449449
/*--- Compute and update residual ---*/
450450

@@ -2393,10 +2393,11 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
23932393
unsigned long iVertex, iPoint, iPointNormal;
23942394
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
23952395
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0;
2396-
su2double Viscosity = 0.0, WallDist[3] = {0.0}, Area, Density = 0.0, GradTemperature = 0.0,
2397-
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, TauTangent[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
2396+
su2double Viscosity = 0.0, Area, Density = 0.0, GradTemperature = 0.0, WallDistMod, FrictionVel,
2397+
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
23982398
thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, AxiFactor;
23992399
const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr;
2400+
const su2double minYPlus = config->GetwallModel_MinYPlus();
24002401

24012402
string Marker_Tag, Monitoring_Tag;
24022403

@@ -2526,30 +2527,37 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
25262527
/*--- Compute wall shear stress (using the stress tensor). Compute wall skin friction coefficient, and heat flux
25272528
* on the wall ---*/
25282529

2529-
su2double TauNormal = GeometryToolbox::DotProduct(nDim, TauElem, UnitNormal);
2530+
su2double TauTangent[MAXNDIM] = {0.0};
2531+
GeometryToolbox::TangentProjection(nDim, Tau, UnitNormal, TauTangent);
25302532

2531-
for (iDim = 0; iDim < nDim; iDim++) {
2532-
TauTangent[iDim] = TauElem[iDim] - TauNormal * UnitNormal[iDim];
2533-
/* --- in case of wall functions, we have computed the skin friction in the turbulence solver --- */
2534-
/* --- Note that in the wall model, we switch off the computation when the computed y+ < 5 --- */
2535-
/* --- We put YPlus to 1.0 so we have to compute skinfriction and the actual y+ in that case as well --- */
2536-
if (!wallfunctions || (wallfunctions && YPlus[iMarker][iVertex] < 5.0))
2537-
CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric;
2533+
WallShearStress[iMarker][iVertex] = GeometryToolbox::Norm(int(MAXNDIM), TauTangent);
2534+
2535+
/*--- For wall functions, the wall stresses need to be scaled by the wallfunction stress Tau_Wall---*/
2536+
su2double Tau_Wall, scale;
2537+
if (wallfunctions && (YPlus[iMarker][iVertex] > minYPlus)){
2538+
Tau_Wall = nodes->GetTau_Wall(iPoint);
2539+
scale = Tau_Wall / WallShearStress[iMarker][iVertex];
2540+
for (iDim = 0; iDim < nDim; iDim++) {
2541+
TauTangent[iDim] *= scale;
2542+
TauElem[iDim] *= scale;
2543+
}
2544+
2545+
WallShearStress[iMarker][iVertex] = Tau_Wall;
25382546
}
2539-
WallShearStress[iMarker][iVertex] = GeometryToolbox::Norm(nDim, TauTangent);
25402547

2541-
for (iDim = 0; iDim < nDim; iDim++) WallDist[iDim] = (Coord[iDim] - Coord_Normal[iDim]);
2542-
2543-
su2double WallDistMod = GeometryToolbox::Norm(nDim, WallDist);
2548+
for (iDim = 0; iDim < nDim; iDim++) {
2549+
CSkinFriction[iMarker](iVertex,iDim) = TauTangent[iDim] * factorFric;
2550+
}
25442551

2545-
/*--- Compute y+ and non-dimensional velocity ---*/
2552+
WallDistMod = GeometryToolbox::Distance(nDim, Coord, Coord_Normal);
25462553

2547-
su2double FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density);
2554+
/*--- Compute non-dimensional velocity and y+ ---*/
25482555

2549-
/* --- in case of wall functions, we have computed YPlus in the turbulence class --- */
2550-
/* --- Note that we do not recompute y+ when y+<5 because y+ can become > 5 again --- */
2551-
if (!wallfunctions)
2556+
FrictionVel = sqrt(fabs(WallShearStress[iMarker][iVertex]) / Density);
2557+
2558+
if (!wallfunctions) {
25522559
YPlus[iMarker][iVertex] = WallDistMod * FrictionVel / (Viscosity / Density);
2560+
}
25532561

25542562
/*--- Compute total and maximum heat flux on the wall ---*/
25552563

SU2_CFD/include/solvers/CIncNSSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ class CIncNSSolver final : public CIncEulerSolver {
7171
* \param[in] solver_container - Container vector with all the solutions.
7272
* \param[in] config - Definition of the particular problem.
7373
*/
74-
void SetTauWall_WF(CGeometry *geometry,
74+
void SetTau_Wall_WF(CGeometry *geometry,
7575
CSolver** solver_container,
7676
const CConfig* config);
7777

SU2_CFD/include/solvers/CNEMONSSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class CNEMONSSolver final : public CNEMOEulerSolver {
7070
* \param[in] solver_container - Container vector with all the solutions.
7171
* \param[in] config - Definition of the particular problem.
7272
*/
73-
void SetTauWall_WF(CGeometry *geometry, CSolver** solver_container, const CConfig* config);
73+
void SetTau_Wall_WF(CGeometry *geometry, CSolver** solver_container, const CConfig* config);
7474

7575
public:
7676

0 commit comments

Comments
 (0)