Global Balance of Squared Velocity

Sink (Dissipation)

There are 9 terms dissipating the squared velocity, which are computed separately.

\[\sumzc \sumyc \sumxc \dkdis{1}{1}\]
src/logging/dissipated_squared_velocity.c
17static int get_duxdx (
18    const domain_t * domain,
19    const fluid_t * fluid,
20    double * quantity
21) {
22  const int isize = domain->mysizes[0];
23  const int jsize = domain->mysizes[1];
24#if NDIMS == 3
25  const int ksize = domain->mysizes[2];
26#endif
27  const double * restrict hxxc = domain->hxxc;
28  const double * restrict jdxc = domain->jdxc;
29  const double * restrict ux = fluid->ux.data;
30  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
31#if NDIMS == 2
32  for (int j = 1; j <= jsize; j++) {
33    for (int i = 1; i <= isize; i++) {
34      const double hx = HXXC(i);
35      const double jd = JDXC(i);
36      const double dux =
37        - UX(i  , j  )
38        + UX(i+1, j  );
39      *quantity += diffusivity * jd * pow(1. / hx * dux, 2.);
40    }
41  }
42#else
43  for (int k = 1; k <= ksize; k++) {
44    for (int j = 1; j <= jsize; j++) {
45      for (int i = 1; i <= isize; i++) {
46        const double hx = HXXC(i);
47        const double jd = JDXC(i);
48        const double dux =
49          - UX(i  , j  , k  )
50          + UX(i+1, j  , k  );
51        *quantity += diffusivity * jd * pow(1. / hx * dux, 2.);
52      }
53    }
54  }
55#endif
56  return 0;
57}
\[\sumzc \sumyf \sumxf \dkdis{2}{1}\]
src/logging/dissipated_squared_velocity.c
60static int get_duxdy (
61    const domain_t * domain,
62    const fluid_t * fluid,
63    double * quantity
64) {
65  const int isize = domain->mysizes[0];
66  const int jsize = domain->mysizes[1];
67#if NDIMS == 3
68  const int ksize = domain->mysizes[2];
69#endif
70  const double hy = domain->hy;
71  const double * restrict jdxf = domain->jdxf;
72  const double * restrict ux = fluid->ux.data;
73  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
74#if NDIMS == 2
75  for (int j = 1; j <= jsize; j++) {
76    for (int i = 1; i <= isize + 1; i++) {
77      const double jd = JDXF(i);
78      const double dux =
79        - UX(i  , j-1)
80        + UX(i  , j  );
81      *quantity += diffusivity * jd * pow(1. / hy * dux, 2.);
82    }
83  }
84#else
85  for (int k = 1; k <= ksize; k++) {
86    for (int j = 1; j <= jsize; j++) {
87      for (int i = 1; i <= isize + 1; i++) {
88        const double jd = JDXF(i);
89        const double dux =
90          - UX(i  , j-1, k  )
91          + UX(i  , j  , k  );
92        *quantity += diffusivity * jd * pow(1. / hy * dux, 2.);
93      }
94    }
95  }
96#endif
97  return 0;
98}
\[\sumzf \sumyc \sumxf \dkdis{3}{1}\]
src/logging/dissipated_squared_velocity.c
102static int get_duxdz (
103    const domain_t * domain,
104    const fluid_t * fluid,
105    double * quantity
106) {
107  const int isize = domain->mysizes[0];
108  const int jsize = domain->mysizes[1];
109  const int ksize = domain->mysizes[2];
110  const double hz = domain->hz;
111  const double * restrict jdxf = domain->jdxf;
112  const double * restrict ux = fluid->ux.data;
113  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
114  for (int k = 1; k <= ksize; k++) {
115    for (int j = 1; j <= jsize; j++) {
116      for (int i = 1; i <= isize + 1; i++) {
117        const double jd = JDXF(i);
118        const double dux =
119          - UX(i  , j  , k-1)
120          + UX(i  , j  , k  );
121        *quantity += diffusivity * jd * pow(1. / hz * dux, 2.);
122      }
123    }
124  }
125  return 0;
126}
\[\sumzc \sumyf \sumxf \dkdis{1}{2}\]
src/logging/dissipated_squared_velocity.c
130static int get_duydx (
131    const domain_t * domain,
132    const fluid_t * fluid,
133    double * quantity
134) {
135  const int isize = domain->mysizes[0];
136  const int jsize = domain->mysizes[1];
137#if NDIMS == 3
138  const int ksize = domain->mysizes[2];
139#endif
140  const double * restrict hxxf = domain->hxxf;
141  const double * restrict jdxf = domain->jdxf;
142  const double * restrict uy = fluid->uy.data;
143  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
144#if NDIMS == 2
145  for (int j = 1; j <= jsize; j++) {
146    for (int i = 1; i <= isize + 1; i++) {
147      const double hx = HXXF(i);
148      const double jd = JDXF(i);
149      const double duy =
150        - UY(i-1, j  )
151        + UY(i  , j  );
152      *quantity += diffusivity * jd * pow(1. / hx * duy, 2.);
153    }
154  }
155#else
156  for (int k = 1; k <= ksize; k++) {
157    for (int j = 1; j <= jsize; j++) {
158      for (int i = 1; i <= isize + 1; i++) {
159        const double hx = HXXF(i);
160        const double jd = JDXF(i);
161        const double duy =
162          - UY(i-1, j  , k  )
163          + UY(i  , j  , k  );
164        *quantity += diffusivity * jd * pow(1. / hx * duy, 2.);
165      }
166    }
167  }
168#endif
169  return 0;
170}
\[\sumzc \sumyc \sumxc \dkdis{2}{2}\]
src/logging/dissipated_squared_velocity.c
173static int get_duydy (
174    const domain_t * domain,
175    const fluid_t * fluid,
176    double * quantity
177) {
178  const int isize = domain->mysizes[0];
179  const int jsize = domain->mysizes[1];
180#if NDIMS == 3
181  const int ksize = domain->mysizes[2];
182#endif
183  const double hy = domain->hy;
184  const double * restrict jdxc = domain->jdxc;
185  const double * restrict uy = fluid->uy.data;
186  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
187#if NDIMS == 2
188  for (int j = 1; j <= jsize; j++) {
189    for (int i = 1; i <= isize; i++) {
190      const double jd = JDXC(i);
191      const double duy =
192        - UY(i  , j  )
193        + UY(i  , j+1);
194      *quantity += diffusivity * jd * pow(1. / hy * duy, 2.);
195    }
196  }
197#else
198  for (int k = 1; k <= ksize; k++) {
199    for (int j = 1; j <= jsize; j++) {
200      for (int i = 1; i <= isize; i++) {
201        const double jd = JDXC(i);
202        const double duy =
203          - UY(i  , j  , k  )
204          + UY(i  , j+1, k  );
205        *quantity += diffusivity * jd * pow(1. / hy * duy, 2.);
206      }
207    }
208  }
209#endif
210  return 0;
211}
\[\sumzf \sumyf \sumxc \dkdis{3}{2}\]
src/logging/dissipated_squared_velocity.c
215static int get_duydz (
216    const domain_t * domain,
217    const fluid_t * fluid,
218    double * quantity
219) {
220  const int isize = domain->mysizes[0];
221  const int jsize = domain->mysizes[1];
222  const int ksize = domain->mysizes[2];
223  const double hz = domain->hz;
224  const double * restrict jdxc = domain->jdxc;
225  const double * restrict uy = fluid->uy.data;
226  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
227  for (int k = 1; k <= ksize; k++) {
228    for (int j = 1; j <= jsize; j++) {
229      for (int i = 1; i <= isize; i++) {
230        const double jd = JDXC(i);
231        const double duy =
232          - UY(i  , j  , k-1)
233          + UY(i  , j  , k  );
234        *quantity += diffusivity * jd * pow(1. / hz * duy, 2.);
235      }
236    }
237  }
238  return 0;
239}
\[\sumzf \sumyc \sumxf \dkdis{1}{3}\]
src/logging/dissipated_squared_velocity.c
244static int get_duzdx (
245    const domain_t * domain,
246    const fluid_t * fluid,
247    double * quantity
248) {
249  const int isize = domain->mysizes[0];
250  const int jsize = domain->mysizes[1];
251  const int ksize = domain->mysizes[2];
252  const double * restrict hxxf = domain->hxxf;
253  const double * restrict jdxf = domain->jdxf;
254  const double * restrict uz = fluid->uz.data;
255  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
256  for (int k = 1; k <= ksize; k++) {
257    for (int j = 1; j <= jsize; j++) {
258      for (int i = 1; i <= isize + 1; i++) {
259        const double hx = HXXF(i);
260        const double jd = JDXF(i);
261        const double duz =
262          - UZ(i-1, j  , k  )
263          + UZ(i  , j  , k  );
264        *quantity += diffusivity * jd * pow(1. / hx * duz, 2.);
265      }
266    }
267  }
268  return 0;
269}
\[\sumzf \sumyf \sumxc \dkdis{2}{3}\]
src/logging/dissipated_squared_velocity.c
274static int get_duzdy (
275    const domain_t * domain,
276    const fluid_t * fluid,
277    double * quantity
278) {
279  const int isize = domain->mysizes[0];
280  const int jsize = domain->mysizes[1];
281  const int ksize = domain->mysizes[2];
282  const double hy = domain->hy;
283  const double * restrict jdxc = domain->jdxc;
284  const double * restrict uz = fluid->uz.data;
285  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
286  for (int k = 1; k <= ksize; k++) {
287    for (int j = 1; j <= jsize; j++) {
288      for (int i = 1; i <= isize; i++) {
289        const double jd = JDXC(i);
290        const double duz =
291          - UZ(i  , j-1, k  )
292          + UZ(i  , j  , k  );
293        *quantity += diffusivity * jd * pow(1. / hy * duz, 2.);
294      }
295    }
296  }
297  return 0;
298}
\[\sumzc \sumyc \sumxc \dkdis{3}{3}\]
src/logging/dissipated_squared_velocity.c
303static int get_duzdz (
304    const domain_t * domain,
305    const fluid_t * fluid,
306    double * quantity
307) {
308  const int isize = domain->mysizes[0];
309  const int jsize = domain->mysizes[1];
310  const int ksize = domain->mysizes[2];
311  const double hz = domain->hz;
312  const double * restrict jdxc = domain->jdxc;
313  const double * restrict uz = fluid->uz.data;
314  const double diffusivity = fluid_compute_momentum_diffusivity(fluid);
315  for (int k = 1; k <= ksize; k++) {
316    for (int j = 1; j <= jsize; j++) {
317      for (int i = 1; i <= isize; i++) {
318        const double jd = JDXC(i);
319        const double duz =
320          - UZ(i  , j  , k  )
321          + UZ(i  , j  , k+1);
322        *quantity += diffusivity * jd * pow(1. / hz * duz, 2.);
323      }
324    }
325  }
326  return 0;
327}

Source (Injection)

\[\sumzc \sumyc \sumxc J \vel{1} \ave{T}{\gcs{1}}\]

increases the total amount of the squared velocity. Physically this term accounts for the kinetic energy injection due to the buoyancy effects.

This quantity is implemented to monitor as follows:

src/logging/injected_squared_velocity.c
54  double quantity = 0.;
55  BEGIN
56    const double jd_x0 = JDXF(i);
57#if NDIMS == 2
58    const double ux_x0 = UX(i, j);
59    const double  t_x0 =
60      + 0.5 * T(i-1, j  )
61      + 0.5 * T(i  , j  );
62#else
63    const double ux_x0 = UX(i, j, k);
64    const double  t_x0 =
65      + 0.5 * T(i-1, j  , k  )
66      + 0.5 * T(i  , j  , k  );
67#endif
68    quantity += jd_x0 * ux_x0 * t_x0;
69  END
70  const void * sendbuf = root == myrank ? MPI_IN_PLACE : &quantity;
71  void * recvbuf = &quantity;
72  MPI_Reduce(sendbuf, recvbuf, 1, MPI_DOUBLE, MPI_SUM, root, comm_cart);