KTH framework for Nek5000 toolboxes; testing version  0.0.1
2D and 3D statistics module

Set of routines to collect 44 fields for statistics. More...

+ Collaboration diagram for 2D and 3D statistics module:

Files

file  stat.f
 2D and 3D statistics module
 
file  stat_IO.f
 IO routines for 2D/3D statistics module.
 

Functions

subroutine stat_register ()
 Register 2D and 3D statistics module. More...
 
subroutine stat_init ()
 Initilise statistics module. More...
 
subroutine stat_end ()
 Finalise statistics module. More...
 
logical function stat_is_initialised ()
 Check if module was initialised. More...
 
subroutine stat_avg
 Main interface of statistics module. More...
 
subroutine stat_init_int1d ()
 Get local integration coefficients. More...
 
subroutine stat_reshufflev (rvar, var, nl)
 Array reshuffle. More...
 
subroutine stat_compute_1dav1 (lvar, npos, alpha, beta)
 Perform local 1D integration on 1 variable. More...
 
subroutine stat_compute_1dav2 (lvar1, lvar2, npos, alpha, beta)
 Perform local 1D integration on multiplication of 2 variables. More...
 
subroutine stat_gs_sum
 Global statistics summation. More...
 
subroutine stat_compute ()
 Compute statistics. More...
 
subroutine stat_mfo ()
 Main interface for saving statistics. More...
 
subroutine stat_mfo_outfld3d ()
 Statistics muti-file output of 3D data. More...
 
subroutine stat_mfo_outfld2d ()
 Statistics muti-file output of 2D data. More...
 
subroutine stat_mfo_write_hdr2d
 Write hdr, byte key, global ordering of 2D data. More...
 
subroutine stat_mfo_write_stat2d
 Write additional data at the end of the file. More...
 
subroutine stat_mfo_crd2d
 Write element centres to the file (in case of AMR level as well) More...
 

Detailed Description

Set of routines to collect 44 fields for statistics.

This set of routines performs temporal, and, in case of the 2D version, spanwise averaging of some 44 different fields, which include selected statistical moments of velocity and pressure up to fourth order. A full list of fields is provided in the field_list.txt file located in the same directory as this file. Please note that there is no abuse of notation in the names of the quantities, e.g. <uu> actually means <uu> and not <u'u'>.

As metioned above, the module can operate in two regimes, 2D and 3D. In the 3D case, the fields are only averaged in time, whereas in 2D the they are also averaged spatially along a chosen homogeneous direction. To select the mode of operation, the parameter stat_rdim defined in the include file STATD should be set to either 1 for 2D statistics or 0 for 3D. A template for this file is provided in this directory, you should copy it to your case folder and rename it to STATD.

In the case of 2D statistics, the index of the homogeneous direction should be selected as well. This is done by setting the idir variable in the user_map2d_get subroutine, which should be copied into your .usr file. The module will compute the statistics based on sampling the solution every AVSTEP iterations. At each IOSTEP iteration, two files will be output with prefix c2D and sts, respectively. Important: the whole simulation must be run on the same number of ranks!

Each sts file will hold the data averaged over IOSTEP iterations. IOSTEP is thus both the averaging window length and the frequency of output. The sts files are in the same format as Nek5000 output files, meaning that they can, for example, be opened with Paraview or other tools. See also pstat2d in this Toolbox for ways of extracting data from sts files: averaging across sts files, computing additional fields, extracting data at arbitrary points.

The c2D files store the element numbering in the sts-file mesh, the centres of these elements, and also the level of refinement (used for adaptive mesh refinement). This information is used by the pstat2d tool.

In the case of 3D statistics, 11 files, s01* to s11* will be written each IOSTEP iterations. Like with the 2D statistics, these will hold quantities averaged over IOSTEP iterations. Each file holds 4 fields, the distribtuion of quantities across the files is provided in the field_list.txt file in this directory. The files can also be opened in e.g. Paraview, but one should be aware that the names of the fields are always x_velocity, y_velocity, z_velocity and temerature. These names have nothing to do with the physical quantity stored. Instead, one should consult field_list.txt and map the 4 quantities listed there to the names above, in the order listed. Post-processing of the produced fields can also be performed with the pstat3d tool.

