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