Skip to content

Commit c2c78e2

Browse files
authored
Merge pull request #1347 from su2code/nemo_visc_update
Updating some of the NEMO viscous solver routines.
2 parents 3ec1c68 + 7a487f2 commit c2c78e2

11 files changed

Lines changed: 444 additions & 478 deletions

File tree

SU2_CFD/include/solvers/CFVMFlowSolverBase.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,8 @@ class CFVMFlowSolverBase : public CSolver {
10071007
* \brief Evaluate the vorticity and strain rate magnitude.
10081008
* \tparam VelocityOffset - Index in the primitive variables where the velocity starts.
10091009
*/
1010-
template<unsigned long VelocityOffset>
1011-
void ComputeVorticityAndStrainMag(const CConfig& config, unsigned short iMesh) {
1010+
void ComputeVorticityAndStrainMag(const CConfig& config, unsigned short iMesh,
1011+
const size_t VelocityOffset = 1) {
10121012

10131013
auto& StrainMag = nodes->GetStrainMag();
10141014

SU2_CFD/include/solvers/CNEMONSSolver.hpp

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,14 +38,10 @@
3838
* \brief Main class for defining the NEMO Navier-Stokes flow solver.
3939
* \ingroup Navier_Stokes_Equations
4040
* \author S. R. Copeland, F. Palacios, W. Maier.
41-
*
4241
*/
4342
class CNEMONSSolver final : public CNEMOEulerSolver {
4443
private:
4544

46-
su2double Prandtl_Lam, /*!< \brief Laminar Prandtl number. */
47-
Prandtl_Turb; /*!< \brief Turbulent Prandtl number. */
48-
4945
/*!
5046
* \brief Compute the velocity^2, SoundSpeed, Pressure, Enthalpy, Viscosity.
5147
* \param[in] solver_container - Container vector with all the solutions.
@@ -55,6 +51,27 @@ class CNEMONSSolver final : public CNEMOEulerSolver {
5551
*/
5652
unsigned long SetPrimitive_Variables(CSolver **solver_container,
5753
CConfig *config, bool Output) override;
54+
55+
/*!
56+
* \brief Compute the viscous residuals.
57+
* \param[in] geometry - Geometrical definition of the problem.
58+
* \param[in] solver_container - Container vector with all the solutions.
59+
* \param[in] numerics - Description of the numerical method.
60+
* \param[in] config - Definition of the particular problem.
61+
* \param[in] iMesh - Index of the mesh in multigrid computations.
62+
* \param[in] iRKStep - Current step of the Runge-Kutta iteration.
63+
*/
64+
void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container,
65+
CConfig *config, unsigned short iMesh, unsigned short iRKStep) override;
66+
67+
/*!
68+
* \brief Computes the wall shear stress (Tau_Wall) on the surface using a wall function.
69+
* \param[in] geometry - Geometrical definition of the problem.
70+
* \param[in] solver_container - Container vector with all the solutions.
71+
* \param[in] config - Definition of the particular problem.
72+
*/
73+
void SetTauWall_WF(CGeometry *geometry, CSolver** solver_container, const CConfig* config);
74+
5875
public:
5976

6077
/*!
@@ -198,17 +215,4 @@ class CNEMONSSolver final : public CNEMOEulerSolver {
198215
CNumerics *visc_numerics,
199216
CConfig *config,
200217
unsigned short val_marker) override;
201-
202-
/*!
203-
* \brief Compute the viscous residuals.
204-
* \param[in] geometry - Geometrical definition of the problem.
205-
* \param[in] solver_container - Container vector with all the solutions.
206-
* \param[in] numerics - Description of the numerical method.
207-
* \param[in] config - Definition of the particular problem.
208-
* \param[in] iMesh - Index of the mesh in multigrid computations.
209-
* \param[in] iRKStep - Current step of the Runge-Kutta iteration.
210-
*/
211-
void Viscous_Residual(CGeometry *geometry, CSolver **solver_container, CNumerics **numerics_container,
212-
CConfig *config, unsigned short iMesh, unsigned short iRKStep) override;
213-
214218
};

SU2_CFD/include/variables/CNEMOEulerVariable.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ class CNEMOEulerVariable : public CVariable {
6565
/*--- New solution container for Classical RK4 ---*/
6666
MatrixType Solution_New; /*!< \brief New solution container for Classical RK4. */
6767

68+
/*--- NS Variables declared here to make it easier to re-use code between compressible and incompressible solvers. ---*/
69+
MatrixType Vorticity; /*!< \brief Vorticity of the fluid. */
70+
VectorType StrainMag; /*!< \brief Magnitude of rate of strain tensor. */
71+
6872
/*--- Other Necessary Variable Definition ---*/
6973
MatrixType dPdU; /*!< \brief Partial derivative of pressure w.r.t. conserved variables. */
7074
MatrixType dTdU; /*!< \brief Partial derivative of temperature w.r.t. conserved variables. */
@@ -536,6 +540,19 @@ class CNEMOEulerVariable : public CVariable {
536540
Solution(iPoint, nSpecies+iDim) = Primitive(iPoint,RHO_INDEX) * val_vector[iDim];
537541
}
538542

543+
/*!
544+
* \brief Get the value of the vorticity.
545+
* \return Value of the vorticity.
546+
*/
547+
inline su2double *GetVorticity(unsigned long iPoint) final { return Vorticity[iPoint]; }
548+
549+
/*!
550+
* \brief Get the value of the magnitude of rate of strain.
551+
* \return Value of the rate of strain magnitude.
552+
*/
553+
inline su2double GetStrainMag(unsigned long iPoint) const final { return StrainMag(iPoint); }
554+
inline su2activevector& GetStrainMag() { return StrainMag; }
555+
539556
/*!
540557
* \brief Set the momentum part of the truncation error to zero.
541558
* \param[in] iPoint - Point index.

SU2_CFD/include/variables/CNEMONSVariable.hpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ class CNEMONSVariable final : public CNEMOEulerVariable {
5151

5252
su2double inv_TimeScale; /*!< \brief Inverse of the reference time scale. */
5353

54-
MatrixType Vorticity; /*!< \brief Vorticity of the fluid. */
55-
VectorType StrainMag; /*!< \brief Magnitude of rate of strain tensor. */
5654
VectorType Tau_Wall; /*!< \brief Magnitude of the wall shear stress from a wall function. */
5755
VectorType DES_LengthScale; /*!< \brief DES Length Scale. */
5856
VectorType Roe_Dissipation; /*!< \brief Roe low dissipation coefficient. */
@@ -155,12 +153,4 @@ class CNEMONSVariable final : public CNEMOEulerVariable {
155153
inline void SetWallTemperature(unsigned long iPoint, su2double temperature_wall) override {
156154
Primitive(iPoint,T_INDEX) = temperature_wall;
157155
}
158-
159-
/*!
160-
* \brief Get the value of the vorticity.
161-
* \return Value of the vorticity.
162-
*/
163-
inline su2double *GetVorticity(unsigned long iPoint) override { return Vorticity[iPoint]; }
164-
165-
166156
};

SU2_CFD/src/fluid/CNEMOGas.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,10 @@ void CNEMOGas::ComputedPdU(su2double *V, vector<su2double>& val_eves, su2double
240240

241241
void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
242242

243-
su2double Vel[3] = {0.0};
244-
245243
/*--- Necessary indexes to assess primitive variables ---*/
246-
unsigned long T_INDEX = nSpecies;
247-
unsigned long VEL_INDEX = nSpecies+2;
248-
unsigned long RHOCVTR_INDEX = nSpecies+nDim+6;
244+
const unsigned long T_INDEX = nSpecies;
245+
const unsigned long VEL_INDEX = nSpecies+2;
246+
const unsigned long RHOCVTR_INDEX = nSpecies+nDim+6;
249247

250248
/*--- Rename for convenience ---*/
251249
T = V[T_INDEX];
@@ -256,9 +254,7 @@ void CNEMOGas::ComputedTdU(su2double *V, su2double *val_dTdU){
256254
Ref_Temperature = GetRefTemperature();
257255

258256
/*--- Calculate supporting quantities ---*/
259-
for (iDim = 0; iDim < nDim; iDim++)
260-
Vel[iDim] = V[VEL_INDEX+iDim]*V[VEL_INDEX+iDim];
261-
su2double v2 = GeometryToolbox::SquaredNorm(nDim,Vel);
257+
const su2double v2 = GeometryToolbox::SquaredNorm(nDim, &V[VEL_INDEX]);
262258

263259
/*--- Species density derivatives ---*/
264260
for (iSpecies = nEl; iSpecies < nSpecies; iSpecies++) {

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container
9696
SetPrimitive_Limiter(geometry, config);
9797
}
9898

99-
ComputeVorticityAndStrainMag<1>(*config, iMesh);
99+
ComputeVorticityAndStrainMag(*config, iMesh);
100100

101101
/*--- Compute the TauWall from the wall functions ---*/
102102

SU2_CFD/src/solvers/CNEMOEulerSolver.cpp

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,20 @@ CNEMOEulerSolver::CNEMOEulerSolver(CGeometry *geometry, CConfig *config,
4646
description = "Euler";
4747
}
4848

49+
const auto nZone = geometry->GetnZone();
50+
const bool restart = (config->GetRestart() || config->GetRestart_Flow());
51+
const auto direct_diff = config->GetDirectDiff();
52+
const bool dual_time = (config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
53+
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND);
54+
const bool time_stepping = (config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING);
55+
const bool adjoint = config->GetContinuous_Adjoint() || config->GetDiscrete_Adjoint();
56+
57+
int Unst_RestartIter = 0;
4958
unsigned short iMarker, nLineLets;
50-
unsigned short nZone = geometry->GetnZone();
5159
su2double *Mvec_Inf, Alpha, Beta;
52-
bool restart = (config->GetRestart() || config->GetRestart_Flow());
53-
unsigned short direct_diff = config->GetDirectDiff();
54-
int Unst_RestartIter = 0;
55-
bool dual_time = ((config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_1ST) ||
56-
(config->GetTime_Marching() == TIME_MARCHING::DT_STEPPING_2ND));
57-
bool time_stepping = config->GetTime_Marching() == TIME_MARCHING::TIME_STEPPING;
58-
bool adjoint = config->GetDiscrete_Adjoint();
59-
string filename_ = "flow";
60+
61+
/*--- A grid is defined as dynamic if there's rigid grid movement or grid deformation AND the problem is time domain ---*/
62+
dynamic_grid = config->GetDynamic_Grid();
6063

6164
/*--- Store the multigrid level. ---*/
6265
MGLevel = iMesh;
@@ -79,6 +82,7 @@ CNEMOEulerSolver::CNEMOEulerSolver(CGeometry *geometry, CConfig *config,
7982
else Unst_RestartIter = SU2_TYPE::Int(config->GetRestart_Iter())-1;
8083
}
8184

85+
string filename_ = "flow";
8286
filename_ = config->GetFilename(filename_, ".meta", Unst_RestartIter);
8387

8488
/*--- Read and store the restart metadata ---*/
@@ -246,18 +250,24 @@ void CNEMOEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver
246250
bool center_jst_ke = (config->GetKind_Centered_Flow() == JST_KE) && (iMesh == MESH_0);
247251

248252
/*--- Set the primitive variables ---*/
249-
ErrorCounter = 0;
253+
ompMasterAssignBarrier(ErrorCounter,0);
254+
SU2_OMP_ATOMIC
250255
ErrorCounter += SetPrimitive_Variables(solver_container, config, Output);
256+
SU2_OMP_BARRIER
251257

252-
if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) {
258+
SU2_OMP_MASTER { /*--- Ops that are not OpenMP parallel go in this block. ---*/
253259

260+
if ((iMesh == MESH_0) && (config->GetComm_Level() == COMM_FULL)) {
254261
unsigned long tmp = ErrorCounter;
255262
SU2_MPI::Allreduce(&tmp, &ErrorCounter, 1, MPI_UNSIGNED_LONG, MPI_SUM, SU2_MPI::GetComm());
256263
config->SetNonphysical_Points(ErrorCounter);
257264

258265
if ((rank == MASTER_NODE) && (ErrorCounter != 0))
259266
cout << "Warning. The initial solution contains "<< ErrorCounter << " points that are not physical." << endl;
267+
}
260268
}
269+
END_SU2_OMP_MASTER
270+
SU2_OMP_BARRIER
261271

262272
/*--- Artificial dissipation ---*/
263273

@@ -986,7 +996,7 @@ void CNEMOEulerSolver::SetNondimensionalization(CConfig *config, unsigned short
986996
Gas_ConstantND = 0.0, Viscosity_FreeStreamND = 0.0, sqvel = 0.0,
987997
Tke_FreeStreamND = 0.0, Total_UnstTimeND = 0.0, Delta_UnstTimeND = 0.0,
988998
soundspeed = 0.0, GasConstant_Inf = 0.0, Froude = 0.0,
989-
Density_FreeStreamND = 0.0;
999+
Density_FreeStreamND = 0.0, Heat_Flux_Ref = 0.0;
9901000

9911001
su2double Velocity_FreeStreamND[3] = {0.0, 0.0, 0.0};
9921002

@@ -1153,6 +1163,7 @@ void CNEMOEulerSolver::SetNondimensionalization(CConfig *config, unsigned short
11531163
Time_Ref = Length_Ref/Velocity_Ref; config->SetTime_Ref(Time_Ref);
11541164
Omega_Ref = Velocity_Ref/Length_Ref; config->SetOmega_Ref(Omega_Ref);
11551165
Force_Ref = config->GetDensity_Ref()*Velocity_Ref*Velocity_Ref*Length_Ref*Length_Ref; config->SetForce_Ref(Force_Ref);
1166+
Heat_Flux_Ref = Density_Ref*Velocity_Ref*Velocity_Ref*Velocity_Ref; config->SetHeat_Flux_Ref(Heat_Flux_Ref);
11561167
Gas_Constant_Ref = Velocity_Ref*Velocity_Ref/config->GetTemperature_Ref(); config->SetGas_Constant_Ref(Gas_Constant_Ref);
11571168
Viscosity_Ref = config->GetDensity_Ref()*Velocity_Ref*Length_Ref; config->SetViscosity_Ref(Viscosity_Ref);
11581169
Conductivity_Ref = Viscosity_Ref*Gas_Constant_Ref; config->SetConductivity_Ref(Conductivity_Ref);
@@ -1640,12 +1651,10 @@ void CNEMOEulerSolver::BC_Far_Field(CGeometry *geometry, CSolver **solver_contai
16401651

16411652
void CNEMOEulerSolver::BC_Inlet(CGeometry *geometry, CSolver **solver_container,
16421653
CNumerics *conv_numerics, CNumerics *visc_numerics, CConfig *config, unsigned short val_marker) {
1643-
1644-
1645-
16461654
SU2_MPI::Error("BC_INLET: Not operational in NEMO.", CURRENT_FUNCTION);
16471655

16481656
unsigned short iVar, iDim, iSpecies, RHO_INDEX, nSpecies;
1657+
16491658
unsigned long iVertex, iPoint;
16501659
su2double T_Total, P_Total, Velocity[3], Velocity2, H_Total, Temperature, Riemann,
16511660
Pressure, Density, Energy, Mach2, SoundSpeed2, SoundSpeed_Total2, Vel_Mag,

0 commit comments

Comments
 (0)