Skip to content

Commit fe7b0de

Browse files
committed
Compute mu_t grad via AuxVar.
1 parent 2f2e6f2 commit fe7b0de

6 files changed

Lines changed: 39 additions & 15 deletions

File tree

Common/src/CConfig.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4616,6 +4616,7 @@ void CConfig::SetPostprocessing(unsigned short val_software, unsigned short val_
46164616
SU2_MPI::Error("Streamwise Periodicity only works with \"INC_NONDIM= DIMENSIONAL\", the nondimensionalization with source terms doesn;t work in general.", CURRENT_FUNCTION);
46174617
if (Axisymmetric)
46184618
SU2_MPI::Error("Streamwise Periodicity terms does not not have axisymmetric corrections.", CURRENT_FUNCTION);
4619+
if (!Energy_Equation) Streamwise_Periodic_Temperature = false;
46194620
} else {
46204621
/*--- Safety measure ---*/
46214622
Streamwise_Periodic_Temperature = false;

SU2_CFD/include/solvers/CSolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4415,7 +4415,7 @@ class CSolver {
44154415
* \brief Get values for streamwise periodc flow: delta P, m_dot, inlet T, integrated heat.
44164416
* \return Struct holding 4 su2doubles.
44174417
*/
4418-
virtual StreamwisePeriodicValues GetStreamwisePeriodicValues() const { StreamwisePeriodicValues SPvals; return SPvals; }
4418+
virtual StreamwisePeriodicValues GetStreamwisePeriodicValues() const { return StreamwisePeriodicValues(); }
44194419

44204420

44214421
protected:

SU2_CFD/src/numerics/flow/flow_sources.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ CNumerics::ResidualType<> CSourceIncStreamwise_Periodic::ComputeResidual(const C
720720
scalar_factor = SPvals.Streamwise_Periodic_IntegratedHeatFlow / (SPvals.Streamwise_Periodic_MassFlow * sqrt(norm2_translation) * Prandtl_Turb);
721721

722722
/*--- Compute scalar product between periodic translation vector and eddy viscosity gradient. ---*/
723-
dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, PrimVar_Grad_i[nDim+5]);
723+
dot_product = GeometryToolbox::DotProduct(nDim, Streamwise_Coord_Vector, AuxVar_Grad_i[0]);
724724

725725
residual[nDim+1] -= Volume * scalar_factor * dot_product;
726726
} // if turbulent

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ CIncEulerSolver::CIncEulerSolver(CGeometry *geometry, CConfig *config, unsigned
105105
nDim = geometry->GetnDim();
106106

107107
/*--- Make sure to align the sizes with the constructor of CIncEulerVariable. ---*/
108-
nVar = nDim+2; nPrimVar = nDim+9; nPrimVarGrad = nDim+6;
108+
nVar = nDim+2; nPrimVar = nDim+9; nPrimVarGrad = nDim+4;
109109

110110
/*--- Initialize nVarGrad for deallocation ---*/
111111

@@ -1263,6 +1263,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
12631263
const bool viscous = config->GetViscous();
12641264
const bool radiation = config->AddRadiation();
12651265
const bool vol_heat = config->GetHeatSource();
1266+
const bool turbulent = (config->GetKind_Turb_Model() != NONE);
12661267
const bool energy = config->GetEnergy_Equation();
12671268
const bool streamwise_periodic = config->GetKind_Streamwise_Periodic();
12681269
const bool streamwise_periodic_temperature = config->GetStreamwise_Periodic_Temperature();
@@ -1382,7 +1383,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
13821383
if (yCoord > EPS)
13831384
AuxVar = Total_Viscosity*yVelocity/yCoord;
13841385

1385-
/*--- Set the auxilairy variable for this node. ---*/
1386+
/*--- Set the auxiliary variable for this node. ---*/
13861387

13871388
nodes->SetAuxVar(iPoint, 0, AuxVar);
13881389

@@ -1497,6 +1498,25 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
14971498

14981499
if (streamwise_periodic) {
14991500

1501+
/*--- For turbulent streamwise periodic problems w/ energy eq, we need an additional gradient of Eddy viscosity. ---*/
1502+
if (streamwise_periodic_temperature && turbulent) {
1503+
1504+
SU2_OMP_FOR_STAT(omp_chunk_size)
1505+
for (iPoint = 0; iPoint < nPoint; iPoint++) {
1506+
/*--- Set the auxiliary variable, Eddy viscosity mu_t, for this node. ---*/
1507+
nodes->SetAuxVar(iPoint, 0, nodes->GetEddyViscosity(iPoint));
1508+
}
1509+
1510+
/*--- Compute the auxiliary variable gradient with GG or WLS. ---*/
1511+
if (config->GetKind_Gradient_Method() == GREEN_GAUSS) {
1512+
SetAuxVar_Gradient_GG(geometry, config);
1513+
}
1514+
if (config->GetKind_Gradient_Method() == WEIGHTED_LEAST_SQUARES) {
1515+
SetAuxVar_Gradient_LS(geometry, config);
1516+
}
1517+
1518+
} // if turbulent
1519+
15001520
/*--- Set delta_p, m_dot, inlet_T, integrated_heat ---*/
15011521
numerics->SetStreamwisePeriodicValues(SPvals);
15021522

@@ -1513,11 +1533,9 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
15131533
/*--- Load the volume of the dual mesh cell ---*/
15141534
numerics->SetVolume(geometry->nodes->GetVolume(iPoint));
15151535

1516-
/*--- If viscous, we need gradients for extra terms. ---*/
1517-
if (viscous) {
1518-
/*--- Gradient of the primitive variables ---*/
1519-
numerics->SetPrimVarGradient(nodes->GetGradient_Primitive(iPoint), nullptr);
1520-
}
1536+
/*--- Load the aux variable gradient that we already computed. ---*/
1537+
if(streamwise_periodic_temperature && turbulent)
1538+
numerics->SetAuxVarGrad(nodes->GetAuxVarGradient(iPoint), nullptr);
15211539

15221540
/*--- Compute the streamwise periodic source residual and add to the total ---*/
15231541
auto residual = numerics->ComputeResidual(config);
@@ -1526,9 +1544,10 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
15261544
/*--- Add the implicit Jacobian contribution ---*/
15271545
if (implicit) Jacobian.AddBlock2Diag(iPoint, residual.jacobian_i);
15281546

1529-
}// for iPoint
1547+
} // for iPoint
15301548

15311549
if(!streamwise_periodic_temperature && energy) {
1550+
15321551
CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num()*MAX_TERMS];
15331552

15341553
/*--- Set delta_p, m_dot, inlet_T, integrated_heat ---*/
@@ -2908,11 +2927,8 @@ void CIncEulerSolver::GetStreamwise_Periodic_Properties(const CGeometry *ge
29082927

29092928
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
29102929

2911-
// One could add a CVariable method to return a pointer to the first Vel element to directly plug into GeomToolbox
2912-
su2double Velocity[MAXNDIM] = {0.0};
2913-
for (unsigned short iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = nodes->GetVelocity(iPoint, iDim); }
29142930
/*--- m_dot = dot_prod(n*v) * A * rho, with n beeing unit normal. ---*/
2915-
MassFlow_Local += GeometryToolbox::DotProduct(nDim, AreaNormal, Velocity) * nodes->GetDensity(iPoint);
2931+
MassFlow_Local += nodes->GetProjVel(iPoint, AreaNormal) * nodes->GetDensity(iPoint);
29162932

29172933
Area_Local += FaceArea;
29182934

SU2_CFD/src/variables/CIncEulerVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci
3939
/*--- Allocate and initialize the primitive variables and gradients.
4040
Make sure to align the sizes with the constructor of CIncEulerSolver ---*/
4141

42-
nPrimVar = nDim+9; nPrimVarGrad = nDim+6;
42+
nPrimVar = nDim+9; nPrimVarGrad = nDim+4;
4343

4444
/*--- Allocate residual structures ---*/
4545

SU2_CFD/src/variables/CIncNSVariable.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ CIncNSVariable::CIncNSVariable(su2double pressure, const su2double *velocity, su
4242
AuxVar.resize(nPoint,nAuxVar) = su2double(0.0);
4343
Grad_AuxVar.resize(nPoint,nAuxVar,nDim);
4444
}
45+
46+
/*--- Allocate memory for the AuxVar+gradient of eddy viscosity mu_t ---*/
47+
if (config->GetStreamwise_Periodic_Temperature() && (config->GetKind_Turb_Model() != NONE)) {
48+
nAuxVar = 1;
49+
AuxVar.resize(nPoint,nAuxVar) = su2double(0.0);
50+
Grad_AuxVar.resize(nPoint,nAuxVar,nDim);
51+
}
4552
}
4653

4754
bool CIncNSVariable::SetPrimVar(unsigned long iPoint, su2double eddy_visc, su2double turb_ke, CFluidModel *FluidModel) {

0 commit comments

Comments
 (0)