Skip to content

Commit

Permalink
Merge pull request #1494 from ExtremeFLOW/martin/reasonable_statistics
Browse files Browse the repository at this point in the history
Fluid statistics as simcomp and 1D/2D stats
  • Loading branch information
MartinKarp authored Oct 4, 2024
2 parents a2d136a + 5bec74e commit 815ee82
Show file tree
Hide file tree
Showing 16 changed files with 892 additions and 617 deletions.
88 changes: 39 additions & 49 deletions contrib/postprocess_fluid_stats/postprocess_fluid_stats.f90
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@
!! Martin Karp 27/01-23
program postprocess_fluid_stats
use neko
use mean_flow
implicit none

character(len=NEKO_FNAME_LEN) :: inputchar, mesh_fname, stats_fname, mean_fname
type(file_t) :: mean_file, stats_file, output_file, mesh_file
character(len=NEKO_FNAME_LEN) :: inputchar, mesh_fname, stats_fname
type(file_t) :: stats_file, output_file, mesh_file
real(kind=rp) :: start_time
type(fld_file_data_t) :: stats_data, mean_data
type(mean_flow_t) :: avg_flow
type(fld_file_data_t) :: stats_data
type(fluid_stats_t) :: fld_stats
type(coef_t) :: coef
type(dofmap_t) :: dof
Expand All @@ -25,10 +23,12 @@ program postprocess_fluid_stats

if ((argc .lt. 3) .or. (argc .gt. 3)) then
if (pe_rank .eq. 0) then
write(*,*) 'Usage: ./postprocess_fluid_stats mesh.nmsh mean_field.fld stats.fld'
write(*,*) 'Example command: ./postprocess_fluid_stats mesh.nmsh mean_fieldblabla.fld statsblabla.fld'
write(*,*) 'Computes the statstics from the fld files described in mean_fielblabla.nek5000 statsblabla.nek5000'
write(*,*) 'Currently we output two new fld files reynolds and mean_vei_grad'
write(*,*) 'Usage: ./postprocess_fluid_stats mesh.nmsh stats.fld'
write(*,*) 'Example command: ./postprocess_fluid_stats mesh.nmsh statsblabla.fld'
write(*,*) 'Computes the statstics from the (3D) fld files described in statsblabla.nek5000'
write(*,*) 'Recommended to use PyNekTools for more advanced postprocessing.'
write(*,*) 'If this does not work, switch to that.'
write(*,*) 'Currently we output two new fld files reynolds and mean_vel_grad'
write(*,*) 'In Reynolds the fields are ordered as:'
write(*,*) 'x-velocity=<u`u`>'
write(*,*) 'y-velocity=<v`v`>'
Expand Down Expand Up @@ -57,50 +57,45 @@ program postprocess_fluid_stats
read(inputchar, *) mesh_fname
mesh_file = file_t(trim(mesh_fname))
call get_command_argument(2, inputchar)
read(inputchar, *) mean_fname
mean_file = file_t(trim(mean_fname))
call get_command_argument(3, inputchar)
read(inputchar, *) stats_fname
stats_file = file_t(trim(stats_fname))

call mesh_file%read(msh)

call mean_data%init(msh%nelv,msh%offset_el)
call stats_data%init(msh%nelv,msh%offset_el)
call mean_file%read(mean_data)
call stats_file%read(stats_data)

do i = 1,msh%nelv
lx = mean_data%lx
msh%elements(i)%e%pts(1)%p%x(1) = mean_data%x%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(1) = mean_data%x%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(1) = mean_data%x%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(1) = mean_data%x%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(1) = mean_data%x%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(1) = mean_data%x%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(1) = mean_data%x%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(1) = mean_data%x%x(linear_index(lx,lx,lx,i,lx,lx,lx))

msh%elements(i)%e%pts(1)%p%x(2) = mean_data%y%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(2) = mean_data%y%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(2) = mean_data%y%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(2) = mean_data%y%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(2) = mean_data%y%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(2) = mean_data%y%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(2) = mean_data%y%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(2) = mean_data%y%x(linear_index(lx,lx,lx,i,lx,lx,lx))

