7 character(len=NEKO_FNAME_LEN) :: inputchar, mesh_fname, stats_fname
8 type(file_t) :: stats_file, output_file, mesh_file
9 real(kind=rp) :: start_time
10 type(fld_file_data_t) :: stats_data
11 type(fluid_stats_t) :: fld_stats
17 type(field_t),
pointer :: u, v, w, p
18 type(field_t),
target :: pp, uu, vv, ww, uv, uw, vw, tmp1, tmp2
19 type(field_list_t) :: reynolds, mean_vel_grad
20 integer :: argc, i, n, lx
22 argc = command_argument_count()
24 if ((argc .lt. 2) .or. (argc .gt. 2))
then
25 if (pe_rank .eq. 0)
then
26 write(*,*)
'Usage: ./postprocess_fluid_stats mesh.nmsh stats.fld'
27 write(*,*)
'Example command: ./postprocess_fluid_stats mesh.nmsh statsblabla.fld'
28 write(*,*)
'Computes the statstics from the (3D) fld files described in statsblabla.nek5000'
29 write(*,*)
'Recommended to use PyNekTools for more advanced postprocessing.'
30 write(*,*)
'If this does not work, switch to that.'
31 write(*,*)
'Currently we output two new fld files reynolds and mean_vel_grad'
32 write(*,*)
'In Reynolds the fields are ordered as:'
33 write(*,*)
'x-velocity=<u`u`>'
34 write(*,*)
'y-velocity=<v`v`>'
35 write(*,*)
'z-velocity=<w`w`>'
36 write(*,*)
'pressure=<p`p`>'
37 write(*,*)
'temperature=<u`v`>'
38 write(*,*)
's1=<u`w`>'
39 write(*,*)
's2=<v`w`>'
40 write(*,*)
'In mean_vel_grad:'
41 write(*,*)
'x-velocity=dudx'
42 write(*,*)
'y-velocity=dudy'
43 write(*,*)
'z-velocity=dudz'
44 write(*,*)
'pressure=dvdx'
45 write(*,*)
'temperature=dvdy'
56 call get_command_argument(1, inputchar)
57 read(inputchar, *) mesh_fname
58 mesh_file = file_t(trim(mesh_fname))
59 call get_command_argument(2, inputchar)
60 read(inputchar, *) stats_fname
61 stats_file = file_t(trim(stats_fname))
63 call mesh_file%read(msh)
65 call stats_data%init(msh%nelv,msh%offset_el)
66 call stats_file%read(stats_data)
70 msh%elements(i)%e%pts(1)%p%x(1) = stats_data%x%x(linear_index(1,1,1,i,lx,lx,lx))
71 msh%elements(i)%e%pts(2)%p%x(1) = stats_data%x%x(linear_index(lx,1,1,i,lx,lx,lx))
72 msh%elements(i)%e%pts(3)%p%x(1) = stats_data%x%x(linear_index(1,lx,1,i,lx,lx,lx))
73 msh%elements(i)%e%pts(4)%p%x(1) = stats_data%x%x(linear_index(lx,lx,1,i,lx,lx,lx))
74 msh%elements(i)%e%pts(5)%p%x(1) = stats_data%x%x(linear_index(1,1,lx,i,lx,lx,lx))
75 msh%elements(i)%e%pts(6)%p%x(1) = stats_data%x%x(linear_index(lx,1,lx,i,lx,lx,lx))
76 msh%elements(i)%e%pts(7)%p%x(1) = stats_data%x%x(linear_index(1,lx,lx,i,lx,lx,lx))
77 msh%elements(i)%e%pts(8)%p%x(1) = stats_data%x%x(linear_index(lx,lx,lx,i,lx,lx,lx))
79 msh%elements(i)%e%pts(1)%p%x(2) = stats_data%y%x(linear_index(1,1,1,i,lx,lx,lx))
80 msh%elements(i)%e%pts(2)%p%x(2) = stats_data%y%x(linear_index(lx,1,1,i,lx,lx,lx))
81 msh%elements(i)%e%pts(3)%p%x(2) = stats_data%y%x(linear_index(1,lx,1,i,lx,lx,lx))
82 msh%elements(i)%e%pts(4)%p%x(2) = stats_data%y%x(linear_index(lx,lx,1,i,lx,lx,lx))
83 msh%elements(i)%e%pts(5)%p%x(2) = stats_data%y%x(linear_index(1,1,lx,i,lx,lx,lx))
84 msh%elements(i)%e%pts(6)%p%x(2) = stats_data%y%x(linear_index(lx,1,lx,i,lx,lx,lx))
85 msh%elements(i)%e%pts(7)%p%x(2) = stats_data%y%x(linear_index(1,lx,lx,i,lx,lx,lx))
86 msh%elements(i)%e%pts(8)%p%x(2) = stats_data%y%x(linear_index(lx,lx,lx,i,lx,lx,lx))
88 msh%elements(i)%e%pts(1)%p%x(3) = stats_data%z%x(linear_index(1,1,1,i,lx,lx,lx))
89 msh%elements(i)%e%pts(2)%p%x(3) = stats_data%z%x(linear_index(lx,1,1,i,lx,lx,lx))
90 msh%elements(i)%e%pts(3)%p%x(3) = stats_data%z%x(linear_index(1,lx,1,i,lx,lx,lx))
91 msh%elements(i)%e%pts(4)%p%x(3) = stats_data%z%x(linear_index(lx,lx,1,i,lx,lx,lx))
92 msh%elements(i)%e%pts(5)%p%x(3) = stats_data%z%x(linear_index(1,1,lx,i,lx,lx,lx))
93 msh%elements(i)%e%pts(6)%p%x(3) = stats_data%z%x(linear_index(lx,1,lx,i,lx,lx,lx))
94 msh%elements(i)%e%pts(7)%p%x(3) = stats_data%z%x(linear_index(1,lx,lx,i,lx,lx,lx))
95 msh%elements(i)%e%pts(8)%p%x(3) = stats_data%z%x(linear_index(lx,lx,lx,i,lx,lx,lx))
98 call xh%init(gll, stats_data%lx, stats_data%ly, stats_data%lz)
100 call dof%init(msh, xh)
104 call neko_field_registry%add_field(dof,
'u')
105 call neko_field_registry%add_field(dof,
'v')
106 call neko_field_registry%add_field(dof,
'w')
107 call neko_field_registry%add_field(dof,
'p')
109 u => neko_field_registry%get_field(
'u')
110 v => neko_field_registry%get_field(
'v')
111 w => neko_field_registry%get_field(
'w')
112 p => neko_field_registry%get_field(
'p')
114 call fld_stats%init(coef,u,v,w,p)
117 call copy(fld_stats%stat_fields%items(1)%ptr%x, stats_data%p%x,n)
118 call copy(fld_stats%stat_fields%items(2)%ptr%x, stats_data%u%x,n)
119 call copy(fld_stats%stat_fields%items(3)%ptr%x, stats_data%v%x,n)
120 call copy(fld_stats%stat_fields%items(4)%ptr%x, stats_data%w%x,n)
121 call copy(fld_stats%stat_fields%items(5)%ptr%x, stats_data%t%x,n)
122 do i = 6, fld_stats%stat_fields%size()
123 call copy(fld_stats%stat_fields%items(i)%ptr%x, stats_data%s(i-5)%x,n)
126 call reynolds%init(7)
138 call reynolds%assign_to_field(1, pp)
139 call reynolds%assign_to_field(2, uu)
140 call reynolds%assign_to_field(3, vv)
141 call reynolds%assign_to_field(4, ww)
142 call reynolds%assign_to_field(5, uv)
143 call reynolds%assign_to_field(6, uw)
144 call reynolds%assign_to_field(7, vw)
146 call fld_stats%post_process(reynolds=reynolds)
147 output_file = file_t(
'reynolds.fld')
148 if (pe_rank .eq. 0)
write(*,*)
'Wrtiting Reynolds stresses into reynolds'
149 call output_file%write(reynolds, stats_data%time)
150 if (pe_rank .eq. 0)
write(*,*)
'Done'
152 call mean_vel_grad%init(9)
153 call mean_vel_grad%assign_to_field(1, pp)
154 call mean_vel_grad%assign_to_field(2, uu)
155 call mean_vel_grad%assign_to_field(3, vv)
156 call mean_vel_grad%assign_to_field(4, ww)
157 call mean_vel_grad%assign_to_field(5, uv)
158 call mean_vel_grad%assign_to_field(6, uw)
159 call mean_vel_grad%assign_to_field(7, vw)
160 call mean_vel_grad%assign_to_field(8, tmp1)
161 call mean_vel_grad%assign_to_field(9, tmp2)
163 call fld_stats%post_process(mean_vel_grad=mean_vel_grad)
165 call mean_vel_grad%assign_to_field(1, pp)
166 call mean_vel_grad%assign_to_field(2, uu)
167 call mean_vel_grad%assign_to_field(3, vv)
168 call mean_vel_grad%assign_to_field(4, ww)
169 call mean_vel_grad%assign_to_field(5, uv)
170 call mean_vel_grad%assign_to_field(6, uw)
171 call mean_vel_grad%assign_to_field(7, vw)
172 call mean_vel_grad%assign_to_field(8, tmp1)
173 call mean_vel_grad%assign_to_field(9, tmp2)
176 if (pe_rank .eq. 0)
write(*,*)
'Writing mean velocity gradient into mean_vel_grad'
177 output_file = file_t(
'mean_vel_grad.fld')
178 call output_file%write(mean_vel_grad, stats_data%time)
179 if (pe_rank .eq. 0)
write(*,*)
'Done'
subroutine neko_finalize(c)
program postprocess_fluid_stats
Somewhat preliminary program to sum up averaged fields computed for statistics and mean field Martin ...