#include <petscpf.h>#include <petscdmswarm.h>#include <stdlib.h>#include <time.h>#include <math.h>#include <petsctime.h>#include <petscsys.h>#include <petscdmcomposite.h>#include <petscsystypes.h>#include "variables.h"#include "ParticleSwarm.h"#include "walkingsearch.h"#include "grid.h"#include "logging.h"#include "io.h"#include "interpolation.h"#include "ParticleMotion.h"#include "Boundaries.h"Go to the source code of this file.
Functions | |
| double | E_coeff (double friction_velocity, double roughness_height, double kinematic_viscosity) |
| Computes roughness-modified log-law coefficient E. | |
| double | u_hydset_roughness (double kinematic_viscosity, double wall_distance, double friction_velocity, double roughness_height) |
| Computes velocity from log-law for rough walls. | |
| 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 | 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_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 | nu_t (double yplus) |
| Computes turbulent eddy viscosity ratio (ν_t / ν) | |
| 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 | 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 | 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 | 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. | |
| 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. | |
| 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 | u_Werner (double kinematic_viscosity, double wall_distance, double friction_velocity) |
| Computes velocity using Werner-Wengle wall function. | |
| double | taw_Werner (double kinematic_viscosity, double velocity, double wall_distance) |
| Wall shear stress from the cell-integrated Werner-Wengle relation. | |
| 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 | find_utau_Werner (double kinematic_viscosity, double velocity, double wall_distance, double initial_guess) |
| Friction velocity from a point velocity, inverting u_Werner() exactly. | |
| double E_coeff | ( | double | friction_velocity, |
| double | roughness_height, | ||
| double | kinematic_viscosity | ||
| ) |
Computes roughness-modified log-law coefficient E.
The coefficient E accounts for wall roughness effects on the log-law: u+ = (1/κ) ln(E * y+)
ROUGHNESS REGIMES:
| [in] | friction_velocity | Friction velocity u_τ |
| [in] | roughness_height | Equivalent sand grain roughness height ks |
| [in] | kinematic_viscosity | Kinematic viscosity ν |
Computes roughness-modified log-law coefficient E.
Definition at line 77 of file wallfunction.c.
| double u_hydset_roughness | ( | double | kinematic_viscosity, |
| double | wall_distance, | ||
| double | friction_velocity, | ||
| double | roughness_height | ||
| ) |
Computes velocity from log-law for rough walls.
Calculates the tangential velocity at a given wall distance using the roughness-modified log-law of the wall:
| [in] | kinematic_viscosity | Kinematic viscosity ν |
| [in] | wall_distance | Distance from wall y |
| [in] | friction_velocity | Friction velocity u_τ |
| [in] | roughness_height | Equivalent sand grain roughness ks |
Computes velocity from log-law for rough walls.
Definition at line 134 of file wallfunction.c.
| 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)
This function computes the residual for Newton-Raphson iteration: f(u_τ) = u_predicted(u_τ) - u_known where u_predicted comes from the log-law or linear law depending on y+.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | known_velocity | Known velocity at distance y |
| [in] | wall_distance | Distance from wall |
| [in] | friction_velocity_guess | Current guess for u_τ |
| [in] | roughness_height | Wall roughness height |
Residual function for friction velocity equation (log-law with roughness)
Definition at line 167 of file wallfunction.c.
| double df_hydset | ( | double | kinematic_viscosity, |
| double | known_velocity, | ||
| double | wall_distance, | ||
| double | friction_velocity_guess, | ||
| double | roughness_height | ||
| ) |
Numerical derivative of residual function.
Computes df/du_τ using finite differences for Newton-Raphson iteration.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | known_velocity | Known velocity |
| [in] | wall_distance | Distance from wall |
| [in] | friction_velocity_guess | Current guess for u_τ |
| [in] | roughness_height | Wall roughness |
Numerical derivative of residual function.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.
Definition at line 193 of file wallfunction.c.
| 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.
Given a known velocity at a known distance from the wall, this function iteratively solves for the friction velocity u_τ that satisfies the roughness-modified log-law or linear law.
ALGORITHM: Newton-Raphson: u_τ^(n+1) = u_τ^n - f(u_τ^n) / f'(u_τ^n) Convergence criterion: |u_τ^(n+1) - u_τ^n| < 1e-7
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | known_velocity | Velocity at reference point |
| [in] | wall_distance | Distance from wall to reference point |
| [in] | initial_guess | Initial guess for u_τ |
| [in] | roughness_height | Wall roughness height |
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.
Definition at line 214 of file wallfunction.c.
| double nu_t | ( | double | yplus | ) |
Computes turbulent eddy viscosity ratio (ν_t / ν)
Uses the mixing length model with van Driest damping: ν_t / ν = κ * y+ * [1 - exp(-y+ / A+)]² where A+ ≈ 19 is the damping coefficient.
PHYSICAL INTERPRETATION:
| [in] | yplus | Normalized wall distance y+ = y * u_τ / ν |
Computes turbulent eddy viscosity ratio (ν_t / ν)
Definition at line 267 of file wallfunction.c.
| double integrate_1 | ( | double | kinematic_viscosity, |
| double | wall_distance, | ||
| double | friction_velocity, | ||
| int | integration_mode | ||
| ) |
Integrates eddy viscosity profile from wall to distance y.
Computes integrals needed for non-equilibrium wall functions: If mode=0: ∫[0 to y] dy / (ν + ν_t) If mode=1: ∫[0 to y] y dy / (ν + ν_t)
These integrals appear in the solution of the momentum equation with pressure gradients in the near-wall region.
NUMERICAL METHOD:
| [in] | kinematic_viscosity | Kinematic viscosity ν |
| [in] | wall_distance | Distance from wall y |
| [in] | friction_velocity | Friction velocity u_τ |
| [in] | integration_mode | 0 for F integral, 1 for Fy integral |
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.
Definition at line 282 of file wallfunction.c.
| 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.
Solves the integrated momentum equation in the near-wall region: τ_w = (u - dp/dx * F_y) / F_1 where F_1 and F_y are integrals of the effective viscosity profile.
This accounts for non-equilibrium effects due to streamwise pressure gradients.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | friction_velocity | Friction velocity u_τ |
| [in] | wall_distance | Distance from wall |
| [in] | velocity | Velocity at wall_distance |
| [in] | pressure_gradient_tangent | Tangential pressure gradient dp/ds |
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.
Definition at line 317 of file wallfunction.c.
| 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.
Reconstructs velocity from wall shear stress and pressure gradient: u = τ_w * F1 + (dp/dx) * Fy
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | wall_distance | Distance from wall |
| [in] | friction_velocity | Friction velocity |
| [in] | pressure_gradient_tangent | Tangential pressure gradient |
| [in] | wall_shear_stress | Wall shear stress |
Computes velocity using Cabot wall function.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.
Definition at line 334 of file wallfunction.c.
| 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.
Computes: f(u_τ) = u_τ - sqrt(|τ_w(u_τ)|) This enforces consistency between u_τ and τ_w.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | velocity | Velocity |
| [in] | wall_distance | Distance from wall |
| [in] | friction_velocity_guess | Guess for u_τ |
| [in] | pressure_gradient_tangent | Tangential pressure gradient |
| [in] | pressure_gradient_normal | Normal pressure gradient (currently unused) |
Residual function for Cabot wall function.
Definition at line 348 of file wallfunction.c.
| 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.
| kinematic_viscosity | Fluid kinematic viscosity. |
| velocity | Resolved tangential velocity at the wall-model point. |
| wall_distance | Normal distance from the wall. |
| friction_velocity_guess | Current friction-velocity iterate. |
| pressure_gradient_tangent | Tangential pressure-gradient contribution. |
| pressure_gradient_normal | Normal pressure-gradient contribution. |
Numerical derivative for Cabot wall function.
Full API contract (arguments, ownership, side effects) is documented with the header declaration in include/wallfunction.h.
Definition at line 365 of file wallfunction.c.
| 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.
This non-equilibrium wall function accounts for pressure gradient effects, making it more accurate in separated or strongly accelerating/decelerating flows.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | velocity | Velocity at reference point |
| [in] | wall_distance | Distance from wall |
| [in] | initial_guess | Initial guess for u_τ |
| [in] | pressure_gradient_tangent | Tangential pressure gradient |
| [in] | pressure_gradient_normal | Normal pressure gradient |
| [out] | friction_velocity | Converged friction velocity |
| [out] | wall_shear_velocity | Wall shear stress for velocity |
| [out] | wall_shear_normal | Wall shear stress for normal pressure gradient |
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.
Definition at line 388 of file wallfunction.c.
| double u_Werner | ( | double | kinematic_viscosity, |
| double | wall_distance, | ||
| double | friction_velocity | ||
| ) |
Computes velocity using Werner-Wengle wall function.
The pointwise Werner-Wengle profile. Not called by the solver, which takes the friction velocity from its exact inverse, find_utau_Werner(), at the reference cell; this forward form is the definition that inverse is tested against. Explicit relation: u+ = y+ below the sublayer edge (viscous sublayer) u+ = A * (y+)^B above it (power law) where A = 8.3, B = 1/7, and the edge is where the two meet, A^(7/6) = 11.8102.
ADVANTAGES:
LIMITATIONS:
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | wall_distance | Distance from wall |
| [in] | friction_velocity | Friction velocity |
Computes velocity using Werner-Wengle wall function.
Definition at line 444 of file wallfunction.c.
| double taw_Werner | ( | double | kinematic_viscosity, |
| double | velocity, | ||
| double | wall_distance | ||
| ) |
Wall shear stress from the cell-integrated Werner-Wengle relation.
wall_distance and integrated, so velocity must be the AVERAGE over [0, wall_distance] - a finite-volume first-cell value with its full height. The wall function's reference is instead a point value at the second cell's centre; read as an average it over-predicts u_tau by about (1 + B)^(1/(1+B)), 12-14% on a wall-modelled channel at Re_tau ~ 1000. The solver uses the pointwise pair find_utau_Werner() / u_Werner(), which is also closed form. Kept, with its inverse u_Werner_explicit(), for a caller that does supply a cell average.|u| <= u_m : tau_w = 2 nu |u| / y |u| > u_m : tau_w = [ (1-B)/2 A^((1+B)/(1-B)) (nu/y)^(1+B)
with A = 8.3, B = 1/7, and the switch at u_m = nu/(2y) A^(2/(1-B)). That threshold depends only on the geometry and the fluid, which is what makes the inversion explicit; a threshold written in terms of the friction velocity would reintroduce the iteration the model exists to avoid. The two branches meet exactly at u_m.
Pairs with u_Werner_explicit(), which inverts it. Do not pair it with u_Werner(), which is the pointwise profile rather than its cell integral.
| [in] | kinematic_viscosity | Kinematic viscosity. |
| [in] | velocity | Wall-parallel speed at wall_distance, sign ignored. |
| [in] | wall_distance | Normal distance the profile is integrated over. |
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.
| 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.
The exact inverse of taw_Werner(), branch for branch, so that a stress obtained from a velocity at one distance reproduces a consistent velocity at another. It is monotonically increasing in wall_distance, so a cell nearer the wall than the one the stress came from is always assigned the slower speed.
The branch is selected on the stress rather than the velocity it is about to produce, using the same threshold expressed as tau_m = (nu/y)^2 A^(2/(1-B)).
| [in] | kinematic_viscosity | Kinematic viscosity. |
| [in] | wall_distance | Normal distance to evaluate at. |
| [in] | wall_shear_stress | Wall shear stress from taw_Werner(). |
wall_distance, non-negative.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.
| 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.
The closed-form inverse of the pointwise Werner-Wengle profile, branch for branch, and the solver's path. Along that profile U y / nu = (y+)^2 in the sublayer, so the branch is chosen from the data alone - sublayer while U y / nu <= (8.3^(7/6))^2, about 11.8102^2 - and each branch inverts explicitly:
sublayer : u_tau = sqrt(nu |U| / y) power law : u_tau = ( |U| / (A (y/nu)^B) )^(1/(1+B)), A = 8.3, B = 1/7
No iteration, so the residual it feeds stays smooth for a matrix-free Jacobian.
| [in] | kinematic_viscosity | Kinematic viscosity |
| [in] | velocity | Wall-parallel speed at the reference point, sign ignored |
| [in] | wall_distance | Distance from the wall to that point |
| [in] | initial_guess | Unused; kept so existing callers need no change |
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.
Definition at line 552 of file wallfunction.c.