PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
Macros | Functions
wallfunction.c File Reference

Wall function implementations for near-wall turbulence modeling. More...

#include "wallfunction.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
Include dependency graph for wallfunction.c:

Go to the source code of this file.

Macros

#define KAPPA   0.41
 von Karman constant (universal turbulence constant)
 
#define LOGLAW_B   5.5
 Log-law intercept constant B for smooth walls.
 
#define WERNER_A   8.3
 Werner-Wengle power-law coefficient A and exponent B in u+ = A (y+)^B.
 
#define WERNER_B   (1.0 / 7.0)
 
#define WERNER_SUBLAYER_YPLUS   (pow(WERNER_A, 1.0 / (1.0 - WERNER_B)))
 Werner-Wengle sublayer edge: where u+ = y+ meets u+ = A (y+)^B, at A^(1/(1-B)).
 
#define ROUGHNESS_TRANSITION_YPLUS   2.25
 Smooth-to-rough transition y+ threshold.
 
#define FULLY_ROUGH_YPLUS   90.0
 Fully rough regime y+ threshold.
 
#define DAMPING_COEFFICIENT   19.0
 Eddy viscosity damping coefficient (van Driest damping)
 
#define __FUNCT__   "taw_Werner"
 
#define __FUNCT__   "u_Werner_explicit"
 

Functions

double E_coeff (double friction_velocity, double roughness_height, double kinematic_viscosity)
 Implementation of E_coeff().
 
static double LogLawSublayerEdge (double E)
 The log law's sublayer edge for a given E: the y+ where u+ = y+ meets u+ = ln(E y+)/kappa.
 
double u_hydset_roughness (double kinematic_viscosity, double wall_distance, double friction_velocity, double roughness_height)
 Implementation of u_hydset_roughness().
 
