Newer
Older
#include "sfx-data.h"
#include "sfx-math.cuh"
template<typename T>
FUCNTION_DECLARATION_SPECIFIER void get_thermal_roughness(T &z0_t, T &B,
const T z0_m, const T Re,
const struct sfx_surface_param& param,
const int surface_type)
{
// --- define B = logf(z0_m / z0_t)
B = (Re <= param.Re_rough_min) ? param.B1_rough * logf(param.B3_rough * Re) + param.B2_rough :
param.B4_rough * (powf(Re, param.B2_rough));
// --- apply max restriction based on surface type
if (surface_type == param.surface_ocean) B = sfx_math::min(B, param.B_max_ocean);
if (surface_type == param.surface_lake) B = sfx_math::min(B, param.B_max_lake);
if (surface_type == param.surface_land) B = sfx_math::min(B, param.B_max_land);
// --- define roughness [thermal]
z0_t = z0_m / exp(B);
}
template<typename T>
FUCNTION_DECLARATION_SPECIFIER void get_charnock_roughness(T &z0_m, T &u_dyn0,
{
T Uc, a, b, c, c_min, f;
Uc = U;
a = 0.0;
b = 25.0;
c_min = logf(surface_param.h_charnock) / surface_param.kappa;
f = surface_param.c1_charnock - 2.0 * logf(Uc);
c = (f + 2.0 * logf(b)) / surface_param.kappa;
a = logf(1.0 + surface_param.c2_charnock * ( powf(b / Uc, 3) ) ) / surface_param.kappa;
z0_m = surface_param.h_charnock * exp(-c * surface_param.kappa);
Uc = U * logf(surface_param.h_charnock / z0_m) / logf(h / z0_m);