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, name)
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 character(*), intent(in), optional :: name
173
174 character(len=1024) :: unique_name
175 unique_name = ""
176
177 call this%free()
178 this%coef => coef
179
180 this%u => u
181 this%v => v
182 this%w => w
183 this%p => p
184
185 if (present(set)) then
186 this%stat_set = trim(set)
187 if (this%stat_set .eq. 'basic') then
188 this%n_stats = 11
189 end if
190 else
191 this%stat_set = 'full'
192 this%n_stats = 44
193 end if
194
195 if (present(name)) then
196 unique_name = name // "/"
197 else
198 unique_name = "fluid_stats/"
199 end if
200
201 call this%stats_work%init(this%u%dof, 'stats')
202 call this%stats_u%init(this%u%dof, 'u temp')
203 call this%stats_v%init(this%u%dof, 'v temp')
204 call this%stats_w%init(this%u%dof, 'w temp')
205 call this%stats_p%init(this%u%dof, 'p temp')
206 call this%u_mean%init(this%u, trim(unique_name) // 'mean_u')
207 call this%v_mean%init(this%v, trim(unique_name) // 'mean_v')
208 call this%w_mean%init(this%w, trim(unique_name) // 'mean_w')
209 call this%p_mean%init(this%p, trim(unique_name) // 'mean_p')
210 call this%uu%init(this%stats_u , trim(unique_name) // 'mean_uu')
211 call this%vv%init(this%stats_v , trim(unique_name) // 'mean_vv')
212 call this%ww%init(this%stats_w , trim(unique_name) // 'mean_ww')
213 call this%uv%init(this%stats_work, trim(unique_name) // 'mean_uv')
214 call this%uw%init(this%stats_work, trim(unique_name) // 'mean_uw')
215 call this%vw%init(this%stats_work, trim(unique_name) // 'mean_vw')
216 call this%pp%init(this%stats_p , trim(unique_name) // 'mean_pp')
217
218 if (this%n_stats .eq. 44) then
219 call this%dudx%init(this%u%dof, 'dudx')
220 call this%dudy%init(this%u%dof, 'dudy')
221 call this%dudz%init(this%u%dof, 'dudz')
222 call this%dvdx%init(this%u%dof, 'dvdx')
223 call this%dvdy%init(this%u%dof, 'dvdy')
224 call this%dvdz%init(this%u%dof, 'dvdz')
225 call this%dwdx%init(this%u%dof, 'dwdx')
226 call this%dwdy%init(this%u%dof, 'dwdy')
227 call this%dwdz%init(this%u%dof, 'dwdz')
228
229 call this%uuu%init(this%stats_work, trim(unique_name) // 'mean_uuu')
230 call this%vvv%init(this%stats_work, trim(unique_name) // 'mean_vvv')
231 call this%www%init(this%stats_work, trim(unique_name) // 'mean_www')
232 call this%uuv%init(this%stats_work, trim(unique_name) // 'mean_uuv')
233 call this%uuw%init(this%stats_work, trim(unique_name) // 'mean_uuw')
234 call this%uvv%init(this%stats_work, trim(unique_name) // 'mean_uvv')
235 call this%uvw%init(this%stats_work, trim(unique_name) // 'mean_uvw')
236 call this%vvw%init(this%stats_work, trim(unique_name) // 'mean_vvw')
237 call this%uww%init(this%stats_work, trim(unique_name) // 'mean_uww')
238 call this%vww%init(this%stats_work, trim(unique_name) // 'mean_vww')
239 call this%uuuu%init(this%stats_work, trim(unique_name) // 'mean_uuuu')
240 call this%vvvv%init(this%stats_work, trim(unique_name) // 'mean_vvvv')
241 call this%wwww%init(this%stats_work, trim(unique_name) // 'mean_wwww')
243 call this%ppp%init(this%stats_work , trim(unique_name) // 'mean_ppp')
244 call this%pppp%init(this%stats_work, trim(unique_name) // 'mean_pppp')
246 call this%pu%init(this%stats_work, trim(unique_name) // 'mean_pu')
247 call this%pv%init(this%stats_work, trim(unique_name) // 'mean_pv')
248 call this%pw%init(this%stats_work, trim(unique_name) // 'mean_pw')
249
250 call this%pdudx%init(this%stats_work, trim(unique_name) // 'mean_pdudx')
251 call this%pdudy%init(this%stats_work, trim(unique_name) // 'mean_pdudy')
252 call this%pdudz%init(this%stats_work, trim(unique_name) // 'mean_pdudz')
253 call this%pdvdx%init(this%stats_work, trim(unique_name) // 'mean_pdvdx')
254 call this%pdvdy%init(this%stats_work, trim(unique_name) // 'mean_pdvdy')
255 call this%pdvdz%init(this%stats_work, trim(unique_name) // 'mean_pdvdz')
256 call this%pdwdx%init(this%stats_work, trim(unique_name) // 'mean_pdwdx')
257 call this%pdwdy%init(this%stats_work, trim(unique_name) // 'mean_pdwdy')
258 call this%pdwdz%init(this%stats_work, trim(unique_name) // 'mean_pdwdz')
259
260 call this%e11%init(this%stats_work, trim(unique_name) // 'mean_e11')
261 call this%e22%init(this%stats_work, trim(unique_name) // 'mean_e22')
262 call this%e33%init(this%stats_work, trim(unique_name) // 'mean_e33')
263 call this%e12%init(this%stats_work, trim(unique_name) // 'mean_e12')
264 call this%e13%init(this%stats_work, trim(unique_name) // 'mean_e13')
265 call this%e23%init(this%stats_work, trim(unique_name) // 'mean_e23')
266 end if
267
268 call this%stat_fields%init(this%n_stats)
269
270 call this%stat_fields%assign_to_field(1, this%p_mean%mf)
271 call this%stat_fields%assign_to_field(2, this%u_mean%mf)
272 call this%stat_fields%assign_to_field(3, this%v_mean%mf)
273 call this%stat_fields%assign_to_field(4, this%w_mean%mf)
274 call this%stat_fields%assign_to_field(5, this%pp%mf)
275 call this%stat_fields%assign_to_field(6, this%uu%mf)
276 call this%stat_fields%assign_to_field(7, this%vv%mf)
277 call this%stat_fields%assign_to_field(8, this%ww%mf)
278 call this%stat_fields%assign_to_field(9, this%uv%mf)
279 call this%stat_fields%assign_to_field(10, this%uw%mf)
280 call this%stat_fields%assign_to_field(11, this%vw%mf)
281
282 if (this%n_stats .eq. 44) then
283 call this%stat_fields%assign_to_field(12, this%uuu%mf)
284 call this%stat_fields%assign_to_field(13, this%vvv%mf)
285 call this%stat_fields%assign_to_field(14, this%www%mf)
286 call this%stat_fields%assign_to_field(15, this%uuv%mf)
287 call this%stat_fields%assign_to_field(16, this%uuw%mf)
288 call this%stat_fields%assign_to_field(17, this%uvv%mf)
289 call this%stat_fields%assign_to_field(18, this%uvw%mf)
290 call this%stat_fields%assign_to_field(19, this%vvw%mf)
291 call this%stat_fields%assign_to_field(20, this%uww%mf)
292 call this%stat_fields%assign_to_field(21, this%vww%mf)
293 call this%stat_fields%assign_to_field(22, this%uuuu%mf)
294 call this%stat_fields%assign_to_field(23, this%vvvv%mf)
295 call this%stat_fields%assign_to_field(24, this%wwww%mf)
296 call this%stat_fields%assign_to_field(25, this%ppp%mf)
297 call this%stat_fields%assign_to_field(26, this%pppp%mf)
298 call this%stat_fields%assign_to_field(27, this%pu%mf)
299 call this%stat_fields%assign_to_field(28, this%pv%mf)
300 call this%stat_fields%assign_to_field(29, this%pw%mf)
301
302 call this%stat_fields%assign_to_field(30, this%pdudx%mf)
303 call this%stat_fields%assign_to_field(31, this%pdudy%mf)
304 call this%stat_fields%assign_to_field(32, this%pdudz%mf)
305 call this%stat_fields%assign_to_field(33, this%pdvdx%mf)
306 call this%stat_fields%assign_to_field(34, this%pdvdy%mf)
307 call this%stat_fields%assign_to_field(35, this%pdvdz%mf)
308 call this%stat_fields%assign_to_field(36, this%pdwdx%mf)
309 call this%stat_fields%assign_to_field(37, this%pdwdy%mf)
310 call this%stat_fields%assign_to_field(38, this%pdwdz%mf)
311 call this%stat_fields%assign_to_field(39, this%e11%mf)
312 call this%stat_fields%assign_to_field(40, this%e22%mf)
313 call this%stat_fields%assign_to_field(41, this%e33%mf)
314 call this%stat_fields%assign_to_field(42, this%e12%mf)
315 call this%stat_fields%assign_to_field(43, this%e13%mf)
316 call this%stat_fields%assign_to_field(44, this%e23%mf)
317 end if
318
319 end subroutine fluid_stats_init
320
323 subroutine fluid_stats_update(this, k)
324 class(fluid_stats_t), intent(inout) :: this
325 real(kind=rp), intent(in) :: k
326 integer :: n
327
328 associate(stats_work => this%stats_work, stats_u => this%stats_u, &
329 stats_v => this%stats_v, stats_w => this%stats_w, &
330 stats_p => this%stats_p)
331 n = stats_work%dof%size()
332
334 if (neko_bcknd_device .eq. 1) then
335
336 call this%u_mean%update(k)
337 call this%v_mean%update(k)
338 call this%w_mean%update(k)
339 call this%p_mean%update(k)
340
341 call device_col3(stats_u%x_d, this%u%x_d, this%u%x_d, n)
342 call device_col3(stats_v%x_d, this%v%x_d, this%v%x_d, n)
343 call device_col3(stats_w%x_d, this%w%x_d, this%w%x_d, n)
344 call device_col3(stats_p%x_d, this%p%x_d, this%p%x_d, n)
345
346 call this%uu%update(k)
347 call this%vv%update(k)
348 call this%ww%update(k)
349 call this%pp%update(k)
350
351 call device_col3(stats_work%x_d, this%u%x_d, this%v%x_d, n)
352 call this%uv%update(k)
353 call device_col3(stats_work%x_d, this%u%x_d, this%w%x_d, n)
354 call this%uw%update(k)
355 call device_col3(stats_work%x_d, this%v%x_d, this%w%x_d, n)
356 call this%vw%update(k)
357 if (this%n_stats .eq. 11) return
358 call device_col2(stats_work%x_d, this%u%x_d, n)
359 call this%uvw%update(k)
360 call device_col3(stats_work%x_d, this%stats_u%x_d, this%u%x_d, n)
361 call this%uuu%update(k)
362 call device_col3(stats_work%x_d, this%stats_v%x_d, this%v%x_d, n)
363 call this%vvv%update(k)
364 call device_col3(stats_work%x_d, this%stats_w%x_d, this%w%x_d, n)
365 call this%www%update(k)
366 call device_col3(stats_work%x_d, this%stats_u%x_d, this%v%x_d, n)
367 call this%uuv%update(k)
368 call device_col3(stats_work%x_d, this%stats_u%x_d, this%w%x_d, n)
369 call this%uuw%update(k)
370 call device_col3(stats_work%x_d, this%stats_v%x_d, this%u%x_d, n)
371 call this%uvv%update(k)
372 call device_col3(stats_work%x_d, this%stats_v%x_d, this%w%x_d, n)
373 call this%vvw%update(k)
374 call device_col3(stats_work%x_d, this%stats_w%x_d, this%u%x_d, n)
375 call this%uww%update(k)
376 call device_col3(stats_work%x_d, this%stats_w%x_d, this%v%x_d, n)
377 call this%vww%update(k)
378
379 call device_col3(stats_work%x_d, this%stats_u%x_d, this%stats_u%x_d, n)
380 call this%uuuu%update(k)
381 call device_col3(stats_work%x_d, this%stats_v%x_d, this%stats_v%x_d, n)
382 call this%vvvv%update(k)
383 call device_col3(stats_work%x_d, this%stats_w%x_d, this%stats_w%x_d, n)
384 call this%wwww%update(k)
385
386 call device_col3(stats_work%x_d, this%stats_p%x_d, this%p%x_d, n)
387 call this%ppp%update(k)
388 call device_col3(stats_work%x_d, this%stats_p%x_d, this%stats_p%x_d, n)
389 call this%pppp%update(k)
390
391 call device_col3(stats_work%x_d, this%p%x_d, this%u%x_d, n)
392 call this%pu%update(k)
393 call device_col3(stats_work%x_d, this%p%x_d, this%v%x_d, n)
394 call this%pv%update(k)
395 call device_col3(stats_work%x_d, this%p%x_d, this%w%x_d, n)
396 call this%pw%update(k)
397
398 else
399
400 call this%u_mean%update(k)
401 call this%v_mean%update(k)
402 call this%w_mean%update(k)
403 call this%p_mean%update(k)
404 call col3(stats_u%x, this%u%x, this%u%x, n)
405 call col3(stats_v%x, this%v%x, this%v%x, n)
406 call col3(stats_w%x, this%w%x, this%w%x, n)
407 call col3(stats_p%x, this%p%x, this%p%x, n)
408
409 call this%uu%update(k)
410 call this%vv%update(k)
411 call this%ww%update(k)
412 call this%pp%update(k)
413
414 call col3(stats_work%x, this%u%x, this%v%x, n)
415 call this%uv%update(k)
416 call col3(stats_work%x, this%u%x, this%w%x, n)
417 call this%uw%update(k)
418 call col3(stats_work%x, this%v%x, this%w%x, n)
419 call this%vw%update(k)
420
421 if (this%n_stats .eq. 11) return
422
423 call col2(stats_work%x, this%u%x, n)
424 call this%uvw%update(k)
425 call col3(stats_work%x, this%stats_u%x, this%u%x, n)
426 call this%uuu%update(k)
427 call col3(stats_work%x, this%stats_v%x, this%v%x, n)
428 call this%vvv%update(k)
429 call col3(stats_work%x, this%stats_w%x, this%w%x, n)
430 call this%www%update(k)
431 call col3(stats_work%x, this%stats_u%x, this%v%x, n)
432 call this%uuv%update(k)
433 call col3(stats_work%x, this%stats_u%x, this%w%x, n)
434 call this%uuw%update(k)
435 call col3(stats_work%x, this%stats_v%x, this%u%x, n)
436 call this%uvv%update(k)
437 call col3(stats_work%x, this%stats_v%x, this%w%x, n)
438 call this%vvw%update(k)
439 call col3(stats_work%x, this%stats_w%x, this%u%x, n)
440 call this%uww%update(k)
441 call col3(stats_work%x, this%stats_w%x, this%v%x, n)
442 call this%vww%update(k)
443
444 call col3(stats_work%x, this%stats_u%x, this%stats_u%x, n)
445 call this%uuuu%update(k)
446 call col3(stats_work%x, this%stats_v%x, this%stats_v%x, n)
447 call this%vvvv%update(k)
448 call col3(stats_work%x, this%stats_w%x, this%stats_w%x, n)
449 call this%wwww%update(k)
450
451 call col3(stats_work%x, this%stats_p%x, this%p%x, n)
452 call this%ppp%update(k)
453 call col3(stats_work%x, this%stats_p%x, this%stats_p%x, n)
454 call this%pppp%update(k)
455
456 call col3(stats_work%x, this%p%x, this%u%x,n)
457 call this%pu%update(k)
458 call col3(stats_work%x, this%p%x, this%v%x,n)
459 call this%pv%update(k)
460 call col3(stats_work%x, this%p%x, this%w%x,n)
461 call this%pw%update(k)
462
463
464 end if
465 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, this%u%x, this%coef)
466 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, this%v%x, this%coef)
467 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, this%w%x, this%coef)
468
469 if (neko_bcknd_device .eq. 1) then
470 call device_col3(stats_work%x_d, this%dudx%x_d, this%p%x_d, n)
471 call this%pdudx%update(k)
472 call device_col3(stats_work%x_d, this%dudy%x_d, this%p%x_d, n)
473 call this%pdudy%update(k)
474 call device_col3(stats_work%x_d, this%dudz%x_d, this%p%x_d, n)
475 call this%pdudz%update(k)
476
477 call device_col3(stats_work%x_d, this%dvdx%x_d, this%p%x_d, n)
478 call this%pdvdx%update(k)
479 call device_col3(stats_work%x_d, this%dvdy%x_d, this%p%x_d, n)
480 call this%pdvdy%update(k)
481 call device_col3(stats_work%x_d, this%dvdz%x_d, this%p%x_d, n)
482 call this%pdvdz%update(k)
483
484 call device_col3(stats_work%x_d, this%dwdx%x_d, this%p%x_d, n)
485 call this%pdwdx%update(k)
486 call device_col3(stats_work%x_d, this%dwdy%x_d, this%p%x_d, n)
487 call this%pdwdy%update(k)
488 call device_col3(stats_work%x_d, this%dwdz%x_d, this%p%x_d, n)
489 call this%pdwdz%update(k)
490
491 call device_col3(this%stats_work%x_d, this%dudx%x_d, this%dudx%x_d, n)
492 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
493 this%dudy%x_d, n)
494 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
495 this%dudz%x_d, n)
496 call this%e11%update(k)
497 call device_col3(this%stats_work%x_d, this%dvdx%x_d, this%dvdx%x_d, n)
498 call device_addcol3(this%stats_work%x_d, this%dvdy%x_d, &
499 this%dvdy%x_d, n)
500 call device_addcol3(this%stats_work%x_d, this%dvdz%x_d, &
501 this%dvdz%x_d, n)
502 call this%e22%update(k)
503 call device_col3(this%stats_work%x_d, this%dwdx%x_d, this%dwdx%x_d, n)
504 call device_addcol3(this%stats_work%x_d, this%dwdy%x_d, &
505 this%dwdy%x_d, n)
506 call device_addcol3(this%stats_work%x_d, this%dwdz%x_d, &
507 this%dwdz%x_d, n)
508 call this%e33%update(k)
509 call device_col3(this%stats_work%x_d, this%dudx%x_d, &
510 this%dvdx%x_d, n)
511 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
512 this%dvdy%x_d, n)
513 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
514 this%dvdz%x_d, n)
515 call this%e12%update(k)
516 call device_col3(this%stats_work%x_d, this%dudx%x_d, this%dwdx%x_d, n)
517 call device_addcol3(this%stats_work%x_d, this%dudy%x_d, &
518 this%dwdy%x_d, n)
519 call device_addcol3(this%stats_work%x_d, this%dudz%x_d, &
520 this%dwdz%x_d, n)
521 call this%e13%update(k)
522 call device_col3(this%stats_work%x_d, this%dvdx%x_d, this%dwdx%x_d, n)
523 call device_addcol3(this%stats_work%x_d, this%dvdy%x_d, &
524 this%dwdy%x_d, n)
525 call device_addcol3(this%stats_work%x_d, this%dvdz%x_d, &
526 this%dwdz%x_d, n)
527 call this%e23%update(k)
528 else
529 call col3(stats_work%x, this%dudx%x, this%p%x, n)
530 call this%pdudx%update(k)
531 call col3(stats_work%x, this%dudy%x, this%p%x, n)
532 call this%pdudy%update(k)
533 call col3(stats_work%x, this%dudz%x, this%p%x, n)
534 call this%pdudz%update(k)
535
536 call col3(stats_work%x, this%dvdx%x, this%p%x, n)
537 call this%pdvdx%update(k)
538 call col3(stats_work%x, this%dvdy%x, this%p%x, n)
539 call this%pdvdy%update(k)
540 call col3(stats_work%x, this%dvdz%x, this%p%x, n)
541 call this%pdvdz%update(k)
542
543 call col3(stats_work%x, this%dwdx%x, this%p%x, n)
544 call this%pdwdx%update(k)
545 call col3(stats_work%x, this%dwdy%x, this%p%x, n)
546 call this%pdwdy%update(k)
547 call col3(stats_work%x, this%dwdz%x, this%p%x, n)
548 call this%pdwdz%update(k)
549
550 call col3(this%stats_work%x, this%dudx%x, this%dudx%x, n)
551 call addcol3(this%stats_work%x, this%dudy%x, this%dudy%x, n)
552 call addcol3(this%stats_work%x, this%dudz%x, this%dudz%x, n)
553 call this%e11%update(k)
554 call col3(this%stats_work%x, this%dvdx%x, this%dvdx%x, n)
555 call addcol3(this%stats_work%x, this%dvdy%x, this%dvdy%x, n)
556 call addcol3(this%stats_work%x, this%dvdz%x, this%dvdz%x, n)
557 call this%e22%update(k)
558 call col3(this%stats_work%x, this%dwdx%x, this%dwdx%x, n)
559 call addcol3(this%stats_work%x, this%dwdy%x, this%dwdy%x, n)
560 call addcol3(this%stats_work%x, this%dwdz%x, this%dwdz%x, n)
561 call this%e33%update(k)
562 call col3(this%stats_work%x, this%dudx%x, this%dvdx%x, n)
563 call addcol3(this%stats_work%x, this%dudy%x, this%dvdy%x, n)
564 call addcol3(this%stats_work%x, this%dudz%x, this%dvdz%x, n)
565 call this%e12%update(k)
566 call col3(this%stats_work%x, this%dudx%x, this%dwdx%x, n)
567 call addcol3(this%stats_work%x, this%dudy%x, this%dwdy%x, n)
568 call addcol3(this%stats_work%x, this%dudz%x, this%dwdz%x, n)
569 call this%e13%update(k)
570 call col3(this%stats_work%x, this%dvdx%x, this%dwdx%x, n)
571 call addcol3(this%stats_work%x, this%dvdy%x, this%dwdy%x, n)
572 call addcol3(this%stats_work%x, this%dvdz%x, this%dwdz%x, n)
573 call this%e23%update(k)
574
575 end if
576 end associate
577
578 end subroutine fluid_stats_update
579
580
582 subroutine fluid_stats_free(this)
583 class(fluid_stats_t), intent(inout) :: this
584
585 call this%stats_u%free()
586 call this%stats_v%free()
587 call this%stats_w%free()
588 call this%stats_p%free()
589 call this%stats_work%free()
590
591 call this%u_mean%free()
592 call this%v_mean%free()
593 call this%w_mean%free()
594 call this%p_mean%free()
595
596 call this%uu%free()
597 call this%vv%free()
598 call this%ww%free()
599 call this%uv%free()
600 call this%uw%free()
601 call this%vw%free()
602
603 call this%uuu%free()
604 call this%vvv%free()
605 call this%www%free()
606 call this%uuv%free()
607 call this%uuw%free()
608 call this%uvv%free()
609 call this%uvw%free()
610 call this%vvw%free()
611 call this%uww%free()
612 call this%vww%free()
613
614 call this%uuuu%free()
615 call this%vvvv%free()
616 call this%wwww%free()
617
618 call this%pp%free()
619 call this%ppp%free()
620 call this%pppp%free()
621
622 call this%pu%free()
623 call this%pv%free()
624 call this%pw%free()
625
626 call this%pdudx%free()
627 call this%pdudy%free()
628 call this%pdudz%free()
629 call this%pdvdx%free()
630 call this%pdvdy%free()
631 call this%pdvdz%free()
632 call this%pdwdx%free()
633 call this%pdwdy%free()
634 call this%pdwdz%free()
635
636 call this%e11%free()
637 call this%e22%free()
638 call this%e33%free()
639 call this%e12%free()
640 call this%e13%free()
641 call this%e23%free()
642
643 call this%dudx%free()
644 call this%dudy%free()
645 call this%dudz%free()
646 call this%dvdx%free()
647 call this%dvdy%free()
648 call this%dvdz%free()
649 call this%dwdx%free()
650 call this%dwdy%free()
651 call this%dwdz%free()
652
653 nullify(this%u)
654 nullify(this%v)
655 nullify(this%w)
656 nullify(this%p)
657 nullify(this%coef)
658
659 call this%stat_fields%free()
660
661 end subroutine fluid_stats_free
662
664 subroutine fluid_stats_reset(this)
665 class(fluid_stats_t), intent(inout), target:: this
666
667 call this%p_mean%reset()
668 call this%u_mean%reset()
669 call this%v_mean%reset()
670 call this%w_mean%reset()
671
672 call this%uu%reset()
673 call this%vv%reset()
674 call this%ww%reset()
675 call this%uv%reset()
676 call this%uw%reset()
677 call this%vw%reset()
678 call this%pp%reset()
679 if (this%n_stats .eq. 44) then
680 call this%uuu%reset()
681 call this%vvv%reset()
682 call this%www%reset()
683 call this%uuv%reset()
684 call this%uuw%reset()
685 call this%uvv%reset()
686 call this%uvw%reset()
687 call this%vvw%reset()
688 call this%uww%reset()
689 call this%vww%reset()
690 call this%uuuu%reset()
691 call this%vvvv%reset()
692 call this%wwww%reset()
693 call this%ppp%reset()
694 call this%pppp%reset()
695 call this%pu%reset()
696 call this%pv%reset()
697 call this%pw%reset()
698
699 call this%pdudx%reset()
700 call this%pdudy%reset()
701 call this%pdudz%reset()
702 call this%pdvdx%reset()
703 call this%pdvdy%reset()
704 call this%pdvdz%reset()
705 call this%pdwdx%reset()
706 call this%pdwdy%reset()
707 call this%pdwdz%reset()
708
709 call this%e11%reset()
710 call this%e22%reset()
711 call this%e33%reset()
712 call this%e12%reset()
713 call this%e13%reset()
714 call this%e23%reset()
715 end if
716
717 end subroutine fluid_stats_reset
718
719 ! Convert computed weak gradients to strong.
721 class(fluid_stats_t) :: this
722 integer :: n
723
724 if (this%n_stats .eq. 11) return
725
726 n = size(this%coef%B)
727
728 if (neko_bcknd_device .eq. 1) then
729 call device_cfill(this%stats_work%x_d, 1.0_rp, n)
730 call device_invcol2(this%stats_work%x_d, this%coef%B_d, n)
731 call device_col2(this%pdudx%mf%x_d, this%stats_work%x_d, n)
732 call device_col2(this%pdudy%mf%x_d, this%stats_work%x_d, n)
733 call device_col2(this%pdudz%mf%x_d, this%stats_work%x_d, n)
734 call device_col2(this%pdvdx%mf%x_d, this%stats_work%x_d, n)
735 call device_col2(this%pdvdy%mf%x_d, this%stats_work%x_d, n)
736 call device_col2(this%pdvdz%mf%x_d, this%stats_work%x_d, n)
737 call device_col2(this%pdwdx%mf%x_d, this%stats_work%x_d, n)
738 call device_col2(this%pdwdy%mf%x_d, this%stats_work%x_d, n)
739 call device_col2(this%pdwdz%mf%x_d, this%stats_work%x_d, n)
740
741 call device_col2(this%stats_work%x_d, this%stats_work%x_d, n)
742 call device_col2(this%e11%mf%x_d, this%stats_work%x_d, n)
743 call device_col2(this%e22%mf%x_d, this%stats_work%x_d, n)
744 call device_col2(this%e33%mf%x_d, this%stats_work%x_d, n)
745 call device_col2(this%e12%mf%x_d, this%stats_work%x_d, n)
746 call device_col2(this%e13%mf%x_d, this%stats_work%x_d, n)
747 call device_col2(this%e23%mf%x_d, this%stats_work%x_d, n)
748
749
750 else
751 call invers2(this%stats_work%x, this%coef%B, n)
752 call col2(this%pdudx%mf%x, this%stats_work%x, n)
753 call col2(this%pdudy%mf%x, this%stats_work%x, n)
754 call col2(this%pdudz%mf%x, this%stats_work%x, n)
755 call col2(this%pdvdx%mf%x, this%stats_work%x, n)
756 call col2(this%pdvdy%mf%x, this%stats_work%x, n)
757 call col2(this%pdvdz%mf%x, this%stats_work%x, n)
758 call col2(this%pdwdx%mf%x, this%stats_work%x, n)
759 call col2(this%pdwdy%mf%x, this%stats_work%x, n)
760 call col2(this%pdwdz%mf%x, this%stats_work%x, n)
761
762 call col2(this%stats_work%x, this%stats_work%x, n)
763 call col2(this%e11%mf%x, this%stats_work%x, n)
764 call col2(this%e22%mf%x, this%stats_work%x, n)
765 call col2(this%e33%mf%x, this%stats_work%x, n)
766 call col2(this%e12%mf%x, this%stats_work%x, n)
767 call col2(this%e13%mf%x, this%stats_work%x, n)
768 call col2(this%e23%mf%x, this%stats_work%x, n)
769
770 end if
771
772 end subroutine fluid_stats_make_strong_grad
773
776 subroutine fluid_stats_post_process(this, mean, reynolds, pressure_flatness,&
777 pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
778 class(fluid_stats_t) :: this
779 type(field_list_t), intent(inout), optional :: mean
780 type(field_list_t), intent(inout), optional :: reynolds
781 type(field_list_t), intent(in), optional :: pressure_skewness
782 type(field_list_t), intent(in), optional :: pressure_flatness
783 type(field_list_t), intent(in), optional :: skewness_tensor
784 type(field_list_t), intent(inout), optional :: mean_vel_grad
785 type(field_list_t), intent(in), optional :: dissipation_tensor
786 integer :: n
787
788 if (present(mean)) then
789 n = mean%item_size(1)
790 call copy(mean%items(1)%ptr%x, this%u_mean%mf%x, n)
791 call copy(mean%items(2)%ptr%x, this%v_mean%mf%x, n)
792 call copy(mean%items(3)%ptr%x, this%w_mean%mf%x, n)
793 call copy(mean%items(4)%ptr%x, this%p_mean%mf%x, n)
794 end if
795
796 if (present(reynolds)) then
797 n = reynolds%item_size(1)
798 call copy(reynolds%items(1)%ptr%x, this%pp%mf%x, n)
799 call subcol3(reynolds%items(1)%ptr%x, this%p_mean%mf%x, &
800 this%p_mean%mf%x, n)
801
802 call copy(reynolds%items(2)%ptr%x, this%uu%mf%x, n)
803 call subcol3(reynolds%items(2)%ptr%x, this%u_mean%mf%x, &
804 this%u_mean%mf%x, n)
805
806 call copy(reynolds%items(3)%ptr%x, this%vv%mf%x, n)
807 call subcol3(reynolds%items(3)%ptr%x, this%v_mean%mf%x, &
808 this%v_mean%mf%x,n)
809
810 call copy(reynolds%items(4)%ptr%x, this%ww%mf%x, n)
811 call subcol3(reynolds%items(4)%ptr%x, this%w_mean%mf%x, &
812 this%w_mean%mf%x,n)
813
814 call copy(reynolds%items(5)%ptr%x, this%uv%mf%x, n)
815 call subcol3(reynolds%items(5)%ptr%x, this%u_mean%mf%x, &
816 this%v_mean%mf%x, n)
817
818 call copy(reynolds%items(6)%ptr%x, this%uw%mf%x, n)
819 call subcol3(reynolds%items(6)%ptr%x, this%u_mean%mf%x, &
820 this%w_mean%mf%x, n)
821
822 call copy(reynolds%items(7)%ptr%x, this%vw%mf%x, n)
823 call subcol3(reynolds%items(7)%ptr%x, this%v_mean%mf%x, &
824 this%w_mean%mf%x, n)
825 end if
826 if (present(pressure_skewness)) then
827
828 call neko_warning('Presssure skewness stat not implemented'// &
829 ' in fluid_stats, process stats in python instead')
830
831 end if
832
833 if (present(pressure_flatness)) then
834 call neko_warning('Presssure flatness stat not implemented'// &
835 ' in fluid_stats, process stats in python instead')
836
837 end if
838
839 if (present(skewness_tensor)) then
840 call neko_warning('Skewness tensor stat not implemented'// &
841 ' in fluid_stats, process stats in python instead')
842 end if
843
844 if (present(mean_vel_grad)) then
845 !Compute gradient of mean flow
846 n = mean_vel_grad%item_size(1)
847 if (neko_bcknd_device .eq. 1) then
848 call device_memcpy(this%u_mean%mf%x, this%u_mean%mf%x_d, n, &
849 host_to_device, sync = .false.)
850 call device_memcpy(this%v_mean%mf%x, this%v_mean%mf%x_d, n, &
851 host_to_device, sync = .false.)
852 call device_memcpy(this%w_mean%mf%x, this%w_mean%mf%x_d, n, &
853 host_to_device, sync = .false.)
854 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, &
855 this%u_mean%mf%x, this%coef)
856 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, &
857 this%v_mean%mf%x, this%coef)
858 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, &
859 this%w_mean%mf%x, this%coef)
860 call device_memcpy(this%dudx%x, this%dudx%x_d, n, &
861 device_to_host, sync = .false.)
862 call device_memcpy(this%dvdx%x, this%dvdx%x_d, n, &
863 device_to_host, sync = .false.)
864 call device_memcpy(this%dwdx%x, this%dwdx%x_d, n, &
865 device_to_host, sync = .false.)
866 call device_memcpy(this%dudy%x, this%dudy%x_d, n, &
867 device_to_host, sync = .false.)
868 call device_memcpy(this%dvdy%x, this%dvdy%x_d, n, &
869 device_to_host, sync = .false.)
870 call device_memcpy(this%dwdy%x, this%dwdy%x_d, n, &
871 device_to_host, sync = .false.)
872 call device_memcpy(this%dudz%x, this%dudz%x_d, n, &
873 device_to_host, sync = .false.)
874 call device_memcpy(this%dvdz%x, this%dvdz%x_d, n, &
875 device_to_host, sync = .false.)
876 call device_memcpy(this%dwdz%x, this%dwdz%x_d, n, &
877 device_to_host, sync = .true.)
878 else
879 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, &
880 this%u_mean%mf%x, this%coef)
881 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, &
882 this%v_mean%mf%x, this%coef)
883 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, &
884 this%w_mean%mf%x, this%coef)
885 end if
886 call invers2(this%stats_work%x, this%coef%B,n)
887 call col3(mean_vel_grad%items(1)%ptr%x, this%dudx%x, &
888 this%stats_work%x, n)
889 call col3(mean_vel_grad%items(2)%ptr%x, this%dudy%x, &
890 this%stats_work%x, n)
891 call col3(mean_vel_grad%items(3)%ptr%x, this%dudz%x, &
892 this%stats_work%x, n)
893 call col3(mean_vel_grad%items(4)%ptr%x, this%dvdx%x, &
894 this%stats_work%x, n)
895 call col3(mean_vel_grad%items(5)%ptr%x, this%dvdy%x, &
896 this%stats_work%x, n)
897 call col3(mean_vel_grad%items(6)%ptr%x, this%dvdz%x, &
898 this%stats_work%x, n)
899 call col3(mean_vel_grad%items(7)%ptr%x, this%dwdx%x, &
900 this%stats_work%x, n)
901 call col3(mean_vel_grad%items(8)%ptr%x, this%dwdy%x, &
902 this%stats_work%x, n)
903 call col3(mean_vel_grad%items(9)%ptr%x, this%dwdz%x, &
904 this%stats_work%x, n)
905
906 end if
907
908 if (present(dissipation_tensor)) then
909 call neko_warning('Dissipation tensor stat not implemented'// &
910 ' in fluid_stats, process stats in python instead')
911 end if
912
913 end subroutine fluid_stats_post_process
914
915end 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, name)
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.