7.1
general documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
Compressible example

Compressible example

Local variables to be added

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

integer, allocatable, dimension(:) :: lstelt
integer iel
integer iscal, imodif
double precision, allocatable, dimension(:) :: w1, w2, w3, w4
double precision, dimension(:), pointer :: cpro_rom
double precision, dimension(:,:), pointer :: cvar_vel
double precision, dimension(:), pointer :: cvar_pr
double precision, dimension(:), pointer :: cvar_scal, cvar_tempk, cvar_energ

Allocation

Before user initialization, work arrays must be allocated.

Initialization

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

if ( isuite.eq.0 ) then
! --- Velocity components
do iel = 1, ncel
cvar_vel(1,iel) = 0.d0
cvar_vel(2,iel) = 0.d0
cvar_vel(3,iel) = 0.d0
enddo
! --- User defined scalars
! If there are user defined scalars
if(nscaus.gt.0) then
! For each scalar
do iscal = 1, nscaus
! If the scalar is associated to the considered phase iphas
! if(iphsca(iscal).eq.iphas) then
call field_get_val_s(ivarfl(isca(iscal)), cvar_scal)
! Initialize each cell value
do iel = 1, ncel
cvar_scal(iel) = 0.d0
enddo
! endif
enddo
endif
! --- Pressure, Density, Temperature, Total Energy
! Only 2 out of these 4 variables are independent: one may choose to
! initialize any pair of variables picked out of these 4, except
! (Temperature-Energy). The remaining 2 variables will be deduced
! automatically.
! Initialize 2 and only 2 variables
! To do so, set iutile=1 for each of the 2 selected variables
! and iutile=0 for each of the 2 others
! In the example provided below, Pressure and Temperature are
! initialized.
! ithvar indicates which variables have been set:
! it is completed automatically for each variable and
! it must not be modified.
! 1. Pressure (Pa)
if(.true.) then
ithvar = ithvar*2
do iel = 1, ncel
cvar_pr(iel) = p0
enddo
endif
! 2. Density (kg.m-3)
if(.false.) then
ithvar = ithvar*3
do iel = 1, ncel
cpro_rom(iel) = ro0
enddo
endif
! 3. Temperature (K -- Warning: Kelvin)
if(.true.) then
ithvar = ithvar*5
call field_get_val_s(ivarfl(isca(itempk)), cvar_tempk)
do iel = 1, ncel
cvar_tempk(iel) = t0
enddo
endif
! 4. Total Energy (J/kg)
if(.false.) then
ithvar = ithvar*7
call field_get_val_s(ivarfl(isca(ienerg)), cvar_energ)
do iel = 1, ncel
cvar_energ(iel) = cv0*t0
enddo
endif
endif

Finalization

At the end of the subroutine, it is recommended to deallocate the work arrays:

deallocate(lstelt) ! temporary array for cells selection
deallocate(w1, w2, w3, w4)