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