Module interface:
Global interface list:
Interface provided:
  1. stat_register
  2. stat_init
  3. stat_end
  4. stat_avg
Global interface dependency:
Interface required:
  1. multiple interfaces from Runtime parameters and Monitoring module modules
  2. map2d_register , map2d_init and map2d_get from Grid mapping module (automatically registered)
  3. user_stat_trnsv; user defined
Warning
This module depends on Grid mapping module and (user_map2d_get) has to be provided irrespective of the spanwise average being performed or not. In case only the time average is performed (stat_rdim=0 in STATD) user_map2d_get should be empty, but stil present. However, Grid mapping is automatically registered by statistics tool, so there is no need to add it to frame_usr_register and frame_usr_init.
Note
user_stat_trnsv is a user provided interface for both statistics and Time history for set of points modules.
Module interface usage:
!======================================================================
subroutine userchk
include 'TSTEP'
if (istep.eq.0) then
! start framework
endif
! monitor simulation
! collect statistics
call stat_avg
! finalise framework
if (istep.eq.nsteps.or.lastep.eq.1) then
call frame_end
endif
return
end
!======================================================================
subroutine frame_usr_register
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! register modules
return
end subroutine
!======================================================================
subroutine frame_usr_init
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! initialise modules
call stat_init
return
end subroutine
!======================================================================
subroutine frame_usr_end
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! finlise modules
call stat_end
return
end subroutine
!=======================================================================
subroutine frame_monitor
Simulataion monitoring.
Definition: frame.f:59
subroutine frame_start
Start framework.
Definition: frame.f:12
subroutine frame_end
Finalise framework.
Definition: frame.f:76
subroutine stat_avg
Main interface of statistics module.
Definition: stat.f:237
subroutine stat_init()
Initilise statistics module.
Definition: stat.f:111
subroutine stat_register()
Register 2D and 3D statistics module.
Definition: stat.f:13
subroutine stat_end()
Finalise statistics module.
Definition: stat.f:186
!=======================================================================
subroutine user_stat_trnsv(lvel,dudx,dvdx,dwdx,vort,pres)
implicit none
include 'SIZE'
include 'SOLN'
include 'INPUT' ! if3d
include 'GEOM'
! argument list
real lvel(LX1,LY1,LZ1,LELT,3) ! velocity array
real dudx(LX1,LY1,LZ1,LELT,3) ! velocity derivatives; U
real dvdx(LX1,LY1,LZ1,LELT,3) ! V
real dwdx(LX1,LY1,LZ1,LELT,3) ! W
real vort(LX1,LY1,LZ1,LELT,3) ! vorticity
real pres(LX1,LY1,LZ1,LELT) ! pressure
! local variables
integer itmp ! dummy variable
integer il, jl ! loop index
integer ifll ! field number for object definition
real vrtmp(lx1*lz1) ! work array for face
real vrtmp2(2) ! work array
! functions
real vlsum
!-----------------------------------------------------------------------
! Velocity transformation; simple copy
itmp = nx1*ny1*nz1*nelv
call copy(lvel(1,1,1,1,1),vx,itmp)
call copy(lvel(1,1,1,1,2),vy,itmp)
call copy(lvel(1,1,1,1,3),vz,itmp)
! Derivative transformation
! No transformation
call gradm1(dudx(1,1,1,1,1),dudx(1,1,1,1,2),dudx(1,1,1,1,3),
$ lvel(1,1,1,1,1))
call gradm1(dvdx(1,1,1,1,1),dvdx(1,1,1,1,2),dvdx(1,1,1,1,3),
$ lvel(1,1,1,1,2))
call gradm1(dwdx(1,1,1,1,1),dwdx(1,1,1,1,2),dwdx(1,1,1,1,3),
$ lvel(1,1,1,1,3))
! get vorticity
if (if3d) then
! curlx
call sub3(vort(1,1,1,1,1),dwdx(1,1,1,1,2),
$ dvdx(1,1,1,1,3),itmp)
! curly
call sub3(vort(1,1,1,1,2),dudx(1,1,1,1,3),
$ dwdx(1,1,1,1,1),itmp)
endif
! curlz
call sub3(vort(1,1,1,1,3),dvdx(1,1,1,1,1),dudx(1,1,1,1,2),itmp)
! normalise pressure
! in this example I integrate pressure over all faces marked "W"
ifll = 1 ! I'm interested in velocity bc
call rzero(vrtmp2,2) ! zero work array
obj_srfl = 0.0 ! initialise object surface
pmeanl = 0.0 ! initialise pressure mean
itmp = lx1*lz1
do il=1,nelv ! element loop
do jl=1,2*ldim ! face loop
if (cbc(jl,il,ifll).eq.'W ') then
vrtmp2(1) = vrtmp2(1) + vlsum(area(1,1,jl,il),itmp)
call ftovec(vrtmp,pres,il,jl,lx1,ly1,lz1)
call col2(vrtmp,area(1,1,jl,il),itmp)
vrtmp2(2) = vrtmp2(2) + vlsum(vrtmp,itmp)
enddo
enddo
! global communication
call gop(vrtmp2,vrtmp,'+ ',2)
! missing error check vrtmp2(1) == 0
vrtmp2(2) = -vrtmp2(2)/vrtmp2(1)
! remove mean pressure
itmp = nx1*ny1*nz1*nelv
call cadd(pres,vrtmp2(2),itmp)
return
end subroutine
!=======================================================================
subroutine gop(x, w, op, n)
Definition: comm_mpi.f:201
subroutine ftovec(a, b, ie, iface, nx, ny, nz)
Definition: dssum.f:417
subroutine cadd(a, const, n)
Definition: math.f:326
subroutine col2(a, b, n)
Definition: math.f:564
subroutine copy(a, b, n)
Definition: math.f:260
subroutine sub3(a, b, c, n)
Definition: math.f:175
subroutine rzero(a, n)
Definition: math.f:208
subroutine gradm1(ux, uy, uz, u)
Definition: navier5.f:463
Module parameters:
Global parameter list:
Parameters provided by stat module (include file - STATD):
Varaible Type Runtime parameter Description
stat_avstep integer _stat:AvStep frequency of averaging
stat_skstep integer _stat:SkStep skipped initial steps
stat_IOstep integer _stat:IOStep frequency of saving data to the disc
Module parameter usage:
[_STAT] # Runtime parameter section for statistics module
AVSTEP = 10 # The frequency, in time-steps, at which the solution is sampled
SKSTEP = 2 # Skipped initial steps
IOSTEP = 50 # The output frequency, in time-steps, which also defines the averaging window

