Skip to content

Commit 764b3be

Browse files
Fix damping mass outlet (#2516)
* modifications for damping factor Co-authored-by: Pedro Gomes <[email protected]>
1 parent 1c6ce32 commit 764b3be

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
@@ -1092,6 +1092,7 @@ class CConfig {
10921092
su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */
10931093
su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */
10941094
su2double Max_Vel2; /*!< \brief The maximum velocity^2 in the domain for the incompressible preconditioner. */
1095+
su2double RangePressure[2]; /*!< \brief The pressure difference pmax-pmin in the domain for the target mass flow rate scaling. */
10951096
bool topology_optimization; /*!< \brief If the structural solver should consider a variable density field to penalize element stiffness. */
10961097
string top_optim_output_file; /*!< \brief File to where the derivatives w.r.t. element densities will be written to. */
10971098
su2double simp_exponent; /*!< \brief Exponent for the density-based stiffness penalization of the SIMP method. */
@@ -9222,6 +9223,18 @@ class CConfig {
92229223
*/
92239224
void SetMax_Vel2(su2double val_max_vel2) { Max_Vel2 = val_max_vel2; }
92249225

9226+
/*!
9227+
* \brief Get the maximum pressure (pmax - pmin) in the domain.
9228+
* \return Value of the maximum pressure in the domain.
9229+
*/
9230+
su2double GetRangePressure(int minmax) const { return RangePressure[minmax]; }
9231+
9232+
/*!
9233+
* \brief Set the maximum pressure in the domain.
9234+
* \param[in] Value of the maximum pressure in the domain.
9235+
*/
9236+
void SetRangePressure(su2double val_dp_min,su2double val_dp_max) { RangePressure[0] = val_dp_min;RangePressure[1]=val_dp_max; }
9237+
92259238
/*!
92269239
* \brief Get the maximum velocity^2 in the domain for the incompressible preconditioner.
92279240
* \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
@@ -985,6 +985,10 @@ void CIncEulerSolver::CommonPreprocessing(CGeometry *geometry, CSolver **solver_
985985

986986
SetBeta_Parameter(geometry, solver_container, config, iMesh);
987987

988+
/*--- Update the pressure range in the domain for target outflow mass flow rate. ---*/
989+
990+
SetRangePressure(geometry, solver_container, config, iMesh);
991+
988992
/*--- Compute properties needed for mass flow BCs. ---*/
989993

990994
if (outlet) {
@@ -1974,6 +1978,46 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co
19741978

19751979
}
19761980

1981+
void CIncEulerSolver::SetRangePressure(CGeometry *geometry, CSolver **solver_container,
1982+
CConfig *config, unsigned short iMesh) {
1983+
static su2double MinP, MaxP;
1984+
1985+
if (iMesh == MESH_0) {
1986+
SU2_OMP_MASTER {
1987+
MinP = std::numeric_limits<su2double>::max();
1988+
MaxP = std::numeric_limits<su2double>::lowest();
1989+
}
1990+
END_SU2_OMP_MASTER
1991+
su2double minP = std::numeric_limits<su2double>::max();
1992+
su2double maxP = std::numeric_limits<su2double>::lowest();
1993+
1994+
SU2_OMP_FOR_STAT(omp_chunk_size)
1995+
for (auto iPoint = 0ul; iPoint < nPoint; iPoint++) {
1996+
minP = min(minP, nodes->GetPressure(iPoint));
1997+
maxP = max(maxP, nodes->GetPressure(iPoint));
1998+
}
1999+
END_SU2_OMP_FOR
2000+
2001+
SU2_OMP_CRITICAL {
2002+
MinP = min(MinP, minP);
2003+
MaxP = max(MaxP, maxP);
2004+
}
2005+
END_SU2_OMP_CRITICAL
2006+
2007+
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
2008+
{
2009+
minP = MinP;
2010+
SU2_MPI::Allreduce(&minP, &MinP, 1, MPI_DOUBLE, MPI_MAX, SU2_MPI::GetComm());
2011+
maxP = MaxP;
2012+
SU2_MPI::Allreduce(&maxP, &MaxP, 1, MPI_DOUBLE, MPI_MAX, SU2_MPI::GetComm());
2013+
2014+
config->SetRangePressure(MinP,MaxP);
2015+
}
2016+
END_SU2_OMP_SAFE_GLOBAL_ACCESS
2017+
}
2018+
2019+
}
2020+
19772021
void CIncEulerSolver::SetPreconditioner(const CConfig *config, unsigned long iPoint,
19782022
su2double delta, su2activematrix& Preconditioner) const {
19792023

@@ -2556,10 +2600,14 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
25562600

25572601
dP = 0.5*Density_Avg*(mDot_Old*mDot_Old - mDot_Target*mDot_Target)/((Density_Avg*Area_Outlet)*(Density_Avg*Area_Outlet));
25582602

2559-
/*--- Update the new outlet pressure. Note that we use damping
2560-
here to improve stability/convergence. ---*/
2603+
su2double P_domain_min = config->GetRangePressure(0);
2604+
2605+
/*--- Do not relax when dP is relatively small compared to the pressure range dp = (P-P_min). ---*/
2606+
2607+
if (abs(dP) < abs(Damping * (P_domain-P_domain_min)))
2608+
Damping = 1.0;
25612609

2562-
P_Outlet = P_domain + Damping*dP;
2610+
P_Outlet = P_domain + Damping * dP;
25632611

25642612
/*--- The pressure is prescribed at the outlet. ---*/
25652613

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)