-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add implementaiton for a log-law based wall model (#847)
* add implementaiton for a log-law based wall model * make clang-format happy * make LogLaw header only and add gpu fix * linter fix * Add unit test and remove print for gpu * remove .h from cmakelist and fix gpu * Add a Schumann type model too * change default constructor for loglaw, and fix bug in utau_mean initialization * add a base amd model that can work without ABL physics to test the log-law wall-model for channel flow * Remove default constructors * Add the newly added wall-models to the doc, along with documentation for the base AMD model and Smagorisnky model * allow the specification of a reference index for the log-law instead of just the first cell * Change to a while loop, and abort if u_tau hasn't converged * make clang happy * formatting change * fix breaking changes from pr #842 * gpu fix for for the notherm model, needed to use CellSizeArray, and a GPUArray for grid spacing --------- Co-authored-by: Marc T. Henry de Frahan <marc.henrydefrahan@nrel.gov>
- Loading branch information
1 parent
ffd7205
commit 4b71037
Showing
12 changed files
with
698 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#ifndef LogLaw_H | ||
#define LogLaw_H | ||
|
||
#include "AMReX_AmrCore.H" | ||
#include <AMReX.H> | ||
namespace amr_wind { | ||
struct LogLaw | ||
{ | ||
/* | ||
* A simple wall model that sets the wall-shear stress | ||
* based on computing u_tau given the horizontal velocity | ||
* magnitude at a zref. This is akin to an explicit non-linear | ||
* Robin boundary condition at the wall. | ||
*/ | ||
|
||
// Log law constants from Lee & Moser 2015 | ||
// https://doi.org/10.1017/jfm.2015.268. | ||
amrex::Real B{4.27}; | ||
amrex::Real kappa{0.384}; | ||
int max_iters = 25; // Max iterations for u_tau Newton-Raphson solve | ||
// Reference height for log law | ||
amrex::Real zref; | ||
int ref_index{0}; | ||
amrex::Real nu; // molecular viscosity | ||
// u_tau state variable, gets updated in update_utau depending on | ||
// the type of wall model used | ||
amrex::Real utau_mean{1.0}; | ||
amrex::Real wspd_mean; // mean horizontal velocity magnitude | ||
|
||
void update_utau_mean() { utau_mean = get_utau(wspd_mean); } | ||
|
||
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real | ||
get_utau(amrex::Real wspd) const | ||
{ | ||
amrex::Real utau_iter = -1; | ||
amrex::Real wspd_pred; | ||
amrex::Real wspd_deriv; | ||
amrex::Real zplus; | ||
amrex::Real utau = utau_mean; | ||
int iter = 0; | ||
while ((std::abs(utau_iter - utau) > 1e-5) && iter <= max_iters) { | ||
utau_iter = utau; | ||
zplus = zref * utau / nu; | ||
// Get wspd for a given utau from log-law | ||
wspd_pred = utau * (std::log(zplus) / kappa + B); | ||
wspd_deriv = (1 + std::log(zplus)) / kappa + B; // d(wspd)/d(utau) | ||
utau = | ||
utau - (wspd_pred - wspd) / wspd_deriv; // Newton-Raphson update | ||
++iter; | ||
} | ||
if (iter == max_iters) { | ||
amrex::Abort(); | ||
} | ||
return utau; | ||
} | ||
}; | ||
} /* namespace amr_wind */ | ||
|
||
#endif /* LogLaw_H */ |
40 changes: 40 additions & 0 deletions
40
amr-wind/boundary_conditions/wall_models/ShearStressSimple.H
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#ifndef SHEARSTRESSSIMPLE_H | ||
#define SHEARSTRESSSIMPLE_H | ||
|
||
#include "amr-wind/boundary_conditions/wall_models/LogLaw.H" | ||
#include "amr-wind/wind_energy/ShearStress.H" | ||
|
||
namespace amr_wind { | ||
|
||
struct SimpleShearSchumann | ||
{ | ||
explicit SimpleShearSchumann(const amr_wind::LogLaw& ll) | ||
: utau2(ll.utau_mean * ll.utau_mean), wspd_mean(ll.wspd_mean), m_ll(ll) | ||
{} | ||
|
||
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real | ||
get_shear(amrex::Real u, amrex::Real /* wspd */) const | ||
{ | ||
return u / wspd_mean * utau2; | ||
}; | ||
|
||
amrex::Real utau2; | ||
amrex::Real wspd_mean; | ||
const amr_wind::LogLaw m_ll; | ||
}; | ||
struct SimpleShearLogLaw | ||
{ | ||
explicit SimpleShearLogLaw(const amr_wind::LogLaw& ll) : m_ll(ll) {} | ||
|
||
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::Real | ||
get_shear(amrex::Real u, amrex::Real wspd) const | ||
{ | ||
amrex::Real utau = m_ll.get_utau(wspd); | ||
return utau * utau * u / wspd; | ||
}; | ||
|
||
const amr_wind::LogLaw m_ll; | ||
}; | ||
} // namespace amr_wind | ||
|
||
#endif /* SHEARSTRESSSIMPLE_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.