msh%elements(i)%e%pts(1)%p%x(3) = mean_data%z%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(3) = mean_data%z%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(3) = mean_data%z%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(3) = mean_data%z%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(3) = mean_data%z%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(3) = mean_data%z%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(3) = mean_data%z%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(3) = mean_data%z%x(linear_index(lx,lx,lx,i,lx,lx,lx))
lx = stats_data%lx
msh%elements(i)%e%pts(1)%p%x(1) = stats_data%x%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(1) = stats_data%x%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(1) = stats_data%x%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(1) = stats_data%x%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(1) = stats_data%x%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(1) = stats_data%x%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(1) = stats_data%x%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(1) = stats_data%x%x(linear_index(lx,lx,lx,i,lx,lx,lx))

msh%elements(i)%e%pts(1)%p%x(2) = stats_data%y%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(2) = stats_data%y%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(2) = stats_data%y%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(2) = stats_data%y%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(2) = stats_data%y%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(2) = stats_data%y%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(2) = stats_data%y%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(2) = stats_data%y%x(linear_index(lx,lx,lx,i,lx,lx,lx))

msh%elements(i)%e%pts(1)%p%x(3) = stats_data%z%x(linear_index(1,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(2)%p%x(3) = stats_data%z%x(linear_index(lx,1,1,i,lx,lx,lx))
msh%elements(i)%e%pts(3)%p%x(3) = stats_data%z%x(linear_index(1,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(4)%p%x(3) = stats_data%z%x(linear_index(lx,lx,1,i,lx,lx,lx))
msh%elements(i)%e%pts(5)%p%x(3) = stats_data%z%x(linear_index(1,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(6)%p%x(3) = stats_data%z%x(linear_index(lx,1,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(7)%p%x(3) = stats_data%z%x(linear_index(1,lx,lx,i,lx,lx,lx))
msh%elements(i)%e%pts(8)%p%x(3) = stats_data%z%x(linear_index(lx,lx,lx,i,lx,lx,lx))
end do

call Xh%init(GLL, mean_data%lx, mean_data%ly, mean_data%lz)
call Xh%init(GLL, stats_data%lx, stats_data%ly, stats_data%lz)

call dof%init(msh, Xh)
call gs_h%init(dof)
Expand All @@ -116,13 +111,8 @@ program postprocess_fluid_stats
w => neko_field_registry%get_field('w')
p => neko_field_registry%get_field('p')

call avg_flow%init(u, v, w, p)
call fld_stats%init(coef,avg_flow%u,avg_flow%v,avg_flow%w,avg_flow%p)
n = mean_data%u%n
call copy(avg_flow%u%mf%x,mean_data%u%x,n)
call copy(avg_flow%v%mf%x,mean_data%v%x,n)
call copy(avg_flow%w%mf%x,mean_data%w%x,n)
call copy(avg_flow%p%mf%x,mean_data%p%x,n)
call fld_stats%init(coef,u,v,w,p)
n = stats_data%u%n

call copy(fld_stats%stat_fields%items(1)%ptr%x, stats_data%p%x,n)
call copy(fld_stats%stat_fields%items(2)%ptr%x, stats_data%u%x,n)
Expand Down
1 change: 1 addition & 0 deletions doc/pages/user-guide/simcomps.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ in Neko. The list will be updated as new simcomps are added.
- Computation of forces and torque on a surface \ref simcomp_force_torque
- Computation of the weak gradient of a field \ref simcomp_weak_grad
- User defined components \ref user-file_simcomps
- Fluid statistics simcomp, "fluid_stats", for more details see the [statistics guide](@ref statistics-guide)

## Controling execution and file output
Each simulation component is, by default, executed once per time step to perform
Expand Down
Loading

0 comments on commit 815ee82

Please sign in to comment.