Function Documentation

◆ stat_avg()

subroutine stat_avg

Main interface of statistics module.

This routine performs time averaging and file writing.

Note
This routine should be called in userchk during every step

Definition at line 236 of file stat.f.

References mntr_log(), mntr_tmr_add(), rzero(), stat_compute(), stat_gs_sum(), and stat_mfo().

+ Here is the call graph for this function:

◆ stat_compute()

subroutine stat_compute

Compute statistics.

Remarks
This routine uses global scratch space SCRMG, SCRUZ, SCRNS, SCRSF

Definition at line 762 of file stat.f.

References add2(), col3(), copy(), mappr(), mntr_log(), stat_compute_1dav1(), stat_compute_1dav2(), and stat_reshufflev().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_compute_1dav1()

subroutine stat_compute_1dav1 ( real, dimension(lx1,ly1,lz1,lelt lvar,
integer  npos,
real  alpha,
real  beta 
)

Perform local 1D integration on 1 variable.

Parameters
[in]lvarintegrated variable
[in]nposposition in stat_ruavg
[in]alpha,betatime averaging parameters
Remarks
This routine uses global scratch space CTMP0

Definition at line 565 of file stat.f.

References add2sxy(), mntr_abort(), and rzero().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_compute_1dav2()

subroutine stat_compute_1dav2 ( real, dimension(lx1,ly1,lz1,lelt lvar1,
real, dimension(lx1,ly1,lz1,lelt lvar2,
integer  npos,
real  alpha,
real  beta 
)

Perform local 1D integration on multiplication of 2 variables.

Parameters
[in]lvar1,lvar2integrated variable
[in]nposposition in stat_ruavg
[in]alpha,betatime averaging parameters
Remarks
This routine uses global scratch space CTMP0

Definition at line 622 of file stat.f.

References add2sxy(), col3(), mntr_abort(), and rzero().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_end()

subroutine stat_end

Finalise statistics module.

Note
This routine should be called in frame_usr_end

Definition at line 185 of file stat.f.

References mntr_log(), mntr_tmr_add(), stat_gs_sum(), and stat_mfo().

+ Here is the call graph for this function:

◆ stat_gs_sum()

subroutine stat_gs_sum

Global statistics summation.

Definition at line 678 of file stat.f.

References copy(), invcol2(), mntr_log(), and rzero().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_init()

subroutine stat_init

Initilise statistics module.

Note
This routine should be called in frame_usr_init

Definition at line 110 of file stat.f.

References map2d_init(), mntr_log(), mntr_tmr_add(), mntr_warn(), rprm_rp_get(), rzero(), and stat_init_int1d().

+ Here is the call graph for this function:

◆ stat_init_int1d()

subroutine stat_init_int1d

Get local integration coefficients.

This version does 1D integration over one of the directions R,S,T. It supports curved coordinate systems, however axisymmetric 2.5D cases are not supported

Remarks
This routine uses global scratch space SCRSF

Definition at line 309 of file stat.f.

References add2(), copy(), mntr_abort(), mxm(), rzero(), stat_reshufflev(), vsq(), and vsqrt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_is_initialised()

logical function stat_is_initialised

Check if module was initialised.

Returns
stat_is_initialised

Definition at line 221 of file stat.f.

◆ stat_mfo()

subroutine stat_mfo

Main interface for saving statistics.

Definition at line 12 of file stat_IO.f.

References stat_mfo_outfld2d(), and stat_mfo_outfld3d().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_mfo_crd2d()

subroutine stat_mfo_crd2d

Write element centres to the file (in case of AMR level as well)

Definition at line 484 of file stat_IO.f.

References blank(), byte_close, byte_close_mpi(), byte_set_view(), byte_write, byte_write_mpi(), crecv(), csend(), igllm(), mfo_open_files(), mntr_check_abort(), mxm(), and zwgll().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_mfo_outfld2d()

subroutine stat_mfo_outfld2d

Statistics muti-file output of 2D data.

This routine is just modification of mfo_outfld

Remarks
This routine uses global scratch space SCRUZ

Definition at line 102 of file stat_IO.f.

References byte_close, byte_close_mpi(), byte_set_view(), copy(), mfo_open_files(), mfo_outs(), mntr_check_abort(), stat_mfo_crd2d(), stat_mfo_write_hdr2d(), and stat_mfo_write_stat2d().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_mfo_outfld3d()

subroutine stat_mfo_outfld3d

Statistics muti-file output of 3D data.

Definition at line 29 of file stat_IO.f.

References outpost().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_mfo_write_hdr2d()

subroutine stat_mfo_write_hdr2d

Write hdr, byte key, global ordering of 2D data.

This routine is just modification of mfo_write_hdr

Remarks
This routine uses global scratch space CTMP0

Definition at line 318 of file stat_IO.f.

References blank(), byte_set_view(), byte_write, byte_write_mpi(), crecv(), csend(), and mntr_check_abort().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stat_mfo_write_stat2d()

subroutine stat_mfo_write_stat2d

Write additional data at the end of the file.

Definition at line 465 of file stat_IO.f.

+ Here is the caller graph for this function:

◆ stat_register()

subroutine stat_register

Register 2D and 3D statistics module.

Note
This routine should be called in frame_usr_register

Definition at line 12 of file stat.f.

References map2d_register(), mntr_abort(), mntr_mod_is_name_reg(), mntr_mod_reg(), mntr_tmr_add(), mntr_tmr_is_name_reg(), mntr_tmr_reg(), mntr_warn(), rprm_rp_reg(), rprm_sec_reg(), and rprm_sec_set_act().

+ Here is the call graph for this function:

◆ stat_reshufflev()

subroutine stat_reshufflev ( real, dimension(lx1,ly1,lz1,lelt rvar,
real, dimension(lx1,ly1,lz1,lelt var,
integer  nl 
)

Array reshuffle.

Reorder directions in such a way that the uniform direction corresponds to the the first index

Parameters
[out]rvarreshuffled array
[in]varinput array
[in]nlelement number to reshuffle

Definition at line 496 of file stat.f.

References copy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: