PICurv 0.1.0
A Parallel Particle-In-Cell Solver for Curvilinear LES
 
Loading...
Searching...
No Matches
wallfunction.h
Go to the documentation of this file.
1#ifndef WALLFUNCTION_H
2#define WALLFUNCTION_H
3
4#include <petscpf.h>
5#include <petscdmswarm.h>
6#include <stdlib.h>
7#include <time.h>
8#include <math.h>
9#include <petsctime.h>
10#include <petscsys.h>
11#include <petscdmcomposite.h>
12#include <petscsystypes.h>
13
14// Include additional headers
15#include "variables.h" // Shared type definitions
16#include "ParticleSwarm.h" // Particle swarm functions
17#include "walkingsearch.h" // Particle location functions
18#include "grid.h" // Grid functions
19#include "logging.h" // Logging macros
20#include "io.h" // Data Input and Output functions
21#include "interpolation.h" // Interpolation routines
22#include "ParticleMotion.h" // Functions related to motion of particles
23#include "Boundaries.h" // Functions related to Boundary condition
24
25// ===========================================================================
26// Function Declarations
27// ===========================================================================
28
29/**
30 * @brief Applies no-slip wall boundary condition with linear interpolation
31 *
32 * This function enforces a no-slip boundary condition (zero velocity at the wall)
33 * by linearly interpolating between the wall velocity (typically zero) and the
34 * velocity at a reference point in the flow.
35 *
36 * MATHEMATICAL FORMULATION:
37 * For a point at distance sb from the wall, with a reference velocity Uc
38 * at distance sc from the wall:
39 * U_boundary = U_wall + (U_reference - U_wall) * (sb / sc)
40 *
41 * PHYSICAL INTERPRETATION:
42 * This provides a first-order approximation assuming linear velocity variation
43 * in the near-wall region, which is valid in the viscous sublayer.
44 *
45 * @param[in] user Simulation context (unused but required for interface)
46 * @param[in] distance_reference Wall-normal distance to reference point (sc)
47 * @param[in] distance_boundary Wall-normal distance to boundary point (sb)
48 * @param[in] velocity_wall Velocity at the wall (Ua), typically zero
49 * @param[in] velocity_reference Velocity at reference point (Uc)
50 * @param[out] velocity_boundary Computed velocity at boundary point (Ub)
51 * @param[in] normal_x X-component of wall normal vector
52 * @param[in] normal_y Y-component of wall normal vector
53 * @param[in] normal_z Z-component of wall normal vector
54 *
55 * @note For moving walls, velocity_wall would be non-zero
56 * @note The normal vector should point INTO the fluid domain
57 */
58void noslip(UserCtx *user,
59 double distance_reference, double distance_boundary,
60 Cmpnts velocity_wall, Cmpnts velocity_reference,
61 Cmpnts *velocity_boundary,
62 double normal_x, double normal_y, double normal_z);
63
64/**
65 * @brief Applies free-slip wall boundary condition
66 *
67 * Free-slip conditions allow tangential flow but enforce zero normal velocity.
68 * This is appropriate for inviscid walls or symmetry planes where there is
69 * no shear stress but flow cannot penetrate the boundary.
70 *
71 * DECOMPOSITION:
72 * Velocity is decomposed into normal and tangential components:
73 * U = U_n * n + U_t
74 * where U_n = U · n (normal component)
75 * U_t = U - U_n * n (tangential component)
76 *
77 * BOUNDARY CONDITIONS:
78 * - Normal component: Interpolated from interior (∂U_n/∂n ≠ 0)
79 * - Tangential component: Extrapolated from interior (∂U_t/∂n = 0)
80 *
81 * @param[in] user Simulation context
82 * @param[in] distance_reference Wall-normal distance to reference point
83 * @param[in] distance_boundary Wall-normal distance to boundary point
84 * @param[in] velocity_wall Velocity at the wall
85 * @param[in] velocity_reference Velocity at reference point
86 * @param[out] velocity_boundary Computed velocity at boundary point
87 * @param[in] normal_x X-component of wall normal vector
88 * @param[in] normal_y Y-component of wall normal vector
89 * @param[in] normal_z Z-component of wall normal vector
90 */
91void freeslip(UserCtx *user,
92 double distance_reference, double distance_boundary,
93 Cmpnts velocity_wall, Cmpnts velocity_reference,
94 Cmpnts *velocity_boundary,
95 double normal_x, double normal_y, double normal_z);
96
97/**
98 * @brief Computes roughness-modified log-law coefficient E
99 *
100 * The coefficient E accounts for wall roughness effects on the log-law:
101 * u+ = (1/κ) ln(E * y+)
102 *
103 * ROUGHNESS REGIMES:
104 * 1. Hydraulically smooth (ks+ < 2.25): E = exp(κ*B), no roughness effect
105 * 2. Transitional (2.25 < ks+ < 90): Smooth interpolation between regimes
106 * 3. Fully rough (ks+ > 90): E modified by roughness height
107 * where ks+ = u_τ * ks / ν (roughness Reynolds number)
108 *
109 * @param[in] friction_velocity Friction velocity u_τ
110 * @param[in] roughness_height Equivalent sand grain roughness height ks
111 * @param[in] kinematic_viscosity Kinematic viscosity ν
112 * @return Roughness-modified log-law coefficient E
113 *
114 * @note This follows the Nikuradse sand grain roughness correlation
115 */
116double E_coeff(double friction_velocity, double roughness_height, double kinematic_viscosity);
117
118/**
119 * @brief Computes velocity from log-law for rough walls
120 *
121 * Calculates the tangential velocity at a given wall distance using
122 * the roughness-modified log-law of the wall.
123 *
124 * APPLICABLE REGIMES:
125 * - Viscous sublayer (y+ < 11.53): u+ = y+
126 * - Log-layer (11.53 < y+ < 300): u+ = (1/κ) ln(E * y+)
127 * - Outer layer (y+ > 300): Returns -1 (invalid, wake region)
128 *
129 * @param[in] kinematic_viscosity Kinematic viscosity ν
130 * @param[in] wall_distance Distance from wall y
131 * @param[in] friction_velocity Friction velocity u_τ
132 * @param[in] roughness_height Equivalent sand grain roughness ks
133 * @return Tangential velocity u_t, or -1 if outside valid range
134 *
135 * @note The upper limit y+ < 300 ensures we stay within the log-layer
136 * @note For y+ > 300, wake effects become important and log-law is invalid
137 */
138double u_hydset_roughness(double kinematic_viscosity, double wall_distance,
139 double friction_velocity, double roughness_height);
140
141/**
142 * @brief Residual function for friction velocity equation (log-law with roughness)
143 *
144 * This function computes the residual for Newton-Raphson iteration:
145 * f(u_τ) = u_predicted(u_τ) - u_known
146 * where u_predicted comes from the log-law or linear law depending on y+.
147 *
148 * @param[in] kinematic_viscosity Kinematic viscosity
149 * @param[in] known_velocity Known velocity at distance y
150 * @param[in] wall_distance Distance from wall
151 * @param[in] friction_velocity_guess Current guess for u_τ
152 * @param[in] roughness_height Wall roughness height
153 * @return Residual value (should be zero at solution)
154 */
155double f_hydset(double kinematic_viscosity, double known_velocity,
156 double wall_distance, double friction_velocity_guess,
157 double roughness_height);
158
159/**
160 * @brief Numerical derivative of residual function
161 *
162 * Computes df/du_τ using finite differences for Newton-Raphson iteration.
163 *
164 * @param[in] kinematic_viscosity Kinematic viscosity
165 * @param[in] known_velocity Known velocity
166 * @param[in] wall_distance Distance from wall
167 * @param[in] friction_velocity_guess Current guess for u_τ
168 * @param[in] roughness_height Wall roughness
169 * @return Derivative df/du_τ
170 */
171double df_hydset(double kinematic_viscosity, double known_velocity,
172 double wall_distance, double friction_velocity_guess,
173 double roughness_height);
174
175/**
176 * @brief Solves for friction velocity using Newton-Raphson iteration
177 *
178 * Given a known velocity at a known distance from the wall, this function
179 * iteratively solves for the friction velocity u_τ that satisfies the
180 * roughness-modified log-law or linear law.
181 *
182 * ALGORITHM:
183 * Newton-Raphson: u_τ^(n+1) = u_τ^n - f(u_τ^n) / f'(u_τ^n)
184 * Convergence criterion: |u_τ^(n+1) - u_τ^n| < 1e-7
185 *
186 * @param[in] kinematic_viscosity Kinematic viscosity
187 * @param[in] known_velocity Velocity at reference point
188 * @param[in] wall_distance Distance from wall to reference point
189 * @param[in] initial_guess Initial guess for u_τ
190 * @param[in] roughness_height Wall roughness height
191 * @return Converged friction velocity u_τ
192 *
193 * @note Maximum 30 iterations; warns if convergence not achieved
194 * @note Typical convergence in 3-5 iterations for good initial guess
195 */
196double find_utau_hydset(double kinematic_viscosity, double known_velocity,
197 double wall_distance, double initial_guess,
198 double roughness_height);
199
200
201/**
202 * @brief Computes turbulent eddy viscosity ratio (ν_t / ν)
203 *
204 * Uses the mixing length model with van Driest damping:
205 * ν_t / ν = κ * y+ * [1 - exp(-y+ / A+)]²
206 * where A+ ≈ 19 is the damping coefficient.
207 *
208 * PHYSICAL INTERPRETATION:
209 * - Near wall (y+ → 0): ν_t → 0 (viscous effects dominate)
210 * - Far from wall (y+ >> A+): ν_t ~ κ * y+ (mixing length theory)
211 * - Damping function smoothly transitions between these limits
212 *
213 * @param[in] yplus Normalized wall distance y+ = y * u_τ / ν
214 * @return Eddy viscosity ratio ν_t / ν
215 *
216 * @note This is the standard mixing length model with van Driest damping
217 * @note Valid in the inner layer (y+ < 50-100)
218 */
219double nu_t(double yplus);
220
221/**
222 * @brief Integrates eddy viscosity profile from wall to distance y
223 *
224 * Computes integrals needed for non-equilibrium wall functions:
225 * If mode=0: ∫[0 to y] dy / (ν + ν_t)
226 * If mode=1: ∫[0 to y] y dy / (ν + ν_t)
227 *
228 * These integrals appear in the solution of the momentum equation
229 * with pressure gradients in the near-wall region.
230 *
231 * NUMERICAL METHOD:
232 * - Trapezoidal rule with 30 integration points
233 * - Higher-order correction at endpoints for accuracy
234 *
235 * @param[in] kinematic_viscosity Kinematic viscosity ν
236 * @param[in] wall_distance Distance from wall y
237 * @param[in] friction_velocity Friction velocity u_τ
238 * @param[in] integration_mode 0 for F integral, 1 for Fy integral
239 * @return Value of the integral
240 *
241 * @note Used in Cabot wall function for pressure gradient effects
242 */
243double integrate_1(double kinematic_viscosity, double wall_distance,
244 double friction_velocity, int integration_mode);
245
246/**
247 * @brief Computes wall shear stress with pressure gradient effects
248 *
249 * Solves the integrated momentum equation in the near-wall region:
250 * τ_w = (u - dp/dx * F_y) / F_1
251 * where F_1 and F_y are integrals of the effective viscosity profile.
252 *
253 * This accounts for non-equilibrium effects due to streamwise pressure gradients.
254 *
255 * @param[in] kinematic_viscosity Kinematic viscosity
256 * @param[in] friction_velocity Friction velocity u_τ
257 * @param[in] wall_distance Distance from wall
258 * @param[in] velocity Velocity at wall_distance
259 * @param[in] pressure_gradient_tangent Tangential pressure gradient dp/ds
260 * @return Wall shear stress τ_w
261 *
262 * @note This is more accurate than equilibrium wall functions in separated flows
263 */
264double taw(double kinematic_viscosity, double friction_velocity,
265 double wall_distance, double velocity, double pressure_gradient_tangent);
266
267/**
268 * @brief Computes velocity using Cabot wall function
269 *
270 * Reconstructs velocity from wall shear stress and pressure gradient:
271 * u = τ_w * F1 + (dp/dx) * Fy
272 *
273 * @param[in] kinematic_viscosity Kinematic viscosity
274 * @param[in] wall_distance Distance from wall
275 * @param[in] friction_velocity Friction velocity
276 * @param[in] pressure_gradient_tangent Tangential pressure gradient
277 * @param[in] wall_shear_stress Wall shear stress
278 * @return Velocity at wall_distance
279 */
280double u_Cabot(double kinematic_viscosity, double wall_distance,
281 double friction_velocity, double pressure_gradient_tangent,
282 double wall_shear_stress);
283
284/**
285 * @brief Residual function for Cabot wall function
286 *
287 * Computes: f(u_τ) = u_τ - sqrt(|τ_w(u_τ)|)
288 * This enforces consistency between u_τ and τ_w.
289 *
290 * @param[in] kinematic_viscosity Kinematic viscosity
291 * @param[in] velocity Velocity
292 * @param[in] wall_distance Distance from wall
293 * @param[in] friction_velocity_guess Guess for u_τ
294 * @param[in] pressure_gradient_tangent Tangential pressure gradient
295 * @param[in] pressure_gradient_normal Normal pressure gradient (currently unused)
296 * @return Residual value
297 */
298double f_Cabot(double kinematic_viscosity, double velocity, double wall_distance,
299 double friction_velocity_guess, double pressure_gradient_tangent,
300 double pressure_gradient_normal);
301
302/**
303 * @brief Numerical derivative for Cabot wall function
304 *
305 * @param kinematic_viscosity Fluid kinematic viscosity.
306 * @param velocity Resolved tangential velocity at the wall-model point.
307 * @param wall_distance Normal distance from the wall.
308 * @param friction_velocity_guess Current friction-velocity iterate.
309 * @param pressure_gradient_tangent Tangential pressure-gradient contribution.
310 * @param pressure_gradient_normal Normal pressure-gradient contribution.
311 * @return Derivative of the Cabot residual with respect to friction velocity.
312 */
313double df_Cabot(double kinematic_viscosity, double velocity, double wall_distance,
314 double friction_velocity_guess, double pressure_gradient_tangent,
315 double pressure_gradient_normal);
316
317/**
318 * @brief Solves for friction velocity using Cabot wall function
319 *
320 * This non-equilibrium wall function accounts for pressure gradient effects,
321 * making it more accurate in separated or strongly accelerating/decelerating flows.
322 *
323 * @param[in] kinematic_viscosity Kinematic viscosity
324 * @param[in] velocity Velocity at reference point
325 * @param[in] wall_distance Distance from wall
326 * @param[in] initial_guess Initial guess for u_τ
327 * @param[in] pressure_gradient_tangent Tangential pressure gradient
328 * @param[in] pressure_gradient_normal Normal pressure gradient
329 * @param[out] friction_velocity Converged friction velocity
330 * @param[out] wall_shear_velocity Wall shear stress for velocity
331 * @param[out] wall_shear_normal Wall shear stress for normal pressure gradient
332 */
333void find_utau_Cabot(double kinematic_viscosity, double velocity, double wall_distance,
334 double initial_guess, double pressure_gradient_tangent,
335 double pressure_gradient_normal, double *friction_velocity,
336 double *wall_shear_velocity, double *wall_shear_normal);
337
338/**
339 * @brief Computes velocity using Werner-Wengle wall function
340 *
341 * The pointwise Werner-Wengle profile, and the relation the solver uses: the wall
342 * function evaluates it at the boundary cell with the friction velocity that
343 * @ref find_utau_Werner() takes from the reference cell. Explicit relation:
344 * u+ = y+ for y+ < 11.81 (viscous sublayer)
345 * u+ = A * (y+)^B for y+ ≥ 11.81 (power law)
346 * where A = 8.3, B = 1/7 are empirical constants.
347 *
348 * ADVANTAGES:
349 * - Explicit (no iteration required)
350 * - Computationally cheap
351 * - Reasonable accuracy for equilibrium boundary layers
352 *
353 * LIMITATIONS:
354 * - Less accurate than log-law for high Reynolds numbers
355 * - No pressure gradient effects
356 *
357 * @param[in] kinematic_viscosity Kinematic viscosity
358 * @param[in] wall_distance Distance from wall
359 * @param[in] friction_velocity Friction velocity
360 * @return Tangential velocity
361 */
362double u_Werner(double kinematic_viscosity, double wall_distance,
363 double friction_velocity);
364
365
366/**
367 * @brief Wall shear stress from the cell-integrated Werner-Wengle relation.
368 *
369 * @note Not wired into the solver. The profile is assumed to hold across a cell of height
370 * `wall_distance` and integrated, so `velocity` must be the AVERAGE over
371 * [0, wall_distance] - a finite-volume first-cell value with its full height. The
372 * wall function's reference is instead a point value at the second cell's centre;
373 * read as an average it over-predicts u_tau by about (1 + B)^(1/(1+B)), 12-14% on
374 * a wall-modelled channel at Re_tau ~ 1000. The solver uses the pointwise pair
375 * @ref find_utau_Werner() / @ref u_Werner(), which is also closed form. Kept, with
376 * its inverse @ref u_Werner_explicit(), for a caller that does supply a cell average.
377 *
378 * |u| <= u_m : tau_w = 2 nu |u| / y
379 * |u| > u_m : tau_w = [ (1-B)/2 A^((1+B)/(1-B)) (nu/y)^(1+B)
380 * + (1+B)/A (nu/y)^B |u| ]^(2/(1+B))
381 *
382 * with A = 8.3, B = 1/7, and the switch at u_m = nu/(2y) A^(2/(1-B)). That threshold
383 * depends only on the geometry and the fluid, which is what makes the inversion
384 * explicit; a threshold written in terms of the friction velocity would reintroduce the
385 * iteration the model exists to avoid. The two branches meet exactly at u_m.
386 *
387 * Pairs with @ref u_Werner_explicit(), which inverts it. Do not pair it with
388 * @ref u_Werner(), which is the pointwise profile rather than its cell integral.
389 *
390 * @param[in] kinematic_viscosity Kinematic viscosity.
391 * @param[in] velocity Wall-parallel speed at `wall_distance`, sign ignored.
392 * @param[in] wall_distance Normal distance the profile is integrated over.
393 * @return Wall shear stress, equal to the square of the friction velocity.
394 */
395double taw_Werner(double kinematic_viscosity, double velocity, double wall_distance);
396
397/**
398 * @brief Wall-parallel velocity at a distance, from the Werner-Wengle wall stress.
399 *
400 * The exact inverse of @ref taw_Werner(), branch for branch, so that a stress obtained
401 * from a velocity at one distance reproduces a consistent velocity at another. It is
402 * monotonically increasing in `wall_distance`, so a cell nearer the wall than the one
403 * the stress came from is always assigned the slower speed.
404 *
405 * The branch is selected on the stress rather than the velocity it is about to produce,
406 * using the same threshold expressed as tau_m = (nu/y)^2 A^(2/(1-B)).
407 *
408 * @param[in] kinematic_viscosity Kinematic viscosity.
409 * @param[in] wall_distance Normal distance to evaluate at.
410 * @param[in] wall_shear_stress Wall shear stress from @ref taw_Werner().
411 * @return Wall-parallel speed at `wall_distance`, non-negative.
412 */
413double u_Werner_explicit(double kinematic_viscosity, double wall_distance,
414 double wall_shear_stress);
415
416
417/**
418 * @brief Friction velocity from a point velocity, inverting @ref u_Werner() exactly.
419 *
420 * The closed-form inverse of the pointwise Werner-Wengle profile, branch for branch, and
421 * the solver's path. Along that profile U y / nu = (y+)^2 in the sublayer, so the branch
422 * is chosen from the data alone - sublayer while U y / nu <= 11.81^2 - and each branch
423 * inverts explicitly:
424 *
425 * sublayer : u_tau = sqrt(nu |U| / y)
426 * power law : u_tau = ( |U| / (A (y/nu)^B) )^(1/(1+B)), A = 8.3, B = 1/7
427 *
428 * No iteration, so the residual it feeds stays smooth for a matrix-free Jacobian.
429 *
430 * @param[in] kinematic_viscosity Kinematic viscosity
431 * @param[in] velocity Wall-parallel speed at the reference point, sign ignored
432 * @param[in] wall_distance Distance from the wall to that point
433 * @param[in] initial_guess Unused; kept so existing callers need no change
434 * @return Friction velocity
435 */
436double find_utau_Werner(double kinematic_viscosity, double velocity,
437 double wall_distance, double initial_guess);
438
439/**
440 * @brief Computes velocity using simple log-law (smooth wall with roughness offset)
441 *
442 * Simple logarithmic profile:
443 * u = (u_τ / κ) * ln((y + y0) / y0)
444 * where y0 is a roughness length scale.
445 *
446 * @param[in] wall_distance Distance from wall
447 * @param[in] friction_velocity Friction velocity
448 * @param[in] roughness_length Roughness length scale y0
449 * @return Velocity
450 *
451 * @note This is a simplified model; use u_hydset_roughness for better accuracy
452 */
453double u_loglaw(double wall_distance, double friction_velocity, double roughness_length);
454
455/**
456 * @brief Solves for friction velocity using simple log-law (explicit formula)
457 *
458 * Explicit inversion: u_τ = κ * u / ln((y + y0) / y0)
459 *
460 * @param[in] velocity Known velocity
461 * @param[in] wall_distance Distance from wall
462 * @param[in] roughness_length Roughness length scale
463 * @return Friction velocity
464 */
465double find_utau_loglaw(double velocity, double wall_distance, double roughness_length);
466
467/**
468 * @brief Applies standard wall function with Werner-Wengle model
469 *
470 * This is a high-level interface that:
471 * 1. Decomposes velocity into normal/tangential components
472 * 2. Applies wall function to tangential velocity
473 * 3. Interpolates normal velocity
474 * 4. Reconstructs total velocity
475 *
476 * @param[in] user Simulation context
477 * @param[in] distance_reference Distance to reference point
478 * @param[in] distance_boundary Distance to boundary point
479 * @param[in] velocity_wall Wall velocity
480 * @param[in] velocity_reference Reference velocity
481 * @param[out] velocity_boundary Output boundary velocity
482 * @param[out] friction_velocity Output friction velocity
483 * @param[in] normal_x X-component of wall normal
484 * @param[in] normal_y Y-component of wall normal
485 * @param[in] normal_z Z-component of wall normal
486 */
487void wall_function(UserCtx *user, double distance_reference, double distance_boundary,
488 Cmpnts velocity_wall, Cmpnts velocity_reference,
489 Cmpnts *velocity_boundary, PetscReal *friction_velocity,
490 double normal_x, double normal_y, double normal_z);
491
492/**
493 * @brief Applies log-law wall function with roughness correction
494 *
495 * This is the recommended wall function interface for most applications.
496 * It uses the roughness-corrected log-law which is accurate for both
497 * smooth and rough walls.
498 *
499 * @param[in] user Simulation context
500 * @param[in] roughness_height Wall roughness height ks
501 * @param[in] distance_reference Distance to reference point
502 * @param[in] distance_boundary Distance to boundary point
503 * @param[in] velocity_wall Wall velocity (typically zero)
504 * @param[in] velocity_reference Reference velocity
505 * @param[out] velocity_boundary Output boundary velocity
506 * @param[out] friction_velocity Output friction velocity u_τ
507 * @param[in] normal_x X-component of wall normal
508 * @param[in] normal_y Y-component of wall normal
509 * @param[in] normal_z Z-component of wall normal
510 *
511 * @note Sets velocity to reference value if y+ > 300 (outside log-layer)
512 */
513void wall_function_loglaw(UserCtx *user, double roughness_height,
514 double distance_reference, double distance_boundary,
515 Cmpnts velocity_wall, Cmpnts velocity_reference,
516 Cmpnts *velocity_boundary, PetscReal *friction_velocity,
517 double normal_x, double normal_y, double normal_z);
518
519/**
520 * @brief Applies Cabot non-equilibrium wall function with pressure gradients
521 *
522 * This wall function accounts for pressure gradient effects and is most
523 * accurate in separated or strongly accelerating/decelerating flows.
524 *
525 * @param[in] user Simulation context
526 * @param[in] roughness_height Wall roughness (currently unused in this version)
527 * @param[in] distance_reference Distance to reference point
528 * @param[in] distance_boundary Distance to boundary point
529 * @param[in] velocity_wall Wall velocity
530 * @param[in] velocity_reference Reference velocity
531 * @param[out] velocity_boundary Output boundary velocity
532 * @param[out] friction_velocity Output friction velocity
533 * @param[in] normal_x X-component of wall normal
534 * @param[in] normal_y Y-component of wall normal
535 * @param[in] normal_z Z-component of wall normal
536 * @param[in] pressure_gradient_x X-component of pressure gradient
537 * @param[in] pressure_gradient_y Y-component of pressure gradient
538 * @param[in] pressure_gradient_z Z-component of pressure gradient
539 * @param[in] iteration_count Current iteration count
540 *
541 * @note Only updates friction velocity every 5 iterations for stability
542 * @note Normal pressure gradient currently set to zero
543 */
544void wall_function_Cabot(UserCtx *user, double roughness_height,
545 double distance_reference, double distance_boundary,
546 Cmpnts velocity_wall, Cmpnts velocity_reference,
547 Cmpnts *velocity_boundary, PetscReal *friction_velocity,
548 double normal_x, double normal_y, double normal_z,
549 double pressure_gradient_x, double pressure_gradient_y,
550 double pressure_gradient_z, int iteration_count);
551
552#endif // WALLFUNCTION_H
Header file for Particle Motion and migration related functions.
Header file for Particle Swarm management functions.
Public interface for grid, solver, and metric setup routines.
Public interface for data input/output routines.
Logging utilities and macros for PETSc-based applications.
Main header file for a complex fluid dynamics solver.
A 3D point or vector with PetscScalar components.
Definition variables.h:121
User-defined context containing data specific to a single computational grid level.
Definition variables.h:1074
Header file for particle location functions using the walking search algorithm.
double df_Cabot(double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
Numerical derivative for Cabot wall function.
double f_Cabot(double kinematic_viscosity, double velocity, double wall_distance, double friction_velocity_guess, double pressure_gradient_tangent, double pressure_gradient_normal)
Residual function for Cabot wall function.
void wall_function_loglaw(UserCtx *user, double roughness_height, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, PetscReal *friction_velocity, double normal_x, double normal_y, double normal_z)
Applies log-law wall function with roughness correction.
double find_utau_loglaw(double velocity, double wall_distance, double roughness_length)
Solves for friction velocity using simple log-law (explicit formula)
double u_Werner(double kinematic_viscosity, double wall_distance, double friction_velocity)
Computes velocity using Werner-Wengle wall function.
double u_hydset_roughness(double kinematic_viscosity, double wall_distance, double friction_velocity, double roughness_height)
Computes velocity from log-law for rough walls.
void wall_function(UserCtx *user, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, PetscReal *friction_velocity, double normal_x, double normal_y, double normal_z)
Applies standard wall function with Werner-Wengle model.
double u_Werner_explicit(double kinematic_viscosity, double wall_distance, double wall_shear_stress)
Wall-parallel velocity at a distance, from the Werner-Wengle wall stress.
double taw(double kinematic_viscosity, double friction_velocity, double wall_distance, double velocity, double pressure_gradient_tangent)
Computes wall shear stress with pressure gradient effects.
double find_utau_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double initial_guess, double roughness_height)
Solves for friction velocity using Newton-Raphson iteration.
double u_Cabot(double kinematic_viscosity, double wall_distance, double friction_velocity, double pressure_gradient_tangent, double wall_shear_stress)
Computes velocity using Cabot wall function.
double u_loglaw(double wall_distance, double friction_velocity, double roughness_length)
Computes velocity using simple log-law (smooth wall with roughness offset)
void wall_function_Cabot(UserCtx *user, double roughness_height, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, PetscReal *friction_velocity, double normal_x, double normal_y, double normal_z, double pressure_gradient_x, double pressure_gradient_y, double pressure_gradient_z, int iteration_count)
Applies Cabot non-equilibrium wall function with pressure gradients.
void noslip(UserCtx *user, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, double normal_x, double normal_y, double normal_z)
Applies no-slip wall boundary condition with linear interpolation.
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)
Solves for friction velocity using Cabot wall function.
double integrate_1(double kinematic_viscosity, double wall_distance, double friction_velocity, int integration_mode)
Integrates eddy viscosity profile from wall to distance y.
double f_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
Residual function for friction velocity equation (log-law with roughness)
double E_coeff(double friction_velocity, double roughness_height, double kinematic_viscosity)
Computes roughness-modified log-law coefficient E.
double taw_Werner(double kinematic_viscosity, double velocity, double wall_distance)
Wall shear stress from the cell-integrated Werner-Wengle relation.
double nu_t(double yplus)
Computes turbulent eddy viscosity ratio (ν_t / ν)
double df_hydset(double kinematic_viscosity, double known_velocity, double wall_distance, double friction_velocity_guess, double roughness_height)
Numerical derivative of residual function.
double find_utau_Werner(double kinematic_viscosity, double velocity, double wall_distance, double initial_guess)
Friction velocity from a point velocity, inverting u_Werner() exactly.
void freeslip(UserCtx *user, double distance_reference, double distance_boundary, Cmpnts velocity_wall, Cmpnts velocity_reference, Cmpnts *velocity_boundary, double normal_x, double normal_y, double normal_z)
Applies free-slip wall boundary condition.