Basic examples

| programmer's documentation

- Main Page
- Related Pages
- Modules
- Data Structures
- Files

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Basic examples

# Local variables to be added

The following local variables need to be defined for the examples in this section:

integer ifac, iel, ii, ivar
integer izone
integer ilelt, nlelt
double precision uref2, d2s3
double precision rhomoy, xdh, xustar2
double precision xitur
double precision xkent, xeent
integer, allocatable, dimension(:) :: lstelt

# Initialization and finalization

The following initialization block needs to be added for the following examples:

allocate(lstelt(nfabor)) ! temporary array for boundary faces selection
d2s3 = 2.d0/3.d0
call field_get_val_s(ibrom, brom)

Ad the end of the subroutine, it is recommended to deallocate the work array:

deallocate(lstelt) ! temporary array for boundary faces selection

In theory Fortran 95 deallocates locally-allocated arrays automatically, but deallocating arrays in a symmetric manner to their allocation is good practice, and it avoids using a different logic for C and Fortran.

# Body

In the body, we may define several boundary conditions. Here are a few examples.

# Inlet example with hydraulic diameter

Assign an inlet to boundary faces of group '2' and x < 0.01.

Warning
  the <, <=, >, and >= operators may only be used with variables x, y, and z. This syntax is not a full equation interpreter, so formulas involving x, y, or z are not allowed.

Set a a Dirichlet value on the three components of on the faces with the selection criterium '2 and x < 0.01' and set a Dirichlet to all the scalars .

Turbulence example computed using equations valid for a pipe.

We will be careful to specify a hydraulic diameter adapted to the current inlet.

We will also be careful if necessary to use a more precise formula for the dynamic viscosity use in the calculation of the Reynolds number (especially if it is variable, it may be useful to take the law from usphyv. Here, we use by default the 'viscl0" value.

Regarding the density, we have access to its value at boundary faces (romb) so this value is the one used here (specifically, it is consistent with the processing in usphyv, in case of variable density).

call getfbr('2 and x < 0.01', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
itypfb(ifac) = ientre
rcodcl(ifac,iu,1) = 1.1d0
rcodcl(ifac,iv,1) = 1.1d0
rcodcl(ifac,iw,1) = 1.1d0
uref2 = rcodcl(ifac,iu,1)**2 &
+ rcodcl(ifac,iv,1)**2 &
+ rcodcl(ifac,iw,1)**2
uref2 = max(uref2,1.d-12)
! Turbulence example computed using equations valid for a pipe.
! We will be careful to specify a hydraulic diameter adapted
! to the current inlet.
! We will also be careful if necessary to use a more precise
! formula for the dynamic viscosity use in the calculation of
! the Reynolds number (especially if it is variable, it may be
! useful to take the law from 'usphyv'. Here, we use by default
! the 'viscl0" value.
! Regarding the density, we have access to its value at boundary
! faces (romb) so this value is the one used here (specifically,
! it is consistent with the processing in 'usphyv', in case of
! variable density)
! Hydraulic diameter
xdh = 0.075d0
! Calculation of friction velocity squared (ustar2)
! and of k and epsilon at the inlet (xkent and xeent) using
! standard laws for a circular pipe
! (their initialization is not needed here but is good practice).
rhomoy = brom(ifac)
xustar2 = 0.d0
xkent = epzero
xeent = epzero
call keendb &
!==========
( uref2, xdh, rhomoy, viscl0, cmu, xkappa, &
xustar2, xkent, xeent )
! itytur is a flag equal to iturb/10
if (itytur.eq.2) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iep,1) = xeent
elseif (itytur.eq.3) then
rcodcl(ifac,ir11,1) = d2s3*xkent
rcodcl(ifac,ir22,1) = d2s3*xkent
rcodcl(ifac,ir33,1) = d2s3*xkent
rcodcl(ifac,ir12,1) = 0.d0
rcodcl(ifac,ir13,1) = 0.d0
rcodcl(ifac,ir23,1) = 0.d0
rcodcl(ifac,iep,1) = xeent
if (iturb.eq.32) then
rcodcl(ifac,ial,1) = 1.d0
endif
elseif (itytur.eq.5) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iep,1) = xeent
rcodcl(ifac,iphi,1) = d2s3
if (iturb.eq.50) then
rcodcl(ifac,ifb,1) = 0.d0
elseif (iturb.eq.51) then
rcodcl(ifac,ial,1) = 0.d0
endif
elseif (iturb.eq.60) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iomg,1) = xeent/cmu/xkent
elseif (iturb.eq.70) then
rcodcl(ifac,inusa,1) = cmu*xkent**2/xeent
endif
! Handle scalars
if (nscal.gt.0) then
do ii = 1, nscal
rcodcl(ifac,isca(ii),1) = 1.d0
enddo
endif
enddo

# Inlet example with turbulence intensity

Assign an inlet to boundary faces of group '3'.

Set a a Dirichlet value on the three components of on the faces with the selection criterium '3' and set a Dirichlet to all the scalars .

Turbulence example computed using turbulence intensity data.

We will be careful to specify a hydraulic diameter adapted to the current inlet.

Calculation of and at the inlet (xkent and xeent) using the turbulence intensity and standard laws for a circular pipe (their initialization is not needed here but is good practice)

