Libby-Williams gas example
Local variables to be added
The following local variables need to be defined for the examples in this section:
integer iel, mode, igg, izone
double precision hinit, coefg(ngazgm)
double precision sommqf, sommqt, sommq, tentm, fmelm
character(len=80) :: chaine
integer :: iscal, ivar, ii
double precision :: valmax, valmin
double precision, dimension(:), pointer :: cvar_yfm, cvar_fm, cvar_cyfp2m
double precision, dimension(:), pointer :: cvar_fp2m, cvar_coyfp
double precision, dimension(:), pointer :: cvar_scalt, cvar_scal
Allocation
Before user initialization, work arrays lstelt must be allocated, like in basic example.
Initialization
The following initialization block needs to be added for the following examples:
if (isuite.gt.0) return
write(nfecra,9001)
call field_get_val_s(ivarfl(isca(iyfm)), cvar_yfm)
call field_get_val_s(ivarfl(isca(ifm)), cvar_fm)
call field_get_val_s(ivarfl(isca(iyfp2m)), cvar_cyfp2m)
call field_get_val_s(ivarfl(isca(ifp2m)), cvar_fp2m)
call field_get_val_s(ivarfl(isca(icoyfp)), cvar_coyfp)
call field_get_val_s(ivarfl(isca(iscalt)), cvar_scalt)
do igg = 1, ngazgm
coefg(igg) = zero
enddo
sommqf = zero
sommq = zero
sommqt = zero
do izone = 1, nozapm
sommqf = sommqf + qimp(izone)*fment(izone)
sommqt = sommqt + qimp(izone)*tkent(izone)
sommq = sommq + qimp(izone)
enddo
if (abs(sommq).gt.epzero) then
fmelm = sommqf / sommq
tentm = sommqt / sommq
else
fmelm = zero
tentm = t0
endif
if (ippmod(icolwc).eq.1 .or. ippmod(icolwc).eq.3 &
.or. ippmod(icolwc).eq.5) then
coefg(1) = fmelm
coefg(2) = (1.d0-fmelm)
coefg(3) = zero
mode = -1
call cothht(mode, ngazg, ngazgm, coefg, npo, npot, th, ehgazg, hinit, tentm)
endif
do iel = 1, ncel
cvar_yfm(iel) = 0.0d0*fmelm
cvar_fm(iel) = 0.d0*fmelm
cvar_cyfp2m(iel) = zero
cvar_fp2m(iel) = zero
if (ippmod(icolwc).ge. 2) then
cvar_coyfp(iel) = zero
endif
if (ippmod(icolwc).eq.1 .or. ippmod(icolwc).eq.3 &
.or. ippmod(icolwc).eq.5) then
cvar_scalt(iel) = hinit
endif
enddo
write(nfecra,2000)
do ii = 1, nscapp
iscal = iscapp(ii)
ivar = isca(iscal)
call field_get_val_s(ivarfl(isca(ivar)), cvar_scal)
valmax = -grand
valmin = grand
do iel = 1, ncel
valmax = max(valmax,cvar_scal(iel))
valmin = min(valmin,cvar_scal(iel))
enddo
if ( irangp.ge.0 ) then
call parmax(valmax)
call parmin(valmin)
endif
call field_get_label(ivarfl(ivar), chaine)
write(nfecra,2010)chaine(1:8),valmin,valmax
enddo
write(nfecra,2020)
9001 format( /,&
' cs_user_initialization: variables initialization by user' ,/,&
/)
2000 format( /,&
/,&
' -----------------------------------------------------------' ,/,&
/,&
' ** INITIALIZATION OF VARIABLES FOR Libby-Williams model' ,/,&
' --------------------------------------------------------' ,/,&
' ONLY ONE PASS' ,/,&
' ---------------------------------' ,/,&
' Variable Valeur min Valeur max' ,/,&
' ---------------------------------' )
2010 format( &
2x, a8, e12.4, e12.4 )
2020 format( &
' ---------------------------------' ,/)
Finalization
At the end of the subroutine, it is recommended to deallocate the work array lstelt, like in basic example.