8 #include <athena/athena.hpp>
9 #include <athena/coordinates/coordinates.hpp>
10 #include <athena/hydro/hydro.hpp>
11 #include <athena/mesh/mesh.hpp>
18 cmu_ = pin->GetOrAddReal(
"turbulence",
"kepsilon.cmu", 0.09);
19 c1_ = pin->GetOrAddReal(
"turbulence",
"kepsilon.c1", 1.44);
20 c2_ = pin->GetOrAddReal(
"turbulence",
"kepsilon.c2", 1.92);
21 sigk_ = pin->GetOrAddReal(
"turbulence",
"kepsilon.sigk", 1.0);
22 sige_ = pin->GetOrAddReal(
"turbulence",
"kepsilon.sige", 1.3);
25 Real tke0 = pin->GetOrAddReal(
"turbulence",
"kepsilon.tke0", 1.);
27 int il = pmb->is - NGHOST;
30 int iu = pmb->ie + NGHOST;
33 if (pmb->block_size.nx2 > 1) {
37 if (pmb->block_size.nx3 > 1) {
42 for (
int k = kl; k <= ku; ++k)
43 for (
int j = jl;
j <= ju; ++
j)
44 for (
int i = il; i <= iu; ++i) {
47 Real volume = pmb->pcoord->GetCellVolume(k,
j, i);
48 Real eps0 = pow(tke0, 1.5) / pow(volume, 1. / 3.);
55 auto phydro = pmb->phydro;
57 for (
int k = pmb->ks; k <= pmb->ke; ++k)
58 for (
int j = pmb->js; j <= pmb->je; ++
j)
59 for (
int i = pmb->is; i <= pmb->ie; ++i) {
60 Real rhod = phydro->w(IDN, k,
j, i);
61 u(0, k,
j, i) =
w(0, k,
j, i) * rhod;
62 u(1, k,
j, i) =
w(1, k,
j, i) * rhod;
64 cmu_ * rhod *
w(1, k,
j, i) *
w(1, k,
j, i) /
w(0, k,
j, i);
71 Mesh *pm = pcoord->pmy_block->pmy_mesh;
74 Real mut_p = (mut(k,
j, i + 1) + mut(k,
j, i)) / 2.;
75 Real mut_m = (mut(k,
j, i) + mut(k,
j, i - 1)) / 2.;
77 (v(k,
j, i + 1) - v(k,
j, i)) / (pcoord->x1v(i + 1) - pcoord->x1v(i));
79 (v(k,
j, i) - v(k,
j, i - 1)) / (pcoord->x1v(i) - pcoord->x1v(i - 1));
80 result += (mut_p * gradv_p - mut_m * gradv_m) / pcoord->dx1f(i);
84 mut_p = (mut(k,
j + 1, i) + mut(k,
j, i)) / 2.;
85 mut_m = (mut(k,
j, i) + mut(k,
j - 1, i)) / 2.;
87 (v(k,
j + 1, i) - v(k,
j, i)) / (pcoord->x2v(
j + 1) - pcoord->x2v(
j));
89 (v(k,
j, i) - v(k,
j - 1, i)) / (pcoord->x2v(
j) - pcoord->x2v(
j - 1));
90 result += (mut_p * gradv_p - mut_m * gradv_m) / pcoord->dx2f(
j);
95 mut_p = (mut(k + 1,
j, i) + mut(k,
j, i)) / 2.;
96 mut_m = (mut(k,
j, i) + mut(k - 1,
j, i)) / 2.;
98 (v(k + 1,
j, i) - v(k,
j, i)) / (pcoord->x3v(k + 1) - pcoord->x3v(k));
100 (v(k,
j, i) - v(k - 1,
j, i)) / (pcoord->x3v(k) - pcoord->x3v(k - 1));
101 result += (mut_p * gradv_p - mut_m * gradv_m) / pcoord->dx3f(k);
110 Mesh *pm = pcoord->pmy_block->pmy_mesh;
111 Real gradv, gradv1, gradv2, gradv3, gradv4;
114 gradv = (w(IM1, k,
j, i + 1) - w(IM1, k,
j, i - 1)) /
115 (pcoord->x1v(i + 1) - pcoord->x1v(i - 1));
116 result += 2 * gradv * gradv;
120 gradv = (w(IM2, k,
j + 1, i) - w(IM2, k,
j - 1, i)) /
121 (pcoord->x2v(
j + 1) - pcoord->x2v(
j - 1));
122 gradv1 = (w(IM1, k,
j + 1, i) - w(IM1, k,
j - 1, i)) /
123 (pcoord->x2v(
j + 1) - pcoord->x2v(
j - 1));
124 gradv2 = (w(IM2, k,
j, i + 1) - w(IM2, k,
j, i - 1)) /
125 (pcoord->x1v(i + 1) - pcoord->x1v(i - 1));
126 result += 2 * gradv * gradv + (gradv1 + gradv2) * (gradv1 + gradv2);
131 gradv = (w(IM3, k + 1,
j, i) - w(IM3, k - 1,
j, i)) /
132 (pcoord->x3v(k + 1) - pcoord->x3v(k - 1));
133 gradv1 = (w(IM1, k + 1,
j, i) - w(IM1, k - 1,
j, i)) /
134 (pcoord->x3v(k + 1) - pcoord->x3v(k - 1));
135 gradv2 = (w(IM3, k,
j, i + 1) - w(IM3, k,
j, i - 1)) /
136 (pcoord->x1v(i + 1) - pcoord->x1v(i - 1));
137 gradv3 = (w(IM2, k + 1,
j, i) - w(IM2, k - 1,
j, i)) /
138 (pcoord->x3v(k + 1) - pcoord->x3v(k - 1));
139 gradv4 = (w(IM3, k,
j + 1, i) - w(IM3, k,
j - 1, i)) /
140 (pcoord->x2v(
j + 1) - pcoord->x2v(
j - 1));
141 result += 2 * gradv * gradv + (gradv1 + gradv2) * (gradv1 + gradv2) +
142 (gradv3 + gradv4) * (gradv3 + gradv4);
151 auto phydro = pmb->phydro;
153 int ks = pmb->ks, js = pmb->js, is = pmb->is;
154 int ke = pmb->ke, je = pmb->je, ie = pmb->ie;
157 eps.InitWithShallowSlice(
w, 4, 0, 1);
158 tke.InitWithShallowSlice(
w, 4, 1, 1);
161 for (
int k = ks; k <= ke; ++k)
162 for (
int j = js;
j <= je; ++
j)
163 for (
int i = is; i <= ie; ++i) {
164 Real rhod = phydro->w(IDN, k,
j, i);
170 s1 =
c1_ *
mut(k,
j, i) * eps(k,
j, i) / tke(k,
j, i) * shear;
172 s3 = -
c2_ * eps(k,
j, i) * eps(k,
j, i) / tke(k,
j, i) * rhod;
173 u(0, k,
j, i) += (s1 + s2) * dt;
174 if (
u(0, k,
j, i) + s3 * dt > 0)
175 u(0, k,
j, i) += s3 * dt;
181 s1 =
mut(k,
j, i) * shear;
183 s3 = -eps(k,
j, i) * rhod;
184 u(1, k,
j, i) += (s1 + s2) * dt;
185 if (
u(1, k,
j, i) + s3 * dt > 0.)
186 u(1, k,
j, i) += s3 * dt;
196 int iu,
int jl,
int ju,
int kl,
199 eps.InitWithShallowSlice(
w, 4, 0, 1);
200 tke.InitWithShallowSlice(
w, 4, 1, 1);
202 for (
int k = kl; k <= ku; ++k) {
203 for (
int j = jl;
j <= ju; ++
j) {
205 for (
int i = il; i <= iu; ++i) {
207 mut(k,
j, i) =
cmu_ * prim(IDN, k,
j, i) * tke(k,
j, i) * tke(k,
j, i) /
211 nu(HydroDiffusion::DiffProcess::iso, k,
j, i) =
212 mut(k,
j, i) / prim(IDN, k,
j, i);
213 kappa(HydroDiffusion::DiffProcess::iso, k,
j, i) =
214 nu(HydroDiffusion::DiffProcess::iso, k,
j, i);
void DriveTurbulence(Real dt)
KEpsilonTurbulence(MeshBlock *pmb, ParameterInput *pin)
void SetDiffusivity(AthenaArray< Real > &nu, AthenaArray< Real > &kappa, const AthenaArray< Real > &w, const AthenaArray< Real > &bc, int il, int iu, int jl, int ju, int kl, int ku)
Real ShearProduction_(AthenaArray< Real > const &w, int k, int j, int i, Coordinates *pcoord)
Real Laplace_(AthenaArray< Real > const &mut, AthenaArray< Real > const &v, int k, int j, int i, Coordinates *pcoord)