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