!===============================================================================
! User synthetic turbulence inlet definition.
!
! 1) Global characteristics of synthetic turbulence inlets
! 2) Caracteristics of one specific inlet
! 3) Accurate specification of target statistics at inlet
!===============================================================================

!-------------------------------------------------------------------------------

!                      Code_Saturne version 6.0
!                      ------------------------
! This file is part of Code_Saturne, a general-purpose CFD tool.
!
! Copyright (C) 1998-2019 EDF S.A.
!
! This program is free software; you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free Software
! Foundation; either version 2 of the License, or (at your option) any later
! version.
!
! This program is distributed in the hope that it will be useful, but WITHOUT
! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
! Street, Fifth Floor, Boston, MA 02110-1301, USA.

!-------------------------------------------------------------------------------

!===============================================================================

!===============================================================================
! Purpose :
! --------

!> \brief Definition of the characteristics of the synthetic turbulence inlet
!>  \c nument
!>
!> For each LES inlet, the following parameters might be defined:
!>
!>  1. Data relatve to the method employed
!>
!>    - typent indicates the synthetic turbulence method:
!>
!>       - 0: laminar, no turbulent fluctations
!>       - 1: random gaussian noise
!>       - 2: Batten method, based on Fourier mode decomposition
!>       - 3: Synthetic Eddy Method (SEM)
!>       .
!>
!>    - nelent indicates the number of "entities" relative to the method
!>       (useful only for the Batten method and the SEM):
!>
!>       - for Batten : number of Fourier modes of the turbulent fluctuations
!>       - for SEM    : number of synthetic eddies building the fluctuations
!>       .
!>
!>    - iverbo indicates the verbosity level (log)
!>
!>       -   0  no specific output
!>       - > 0 additionnal output (only for SEM)
!>       .
!>
!>
!>  2. Data relative to the LES inflow boundary faces
!>
!>     - nfbent: number of boundary faces of the LES inflow
!>     - lfbent: list of boundary faces of the LES inflow
!>
!>
!>  3. Data relative to the flow
!>
!>     - vitent(3): reference mean velocity vector
!>     - enrent   : reference turbulent kinetic energy
!>     - dspent   : reference dissipation rate
!>
!>       \remarks
!>       - dspent useful only for typent = 2 (Batten) or typent = 3 (SEM).
!>       - Strictly positive values are required for enrent and dspent.
!>       - Accurate specification of the statistics of the flow at LES inlet
!>         can be made via the user subroutine cs_user_les_inflow_advanced.
!>
!-------------------------------------------------------------------------------

!-------------------------------------------------------------------------------
! Arguments
!______________________________________________________________________________.
!  mode           name          role                                           !
!______________________________________________________________________________!
!> \param[in]     nument        id of the inlet
!> \param[out]    typent        type of inflow method at the inlet
!> \param[out]    nelent        numb. of entities of the inflow meth
!> \param[out]    iverbo        verbosity level
!> \param[out]    nfbent        numb. of bound. faces of the inlet
!> \param[out]    lfbent        list of bound. faces of the inlet
!> \param[out]    vitent        ref. mean velocity at the inlet
!> \param[out]    enrent        ref. turb. kin. ener. at the inlet
!> \param[out]    dspent        ref. turb. dissipation at the inlet
!_______________________________________________________________________________

subroutine cs_user_les_inflow_define &
( nument, typent, nelent, iverbo,                                             &
  nfbent, lfbent,                                                             &
  vitent, enrent, dspent                                                      &
)

!===============================================================================

!===============================================================================
! Module files
!===============================================================================

use paramx
use numvar
use optcal
use entsor
use mesh
use cstnum
use cstphy
use parall

!===============================================================================

implicit none

! Arguments

integer          nument, iverbo
integer          nfbent, typent, nelent
integer          lfbent(nfabor)

double precision vitent(3), enrent, dspent

!===============================================================================

if (nument.eq.1) then
  ! 1. Data relatve to the method employed
  ! Batten method
  typent = 2
  ! Synthetic fluctuations are composed of 200 modes
  nelent = 200
  ! No specific verbosity
  iverbo = 0
  ! 2. Data relative to the LES inflow boundary faces
  ! Selection of the boundary faces of color '1'
  call getfbr('inlet',nfbent,lfbent)
  ! 3. Data relative to the flow
  ! Velocity, turb. kinetic energy and dissipation scales are given
  vitent(1) = 2.d0
  vitent(2) = 0.d0
  vitent(3) = 0.d0
  enrent = 4.d0
  dspent = 4.d0
endif

!--------
! Formats
!--------

!----
! End
!----

return
end subroutine cs_user_les_inflow_define
