Skip to content

Commit 5bad047

Browse files
committed
fix #1175
1 parent ce04458 commit 5bad047

7 files changed

Lines changed: 33 additions & 130 deletions

File tree

SU2_CFD/include/solvers/CFEM_DG_EulerSolver.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ class CFEM_DG_EulerSolver : public CSolver {
9292
AllBound_CEff_Inv; /*!< \brief Total efficiency (Cl/Cd) (inviscid contribution) for all the boundaries. */
9393

9494
su2double
95+
AeroCoeffForceRef, /*!< \brief Reference force for coefficients */
9596
Total_CL, /*!< \brief Total lift coefficient for all the boundaries. */
9697
Total_CD, /*!< \brief Total drag coefficient for all the boundaries. */
9798
Total_CSF, /*!< \brief Total sideforce coefficient for all the boundaries. */
@@ -1127,6 +1128,11 @@ class CFEM_DG_EulerSolver : public CSolver {
11271128
*/
11281129
inline void SetTotal_CL(su2double val_Total_CL) final { Total_CL = val_Total_CL; }
11291130

1131+
/*!
1132+
* \brief Get the reference force used to compute CL, CD, etc.
1133+
*/
1134+
inline su2double GetAeroCoeffsReferenceForce() const final { return AeroCoeffForceRef; }
1135+
11301136
/*!
11311137
* \brief Provide the total (inviscid + viscous) non dimensional lift coefficient.
11321138
* \return Value of the lift coefficient (inviscid + viscous contribution).

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,8 @@ class CFVMFlowSolverBase : public CSolver {
125125
AeroCoeffsArray SurfaceCoeff; /*!< \brief Totals for each monitoring surface. */
126126
AeroCoeffs TotalCoeff; /*!< \brief Totals for all boundaries. */
127127

128+
su2double AeroCoeffForceRef = 1.0; /*!< \brief Reference force for aerodynamic coefficients. */
129+
128130
su2double InverseDesign = 0.0; /*!< \brief Inverse design functional for each boundary. */
129131
su2double Total_ComboObj = 0.0; /*!< \brief Total 'combo' objective for all monitored boundaries */
130132
su2double Total_Custom_ObjFunc = 0.0; /*!< \brief Total custom objective function for all the boundaries. */
@@ -1559,6 +1561,11 @@ class CFVMFlowSolverBase : public CSolver {
15591561
*/
15601562
inline su2double GetTotal_CEff() const final { return TotalCoeff.CEff; }
15611563

1564+
/*!
1565+
* \brief Get the reference force used to compute CL, CD, etc.
1566+
*/
1567+
inline su2double GetAeroCoeffsReferenceForce() const final { return AeroCoeffForceRef; }
1568+
15621569
/*!
15631570
* \brief Provide the total (inviscid + viscous) non dimensional lift coefficient.
15641571
* \return Value of the lift coefficient (inviscid + viscous contribution).

SU2_CFD/include/solvers/CFVMFlowSolverBase.inl

Lines changed: 7 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,7 +1632,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Pressure_Forces(const CGeometry* geometr
16321632
}
16331633
}
16341634

1635-
factor = 1.0 / (0.5 * RefDensity * RefArea * RefVel2);
1635+
AeroCoeffForceRef = 0.5 * RefDensity * RefArea * RefVel2;
1636+
factor = 1.0 / AeroCoeffForceRef;
16361637

16371638
/*--- Reference pressure is always the far-field value. ---*/
16381639

@@ -1938,57 +1939,18 @@ template <class V, ENUM_REGIME FlowRegime>
19381939
void CFVMFlowSolverBase<V, FlowRegime>::Momentum_Forces(const CGeometry* geometry, const CConfig* config) {
19391940
unsigned long iVertex, iPoint;
19401941
unsigned short iDim, iMarker, Boundary, Monitoring, iMarker_Monitoring;
1941-
su2double factor, RefVel2 = 0.0, RefTemp, RefDensity = 0.0, Mach2Vel, Mach_Motion, MassFlow, Density;
1942+
su2double MassFlow, Density;
19421943
const su2double *Normal = nullptr, *Coord = nullptr;
19431944
string Marker_Tag, Monitoring_Tag;
19441945
su2double AxiFactor;
19451946

19461947
su2double Alpha = config->GetAoA() * PI_NUMBER / 180.0;
19471948
su2double Beta = config->GetAoS() * PI_NUMBER / 180.0;
1948-
su2double RefArea = config->GetRefArea();
19491949
su2double RefLength = config->GetRefLength();
1950-
su2double Gas_Constant = config->GetGas_ConstantND();
19511950
auto Origin = config->GetRefOriginMoment(0);
19521951
bool axisymmetric = config->GetAxisymmetric();
19531952

1954-
/// TODO: Move these ifs to specialized functions.
1955-
1956-
if (FlowRegime == COMPRESSIBLE) {
1957-
/*--- Evaluate reference values for non-dimensionalization.
1958-
For dynamic meshes, use the motion Mach number as a reference value
1959-
for computing the force coefficients. Otherwise, use the freestream values,
1960-
which is the standard convention. ---*/
1961-
1962-
RefTemp = Temperature_Inf;
1963-
RefDensity = Density_Inf;
1964-
if (dynamic_grid) {
1965-
Mach2Vel = sqrt(Gamma * Gas_Constant * RefTemp);
1966-
Mach_Motion = config->GetMach_Motion();
1967-
RefVel2 = (Mach_Motion * Mach2Vel) * (Mach_Motion * Mach2Vel);
1968-
} else {
1969-
RefVel2 = 0.0;
1970-
for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim];
1971-
}
1972-
}
1973-
1974-
if (FlowRegime == INCOMPRESSIBLE) {
1975-
/*--- Evaluate reference values for non-dimensionalization.
1976-
For dimensional or non-dim based on initial values, use
1977-
the far-field state (inf). For a custom non-dim based
1978-
on user-provided reference values, use the ref values
1979-
to compute the forces. ---*/
1980-
1981-
if ((config->GetRef_Inc_NonDim() == DIMENSIONAL) || (config->GetRef_Inc_NonDim() == INITIAL_VALUES)) {
1982-
RefDensity = Density_Inf;
1983-
RefVel2 = 0.0;
1984-
for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim];
1985-
} else if (config->GetRef_Inc_NonDim() == REFERENCE_VALUES) {
1986-
RefDensity = config->GetInc_Density_Ref();
1987-
RefVel2 = config->GetInc_Velocity_Ref() * config->GetInc_Velocity_Ref();
1988-
}
1989-
}
1990-
1991-
factor = 1.0 / (0.5 * RefDensity * RefArea * RefVel2);
1953+
const su2double factor = 1.0 / AeroCoeffForceRef;
19921954

19931955
/*-- Variables initialization ---*/
19941956

@@ -2263,8 +2225,8 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
22632225
unsigned long iVertex, iPoint, iPointNormal;
22642226
unsigned short iMarker, iMarker_Monitoring, iDim, jDim;
22652227
unsigned short T_INDEX = 0, TVE_INDEX = 0, VEL_INDEX = 0;
2266-
su2double Viscosity = 0.0, WallDist[3] = {0.0}, Area, TauNormal, RefTemp, RefVel2 = 0.0, dTn, dTven,
2267-
RefDensity = 0.0, GradTemperature, Density = 0.0, WallDistMod, FrictionVel, Mach2Vel, Mach_Motion,
2228+
su2double Viscosity = 0.0, WallDist[3] = {0.0}, Area, TauNormal, RefVel2 = 0.0, dTn, dTven,
2229+
RefDensity = 0.0, GradTemperature, Density = 0.0, WallDistMod, FrictionVel,
22682230
UnitNormal[3] = {0.0}, TauElem[3] = {0.0}, TauTangent[3] = {0.0}, Tau[3][3] = {{0.0}}, Cp,
22692231
thermal_conductivity, MaxNorm = 8.0, Grad_Vel[3][3] = {{0.0}}, Grad_Temp[3] = {0.0}, AxiFactor;
22702232
const su2double *Coord = nullptr, *Coord_Normal = nullptr, *Normal = nullptr;
@@ -2273,7 +2235,6 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
22732235

22742236
su2double Alpha = config->GetAoA() * PI_NUMBER / 180.0;
22752237
su2double Beta = config->GetAoS() * PI_NUMBER / 180.0;
2276-
su2double RefArea = config->GetRefArea();
22772238
su2double RefLength = config->GetRefLength();
22782239
su2double RefHeatFlux = config->GetHeat_Flux_Ref();
22792240
su2double Gas_Constant = config->GetGas_ConstantND();
@@ -2294,44 +2255,7 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
22942255
VEL_INDEX = nSpecies+2;
22952256
}
22962257

2297-
/// TODO: Move these ifs to specialized functions.
2298-
2299-
if (FlowRegime == COMPRESSIBLE) {
2300-
/*--- Evaluate reference values for non-dimensionalization.
2301-
For dynamic meshes, use the motion Mach number as a reference value
2302-
for computing the force coefficients. Otherwise, use the freestream values,
2303-
which is the standard convention. ---*/
2304-
2305-
RefTemp = Temperature_Inf;
2306-
RefDensity = Density_Inf;
2307-
if (dynamic_grid) {
2308-
Mach2Vel = sqrt(Gamma * Gas_Constant * RefTemp);
2309-
Mach_Motion = config->GetMach_Motion();
2310-
RefVel2 = (Mach_Motion * Mach2Vel) * (Mach_Motion * Mach2Vel);
2311-
} else {
2312-
RefVel2 = 0.0;
2313-
for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim];
2314-
}
2315-
}
2316-
2317-
if (FlowRegime == INCOMPRESSIBLE) {
2318-
/*--- Evaluate reference values for non-dimensionalization.
2319-
For dimensional or non-dim based on initial values, use
2320-
the far-field state (inf). For a custom non-dim based
2321-
on user-provided reference values, use the ref values
2322-
to compute the forces. ---*/
2323-
2324-
if ((config->GetRef_Inc_NonDim() == DIMENSIONAL) || (config->GetRef_Inc_NonDim() == INITIAL_VALUES)) {
2325-
RefDensity = Density_Inf;
2326-
RefVel2 = 0.0;
2327-
for (iDim = 0; iDim < nDim; iDim++) RefVel2 += Velocity_Inf[iDim] * Velocity_Inf[iDim];
2328-
} else if (config->GetRef_Inc_NonDim() == REFERENCE_VALUES) {
2329-
RefDensity = config->GetInc_Density_Ref();
2330-
RefVel2 = config->GetInc_Velocity_Ref() * config->GetInc_Velocity_Ref();
2331-
}
2332-
}
2333-
2334-
const su2double factor = 1.0 / (0.5 * RefDensity * RefArea * RefVel2);
2258+
const su2double factor = 1.0 / AeroCoeffForceRef;
23352259

23362260
/*--- Variables initialization ---*/
23372261

@@ -2452,8 +2376,6 @@ void CFVMFlowSolverBase<V, FlowRegime>::Friction_Forces(const CGeometry* geometr
24522376

24532377
/*--- Compute total and maximum heat flux on the wall ---*/
24542378

2455-
2456-
24572379
/// TODO: Move these ifs to specialized functions.
24582380
if (!nemo){
24592381

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2516,6 +2516,11 @@ class CSolver {
25162516
*/
25172517
inline virtual void SetTotal_CNearFieldOF(su2double val_cnearfieldpress) { }
25182518

2519+
/*!
2520+
* \brief Get the reference force used to compute CL, CD, etc.
2521+
*/
2522+
inline virtual su2double GetAeroCoeffsReferenceForce() const { return 0; }
2523+
25192524
/*!
25202525
* \brief A virtual member.
25212526
* \return Value of the lift coefficient (inviscid + viscous contribution).

SU2_CFD/src/output/CFlowOutput.cpp

Lines changed: 3 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1022,7 +1022,7 @@ void CFlowOutput::WriteMetaData(CConfig *config){
10221022

10231023
void CFlowOutput::WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSolver **solver_container){
10241024

1025-
unsigned short iDim, iMarker_Monitoring;
1025+
unsigned short iMarker_Monitoring;
10261026

10271027
const bool compressible = (config->GetKind_Regime() == COMPRESSIBLE);
10281028
const bool incompressible = (config->GetKind_Regime() == INCOMPRESSIBLE);
@@ -2144,26 +2144,8 @@ void CFlowOutput::WriteForcesBreakdown(CConfig *config, CGeometry *geometry, CSo
21442144

21452145
/*--- Reference area and force factors. ---*/
21462146

2147-
su2double RefDensity, RefArea, RefVel, Factor, Ref;
2148-
RefArea = config->GetRefArea();
2149-
if (compressible) {
2150-
RefDensity = solver_container[FLOW_SOL]->GetDensity_Inf();
2151-
RefVel = solver_container[FLOW_SOL]->GetModVelocity_Inf();
2152-
} else {
2153-
if ((config->GetRef_Inc_NonDim() == DIMENSIONAL) ||
2154-
(config->GetRef_Inc_NonDim() == INITIAL_VALUES)) {
2155-
RefDensity = solver_container[FLOW_SOL]->GetDensity_Inf();
2156-
RefVel = 0.0;
2157-
for (iDim = 0; iDim < nDim; iDim++)
2158-
RefVel += solver_container[FLOW_SOL]->GetVelocity_Inf(iDim)*solver_container[FLOW_SOL]->GetVelocity_Inf(iDim);
2159-
RefVel = sqrt(RefVel);
2160-
} else {
2161-
RefDensity = config->GetInc_Density_Ref();
2162-
RefVel = config->GetInc_Velocity_Ref();
2163-
}
2164-
}
2165-
Factor = (0.5*RefDensity*RefArea*RefVel*RefVel);
2166-
Ref = config->GetDensity_Ref() * config->GetVelocity_Ref() * config->GetVelocity_Ref() * 1.0 * 1.0;
2147+
const su2double Factor = solver_container[FLOW_SOL]->GetAeroCoeffsReferenceForce();
2148+
const su2double Ref = config->GetDensity_Ref() * pow(config->GetVelocity_Ref(),2);
21672149

21682150
Breakdown_file << "NOTE: Multiply forces by the non-dimensional factor: " << Factor << ", and the reference factor: " << Ref << "\n";
21692151
Breakdown_file << "to obtain the dimensional force." << "\n" << "\n";

SU2_CFD/src/solvers/CFEM_DG_EulerSolver.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6752,7 +6752,8 @@ void CFEM_DG_EulerSolver::Pressure_Forces(const CGeometry* geometry, const CConf
67526752
RefVel2 += Velocity_Inf[iDim]*Velocity_Inf[iDim];
67536753
}
67546754

6755-
const su2double factor = 1.0/(0.5*RefDensity*RefArea*RefVel2);
6755+
AeroCoeffForceRef = 0.5 * RefDensity * RefArea * RefVel2;
6756+
const su2double factor = 1.0 / AeroCoeffForceRef;
67566757

67576758
/*-- Variables initialization ---*/
67586759
Total_CD = 0.0; Total_CL = 0.0; Total_CSF = 0.0; Total_CEff = 0.0;

SU2_CFD/src/solvers/CFEM_DG_NSSolver.cpp

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -209,33 +209,13 @@ void CFEM_DG_NSSolver::Friction_Forces(const CGeometry* geometry, const CConfig*
209209
/*--- Get the information of the angle of attack, reference area, etc. ---*/
210210
const su2double Alpha = config->GetAoA()*PI_NUMBER/180.0;
211211
const su2double Beta = config->GetAoS()*PI_NUMBER/180.0;
212-
const su2double RefArea = config->GetRefArea();
213212
const su2double RefLength = config->GetRefLength();
214-
const su2double Gas_Constant = config->GetGas_ConstantND();
215213
auto Origin = config->GetRefOriginMoment(0);
216-
const bool grid_movement = config->GetGrid_Movement();
217-
218-
/*--- Evaluate reference values for non-dimensionalization.
219-
For dynamic meshes, use the motion Mach number as a reference value
220-
for computing the force coefficients. Otherwise, use the freestream
221-
values, which is the standard convention. ---*/
222-
const su2double RefTemp = Temperature_Inf;
223-
const su2double RefDensity = Density_Inf;
224-
const su2double RefHeatFlux = config->GetHeat_Flux_Ref();
225214

226-
su2double RefVel2;
227-
if (grid_movement) {
228-
const su2double Mach2Vel = sqrt(Gamma*Gas_Constant*RefTemp);
229-
const su2double Mach_Motion = config->GetMach_Motion();
230-
RefVel2 = (Mach_Motion*Mach2Vel)*(Mach_Motion*Mach2Vel);
231-
}
232-
else {
233-
RefVel2 = 0.0;
234-
for(unsigned short iDim=0; iDim<nDim; ++iDim)
235-
RefVel2 += Velocity_Inf[iDim]*Velocity_Inf[iDim];
236-
}
215+
/*--- Evaluate reference values for non-dimensionalization. ---*/
216+
const su2double RefHeatFlux = config->GetHeat_Flux_Ref();
237217

238-
const su2double factor = 1.0/(0.5*RefDensity*RefArea*RefVel2);
218+
const su2double factor = 1.0 / AeroCoeffForceRef;
239219

240220
/*--- Variables initialization ---*/
241221
AllBound_CD_Visc = 0.0; AllBound_CL_Visc = 0.0; AllBound_CSF_Visc = 0.0;

0 commit comments

Comments
 (0)