Skip to content

Commit 7a6ddfc

Browse files
Merge branch 'develop' into feature_preconditioning
2 parents 1cfbb67 + 764b3be commit 7a6ddfc

File tree

6 files changed

+79
-6
lines changed

6 files changed

+79
-6
lines changed

Common/include/CConfig.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,6 +1093,7 @@ class CConfig {
10931093
su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */
10941094
su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */
10951095
su2double Max_Vel2; /*!< \brief The maximum velocity^2 in the domain for the incompressible preconditioner. */
1096+
su2double RangePressure[2]; /*!< \brief The pressure difference pmax-pmin in the domain for the target mass flow rate scaling. */
10961097
bool topology_optimization; /*!< \brief If the structural solver should consider a variable density field to penalize element stiffness. */
10971098
string top_optim_output_file; /*!< \brief File to where the derivatives w.r.t. element densities will be written to. */
10981099
su2double simp_exponent; /*!< \brief Exponent for the density-based stiffness penalization of the SIMP method. */
@@ -9229,6 +9230,18 @@ class CConfig {
92299230
*/
92309231
void SetMax_Vel2(su2double val_max_vel2) { Max_Vel2 = val_max_vel2; }
92319232

9233+
/*!
9234+
* \brief Get the maximum pressure (pmax - pmin) in the domain.
9235+
* \return Value of the maximum pressure in the domain.
9236+
*/
9237+
su2double GetRangePressure(int minmax) const { return RangePressure[minmax]; }
9238+
9239+
/*!
9240+
* \brief Set the maximum pressure in the domain.
9241+
* \param[in] Value of the maximum pressure in the domain.
9242+
*/
9243+
void SetRangePressure(su2double val_dp_min,su2double val_dp_max) { RangePressure[0] = val_dp_min;RangePressure[1]=val_dp_max; }
9244+
92329245
/*!
92339246
* \brief Get the maximum velocity^2 in the domain for the incompressible preconditioner.
92349247
* \return Value of the maximum velocity^2 in the domain for the incompressible preconditioner.

SU2_CFD/include/solvers/CIncEulerSolver.hpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,18 @@ class CIncEulerSolver : public CFVMFlowSolverBase<CIncEulerVariable, ENUM_REGIME
9898
CConfig *config,
9999
unsigned short iMesh);
100100

101+
/*!
102+
* \brief Update the pressure range P_max - P_min for target mass flow rate.
103+
* \param[in] geometry - Geometrical definition of the problem.
104+
* \param[in] solver_container - Container vector with all the solutions.
105+
* \param[in] config - Definition of the particular problem.
106+
* \param[in] iMesh - current mesh level for the multigrid.
107+
*/
108+
void SetRangePressure(CGeometry *geometry,
109+
CSolver **solver_container,
110+
CConfig *config,
111+
unsigned short iMesh);
112+
101113
/*!
102114
* \brief A virtual member.
103115
*/

SU2_CFD/src/solvers/CIncEulerSolver.cpp

Lines changed: 51 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,10 @@ void CIncEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver_
996996

997997
SetBeta_Parameter(geometry, solver_container, config, iMesh);
998998

999+
/*--- Update the pressure range in the domain for target outflow mass flow rate. ---*/
1000+
1001+
SetRangePressure(geometry, solver_container, config, iMesh);
1002+
9991003
/*--- Compute properties needed for mass flow BCs. ---*/
10001004

10011005
if (outlet) {
@@ -2054,6 +2058,46 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co
20542058

20552059
}
20562060

2061+
void CIncEulerSolver::SetRangePressure(CGeometry *geometry, CSolver **solver_container,
2062+
CConfig *config, unsigned short iMesh) {
2063+
static su2double MinP, MaxP;
2064+
2065+
if (iMesh == MESH_0) {
2066+
SU2_OMP_MASTER {
2067+
MinP = std::numeric_limits<su2double>::max();
2068+
MaxP = std::numeric_limits<su2double>::lowest();
2069+
}
2070+
END_SU2_OMP_MASTER
2071+
su2double minP = std::numeric_limits<su2double>::max();
2072+
su2double maxP = std::numeric_limits<su2double>::lowest();
2073+
2074+
SU2_OMP_FOR_STAT(omp_chunk_size)
2075+
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
2076+
minP = min(minP, nodes->GetPressure(iPoint));
2077+
maxP = max(maxP, nodes->GetPressure(iPoint));
2078+
}
2079+
END_SU2_OMP_FOR
2080+
2081+
SU2_OMP_CRITICAL {
2082+
MinP = min(MinP, minP);
2083+
MaxP = max(MaxP, maxP);
2084+
}
2085+
END_SU2_OMP_CRITICAL
2086+
2087+
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
2088+
{
2089+
minP = MinP;
2090+
SU2_MPI::Allreduce(&minP, &MinP, 1, MPI_DOUBLE, MPI_MAX, SU2_MPI::GetComm());
2091+
maxP = MaxP;
2092+
SU2_MPI::Allreduce(&maxP, &MaxP, 1, MPI_DOUBLE, MPI_MAX, SU2_MPI::GetComm());
2093+
2094+
config->SetRangePressure(MinP,MaxP);
2095+
}
2096+
END_SU2_OMP_SAFE_GLOBAL_ACCESS
2097+
}
2098+
2099+
}
2100+
20572101
void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPoint,
20582102
su2double delta, su2activematrix& Preconditioner) const {
20592103

@@ -2676,10 +2720,14 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
26762720

26772721
dP = 0.5*Density_Avg*(mDot_Old*mDot_Old - mDot_Target*mDot_Target)/((Density_Avg*Area_Outlet)*(Density_Avg*Area_Outlet));
26782722

2679-
/*--- Update the new outlet pressure. Note that we use damping
2680-
here to improve stability/convergence. ---*/
2723+
su2double P_domain_min = config->GetRangePressure(0);
2724+
2725+
/*--- Do not relax when dP is relatively small compared to the pressure range dp = (P-P_min). ---*/
2726+
2727+
if (abs(dP) < abs(Damping * (P_domain-P_domain_min)))
2728+
Damping = 1.0;
26812729

2682-
P_Outlet = P_domain + Damping*dP;
2730+
P_Outlet = P_domain + Damping * dP;
26832731

26842732
/*--- The pressure is prescribed at the outlet. ---*/
26852733

TestCases/hybrid_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ def main():
352352
inc_nozzle.cfg_dir = "incomp_euler/nozzle"
353353
inc_nozzle.cfg_file = "inv_nozzle.cfg"
354354
inc_nozzle.test_iter = 20
355-
inc_nozzle.test_vals = [-6.595923, -5.820518, -0.018365, 0.126411]
355+
inc_nozzle.test_vals = [-6.593521, -5.830706, -0.009062, 0.126050]
356356
inc_nozzle.test_vals_aarch64 = [-5.624385, -4.988472, -0.000096, 0.137032]
357357
test_list.append(inc_nozzle)
358358

TestCases/parallel_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,7 @@ def main():
566566
inc_nozzle.cfg_dir = "incomp_euler/nozzle"
567567
inc_nozzle.cfg_file = "inv_nozzle.cfg"
568568
inc_nozzle.test_iter = 20
569-
inc_nozzle.test_vals = [-6.576818, -5.796867, -0.003141, 0.126481]
569+
inc_nozzle.test_vals = [-6.407323, -5.715668, -0.003225, 0.126214]
570570
test_list.append(inc_nozzle)
571571

572572
# Laminar wall mounted cylinder, Euler walls, cylinder wall diagonally split

TestCases/serial_regression.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ def main():
379379
inc_nozzle.cfg_dir = "incomp_euler/nozzle"
380380
inc_nozzle.cfg_file = "inv_nozzle.cfg"
381381
inc_nozzle.test_iter = 20
382-
inc_nozzle.test_vals = [-6.623301, -5.844127, -0.023181, 0.126370]
382+
inc_nozzle.test_vals = [-5.394788, -4.869896, -0.021578, 0.125704]
383383
test_list.append(inc_nozzle)
384384

385385
#############################

0 commit comments

Comments
 (0)