Neko  0.8.1
A portable framework for high-order spectral element flow simulations
fluid_stats.f90
Go to the documentation of this file.
1 ! Copyright (c) 2022-2023, 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
38  use device_math
39  use device_mathops
40  use mathops
41  use math
42  use operators
43  use coefs
44  use field
45  use field_registry
46  use field_list
47  use gather_scatter
48  use stats_quant
49  use device
50  use neko_config
51  use utils
52  implicit none
53  private
54 
55  type, public, extends(stats_quant_t) :: fluid_stats_t
56  type(field_t) :: stats_u
57  type(field_t) :: stats_v
58  type(field_t) :: stats_w
59  type(field_t) :: stats_p
60  type(field_t) :: stats_work
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(field_t), pointer :: u_mean
67  type(field_t), pointer :: v_mean
68  type(field_t), pointer :: w_mean
69  type(field_t), pointer :: p_mean
71  type(mean_field_t) :: uu
72  type(mean_field_t) :: vv
73  type(mean_field_t) :: ww
74  type(mean_field_t) :: uv
75  type(mean_field_t) :: uw
76  type(mean_field_t) :: vw
78  type(mean_field_t) :: uuu
79  type(mean_field_t) :: vvv
80  type(mean_field_t) :: www
81  type(mean_field_t) :: uuv
82  type(mean_field_t) :: uuw
83  type(mean_field_t) :: uvv
84  type(mean_field_t) :: uvw
85  type(mean_field_t) :: vvw
86  type(mean_field_t) :: uww
87  type(mean_field_t) :: vww
89  type(mean_field_t) :: uuuu
90  type(mean_field_t) :: vvvv
91  type(mean_field_t) :: wwww
93  type(mean_field_t) :: pp
94  type(mean_field_t) :: ppp
95  type(mean_field_t) :: pppp
97  type(mean_field_t) :: pu
98  type(mean_field_t) :: pv
99  type(mean_field_t) :: pw
100 
102  type(mean_field_t) :: pdudx
103  type(mean_field_t) :: pdudy
104  type(mean_field_t) :: pdudz
105  type(mean_field_t) :: pdvdx
106  type(mean_field_t) :: pdvdy
107  type(mean_field_t) :: pdvdz
108  type(mean_field_t) :: pdwdx
109  type(mean_field_t) :: pdwdy
110  type(mean_field_t) :: pdwdz
111 
113  type(mean_field_t) :: e11
114  type(mean_field_t) :: e22
115  type(mean_field_t) :: e33
116  type(mean_field_t) :: e12
117  type(mean_field_t) :: e13
118  type(mean_field_t) :: e23
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 
130  type(coef_t), pointer :: coef
131  integer :: n_stats = 40
141  type(field_list_t) :: stat_fields
142  contains
143  procedure, pass(this) :: init => fluid_stats_init
144  procedure, pass(this) :: free => fluid_stats_free
145  procedure, pass(this) :: update => fluid_stats_update
146  procedure, pass(this) :: reset => fluid_stats_reset
147  procedure, pass(this) :: make_strong_grad => fluid_stats_make_strong_grad
148  procedure, pass(this) :: post_process => fluid_stats_post_process
149  end type fluid_stats_t
150 
151 contains
152 
154  subroutine fluid_stats_init(this, coef, u_mf,v_mf,w_mf,p_mf)
155  class(fluid_stats_t), intent(inout), target:: this
156  type(coef_t), target, optional :: coef
157  type(mean_field_t), target, intent(inout) :: u_mf, v_mf, w_mf, p_mf
158  this%coef => coef
159 
160  this%u_mean => u_mf%mf
161  this%v_mean => v_mf%mf
162  this%w_mean => w_mf%mf
163  this%p_mean => p_mf%mf
164  this%u => u_mf%f
165  this%v => v_mf%f
166  this%w => w_mf%f
167  this%p => p_mf%f
168 
169  call this%stats_work%init(this%u%dof, 'stats')
170  call this%stats_u%init(this%u%dof, 'u temp')
171  call this%stats_v%init(this%u%dof, 'v temp')
172  call this%stats_w%init(this%u%dof, 'w temp')
173  call this%stats_p%init(this%u%dof, 'p temp')
174 
175  call this%dudx%init(this%u%dof, 'dudx')
176  call this%dudy%init(this%u%dof, 'dudy')
177  call this%dudz%init(this%u%dof, 'dudz')
178  call this%dvdx%init(this%u%dof, 'dvdx')
179  call this%dvdy%init(this%u%dof, 'dvdy')
180  call this%dvdz%init(this%u%dof, 'dvdz')
181  call this%dwdx%init(this%u%dof, 'dwdx')
182  call this%dwdy%init(this%u%dof, 'dwdy')
183  call this%dwdz%init(this%u%dof, 'dwdz')
184 
185  call this%uu%init(this%stats_u, 'uu')
186  call this%vv%init(this%stats_v, 'vv')
187  call this%ww%init(this%stats_w, 'ww')
188  call this%uv%init(this%stats_work, 'uv')
189  call this%uw%init(this%stats_work, 'uw')
190  call this%vw%init(this%stats_work, 'vw')
191  call this%uuu%init(this%stats_work, 'uuu')
192  call this%vvv%init(this%stats_work, 'vvv')
193  call this%www%init(this%stats_work, 'www')
194  call this%uuv%init(this%stats_work, 'uuv')
195  call this%uuw%init(this%stats_work, 'uuw')
196  call this%uvv%init(this%stats_work, 'uvv')
197  call this%uvw%init(this%stats_work, 'uvw')
198  call this%vvw%init(this%stats_work, 'vvw')
199  call this%uww%init(this%stats_work, 'uww')
200  call this%vww%init(this%stats_work, 'vww')
201  call this%uuuu%init(this%stats_work, 'uuuu')
202  call this%vvvv%init(this%stats_work, 'vvvv')
203  call this%wwww%init(this%stats_work, 'wwww')
205  call this%pp%init(this%stats_p, 'pp')
206  call this%ppp%init(this%stats_work, 'ppp')
207  call this%pppp%init(this%stats_work, 'pppp')
209  call this%pu%init(this%stats_work, 'pu')
210  call this%pv%init(this%stats_work, 'pv')
211  call this%pw%init(this%stats_work, 'pw')
212 
213  call this%pdudx%init(this%stats_work, 'pdudx')
214  call this%pdudy%init(this%stats_work, 'pdudy')
215  call this%pdudz%init(this%stats_work, 'pdudz')
216  call this%pdvdx%init(this%stats_work, 'pdvdx')
217  call this%pdvdy%init(this%stats_work, 'pdvdy')
218  call this%pdvdz%init(this%stats_work, 'pdvdz')
219  call this%pdwdx%init(this%stats_work, 'pdwdx')
220  call this%pdwdy%init(this%stats_work, 'pdwdy')
221  call this%pdwdz%init(this%stats_work, 'pdwdz')
222 
223  call this%e11%init(this%stats_work, 'e11')
224  call this%e22%init(this%stats_work, 'e22')
225  call this%e33%init(this%stats_work, 'e33')
226  call this%e12%init(this%stats_work, 'e12')
227  call this%e13%init(this%stats_work, 'e13')
228  call this%e23%init(this%stats_work, 'e23')
229 
230  allocate(this%stat_fields%fields(this%n_stats))
231 
232  this%stat_fields%fields(1)%f => this%pp%mf
233  this%stat_fields%fields(2)%f => this%uu%mf
234  this%stat_fields%fields(3)%f => this%vv%mf
235  this%stat_fields%fields(4)%f => this%ww%mf
236  this%stat_fields%fields(5)%f => this%uv%mf
237  this%stat_fields%fields(6)%f => this%uw%mf
238  this%stat_fields%fields(7)%f => this%vw%mf
239  this%stat_fields%fields(8)%f => this%uuu%mf
240  this%stat_fields%fields(9)%f => this%vvv%mf
241  this%stat_fields%fields(10)%f => this%www%mf
242  this%stat_fields%fields(11)%f => this%uuv%mf
243  this%stat_fields%fields(12)%f => this%uuw%mf
244  this%stat_fields%fields(13)%f => this%uvv%mf
245  this%stat_fields%fields(14)%f => this%uvw%mf
246  this%stat_fields%fields(15)%f => this%vvw%mf
247  this%stat_fields%fields(16)%f => this%uww%mf
248  this%stat_fields%fields(17)%f => this%vww%mf
249  this%stat_fields%fields(18)%f => this%uuuu%mf
250  this%stat_fields%fields(19)%f => this%vvvv%mf
251  this%stat_fields%fields(20)%f => this%wwww%mf
252  this%stat_fields%fields(21)%f => this%ppp%mf
253  this%stat_fields%fields(22)%f => this%pppp%mf
254  this%stat_fields%fields(23)%f => this%pu%mf
255  this%stat_fields%fields(24)%f => this%pv%mf
256  this%stat_fields%fields(25)%f => this%pw%mf
257 
258  this%stat_fields%fields(26)%f => this%pdudx%mf
259  this%stat_fields%fields(27)%f => this%pdudy%mf
260  this%stat_fields%fields(28)%f => this%pdudz%mf
261  this%stat_fields%fields(29)%f => this%pdvdx%mf
262  this%stat_fields%fields(30)%f => this%pdvdy%mf
263  this%stat_fields%fields(31)%f => this%pdvdz%mf
264  this%stat_fields%fields(32)%f => this%pdwdx%mf
265  this%stat_fields%fields(33)%f => this%pdwdy%mf
266  this%stat_fields%fields(34)%f => this%pdwdz%mf
267  this%stat_fields%fields(35)%f => this%e11%mf
268  this%stat_fields%fields(36)%f => this%e22%mf
269  this%stat_fields%fields(37)%f => this%e33%mf
270  this%stat_fields%fields(38)%f => this%e12%mf
271  this%stat_fields%fields(39)%f => this%e13%mf
272  this%stat_fields%fields(40)%f => this%e23%mf
273 
274 
275  end subroutine fluid_stats_init
276 
278  subroutine fluid_stats_update(this, k)
279  class(fluid_stats_t), intent(inout) :: this
280  real(kind=rp), intent(in) :: k
281  integer :: n
282 
283 
284 
285  associate(stats_work => this%stats_work, stats_u => this%stats_u,&
286  stats_v => this%stats_v, stats_w => this%stats_w, stats_p => this%stats_p)
287  n = stats_work%dof%size()
288 
290  if (neko_bcknd_device .eq. 1) then
291 
292  call device_col3(stats_u%x_d,this%u%x_d, this%u%x_d,n)
293  call device_col3(stats_v%x_d,this%v%x_d, this%v%x_d,n)
294  call device_col3(stats_w%x_d,this%w%x_d, this%w%x_d,n)
295  call device_col3(stats_p%x_d,this%p%x_d, this%p%x_d,n)
296 
297  call this%uu%update(k)
298  call this%vv%update(k)
299  call this%ww%update(k)
300  call this%pp%update(k)
301 
302  call device_col3(stats_work%x_d,this%u%x_d, this%v%x_d,n)
303  call this%uv%update(k)
304  call device_col3(stats_work%x_d,this%u%x_d, this%w%x_d,n)
305  call this%uw%update(k)
306  call device_col3(stats_work%x_d,this%v%x_d, this%w%x_d,n)
307  call this%vw%update(k)
308 
309  call device_col2(stats_work%x_d, this%u%x_d,n)
310  call this%uvw%update(k)
311  call device_col3(stats_work%x_d,this%stats_u%x_d, this%u%x_d,n)
312  call this%uuu%update(k)
313  call device_col3(stats_work%x_d,this%stats_v%x_d, this%v%x_d,n)
314  call this%vvv%update(k)
315  call device_col3(stats_work%x_d,this%stats_w%x_d, this%w%x_d,n)
316  call this%www%update(k)
317  call device_col3(stats_work%x_d,this%stats_u%x_d, this%v%x_d,n)
318  call this%uuv%update(k)
319  call device_col3(stats_work%x_d,this%stats_u%x_d, this%w%x_d,n)
320  call this%uuw%update(k)
321  call device_col3(stats_work%x_d,this%stats_v%x_d, this%u%x_d,n)
322  call this%uvv%update(k)
323  call device_col3(stats_work%x_d,this%stats_v%x_d, this%w%x_d,n)
324  call this%vvw%update(k)
325  call device_col3(stats_work%x_d,this%stats_w%x_d, this%u%x_d,n)
326  call this%uww%update(k)
327  call device_col3(stats_work%x_d,this%stats_w%x_d, this%v%x_d,n)
328  call this%vww%update(k)
329 
330  call device_col3(stats_work%x_d,this%stats_u%x_d, this%stats_u%x_d,n)
331  call this%uuuu%update(k)
332  call device_col3(stats_work%x_d,this%stats_v%x_d, this%stats_v%x_d,n)
333  call this%vvvv%update(k)
334  call device_col3(stats_work%x_d,this%stats_w%x_d, this%stats_w%x_d,n)
335  call this%wwww%update(k)
336 
337  call device_col3(stats_work%x_d,this%stats_p%x_d, this%p%x_d,n)
338  call this%ppp%update(k)
339  call device_col3(stats_work%x_d,this%stats_p%x_d, this%stats_p%x_d,n)
340  call this%pppp%update(k)
341 
342  call device_col3(stats_work%x_d,this%p%x_d, this%u%x_d,n)
343  call this%pu%update(k)
344  call device_col3(stats_work%x_d,this%p%x_d, this%v%x_d,n)
345  call this%pv%update(k)
346  call device_col3(stats_work%x_d,this%p%x_d, this%w%x_d,n)
347  call this%pw%update(k)
348 
349  else
350 
351  call col3(stats_u%x,this%u%x, this%u%x,n)
352  call col3(stats_v%x,this%v%x, this%v%x,n)
353  call col3(stats_w%x,this%w%x, this%w%x,n)
354  call col3(stats_p%x,this%p%x, this%p%x,n)
355 
356  call this%uu%update(k)
357  call this%vv%update(k)
358  call this%ww%update(k)
359  call this%pp%update(k)
360 
361  call col3(stats_work%x,this%u%x, this%v%x,n)
362  call this%uv%update(k)
363  call col3(stats_work%x,this%u%x, this%w%x,n)
364  call this%uw%update(k)
365  call col3(stats_work%x,this%v%x, this%w%x,n)
366  call this%vw%update(k)
367 
368  call col2(stats_work%x, this%u%x,n)
369  call this%uvw%update(k)
370  call col3(stats_work%x,this%stats_u%x, this%u%x,n)
371  call this%uuu%update(k)
372  call col3(stats_work%x,this%stats_v%x, this%v%x,n)
373  call this%vvv%update(k)
374  call col3(stats_work%x,this%stats_w%x, this%w%x,n)
375  call this%www%update(k)
376  call col3(stats_work%x,this%stats_u%x, this%v%x,n)
377  call this%uuv%update(k)
378  call col3(stats_work%x,this%stats_u%x, this%w%x,n)
379  call this%uuw%update(k)
380  call col3(stats_work%x,this%stats_v%x, this%u%x,n)
381  call this%uvv%update(k)
382  call col3(stats_work%x,this%stats_v%x, this%w%x,n)
383  call this%vvw%update(k)
384  call col3(stats_work%x,this%stats_w%x, this%u%x,n)
385  call this%uww%update(k)
386  call col3(stats_work%x,this%stats_w%x, this%v%x,n)
387  call this%vww%update(k)
388 
389  call col3(stats_work%x,this%stats_u%x, this%stats_u%x,n)
390  call this%uuuu%update(k)
391  call col3(stats_work%x,this%stats_v%x, this%stats_v%x,n)
392  call this%vvvv%update(k)
393  call col3(stats_work%x,this%stats_w%x, this%stats_w%x,n)
394  call this%wwww%update(k)
395 
396  call col3(stats_work%x,this%stats_p%x, this%p%x,n)
397  call this%ppp%update(k)
398  call col3(stats_work%x,this%stats_p%x, this%stats_p%x,n)
399  call this%pppp%update(k)
400 
401  call col3(stats_work%x,this%p%x, this%u%x,n)
402  call this%pu%update(k)
403  call col3(stats_work%x,this%p%x, this%v%x,n)
404  call this%pv%update(k)
405  call col3(stats_work%x,this%p%x, this%w%x,n)
406  call this%pw%update(k)
407 
408 
409  end if
410  call opgrad(this%dudx%x,this%dudy%x, this%dudz%x,this%u%x,this%coef)
411  call opgrad(this%dvdx%x,this%dvdy%x, this%dvdz%x,this%v%x,this%coef)
412  call opgrad(this%dwdx%x,this%dwdy%x, this%dwdz%x,this%w%x,this%coef)
413 
414  if (neko_bcknd_device .eq. 1) then
415  call device_col3(stats_work%x_d,this%dudx%x_d, this%p%x_d,n)
416  call this%pdudx%update(k)
417  call device_col3(stats_work%x_d,this%dudy%x_d, this%p%x_d,n)
418  call this%pdudy%update(k)
419  call device_col3(stats_work%x_d,this%dudz%x_d, this%p%x_d,n)
420  call this%pdudz%update(k)
421 
422  call device_col3(stats_work%x_d,this%dvdx%x_d, this%p%x_d,n)
423  call this%pdvdx%update(k)
424  call device_col3(stats_work%x_d,this%dvdy%x_d, this%p%x_d,n)
425  call this%pdvdy%update(k)
426  call device_col3(stats_work%x_d,this%dvdz%x_d, this%p%x_d,n)
427  call this%pdvdz%update(k)
428 
429  call device_col3(stats_work%x_d,this%dwdx%x_d, this%p%x_d,n)
430  call this%pdwdx%update(k)
431  call device_col3(stats_work%x_d,this%dwdy%x_d, this%p%x_d,n)
432  call this%pdwdy%update(k)
433  call device_col3(stats_work%x_d,this%dwdz%x_d, this%p%x_d,n)
434  call this%pdwdz%update(k)
435 
436  call device_col3(this%stats_work%x_d,this%dudx%x_d, this%dudx%x_d,n)
437  call device_addcol3(this%stats_work%x_d,this%dudy%x_d, this%dudy%x_d,n)
438  call device_addcol3(this%stats_work%x_d,this%dudz%x_d, this%dudz%x_d,n)
439  call this%e11%update(k)
440  call device_col3(this%stats_work%x_d,this%dvdx%x_d, this%dvdx%x_d,n)
441  call device_addcol3(this%stats_work%x_d,this%dvdy%x_d, this%dvdy%x_d,n)
442  call device_addcol3(this%stats_work%x_d,this%dvdz%x_d, this%dvdz%x_d,n)
443  call this%e22%update(k)
444  call device_col3(this%stats_work%x_d,this%dwdx%x_d, this%dwdx%x_d,n)
445  call device_addcol3(this%stats_work%x_d,this%dwdy%x_d, this%dwdy%x_d,n)
446  call device_addcol3(this%stats_work%x_d,this%dwdz%x_d, this%dwdz%x_d,n)
447  call this%e33%update(k)
448  call device_col3(this%stats_work%x_d,this%dudx%x_d, this%dvdx%x_d,n)
449  call device_addcol3(this%stats_work%x_d,this%dudy%x_d, this%dvdy%x_d,n)
450  call device_addcol3(this%stats_work%x_d,this%dudz%x_d, this%dvdz%x_d,n)
451  call this%e12%update(k)
452  call device_col3(this%stats_work%x_d,this%dvdx%x_d, this%dwdx%x_d,n)
453  call device_addcol3(this%stats_work%x_d,this%dvdy%x_d, this%dwdy%x_d,n)
454  call device_addcol3(this%stats_work%x_d,this%dvdz%x_d, this%dwdz%x_d,n)
455  call this%e23%update(k)
456 
457 
458  else
459  call col3(stats_work%x,this%dudx%x, this%p%x,n)
460  call this%pdudx%update(k)
461  call col3(stats_work%x,this%dudy%x, this%p%x,n)
462  call this%pdudy%update(k)
463  call col3(stats_work%x,this%dudz%x, this%p%x,n)
464  call this%pdudz%update(k)
465 
466  call col3(stats_work%x,this%dvdx%x, this%p%x,n)
467  call this%pdvdx%update(k)
468  call col3(stats_work%x,this%dvdy%x, this%p%x,n)
469  call this%pdvdy%update(k)
470  call col3(stats_work%x,this%dvdz%x, this%p%x,n)
471  call this%pdvdz%update(k)
472 
473  call col3(stats_work%x,this%dwdx%x, this%p%x,n)
474  call this%pdwdx%update(k)
475  call col3(stats_work%x,this%dwdy%x, this%p%x,n)
476  call this%pdwdy%update(k)
477  call col3(stats_work%x,this%dwdz%x, this%p%x,n)
478  call this%pdwdz%update(k)
479 
480  call col3(this%stats_work%x,this%dudx%x, this%dudx%x,n)
481  call addcol3(this%stats_work%x,this%dudy%x, this%dudy%x,n)
482  call addcol3(this%stats_work%x,this%dudz%x, this%dudz%x,n)
483  call this%e11%update(k)
484  call col3(this%stats_work%x,this%dvdx%x, this%dvdx%x,n)
485  call addcol3(this%stats_work%x,this%dvdy%x, this%dvdy%x,n)
486  call addcol3(this%stats_work%x,this%dvdz%x, this%dvdz%x,n)
487  call this%e22%update(k)
488  call col3(this%stats_work%x,this%dwdx%x, this%dwdx%x,n)
489  call addcol3(this%stats_work%x,this%dwdy%x, this%dwdy%x,n)
490  call addcol3(this%stats_work%x,this%dwdz%x, this%dwdz%x,n)
491  call this%e33%update(k)
492  call col3(this%stats_work%x,this%dudx%x, this%dvdx%x,n)
493  call addcol3(this%stats_work%x,this%dudy%x, this%dvdy%x,n)
494  call addcol3(this%stats_work%x,this%dudz%x, this%dvdz%x,n)
495  call this%e12%update(k)
496  call col3(this%stats_work%x,this%dvdx%x, this%dwdx%x,n)
497  call addcol3(this%stats_work%x,this%dvdy%x, this%dwdy%x,n)
498  call addcol3(this%stats_work%x,this%dvdz%x, this%dwdz%x,n)
499  call this%e23%update(k)
500 
501  end if
502 
503  end associate
504 
505  end subroutine fluid_stats_update
506 
507 
509  subroutine fluid_stats_free(this)
510  class(fluid_stats_t), intent(inout) :: this
511 
512  call this%stats_work%free()
513  call this%stats_u%free()
514  call this%stats_v%free()
515  call this%stats_w%free()
516 
517  call this%uu%free()
518  call this%vv%free()
519  call this%ww%free()
520  call this%uv%free()
521  call this%uw%free()
522  call this%vw%free()
523  call this%pp%free()
524 
525  call this%dUdx%free()
526  call this%dUdy%free()
527  call this%dUdz%free()
528  call this%dVdx%free()
529  call this%dVdy%free()
530  call this%dVdz%free()
531  call this%dWdx%free()
532  call this%dWdy%free()
533  call this%dWdz%free()
534 
535  end subroutine fluid_stats_free
536 
538  subroutine fluid_stats_reset(this)
539  class(fluid_stats_t), intent(inout), target:: this
540 
541  call this%uu%reset()
542  call this%vv%reset()
543  call this%ww%reset()
544  call this%uv%reset()
545  call this%uw%reset()
546  call this%vw%reset()
547  call this%uuu%reset()
548  call this%vvv%reset()
549  call this%www%reset()
550  call this%uuv%reset()
551  call this%uuw%reset()
552  call this%uvv%reset()
553  call this%uvw%reset()
554  call this%vvw%reset()
555  call this%uww%reset()
556  call this%vww%reset()
557  call this%uuuu%reset()
558  call this%vvvv%reset()
559  call this%wwww%reset()
561  call this%pp%reset()
562  call this%ppp%reset()
563  call this%pppp%reset()
565  call this%pu%reset()
566  call this%pv%reset()
567  call this%pw%reset()
568 
569  call this%pdudx%reset()
570  call this%pdudy%reset()
571  call this%pdudz%reset()
572  call this%pdvdx%reset()
573  call this%pdvdy%reset()
574  call this%pdvdz%reset()
575  call this%pdwdx%reset()
576  call this%pdwdy%reset()
577  call this%pdwdz%reset()
578 
579  call this%e11%reset()
580  call this%e22%reset()
581  call this%e33%reset()
582  call this%e12%reset()
583  call this%e13%reset()
584  call this%e23%reset()
585 
586  end subroutine fluid_stats_reset
587 
589  class(fluid_stats_t) :: this
590  integer :: n
591  n = size(this%coef%B)
592  if (neko_bcknd_device .eq. 1) then
593  call device_cfill(this%stats_work%x_d, 1.0_rp,n)
594  call device_invcol2(this%stats_work%x_d, this%coef%B_d,n)
595  call device_col2(this%pdudx%mf%x_d, this%stats_work%x_d, n)
596  call device_col2(this%pdudy%mf%x_d, this%stats_work%x_d, n)
597  call device_col2(this%pdudz%mf%x_d, this%stats_work%x_d, n)
598  call device_col2(this%pdvdx%mf%x_d, this%stats_work%x_d, n)
599  call device_col2(this%pdvdy%mf%x_d, this%stats_work%x_d, n)
600  call device_col2(this%pdvdz%mf%x_d, this%stats_work%x_d, n)
601  call device_col2(this%pdwdx%mf%x_d, this%stats_work%x_d, n)
602  call device_col2(this%pdwdy%mf%x_d, this%stats_work%x_d, n)
603  call device_col2(this%pdwdz%mf%x_d, this%stats_work%x_d, n)
604 
605  call device_col2(this%stats_work%x_d, this%stats_work%x_d,n)
606  call device_col2(this%e11%mf%x_d,this%stats_work%x_d, n)
607  call device_col2(this%e22%mf%x_d,this%stats_work%x_d, n)
608  call device_col2(this%e33%mf%x_d,this%stats_work%x_d, n)
609  call device_col2(this%e12%mf%x_d,this%stats_work%x_d, n)
610  call device_col2(this%e13%mf%x_d,this%stats_work%x_d, n)
611  call device_col2(this%e23%mf%x_d,this%stats_work%x_d, n)
612 
613 
614  else
615  call invers2(this%stats_work%x, this%coef%B,n)
616  call col2(this%pdudx%mf%x, this%stats_work%x, n)
617  call col2(this%pdudy%mf%x, this%stats_work%x, n)
618  call col2(this%pdudz%mf%x, this%stats_work%x, n)
619  call col2(this%pdvdx%mf%x, this%stats_work%x, n)
620  call col2(this%pdvdy%mf%x, this%stats_work%x, n)
621  call col2(this%pdvdz%mf%x, this%stats_work%x, n)
622  call col2(this%pdwdx%mf%x, this%stats_work%x, n)
623  call col2(this%pdwdy%mf%x, this%stats_work%x, n)
624  call col2(this%pdwdz%mf%x, this%stats_work%x, n)
625 
626  call col2(this%stats_work%x, this%stats_work%x,n)
627  call col2(this%e11%mf%x,this%stats_work%x, n)
628  call col2(this%e22%mf%x,this%stats_work%x, n)
629  call col2(this%e33%mf%x,this%stats_work%x, n)
630  call col2(this%e12%mf%x,this%stats_work%x, n)
631  call col2(this%e13%mf%x,this%stats_work%x, n)
632  call col2(this%e23%mf%x,this%stats_work%x, n)
633 
634  end if
635 
636  end subroutine fluid_stats_make_strong_grad
637 
638  subroutine fluid_stats_post_process(this, mean, reynolds, pressure_flatness,&
639  pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
640  class(fluid_stats_t) :: this
641  type(field_list_t), intent(inout), optional :: mean
642  type(field_list_t), intent(inout), optional :: reynolds
643  type(field_list_t), intent(inout), optional :: pressure_skewness
644  type(field_list_t), intent(inout), optional :: pressure_flatness
645  type(field_list_t), intent(inout), optional :: skewness_tensor
646  type(field_list_t), intent(inout), optional :: mean_vel_grad
647  type(field_list_t), intent(inout), optional :: dissipation_tensor
648  integer :: n
649 
650  if (present(mean)) then
651  n = mean%fields(1)%f%dof%size()
652  call copy(mean%fields(1)%f%x,this%u_mean%x,n)
653  call copy(mean%fields(2)%f%x,this%v_mean%x,n)
654  call copy(mean%fields(3)%f%x,this%w_mean%x,n)
655  call copy(mean%fields(4)%f%x,this%p_mean%x,n)
656  end if
657 
658  if (present(reynolds)) then
659  n = reynolds%fields(1)%f%dof%size()
660  call copy(reynolds%fields(1)%f%x,this%pp%mf%x,n)
661  call subcol3(reynolds%fields(1)%f%x,this%p_mean%x,this%p_mean%x,n)
662 
663  call copy(reynolds%fields(2)%f%x,this%uu%mf%x,n)
664  call subcol3(reynolds%fields(2)%f%x,this%u_mean%x,this%u_mean%x,n)
665 
666  call copy(reynolds%fields(3)%f%x,this%vv%mf%x,n)
667  call subcol3(reynolds%fields(3)%f%x,this%v_mean%x,this%v_mean%x,n)
668 
669  call copy(reynolds%fields(4)%f%x,this%ww%mf%x,n)
670  call subcol3(reynolds%fields(4)%f%x,this%w_mean%x,this%w_mean%x,n)
671 
672  call copy(reynolds%fields(5)%f%x,this%uv%mf%x,n)
673  call subcol3(reynolds%fields(5)%f%x,this%u_mean%x,this%v_mean%x,n)
674 
675  call copy(reynolds%fields(6)%f%x,this%uw%mf%x,n)
676  call subcol3(reynolds%fields(6)%f%x,this%u_mean%x,this%w_mean%x,n)
677 
678  call copy(reynolds%fields(7)%f%x,this%vw%mf%x,n)
679  call subcol3(reynolds%fields(7)%f%x,this%v_mean%x,this%w_mean%x,n)
680  end if
681  if (present(pressure_skewness)) then
682 
683  call neko_warning('Presssure skewness stat not implemented in fluid_stats yet, please help!')
684 
685  end if
686 
687  if (present(pressure_flatness)) then
688  call neko_warning('Presssure flatness stat not implemented yet, please help!')
689 
690  end if
691 
692  if (present(skewness_tensor)) then
693  call neko_warning('Skewness tensor stat not implemented yet, please help!')
694  end if
695 
696  if (present(mean_vel_grad)) then
697  !Compute gradient of mean flow
698  n = mean_vel_grad%fields(1)%f%dof%size()
699  if (neko_bcknd_device .eq. 1) then
700  call device_memcpy(this%u_mean%x, this%u_mean%x_d, n, &
701  host_to_device, sync=.false.)
702  call device_memcpy(this%v_mean%x, this%v_mean%x_d, n, &
703  host_to_device, sync=.false.)
704  call device_memcpy(this%w_mean%x, this%w_mean%x_d, n, &
705  host_to_device, sync=.false.)
706  call opgrad(this%dudx%x, this%dudy%x, this%dudz%x, &
707  this%u_mean%x, this%coef)
708  call opgrad(this%dvdx%x, this%dvdy%x, this%dvdz%x, &
709  this%v_mean%x, this%coef)
710  call opgrad(this%dwdx%x, this%dwdy%x, this%dwdz%x, &
711  this%w_mean%x, this%coef)
712  call device_memcpy(this%dudx%x, this%dudx%x_d, n, &
713  device_to_host, sync=.false.)
714  call device_memcpy(this%dvdx%x, this%dvdx%x_d, n, &
715  device_to_host, sync=.false.)
716  call device_memcpy(this%dwdx%x, this%dwdx%x_d, n, &
717  device_to_host, sync=.false.)
718  call device_memcpy(this%dudy%x, this%dudy%x_d, n, &
719  device_to_host, sync=.false.)
720  call device_memcpy(this%dvdy%x, this%dvdy%x_d, n, &
721  device_to_host, sync=.false.)
722  call device_memcpy(this%dwdy%x, this%dwdy%x_d, n, &
723  device_to_host, sync=.false.)
724  call device_memcpy(this%dudz%x, this%dudz%x_d, n, &
725  device_to_host, sync=.false.)
726  call device_memcpy(this%dvdz%x, this%dvdz%x_d, n, &
727  device_to_host, sync=.false.)
728  call device_memcpy(this%dwdz%x, this%dwdz%x_d, n, &
729  device_to_host, sync=.true.)
730  else
731  call opgrad(this%dudx%x,this%dudy%x, this%dudz%x,this%u_mean%x,this%coef)
732  call opgrad(this%dvdx%x,this%dvdy%x, this%dvdz%x,this%v_mean%x,this%coef)
733  call opgrad(this%dwdx%x,this%dwdy%x, this%dwdz%x,this%w_mean%x,this%coef)
734  end if
735  call invers2(this%stats_work%x, this%coef%B,n)
736  call col3(mean_vel_grad%fields(1)%f%x, this%dudx%x,this%stats_work%x, n)
737  call col3(mean_vel_grad%fields(2)%f%x, this%dudy%x,this%stats_work%x, n)
738  call col3(mean_vel_grad%fields(3)%f%x, this%dudz%x,this%stats_work%x, n)
739  call col3(mean_vel_grad%fields(4)%f%x, this%dvdx%x,this%stats_work%x, n)
740  call col3(mean_vel_grad%fields(5)%f%x, this%dvdy%x,this%stats_work%x, n)
741  call col3(mean_vel_grad%fields(6)%f%x, this%dvdz%x,this%stats_work%x, n)
742  call col3(mean_vel_grad%fields(7)%f%x, this%dwdx%x,this%stats_work%x, n)
743  call col3(mean_vel_grad%fields(8)%f%x, this%dwdy%x,this%stats_work%x, n)
744  call col3(mean_vel_grad%fields(9)%f%x, this%dwdz%x,this%stats_work%x, n)
745 
746  end if
747 
748  if (present(dissipation_tensor)) then
749 
750  end if
751 
752  end subroutine fluid_stats_post_process
753 
754 end module fluid_stats
Coefficients.
Definition: coef.f90:34
subroutine, public device_addcol3(a_d, b_d, c_d, n)
subroutine, public device_col2(a_d, b_d, n)
subroutine, public device_col3(a_d, b_d, c_d, n)
Device abstraction, common interface for various accelerators.
Definition: device.F90:34
Defines a registry for storing solution fields.
Defines a field.
Definition: field.f90:34
Computes various statistics for the fluid fields. We use the Reynolds decomposition for a field u = ...
Definition: fluid_stats.f90:36
subroutine fluid_stats_init(this, coef, u_mf, v_mf, w_mf, p_mf)
Initialize the fields associated with fluid_stats.
subroutine fluid_stats_reset(this)
Initialize a mean flow field.
subroutine fluid_stats_make_strong_grad(this)
subroutine fluid_stats_update(this, k)
Updates all fields.
subroutine fluid_stats_free(this)
Deallocates a mean flow field.
subroutine fluid_stats_post_process(this, mean, reynolds, pressure_flatness, pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
Gather-scatter.
Definition: math.f90:60
subroutine, public addcol3(a, b, c, n)
Returns .
Definition: math.f90:717
subroutine, public col2(a, b, n)
Vector multiplication .
Definition: math.f90:645
subroutine, public col3(a, b, c, n)
Vector multiplication with 3 vectors .
Definition: math.f90:658
Collection of vector field operations operating on and . Note that in general the indices and ....
Definition: mathops.f90:65
Defines a mean field.
Definition: mean_field.f90:35
Build configurations.
Definition: neko_config.f90:34
integer, parameter neko_bcknd_device
Definition: neko_config.f90:44
Operators.
Definition: operators.f90:34
subroutine, public opgrad(ux, uy, uz, u, coef, es, ee)
Compute the gradient of a scalar field.
Definition: operators.f90:100
Defines a statistical quantity.
Definition: stats_quant.f90:34
Utilities.
Definition: utils.f90:35
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition: coef.f90:54
field_list_t, To be able to group fields together
Definition: field_list.f90:7
Abstract type defining a statistical quantity.
Definition: stats_quant.f90:40