16#include <unordered_map>
18#include <Kokkos_Core.hpp>
26static const std::unordered_map<std::string, SGSModel> SGS_MODELS = {
51 static bool in_input(
const toml::value & input) {
return input.contains(
"les"); }
82 const double c =
static_cast<double>(
C);
84 const double d =
static_cast<double>(
delta);
91 for (
int i = 0;
i < 3;
i++) {
92 for (
int j = 0;
j < 3;
j++) {
106 static double wale(
const double g[3][3]) {
108 for (
int i = 0;
i < 3;
i++) {
109 for (
int j = 0;
j < 3;
j++) {
111 for (
int k = 0; k < 3; k++)
g2[
i][
j] +=
g[
i][k] *
g[k][
j];
114 const double trace = (
g2[0][0] +
g2[1][1] +
g2[2][2]) / 3.0;
116 for (
int i = 0;
i < 3;
i++) {
117 for (
int j = 0;
j < 3;
j++) {
123 const double denominator = Kokkos::pow(
ss, 2.5) + Kokkos::pow(
sd, 1.25);
130 double b[3][3],
aa = 0.0;
131 for (
int i = 0;
i < 3;
i++) {
132 for (
int j = 0;
j < 3;
j++) {
135 for (
int m = 0;
m < 3;
m++) b[
i][
j] +=
g[
i][
m] *
g[
j][
m];
139 const double B = b[0][0] * b[1][1] - b[0][1] * b[0][1] + b[0][0] * b[2][2] - b[0][2] * b[0][2] +
140 b[1][1] * b[2][2] - b[1][2] * b[1][2];
141 return aa > 0.0 ? Kokkos::sqrt(Kokkos::fmax(
B, 0.0) /
aa) : 0.0;
156 for (
int i = 0;
i < 3;
i++) {
157 for (
int j = 0;
j < 3;
j++) {
159 for (
int k = 0; k < 3; k++)
G[
i][
j] +=
g[k][
i] *
g[k][
j];
162 const double I1 =
G[0][0] +
G[1][1] +
G[2][2];
163 const double I2 =
G[0][0] *
G[1][1] -
G[0][1] *
G[0][1] +
G[0][0] *
G[2][2] -
G[0][2] *
G[0][2] +
164 G[1][1] *
G[2][2] -
G[1][2] *
G[1][2];
165 const double det =
g[0][0] * (
g[1][1] *
g[2][2] -
g[1][2] *
g[2][1]) -
166 g[0][1] * (
g[1][0] *
g[2][2] -
g[1][2] *
g[2][0]) +
167 g[0][2] * (
g[1][0] *
g[2][1] -
g[1][1] *
g[2][0]);
169 double l1 =
I1 / 3.0;
170 const double a1 =
I1 *
I1 / 9.0 -
I2 / 3.0;
173 const double a3 = Kokkos::acos(Kokkos::fmin(1.0, Kokkos::fmax(-1.0,
a2 / Kokkos::pow(
a1, 1.5)))) / 3.0;
174 l1 += 2.0 * Kokkos::sqrt(
a1) * Kokkos::cos(
a3);
176 s[0] =
s[1] =
s[2] = 0.0;
177 if (!(
l1 > 0.0))
return;
179 const double sum = Kokkos::fmax((
I2 -
product) /
l1, 0.0);
180 const double l2 = 0.5 * (sum + Kokkos::sqrt(Kokkos::fmax(sum * sum - 4.0 *
product, 0.0)));
182 s[0] = Kokkos::sqrt(
l1);
183 s[1] = Kokkos::sqrt(Kokkos::fmin(
l2,
l1));
184 s[2] = Kokkos::sqrt(Kokkos::fmin(
l3,
l2));
189 static double sigma(
const double g[3][3]) {
192 if (!(
s[0] > 0.0))
return 0.0;
193 return Kokkos::fmax(
s[2] * (
s[0] -
s[1]) * (
s[1] -
s[2]) / (
s[0] *
s[0]), 0.0);
KOKKOS_INLINE_FUNCTION rtype dot(const rtype *a, const rtype *b)
Compute the dot product of two arrays.
Definition common_math.h:32
float rtype
Definition common_typedef.h:39
SGSModel
Definition les.h:24
Console output: rank-0 info lines, aligned sections and tables, warnings and errors on stderr,...
std::vector< std::pair< std::string, std::string > > Items
Key-value lines of a setup section, in display order.
Definition log.h:27
Eddy viscosity nu_t = C^2 Delta^2 D(g) (Vreman: c Delta^2 D(g)) of the resolved velocity gradient g[i...
Definition les.h:40
static double scotti_factor(double h1, double h2, double h3)
Scotti, Meneveau & Lilly's (1993) factor cosh(sqrt(4/27 ((ln a_1)^2 - ln a_1 ln a_2 + (ln a_2)^2))) f...
Definition les.cpp:74
static KOKKOS_INLINE_FUNCTION double wale(const double g[3][3])
(S^d:S^d)^(3/2) / ((S:S)^(5/2) + (S^d:S^d)^(5/4)), S^d the traceless symmetric part of g^2.
Definition les.h:106
static KOKKOS_INLINE_FUNCTION void singular_values(const double g[3][3], double s[3])
Singular values s1 >= s2 >= s3 >= 0 of g, the square roots of the eigenvalues l1 >= l2 >= l3 of G = g...
Definition les.h:154
static KOKKOS_INLINE_FUNCTION double vreman(const double g[3][3])
sqrt(B / (a:a)) with a_ij = d u_j / d x_i, b = a^T a and B its second invariant.
Definition les.h:129
static KOKKOS_INLINE_FUNCTION double strain_squared(const double g[3][3])
Definition les.h:89
logging::Items summary() const
Definition les.cpp:79
static KOKKOS_INLINE_FUNCTION double sigma(const double g[3][3])
s3 (s1 - s2)(s2 - s3) / s1^2 of the singular values s of g.
Definition les.h:189
static KOKKOS_INLINE_FUNCTION double operator_of(const SGSModel model, const double g[3][3])
D(g) of the model, the eddy viscosity for unit constant and filter width.
Definition les.h:66
static bool in_input(const toml::value &input)
Definition les.h:51
bool dynamic
Definition les.h:46
static KOKKOS_INLINE_FUNCTION double smagorinsky(const double g[3][3])
sqrt(2 S:S).
Definition les.h:102
static LES from_input(const toml::value &input)
The [les] table of an input (see in_input).
Definition les.cpp:42
rtype Pr_t
Definition les.h:43
rtype C
Definition les.h:42
static rtype default_constant(SGSModel model)
Model constant by default: Lilly's C_s, Nicoud & Ducros's C_w, Vreman's c, Nicoud et al....
Definition les.cpp:29
rtype Sc_t
Definition les.h:44
SGSModel model
Definition les.h:41
KOKKOS_INLINE_FUNCTION rtype nu_t(const double g[3][3], const rtype delta) const
Kinematic eddy viscosity for the gradient g[i][j] = d u_i / d x_j and filter width delta.
Definition les.h:81
bool scotti
Definition les.h:45
CellSetup< ExecSpace > c
Definition teno_setup.cpp:1810
Geometry< Space > g
Definition teno_setup.cpp:678
std::vector< double > delta
Definition transport.cpp:285