Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_stats.f90
Go to the documentation of this file.
1! Copyright (c) 2022-2024, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
37 use mean_field, only : mean_field_t
40 use num_types, only : rp
41 use math, only : invers2, col2, addcol3, col3, copy, subcol3
42 use operators, only : opgrad
43 use coefs, only : coef_t
44 use field, only : field_t
45 use field_list, only : field_list_t
46 use stats_quant, only : stats_quant_t
49 use utils, only : neko_warning
50 implicit none
51 private
52
53 type, public, extends(stats_quant_t) :: fluid_stats_t
55 type(field_t) :: stats_u
56 type(field_t) :: stats_v
57 type(field_t) :: stats_w
58 type(field_t) :: stats_p
59 type(field_t) :: stats_work
60
62 type(field_t), pointer :: u
63 type(field_t), pointer :: v
64 type(field_t), pointer :: w
65 type(field_t), pointer :: p
66
67 type(mean_field_t) :: u_mean
68 type(mean_field_t) :: v_mean
69 type(mean_field_t) :: w_mean
70 type(mean_field_t) :: p_mean
72 type(mean_field_t) :: uu
73 type(mean_field_t) :: vv
74 type(mean_field_t) :: ww
75 type(mean_field_t) :: uv
76 type(mean_field_t) :: uw
77 type(mean_field_t) :: vw
79 type(mean_field_t) :: uuu
80 type(mean_field_t) :: vvv
81 type(mean_field_t) :: www
82 type(mean_field_t) :: uuv
83 type(mean_field_t) :: uuw
84 type(mean_field_t) :: uvv
85 type(mean_field_t) :: uvw
86 type(mean_field_t) :: vvw
87 type(mean_field_t) :: uww
88 type(mean_field_t) :: vww
90 type(mean_field_t) :: uuuu
91 type(mean_field_t) :: vvvv
92 type(mean_field_t) :: wwww
94 type(mean_field_t) :: pp
95 type(mean_field_t) :: ppp
96 type(mean_field_t) :: pppp
98 type(mean_field_t) :: pu
99 type(mean_field_t) :: pv
100 type(mean_field_t) :: pw
101
103 type(mean_field_t) :: pdudx
104 type(mean_field_t) :: pdudy
105 type(mean_field_t) :: pdudz
106 type(mean_field_t) :: pdvdx
107 type(mean_field_t) :: pdvdy
108 type(mean_field_t) :: pdvdz
109 type(mean_field_t) :: pdwdx
110 type(mean_field_t) :: pdwdy
111 type(mean_field_t) :: pdwdz
112
114 type(mean_field_t) :: e11
115 type(mean_field_t) :: e22
116 type(mean_field_t) :: e33
117 type(mean_field_t) :: e12
118 type(mean_field_t) :: e13
119 type(mean_field_t) :: e23
121 type(field_t) :: dudx
122 type(field_t) :: dudy
123 type(field_t) :: dudz
124 type(field_t) :: dvdx
125 type(field_t) :: dvdy
126 type(field_t) :: dvdz
127 type(field_t) :: dwdx
128 type(field_t) :: dwdy
129 type(field_t) :: dwdz
130
132 type(coef_t), pointer :: coef
134 integer :: n_stats = 44
137 character(5) :: stat_set
140 type(field_list_t) :: stat_fields
141 contains
143 procedure, pass(this) :: init => fluid_stats_init
145 procedure, pass(this) :: free => fluid_stats_free
147 procedure, pass(this) :: update => fluid_stats_update
149 procedure, pass(this) :: reset => fluid_stats_reset
150 ! Convert computed weak gradients to strong.
151 procedure, pass(this) :: make_strong_grad => fluid_stats_make_strong_grad
154 procedure, pass(this) :: post_process => fluid_stats_post_process
155 end type fluid_stats_t
156
157contains
158
167 subroutine fluid_stats_init(this, coef, u, v, w, p, set)
168 class(fluid_stats_t), intent(inout), target:: this
169 type(coef_t), target, optional :: coef
170 type(field_t), target, intent(in) :: u, v, w, p
171 character(*), intent(in), optional :: set
172
173 call this%free()
174 this%coef => coef
175
176 this%u => u
177 this%v => v
178 this%w => w
179 this%p => p
180
181 if (present(set)) then
182 this%stat_set = trim(set)
183 if (this%stat_set .eq. 'basic') then
184 this%n_stats = 11
185 end if
186 else
187 this%stat_set = 'full'
188 this%n_stats = 44
189 end if
190
191 call this%stats_work%init(this%u%dof, 'stats')
192 call this%stats_u%init(this%u%dof, 'u temp')
193 call this%stats_v%init(this%u%dof, 'v temp')
194 call this%stats_w%init(this%u%dof, 'w temp')
195 call this%stats_p%init(this%u%dof, 'p temp')
196 call this%u_mean%init(this%u)
197 call this%v_mean%init(this%v)
198 call this%w_mean%init(this%w)
199 call this%p_mean%init(this%p)
200 call this%uu%init(this%stats_u, 'uu')
201 call this%vv%init(this%stats_v, 'vv')
202 call this%ww%init(this%stats_w, 'ww')
203 call this%uv%init(this%stats_work, 'uv')
204 call this%uw%init(this%stats_work, 'uw')
205 call this%vw%init(this%stats_work, 'vw')
206 call this%pp%init(this%stats_p, 'pp')
207
208 if (this%n_stats .eq. 44) then
209 call this%dudx%init(this%u%dof, 'dudx')
210 call this%dudy%init(this%u%dof, 'dudy')
211 call this%dudz%init(this%u%dof, 'dudz')
212 call this%dvdx%init(this%u%dof, 'dvdx')
213 call this%dvdy%init(this%u%dof, 'dvdy')
214 call this%dvdz%init(this%u%dof, 'dvdz')
215 call this%dwdx%init(this%u%dof, 'dwdx')
216 call this%dwdy%init(this%u%dof, 'dwdy')
217 call this%dwdz%init(this%u%dof, 'dwdz')
218
219 call this%uuu%init(this%stats_work, 'uuu')
220 call this%vvv%init(this%stats_work, 'vvv')
221 call this%www%init(this%stats_work, 'www')
222 call this%uuv%init(this%stats_work, 'uuv')
223 call this%uuw%init(this%stats_work, 'uuw')
224 call this%uvv%init(this%stats_work, 'uvv')
225 call this%uvw%init(this%stats_work, 'uvw')
226 call this%vvw%init(this%stats_work, 'vvw')
227 call this%uww%init(this%stats_work, 'uww')
228 call this%vww%init(this%stats_work, 'vww')
229 call this%uuuu%init(this%stats_work, 'uuuu')
230 call this%vvvv%init(this%stats_work, 'vvvv')
231 call this%wwww%init(this%stats_work, 'wwww')
233 call this%ppp%init(this%stats_work, 'ppp')
234 call this%pppp%init(this%stats_work, 'pppp')
236 call this%pu%init(this%stats_work, 'pu')
237 call this%pv%init(this%stats_work, 'pv')
238 call this%pw%init(this%stats_work, 'pw')
239
240 call this%pdudx%init(this%stats_work, 'pdudx')
241 call this%pdudy%init(this%stats_work, 'pdudy')
242 call this%pdudz%init(this%stats_work, 'pdudz')
243 call this%pdvdx%init(this%stats_work, 'pdvdx')
244 call this%pdvdy%init(this%stats_work, 'pdvdy')
245 call this%pdvdz%init(this%stats_work, 'pdvdz')
246 call this%pdwdx%init(this%stats_work, 'pdwdx')
247 call this%pdwdy%init(this%stats_work, 'pdwdy')
248 call this%pdwdz%init(this%stats_work, 'pdwdz')
249
250 call this%e11%init(this%stats_work, 'e11')
251 call this%e22%init(this%stats_work, 'e22')
252 call this%e33%init(this%stats_work, 'e33')
253 call this%e12%init(this%stats_work, 'e12')
254 call this%e13%init(this%stats_work, 'e13')
255 call this%e23%init(this%stats_work, 'e23')
256 end if
257
258 call this%stat_fields%init(this%n_stats)
259
260 call this%stat_fields%assign_to_field(1, this%p_mean%mf)
261 call this%stat_fields%assign_to_field(2, this%u_mean%mf)
262 call this%stat_fields%assign_to_field(3, this%v_mean%mf)
263 call this%stat_fields%assign_to_field(4, this%w_mean%mf)
264 call this%stat_fields%assign_to_field(5, this%pp%mf)
265 call this%stat_fields%assign_to_field(6, this%uu%mf)
266 call this%stat_fields%assign_to_field(7, this%vv%mf)
267 call this%stat_fields%assign_to_field(8, this%ww%mf)
268 call this%stat_fields%assign_to_field(9, this%uv%mf)
269 call this%stat_fields%assign_to_field(10, this%uw%mf)
270 call this%stat_fields%assign_to_field(11, this%vw%mf)
271
272 if (this%n_stats .eq. 44) then
273 call this%stat_fields%assign_to_field(12, this%uuu%mf)
274 call this%stat_fields%assign_to_field(13, this%vvv%mf)
275 call this%stat_fields%assign_to_field(14, this%www%mf)
276 call this%stat_fields%assign_to_field(15, this%uuv%mf)
277 call this%stat_fields%assign_to_field(16, this%uuw%mf)
278 call this%stat_fields%assign_to_field(17, this%uvv%mf)
279 call this%stat_fields%assign_to_field(18, this%uvw%mf)
280 call this%stat_fields%assign_to_field(19, this%vvw%mf)
281 call this%stat_fields%assign_to_field(20, this%uww%mf)
282 call this%stat_fields%assign_to_field(21, this%vww%mf)
283 call this%stat_fields%assign_to_field(22, this%uuuu%mf)
284 call this%stat_fields%assign_to_field(23, this%vvvv%mf)
285 call this%stat_fields%assign_to_field(24, this%wwww%mf)
286 call this%stat_fields%assign_to_field(25, this%ppp%mf)
287 call this%stat_fields%assign_to_field(26, this%pppp%mf)
288 call this%stat_fields%assign_to_field(27, this%pu%mf)
289 call this%stat_fields%assign_to_field(28, this%pv%mf)
290 call this%stat_fields%assign_to_field(29, this%pw%mf)
291
292 call this%stat_fields%assign_to_field(30, this%pdudx%mf)
293 call this%stat_fields%assign_to_field(31, this%pdudy%mf)
294 call this%stat_fields%assign_to_field(32, this%pdudz%mf)
295 call this%stat_fields%assign_to_field(33, this%pdvdx%mf)
296 call this%stat_fields%assign_to_field(34, this%pdvdy%mf)
297 call this%stat_fields%assign_to_field(35, this%pdvdz%mf)
298 call this%stat_fields%assign_to_field(36, this%pdwdx%mf)
299 call this%stat_fields%assign_to_field(37, this%pdwdy%mf)
300 call this%stat_fields%assign_to_field(38, this%pdwdz%mf)
301 call this%stat_fields%assign_to_field(39, this%e11%mf)
302 call this%stat_fields%assign_to_field(40, this%e22%mf)
303 call this%stat_fields%assign_to_field(41, this%e33%mf)
304 call this%stat_fields%assign_to_field(42, this%e12%mf)
305 call this%stat_fields%assign_to_field(43, this%e13%mf)
306 call this%stat_fields%assign_to_field(44, this%e23%mf)
307 end if
308
309 end subroutine fluid_stats_init
310
313 subroutine fluid_stats_update(this, k)
314 class(fluid_stats_t), intent(inout) :: this
315 real(kind=rp), intent(in) :: k
316 integer :: n
317
318 associate(stats_work => this%stats_work, stats_u => this%stats_u, &
319 stats_v => this%stats_v, stats_w => this%stats_w, &
320 stats_p => this%stats_p)
321 n = stats_work%dof%size()
322
324 if (neko_bcknd_device .eq. 1) then
325
326 call this%u_mean%update(k)
327 call this%v_mean%update(k)
328 call this%w_mean%update(k)
329 call this%p_mean%update(k)
330
331 call device_col3(stats_u%x_d, this%u%x_d, this%u%x_d, n)
332 call device_col3(stats_v%x_d, this%v%x_d, this%v%x_d, n)
333 call device_col3(stats_w%x_d, this%w%x_d, this%w%x_d, n)
334 call device_col3(stats_p%x_d, this%p%x_d, this%p%x_d, n)
335
336 call this%uu%update(k)
337 call this%vv%update(k)
338 call this%ww%update(k)
339 call this%pp%update(k)
340
341 call device_col3(stats_work%x_d, this%u%x_d, this%v%x_d, n)
342 call this%uv%update(k)
343 call device_col3(stats_work%x_d, this%u%x_d, this%w%x_d, n)
344 call this%uw%update(k)
345 call device_col3(stats_work%x_d, this%v%x_d, this%w%x_d, n)
346 call this%vw%update(k)
347 if (this%n_stats .eq. 11) return
348 call device_col2(stats_work%x_d, this%u%x_d, n)
349 call this%uvw%update(k)
350 call device_col3(stats_work%x_d, this%stats_u%x_d, this%u%x_d, n)
351 call this%uuu%update(k)
352 call device_col3(stats_work%x_d, this%stats_v%x_d, this%v%x_d, n)
353 call this%vvv%update(k)
354 call device_col3(stats_work%x_d, this%stats_w%x_d, this%w%x_d, n)
355 call this%www%update(k)
356 call device_col3(stats_work%x_d, this%stats_u%x_d, this%v%x_d, n)
357 call this%uuv%update(k)
358 call device_col3(stats_work%x_d, this%stats_u%x_d, this%w%x_d, n)
359 call this%uuw%update(k)
360 call device_col3(stats_work%x_d, this%stats_v%x_d, this%u%x_d, n)
361 call this%uvv%update(k)
362 call device_col3(stats_work%x_d, this%stats_v%x_d, this%w%x_d, n)
363 call this%vvw%update(k)
364 call device_col3(stats_work%x_d, this%stats_w%x_d, this%u%x_d, n)
365 call this%uww%update(k)
366 call device_col3(stats_work%x_d, this%stats_w%x_d, this%v%x_d, n)
367 call this%vww%update(k)
368
369 call device_col3(stats_work%x_d, this%stats_u%x_d, this%stats_u%x_d, n)
370 call this%uuuu%update(k)
371 call device_col3(stats_work%x_d, this%stats_v%x_d, this%stats_v%x_d, n)
372 call this%vvvv%update(k)
373 call device_col3(stats_work%x_d, this%stats_w%x_d, this%stats_w%x_d, n)
374 call this%wwww%update(k)
375
376 call device_col3(stats_work%x_d, this%stats_p%x_d, this%p%x_d, n)
377 call this%ppp%update(k)
378 call device_col3(stats_work%x_d, this%stats_p%x_d, this%stats_p%x_d, n)
379 call this%pppp%update(k)
380
381 call device_col3(stats_work%x_d, this%p%x_d, this%u%x_d, n)
382 call this%pu%update(k)
383 call device_col3(stats_work%x_d, this%p%x_d, this%v%x_d, n)
384 call this%pv%update(k)
385 call device_col3(stats_work%x_d, this%p%x_d, this%w%x_d, n)
386 call this%pw%update(k)
387
388 else
389
390 call this%u_mean%update(k)
391 call this%v_mean%update(k)
392 call this%w_mean%update(k)
393 call this%p_mean%update(k)
394 call col3(stats_u%x, this%u%x, this%u%x, n)
395 call col3(stats_v%x, this%v%x, this%v%x, n)
396 call col3(stats_w%x, this%w%x, this%w%x, n)
397 call col3(stats_p%x, this%p%x, this%p%x, n)
398
399 call this%uu%update(k)
400 call this%vv%update(k)
401 call this%ww%update(k)
402 call this%pp%update(k)
403
404 call col3(stats_work%x, this%u%x, this%v%x, n)
405 call this%uv%update(k)
406 call col3(stats_work%x, this%u%x, this%w%x, n)
407 call this%uw%update(k)
408 call col3(stats_work%x, this%v%x, this%w%x, n)
409 call this%vw%update(k)
410
411 if (this%n_stats .eq. 11) return
412
413 call col2(stats_work%x, this%u%x, n)
414 call this%uvw%update(k)
415 call col3(stats_work%x, this%stats_u%x, this%u%x, n)
416 call this%uuu%update(k)
417 call col3(stats_work%x, this%stats_v%x, this%v%x, n)
418 call this%vvv%update(k)
419 call col3(stats_work%x, this%stats_w%x, this%w%x, n)
420 call this%www%update(k)
421 call col3(stats_work%x, this%stats_u%x, this%v%x, n)
422 call this%uuv%update(k)
423 call col3(stats_work%x, this%stats_u%x, this%w%x, n)
424 call this%uuw%update(k)
425 call col3(stats_work%x, this%stats_v%x, this%u%x, n)
426 call this%uvv%update(k)
427 call col3(stats_work%x, this%stats_v%x, this%w%x, n)
428 call this%vvw%update(k)
429 call col3(stats_work%x, this%stats_w%x, this%u%x, n)
430 call this%uww%update(k)
431 call col3(stats_work%x, this%stats_w%x, this%v%x, n)
432 call this%vww%update(k)
433
434 call col3(stats_work%x, this%stats_u%x, this%stats_u%x, n)
435 call this%uuuu%update(k)
436 call col3(stats_work%x, this%stats_v%x, this%stats_v%x, n)
437 call this%vvvv%update(k)
438 call col3(stats_work%x, this%stats_w%x, this%stats_w%x, n)
439 call this%wwww%update(k)
440
441 call col3(stats_work%x, this%stats_p%x, this%p%x, n)
442 call this%ppp%update(k)
443 call col3(stats_work%x, this%stats_p%x, this%stats_p%x, n)
444 call this%pppp%update(k)
445
446 call col3(stats_work%x, this%p%x, this%u%x,n)
447 call this%pu%update(k)
448 call col3(stats_work%x, this%p%x, this%v%x,n)
449 call this%pv%update(k)
450 call col3(stats_work%x, this%p%x, this%w%x,n)
451 call this%pw%update(k)
452
453
454 end if
455 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, this%u%x, this%coef)
456 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, this%v%x, this%coef)
457 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, this%w%x, this%coef)
458
459 if (neko_bcknd_device .eq. 1) then
460 call device_col3(stats_work%x_d, this%dudx%x_d, this%p%x_d, n)
461 call this%pdudx%update(k)
462 call device_col3(stats_work%x_d, this%dudy%x_d, this%p%x_d, n)
463 call this%pdudy%update(k)
464 call device_col3(stats_work%x_d, this%dudz%x_d, this%p%x_d, n)
465 call this%pdudz%update(k)
466
467 call device_col3(stats_work%x_d, this%dvdx%x_d, this%p%x_d, n)
468 call this%pdvdx%update(k)
469 call device_col3(stats_work%x_d, this%dvdy%x_d, this%p%x_d, n)
470 call this%pdvdy%update(k)
471 call device_col3(stats_work%x_d, this%dvdz%x_d, this%p%x_d, n)
472 call this%pdvdz%update(k)
473
474 call device_col3(stats_work%x_d, this%dwdx%x_d, this%p%x_d, n)
475 call this%pdwdx%update(k)
476 call device_col3(stats_work%x_d, this%dwdy%x_d, this%p%x_d, n)
477 call this%pdwdy%update(k)
478 call device_col3(stats_work%x_d, this%dwdz%x_d, this%p%x_d, n)
479 call this%pdwdz%update(k)
480
481 call device_col3(this%stats_work%x_d, this%dudx%x_d, this%dudx%x_d, n)
482 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
483 this%dudy%x_d, n)
484 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
485 this%dudz%x_d, n)
486 call this%e11%update(k)
487 call device_col3(this%stats_work%x_d, this%dvdx%x_d, this%dvdx%x_d, n)
488 call device_addcol3(this%stats_work%x_d, this%dvdy%x_d, &
489 this%dvdy%x_d, n)
490 call device_addcol3(this%stats_work%x_d, this%dvdz%x_d, &
491 this%dvdz%x_d, n)
492 call this%e22%update(k)
493 call device_col3(this%stats_work%x_d, this%dwdx%x_d, this%dwdx%x_d, n)
494 call device_addcol3(this%stats_work%x_d, this%dwdy%x_d, &
495 this%dwdy%x_d, n)
496 call device_addcol3(this%stats_work%x_d, this%dwdz%x_d, &
497 this%dwdz%x_d, n)
498 call this%e33%update(k)
499 call device_col3(this%stats_work%x_d, this%dudx%x_d, &
500 this%dvdx%x_d, n)
501 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
502 this%dvdy%x_d, n)
503 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
504 this%dvdz%x_d, n)
505 call this%e12%update(k)
506 call device_col3(this%stats_work%x_d, this%dudx%x_d, this%dwdx%x_d, n)
507 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
508 this%dwdy%x_d, n)
509 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
510 this%dwdz%x_d, n)
511 call this%e13%update(k)
512 call device_col3(this%stats_work%x_d, this%dvdx%x_d, this%dwdx%x_d, n)
513 call device_addcol3(this%stats_work%x_d, this%dvdy%x_d, &
514 this%dwdy%x_d, n)
515 call device_addcol3(this%stats_work%x_d, this%dvdz%x_d, &
516 this%dwdz%x_d, n)
517 call this%e23%update(k)
518 else
519 call col3(stats_work%x, this%dudx%x, this%p%x, n)
520 call this%pdudx%update(k)
521 call col3(stats_work%x, this%dudy%x, this%p%x, n)
522 call this%pdudy%update(k)
523 call col3(stats_work%x, this%dudz%x, this%p%x, n)
524 call this%pdudz%update(k)
525
526 call col3(stats_work%x, this%dvdx%x, this%p%x, n)
527 call this%pdvdx%update(k)
528 call col3(stats_work%x, this%dvdy%x, this%p%x, n)
529 call this%pdvdy%update(k)
530 call col3(stats_work%x, this%dvdz%x, this%p%x, n)
531 call this%pdvdz%update(k)
532
533 call col3(stats_work%x, this%dwdx%x, this%p%x, n)
534 call this%pdwdx%update(k)
535 call col3(stats_work%x, this%dwdy%x, this%p%x, n)
536 call this%pdwdy%update(k)
537 call col3(stats_work%x, this%dwdz%x, this%p%x, n)
538 call this%pdwdz%update(k)
539
540 call col3(this%stats_work%x, this%dudx%x, this%dudx%x, n)
541 call addcol3(this%stats_work%x, this%dudy%x, this%dudy%x, n)
542 call addcol3(this%stats_work%x, this%dudz%x, this%dudz%x, n)
543 call this%e11%update(k)
544 call col3(this%stats_work%x, this%dvdx%x, this%dvdx%x, n)
545 call addcol3(this%stats_work%x, this%dvdy%x, this%dvdy%x, n)
546 call addcol3(this%stats_work%x, this%dvdz%x, this%dvdz%x, n)
547 call this%e22%update(k)
548 call col3(this%stats_work%x, this%dwdx%x, this%dwdx%x, n)
549 call addcol3(this%stats_work%x, this%dwdy%x, this%dwdy%x, n)
550 call addcol3(this%stats_work%x, this%dwdz%x, this%dwdz%x, n)
551 call this%e33%update(k)
552 call col3(this%stats_work%x, this%dudx%x, this%dvdx%x, n)
553 call addcol3(this%stats_work%x, this%dudy%x, this%dvdy%x, n)
554 call addcol3(this%stats_work%x, this%dudz%x, this%dvdz%x, n)
555 call this%e12%update(k)
556 call col3(this%stats_work%x, this%dudx%x, this%dwdx%x, n)
557 call addcol3(this%stats_work%x, this%dudy%x, this%dwdy%x, n)
558 call addcol3(this%stats_work%x, this%dudz%x, this%dwdz%x, n)
559 call this%e13%update(k)
560 call col3(this%stats_work%x, this%dvdx%x, this%dwdx%x, n)
561 call addcol3(this%stats_work%x, this%dvdy%x, this%dwdy%x, n)
562 call addcol3(this%stats_work%x, this%dvdz%x, this%dwdz%x, n)
563 call this%e23%update(k)
564
565 end if
566 end associate
567
568 end subroutine fluid_stats_update
569
570
572 subroutine fluid_stats_free(this)
573 class(fluid_stats_t), intent(inout) :: this
574
575 call this%stats_u%free()
576 call this%stats_v%free()
577 call this%stats_w%free()
578 call this%stats_p%free()
579 call this%stats_work%free()
580
581 call this%u_mean%free()
582 call this%v_mean%free()
583 call this%w_mean%free()
584 call this%p_mean%free()
585
586 call this%uu%free()
587 call this%vv%free()
588 call this%ww%free()
589 call this%uv%free()
590 call this%uw%free()
591 call this%vw%free()
592
593 call this%uuu%free()
594 call this%vvv%free()
595 call this%www%free()
596 call this%uuv%free()
597 call this%uuw%free()
598 call this%uvv%free()
599 call this%uvw%free()
600 call this%vvw%free()
601 call this%uww%free()
602 call this%vww%free()
603
604 call this%uuuu%free()
605 call this%vvvv%free()
606 call this%wwww%free()
607
608 call this%pp%free()
609 call this%ppp%free()
610 call this%pppp%free()
611
612 call this%pu%free()
613 call this%pv%free()
614 call this%pw%free()
615
616 call this%pdudx%free()
617 call this%pdudy%free()
618 call this%pdudz%free()
619 call this%pdvdx%free()
620 call this%pdvdy%free()
621 call this%pdvdz%free()
622 call this%pdwdx%free()
623 call this%pdwdy%free()
624 call this%pdwdz%free()
625
626 call this%e11%free()
627 call this%e22%free()
628 call this%e33%free()
629 call this%e12%free()
630 call this%e13%free()
631 call this%e23%free()
632
633 call this%dudx%free()
634 call this%dudy%free()
635 call this%dudz%free()
636 call this%dvdx%free()
637 call this%dvdy%free()
638 call this%dvdz%free()
639 call this%dwdx%free()
640 call this%dwdy%free()
641 call this%dwdz%free()
642
643 nullify(this%u)
644 nullify(this%v)
645 nullify(this%w)
646 nullify(this%p)
647 nullify(this%coef)
648
649 call this%stat_fields%free()
650
651 end subroutine fluid_stats_free
652
654 subroutine fluid_stats_reset(this)
655 class(fluid_stats_t), intent(inout), target:: this
656
657 call this%p_mean%reset()
658 call this%u_mean%reset()
659 call this%v_mean%reset()
660 call this%w_mean%reset()
661
662 call this%uu%reset()
663 call this%vv%reset()
664 call this%ww%reset()
665 call this%uv%reset()
666 call this%uw%reset()
667 call this%vw%reset()
668 call this%pp%reset()
669 if (this%n_stats .eq. 44) then
670 call this%uuu%reset()
671 call this%vvv%reset()
672 call this%www%reset()
673 call this%uuv%reset()
674 call this%uuw%reset()
675 call this%uvv%reset()
676 call this%uvw%reset()
677 call this%vvw%reset()
678 call this%uww%reset()
679 call this%vww%reset()
680 call this%uuuu%reset()
681 call this%vvvv%reset()
682 call this%wwww%reset()
683 call this%ppp%reset()
684 call this%pppp%reset()
685 call this%pu%reset()
686 call this%pv%reset()
687 call this%pw%reset()
688
689 call this%pdudx%reset()
690 call this%pdudy%reset()
691 call this%pdudz%reset()
692 call this%pdvdx%reset()
693 call this%pdvdy%reset()
694 call this%pdvdz%reset()
695 call this%pdwdx%reset()
696 call this%pdwdy%reset()
697 call this%pdwdz%reset()
698
699 call this%e11%reset()
700 call this%e22%reset()
701 call this%e33%reset()
702 call this%e12%reset()
703 call this%e13%reset()
704 call this%e23%reset()
705 end if
706
707 end subroutine fluid_stats_reset
708
709 ! Convert computed weak gradients to strong.
711 class(fluid_stats_t) :: this
712 integer :: n
713
714 if (this%n_stats .eq. 11) return
715
716 n = size(this%coef%B)
717
718 if (neko_bcknd_device .eq. 1) then
719 call device_cfill(this%stats_work%x_d, 1.0_rp, n)
720 call device_invcol2(this%stats_work%x_d, this%coef%B_d, n)
721 call device_col2(this%pdudx%mf%x_d, this%stats_work%x_d, n)
722 call device_col2(this%pdudy%mf%x_d, this%stats_work%x_d, n)
723 call device_col2(this%pdudz%mf%x_d, this%stats_work%x_d, n)
724 call device_col2(this%pdvdx%mf%x_d, this%stats_work%x_d, n)
725 call device_col2(this%pdvdy%mf%x_d, this%stats_work%x_d, n)
726 call device_col2(this%pdvdz%mf%x_d, this%stats_work%x_d, n)
727 call device_col2(this%pdwdx%mf%x_d, this%stats_work%x_d, n)
728 call device_col2(this%pdwdy%mf%x_d, this%stats_work%x_d, n)
729 call device_col2(this%pdwdz%mf%x_d, this%stats_work%x_d, n)
730
731 call device_col2(this%stats_work%x_d, this%stats_work%x_d, n)
732 call device_col2(this%e11%mf%x_d, this%stats_work%x_d, n)
733 call device_col2(this%e22%mf%x_d, this%stats_work%x_d, n)
734 call device_col2(this%e33%mf%x_d, this%stats_work%x_d, n)
735 call device_col2(this%e12%mf%x_d, this%stats_work%x_d, n)
736 call device_col2(this%e13%mf%x_d, this%stats_work%x_d, n)
737 call device_col2(this%e23%mf%x_d, this%stats_work%x_d, n)
738
739
740 else
741 call invers2(this%stats_work%x, this%coef%B, n)
742 call col2(this%pdudx%mf%x, this%stats_work%x, n)
743 call col2(this%pdudy%mf%x, this%stats_work%x, n)
744 call col2(this%pdudz%mf%x, this%stats_work%x, n)
745 call col2(this%pdvdx%mf%x, this%stats_work%x, n)
746 call col2(this%pdvdy%mf%x, this%stats_work%x, n)
747 call col2(this%pdvdz%mf%x, this%stats_work%x, n)
748 call col2(this%pdwdx%mf%x, this%stats_work%x, n)
749 call col2(this%pdwdy%mf%x, this%stats_work%x, n)
750 call col2(this%pdwdz%mf%x, this%stats_work%x, n)
751
752 call col2(this%stats_work%x, this%stats_work%x, n)
753 call col2(this%e11%mf%x, this%stats_work%x, n)
754 call col2(this%e22%mf%x, this%stats_work%x, n)
755 call col2(this%e33%mf%x, this%stats_work%x, n)
756 call col2(this%e12%mf%x, this%stats_work%x, n)
757 call col2(this%e13%mf%x, this%stats_work%x, n)
758 call col2(this%e23%mf%x, this%stats_work%x, n)
759
760 end if
761
762 end subroutine fluid_stats_make_strong_grad
763
766 subroutine fluid_stats_post_process(this, mean, reynolds, pressure_flatness,&
767 pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
768 class(fluid_stats_t) :: this
769 type(field_list_t), intent(inout), optional :: mean
770 type(field_list_t), intent(inout), optional :: reynolds
771 type(field_list_t), intent(in), optional :: pressure_skewness
772 type(field_list_t), intent(in), optional :: pressure_flatness
773 type(field_list_t), intent(in), optional :: skewness_tensor
774 type(field_list_t), intent(inout), optional :: mean_vel_grad
775 type(field_list_t), intent(in), optional :: dissipation_tensor
776 integer :: n
777
778 if (present(mean)) then
779 n = mean%item_size(1)
780 call copy(mean%items(1)%ptr%x, this%u_mean%mf%x, n)
781 call copy(mean%items(2)%ptr%x, this%v_mean%mf%x, n)
782 call copy(mean%items(3)%ptr%x, this%w_mean%mf%x, n)
783 call copy(mean%items(4)%ptr%x, this%p_mean%mf%x, n)
784 end if
785
786 if (present(reynolds)) then
787 n = reynolds%item_size(1)
788 call copy(reynolds%items(1)%ptr%x, this%pp%mf%x, n)
789 call subcol3(reynolds%items(1)%ptr%x, this%p_mean%mf%x, &
790 this%p_mean%mf%x, n)
791
792 call copy(reynolds%items(2)%ptr%x, this%uu%mf%x, n)
793 call subcol3(reynolds%items(2)%ptr%x, this%u_mean%mf%x, &
794 this%u_mean%mf%x, n)
795
796 call copy(reynolds%items(3)%ptr%x, this%vv%mf%x, n)
797 call subcol3(reynolds%items(3)%ptr%x, this%v_mean%mf%x, &
798 this%v_mean%mf%x,n)
799
800 call copy(reynolds%items(4)%ptr%x, this%ww%mf%x, n)
801 call subcol3(reynolds%items(4)%ptr%x, this%w_mean%mf%x, &
802 this%w_mean%mf%x,n)
803
804 call copy(reynolds%items(5)%ptr%x, this%uv%mf%x, n)
805 call subcol3(reynolds%items(5)%ptr%x, this%u_mean%mf%x, &
806 this%v_mean%mf%x, n)
807
808 call copy(reynolds%items(6)%ptr%x, this%uw%mf%x, n)
809 call subcol3(reynolds%items(6)%ptr%x, this%u_mean%mf%x, &
810 this%w_mean%mf%x, n)
811
812 call copy(reynolds%items(7)%ptr%x, this%vw%mf%x, n)
813 call subcol3(reynolds%items(7)%ptr%x, this%v_mean%mf%x, &
814 this%w_mean%mf%x, n)
815 end if
816 if (present(pressure_skewness)) then
817
818 call neko_warning('Presssure skewness stat not implemented'// &
819 ' in fluid_stats, process stats in python instead')
820
821 end if
822
823 if (present(pressure_flatness)) then
824 call neko_warning('Presssure flatness stat not implemented'// &
825 ' in fluid_stats, process stats in python instead')
826
827 end if
828
829 if (present(skewness_tensor)) then
830 call neko_warning('Skewness tensor stat not implemented'// &
831 ' in fluid_stats, process stats in python instead')
832 end if
833
834 if (present(mean_vel_grad)) then
835 !Compute gradient of mean flow
836 n = mean_vel_grad%item_size(1)
837 if (neko_bcknd_device .eq. 1) then
838 call device_memcpy(this%u_mean%mf%x, this%u_mean%mf%x_d, n, &
839 host_to_device, sync = .false.)
840 call device_memcpy(this%v_mean%mf%x, this%v_mean%mf%x_d, n, &
841 host_to_device, sync = .false.)
842 call device_memcpy(this%w_mean%mf%x, this%w_mean%mf%x_d, n, &
843 host_to_device, sync = .false.)
844 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, &
845 this%u_mean%mf%x, this%coef)
846 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, &
847 this%v_mean%mf%x, this%coef)
848 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, &
849 this%w_mean%mf%x, this%coef)
850 call device_memcpy(this%dudx%x, this%dudx%x_d, n, &
851 device_to_host, sync = .false.)
852 call device_memcpy(this%dvdx%x, this%dvdx%x_d, n, &
853 device_to_host, sync = .false.)
854 call device_memcpy(this%dwdx%x, this%dwdx%x_d, n, &
855 device_to_host, sync = .false.)
856 call device_memcpy(this%dudy%x, this%dudy%x_d, n, &
857 device_to_host, sync = .false.)
858 call device_memcpy(this%dvdy%x, this%dvdy%x_d, n, &
859 device_to_host, sync = .false.)
860 call device_memcpy(this%dwdy%x, this%dwdy%x_d, n, &
861 device_to_host, sync = .false.)
862 call device_memcpy(this%dudz%x, this%dudz%x_d, n, &
863 device_to_host, sync = .false.)
864 call device_memcpy(this%dvdz%x, this%dvdz%x_d, n, &
865 device_to_host, sync = .false.)
866 call device_memcpy(this%dwdz%x, this%dwdz%x_d, n, &
867 device_to_host, sync = .true.)
868 else
869 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, &
870 this%u_mean%mf%x, this%coef)
871 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, &
872 this%v_mean%mf%x, this%coef)
873 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, &
874 this%w_mean%mf%x, this%coef)
875 end if
876 call invers2(this%stats_work%x, this%coef%B,n)
877 call col3(mean_vel_grad%items(1)%ptr%x, this%dudx%x, &
878 this%stats_work%x, n)
879 call col3(mean_vel_grad%items(2)%ptr%x, this%dudy%x, &
880 this%stats_work%x, n)
881 call col3(mean_vel_grad%items(3)%ptr%x, this%dudz%x, &
882 this%stats_work%x, n)
883 call col3(mean_vel_grad%items(4)%ptr%x, this%dvdx%x, &
884 this%stats_work%x, n)
885 call col3(mean_vel_grad%items(5)%ptr%x, this%dvdy%x, &
886 this%stats_work%x, n)
887 call col3(mean_vel_grad%items(6)%ptr%x, this%dvdz%x, &
888 this%stats_work%x, n)
889 call col3(mean_vel_grad%items(7)%ptr%x, this%dwdx%x, &
890 this%stats_work%x, n)
891 call col3(mean_vel_grad%items(8)%ptr%x, this%dwdy%x, &
892 this%stats_work%x, n)
893 call col3(mean_vel_grad%items(9)%ptr%x, this%dwdz%x, &
894 this%stats_work%x, n)
895
896 end if
897
898 if (present(dissipation_tensor)) then
899 call neko_warning('Dissipation tensor stat not implemented'// &
900 ' in fluid_stats, process stats in python instead')
901 end if
902
903 end subroutine fluid_stats_post_process
904
905end module fluid_stats
Copy data between host and device (or device and device)
Definition device.F90:71
Coefficients.
Definition coef.f90:34
subroutine, public device_addcol3(a_d, b_d, c_d, n, strm)
Returns .
subroutine, public device_col2(a_d, b_d, n, strm)
Vector multiplication .
subroutine, public device_invcol2(a_d, b_d, n, strm)
Vector division .
subroutine, public device_col3(a_d, b_d, c_d, n, strm)
Vector multiplication with 3 vectors .
subroutine, public device_cfill(a_d, c, n, strm)
Set all elements to a constant c .
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public host_to_device
Definition device.F90:47
integer, parameter, public device_to_host
Definition device.F90:47
Defines a field.
Definition field.f90:34
Computes various statistics for the fluid fields. We use the Reynolds decomposition for a field u = ...
subroutine fluid_stats_reset(this)
Resets all the computed means values and sampling times to zero.
subroutine fluid_stats_make_strong_grad(this)
subroutine fluid_stats_update(this, k)
Updates all fields with a new sample.
subroutine fluid_stats_free(this)
Destructor.
subroutine fluid_stats_post_process(this, mean, reynolds, pressure_flatness, pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
Compute certain physical statistical quantities based on existing mean fields.
subroutine fluid_stats_init(this, coef, u, v, w, p, set)
Constructor. Initialize the fields associated with fluid_stats.
Definition math.f90:60
subroutine, public invers2(a, b, n)
Compute inverted vector .
Definition math.f90:639
subroutine, public subcol3(a, b, c, n)
Returns .
Definition math.f90:881
subroutine, public addcol3(a, b, c, n)
Returns .
Definition math.f90:958
subroutine, public col2(a, b, n)
Vector multiplication .
Definition math.f90:854
subroutine, public copy(a, b, n)
Copy a vector .
Definition math.f90:249
subroutine, public col3(a, b, c, n)
Vector multiplication with 3 vectors .
Definition math.f90:867
Implements mean_field_t.
Build configurations.
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public opgrad(ux, uy, uz, u, coef, es, ee)
Compute the weak gradient of a scalar field, i.e. the gradient multiplied by the mass matrix.
Defines a statistical quantity.
Utilities.
Definition utils.f90:35
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Definition utils.f90:346
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:56
field_list_t, To be able to group fields together
Computes the temporal mean of a field.
Abstract type defining a statistical quantity.