/home/runner/work/amr-wind/amr-wind/amr-wind/boundary_conditions/wall_models/LogLaw.H Source File

AMR-Wind API: /home/runner/work/amr-wind/amr-wind/amr-wind/boundary_conditions/wall_models/LogLaw.H Source File
AMR-Wind API v0.1.0
CFD solver for wind plant simulations
Loading...
Searching...
No Matches
LogLaw.H
Go to the documentation of this file.
1#ifndef LogLaw_H
2#define LogLaw_H
3
4#include "AMReX_AmrCore.H"
5#include <AMReX.H>
6namespace amr_wind {
7struct LogLaw
8{
9 /*
10 * A simple wall model that sets the wall-shear stress
11 * based on computing u_tau given the horizontal velocity
12 * magnitude at a zref. This is akin to an explicit non-linear
13 * Robin boundary condition at the wall.
14 */
15
16 // Log law constants from Lee & Moser 2015
17 // https://doi.org/10.1017/jfm.2015.268.
18 amrex::Real B{4.27};
19 amrex::Real kappa{0.384};
20 int max_iters = 25; // Max iterations for u_tau Newton-Raphson solve
21 // Reference height for log law
22 amrex::Real zref;
23 int ref_index{0};
24 amrex::Real nu; // molecular viscosity
25 // u_tau state variable, gets updated in update_utau depending on
26 // the type of wall model used
27 amrex::Real utau_mean{1.0};
28 amrex::Real wspd_mean; // mean horizontal velocity magnitude
29
31
32 AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real
33 get_utau(amrex::Real wspd) const
34 {
35 amrex::Real utau_iter = -1;
36 amrex::Real wspd_pred;
37 amrex::Real wspd_deriv;
38 amrex::Real zplus;
39 amrex::Real utau = utau_mean;
40 int iter = 0;
41 while ((std::abs(utau_iter - utau) > 1e-5) && iter <= max_iters) {
42 utau_iter = utau;
43 zplus = zref * utau / nu;
44 // Get wspd for a given utau from log-law
45 wspd_pred = utau * (std::log(zplus) / kappa + B);
46 wspd_deriv = (1 + std::log(zplus)) / kappa + B; // d(wspd)/d(utau)
47 utau =
48 utau - (wspd_pred - wspd) / wspd_deriv; // Newton-Raphson update
49 ++iter;
50 }
51 if (iter == max_iters) {
52 amrex::Abort();
53 }
54 return utau;
55 }
56};
57} /* namespace amr_wind */
58
59#endif /* LogLaw_H */
Definition BCInterface.cpp:7
Definition LogLaw.H:8
amrex::Real kappa
Definition LogLaw.H:19
int max_iters
Definition LogLaw.H:20
amrex::Real wspd_mean
Definition LogLaw.H:28
amrex::Real B
Definition LogLaw.H:18
amrex::Real nu
Definition LogLaw.H:24
amrex::Real zref
Definition LogLaw.H:22
amrex::Real utau_mean
Definition LogLaw.H:27
int ref_index
Definition LogLaw.H:23
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real get_utau(amrex::Real wspd) const
Definition LogLaw.H:33
void update_utau_mean()
Definition LogLaw.H:30