double f_hydset (double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
 Implementation of f_hydset().
 
double df_hydset (double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
 Implementation of df_hydset().
 
double find_utau_hydset (double kinematic_viscosity, double known_velocity, double wall_distance, double initial_guess, double roughness_height)
 Implementation of find_utau_hydset().
 
double nu_t (double yplus)
 Implementation of nu_t().
 
double integrate_1 (double kinematic_viscosity, double wall_distance, double friction_velocity, int integration_mode)
 Implementation of integrate_1().
 
double taw (double kinematic_viscosity, double friction_velocity, double wall_distance, double velocity, double pressure_gradient_tangent)
 Implementation of taw().
 
double u_Cabot (double kinematic_viscosity, double wall_distance, double friction_velocity, double pressure_gradient_tangent, double wall_shear_stress)
 Implementation of u_Cabot().
 
double f_Cabot (double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
 Implementation of f_Cabot().
 
double df_Cabot (double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
 Implementation of df_Cabot().
 
void find_utau_Cabot (double kinematic_viscosity, double velocity, double wall_distance, double initial_guess, double pressure_gradient_tangent, double pressure_gradient_normal, double *friction_velocity, double *wall_shear_velocity, double *wall_shear_normal)
 Implementation of find_utau_Cabot().
 
double u_Werner (double kinematic_viscosity, double wall_distance, double friction_velocity)
 Implementation of u_Werner().
 
double taw_Werner (double kinematic_viscosity, double velocity, double wall_distance)
 Implementation of taw_Werner().
 
double u_Werner_explicit (double kinematic_viscosity, double wall_distance, double wall_shear_stress)
 Implementation of u_Werner_explicit().
 
double find_utau_Werner (double kinematic_viscosity, double velocity, double wall_distance, double initial_guess)
 Implementation of find_utau_Werner().
 

Detailed Description

Wall function implementations for near-wall turbulence modeling.

This file contains various wall function models that bridge the gap between the wall and the first computational grid point. Wall functions allow simulations to avoid resolving the viscous sublayer, reducing computational cost while maintaining reasonable accuracy for turbulent wall-bounded flows.

PHYSICAL BACKGROUND: The near-wall region in turbulent flows is characterized by three layers:

  1. Viscous sublayer (y+ < 5): Dominated by viscous effects, u+ = y+
  2. Buffer layer (5 < y+ < 30): Transition region
  3. Log-law region (y+ > 30): Inertial layer, u+ = (1/κ) ln(y+) + B where: u+ = u / u_τ (normalized velocity) y+ = y * u_τ / ν (normalized wall distance) u_τ = sqrt(τ_w / ρ) (friction velocity) κ ≈ 0.41 (von Karman constant) B ≈ 5.5 (log-law intercept for smooth walls)

IMPLEMENTED MODELS (each a profile and the friction velocity that inverts it, which ApplyWallFunction() turns into the wall shear stress):

Author
Original implementation adapted from legacy code
Date
Enhanced with comprehensive documentation

Definition in file wallfunction.c.

Macro Definition Documentation

◆ KAPPA

#define KAPPA   0.41

von Karman constant (universal turbulence constant)

Definition at line 42 of file wallfunction.c.

◆ LOGLAW_B

#define LOGLAW_B   5.5

Log-law intercept constant B for smooth walls.

Definition at line 45 of file wallfunction.c.

◆ WERNER_A

#define WERNER_A   8.3

Werner-Wengle power-law coefficient A and exponent B in u+ = A (y+)^B.

Definition at line 48 of file wallfunction.c.

◆ WERNER_B

#define WERNER_B   (1.0 / 7.0)

Definition at line 49 of file wallfunction.c.

◆ WERNER_SUBLAYER_YPLUS

#define WERNER_SUBLAYER_YPLUS   (pow(WERNER_A, 1.0 / (1.0 - WERNER_B)))

Werner-Wengle sublayer edge: where u+ = y+ meets u+ = A (y+)^B, at A^(1/(1-B)).

The commonly quoted 11.81 is this value rounded, and rounding it leaves the two branches apart by about 2e-5 of u+, so the profile and its inverse jump there.

Definition at line 54 of file wallfunction.c.

◆ ROUGHNESS_TRANSITION_YPLUS

#define ROUGHNESS_TRANSITION_YPLUS   2.25

Smooth-to-rough transition y+ threshold.

Definition at line 57 of file wallfunction.c.

◆ FULLY_ROUGH_YPLUS

#define FULLY_ROUGH_YPLUS   90.0

Fully rough regime y+ threshold.

Definition at line 60 of file wallfunction.c.

◆ DAMPING_COEFFICIENT

#define DAMPING_COEFFICIENT   19.0

Eddy viscosity damping coefficient (van Driest damping)

Definition at line 63 of file wallfunction.c.

◆ __FUNCT__ [1/2]

#define __FUNCT__   "taw_Werner"

Definition at line 470 of file wallfunction.c.

◆ __FUNCT__ [2/2]

#define __FUNCT__   "u_Werner_explicit"

Definition at line 470 of file wallfunction.c.

Function Documentation

◆ E_coeff()

double E_coeff ( double  friction_velocity,
double  roughness_height,
double  kinematic_viscosity 
)

Implementation of E_coeff().

Computes roughness-modified log-law coefficient E.

See also
E_coeff()

Definition at line 77 of file wallfunction.c.

78{
79 // Compute roughness Reynolds number
80 double roughness_reynolds = friction_velocity * roughness_height / kinematic_viscosity;
81
82 double roughness_correction;
83
84 if (roughness_reynolds <= ROUGHNESS_TRANSITION_YPLUS) {
85 // Hydraulically smooth regime: no correction needed
86 roughness_correction = 0.0;
87 }
88 else if (roughness_reynolds < FULLY_ROUGH_YPLUS) {
89 // Transitional regime: smooth interpolation using sine function
90 // This provides a gradual transition between smooth and rough wall behavior
91 double max_correction = LOGLAW_B - 8.5 + (1.0 / KAPPA) * log(roughness_reynolds);
92
93 roughness_correction = max_correction *
94 sin(0.4258 * (log(roughness_reynolds) - 0.811));
95 }
96 else {
97 // Fully rough regime: maximum correction
98 roughness_correction = LOGLAW_B - 8.5 + (1.0 / KAPPA) * log(roughness_reynolds);
99 }
100
101 // Return E = exp[κ(B - ΔB)]
102 return exp(KAPPA * (LOGLAW_B - roughness_correction));
103}
#define ROUGHNESS_TRANSITION_YPLUS
Smooth-to-rough transition y+ threshold.
#define LOGLAW_B
Log-law intercept constant B for smooth walls.
#define FULLY_ROUGH_YPLUS
Fully rough regime y+ threshold.
#define KAPPA
von Karman constant (universal turbulence constant)
Here is the caller graph for this function:

◆ LogLawSublayerEdge()

static double LogLawSublayerEdge ( double  E)
inlinestatic

The log law's sublayer edge for a given E: the y+ where u+ = y+ meets u+ = ln(E y+)/kappa.

Switching at a fixed 11.81 instead left the two branches apart by about 2.4% of u+ for a smooth wall (E = exp(kappa B)), so the profile jumped and the friction velocity it implies had two roots in a band of U y/nu. Switching where they meet keeps the profile continuous and increasing, so each reference speed has one friction velocity. Newton from 11.81 converges in a few steps for every E the roughness function produces.

Definition at line 115 of file wallfunction.c.

116{
117 double y = 11.81;
118
119 for (int iteration = 0; iteration < 50; iteration++) {
120 const double g = y - log(E * y) / KAPPA;
121 const double dg = 1.0 - 1.0 / (KAPPA * y);
122 const double step = g / dg;
123
124 y -= step;
125 if (fabs(step) < 1.e-12 * y) break;
126 }
127 return y;
128}
Here is the caller graph for this function:

◆ u_hydset_roughness()

double u_hydset_roughness ( double  kinematic_viscosity,
double  wall_distance,
double  friction_velocity,
double  roughness_height 
)

Implementation of u_hydset_roughness().

Computes velocity from log-law for rough walls.

See also
u_hydset_roughness()

Definition at line 134 of file wallfunction.c.

136{
137 // Normalized wall distance
138 double yplus = friction_velocity * wall_distance / kinematic_viscosity;
139 const double E = E_coeff(friction_velocity, roughness_height, kinematic_viscosity);
140
141 double tangential_velocity;
142
143 /* The forward form of exactly the relation find_utau_hydset() inverts, at every y+:
144 the logarithmic branch continues above y+ = 300 as it does in the inverse. Whether
145 the first cell lies where the law describes the flow is the range check in
146 LogWallModelDiagnostics(), not a property of the profile. */
147 if (yplus <= LogLawSublayerEdge(E)) {
148 // Viscous sublayer: linear velocity profile
149 tangential_velocity = friction_velocity * yplus;
150 }
151 else {
152 // Log-layer: logarithmic velocity profile with roughness correction
153 tangential_velocity = (friction_velocity / KAPPA) * log(E * yplus);
154 }
155
156 return tangential_velocity;
157}
static double LogLawSublayerEdge(double E)
The log law's sublayer edge for a given E: the y+ where u+ = y+ meets u+ = ln(E y+)/kappa.
double E_coeff(double friction_velocity, double roughness_height, double kinematic_viscosity)
Implementation of E_coeff().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_hydset()

double f_hydset ( double  kinematic_viscosity,
double  known_velocity,
double  wall_distance,
double  friction_velocity_guess,
double  roughness_height 
)

Implementation of f_hydset().

Residual function for friction velocity equation (log-law with roughness)

See also
f_hydset()

Definition at line 167 of file wallfunction.c.

170{
171 double yplus = friction_velocity_guess * wall_distance / kinematic_viscosity;
172 double E = E_coeff(friction_velocity_guess, roughness_height, kinematic_viscosity);
173 double residual;
174
175 if (yplus <= LogLawSublayerEdge(E)) {
176 // Viscous sublayer: u = u_τ * y+
177 residual = friction_velocity_guess * yplus - known_velocity;
178 }
179 else {
180 // Log-layer: u = (u_τ / κ) * ln(E * y+)
181 residual = friction_velocity_guess * (1.0 / KAPPA * log(E * yplus)) - known_velocity;
182 }
183
184 return residual;
185}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ df_hydset()

double df_hydset ( double  kinematic_viscosity,
double  known_velocity,
double  wall_distance,
double  friction_velocity_guess,
double  roughness_height 
)

Implementation of df_hydset().

Numerical derivative of residual function.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
df_hydset()

Definition at line 193 of file wallfunction.c.

196{
197 const double perturbation = 1.e-7;
198
199 double f_plus = f_hydset(kinematic_viscosity, known_velocity, wall_distance,
200 friction_velocity_guess + perturbation, roughness_height);
201
202 double f_minus = f_hydset(kinematic_viscosity, known_velocity, wall_distance,
203 friction_velocity_guess - perturbation, roughness_height);
204
205 return (f_plus - f_minus) / (2.0 * perturbation);
206}
double f_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
Implementation of f_hydset().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_utau_hydset()

double find_utau_hydset ( double  kinematic_viscosity,
double  known_velocity,
double  wall_distance,
double  initial_guess,
double  roughness_height 
)

Implementation of find_utau_hydset().

Solves for friction velocity using Newton-Raphson iteration.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
find_utau_hydset()

Definition at line 214 of file wallfunction.c.

217{
218 double friction_velocity = initial_guess;
219 double friction_velocity_old = initial_guess;
220
221 const int max_iterations = 30;
222 const double convergence_tolerance = 1.e-7;
223
224 int iteration;
225 for (iteration = 0; iteration < max_iterations; iteration++) {
226 // Newton-Raphson update
227 double residual = f_hydset(kinematic_viscosity, known_velocity, wall_distance,
228 friction_velocity_old, roughness_height);
229 double derivative = df_hydset(kinematic_viscosity, known_velocity, wall_distance,
230 friction_velocity_old, roughness_height);
231 if (derivative == 0.0 || !isfinite(derivative)) break;
232
233 friction_velocity = friction_velocity_old - residual / derivative;
234 /* The friction velocity is positive. The linear branch's residual u_tau^2 y/nu - U
235 has a mirror root at -u_tau, which an undamped step from a small guess can reach
236 (a rough wall made it common); halving toward the last positive iterate keeps the
237 iteration on the physical root. */
238 if (!(friction_velocity > 0.0)) friction_velocity = 0.5 * friction_velocity_old;
239
240 // Check convergence
241 if (fabs(friction_velocity - friction_velocity_old) < convergence_tolerance) {
242 break;
243 }
244
245 friction_velocity_old = friction_velocity;
246 }
247
248 // Warn if convergence not achieved
249 if (iteration == max_iterations) {
251 "WARNING: u_tau iteration did not converge after %d iterations. "
252 "Final difference: %le\n",
253 iteration, fabs(friction_velocity - friction_velocity_old));
254 }
255
256 return friction_velocity;
257}
#define LOCAL
Logging scope definitions for controlling message output.
Definition logging.h:45
#define LOG_ALLOW(scope, level, fmt,...)
Logging macro that checks both the log level and whether the calling function is in the allowed-funct...
Definition logging.h:214
@ LOG_DEBUG
Detailed debugging information.
Definition logging.h:32
double df_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
Implementation of df_hydset().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ nu_t()

double nu_t ( double  yplus)

Implementation of nu_t().

Computes turbulent eddy viscosity ratio (ν_t / ν)

See also
nu_t()

Definition at line 267 of file wallfunction.c.

268{
269 // van Driest damping function: [1 - exp(-y+ / A+)]²
270 double damping_function = 1.0 - exp(-yplus / DAMPING_COEFFICIENT);
271
272 // Mixing length model: ν_t / ν = κ * y+ * D²
273 return KAPPA * yplus * damping_function * damping_function;
274}
#define DAMPING_COEFFICIENT
Eddy viscosity damping coefficient (van Driest damping)
Here is the caller graph for this function:

◆ integrate_1()

double integrate_1 ( double  kinematic_viscosity,
double  wall_distance,
double  friction_velocity,
int  integration_mode 
)

Implementation of integrate_1().

Integrates eddy viscosity profile from wall to distance y.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
integrate_1()

Definition at line 282 of file wallfunction.c.

284{
285 /* Composite Simpson in s, with y = wall_distance * s^2. The integrand falls off like
286 1/y+ across the log layer, so uniform points in y left the near-wall rise under-sampled:
287 30 of them were about 33% off at y+ = 1000. Clustering them toward the wall as s^2 does
288 makes the mapped integrand smooth at every y+ the model is allowed to reach. */
289 const int intervals = 128; /* even */
290 const double ds = 1.0 / intervals;
291 double integral_sum = 0.0;
292
293 for (int i = 0; i <= intervals; i++) {
294 const double s_value = i * ds;
295 const double current_distance = wall_distance * s_value * s_value;
296 const double jacobian = 2.0 * wall_distance * s_value; /* dy/ds */
297 const double yplus = current_distance * friction_velocity / kinematic_viscosity;
298 const double denominator = (1.0 + nu_t(fabs(yplus))) * kinematic_viscosity;
299 const double integrand = ((integration_mode == 0) ? 1.0 : current_distance) / denominator * jacobian;
300 const double weight = (i == 0 || i == intervals) ? 1.0 : ((i % 2) ? 4.0 : 2.0);
301
302 integral_sum += weight * integrand;
303 }
304 return integral_sum * ds / 3.0;
305}
double nu_t(double yplus)
Implementation of nu_t().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ taw()

double taw ( double  kinematic_viscosity,
double  friction_velocity,
double  wall_distance,
double  velocity,
double  pressure_gradient_tangent 
)

Implementation of taw().

Computes wall shear stress with pressure gradient effects.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
taw()

Definition at line 317 of file wallfunction.c.

319{
320 // Compute integrated viscosity profiles
321 double F1 = integrate_1(kinematic_viscosity, wall_distance, friction_velocity, 0);
322 double Fy = integrate_1(kinematic_viscosity, wall_distance, friction_velocity, 1);
323
324 // Apply momentum balance: τ_w * F1 = u - (dp/dx) * Fy
325 return (1.0 / F1) * (velocity - pressure_gradient_tangent * Fy);
326}
double integrate_1(double kinematic_viscosity, double wall_distance, double friction_velocity, int integration_mode)
Implementation of integrate_1().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ u_Cabot()

double u_Cabot ( double  kinematic_viscosity,
double  wall_distance,
double  friction_velocity,
double  pressure_gradient_tangent,
double  wall_shear_stress 
)

Implementation of u_Cabot().

Computes velocity using Cabot wall function.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
u_Cabot()

Definition at line 334 of file wallfunction.c.

337{
338 double F1 = integrate_1(kinematic_viscosity, wall_distance, friction_velocity, 0);
339 double Fy = integrate_1(kinematic_viscosity, wall_distance, friction_velocity, 1);
340
341 return wall_shear_stress * F1 + pressure_gradient_tangent * Fy;
342}
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_Cabot()

double f_Cabot ( double  kinematic_viscosity,
double  velocity,
double  wall_distance,
double  friction_velocity_guess,
double  pressure_gradient_tangent,
double  pressure_gradient_normal 
)

Implementation of f_Cabot().

Residual function for Cabot wall function.

See also
f_Cabot()

Definition at line 348 of file wallfunction.c.

351{
352 (void)pressure_gradient_normal;
353 double wall_shear = taw(kinematic_viscosity, friction_velocity_guess,
354 wall_distance, velocity, pressure_gradient_tangent);
355
356 return friction_velocity_guess - sqrt(fabs(wall_shear));
357}
double taw(double kinematic_viscosity, double friction_velocity, double wall_distance, double velocity, double pressure_gradient_tangent)
Implementation of taw().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ df_Cabot()

double df_Cabot ( double  kinematic_viscosity,
double  velocity,
double  wall_distance,
double  friction_velocity_guess,
double  pressure_gradient_tangent,
double  pressure_gradient_normal 
)

Implementation of df_Cabot().

Numerical derivative for Cabot wall function.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
df_Cabot()

Definition at line 365 of file wallfunction.c.

368{
369 const double perturbation = 1.e-7;
370
371 double f_plus = f_Cabot(kinematic_viscosity, velocity, wall_distance,
372 friction_velocity_guess + perturbation,
373 pressure_gradient_tangent, pressure_gradient_normal);
374
375 double f_minus = f_Cabot(kinematic_viscosity, velocity, wall_distance,
376 friction_velocity_guess - perturbation,
377 pressure_gradient_tangent, pressure_gradient_normal);
378
379 return (f_plus - f_minus) / (2.0 * perturbation);
380}
double f_Cabot(double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
Implementation of f_Cabot().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_utau_Cabot()

void find_utau_Cabot ( double  kinematic_viscosity,
double  velocity,
double  wall_distance,
double  initial_guess,
double  pressure_gradient_tangent,
double  pressure_gradient_normal,
double *  friction_velocity,
double *  wall_shear_velocity,
double *  wall_shear_normal 
)

Implementation of find_utau_Cabot().

Solves for friction velocity using Cabot wall function.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
find_utau_Cabot()

Definition at line 388 of file wallfunction.c.

392{
393 double current_guess = initial_guess;
394 double new_guess;
395
396 const int max_iterations = 30;
397 const double convergence_tolerance = 1.e-10;
398
399 int iteration;
400 for (iteration = 0; iteration < max_iterations; iteration++) {
401 double residual = f_Cabot(kinematic_viscosity, velocity, wall_distance,
402 current_guess, pressure_gradient_tangent,
403 pressure_gradient_normal);
404
405 double derivative = df_Cabot(kinematic_viscosity, velocity, wall_distance,
406 current_guess, pressure_gradient_tangent,
407 pressure_gradient_normal);
408
409 new_guess = fabs(current_guess - residual / derivative);
410
411 if (fabs(current_guess - new_guess) < convergence_tolerance) {
412 break;
413 }
414
415 current_guess = new_guess;
416 }
417
418 if (fabs(current_guess - new_guess) > 1.e-5 && iteration >= 29) {
419 /* Per wall cell and step, so reported only the first time on each rank. */
420 static PetscBool reported = PETSC_FALSE;
421 if (!reported) {
422 reported = PETSC_TRUE;
424 "Cabot wall-function iteration reached its limit without the requested tolerance "
425 "(reported once per rank; later occurrences are not).\n");
426 }
427 }
428
429 *friction_velocity = new_guess;
430 *wall_shear_velocity = taw(kinematic_viscosity, new_guess, wall_distance,
431 velocity, pressure_gradient_tangent);
432 *wall_shear_normal = taw(kinematic_viscosity, new_guess, wall_distance,
433 0.0, pressure_gradient_normal);
434}
@ LOG_WARNING
Non-critical issues that warrant attention.
Definition logging.h:30
double df_Cabot(double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
Implementation of df_Cabot().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ u_Werner()

double u_Werner ( double  kinematic_viscosity,
double  wall_distance,
double  friction_velocity 
)

Implementation of u_Werner().

Computes velocity using Werner-Wengle wall function.

See also
u_Werner()

Definition at line 444 of file wallfunction.c.

446{
447 /* The pointwise profile. ApplyWallFunction() takes the friction velocity from its exact
448 inverse, find_utau_Werner(), at the reference cell. */
449 double yplus = friction_velocity * wall_distance / kinematic_viscosity;
450
451 // Werner-Wengle constants
452 const double power_law_coefficient = WERNER_A;
453 const double power_law_exponent = WERNER_B;
454
455 double velocity;
456
457 if (yplus <= WERNER_SUBLAYER_YPLUS) {
458 // Viscous sublayer: u+ = y+
459 velocity = yplus * friction_velocity;
460 }
461 else {
462 // Power-law region: u+ = A * (y+)^B
463 velocity = power_law_coefficient * pow(yplus, power_law_exponent) * friction_velocity;
464 }
465
466 return velocity;
467}
#define WERNER_SUBLAYER_YPLUS
Werner-Wengle sublayer edge: where u+ = y+ meets u+ = A (y+)^B, at A^(1/(1-B)).
#define WERNER_A
Werner-Wengle power-law coefficient A and exponent B in u+ = A (y+)^B.
#define WERNER_B
Here is the caller graph for this function:

◆ taw_Werner()

double taw_Werner ( double  kinematic_viscosity,
double  velocity,
double  wall_distance 
)

Implementation of taw_Werner().

Wall shear stress from the cell-integrated Werner-Wengle relation.

Full API contract is documented with the header declaration in include/wallfunction.h.

Definition at line 476 of file wallfunction.c.

477{
479 const double A = WERNER_A;
480 const double B = WERNER_B;
481 const double speed = fabs(velocity);
482 const double nu_over_y = kinematic_viscosity / wall_distance;
483
484 /* The switch is written in terms of the geometry alone. Expressing it through the
485 friction velocity, as the iterative residual does, makes the branch depend on the
486 answer and forces a Newton solve the closed form does not need. */
487 const double transition_speed = 0.5 * nu_over_y * pow(A, 2.0 / (1.0 - B));
488
489 if (speed <= transition_speed) {
490 /* Integrating u+ = y+ across the cell leaves the factor of two that separates
491 this from the pointwise relation tau_w = nu u / y. */
493 return 2.0 * kinematic_viscosity * speed / wall_distance;
494 }
495
496 {
497 const double term1 = 0.5 * (1.0 - B) * pow(A, (1.0 + B) / (1.0 - B)) *
498 pow(nu_over_y, 1.0 + B);
499 const double term2 = (1.0 + B) / A * pow(nu_over_y, B) * speed;
500
502 return pow(term1 + term2, 2.0 / (1.0 + B));
503 }
505}
#define PROFILE_HELPER_BEGIN
Marks the beginning of a profiled helper: timed only when enabled by name.
Definition logging.h:1014
#define PROFILE_HELPER_END
Alias of PROFILE_FUNCTION_END for a function that began with PROFILE_HELPER_BEGIN.
Definition logging.h:1033
Here is the caller graph for this function:

◆ u_Werner_explicit()

double u_Werner_explicit ( double  kinematic_viscosity,
double  wall_distance,
double  wall_shear_stress 
)

Implementation of u_Werner_explicit().

Wall-parallel velocity at a distance, from the Werner-Wengle wall stress.

Full API contract is documented with the header declaration in include/wallfunction.h.

Definition at line 514 of file wallfunction.c.

516{
518 const double A = WERNER_A;
519 const double B = WERNER_B;
520 const double stress = fabs(wall_shear_stress);
521 const double nu_over_y = kinematic_viscosity / wall_distance;
522
523 /* The same threshold as taw_Werner(), carried over to the stress side. The two
524 branches meet here exactly, so selecting on the stress cannot land on the wrong
525 side of the velocity switch. */
526 const double transition_stress = nu_over_y * nu_over_y * pow(A, 2.0 / (1.0 - B));
527
528 if (stress <= transition_stress) {
530 return stress * wall_distance / (2.0 * kinematic_viscosity);
531 }
532
533 {
534 const double offset = 0.5 * (1.0 - B) * pow(A, (1.0 + B) / (1.0 - B)) *
535 pow(nu_over_y, 1.0 + B);
536 /* Non-negative by construction above the threshold - it is zero only in the
537 limit of the switch - so the max guards roundoff, not a modelling case. */
538 const double bracket = PetscMax(pow(stress, 0.5 * (1.0 + B)) - offset, 0.0);
539
541 return A / (1.0 + B) * pow(1.0 / nu_over_y, B) * bracket;
542 }
544}
Here is the caller graph for this function:

◆ find_utau_Werner()

double find_utau_Werner ( double  kinematic_viscosity,
double  velocity,
double  wall_distance,
double  initial_guess 
)

Implementation of find_utau_Werner().

Friction velocity from a point velocity, inverting u_Werner() exactly.

Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.

See also
find_utau_Werner()

Definition at line 552 of file wallfunction.c.

554{
555 const double A = WERNER_A;
556 const double B = WERNER_B;
557 const double speed = fabs(velocity);
558 const double y_over_nu = wall_distance / kinematic_viscosity;
559 (void)initial_guess;
560
561 /* The exact inverse of `u_Werner()`, branch for branch. Along that profile
562 U y / nu = (y+)^2 in the sublayer, so the branch it was evaluated on is decided by
563 the data alone: the sublayer holds while U y / nu <= WERNER_SUBLAYER_YPLUS^2, the
564 same switch `u_Werner()` applies to y+. Both branches then invert explicitly. */
565 if (speed * y_over_nu <= WERNER_SUBLAYER_YPLUS * WERNER_SUBLAYER_YPLUS) {
566 return sqrt(speed / y_over_nu); /* U = u_tau^2 y / nu */
567 }
568 return pow(speed / (A * pow(y_over_nu, B)), 1.0 / (1.0 + B)); /* U = A u_tau^(1+B) (y/nu)^B */
569}
Here is the caller graph for this function: