Skip to content

Commit

Permalink
Fix findYPlus routine. idaholab#27800
Browse files Browse the repository at this point in the history
  • Loading branch information
Freile committed Jul 11, 2024
1 parent 7de74ce commit 93480ba
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions modules/navier_stokes/src/base/NavierStokesMethods.C
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,20 @@ findUStar(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real di

const ADReal nu = mu / rho;

ADReal u_star = std::sqrt(nu * u / dist);
// Wall-function linearized guess
const Real a_c = 1 / NS::von_karman_constant;
const ADReal b_c =
1 / NS::von_karman_constant * (std::log(NS::E_turb_constant * dist / mu) + 1.0);
const ADReal c_c = u;

/// This is important to reduce the number of nonlinear iterations
ADReal u_star = (-b_c + std::sqrt(std::pow(b_c, 2) + 4.0 * a_c * c_c)) / (2.0 * a_c);

// Newton-Raphson method to solve for u_star (friction velocity).
for (int i = 0; i < MAX_ITERS; ++i)
{
ADReal residual = u_star / NS::von_karman_constant * std::log(u_star * dist / (0.111 * nu)) - u;
ADReal deriv = (1 + std::log(u_star * dist / (0.111 * nu))) / NS::von_karman_constant;
ADReal residual = u_star / NS::von_karman_constant * std::log(NS::E_turb_constant * u_star * dist / nu) - u;
ADReal deriv = (1 + std::log(NS::E_turb_constant * u_star * dist / nu)) / NS::von_karman_constant;
ADReal new_u_star = std::max(1e-20, u_star - residual / deriv);

Real rel_err = std::abs((new_u_star.value() - u_star.value()) / new_u_star.value());
Expand Down Expand Up @@ -114,7 +121,7 @@ findyPlus(const ADReal & mu, const ADReal & rho, const ADReal & u, const Real di
{
yPlusLast = yPlus;
yPlus = (kappa_time_Re + yPlus) / (1.0 + std::log(NS::E_turb_constant * yPlus));
} while (rev_yPlusLam * (yPlus - yPlusLast) > REL_TOLERANCE && ++iters < MAX_ITERS);
} while ( std::abs(rev_yPlusLam * (yPlus - yPlusLast)) > REL_TOLERANCE && ++iters < MAX_ITERS);

return std::max(0.0, yPlus);
}
Expand Down

0 comments on commit 93480ba

Please sign in to comment.