call getfbr('3', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
iel = ifabor(ifac)
itypfb(ifac) = ientre
rcodcl(ifac,iu,1) = 1.1d0
rcodcl(ifac,iv,1) = 1.1d0
rcodcl(ifac,iw,1) = 1.1d0
uref2 = rcodcl(ifac,iu,1)**2 &
+ rcodcl(ifac,iv,1)**2 &
+ rcodcl(ifac,iw,1)**2
uref2 = max(uref2,1.d-12)
! Turbulence example computed using turbulence intensity data.
! We will be careful to specify a hydraulic diameter adapted
! to the current inlet.
! Hydraulic diameter
xdh = 0.075d0
! Turbulence intensity
xitur = 0.02d0
! Calculation of k and epsilon at the inlet (xkent and xeent) using
! the turbulence intensity and standard laws for a circular pipe
! (their initialization is not needed here but is good practice)
xkent = epzero
xeent = epzero
call keenin &
!==========
( uref2, xitur, xdh, cmu, xkappa, xkent, xeent )
! itytur is a flag equal to iturb/10
if (itytur.eq.2) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iep,1) = xeent
elseif (itytur.eq.3) then
rcodcl(ifac,ir11,1) = d2s3*xkent
rcodcl(ifac,ir22,1) = d2s3*xkent
rcodcl(ifac,ir33,1) = d2s3*xkent
rcodcl(ifac,ir12,1) = 0.d0
rcodcl(ifac,ir13,1) = 0.d0
rcodcl(ifac,ir23,1) = 0.d0
rcodcl(ifac,iep,1) = xeent
if (iturb.eq.32) then
rcodcl(ifac,ial,1) = 1.d0
endif
elseif (itytur.eq.5) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iep,1) = xeent
rcodcl(ifac,iphi,1) = d2s3
if (iturb.eq.50) then
rcodcl(ifac,ifb,1) = 0.d0
elseif (iturb.eq.51) then
rcodcl(ifac,ial,1) = 0.d0
endif
elseif (iturb.eq.60) then
rcodcl(ifac,ik,1) = xkent
rcodcl(ifac,iomg,1) = xeent/cmu/xkent
elseif (iturb.eq.70) then
rcodcl(ifac,inusa,1) = cmu*xkent**2/xeent
endif
! --- Handle scalars
if (nscal.gt.0) then
do ii = 1, nscal
rcodcl(ifac,isca(ii),1) = 1.d0
enddo
endif
enddo

# Assign an outlet to boundary faces of group 'outlet'

Outlet:

- zero flux for velocity and temperature, prescribed pressure
- Note that the pressure will be set to P0 at the first
- free outlet face (isolib)

call getfbr('outlet', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! Outlet: zero flux for velocity and temperature, prescribed pressure
! Note that the pressure will be set to P0 at the first
! free outlet face (isolib)
itypfb(ifac) = isolib
enddo

# Wall example

Assign a wall to boundary faces of group '5'.

Wall:

- zero flow (zero flux for pressure)
- friction for velocities (+ turbulent variables)
- zero flux for scalars

call getfbr('5', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! Wall: zero flow (zero flux for pressure)
! friction for velocities (+ turbulent variables)
! zero flux for scalars
itypfb(ifac) = iparoi
! If sliding wall with velocity u = 1:
! rcodcl(ifac, iu, 1) = 1.d0
! If sliding wall with velocity u = 0: nothing to do
if (nscal.gt.0) then
! If temperature prescribed to 20 with wall law (scalar ii=1):
ii = 1
icodcl(ifac, isca(ii)) = 5
rcodcl(ifac, isca(ii), 1) = 20.d0
! If temperature prescribed to 50 with no wall law (simple Dirichlet)
! with exchange coefficient 8 (scalar ii=2):
ii = 2
icodcl(ifac, isca(ii)) = 1
rcodcl(ifac, isca(ii),1) = 50.d0
rcodcl(ifac, isca(ii), 2) = 8.d0
! If flux prescribed to 4.d0 (scalar ii=3):
ii = 3
icodcl(ifac, isca(ii)) = 3
rcodcl(ifac, isca(ii), 3) = 4.d0
endif
enddo

# Rough wall example

Assign a rough wall to boundary faces of group '7'.

Wall:

- zero flow (zero flux for pressure)
- rough friction for velocities (+ turbulent variables)
- zero flux for scalars

call getfbr('7', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! Wall: zero flow (zero flux for pressure)
! rough friction for velocities (+ turbulent variables)
! zero flux for scalars
itypfb(ifac) = iparug
! Roughness for velocity: 1cm
rcodcl(ifac,iu,3) = 0.01d0
! Roughness for scalar (if required): 1cm
rcodcl(ifac,iv,3) = 0.01d0
! If sliding wall with velocity u = 1:
rcodcl(ifac, iu, 1) = 1.d0
! If sliding wall with velocity u = 0: nothing to do
if (nscal.gt.0) then
! If temperature prescribed to 20 (scalar ii=1)
! (with thermal roughness specified in rcodcl(ifac,iv,3)) :
ii = 1
icodcl(ifac, isca(ii)) = 6
rcodcl(ifac, isca(ii), 1) = 20.d0
! If flux prescribed to 4.d0 (scalar ii=3):
ii = 3
icodcl(ifac, isca(ii)) = 3
rcodcl(ifac, isca(ii), 3) = 4.d0
endif
enddo

# Symmetry example

Assign a symmetry condition to boundary faces of group '4'

call getfbr('4', nlelt, lstelt)
do ilelt = 1, nlelt
ifac = lstelt(ilelt)
! Symmetries
itypfb(ifac) = isymet
enddo