152 type(
coef_t),
target,
optional :: coef
153 type(
field_t),
target,
intent(in) :: u, v, w, p
154 character(*),
intent(in),
optional :: set
155 character(*),
intent(in),
optional :: name
157 character(len=1024) :: unique_name
168 if (
present(set))
then
169 this%stat_set = trim(set)
170 if (this%stat_set .eq.
'basic')
then
174 this%stat_set =
'full'
178 if (
present(name))
then
179 unique_name = name //
"/"
181 unique_name =
"fluid_stats/"
184 call this%u_mean%init(this%u, trim(unique_name) //
'mean_u')
185 call this%v_mean%init(this%v, trim(unique_name) //
'mean_v')
186 call this%w_mean%init(this%w, trim(unique_name) //
'mean_w')
187 call this%p_mean%init(this%p, trim(unique_name) //
'mean_p')
191 call this%uu%init(this%u, trim(unique_name) //
'mean_uu')
192 call this%vv%init(this%u, trim(unique_name) //
'mean_vv')
193 call this%ww%init(this%u, trim(unique_name) //
'mean_ww')
194 call this%uv%init(this%u, trim(unique_name) //
'mean_uv')
195 call this%uw%init(this%u, trim(unique_name) //
'mean_uw')
196 call this%vw%init(this%u, trim(unique_name) //
'mean_vw')
197 call this%pp%init(this%u, trim(unique_name) //
'mean_pp')
199 if (this%n_stats .eq. 44)
then
200 call this%uuu%init(this%u, trim(unique_name) //
'mean_uuu')
201 call this%vvv%init(this%u, trim(unique_name) //
'mean_vvv')
202 call this%www%init(this%u, trim(unique_name) //
'mean_www')
203 call this%uuv%init(this%u, trim(unique_name) //
'mean_uuv')
204 call this%uuw%init(this%u, trim(unique_name) //
'mean_uuw')
205 call this%uvv%init(this%u, trim(unique_name) //
'mean_uvv')
206 call this%uvw%init(this%u, trim(unique_name) //
'mean_uvw')
207 call this%vvw%init(this%u, trim(unique_name) //
'mean_vvw')
208 call this%uww%init(this%u, trim(unique_name) //
'mean_uww')
209 call this%vww%init(this%u, trim(unique_name) //
'mean_vww')
210 call this%uuuu%init(this%u, trim(unique_name) //
'mean_uuuu')
211 call this%vvvv%init(this%u, trim(unique_name) //
'mean_vvvv')
212 call this%wwww%init(this%u, trim(unique_name) //
'mean_wwww')
214 call this%ppp%init(this%u, trim(unique_name) //
'mean_ppp')
215 call this%pppp%init(this%u, trim(unique_name) //
'mean_pppp')
217 call this%pu%init(this%u, trim(unique_name) //
'mean_pu')
218 call this%pv%init(this%u, trim(unique_name) //
'mean_pv')
219 call this%pw%init(this%u, trim(unique_name) //
'mean_pw')
221 call this%pdudx%init(this%u, trim(unique_name) //
'mean_pdudx')
222 call this%pdudy%init(this%u, trim(unique_name) //
'mean_pdudy')
223 call this%pdudz%init(this%u, trim(unique_name) //
'mean_pdudz')
224 call this%pdvdx%init(this%u, trim(unique_name) //
'mean_pdvdx')
225 call this%pdvdy%init(this%u, trim(unique_name) //
'mean_pdvdy')
226 call this%pdvdz%init(this%u, trim(unique_name) //
'mean_pdvdz')
227 call this%pdwdx%init(this%u, trim(unique_name) //
'mean_pdwdx')
228 call this%pdwdy%init(this%u, trim(unique_name) //
'mean_pdwdy')
229 call this%pdwdz%init(this%u, trim(unique_name) //
'mean_pdwdz')
231 call this%e11%init(this%u, trim(unique_name) //
'mean_e11')
232 call this%e22%init(this%u, trim(unique_name) //
'mean_e22')
233 call this%e33%init(this%u, trim(unique_name) //
'mean_e33')
234 call this%e12%init(this%u, trim(unique_name) //
'mean_e12')
235 call this%e13%init(this%u, trim(unique_name) //
'mean_e13')
236 call this%e23%init(this%u, trim(unique_name) //
'mean_e23')
239 call this%stat_fields%init(this%n_stats)
241 call this%stat_fields%assign_to_field(1, this%p_mean%mf)
242 call this%stat_fields%assign_to_field(2, this%u_mean%mf)
243 call this%stat_fields%assign_to_field(3, this%v_mean%mf)
244 call this%stat_fields%assign_to_field(4, this%w_mean%mf)
245 call this%stat_fields%assign_to_field(5, this%pp%mf)
246 call this%stat_fields%assign_to_field(6, this%uu%mf)
247 call this%stat_fields%assign_to_field(7, this%vv%mf)
248 call this%stat_fields%assign_to_field(8, this%ww%mf)
249 call this%stat_fields%assign_to_field(9, this%uv%mf)
250 call this%stat_fields%assign_to_field(10, this%uw%mf)
251 call this%stat_fields%assign_to_field(11, this%vw%mf)
253 if (this%n_stats .eq. 44)
then
254 call this%stat_fields%assign_to_field(12, this%uuu%mf)
255 call this%stat_fields%assign_to_field(13, this%vvv%mf)
256 call this%stat_fields%assign_to_field(14, this%www%mf)
257 call this%stat_fields%assign_to_field(15, this%uuv%mf)
258 call this%stat_fields%assign_to_field(16, this%uuw%mf)
259 call this%stat_fields%assign_to_field(17, this%uvv%mf)
260 call this%stat_fields%assign_to_field(18, this%uvw%mf)
261 call this%stat_fields%assign_to_field(19, this%vvw%mf)
262 call this%stat_fields%assign_to_field(20, this%uww%mf)
263 call this%stat_fields%assign_to_field(21, this%vww%mf)
264 call this%stat_fields%assign_to_field(22, this%uuuu%mf)
265 call this%stat_fields%assign_to_field(23, this%vvvv%mf)
266 call this%stat_fields%assign_to_field(24, this%wwww%mf)
267 call this%stat_fields%assign_to_field(25, this%ppp%mf)
268 call this%stat_fields%assign_to_field(26, this%pppp%mf)
269 call this%stat_fields%assign_to_field(27, this%pu%mf)
270 call this%stat_fields%assign_to_field(28, this%pv%mf)
271 call this%stat_fields%assign_to_field(29, this%pw%mf)
273 call this%stat_fields%assign_to_field(30, this%pdudx%mf)
274 call this%stat_fields%assign_to_field(31, this%pdudy%mf)
275 call this%stat_fields%assign_to_field(32, this%pdudz%mf)
276 call this%stat_fields%assign_to_field(33, this%pdvdx%mf)
277 call this%stat_fields%assign_to_field(34, this%pdvdy%mf)
278 call this%stat_fields%assign_to_field(35, this%pdvdz%mf)
279 call this%stat_fields%assign_to_field(36, this%pdwdx%mf)
280 call this%stat_fields%assign_to_field(37, this%pdwdy%mf)
281 call this%stat_fields%assign_to_field(38, this%pdwdz%mf)
282 call this%stat_fields%assign_to_field(39, this%e11%mf)
283 call this%stat_fields%assign_to_field(40, this%e22%mf)
284 call this%stat_fields%assign_to_field(41, this%e33%mf)
285 call this%stat_fields%assign_to_field(42, this%e12%mf)
286 call this%stat_fields%assign_to_field(43, this%e13%mf)
287 call this%stat_fields%assign_to_field(44, this%e23%mf)
296 real(kind=
rp),
intent(in) :: k
298 type(
field_t),
pointer :: dudx, dudy, dudz
299 type(
field_t),
pointer :: dvdx, dvdy, dvdz
300 type(
field_t),
pointer :: dwdx, dwdy, dwdz
303 associate(u => this%u, v => this%v, w => this%w, p => this%p)
305 call this%u_mean%update(k)
306 call this%v_mean%update(k)
307 call this%w_mean%update(k)
308 call this%p_mean%update(k)
310 call this%uu%update_col3(k, u, u)
311 call this%vv%update_col3(k, v, v)
312 call this%ww%update_col3(k, w, w)
313 call this%pp%update_col3(k, p, p)
315 call this%uv%update_col3(k, u, v)
316 call this%uw%update_col3(k, u, w)
317 call this%vw%update_col3(k, v, w)
319 if (this%n_stats .eq. 11)
return
325 call this%uuu%update_col3(k, work, u)
326 call this%uuv%update_col3(k, work, v)
327 call this%uuw%update_col3(k, work, w)
328 call this%uuuu%update_col3(k, work, work)
331 call this%vvv%update_col3(k, work, v)
332 call this%uvv%update_col3(k, work, u)
333 call this%vvw%update_col3(k, work, w)
334 call this%vvvv%update_col3(k, work, work)
337 call this%www%update_col3(k, work, w)
338 call this%uww%update_col3(k, work, u)
339 call this%vww%update_col3(k, work, v)
340 call this%wwww%update_col3(k, work, work)
343 call this%uvw%update_col3(k, work, u)
346 call this%ppp%update_col3(k, work, p)
347 call this%pppp%update_col3(k, work, work)
351 call this%pu%update_col3(k, p, u)
352 call this%pv%update_col3(k, p, v)
353 call this%pw%update_col3(k, p, w)
374 call opgrad(dudx%x, dudy%x, dudz%x, u%x, this%coef)
375 call opgrad(dvdx%x, dvdy%x, dvdz%x, v%x, this%coef)
376 call opgrad(dwdx%x, dwdy%x, dwdz%x, w%x, this%coef)
378 call this%pdudx%update_col3(k, dudx, p)
379 call this%pdudy%update_col3(k, dudy, p)
380 call this%pdudz%update_col3(k, dudz, p)
381 call this%pdvdx%update_col3(k, dvdx, p)
382 call this%pdvdy%update_col3(k, dvdy, p)
383 call this%pdvdz%update_col3(k, dvdz, p)
384 call this%pdwdx%update_col3(k, dwdx, p)
385 call this%pdwdy%update_col3(k, dwdy, p)
386 call this%pdwdz%update_col3(k, dwdz, p)
388 call this%e11%update_dot3(k, dudx, dudy, dudz, dudx, dudy, dudz)
389 call this%e22%update_dot3(k, dvdx, dvdy, dvdz, dvdx, dvdy, dvdz)
390 call this%e33%update_dot3(k, dwdx, dwdy, dwdz, dwdx, dwdy, dwdz)
391 call this%e12%update_dot3(k, dudx, dudy, dudz, dvdx, dvdy, dvdz)
392 call this%e13%update_dot3(k, dudx, dudy, dudz, dwdx, dwdy, dwdz)
393 call this%e23%update_dot3(k, dvdx, dvdy, dvdz, dwdx, dwdy, dwdz)
527 real(kind=rp) :: wrk, wrk_sqr
528 type(field_t),
pointer :: work
531 if (this%n_stats .eq. 11)
return
533 n =
size(this%coef%B)
535 if (neko_bcknd_device .eq. 1)
then
536 call neko_scratch_registry%request_field(work, idx, &
538 call device_cfill(work%x_d, 1.0_rp, n)
539 call device_invcol2(work%x_d, this%coef%B_d, n)
540 call device_col2(this%pdudx%mf%x_d, work%x_d, n)
541 call device_col2(this%pdudy%mf%x_d, work%x_d, n)
542 call device_col2(this%pdudz%mf%x_d, work%x_d, n)
543 call device_col2(this%pdvdx%mf%x_d, work%x_d, n)
544 call device_col2(this%pdvdy%mf%x_d, work%x_d, n)
545 call device_col2(this%pdvdz%mf%x_d, work%x_d, n)
546 call device_col2(this%pdwdx%mf%x_d, work%x_d, n)
547 call device_col2(this%pdwdy%mf%x_d, work%x_d, n)
548 call device_col2(this%pdwdz%mf%x_d, work%x_d, n)
550 call device_col2(work%x_d, work%x_d, n)
551 call device_col2(this%e11%mf%x_d, work%x_d, n)
552 call device_col2(this%e22%mf%x_d, work%x_d, n)
553 call device_col2(this%e33%mf%x_d, work%x_d, n)
554 call device_col2(this%e12%mf%x_d, work%x_d, n)
555 call device_col2(this%e13%mf%x_d, work%x_d, n)
556 call device_col2(this%e23%mf%x_d, work%x_d, n)
557 call neko_scratch_registry%relinquish_field(idx)
562 wrk = 1.0_rp / this%coef%B(i,1,1,1)
563 this%pdudx%mf%x(i,1,1,1) = this%pdudx%mf%x(i,1,1,1) * wrk
564 this%pdudy%mf%x(i,1,1,1) = this%pdudy%mf%x(i,1,1,1) * wrk
565 this%pdudz%mf%x(i,1,1,1) = this%pdudz%mf%x(i,1,1,1) * wrk
567 this%pdvdx%mf%x(i,1,1,1) = this%pdvdx%mf%x(i,1,1,1) * wrk
568 this%pdvdy%mf%x(i,1,1,1) = this%pdvdy%mf%x(i,1,1,1) * wrk
569 this%pdvdz%mf%x(i,1,1,1) = this%pdvdz%mf%x(i,1,1,1) * wrk
571 this%pdwdx%mf%x(i,1,1,1) = this%pdwdx%mf%x(i,1,1,1) * wrk
572 this%pdwdy%mf%x(i,1,1,1) = this%pdwdy%mf%x(i,1,1,1) * wrk
573 this%pdwdz%mf%x(i,1,1,1) = this%pdwdz%mf%x(i,1,1,1) * wrk
576 this%e11%mf%x(i,1,1,1) = this%e11%mf%x(i,1,1,1) * wrk_sqr
577 this%e22%mf%x(i,1,1,1) = this%e22%mf%x(i,1,1,1) * wrk_sqr
578 this%e33%mf%x(i,1,1,1) = this%e33%mf%x(i,1,1,1) * wrk_sqr
580 this%e12%mf%x(i,1,1,1) = this%e12%mf%x(i,1,1,1) * wrk_sqr
581 this%e13%mf%x(i,1,1,1) = this%e13%mf%x(i,1,1,1) * wrk_sqr
582 this%e23%mf%x(i,1,1,1) = this%e23%mf%x(i,1,1,1) * wrk_sqr
592 pressure_skewness, skewness_tensor, mean_vel_grad, dissipation_tensor)
594 type(field_list_t),
intent(inout),
optional :: mean
595 type(field_list_t),
intent(inout),
optional :: reynolds
596 type(field_list_t),
intent(in),
optional :: pressure_skewness
597 type(field_list_t),
intent(in),
optional :: pressure_flatness
598 type(field_list_t),
intent(in),
optional :: skewness_tensor
599 type(field_list_t),
intent(inout),
optional :: mean_vel_grad
600 type(field_list_t),
intent(in),
optional :: dissipation_tensor
603 type(field_t),
pointer :: dudx, dudy, dudz
604 type(field_t),
pointer :: dvdx, dvdy, dvdz
605 type(field_t),
pointer :: dwdx, dwdy, dwdz
608 if (
present(mean))
then
609 n = mean%item_size(1)
610 call copy(mean%items(1)%ptr%x, this%u_mean%mf%x, n)
611 call copy(mean%items(2)%ptr%x, this%v_mean%mf%x, n)
612 call copy(mean%items(3)%ptr%x, this%w_mean%mf%x, n)
613 call copy(mean%items(4)%ptr%x, this%p_mean%mf%x, n)
616 if (
present(reynolds))
then
617 n = reynolds%item_size(1)
618 call copy(reynolds%items(1)%ptr%x, this%pp%mf%x, n)
619 call subcol3(reynolds%items(1)%ptr%x, this%p_mean%mf%x, &
622 call copy(reynolds%items(2)%ptr%x, this%uu%mf%x, n)
623 call subcol3(reynolds%items(2)%ptr%x, this%u_mean%mf%x, &
626 call copy(reynolds%items(3)%ptr%x, this%vv%mf%x, n)
627 call subcol3(reynolds%items(3)%ptr%x, this%v_mean%mf%x, &
630 call copy(reynolds%items(4)%ptr%x, this%ww%mf%x, n)
631 call subcol3(reynolds%items(4)%ptr%x, this%w_mean%mf%x, &
634 call copy(reynolds%items(5)%ptr%x, this%uv%mf%x, n)
635 call subcol3(reynolds%items(5)%ptr%x, this%u_mean%mf%x, &
638 call copy(reynolds%items(6)%ptr%x, this%uw%mf%x, n)
639 call subcol3(reynolds%items(6)%ptr%x, this%u_mean%mf%x, &
642 call copy(reynolds%items(7)%ptr%x, this%vw%mf%x, n)
643 call subcol3(reynolds%items(7)%ptr%x, this%v_mean%mf%x, &
646 if (
present(pressure_skewness))
then
648 call neko_warning(
'Presssure skewness stat not implemented'// &
649 ' in fluid_stats, process stats in python instead')
653 if (
present(pressure_flatness))
then
654 call neko_warning(
'Presssure flatness stat not implemented'// &
655 ' in fluid_stats, process stats in python instead')
659 if (
present(skewness_tensor))
then
660 call neko_warning(
'Skewness tensor stat not implemented'// &
661 ' in fluid_stats, process stats in python instead')
664 if (
present(mean_vel_grad))
then
666 n = mean_vel_grad%item_size(1)
667 call neko_scratch_registry%request_field(dudx, idx(1), &
669 call neko_scratch_registry%request_field(dudy, idx(2), &
671 call neko_scratch_registry%request_field(dudz, idx(3), &
673 call neko_scratch_registry%request_field(dvdx, idx(4), &
675 call neko_scratch_registry%request_field(dvdy, idx(5), &
677 call neko_scratch_registry%request_field(dvdz, idx(6), &
679 call neko_scratch_registry%request_field(dwdx, idx(7), &
681 call neko_scratch_registry%request_field(dwdy, idx(8), &
683 call neko_scratch_registry%request_field(dwdz, idx(9), &
685 if (neko_bcknd_device .eq. 1)
then
686 call device_memcpy(this%u_mean%mf%x, this%u_mean%mf%x_d, n, &
687 host_to_device, sync = .false.)
688 call device_memcpy(this%v_mean%mf%x, this%v_mean%mf%x_d, n, &
689 host_to_device, sync = .false.)
690 call device_memcpy(this%w_mean%mf%x, this%w_mean%mf%x_d, n, &
691 host_to_device, sync = .false.)
692 call opgrad(dudx%x, dudy%x, dudz%x, &
693 this%u_mean%mf%x, this%coef)
694 call opgrad(dvdx%x, dvdy%x, dvdz%x, &
695 this%v_mean%mf%x, this%coef)
696 call opgrad(dwdx%x, dwdy%x, dwdz%x, &
697 this%w_mean%mf%x, this%coef)
698 call device_memcpy(dudx%x, dudx%x_d, n, &
699 device_to_host, sync = .false.)
700 call device_memcpy(dvdx%x, dvdx%x_d, n, &
701 device_to_host, sync = .false.)
702 call device_memcpy(dwdx%x, dwdx%x_d, n, &
703 device_to_host, sync = .false.)
704 call device_memcpy(dudy%x, dudy%x_d, n, &
705 device_to_host, sync = .false.)
706 call device_memcpy(dvdy%x, dvdy%x_d, n, &
707 device_to_host, sync = .false.)
708 call device_memcpy(dwdy%x, dwdy%x_d, n, &
709 device_to_host, sync = .false.)
710 call device_memcpy(dudz%x, dudz%x_d, n, &
711 device_to_host, sync = .false.)
712 call device_memcpy(dvdz%x, dvdz%x_d, n, &
713 device_to_host, sync = .false.)
714 call device_memcpy(dwdz%x, dwdz%x_d, n, &
715 device_to_host, sync = .true.)
717 call opgrad(dudx%x, dudy%x, dudz%x, &
718 this%u_mean%mf%x, this%coef)
719 call opgrad(dvdx%x, dvdy%x, dvdz%x, &
720 this%v_mean%mf%x, this%coef)
721 call opgrad(dwdx%x, dwdy%x, dwdz%x, &
722 this%w_mean%mf%x, this%coef)
727 wrk = 1.0_rp / this%coef%B(i,1,1,1)
728 mean_vel_grad%items(1)%ptr%x(i,1,1,1) = dudx%x(i,1,1,1) * wrk
729 mean_vel_grad%items(2)%ptr%x(i,1,1,1) = dudy%x(i,1,1,1) * wrk
730 mean_vel_grad%items(3)%ptr%x(i,1,1,1) = dudz%x(i,1,1,1) * wrk
732 mean_vel_grad%items(4)%ptr%x(i,1,1,1) = dvdx%x(i,1,1,1) * wrk
733 mean_vel_grad%items(5)%ptr%x(i,1,1,1) = dvdy%x(i,1,1,1) * wrk
734 mean_vel_grad%items(6)%ptr%x(i,1,1,1) = dvdz%x(i,1,1,1) * wrk
736 mean_vel_grad%items(7)%ptr%x(i,1,1,1) = dwdx%x(i,1,1,1) * wrk
737 mean_vel_grad%items(8)%ptr%x(i,1,1,1) = dwdy%x(i,1,1,1) * wrk
738 mean_vel_grad%items(9)%ptr%x(i,1,1,1) = dwdz%x(i,1,1,1) * wrk
742 call neko_scratch_registry%relinquish_field(idx)
745 if (
present(dissipation_tensor))
then
746 call neko_warning(
'Dissipation tensor stat not implemented'// &
747 ' in fluid_stats, process stats in python instead')