Skip to content

Commit f0e887f

Browse files
committed
Address PR comments. Part 1.
1 parent 86295f5 commit f0e887f

11 files changed

Lines changed: 75 additions & 54 deletions

File tree

Common/include/CConfig.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -998,9 +998,9 @@ class CConfig {
998998

999999
unsigned short Kind_Streamwise_Periodic; /*!< \brief Kind of Streamwise periodic flow (pressure drop or massflow) */
10001000
bool Streamwise_Periodic_Temperature; /*!< \brief Use real periodicity for Energy equation or otherwise outlet source term. */
1001-
su2double Streamwise_Periodic_PressureDrop, /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */
1002-
Streamwise_Periodic_TargetMassFlow, /*!< \brief Value of prescribed massflow [kg/s] which results in an delta p and therefore an artificial body force vector. */
1003-
Streamwise_Periodic_OutletHeat; /*!< /brief Heatflux boundary [W/m^2] imposed at streamwise periodic outlet. */
1001+
su2double Streamwise_Periodic_PressureDrop; /*!< \brief Value of prescribed pressure drop [Pa] which results in an artificial body force vector. */
1002+
su2double Streamwise_Periodic_TargetMassFlow; /*!< \brief Value of prescribed massflow [kg/s] which results in an delta p and therefore an artificial body force vector. */
1003+
su2double Streamwise_Periodic_OutletHeat; /*!< /brief Heatflux boundary [W/m^2] imposed at streamwise periodic outlet. */
10041004

10051005
su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */
10061006
su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */

Common/include/geometry/CGeometry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1716,7 +1716,7 @@ class CGeometry {
17161716
* \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet.
17171717
* \param[in] config - Definition of the particular problem.
17181718
*/
1719-
inline virtual void FindUniqueNode_PeriodicBound(CConfig *config) {}
1719+
inline virtual void FindUniqueNode_PeriodicBound(const CConfig *config) {}
17201720

17211721
/*!
17221722
* \brief Get a pointer to the reference node coordinate vector.

Common/include/geometry/CPhysicalGeometry.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,7 @@ class CPhysicalGeometry final : public CGeometry {
790790
* \brief For streamwise periodicity, find & store a unique reference node on the designated periodic inlet.
791791
* \param[in] config - Definition of the particular problem.
792792
*/
793-
void FindUniqueNode_PeriodicBound(CConfig *config) final;
793+
void FindUniqueNode_PeriodicBound(const CConfig *config) final;
794794

795795
/*!
796796
* \brief Get a pointer to the reference node coordinate vector.

Common/src/CConfig.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1937,7 +1937,7 @@ void CConfig::SetConfig_Options() {
19371937
/*!\brief OUTPUT_FORMAT \n DESCRIPTION: I/O format for output plots. \n OPTIONS: see \link TabOutput_Map \endlink \n DEFAULT: TECPLOT \ingroup Config */
19381938
addEnumOption("TABULAR_FORMAT", Tab_FileFormat, TabOutput_Map, TAB_CSV);
19391939
/*!\brief OUTPUT_PRECISION \n DESCRIPTION: Set <ofstream>.precision(value) to specified value for SU2_DOT and HISTORY output. Useful for exact gradient validation. \n DEFAULT: 6 \ingroup Config */
1940-
addUnsignedShortOption("OUTPUT_PRECISION", output_precision, 6);
1940+
addUnsignedShortOption("OUTPUT_PRECISION", output_precision, 10);
19411941
/*!\brief ACTDISK_JUMP \n DESCRIPTION: The jump is given by the difference in values or a ratio */
19421942
addEnumOption("ACTDISK_JUMP", ActDisk_Jump, Jump_Map, DIFFERENCE);
19431943
/*!\brief MESH_FORMAT \n DESCRIPTION: Mesh input file format \n OPTIONS: see \link Input_Map \endlink \n DEFAULT: SU2 \ingroup Config*/

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7458,15 +7458,15 @@ void CPhysicalGeometry::MatchPeriodic(CConfig *config,
74587458
delete [] Buffer_Recv_Marker;
74597459
}
74607460

7461-
void CPhysicalGeometry::FindUniqueNode_PeriodicBound(CConfig *config) {
7461+
void CPhysicalGeometry::FindUniqueNode_PeriodicBound(const CConfig *config) {
74627462

74637463
/*-------------------------------------------------------------------------------------------*/
74647464
/*--- Find reference node on the 'inlet' streamwise periodic marker for the computation ---*/
74657465
/*--- of recovered pressure/temperature, such that this found node is independent of the ---*/
74667466
/*--- number of ranks. This does not affect the 'correctness' of the solution as the ---*/
74677467
/*--- absolute value is arbitrary anyway, but it assures that the solution does not change---*/
74687468
/*--- with a higher number of ranks. If the periodic markers are a line\plane and the ---*/
7469-
/*--- streamwise coordiante vector is perpendicular to that |--->|, the choice of the ---*/
7469+
/*--- streamwise coordinate vector is perpendicular to that |--->|, the choice of the ---*/
74707470
/*--- reference node is not relevant at all. This is probably true for most streamwise ---*/
74717471
/*--- periodic cases. Other cases where it is relevant could look like this (--->( or ---*/
74727472
/*--- \--->\ . The chosen metric is the minimal distance to the origin. ---*/

SU2_CFD/include/solvers/CIncNSSolver.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,15 @@ class CIncNSSolver final : public CIncEulerSolver {
6565
void Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container,
6666
CNumerics *numerics, CConfig *config) override;
6767

68+
/*!
69+
* \brief Compute recovered pressure/temperature for streamwise periodic flow and store in CVariable.
70+
* \param[in] config - Definition of the particular problem.
71+
* \param[in] geometry - Geometrical definition of the problem.
72+
* \param[in] iMesh - current mesh level for the multigrid.
73+
*/
74+
void Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry,
75+
const unsigned short iMesh);
76+
6877
public:
6978
/*!
7079
* \brief Constructor of the class.

SU2_CFD/src/output/COutput.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,7 +1253,7 @@ void COutput::PrepareHistoryFile(CConfig *config){
12531253
historyFileTable->SetAlign(PrintingToolbox::CTablePrinter::CENTER);
12541254
historyFileTable->SetPrintHeaderTopLine(false);
12551255
historyFileTable->SetPrintHeaderBottomLine(false);
1256-
historyFileTable->SetPrecision(config->OptionIsSet("OUTPUT_PRECISION") ? config->GetOutput_Precision() : 10);
1256+
historyFileTable->SetPrecision(config->GetOutput_Precision());
12571257

12581258
/*--- Add the header to the history file. ---*/
12591259

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1528,7 +1528,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
15281528
}// for iPoint
15291529

15301530
if(!streamwise_periodic_temperature && energy) {
1531-
CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM];
1531+
CNumerics* second_numerics = numerics_container[SOURCE_SECOND_TERM + omp_get_thread_num()*MAX_TERMS];
15321532
second_numerics->SetStreamwise_Periodic_Values(Streamwise_Periodic_MassFlow, Streamwise_Periodic_IntegratedHeatFlow,
15331533
Streamwise_Periodic_InletTemperature);
15341534

@@ -1539,6 +1539,7 @@ void CIncEulerSolver::Source_Residual(CGeometry *geometry, CSolver **solver_cont
15391539
if (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY &&
15401540
config->GetMarker_All_PerBound(iMarker) == 1) {
15411541

1542+
SU2_OMP_FOR_STAT(omp_chunk_size)
15421543
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
15431544

15441545
iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
@@ -2904,7 +2905,7 @@ void CIncEulerSolver::GetStreamwise_Periodic_Properties(const CGeometry *ge
29042905

29052906
// One could add a CVariable method to return a pointer to the first Vel element to directly plug into GeomToolbox
29062907
su2double Velocity[MAXNDIM] = {0.0};
2907-
for (auto iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = nodes->GetVelocity(iPoint, iDim); }
2908+
for (unsigned short iDim = 0; iDim < nDim; iDim++) { Velocity[iDim] = nodes->GetVelocity(iPoint, iDim); }
29082909
/*--- m_dot = dot_prod(n*v) * A * rho, with n beeing unit normal. ---*/
29092910
MassFlow_Local += GeometryToolbox::DotProduct(nDim, AreaNormal, Velocity) * nodes->GetDensity(iPoint);
29102911

@@ -2982,8 +2983,9 @@ void CIncEulerSolver::GetStreamwise_Periodic_Properties(const CGeometry *ge
29822983

29832984
if (config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) {
29842985

2985-
/*--- Identify the boundary by string name ---*/
2986-
auto Marker_StringTag = config->GetMarker_All_TagBound(iMarker);
2986+
/*--- Identify the boundary by string name and retrive heatflux from config ---*/
2987+
const auto Marker_StringTag = config->GetMarker_All_TagBound(iMarker);
2988+
const auto Wall_HeatFlux = config->GetWall_HeatFlux(Marker_StringTag);
29872989

29882990
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
29892991

@@ -2995,7 +2997,7 @@ void CIncEulerSolver::GetStreamwise_Periodic_Properties(const CGeometry *ge
29952997

29962998
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
29972999

2998-
HeatFlow_Local += FaceArea * (-1.0) * config->GetWall_HeatFlux(Marker_StringTag)/config->GetHeat_Flux_Ref();;
3000+
HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();;
29993001
} // loop Vertices
30003002
} // loop Heatflux marker
30013003
} // loop AllMarker

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container
6262
const bool center = (config->GetKind_ConvNumScheme_Flow() == SPACE_CENTERED);
6363
const bool limiter = (config->GetKind_SlopeLimit_Flow() != NO_LIMITER) && (InnerIter <= config->GetLimiterIter());
6464
const bool van_albada = (config->GetKind_SlopeLimit_Flow() == VAN_ALBADA_EDGE);
65-
const bool energy = config->GetEnergy_Equation();
6665

6766
/*--- Common preprocessing steps (implemented by CEulerSolver) ---*/
6867

@@ -99,42 +98,49 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container
9998
ComputeVorticityAndStrainMag<1>(*config, iMesh);
10099

101100
/*--- Compute recovered pressure and temperature for streamwise periodic flow ---*/
102-
if (config->GetKind_Streamwise_Periodic() != NONE) {
101+
if (config->GetKind_Streamwise_Periodic() != NONE)
102+
Compute_Streamwise_Periodic_Recovered_Values(config, geometry, iMesh);
103+
}
103104

104-
/*--- Define and initialize helping variables ---*/
105-
su2double dot_product, Pressure_Recovered, Temperature_Recovered;
105+
void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry,
106+
const unsigned short iMesh) {
106107

107-
const su2double delta_p = config->GetStreamwise_Periodic_PressureDrop() / config->GetPressure_Ref();
108+
const bool energy = (config->GetEnergy_Equation() && config->GetStreamwise_Periodic_Temperature());
109+
const auto InnerIter = config->GetInnerIter();
108110

109-
/*--- Reference node on inlet periodic marker to compute relative distance along periodic translation vector. ---*/
110-
const su2double* ReferenceNode = geometry->GetStreamwise_Periodic_RefNode();
111+
const su2double delta_p = config->GetStreamwise_Periodic_PressureDrop() / config->GetPressure_Ref();
111112

112-
/*--- Compute square of the distance between the 2 periodic surfaces. ---*/
113-
const su2double norm2_translation = GeometryToolbox::SquaredNorm(nDim, config->GetPeriodic_Translation(0));
113+
/*--- Reference node on inlet periodic marker to compute relative distance along periodic translation vector. ---*/
114+
const su2double* ReferenceNode = geometry->GetStreamwise_Periodic_RefNode();
114115

115-
/*--- Compute recoverd pressure and temperature for all points ---*/
116-
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
116+
/*--- Compute square of the distance between the 2 periodic surfaces. ---*/
117+
const su2double norm2_translation = GeometryToolbox::SquaredNorm(nDim, config->GetPeriodic_Translation(0));
117118

118-
/*--- First, compute helping terms based on relative distance (0,l) between periodic markers ---*/
119-
dot_product = 0.0;
120-
for (unsigned short iDim = 0; iDim < nDim; iDim++)
121-
dot_product += fabs( (geometry->nodes->GetCoord(iPoint,iDim) - ReferenceNode[iDim]) * config->GetPeriodic_Translation(0)[iDim]);
119+
/*--- Compute recoverd pressure and temperature for all points ---*/
120+
SU2_OMP_FOR_STAT(omp_chunk_size)
121+
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
122122

123-
/*--- Second, substract/add correction from reduced pressure/temperature to get recoverd pressure/temperature ---*/
124-
Pressure_Recovered = nodes->GetSolution(iPoint, 0) - delta_p / norm2_translation * dot_product;
125-
nodes->SetStreamwise_Periodic_RecoveredPressure(iPoint, Pressure_Recovered);
123+
/*--- First, compute helping terms based on relative distance (0,l) between periodic markers ---*/
124+
su2double dot_product = 0.0;
125+
for (unsigned short iDim = 0; iDim < nDim; iDim++)
126+
dot_product += fabs( (geometry->nodes->GetCoord(iPoint,iDim) - ReferenceNode[iDim]) * config->GetPeriodic_Translation(0)[iDim]);
126127

127-
/*--- InnerIter > 0 as otherwise MassFlow in the denominator would be zero ---*/
128-
if (energy && InnerIter > 0) {
129-
Temperature_Recovered = nodes->GetSolution(iPoint, nDim+1);
130-
Temperature_Recovered += Streamwise_Periodic_IntegratedHeatFlow / (Streamwise_Periodic_MassFlow * nodes->GetSpecificHeatCp(iPoint) * norm2_translation) * dot_product;
131-
nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, Temperature_Recovered);
132-
}
128+
/*--- Second, substract/add correction from reduced pressure/temperature to get recoverd pressure/temperature ---*/
129+
const su2double Pressure_Recovered = nodes->GetPressure(iPoint) - delta_p / norm2_translation * dot_product;
130+
nodes->SetStreamwise_Periodic_RecoveredPressure(iPoint, Pressure_Recovered);
131+
132+
/*--- InnerIter > 0 as otherwise MassFlow in the denominator would be zero ---*/
133+
if (energy && InnerIter > 0) {
134+
su2double Temperature_Recovered = nodes->GetTemperature(iPoint);
135+
Temperature_Recovered += Streamwise_Periodic_IntegratedHeatFlow / (Streamwise_Periodic_MassFlow * nodes->GetSpecificHeatCp(iPoint) * norm2_translation) * dot_product;
136+
nodes->SetStreamwise_Periodic_RecoveredTemperature(iPoint, Temperature_Recovered);
133137
}
138+
} // for iPoint
134139

135-
/*--- Compute the integrated Heatflux Q into the domain, and massflow over periodic markers ---*/
136-
GetStreamwise_Periodic_Properties(geometry, config, iMesh);
137-
} // if streamwise periodic
140+
/*--- Compute the integrated Heatflux Q into the domain, and massflow over periodic markers ---*/
141+
SU2_OMP_MASTER
142+
GetStreamwise_Periodic_Properties(geometry, config, iMesh);
143+
SU2_OMP_BARRIER
138144
}
139145

140146
void CIncNSSolver::Viscous_Residual(unsigned long iEdge, CGeometry *geometry, CSolver **solver_container,
@@ -265,20 +271,20 @@ void CIncNSSolver::BC_Wall_Generic(const CGeometry *geometry, const CConfig *con
265271
LinSysRes(iPoint, nDim+1) -= Wall_HeatFlux*Area;
266272

267273
/*--- With streamwise periodic flow and heatflux walls an additional term is introduced in the boundary formulation ---*/
268-
if (streamwise_periodic && streamwise_periodic_temperature) {
274+
if (streamwise_periodic && streamwise_periodic_temperature) {
269275

270-
Cp = nodes->GetSpecificHeatCp(iPoint);
271-
thermal_conductivity = nodes->GetThermalConductivity(iPoint);
276+
Cp = nodes->GetSpecificHeatCp(iPoint);
277+
thermal_conductivity = nodes->GetThermalConductivity(iPoint);
272278

273-
/*--- Scalar factor of the residual contribution ---*/
274-
const su2double norm2_translation = GeometryToolbox::SquaredNorm(nDim, config->GetPeriodic_Translation(0));
275-
scalar_factor = Streamwise_Periodic_IntegratedHeatFlow*thermal_conductivity / (Streamwise_Periodic_MassFlow * Cp * norm2_translation);
279+
/*--- Scalar factor of the residual contribution ---*/
280+
const su2double norm2_translation = GeometryToolbox::SquaredNorm(nDim, config->GetPeriodic_Translation(0));
281+
scalar_factor = Streamwise_Periodic_IntegratedHeatFlow*thermal_conductivity / (Streamwise_Periodic_MassFlow * Cp * norm2_translation);
276282

277-
/*--- Dot product ---*/
278-
dot_product = GeometryToolbox::DotProduct(nDim, config->GetPeriodic_Translation(0), Normal);
283+
/*--- Dot product ---*/
284+
dot_product = GeometryToolbox::DotProduct(nDim, config->GetPeriodic_Translation(0), Normal);
279285

280-
LinSysRes(iPoint, nDim+1) += scalar_factor*dot_product;
281-
} // if streamwise_periodic
286+
LinSysRes(iPoint, nDim+1) += scalar_factor*dot_product;
287+
} // if streamwise_periodic
282288
}
283289
else { // ISOTHERMAL
284290

SU2_CFD/src/variables/CIncEulerVariable.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,12 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci
114114
Delta_Time.resize(nPoint) = su2double(0.0);
115115
Lambda.resize(nPoint) = su2double(0.0);
116116
Sensor.resize(nPoint) = su2double(0.0);
117-
Streamwise_Periodic_RecoveredPressure.resize(nPoint) = su2double(0.0);
118-
Streamwise_Periodic_RecoveredTemperature.resize(nPoint) = su2double(0.0);
117+
118+
if (config->GetKind_Streamwise_Periodic() != NONE) {
119+
Streamwise_Periodic_RecoveredPressure.resize(nPoint) = su2double(0.0);
120+
if (config->GetStreamwise_Periodic_Temperature())
121+
Streamwise_Periodic_RecoveredTemperature.resize(nPoint) = su2double(0.0);
122+
}
119123

120124
/* Under-relaxation parameter. */
121125
UnderRelaxation.resize(nPoint) = su2double(1.0);

0 commit comments

Comments
 (0)