Neko 0.9.99
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
postprocess_fluid_stats.f90
Go to the documentation of this file.
1
4 use neko
5 implicit none
6
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
12 type(coef_t) :: coef
13 type(dofmap_t) :: dof
14 type(space_t) :: xh
15 type(mesh_t) :: msh
16 type(gs_t) :: gs_h
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
21
22 argc = command_argument_count()
23
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'
46 write(*,*) 's1=dvdz'
47 write(*,*) 's2=dwdx'
48 write(*,*) 's2=dwdy'
49 write(*,*) 's2=dwdz'
50 end if
51 stop
52 end if
53
54 call neko_init
55
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))
62
63 call mesh_file%read(msh)
64
65 call stats_data%init(msh%nelv,msh%offset_el)
66 call stats_file%read(stats_data)
67
68 do i = 1,msh%nelv
69 lx = stats_data%lx
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))
78
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))
87
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))
96 end do
97
98 call xh%init(gll, stats_data%lx, stats_data%ly, stats_data%lz)
99
100 call dof%init(msh, xh)
101 call gs_h%init(dof)
102 call coef%init(gs_h)
103
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')
108
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')
113
114 call fld_stats%init(coef,u,v,w,p)
115 n = stats_data%u%n
116
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)
124 end do
125
126 call reynolds%init(7)
127 !Temp fields used for the computations to come
128 call uu%init(dof)
129 call vv%init(dof)
130 call ww%init(dof)
131 call uv%init(dof)
132 call uw%init(dof)
133 call vw%init(dof)
134 call pp%init(dof)
135 call tmp1%init(dof)
136 call tmp2%init(dof)
137
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)
145
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'
151
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)
162
163 call fld_stats%post_process(mean_vel_grad=mean_vel_grad)
164 !Fix order of gradients
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)
174
175
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'
180
181 call neko_finalize
182
183end program postprocess_fluid_stats
Master module.
Definition neko.f90:34
subroutine neko_finalize(c)
Definition neko.f90:303
subroutine neko_init(c)
Definition neko.f90:130
program postprocess_fluid_stats
Somewhat preliminary program to sum up averaged fields computed for statistics and mean field Martin ...