Skip to content

Commit 8e7e567

Browse files
committed
Move GetStreamwisePerProp from Euler to NS solver.
1 parent fe7b0de commit 8e7e567

5 files changed

Lines changed: 166 additions & 166 deletions

File tree

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,6 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, INCOMPRESSI
119119
template<ENUM_TIME_INT IntegrationType>
120120
void Explicit_Iteration(CGeometry *geometry, CSolver **solver_container, CConfig *config, unsigned short iRKStep);
121121

122-
/*!
123-
* \brief Compute necessary quantities (massflow, integrated heatflux, avg density)
124-
* for streamwise periodic cases. Also sets new delta P for prescribed massflow.
125-
* \param[in] geometry - Geometrical definition of the problem.
126-
* \param[in] config - Definition of the particular problem.
127-
* \param[in] iMesh - current mesh level for the multigrid.
128-
*/
129-
void GetStreamwise_Periodic_Properties(const CGeometry *geometry,
130-
CConfig *config,
131-
const unsigned short iMesh);
132-
133122
public:
134123
/*!
135124
* \brief Constructor of the class.

SU2_CFD/include/solvers/CIncNSSolver.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,17 @@ 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 necessary quantities (massflow, integrated heatflux, avg density)
70+
* for streamwise periodic cases. Also sets new delta P for prescribed massflow.
71+
* \param[in] geometry - Geometrical definition of the problem.
72+
* \param[in] config - Definition of the particular problem.
73+
* \param[in] iMesh - current mesh level for the multigrid.
74+
*/
75+
void GetStreamwise_Periodic_Properties(const CGeometry *geometry,
76+
CConfig *config,
77+
const unsigned short iMesh);
78+
6879
/*!
6980
* \brief Compute recovered pressure/temperature for streamwise periodic flow and store in CVariable.
7081
* \param[in] config - Definition of the particular problem.

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 0 additions & 154 deletions
Original file line numberDiff line numberDiff line change
@@ -2882,160 +2882,6 @@ void CIncEulerSolver::GetOutlet_Properties(CGeometry *geometry, CConfig *config,
28822882

28832883
}
28842884

2885-
void CIncEulerSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry,
2886-
CConfig *config,
2887-
const unsigned short iMesh) {
2888-
2889-
/*---------------------------------------------------------------------------------------------*/
2890-
// 1. Evaluate massflow, area avg density & Temperature and Area at streamwise periodic outlet.
2891-
// 2. Update delta_p is target massflow is chosen.
2892-
// 3. Loop Heatflux markers and integrate heat across the boundary. Only if energy equation is on.
2893-
/*---------------------------------------------------------------------------------------------*/
2894-
2895-
/*-------------------------------------------------------------------------------------------------*/
2896-
/*--- 1. Evaluate Massflow [kg/s], area-averaged density [kg/m^3] and Area [m^2] at the ---*/
2897-
/*--- (there can be only one) streamwise periodic outlet/donor marker. Massflow is obviously ---*/
2898-
/*--- needed for prescribed massflow but also for the additional source and heatflux ---*/
2899-
/*--- boundary terms of the energy equation. Area and the avg-density are used for the ---*/
2900-
/*--- Pressure-Drop update in case of a prescribed massflow. ---*/
2901-
/*-------------------------------------------------------------------------------------------------*/
2902-
2903-
const auto nZone = geometry->GetnZone();
2904-
const auto InnerIter = config->GetInnerIter();
2905-
const auto OuterIter = config->GetOuterIter();
2906-
2907-
su2double Area_Local = 0.0,
2908-
MassFlow_Local = 0.0,
2909-
Average_Density_Local = 0.0,
2910-
Temperature_Local = 0.0;
2911-
2912-
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
2913-
2914-
/*--- Only "outlet"/donor periodic marker ---*/
2915-
if (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY &&
2916-
config->GetMarker_All_PerBound(iMarker) == 2) {
2917-
2918-
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
2919-
2920-
auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
2921-
2922-
if (geometry->nodes->GetDomain(iPoint)) {
2923-
2924-
/*--- A = dot_prod(n_A*n_A), with n_A beeing the area-normal. ---*/
2925-
2926-
const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal();
2927-
2928-
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
2929-
2930-
/*--- m_dot = dot_prod(n*v) * A * rho, with n beeing unit normal. ---*/
2931-
MassFlow_Local += nodes->GetProjVel(iPoint, AreaNormal) * nodes->GetDensity(iPoint);
2932-
2933-
Area_Local += FaceArea;
2934-
2935-
Average_Density_Local += FaceArea * nodes->GetDensity(iPoint);
2936-
2937-
/*--- Due to periodicty, temperatures are equal one the inlet(1) and outlet(2) ---*/
2938-
Temperature_Local += FaceArea * nodes->GetTemperature(iPoint);
2939-
2940-
} // if domain
2941-
} // loop vertices
2942-
} // loop periodic boundaries
2943-
} // loop MarkerAll
2944-
2945-
// MPI Communication: Sum Area, Sum rho*A & T*A and divide by AreaGlobbal, sum massflow
2946-
su2double Area_Global(0), Average_Density_Global(0), MassFlow_Global(0), Temperature_Global(0);
2947-
SU2_MPI::Allreduce(&Area_Local, &Area_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
2948-
SU2_MPI::Allreduce(&Average_Density_Local, &Average_Density_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
2949-
SU2_MPI::Allreduce(&MassFlow_Local, &MassFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
2950-
SU2_MPI::Allreduce(&Temperature_Local, &Temperature_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
2951-
2952-
Average_Density_Global /= Area_Global;
2953-
Temperature_Global /= Area_Global;
2954-
2955-
/*--- Set solver variables ---*/
2956-
SPvals.Streamwise_Periodic_MassFlow = MassFlow_Global;
2957-
SPvals.Streamwise_Periodic_InletTemperature = Temperature_Global;
2958-
2959-
/*--- As deltaP changes with prescribed massflow the const config value should only be used once. ---*/
2960-
if((nZone==1 && InnerIter==0) ||
2961-
(nZone>1 && OuterIter==0 && InnerIter==0)) {
2962-
SPvals.Streamwise_Periodic_PressureDrop = config->GetStreamwise_Periodic_PressureDrop() / config->GetPressure_Ref();
2963-
}
2964-
2965-
if (config->GetKind_Streamwise_Periodic() == STREAMWISE_MASSFLOW) {
2966-
/*------------------------------------------------------------------------------------------------*/
2967-
/*--- 2. Update the Pressure Drop [Pa] for the Momentum source term if Massflow is prescribed. ---*/
2968-
/*--- The Pressure drop is iteratively adapted to result in the prescribed Target-Massflow. ---*/
2969-
/*------------------------------------------------------------------------------------------------*/
2970-
2971-
/*--- Load/define all necessary variables ---*/
2972-
const su2double TargetMassFlow = config->GetStreamwise_Periodic_TargetMassFlow() / (config->GetDensity_Ref() * config->GetVelocity_Ref());
2973-
const su2double damping_factor = config->GetInc_Outlet_Damping();
2974-
su2double Pressure_Drop_new, ddP;
2975-
2976-
/*--- Compute update to Delta p based on massflow-difference ---*/
2977-
ddP = 0.5 / ( Average_Density_Global * pow(Area_Global, 2)) * (pow(TargetMassFlow, 2) - pow(MassFlow_Global, 2));
2978-
2979-
/*--- Store updated pressure difference ---*/
2980-
Pressure_Drop_new = SPvals.Streamwise_Periodic_PressureDrop + damping_factor*ddP;
2981-
/*--- During restarts, this routine GetStreamwise_Periodic_Properties can get called multiple times
2982-
(e.g. 4x for INC_RANS restart). Each time, the pressure drop gets updated. For INC_RANS restarts
2983-
it gets called 2x before the restart files are read such that the current massflow is
2984-
Area*inital-velocity which can be way off!
2985-
With this there is still a slight inconsitency wrt to a non-restarted simulation: The restarted "zero-th"
2986-
iteration does not get a pressure-update but the continuing simulation would have an update here. This can be
2987-
fully neglected if the pressure drop is converged. And for all other cases it should be minor difference at
2988-
best ---*/
2989-
if((nZone==1 && InnerIter>0) ||
2990-
(nZone>1 && OuterIter>0)) {
2991-
SPvals.Streamwise_Periodic_PressureDrop = Pressure_Drop_new;
2992-
}
2993-
2994-
} // if massflow
2995-
2996-
2997-
if (config->GetEnergy_Equation()) {
2998-
/*---------------------------------------------------------------------------------------------*/
2999-
/*--- 3. Compute the integrated Heatflow [W] for the energy equation source term, heatflux ---*/
3000-
/*--- boundary term and recovered Temperature. The computation is not completely clear. ---*/
3001-
/*--- Here the Heatflux from all Bounary markers in the config-file is used. ---*/
3002-
/*---------------------------------------------------------------------------------------------*/
3003-
3004-
su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0;
3005-
3006-
/*--- Loop over all heatflux Markers ---*/
3007-
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
3008-
3009-
if (config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) {
3010-
3011-
/*--- Identify the boundary by string name and retrive heatflux from config ---*/
3012-
const auto Marker_StringTag = config->GetMarker_All_TagBound(iMarker);
3013-
const auto Wall_HeatFlux = config->GetWall_HeatFlux(Marker_StringTag);
3014-
3015-
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
3016-
3017-
auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
3018-
3019-
if (!geometry->nodes->GetDomain(iPoint)) continue;
3020-
3021-
const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal();
3022-
3023-
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
3024-
3025-
HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();;
3026-
} // loop Vertices
3027-
} // loop Heatflux marker
3028-
} // loop AllMarker
3029-
3030-
/*--- MPI Communication sum up integrated Heatflux from all processes ---*/
3031-
SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
3032-
3033-
/*--- Set the solver variable Integrated Heatflux ---*/
3034-
SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global;
3035-
} // if energy
3036-
}
3037-
3038-
30392885
void CIncEulerSolver::PrintVerificationError(const CConfig *config) const {
30402886

30412887
if ((rank != MASTER_NODE) || (MGLevel != MESH_0)) return;

SU2_CFD/src/solvers/CIncNSSolver.cpp

Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,160 @@ void CIncNSSolver::Preprocessing(CGeometry *geometry, CSolver **solver_container
102102
Compute_Streamwise_Periodic_Recovered_Values(config, geometry, iMesh);
103103
}
104104

105+
void CIncNSSolver::GetStreamwise_Periodic_Properties(const CGeometry *geometry,
106+
CConfig *config,
107+
const unsigned short iMesh) {
108+
109+
/*---------------------------------------------------------------------------------------------*/
110+
// 1. Evaluate massflow, area avg density & Temperature and Area at streamwise periodic outlet.
111+
// 2. Update delta_p is target massflow is chosen.
112+
// 3. Loop Heatflux markers and integrate heat across the boundary. Only if energy equation is on.
113+
/*---------------------------------------------------------------------------------------------*/
114+
115+
/*-------------------------------------------------------------------------------------------------*/
116+
/*--- 1. Evaluate Massflow [kg/s], area-averaged density [kg/m^3] and Area [m^2] at the ---*/
117+
/*--- (there can be only one) streamwise periodic outlet/donor marker. Massflow is obviously ---*/
118+
/*--- needed for prescribed massflow but also for the additional source and heatflux ---*/
119+
/*--- boundary terms of the energy equation. Area and the avg-density are used for the ---*/
120+
/*--- Pressure-Drop update in case of a prescribed massflow. ---*/
121+
/*-------------------------------------------------------------------------------------------------*/
122+
123+
const auto nZone = geometry->GetnZone();
124+
const auto InnerIter = config->GetInnerIter();
125+
const auto OuterIter = config->GetOuterIter();
126+
127+
su2double Area_Local = 0.0,
128+
MassFlow_Local = 0.0,
129+
Average_Density_Local = 0.0,
130+
Temperature_Local = 0.0;
131+
132+
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
133+
134+
/*--- Only "outlet"/donor periodic marker ---*/
135+
if (config->GetMarker_All_KindBC(iMarker) == PERIODIC_BOUNDARY &&
136+
config->GetMarker_All_PerBound(iMarker) == 2) {
137+
138+
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
139+
140+
auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
141+
142+
if (geometry->nodes->GetDomain(iPoint)) {
143+
144+
/*--- A = dot_prod(n_A*n_A), with n_A beeing the area-normal. ---*/
145+
146+
const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal();
147+
148+
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
149+
150+
/*--- m_dot = dot_prod(n*v) * A * rho, with n beeing unit normal. ---*/
151+
MassFlow_Local += nodes->GetProjVel(iPoint, AreaNormal) * nodes->GetDensity(iPoint);
152+
153+
Area_Local += FaceArea;
154+
155+
Average_Density_Local += FaceArea * nodes->GetDensity(iPoint);
156+
157+
/*--- Due to periodicty, temperatures are equal one the inlet(1) and outlet(2) ---*/
158+
Temperature_Local += FaceArea * nodes->GetTemperature(iPoint);
159+
160+
} // if domain
161+
} // loop vertices
162+
} // loop periodic boundaries
163+
} // loop MarkerAll
164+
165+
// MPI Communication: Sum Area, Sum rho*A & T*A and divide by AreaGlobbal, sum massflow
166+
su2double Area_Global(0), Average_Density_Global(0), MassFlow_Global(0), Temperature_Global(0);
167+
SU2_MPI::Allreduce(&Area_Local, &Area_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
168+
SU2_MPI::Allreduce(&Average_Density_Local, &Average_Density_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
169+
SU2_MPI::Allreduce(&MassFlow_Local, &MassFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
170+
SU2_MPI::Allreduce(&Temperature_Local, &Temperature_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
171+
172+
Average_Density_Global /= Area_Global;
173+
Temperature_Global /= Area_Global;
174+
175+
/*--- Set solver variables ---*/
176+
SPvals.Streamwise_Periodic_MassFlow = MassFlow_Global;
177+
SPvals.Streamwise_Periodic_InletTemperature = Temperature_Global;
178+
179+
/*--- As deltaP changes with prescribed massflow the const config value should only be used once. ---*/
180+
if((nZone==1 && InnerIter==0) ||
181+
(nZone>1 && OuterIter==0 && InnerIter==0)) {
182+
SPvals.Streamwise_Periodic_PressureDrop = config->GetStreamwise_Periodic_PressureDrop() / config->GetPressure_Ref();
183+
}
184+
185+
if (config->GetKind_Streamwise_Periodic() == STREAMWISE_MASSFLOW) {
186+
/*------------------------------------------------------------------------------------------------*/
187+
/*--- 2. Update the Pressure Drop [Pa] for the Momentum source term if Massflow is prescribed. ---*/
188+
/*--- The Pressure drop is iteratively adapted to result in the prescribed Target-Massflow. ---*/
189+
/*------------------------------------------------------------------------------------------------*/
190+
191+
/*--- Load/define all necessary variables ---*/
192+
const su2double TargetMassFlow = config->GetStreamwise_Periodic_TargetMassFlow() / (config->GetDensity_Ref() * config->GetVelocity_Ref());
193+
const su2double damping_factor = config->GetInc_Outlet_Damping();
194+
su2double Pressure_Drop_new, ddP;
195+
196+
/*--- Compute update to Delta p based on massflow-difference ---*/
197+
ddP = 0.5 / ( Average_Density_Global * pow(Area_Global, 2)) * (pow(TargetMassFlow, 2) - pow(MassFlow_Global, 2));
198+
199+
/*--- Store updated pressure difference ---*/
200+
Pressure_Drop_new = SPvals.Streamwise_Periodic_PressureDrop + damping_factor*ddP;
201+
/*--- During restarts, this routine GetStreamwise_Periodic_Properties can get called multiple times
202+
(e.g. 4x for INC_RANS restart). Each time, the pressure drop gets updated. For INC_RANS restarts
203+
it gets called 2x before the restart files are read such that the current massflow is
204+
Area*inital-velocity which can be way off!
205+
With this there is still a slight inconsitency wrt to a non-restarted simulation: The restarted "zero-th"
206+
iteration does not get a pressure-update but the continuing simulation would have an update here. This can be
207+
fully neglected if the pressure drop is converged. And for all other cases it should be minor difference at
208+
best ---*/
209+
if((nZone==1 && InnerIter>0) ||
210+
(nZone>1 && OuterIter>0)) {
211+
SPvals.Streamwise_Periodic_PressureDrop = Pressure_Drop_new;
212+
}
213+
214+
} // if massflow
215+
216+
217+
if (config->GetEnergy_Equation()) {
218+
/*---------------------------------------------------------------------------------------------*/
219+
/*--- 3. Compute the integrated Heatflow [W] for the energy equation source term, heatflux ---*/
220+
/*--- boundary term and recovered Temperature. The computation is not completely clear. ---*/
221+
/*--- Here the Heatflux from all Bounary markers in the config-file is used. ---*/
222+
/*---------------------------------------------------------------------------------------------*/
223+
224+
su2double HeatFlow_Local = 0.0, HeatFlow_Global = 0.0;
225+
226+
/*--- Loop over all heatflux Markers ---*/
227+
for (auto iMarker = 0; iMarker < config->GetnMarker_All(); iMarker++) {
228+
229+
if (config->GetMarker_All_KindBC(iMarker) == HEAT_FLUX) {
230+
231+
/*--- Identify the boundary by string name and retrive heatflux from config ---*/
232+
const auto Marker_StringTag = config->GetMarker_All_TagBound(iMarker);
233+
const auto Wall_HeatFlux = config->GetWall_HeatFlux(Marker_StringTag);
234+
235+
for (auto iVertex = 0ul; iVertex < geometry->nVertex[iMarker]; iVertex++) {
236+
237+
auto iPoint = geometry->vertex[iMarker][iVertex]->GetNode();
238+
239+
if (!geometry->nodes->GetDomain(iPoint)) continue;
240+
241+
const auto AreaNormal = geometry->vertex[iMarker][iVertex]->GetNormal();
242+
243+
auto FaceArea = GeometryToolbox::Norm(nDim, AreaNormal);
244+
245+
HeatFlow_Local += FaceArea * (-1.0) * Wall_HeatFlux/config->GetHeat_Flux_Ref();;
246+
} // loop Vertices
247+
} // loop Heatflux marker
248+
} // loop AllMarker
249+
250+
/*--- MPI Communication sum up integrated Heatflux from all processes ---*/
251+
SU2_MPI::Allreduce(&HeatFlow_Local, &HeatFlow_Global, 1, MPI_DOUBLE, MPI_SUM, SU2_MPI::GetComm());
252+
253+
/*--- Set the solver variable Integrated Heatflux ---*/
254+
SPvals.Streamwise_Periodic_IntegratedHeatFlow = HeatFlow_Global;
255+
} // if energy
256+
}
257+
258+
105259
void CIncNSSolver::Compute_Streamwise_Periodic_Recovered_Values(CConfig *config, const CGeometry *geometry,
106260
const unsigned short iMesh) {
107261

SU2_CFD/src/variables/CIncEulerVariable.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ CIncEulerVariable::CIncEulerVariable(su2double pressure, const su2double *veloci
9191

9292
Primitive.resize(nPoint,nPrimVar) = su2double(0.0);
9393

94-
/*--- Incompressible flow, gradients primitive variables nDim+6, (P, vx, vy, vz, T, rho, beta, lamMu, EddyMu) ---*/
94+
/*--- Incompressible flow, gradients primitive variables nDim+4, (P, vx, vy, vz, T, rho, beta) ---*/
9595

9696
if (config->GetMUSCL_Flow() || viscous) {
9797
Gradient_Primitive.resize(nPoint,nPrimVarGrad,nDim,0.0);

0 commit comments

Comments
 (0)