Skip to content

Commit d78310d

Browse files
committed
add reference min and max pressure
1 parent fad3374 commit d78310d

File tree

3 files changed

+87
-2
lines changed

3 files changed

+87
-2
lines changed

Common/include/CConfig.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,7 @@ class CConfig {
10851085
su2double *FreeStreamTurboNormal; /*!< \brief Direction to initialize the flow in turbomachinery computation */
10861086
su2double Restart_Bandwidth_Agg; /*!< \brief The aggregate of the bandwidth for writing binary restarts (to be averaged later). */
10871087
su2double Max_Vel2; /*!< \brief The maximum velocity^2 in the domain for the incompressible preconditioner. */
1088+
su2double Range_Pressure[2]; /*!< \brief The pressure difference pmax-pmin in the domain for the target mass flow rate scaling. */
10881089
bool topology_optimization; /*!< \brief If the structural solver should consider a variable density field to penalize element stiffness. */
10891090
string top_optim_output_file; /*!< \brief File to where the derivatives w.r.t. element densities will be written to. */
10901091
su2double simp_exponent; /*!< \brief Exponent for the density-based stiffness penalization of the SIMP method. */
@@ -9173,6 +9174,18 @@ class CConfig {
91739174
*/
91749175
void SetMax_Vel2(su2double val_max_vel2) { Max_Vel2 = val_max_vel2; }
91759176

9177+
/*!
9178+
* \brief Get the maximum pressure (pmax - pmin) in the domain.
9179+
* \return Value of the maximum pressure in the domain.
9180+
*/
9181+
su2double GetRange_Pressure(int minmax) const { return Range_Pressure[minmax]; }
9182+
9183+
/*!
9184+
* \brief Set the maximum pressure in the domain.
9185+
* \param[in] Value of the maximum pressure in the domain.
9186+
*/
9187+
void SetRange_Pressure(su2double val_dp_min,su2double val_dp_max) { Range_Pressure[0] = val_dp_min;Range_Pressure[1]=val_dp_max; }
9188+
91769189
/*!
91779190
* \brief Get the maximum velocity^2 in the domain for the incompressible preconditioner.
91789191
* \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 SetRange_Pressure(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: 62 additions & 2 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+
SetRange_Pressure(geometry, solver_container, config, iMesh);
991+
988992
/*--- Compute properties needed for mass flow BCs. ---*/
989993

990994
if (outlet) {
@@ -1972,6 +1976,45 @@ void CIncEulerSolver::SetBeta_Parameter(CGeometry *geometry, CSolver **solver_co
19721976

19731977
}
19741978

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

@@ -2554,8 +2597,25 @@ void CIncEulerSolver::BC_Outlet(CGeometry *geometry, CSolver **solver_container,
25542597

25552598
dP = 0.5*Density_Avg*(mDot_Old*mDot_Old - mDot_Target*mDot_Target)/((Density_Avg*Area_Outlet)*(Density_Avg*Area_Outlet));
25562599

2557-
/*--- Do not relax when dP is relatively small compared to P itself. ---*/
2558-
if (abs(dP) < abs(Damping * P_domain))
2600+
su2double P_domain_min = config->GetRange_Pressure(0);
2601+
//su2double P_domain_max = config->GetRange_Pressure(1);
2602+
//su2double P_domain_range = P_domain_max - P_domain_min;
2603+
2604+
/*--- Do not relax when dP is relatively small compared to the pressure range dp = (P_max-P_min). ---*/
2605+
2606+
/*
2607+
We take the entire range of pressures and we check the relative P and the relative dp
2608+
1. is it sufficient to subtract the min pressure?
2609+
range [0..1]
2610+
range [-1..0]
2611+
range [0..10]
2612+
range [-10..0]
2613+
range [10..11]
2614+
range [-11..10]]
2615+
*/
2616+
2617+
//if (abs(dP) < abs(Damping * (P_domain-P_domain_min)/P_domain_range))
2618+
if (abs(dP) < abs(Damping * (P_domain-P_domain_min)))
25592619
Damping = 1.0;
25602620

25612621
P_Outlet = P_domain + Damping * dP;

0 commit comments

Comments
 (0)