iappel = 1: Calculation of the number of cells where a mass source is imposed: ncesmp. Called once at the beginning of the calculation.
iappel = 2: Identification of the cells where a mass source term is imposed: array icesmp(ncesmp). Called once at the beginning of the calculation.
iappel = 3: Calculation of the values of the mass source terms. Called at each time step.
The equation for mass conservation becomes:
The equation for a variable becomes: discretized as
is the value of associated to the injected mass.
Two options are available:
the mass flux is injected with the local value of variable : (the equation for is therefore not modified)
the mass flux is injected with a specific value for : is specified by the user
Variables to be specified by the user
ncesmp: number of cells where a mass source term is imposed
icetsm(ieltsm): identification of the cells where a mass source term is imposed. For each cell where a mass source term is imposed (ielstm in [1;ncesmp]), icetsm(ieltsm) is the global index number of the corresponding cell (icestm(ieltsm) in [1;ncel])
smacel(ieltsm,ipr): value of the injection mass rate gamma (in ) in the ieltsm cell with mass source term
itypsm(ieltsm,ivar): type of treatment for variable ivar in the ieltsm cell with mass source term. itypsm = 0 --> injection of ivar at local value itypsm = 1 --> injection of ivar at user specified value
smacel(ieltsm,ivar): specified value for variable ivar associated to the injected mass in the ieltsm cell with a mass source term except for ivar=ipr
Remarks
if itypsm(ieltsm,ivar)=0, smacel(ieltsm,ivar) is not used
if smacel(ieltsm,ipr)<0, mass is removed from the system, therefore Code_Saturne automatically considers , whatever the values of itypsm or smacel specified by the user
if a value ivar is not linked for a mass source term is imposed, no source term will be taken into account.
if a scalar doesn't evolve following the standard equation (alternate convective field for instance), the source term set by this routine will not be correct (except in case of injection at the local value of the variable). The proper source term should be added directly in ustssc.
Idenfication of the cells:
The selection of cells where to apply the source term is based on a getcel command. For more info on the syntax of the getcel command, refer to the user manual or to the comments on the similar command getfbr in the routine cs_user_boundary_conditions.
Local variables
! Local variables
integer ieltsm
integer ifac, ii
integer ilelt, nlelt
integer izone
double precision wind, wind2
double precision dh, ustar2
double precision xkent, xeent
double precision flucel
double precision vtot , gamma
integer, allocatable, dimension(:) :: lstelt
type(var_cal_opt) :: vcopt
Initialization and finalization
The following initialization block needs to be added for the following examples:
! Allocate a temporary array for cells selection
allocate(lstelt(ncel))
At the end of the subroutine, it is recommended to deallocate the work array:
In theory Fortran 95 deallocates locally-allocated arrays automatically, but deallocating arrays in a symetric manner to their alloacation is good pratice, and avoids using a different logic C and Fortran.
First or second call
First call: iappel = 1: ncesmp: calculation of the number of cells with mass source term
Second call (if ncesmp>0): iappel = 2: icetsm: index number of cells with mass source terms
Warning
Do not use smacel in this section (it is set on the third call, iappel = 3 )
Do not use icetsm in this section on the first call (iappel=1)
This section (iappel = 1 or 2) is only accessed at the beginning of a calculation. Should the localization of the mass source terms evolve in time, the user must identify at the beginning all cells that can potentially become a mass source term.
if (iappel.eq.1.or.iappel.eq.2) then
Example 1
No mass source term (default)
ieltsm = 0
Example 2
Mass source term in the cells that have boundary face of color 3 and the cells with a coordinate X between 2.5 and 5.
In this test in two parts, one must pay attention not to count the cells twice (a cell with a boundary face of color 3 can also have a coordinate X between 2.5 and 5). One should also pay attention that, on the first call, the array icetsm doesn't exist yet. It mustn't be used outside of tests (iappel.eq.2).
Simulation of a suction (by a pump for instance) with a total rate of . The suction rate is supposed to be uniformly distributed on all the cells selected above.
Calculation of the total volume of the area where the mass source term is imposed (the case of parallel computing is taken into account with the call to parsom).
vtot = 0.d0
do ieltsm = 1, ncesmp
vtot = vtot + volume(icetsm(ieltsm))
enddo
if (irangp.ge.0) then
call parsom (vtot)
endif
The mass suction rate is (in ). It is set below, with a test for cases where . The total mass rate is calculated for verification.