Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
scalar_stats.f90
Go to the documentation of this file.
1! Copyright (c) 2025, 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) :: scalar_stats_t
55 type(field_t) :: stats_ss
56 type(field_t) :: stats_uiuj
57 type(field_t) :: stats_work
58
60 type(field_t), pointer :: s
61 type(field_t), pointer :: u
62 type(field_t), pointer :: v
63 type(field_t), pointer :: w
64 type(field_t), pointer :: p
65
66 type(mean_field_t) :: s_mean
67
68 type(mean_field_t) :: us
69 type(mean_field_t) :: vs
70 type(mean_field_t) :: ws
71
72 type(mean_field_t) :: ss
73 type(mean_field_t) :: sss
74 type(mean_field_t) :: ssss
75
76 type(mean_field_t) :: uss
77 type(mean_field_t) :: vss
78 type(mean_field_t) :: wss
79
80 type(mean_field_t) :: uus
81 type(mean_field_t) :: vvs
82 type(mean_field_t) :: wws
83 type(mean_field_t) :: uvs
84 type(mean_field_t) :: uws
85 type(mean_field_t) :: vws
86
87 type(mean_field_t) :: ps
88
89 type(mean_field_t) :: pdsdx
90 type(mean_field_t) :: pdsdy
91 type(mean_field_t) :: pdsdz
92
93 type(mean_field_t) :: udsdx
94 type(mean_field_t) :: udsdy
95 type(mean_field_t) :: udsdz
96 type(mean_field_t) :: vdsdx
97 type(mean_field_t) :: vdsdy
98 type(mean_field_t) :: vdsdz
99 type(mean_field_t) :: wdsdx
100 type(mean_field_t) :: wdsdy
101 type(mean_field_t) :: wdsdz
102
103 type(mean_field_t) :: sdudx
104 type(mean_field_t) :: sdudy
105 type(mean_field_t) :: sdudz
106 type(mean_field_t) :: sdvdx
107 type(mean_field_t) :: sdvdy
108 type(mean_field_t) :: sdvdz
109 type(mean_field_t) :: sdwdx
110 type(mean_field_t) :: sdwdy
111 type(mean_field_t) :: sdwdz
112
113 type(mean_field_t) :: ess
114 type(mean_field_t) :: eus
115 type(mean_field_t) :: evs
116 type(mean_field_t) :: ews
117
119 type(field_t) :: dsdx
120 type(field_t) :: dsdy
121 type(field_t) :: dsdz
122 type(field_t) :: dudx
123 type(field_t) :: dudy
124 type(field_t) :: dudz
125 type(field_t) :: dvdx
126 type(field_t) :: dvdy
127 type(field_t) :: dvdz
128 type(field_t) :: dwdx
129 type(field_t) :: dwdy
130 type(field_t) :: dwdz
131
133 type(coef_t), pointer :: coef
135 integer :: n_stats = 42
138 character(5) :: stat_set
141 type(field_list_t) :: stat_fields
142 contains
144 procedure, pass(this) :: init => scalar_stats_init
146 procedure, pass(this) :: free => scalar_stats_free
148 procedure, pass(this) :: update => scalar_stats_update
150 procedure, pass(this) :: reset => scalar_stats_reset
151 ! Convert computed weak gradients to strong.
152 procedure, pass(this) :: make_strong_grad => scalar_stats_make_strong_grad
153 end type scalar_stats_t
154
155contains
156
166 subroutine scalar_stats_init(this, coef, s, u, v, w, p, set)
167 class(scalar_stats_t), intent(inout), target:: this
168 type(coef_t), target, optional :: coef
169 type(field_t), target, intent(in) :: s, u, v, w, p
170 character(*), intent(in), optional :: set
171
172 call this%free()
173 this%coef => coef
174
175 this%s => s
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 = 5
185 end if
186 else
187 this%stat_set = 'full'
188 this%n_stats = 42
189 end if
190
191 ! Initialize work fields
192 call this%stats_work%init(this%u%dof, 'stats')
193 call this%stats_ss%init(this%u%dof, 'ss temp')
194
195 ! Initialize mean fields
196 call this%s_mean%init(this%s)
197
198 call this%us%init(this%stats_work, 'us')
199 call this%vs%init(this%stats_work, 'vs')
200 call this%ws%init(this%stats_work, 'ws')
201
202 call this%ss%init(this%stats_ss, 'ss')
203
204 if (this%n_stats .eq. 42) then
205 ! Initialize req. work fields
206 call this%stats_uiuj%init(this%u%dof, 'uiuj temp')
207
208 ! Initialize req. gradient fields
209 call this%dsdx%init(this%u%dof, 'dsdx')
210 call this%dsdy%init(this%u%dof, 'dsdy')
211 call this%dsdz%init(this%u%dof, 'dsdz')
212
213 call this%dudx%init(this%u%dof, 'dudx')
214 call this%dudy%init(this%u%dof, 'dudy')
215 call this%dudz%init(this%u%dof, 'dudz')
216 call this%dvdx%init(this%u%dof, 'dvdx')
217 call this%dvdy%init(this%u%dof, 'dvdy')
218 call this%dvdz%init(this%u%dof, 'dvdz')
219 call this%dwdx%init(this%u%dof, 'dwdx')
220 call this%dwdy%init(this%u%dof, 'dwdy')
221 call this%dwdz%init(this%u%dof, 'dwdz')
222
223 ! Initialize req. mean fields
224 call this%sss%init(this%stats_work, 'sss')
225 call this%ssss%init(this%stats_work, 'ssss')
226
227 call this%uss%init(this%stats_work, 'uss')
228 call this%vss%init(this%stats_work, 'vss')
229 call this%wss%init(this%stats_work, 'wss')
230
231 call this%uus%init(this%stats_work, 'uus')
232 call this%vvs%init(this%stats_work, 'vvs')
233 call this%wws%init(this%stats_work, 'wws')
234 call this%uvs%init(this%stats_work, 'uvs')
235 call this%uws%init(this%stats_work, 'uws')
236 call this%vws%init(this%stats_work, 'vws')
237
238 call this%ps%init(this%stats_work, 'ps')
239
240 call this%pdsdx%init(this%stats_work, 'pdsdx')
241 call this%pdsdy%init(this%stats_work, 'pdsdy')
242 call this%pdsdz%init(this%stats_work, 'pdsdz')
243
244 call this%udsdx%init(this%stats_work, 'udsdx')
245 call this%udsdy%init(this%stats_work, 'udsdy')
246 call this%udsdz%init(this%stats_work, 'udsdz')
247 call this%vdsdx%init(this%stats_work, 'vdsdx')
248 call this%vdsdy%init(this%stats_work, 'vdsdy')
249 call this%vdsdz%init(this%stats_work, 'vdsdz')
250 call this%wdsdx%init(this%stats_work, 'wdsdx')
251 call this%wdsdy%init(this%stats_work, 'wdsdy')
252 call this%wdsdz%init(this%stats_work, 'wdsdz')
253
254 call this%sdudx%init(this%stats_work, 'sdudx')
255 call this%sdudy%init(this%stats_work, 'sdudy')
256 call this%sdudz%init(this%stats_work, 'sdudz')
257 call this%sdvdx%init(this%stats_work, 'sdvdx')
258 call this%sdvdy%init(this%stats_work, 'sdvdy')
259 call this%sdvdz%init(this%stats_work, 'sdvdz')
260 call this%sdwdx%init(this%stats_work, 'sdwdx')
261 call this%sdwdy%init(this%stats_work, 'sdwdy')
262 call this%sdwdz%init(this%stats_work, 'sdwdz')
263
264 call this%ess%init(this%stats_work, 'ess')
265 call this%eus%init(this%stats_work, 'eus')
266 call this%evs%init(this%stats_work, 'evs')
267 call this%ews%init(this%stats_work, 'ews')
268 end if
269
270 allocate(this%stat_fields%items(this%n_stats))
271
272 call this%stat_fields%assign_to_field(1, this%s_mean%mf)
273
274 call this%stat_fields%assign_to_field(2, this%us%mf)
275 call this%stat_fields%assign_to_field(3, this%vs%mf)
276 call this%stat_fields%assign_to_field(4, this%ws%mf)
277
278 call this%stat_fields%assign_to_field(5, this%ss%mf)
279
280 if (this%n_stats .eq. 42) then
281 call this%stat_fields%assign_to_field(6, this%sss%mf)
282 call this%stat_fields%assign_to_field(7, this%ssss%mf)
283
284 call this%stat_fields%assign_to_field(8, this%uss%mf)
285 call this%stat_fields%assign_to_field(9, this%vss%mf)
286 call this%stat_fields%assign_to_field(10, this%wss%mf)
287 call this%stat_fields%assign_to_field(11, this%uus%mf)
288 call this%stat_fields%assign_to_field(12, this%vvs%mf)
289 call this%stat_fields%assign_to_field(13, this%wws%mf)
290 call this%stat_fields%assign_to_field(14, this%uvs%mf)
291 call this%stat_fields%assign_to_field(15, this%uws%mf)
292 call this%stat_fields%assign_to_field(16, this%vws%mf)
293
294 call this%stat_fields%assign_to_field(17, this%ps%mf)
295
296 call this%stat_fields%assign_to_field(18, this%pdsdx%mf)
297 call this%stat_fields%assign_to_field(19, this%pdsdy%mf)
298 call this%stat_fields%assign_to_field(20, this%pdsdz%mf)
299
300 call this%stat_fields%assign_to_field(21, this%udsdx%mf)
301 call this%stat_fields%assign_to_field(22, this%udsdy%mf)
302 call this%stat_fields%assign_to_field(23, this%udsdz%mf)
303 call this%stat_fields%assign_to_field(24, this%vdsdx%mf)
304 call this%stat_fields%assign_to_field(25, this%vdsdy%mf)
305 call this%stat_fields%assign_to_field(26, this%vdsdz%mf)
306 call this%stat_fields%assign_to_field(27, this%wdsdx%mf)
307 call this%stat_fields%assign_to_field(28, this%wdsdy%mf)
308 call this%stat_fields%assign_to_field(29, this%wdsdz%mf)
309
310 call this%stat_fields%assign_to_field(30, this%sdudx%mf)
311 call this%stat_fields%assign_to_field(31, this%sdudy%mf)
312 call this%stat_fields%assign_to_field(32, this%sdudz%mf)
313 call this%stat_fields%assign_to_field(33, this%sdvdx%mf)
314 call this%stat_fields%assign_to_field(34, this%sdvdy%mf)
315 call this%stat_fields%assign_to_field(35, this%sdvdz%mf)
316 call this%stat_fields%assign_to_field(36, this%sdwdx%mf)
317 call this%stat_fields%assign_to_field(37, this%sdwdy%mf)
318 call this%stat_fields%assign_to_field(38, this%sdwdz%mf)
319
320 call this%stat_fields%assign_to_field(39, this%ess%mf)
321 call this%stat_fields%assign_to_field(40, this%eus%mf)
322 call this%stat_fields%assign_to_field(41, this%evs%mf)
323 call this%stat_fields%assign_to_field(42, this%ews%mf)
324 end if
325
326 end subroutine scalar_stats_init
327
330 subroutine scalar_stats_update(this, k)
331 class(scalar_stats_t), intent(inout) :: this
332 real(kind=rp), intent(in) :: k
333 integer :: n
334
335 associate(stats_work => this%stats_work, stats_ss => this%stats_ss, &
336 stats_uiuj => this%stats_uiuj)
337 n = stats_work%dof%size()
338
340 if (neko_bcknd_device .eq. 1) then
341
342 call this%s_mean%update(k)
343
344 call device_col3(stats_work%x_d, this%u%x_d, this%s%x_d, n)
345 call this%us%update(k)
346 call device_col3(stats_work%x_d, this%v%x_d, this%s%x_d, n)
347 call this%vs%update(k)
348 call device_col3(stats_work%x_d, this%w%x_d, this%s%x_d, n)
349 call this%ws%update(k)
350
351 call device_col3(stats_ss%x_d, this%s%x_d, this%s%x_d, n)
352 call this%ss%update(k)
353
354 if (this%n_stats .eq. 5) return
355
356 call device_col3(stats_work%x_d, this%stats_ss%x_d, this%s%x_d, n)
357 call this%sss%update(k)
358 call device_col3(stats_work%x_d, this%stats_ss%x_d, &
359 this%stats_ss%x_d, n)
360 call this%ssss%update(k)
361
362 call device_col3(stats_work%x_d, this%u%x_d, this%stats_ss%x_d, n)
363 call this%uss%update(k)
364 call device_col3(stats_work%x_d, this%v%x_d, this%stats_ss%x_d, n)
365 call this%vss%update(k)
366 call device_col3(stats_work%x_d, this%w%x_d, this%stats_ss%x_d, n)
367 call this%wss%update(k)
368
369 call device_col3(stats_uiuj%x_d, this%u%x_d, this%u%x_d, n)
370 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
371 call this%uus%update(k)
372 call device_col3(stats_uiuj%x_d, this%v%x_d, this%v%x_d, n)
373 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
374 call this%vvs%update(k)
375 call device_col3(stats_uiuj%x_d, this%w%x_d, this%w%x_d, n)
376 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
377 call this%wws%update(k)
378 call device_col3(stats_uiuj%x_d, this%u%x_d, this%v%x_d, n)
379 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
380 call this%uvs%update(k)
381 call device_col3(stats_uiuj%x_d, this%u%x_d, this%w%x_d, n)
382 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
383 call this%uws%update(k)
384 call device_col3(stats_uiuj%x_d, this%v%x_d, this%w%x_d, n)
385 call device_col3(stats_work%x_d, stats_uiuj%x_d, this%s%x_d, n)
386 call this%vws%update(k)
387
388 call device_col3(stats_work%x_d, this%p%x_d, this%s%x_d, n)
389 call this%ps%update(k)
390
391 else
392
393 call this%s_mean%update(k)
394
395 call col3(stats_work%x, this%u%x, this%s%x, n)
396 call this%us%update(k)
397 call col3(stats_work%x, this%v%x, this%s%x, n)
398 call this%vs%update(k)
399 call col3(stats_work%x, this%w%x, this%s%x, n)
400 call this%ws%update(k)
401
402 call col3(stats_ss%x, this%s%x, this%s%x, n)
403 call this%ss%update(k)
404
405 if (this%n_stats .eq. 5) return
406
407 call col3(stats_work%x, this%stats_ss%x, this%s%x, n)
408 call this%sss%update(k)
409 call col3(stats_work%x, this%stats_ss%x, this%stats_ss%x, n)
410 call this%ssss%update(k)
411
412 call col3(stats_work%x, this%u%x, this%stats_ss%x, n)
413 call this%uss%update(k)
414 call col3(stats_work%x, this%v%x, this%stats_ss%x, n)
415 call this%vss%update(k)
416 call col3(stats_work%x, this%w%x, this%stats_ss%x, n)
417 call this%wss%update(k)
418
419 call col3(stats_uiuj%x, this%u%x, this%u%x, n)
420 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
421 call this%uus%update(k)
422 call col3(stats_uiuj%x, this%v%x, this%v%x, n)
423 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
424 call this%vvs%update(k)
425 call col3(stats_uiuj%x, this%w%x, this%w%x, n)
426 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
427 call this%wws%update(k)
428 call col3(stats_uiuj%x, this%u%x, this%v%x, n)
429 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
430 call this%uvs%update(k)
431 call col3(stats_uiuj%x, this%u%x, this%w%x, n)
432 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
433 call this%uws%update(k)
434 call col3(stats_uiuj%x, this%v%x, this%w%x, n)
435 call col3(stats_work%x, stats_uiuj%x, this%s%x, n)
436 call this%vws%update(k)
437
438 call col3(stats_work%x, this%p%x, this%s%x, n)
439 call this%ps%update(k)
440
441 end if
442
443 call opgrad(this%dsdx%x, this%dsdy%x, this%dsdz%x, this%s%x, this%coef)
444 call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, this%u%x, this%coef)
445 call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, this%v%x, this%coef)
446 call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, this%w%x, this%coef)
447
448 if (neko_bcknd_device .eq. 1) then
449 call device_col3(stats_work%x_d, this%dsdx%x_d, this%p%x_d, n)
450 call this%pdsdx%update(k)
451 call device_col3(stats_work%x_d, this%dsdy%x_d, this%p%x_d, n)
452 call this%pdsdy%update(k)
453 call device_col3(stats_work%x_d, this%dsdz%x_d, this%p%x_d, n)
454 call this%pdsdz%update(k)
455
456 call device_col3(stats_work%x_d, this%dsdx%x_d, this%u%x_d, n)
457 call this%udsdx%update(k)
458 call device_col3(stats_work%x_d, this%dsdy%x_d, this%u%x_d, n)
459 call this%udsdy%update(k)
460 call device_col3(stats_work%x_d, this%dsdz%x_d, this%u%x_d, n)
461 call this%udsdz%update(k)
462
463 call device_col3(stats_work%x_d, this%dsdx%x_d, this%v%x_d, n)
464 call this%vdsdx%update(k)
465 call device_col3(stats_work%x_d, this%dsdy%x_d, this%v%x_d, n)
466 call this%vdsdy%update(k)
467 call device_col3(stats_work%x_d, this%dsdz%x_d, this%v%x_d, n)
468 call this%vdsdz%update(k)
469
470 call device_col3(stats_work%x_d, this%dsdx%x_d, this%w%x_d, n)
471 call this%wdsdx%update(k)
472 call device_col3(stats_work%x_d, this%dsdy%x_d, this%w%x_d, n)
473 call this%wdsdy%update(k)
474 call device_col3(stats_work%x_d, this%dsdz%x_d, this%w%x_d, n)
475 call this%wdsdz%update(k)
476
477 call device_col3(stats_work%x_d, this%dudx%x_d, this%s%x_d, n)
478 call this%sdudx%update(k)
479 call device_col3(stats_work%x_d, this%dudy%x_d, this%s%x_d, n)
480 call this%sdudy%update(k)
481 call device_col3(stats_work%x_d, this%dudz%x_d, this%s%x_d, n)
482 call this%sdudz%update(k)
483
484 call device_col3(stats_work%x_d, this%dvdx%x_d, this%s%x_d, n)
485 call this%sdvdx%update(k)
486 call device_col3(stats_work%x_d, this%dvdy%x_d, this%s%x_d, n)
487 call this%sdvdy%update(k)
488 call device_col3(stats_work%x_d, this%dvdz%x_d, this%s%x_d, n)
489 call this%sdvdz%update(k)
490
491 call device_col3(stats_work%x_d, this%dwdx%x_d, this%s%x_d, n)
492 call this%sdwdx%update(k)
493 call device_col3(stats_work%x_d, this%dwdy%x_d, this%s%x_d, n)
494 call this%sdwdy%update(k)
495 call device_col3(stats_work%x_d, this%dwdz%x_d, this%s%x_d, n)
496 call this%sdwdz%update(k)
497
498 call device_col3(stats_work%x_d, this%dsdx%x_d, &
499 this%dsdx%x_d, n)
500 call device_addcol3(stats_work%x_d, this%dsdy%x_d, &
501 this%dsdy%x_d, n)
502 call device_addcol3(stats_work%x_d, this%dsdz%x_d, &
503 this%dsdz%x_d, n)
504 call this%ess%update(k)
505
506 call device_col3(stats_work%x_d, this%dudx%x_d, &
507 this%dsdx%x_d, n)
508 call device_addcol3(stats_work%x_d, this%dudy%x_d, &
509 this%dsdy%x_d, n)
510 call device_addcol3(stats_work%x_d, this%dudz%x_d, &
511 this%dsdz%x_d, n)
512 call this%eus%update(k)
513
514 call device_col3(stats_work%x_d, this%dvdx%x_d, &
515 this%dsdx%x_d, n)
516 call device_addcol3(stats_work%x_d, this%dvdy%x_d, &
517 this%dsdy%x_d, n)
518 call device_addcol3(stats_work%x_d, this%dvdz%x_d, &
519 this%dsdz%x_d, n)
520 call this%evs%update(k)
521
522 call device_col3(stats_work%x_d, this%dwdx%x_d, &
523 this%dsdx%x_d, n)
524 call device_addcol3(stats_work%x_d, this%dwdy%x_d, &
525 this%dsdy%x_d, n)
526 call device_addcol3(stats_work%x_d, this%dwdz%x_d, &
527 this%dsdz%x_d, n)
528 call this%ews%update(k)
529
530 else
531
532 call col3(stats_work%x, this%dsdx%x, this%p%x, n)
533 call this%pdsdx%update(k)
534 call col3(stats_work%x, this%dsdy%x, this%p%x, n)
535 call this%pdsdy%update(k)
536 call col3(stats_work%x, this%dsdz%x, this%p%x, n)
537 call this%pdsdz%update(k)
538
539 call col3(stats_work%x, this%dsdx%x, this%u%x, n)
540 call this%udsdx%update(k)
541 call col3(stats_work%x, this%dsdy%x, this%u%x, n)
542 call this%udsdy%update(k)
543 call col3(stats_work%x, this%dsdz%x, this%u%x, n)
544 call this%udsdz%update(k)
545
546 call col3(stats_work%x, this%dsdx%x, this%v%x, n)
547 call this%vdsdx%update(k)
548 call col3(stats_work%x, this%dsdy%x, this%v%x, n)
549 call this%vdsdy%update(k)
550 call col3(stats_work%x, this%dsdz%x, this%v%x, n)
551 call this%vdsdz%update(k)
552
553 call col3(stats_work%x, this%dsdx%x, this%w%x, n)
554 call this%wdsdx%update(k)
555 call col3(stats_work%x, this%dsdy%x, this%w%x, n)
556 call this%wdsdy%update(k)
557 call col3(stats_work%x, this%dsdz%x, this%w%x, n)
558 call this%wdsdz%update(k)
559
560 call col3(stats_work%x, this%dudx%x, this%s%x, n)
561 call this%sdudx%update(k)
562 call col3(stats_work%x, this%dudy%x, this%s%x, n)
563 call this%sdudy%update(k)
564 call col3(stats_work%x, this%dudz%x, this%s%x, n)
565 call this%sdudz%update(k)
566
567 call col3(stats_work%x, this%dvdx%x, this%s%x, n)
568 call this%sdvdx%update(k)
569 call col3(stats_work%x, this%dvdy%x, this%s%x, n)
570 call this%sdvdy%update(k)
571 call col3(stats_work%x, this%dvdz%x, this%s%x, n)
572 call this%sdvdz%update(k)
573
574 call col3(stats_work%x, this%dwdx%x, this%s%x, n)
575 call this%sdwdx%update(k)
576 call col3(stats_work%x, this%dwdy%x, this%s%x, n)
577 call this%sdwdy%update(k)
578 call col3(stats_work%x, this%dwdz%x, this%s%x, n)
579 call this%sdwdz%update(k)
580
581 call col3(stats_work%x, this%dsdx%x, &
582 this%dsdx%x, n)
583 call addcol3(stats_work%x, this%dsdy%x, &
584 this%dsdy%x, n)
585 call addcol3(stats_work%x, this%dsdz%x, &
586 this%dsdz%x, n)
587 call this%ess%update(k)
588
589 call col3(stats_work%x, this%dudx%x, &
590 this%dsdx%x, n)
591 call addcol3(stats_work%x, this%dudy%x, &
592 this%dsdy%x, n)
593 call addcol3(stats_work%x, this%dudz%x, &
594 this%dsdz%x, n)
595 call this%eus%update(k)
596
597 call col3(stats_work%x, this%dvdx%x, &
598 this%dsdx%x, n)
599 call addcol3(stats_work%x, this%dvdy%x, &
600 this%dsdy%x, n)
601 call addcol3(stats_work%x, this%dvdz%x, &
602 this%dsdz%x, n)
603 call this%evs%update(k)
604
605 call col3(stats_work%x, this%dwdx%x, &
606 this%dsdx%x, n)
607 call addcol3(stats_work%x, this%dwdy%x, &
608 this%dsdy%x, n)
609 call addcol3(stats_work%x, this%dwdz%x, &
610 this%dsdz%x, n)
611 call this%ews%update(k)
612
613 end if
614 end associate
615
616 end subroutine scalar_stats_update
617
618
620 subroutine scalar_stats_free(this)
621 class(scalar_stats_t), intent(inout) :: this
622
623 call this%stats_work%free()
624 call this%stats_ss%free()
625 call this%stats_uiuj%free()
626
627 call this%s_mean%free()
628
629 call this%us%free()
630 call this%vs%free()
631 call this%ws%free()
632
633 call this%ss%free()
634
635 if (this%n_stats .eq. 42) then
636 call this%sss%free()
637 call this%ssss%free()
638
639 call this%uss%free()
640 call this%vss%free()
641 call this%wss%free()
642
643 call this%uus%free()
644 call this%vvs%free()
645 call this%wws%free()
646 call this%uvs%free()
647 call this%uws%free()
648 call this%vws%free()
649
650 call this%ps%free()
651
652 call this%pdsdx%free()
653 call this%pdsdy%free()
654 call this%pdsdz%free()
655
656 call this%udsdx%free()
657 call this%udsdy%free()
658 call this%udsdz%free()
659 call this%vdsdx%free()
660 call this%vdsdy%free()
661 call this%vdsdz%free()
662 call this%wdsdx%free()
663 call this%wdsdy%free()
664 call this%wdsdz%free()
665
666 call this%sdudx%free()
667 call this%sdudy%free()
668 call this%sdudz%free()
669 call this%sdvdx%free()
670 call this%sdvdy%free()
671 call this%sdvdz%free()
672 call this%sdwdx%free()
673 call this%sdwdy%free()
674 call this%sdwdz%free()
675
676 call this%ess%free()
677 call this%eus%free()
678 call this%evs%free()
679 call this%ews%free()
680
681 call this%dsdx%free()
682 call this%dsdy%free()
683 call this%dsdz%free()
684 call this%dudx%free()
685 call this%dudy%free()
686 call this%dudz%free()
687 call this%dvdx%free()
688 call this%dvdy%free()
689 call this%dvdz%free()
690 call this%dwdx%free()
691 call this%dwdy%free()
692 call this%dwdz%free()
693 end if
694
695 nullify(this%coef)
696 nullify(this%s)
697 nullify(this%u)
698 nullify(this%v)
699 nullify(this%w)
700 nullify(this%p)
701
702 end subroutine scalar_stats_free
703
705 subroutine scalar_stats_reset(this)
706 class(scalar_stats_t), intent(inout), target:: this
707
708 call this%s_mean%reset()
709
710 call this%us%reset()
711 call this%vs%reset()
712 call this%ws%reset()
713
714 call this%ss%reset()
715
716 if (this%n_stats .eq. 42) then
717 call this%sss%reset()
718 call this%ssss%reset()
719
720 call this%uss%reset()
721 call this%vss%reset()
722 call this%wss%reset()
723
724 call this%uus%reset()
725 call this%vvs%reset()
726 call this%wws%reset()
727 call this%uvs%reset()
728 call this%uws%reset()
729 call this%vws%reset()
730
731 call this%ps%reset()
732
733 call this%pdsdx%reset()
734 call this%pdsdy%reset()
735 call this%pdsdz%reset()
736
737 call this%udsdx%reset()
738 call this%udsdy%reset()
739 call this%udsdz%reset()
740 call this%vdsdx%reset()
741 call this%vdsdy%reset()
742 call this%vdsdz%reset()
743 call this%wdsdx%reset()
744 call this%wdsdy%reset()
745 call this%wdsdz%reset()
746
747 call this%sdudx%reset()
748 call this%sdudy%reset()
749 call this%sdudz%reset()
750 call this%sdvdx%reset()
751 call this%sdvdy%reset()
752 call this%sdvdz%reset()
753 call this%sdwdx%reset()
754 call this%sdwdy%reset()
755 call this%sdwdz%reset()
756
757 call this%ess%reset()
758 call this%eus%reset()
759 call this%evs%reset()
760 call this%ews%reset()
761 end if
762
763 end subroutine scalar_stats_reset
764
765 ! Convert computed weak gradients to strong.
767 class(scalar_stats_t) :: this
768 integer :: n
769
770 if (this%n_stats .eq. 5) return
771
772 n = size(this%coef%B)
773
774 if (neko_bcknd_device .eq. 1) then
775 call device_cfill(this%stats_work%x_d, 1.0_rp, n)
776 call device_invcol2(this%stats_work%x_d, this%coef%B_d, n)
777
778 call device_col2(this%pdsdx%mf%x_d, this%stats_work%x_d, n)
779 call device_col2(this%pdsdy%mf%x_d, this%stats_work%x_d, n)
780 call device_col2(this%pdsdz%mf%x_d, this%stats_work%x_d, n)
781
782 call device_col2(this%udsdx%mf%x_d, this%stats_work%x_d, n)
783 call device_col2(this%udsdy%mf%x_d, this%stats_work%x_d, n)
784 call device_col2(this%udsdz%mf%x_d, this%stats_work%x_d, n)
785 call device_col2(this%vdsdx%mf%x_d, this%stats_work%x_d, n)
786 call device_col2(this%vdsdy%mf%x_d, this%stats_work%x_d, n)
787 call device_col2(this%vdsdz%mf%x_d, this%stats_work%x_d, n)
788 call device_col2(this%wdsdx%mf%x_d, this%stats_work%x_d, n)
789 call device_col2(this%wdsdy%mf%x_d, this%stats_work%x_d, n)
790 call device_col2(this%wdsdz%mf%x_d, this%stats_work%x_d, n)
791
792 call device_col2(this%sdudx%mf%x_d, this%stats_work%x_d, n)
793 call device_col2(this%sdudy%mf%x_d, this%stats_work%x_d, n)
794 call device_col2(this%sdudz%mf%x_d, this%stats_work%x_d, n)
795 call device_col2(this%sdvdx%mf%x_d, this%stats_work%x_d, n)
796 call device_col2(this%sdvdy%mf%x_d, this%stats_work%x_d, n)
797 call device_col2(this%sdvdz%mf%x_d, this%stats_work%x_d, n)
798 call device_col2(this%sdwdx%mf%x_d, this%stats_work%x_d, n)
799 call device_col2(this%sdwdy%mf%x_d, this%stats_work%x_d, n)
800 call device_col2(this%sdwdz%mf%x_d, this%stats_work%x_d, n)
801
802 call device_col2(this%stats_work%x_d, this%stats_work%x_d, n)
803
804 call device_col2(this%ess%mf%x_d, this%stats_work%x_d, n)
805 call device_col2(this%eus%mf%x_d, this%stats_work%x_d, n)
806 call device_col2(this%evs%mf%x_d, this%stats_work%x_d, n)
807 call device_col2(this%ews%mf%x_d, this%stats_work%x_d, n)
808
809 else
810
811 call invers2(this%stats_work%x, this%coef%B, n)
812
813 call col2(this%pdsdx%mf%x, this%stats_work%x, n)
814 call col2(this%pdsdy%mf%x, this%stats_work%x, n)
815 call col2(this%pdsdz%mf%x, this%stats_work%x, n)
816
817 call col2(this%udsdx%mf%x, this%stats_work%x, n)
818 call col2(this%udsdy%mf%x, this%stats_work%x, n)
819 call col2(this%udsdz%mf%x, this%stats_work%x, n)
820 call col2(this%vdsdx%mf%x, this%stats_work%x, n)
821 call col2(this%vdsdy%mf%x, this%stats_work%x, n)
822 call col2(this%vdsdz%mf%x, this%stats_work%x, n)
823 call col2(this%wdsdx%mf%x, this%stats_work%x, n)
824 call col2(this%wdsdy%mf%x, this%stats_work%x, n)
825 call col2(this%wdsdz%mf%x, this%stats_work%x, n)
826
827 call col2(this%sdudx%mf%x, this%stats_work%x, n)
828 call col2(this%sdudy%mf%x, this%stats_work%x, n)
829 call col2(this%sdudz%mf%x, this%stats_work%x, n)
830 call col2(this%sdvdx%mf%x, this%stats_work%x, n)
831 call col2(this%sdvdy%mf%x, this%stats_work%x, n)
832 call col2(this%sdvdz%mf%x, this%stats_work%x, n)
833 call col2(this%sdwdx%mf%x, this%stats_work%x, n)
834 call col2(this%sdwdy%mf%x, this%stats_work%x, n)
835 call col2(this%sdwdz%mf%x, this%stats_work%x, n)
836
837 call col2(this%stats_work%x, this%stats_work%x, n)
838
839 call col2(this%ess%mf%x, this%stats_work%x, n)
840 call col2(this%eus%mf%x, this%stats_work%x, n)
841 call col2(this%evs%mf%x, this%stats_work%x, n)
842 call col2(this%ews%mf%x, this%stats_work%x, n)
843
844 end if
845
846 end subroutine scalar_stats_make_strong_grad
847
848end module scalar_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
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.
Computes various statistics for the scalar fields. We use the Reynolds decomposition for a field u = ...
subroutine scalar_stats_free(this)
Destructor.
subroutine scalar_stats_make_strong_grad(this)
subroutine scalar_stats_update(this, k)
Updates all fields with a new sample.
subroutine scalar_stats_init(this, coef, s, u, v, w, p, set)
Constructor. Initialize the fields associated with scalar_stats.
subroutine scalar_stats_reset(this)
Resets all the computed means values and sampling times to zero.
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.