Skip to content

Commit 5cbf7a2

Browse files
Merge branch 'develop' into fix_unsteady_flamelet
2 parents 899ab14 + 7dc5e69 commit 5cbf7a2

60 files changed

Lines changed: 3612 additions & 1827 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎AUTHORS.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Alessandro Gastaldi
5050
Aman uz zaman Baig
5151
Amit Sachdeva
5252
Ana Lourenco
53+
Andrea Rausa
5354
Andrew Burkett
5455
Andrew Wendorff
5556
Angelo Passariello

‎Common/include/CConfig.hpp‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ class CConfig {
516516
Kind_SlopeLimit_Turb, /*!< \brief Slope limiter for the turbulence equation.*/
517517
Kind_SlopeLimit_AdjTurb, /*!< \brief Slope limiter for the adjoint turbulent equation.*/
518518
Kind_SlopeLimit_AdjFlow, /*!< \brief Slope limiter for the adjoint equation.*/
519-
Kind_SlopeLimit_Heat, /*!< \brief Slope limiter for the adjoint equation.*/
519+
Kind_SlopeLimit_Heat, /*!< \brief Slope limiter for the heat equation.*/
520520
Kind_SlopeLimit_Species; /*!< \brief Slope limiter for the species equation.*/
521521
LINEAR_SOLVER_INNER Kind_Linear_Solver_Inner; /*!< \brief Inner solver used in nested Krylov schemes. */
522522
unsigned short Kind_FluidModel, /*!< \brief Kind of the Fluid Model: Ideal, van der Waals, etc. */
@@ -5074,6 +5074,12 @@ class CConfig {
50745074
*/
50755075
LIMITER GetKind_SlopeLimit_Species() const { return Kind_SlopeLimit_Species; }
50765076

5077+
/*!
5078+
* \brief Get the method for limiting the spatial gradients.
5079+
* \return Method for limiting the spatial gradients solving the heat equation.
5080+
*/
5081+
LIMITER GetKind_SlopeLimit_Heat() const { return Kind_SlopeLimit_Heat; }
5082+
50775083
/*!
50785084
* \brief Get the method for limiting the spatial gradients.
50795085
* \return Method for limiting the spatial gradients solving the adjoint turbulent equation.

‎Common/src/CConfig.cpp‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4002,6 +4002,27 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
40024002
if (!MUSCL_AdjFlow || (Kind_ConvNumScheme_AdjFlow == SPACE_CENTERED)) Kind_SlopeLimit_AdjFlow = LIMITER::NONE;
40034003
if (!MUSCL_AdjTurb || (Kind_ConvNumScheme_AdjTurb == SPACE_CENTERED)) Kind_SlopeLimit_AdjTurb = LIMITER::NONE;
40044004

4005+
/*--- The SHARP_EDGES and WALL_DISTANCE limiters are first order within a distance proportional to
4006+
* VENKAT_LIMITER_COEFF * ADJ_SHARP_LIMITER_COEFF, with a zero width they are first order everywhere.
4007+
* Only the limiters of the active equations are checked. ---*/
4008+
const bool turb = Kind_Turb_Model != TURB_MODEL::NONE;
4009+
const bool heat =
4010+
Weakly_Coupled_Heat || Kind_Solver == MAIN_SOLVER::HEAT_EQUATION || Kind_Solver == MAIN_SOLVER::DISC_ADJ_HEAT;
4011+
vector<LIMITER> activeLimiters = {Kind_SlopeLimit_Flow};
4012+
if (turb) activeLimiters.push_back(Kind_SlopeLimit_Turb);
4013+
if (Kind_Species_Model != SPECIES_MODEL::NONE) activeLimiters.push_back(Kind_SlopeLimit_Species);
4014+
if (heat) activeLimiters.push_back(Kind_SlopeLimit_Heat);
4015+
if (ContinuousAdjoint) activeLimiters.push_back(Kind_SlopeLimit_AdjFlow);
4016+
if (ContinuousAdjoint && turb) activeLimiters.push_back(Kind_SlopeLimit_AdjTurb);
4017+
for (const auto kind : activeLimiters) {
4018+
if ((kind == LIMITER::SHARP_EDGES || kind == LIMITER::WALL_DISTANCE) &&
4019+
!(Venkat_LimiterCoeff > 0.0 && AdjSharp_LimiterCoeff > 0.0)) {
4020+
SU2_MPI::Error("The SHARP_EDGES and WALL_DISTANCE slope limiters need VENKAT_LIMITER_COEFF > 0 and\n"
4021+
"ADJ_SHARP_LIMITER_COEFF > 0 (they set the width of the region limited to first order).",
4022+
CURRENT_FUNCTION);
4023+
}
4024+
}
4025+
40054026
/*--- Set the default for thrust in ActDisk ---*/
40064027

40074028
if ((Kind_ActDisk == NET_THRUST) || (Kind_ActDisk == BC_THRUST)
@@ -4706,6 +4727,36 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
47064727

47074728
Rotating_Frame = (Kind_GridMovement == ROTATING_FRAME);
47084729

4730+
/*--- The finite volume flow solvers apply these source terms with a single numerics object, which is built
4731+
for only one of them: combinations would apply one source several times and ignore the others. Only these
4732+
solvers (and their discrete adjoints) are checked: e.g. elasticity uses BODY_FORCE and GRAVITY_FORCE together. ---*/
4733+
4734+
if (GetFluidProblem() && !GetNEMOProblem()) {
4735+
const bool inc = (Kind_Regime == ENUM_REGIME::INCOMPRESSIBLE);
4736+
const int nSources = int(Body_Force) + int(Rotating_Frame) + int(Axisymmetric) + int(GravityForce && !inc) +
4737+
int(inc && Kind_DensityModel == INC_DENSITYMODEL::BOUSSINESQ) +
4738+
int(inc && Kind_Streamwise_Periodic != ENUM_STREAMWISE_PERIODIC::NONE);
4739+
if (nSources > 1) {
4740+
SU2_MPI::Error("Only one of BODY_FORCE, GRID_MOVEMENT= ROTATING_FRAME, AXISYMMETRIC, GRAVITY_FORCE (compressible), "
4741+
"INC_DENSITY_MODEL= BOUSSINESQ and KIND_STREAMWISE_PERIODIC (incompressible) can be used at a time.",
4742+
CURRENT_FUNCTION);
4743+
}
4744+
}
4745+
4746+
/*--- The second source object, for radiation, the energy correction of incompressible streamwise periodic flow
4747+
(without periodic temperature) or vorticity confinement, is also built for only one of them. ---*/
4748+
4749+
if (GetFluidProblem() && !GetNEMOProblem()) {
4750+
const bool inc = (Kind_Regime == ENUM_REGIME::INCOMPRESSIBLE);
4751+
const bool periodicOutlet = inc && Kind_Streamwise_Periodic != ENUM_STREAMWISE_PERIODIC::NONE && Energy_Equation &&
4752+
!Streamwise_Periodic_Temperature;
4753+
if (int(Radiation) + int(periodicOutlet) + int(VorticityConfinement) > 1) {
4754+
SU2_MPI::Error("Only one of RADIATION, the energy correction of KIND_STREAMWISE_PERIODIC (incompressible, "
4755+
"STREAMWISE_PERIODIC_TEMPERATURE= NO) and VORTICITY_CONFINEMENT can be used at a time.",
4756+
CURRENT_FUNCTION);
4757+
}
4758+
}
4759+
47094760
/*--- In case the grid movement parameters have not been declared in the
47104761
config file, set them equal to zero for safety. Also check to make sure
47114762
that for each option, a value has been declared for each moving marker. ---*/
@@ -5065,6 +5116,11 @@ void CConfig::SetPostprocessing(SU2_COMPONENT val_software, unsigned short val_i
50655116

50665117
if (Restart || ((Kind_MGCycle == MG_CYCLE::FULL) && ContinuousAdjoint)) Kind_MGCycle = MG_CYCLE::V;
50675118

5119+
/*--- The multigrid arrays hold at most 10 coarse levels (CMultiGridIntegration::MAX_MG_LEVELS). ---*/
5120+
if (nMGLevels > 10) {
5121+
SU2_MPI::Error("MGLEVEL must be between 0 and 10; larger multigrid hierarchies are not supported.", CURRENT_FUNCTION);
5122+
}
5123+
50685124
FinestMesh = MESH_0;
50695125
if (Kind_MGCycle == MG_CYCLE::FULL) FinestMesh = nMGLevels;
50705126

‎Common/src/geometry/CGeometry.cpp‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4542,12 +4542,30 @@ su2double NearestNeighborDistance(CGeometry* geometry, const CConfig* config, co
45424542
const su2double Vol = geometry->nodes->GetVolume(iPoint) + geometry->nodes->GetPeriodicVolume(iPoint);
45434543
return 2 * Vol / GeometryToolbox::Norm(3, Normal);
45444544
}
4545+
4546+
/*--- Whether any equation system of a zone uses the WALL_DISTANCE slope limiter. ---*/
4547+
bool UsesWallDistanceLimiter(const CConfig* config) {
4548+
constexpr auto wall = LIMITER::WALL_DISTANCE;
4549+
const bool turb = config->GetKind_Turb_Model() != TURB_MODEL::NONE;
4550+
const bool species = config->GetKind_Species_Model() != SPECIES_MODEL::NONE;
4551+
const bool heat = config->GetWeakly_Coupled_Heat() || config->GetKind_Solver() == MAIN_SOLVER::HEAT_EQUATION ||
4552+
config->GetKind_Solver() == MAIN_SOLVER::DISC_ADJ_HEAT;
4553+
const bool adjoint = config->GetContinuous_Adjoint();
4554+
const bool flowLimiter = config->GetKind_SlopeLimit_Flow() == wall;
4555+
const bool turbLimiter = turb && config->GetKind_SlopeLimit_Turb() == wall;
4556+
const bool speciesLimiter = species && config->GetKind_SlopeLimit_Species() == wall;
4557+
const bool heatLimiter = heat && config->GetKind_SlopeLimit_Heat() == wall;
4558+
const bool adjFlowLimiter = adjoint && config->GetKind_SlopeLimit_AdjFlow() == wall;
4559+
const bool adjTurbLimiter = adjoint && turb && config->GetKind_SlopeLimit_AdjTurb() == wall;
4560+
return flowLimiter || turbLimiter || speciesLimiter || heatLimiter || adjFlowLimiter || adjTurbLimiter;
4561+
}
45454562
} // namespace
45464563

45474564
void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeometry**** geometry_container,
45484565
const int record_zone) {
45494566
int nZone = config_container[ZONE_0]->GetnZone();
45504567
bool allEmpty = true;
4568+
bool limiterNeedsWalls = false;
45514569
vector<bool> wallDistanceNeeded(nZone, false);
45524570

45534571
for (int iInst = 0; iInst < config_container[ZONE_0]->GetnTimeInstances(); iInst++) {
@@ -4561,6 +4579,12 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo
45614579
wallDistanceNeeded[iZone] = true;
45624580
}
45634581

4582+
/*--- The WALL_DISTANCE slope limiter also needs it (without it, it limits to first order everywhere). ---*/
4583+
if (UsesWallDistanceLimiter(config_container[iZone])) {
4584+
wallDistanceNeeded[iZone] = true;
4585+
limiterNeedsWalls = true;
4586+
}
4587+
45644588
/*--- Set the wall distances in all zones to the numerical limit.
45654589
* This is necessary, because before a computed distance is set, it will be checked
45664590
* whether the new distance is smaller than the currently stored one. ---*/
@@ -4586,6 +4610,10 @@ void CGeometry::ComputeWallDistance(const CConfig* const* config_container, CGeo
45864610
/*--- Without viscous walls every point is far from a wall. The distance is large but finite,
45874611
* so that its square does not overflow, and the turbulence models take their free-shear limit. ---*/
45884612
if (allEmpty) {
4613+
if (limiterNeedsWalls) {
4614+
SU2_MPI::Error("The WALL_DISTANCE slope limiter needs viscous walls (it limits to first order near them).",
4615+
CURRENT_FUNCTION);
4616+
}
45894617
constexpr passivedouble noWallDistance = 1e15;
45904618
for (int iZone = 0; iZone < nZone; iZone++) {
45914619
CGeometry* geometry = geometry_container[iZone][iInst][MESH_0];

‎SU2_CFD/flamelet_python_bc.md‎

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This document explains how to use the Python wrapper (`pysu2`) to set
44
custom per-vertex boundary conditions for the flamelet (FGM) scalar transport
5-
solver, and how the setup differs between the two `FLAMELET_ENTHALPY_BC` modes.
5+
solver, and how the setup differs between the two `FLAME_ENTHALPY_BC` modes.
66

77
---
88

@@ -20,15 +20,15 @@ The flamelet solver transports `nVar` scalar variables. Their order is:
2020
Two modes control how the enthalpy boundary condition is derived at thermal
2121
walls (`MARKER_ISOTHERMAL`, `MARKER_HEATFLUX`):
2222

23-
- **`FLOW_MARKERS`** — enthalpy is derived from the flow thermal field (wall
23+
- **`FLOW_MARKERS`** (default) — enthalpy is derived from the flow thermal field (wall
2424
temperature via `MARKER_ISOTHERMAL`, or wall heat flux via `MARKER_HEATFLUX`).
25-
- **`SPECIES_MARKERS`** (default) — enthalpy and all other scalars are taken
25+
- **`SPECIES_MARKERS`** — enthalpy and all other scalars are taken
2626
directly from `MARKER_WALL_SPECIES`, or from the Python wrapper when
2727
`MARKER_PYTHON_CUSTOM` is active.
2828

2929
---
3030

31-
## Mode 1: `FLAMELET_ENTHALPY_BC = FLOW_MARKERS`
31+
## Mode 1: `FLAME_ENTHALPY_BC = FLOW_MARKERS` (default)
3232

3333
### How it works
3434

@@ -57,7 +57,7 @@ driver.SetMarkerCustomNormalHeatFlux(iMarker, iVertex, q_wall)
5757
### config.cfg
5858

5959
```cfg
60-
FLAMELET_ENTHALPY_BC = FLOW_MARKERS
60+
FLAME_ENTHALPY_BC = FLOW_MARKERS
6161
6262
% Flow solver wall BC — sets KindBC and provides the fallback heat flux value
6363
% used when MARKER_PYTHON_CUSTOM is not active.
@@ -103,7 +103,7 @@ driver.Finalize()
103103

104104
---
105105

106-
## Mode 2: `FLAMELET_ENTHALPY_BC = SPECIES_MARKERS` (default)
106+
## Mode 2: `FLAME_ENTHALPY_BC = SPECIES_MARKERS`
107107

108108
### How it works
109109

@@ -129,7 +129,7 @@ Adjust the number of `BC_TYPE, value` pairs to match the actual number of
129129
scalar variables in your setup.
130130

131131
```cfg
132-
FLAMELET_ENTHALPY_BC = SPECIES_MARKERS
132+
FLAME_ENTHALPY_BC = SPECIES_MARKERS
133133
134134
% Flow solver wall BC — still required to set KindBC.
135135
% The choice between MARKER_ISOTHERMAL and MARKER_HEATFLUX only affects
@@ -222,4 +222,4 @@ driver.Finalize()
222222
should receive `0.0` unless you intentionally want a non-zero flux there.
223223
- The `CHT` (conjugate heat transfer) path (`BC_ConjugateHeat_Interface`)
224224
always uses `BC_Isothermal_Wall_Generic` and is unaffected by
225-
`FLAMELET_ENTHALPY_BC`. Python custom BCs are not applicable to CHT markers.
225+
`FLAME_ENTHALPY_BC`. Python custom BCs are not applicable to CHT markers.

‎SU2_CFD/include/drivers/CDriver.hpp‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,13 @@ class CDriver : public CDriverBase {
423423
*/
424424
virtual void StartSolver() {}
425425

426+
/*!
427+
* \brief Stop with an error if a steady run ends while a static-pressure outlet still uses a fallback state
428+
* (sonic-limited backflow or the interior state).
429+
* \note Called at the end of StartSolver; Python scripts that run the iterations themselves should call it too.
430+
*/
431+
void CheckPressureOutletFallbacks() const;
432+
426433
/*!
427434
* \brief Deallocation routine
428435
*/

‎SU2_CFD/include/gradients/computeGradientsGreenGauss.hpp‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,14 @@ void computeGradientsGreenGauss(CSolver* solver, MPI_QUANTITIES kindMpiComm, PER
6969
const auto chunkSize = computeStaticChunkSize(nPointDomain, omp_get_max_threads(), OMP_MAX_CHUNK);
7070
#endif
7171

72-
static constexpr size_t MAXNVAR = 20;
72+
static constexpr size_t MAXNVAR = 32;
73+
74+
/*--- Called by all threads of a parallel region: only the master may call MPI (MPI_THREAD_FUNNELED). ---*/
75+
if (varEnd > MAXNVAR) {
76+
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
77+
SU2_MPI::Error("Number of variables is too large, increase MAXNVAR.", CURRENT_FUNCTION);
78+
END_SU2_OMP_SAFE_GLOBAL_ACCESS
79+
}
7380

7481
/*--- For each (non-halo) volume integrate over its faces (edges). ---*/
7582

‎SU2_CFD/include/limiters/CLimiterDetails.hpp‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ struct LimiterHelpers
132132
if(Dp>(2.0*Dm)) return 1.0;
133133
Type y = pow(Dp, 4) + epsp;
134134
Type S4 = 2.0*Dm*(Dp*Dp-2.0*Dm*(Dp-2.0*Dm));
135-
return (y + Dp*S4) / (y + Dm*(pow(delta,3)+S4));
135+
return (y + Dp*S4) / (y + Dm*(pow(Dp,3)+S4));
136136
}
137137

138138
FORCEINLINE static Type r5Function(const Type& proj, const Type& delta, const Type& epsp)

‎SU2_CFD/include/limiters/computeLimiters_impl.hpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ void computeLimiters_impl(CSolver* solver,
8686
constexpr size_t MAXNVAR = 32;
8787
static_assert(MAXNVAR >= MAX_TRANSPORTED_SPECIES, "MAXNVAR (size of the limiter work arrays) must be at least MAX_TRANSPORTED_SPECIES.");
8888

89-
if (varEnd > MAXNVAR)
89+
/*--- Called by all threads of a parallel region: only the master may call MPI (MPI_THREAD_FUNNELED). ---*/
90+
if (varEnd > MAXNVAR) {
91+
BEGIN_SU2_OMP_SAFE_GLOBAL_ACCESS
9092
SU2_MPI::Error("Number of variables is too large, increase MAXNVAR.", CURRENT_FUNCTION);
93+
END_SU2_OMP_SAFE_GLOBAL_ACCESS
94+
}
9195

9296
const size_t nPointDomain = geometry.GetnPointDomain();
9397
const size_t nPoint = geometry.GetnPoint();

‎SU2_CFD/include/numerics/turbulent/turb_sources.hpp‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1021,6 +1021,12 @@ class CSourcePieceWise_TurbSST final : public CNumerics {
10211021

10221022
Jacobian_i[0][0] = -beta_star * ScalarVar_i[1] * Volume * (1.0 + zetaFMt);
10231023
Jacobian_i[0][1] = -beta_star * ScalarVar_i[0] * Volume * (1.0 + zetaFMt);
1024+
/*--- Same LM scaling of dk as in the residual. ---*/
1025+
if (config->GetKind_Trans_Model() == TURB_TRANS_MODEL::LM) {
1026+
const su2double dk_factor = min(max(eff_intermittency, 0.1), 1.0);
1027+
Jacobian_i[0][0] *= dk_factor;
1028+
Jacobian_i[0][1] *= dk_factor;
1029+
}
10241030
Jacobian_i[1][0] = 0.0;
10251031
Jacobian_i[1][1] = -2.0 * beta_blended * ScalarVar_i[1] * Volume * (1.0 - 0.09/beta_blended * zetaFMt);
10261032

0 commit comments

Comments
 (0)