Skip to content

Commit 165cf36

Browse files
committed
fix: Address reviewer feedback on wall model bug fixes
Wall model (wall_model.cpp): - Use fmax(x, 1e-16) in denominator for convergence check - Use fmin(Gamma, -1e-16) in exp denominator (Gamma is always negative) Reverted changes per reviewer request: - CPhysicalGeometry.cpp: Revert to original strcpy (don't complicate) - CSolver.cpp: Revert ITER offset to 9 (original author had reason) - CRadP1Solver.cpp: Remove emissivity validation (should be in CConfig) Signed-off-by: shbhmexe <[email protected]>
2 parents 2238d81 + dac92cc commit 165cf36

File tree

4 files changed

+9
-54
lines changed

4 files changed

+9
-54
lines changed

Common/src/geometry/CPhysicalGeometry.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8252,8 +8252,7 @@ void CPhysicalGeometry::SetSensitivity(CConfig* config) {
82528252

82538253
char str_buf[CGNS_STRING_SIZE], fname[100];
82548254
unsigned short iVar;
8255-
strncpy(fname, filename.c_str(), sizeof(fname) - 1);
8256-
fname[sizeof(fname) - 1] = '\0'; // Ensure null termination
8255+
strcpy(fname, filename.c_str());
82578256
int nRestart_Vars = 5, nFields;
82588257
int* Restart_Vars = new int[5];
82598258
passivedouble* Restart_Data = nullptr;
@@ -8566,8 +8565,7 @@ void CPhysicalGeometry::SetSensitivity(CConfig* config) {
85668565
/*--- First, check that this is not a binary restart file. ---*/
85678566

85688567
char fname[100];
8569-
strncpy(fname, filename.c_str(), sizeof(fname) - 1);
8570-
fname[sizeof(fname) - 1] = '\0'; // Ensure null termination
8568+
strcpy(fname, filename.c_str());
85718569
int magic_number;
85728570

85738571
#ifndef HAVE_MPI

Common/src/wall_model.cpp

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -306,11 +306,9 @@ void CWallModel1DEQ::WallShearStressAndHeatFlux(const su2double tExchange, const
306306
if (y_cv[0] * sqrt(tauWall / rho) / (mu_lam / rho) > 1.0)
307307
SU2_MPI::Error("Y+ greater than one: Increase the number of points or growth ratio.", CURRENT_FUNCTION);
308308

309-
/* Define a norm
310-
* Check convergence only if previous values are non-zero to avoid division by zero
311-
*/
312-
bool tau_converged = (tauWall_prev != 0.0) ? (abs(1.0 - tauWall / tauWall_prev) < tol) : false;
313-
bool q_converged = (qWall_prev != 0.0) ? (abs(1.0 - qWall / qWall_prev) < tol) : false;
309+
/* Define a norm */
310+
bool tau_converged = abs(1.0 - tauWall / fmax(tauWall_prev, 1e-16)) < tol;
311+
bool q_converged = abs(1.0 - qWall / fmax(qWall_prev, 1e-16)) < tol;
314312

315313
if (tau_converged && q_converged) {
316314
converged = true;
@@ -394,20 +392,9 @@ void CWallModelLogLaw::WallShearStressAndHeatFlux(const su2double tExchange, con
394392
const su2double lhs = -((tExchange - TWall) * rho_wall * c_p * u_tau);
395393
const su2double Gamma = -(0.01 * (Pr_lam * pow(y_plus, 4.0)) / (1.0 + 5.0 * y_plus * pow(Pr_lam, 3.0)));
396394
const su2double rhs_1 = Pr_lam * y_plus * exp(Gamma);
397-
398-
/* Protect against division by zero in exp(1/Gamma) when Gamma is very small */
399-
const su2double eps_gamma = 1e-20;
400-
su2double exp_term;
401-
if (abs(Gamma) > eps_gamma) {
402-
exp_term = exp(1.0 / Gamma);
403-
} else {
404-
/* For very small Gamma, cap the exponential to prevent overflow/division by zero */
405-
exp_term = (Gamma > 0) ? exp(1.0 / eps_gamma) : exp(-1.0 / eps_gamma);
406-
}
407-
408395
const su2double rhs_2 =
409396
(2.12 * log(1.0 + y_plus) + pow((3.85 * pow(Pr_lam, (1.0 / 3.0)) - 1.3), 2.0) + 2.12 * log(Pr_lam)) *
410-
exp_term;
397+
exp(1.0 / fmin(Gamma, -1e-16));
411398
qWall = lhs / (rhs_1 + rhs_2);
412399
} else {
413400
qWall = Wall_HeatFlux;

SU2_CFD/src/solvers/CRadP1Solver.cpp

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -282,18 +282,10 @@ void CRadP1Solver::BC_Isothermal_Wall(CGeometry *geometry, CSolver **solver_cont
282282
/*--- Get the specified wall emissivity from config ---*/
283283
Wall_Emissivity = config->GetWall_Emissivity(Marker_Tag);
284284

285-
/*--- Clamp emissivity to valid physical range [0,1] to prevent division by zero ---*/
286-
if (Wall_Emissivity < 0.0) {
287-
Wall_Emissivity = 0.0;
288-
}
289-
if (Wall_Emissivity > 1.0) {
290-
Wall_Emissivity = 1.0;
291-
}
292-
293285
/*--- Compute the constant for the wall theta ---*/
294286
Theta = Wall_Emissivity / (2.0*(2.0 - Wall_Emissivity));
295287

296-
/*--- Retrieve the specified wall temperature ---*/
288+
/*--- Retrieve the specified wall temperature ---*/
297289
Twall = config->GetIsothermal_Temperature(Marker_Tag)/config->GetTemperature_Ref();
298290

299291
/*--- Loop over all of the vertices on this boundary marker ---*/
@@ -364,14 +356,6 @@ void CRadP1Solver::BC_Far_Field(CGeometry *geometry, CSolver **solver_container,
364356
/*--- Get the specified wall emissivity from config ---*/
365357
Wall_Emissivity = config->GetWall_Emissivity(Marker_Tag);
366358

367-
/*--- Clamp emissivity to valid physical range [0,1] to prevent division by zero ---*/
368-
if (Wall_Emissivity < 0.0) {
369-
Wall_Emissivity = 0.0;
370-
}
371-
if (Wall_Emissivity > 1.0) {
372-
Wall_Emissivity = 1.0;
373-
}
374-
375359
/*--- Compute the constant for the wall theta ---*/
376360
Theta = Wall_Emissivity / (2.0*(2.0 - Wall_Emissivity));
377361

@@ -446,19 +430,6 @@ void CRadP1Solver::BC_Marshak(CGeometry *geometry, CSolver **solver_container, C
446430
/*--- Get the specified wall emissivity from config ---*/
447431
Wall_Emissivity = config->GetWall_Emissivity(Marker_Tag);
448432

449-
/*--- Clamp emissivity to valid physical range [0,1] to prevent division by zero ---*/
450-
<<<<<<< HEAD
451-
if (Wall_Emissivity < 0.0) {
452-
Wall_Emissivity = 0.0;
453-
}
454-
if (Wall_Emissivity > 1.0) {
455-
Wall_Emissivity = 1.0;
456-
}
457-
=======
458-
if (Wall_Emissivity < 0.0) Wall_Emissivity = 0.0;
459-
if (Wall_Emissivity > 1.0) Wall_Emissivity = 1.0;
460-
>>>>>>> 46baac1286ba393e261fef83bced67d0d4d3f269
461-
462433
/*--- Compute the constant for the wall theta ---*/
463434
Theta = Wall_Emissivity / (2.0*(2.0 - Wall_Emissivity));
464435

SU2_CFD/src/solvers/CSolver.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3381,10 +3381,9 @@ void CSolver::Read_SU2_Restart_Metadata(CGeometry *geometry, CConfig *config, bo
33813381

33823382
/*--- External iteration ---*/
33833383

3384-
position = text_line.find("ITER=", 0);
3384+
position = text_line.find ("ITER=",0);
33853385
if (position != string::npos) {
3386-
text_line.erase(0, 5);
3387-
InnerIter_ = atoi(text_line.c_str()); // 'ITER=' has 5 chars
3386+
text_line.erase (0,9); InnerIter_ = atoi(text_line.c_str());
33883387
}
33893388

33903389
/*--- Angle of attack ---*/

0 commit comments

Comments
 (0)