MFIX  2016-1
calc_epg_des.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! Subroutine: CALC_EPG_DES !
3 ! Author: R.Garg Date: ??-???-?? !
4 ! !
5 ! Purpose: Calculate the gas phase volume fraction (and in turn the !
6 ! gas phase bulk density) from the sum of the solids volume fractions.!
7 ! !
8 ! NOTE: This routine uses a global communication to notify all ranks !
9 ! of potential errors. Therefore all ranks can call MFIX_EXIT and !
10 ! prevent dead-lock. Communications may be reduced by passing the !
11 ! flag back to the caller and combining with other error checks. !
12 ! !
13 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
14  SUBROUTINE calc_epg_des
15 
16 ! Global Variables:
17 !---------------------------------------------------------------------//
18 ! Flag: Discrete and continuum solids co-exist
19  use discretelement, only: des_continuum_coupled
20 ! Number of discrete solids phases
21  use discretelement, only: des_mmax
22 ! Global ID of particles
23  use discretelement, only: iglobal_id
24 ! Particle positions
25  use discretelement, only: des_pos_new
26 ! Number of continuum solids phases
27  use physprop, only: mmax
28 ! Number of particles in indexed fluid cell
29  use discretelement, only: pinc
30 ! List of particles in each cell.
31  use derived_types, only: pic
32 ! Gas phae volume fraction, density, and build density
33  use fldvar, only: ep_g, ro_g, rop_g
34 ! Bulk density of continuum solids phases
35  use fldvar, only: ep_s
36 ! Volume of scalar grid cell.
37  use geometry, only: vol
38 ! Flag: Status of indexed cell
39  use cutcell, only: cut_cell_at
40 ! Flag: Indexed cell contains fluid
41  USE functions, only: fluid_at
42 ! Fluid grid loop bounds.
43  use compar, only: ijkstart3, ijkend3
44 ! Flag: Fluid exists at indexed cell
45  use functions, only: fluid_at
46 ! The I, J, and K values that comprise an IJK
47  use indices, only: i_of, j_of, k_of
48 ! Rank ID of current process
49  use compar, only: mype
50 ! Global communication function to sum to all ranks.
51  use mpi_utility, only: global_all_sum
52 ! Flag for PIC simulation
53  use mfix_pic, only: mppic
54 
55 ! Global Parameters:
56 !---------------------------------------------------------------------//
57  USE param1, only: zero, one
58 
59  use error_manager
60 
61  IMPLICIT NONE
62 
63 ! Local Variables:
64 !---------------------------------------------------------------------//
65 ! Loop indices
66  INTEGER :: IJK, M, LC
67 ! Total solids volume fraction
68  DOUBLE PRECISION :: SUM_EPS
69 ! Packed
70  DOUBLE PRECISION :: PACKED_EPS
71 ! Integer Error Flag
72  INTEGER :: IER
73 !......................................................................!
74 
75 ! Initialize error flag.
76  ier = 0
77 
78 ! Set a max solids volume fraction for MPPIC. The value is arbitrarily
79 ! larger than EP_STAR. However, the value should be large enough so
80 ! that it is rarely used. This was added as a crude work around for
81 ! poor initial conditions that start cells overpacked.
82  packed_eps = merge(0.9d0, one, mppic)
83 
84 ! Calculate gas volume fraction from solids volume fraction:
85 !---------------------------------------------------------------------//
86 !$omp parallel do if(ijkend3 .ge. 2000) default(none) reduction(+:IER) &
87 !$omp shared(IJKSTART3, IJKEND3, DES_CONTINUUM_COUPLED, DES_MMAX, MMAX,&
88 !$omp EP_G, RO_G, ROP_G, MPPIC, PACKED_EPS) &
89 !$omp private(IJK, SUM_EPs, M)
90  DO ijk = ijkstart3, ijkend3
91 ! Skip wall cells.
92  IF(.NOT.fluid_at(ijk)) cycle
93 ! Initialize EP_g and the accumulator.
94  ep_g(ijk) = one
95  sum_eps = zero
96 ! Sum the DES solids volume fraction. If hybrid TFM solids contributions
97 ! will be included
98  DO m = 1, des_mmax+mmax
99  sum_eps = sum_eps + ep_s(ijk,m)
100  ENDDO
101 
102 ! Calculate the gas phase volume fraction.
103  ep_g(ijk) = one - min(packed_eps, sum_eps)
104 
105 ! Calculate the gas phase bulk density.
106  rop_g(ijk) = ro_g(ijk) * ep_g(ijk)
107 ! Flag an error if gas volume fraction is unphysical.
108  IF(des_continuum_coupled) THEN
109  IF(ep_g(ijk) <= zero .OR. ep_g(ijk) > one) ier = ier + 1
110  ENDIF
111  ENDDO
112 !omp end parallel do
113 
114 
115  CALL global_all_sum(ier)
116  IF(ier == 0) RETURN
117 
118 
119 ! Report any errors. Volume fraction errors are fatal.
120 !---------------------------------------------------------------------//
121  CALL init_err_msg("CALC_EPG_DES")
122  CALL open_pe_log(ier)
123 
124  WRITE(err_msg, 1100)
125  CALL flush_err_msg(footer=.false.)
126 
127  1100 FORMAT('Error 1100: Unphysical gas phase volume fraction ', &
128  'calculated. A .vtp',/'file will be written and the code ', &
129  'will exit. Fluid cell details:')
130 
131  DO ijk=ijkstart3, ijkend3
132  IF(.NOT.fluid_at(ijk)) cycle
133  IF(ep_g(ijk) > zero .AND. ep_g(ijk) <= one) cycle
134 
135  WRITE(err_msg,1101) trim(ival(ijk)), trim(ival(i_of(ijk))),&
136  trim(ival(j_of(ijk))), trim(ival(k_of(ijk))),ep_g(ijk), &
137  cut_cell_at(ijk), trim(ival(pinc(ijk))), vol(ijk)
138  CALL flush_err_msg(header=.false., footer=.false.)
139 
140  WRITE(err_msg,1102)
141  CALL flush_err_msg(header=.false., footer=.false.)
142  DO lc=1,pinc(ijk)
143  m=pic(ijk)%P(lc)
144  WRITE(err_msg,1103) iglobal_id(m), trim(ival( &
145  des_pos_new(m,1))), trim(ival(des_pos_new(m,2))), &
146  trim(ival(des_pos_new(m,3)))
147  CALL flush_err_msg(header=.false., footer=.false.)
148  ENDDO
149  ENDDO
150 
151  1101 FORMAT(/3x,'Fluid Cell IJK: ',a,6x,'I/J/K: (',a,',',a,',',a,')',/&
152  t6,'EP_G = ',g11.4,t30,'CUT_CELL_AT = ',l1,/t6,'PINC: ',a,t30,&
153  'VOL = ',g11.4)
154 
155  1102 FORMAT(/t6,'Global ID',t30,'Position')
156 
157  1103 FORMAT(t6,i9,3x,'(',a,', ',a,', ',a,')')
158 
159  WRITE(err_msg, 1104)
160  CALL flush_err_msg(header=.false.)
161  1104 FORMAT('This is a fatal error. A particle output file (vtp) ', &
162  'will be written',/'to aid debugging.')
163 
164  CALL write_des_data
165  CALL mfix_exit(mype)
166 
167  END SUBROUTINE calc_epg_des
integer, dimension(:), allocatable i_of
Definition: indices_mod.f:45
integer ijkend3
Definition: compar_mod.f:80
subroutine write_des_data
double precision, dimension(:), allocatable ep_g
Definition: fldvar_mod.f:15
double precision, parameter one
Definition: param1_mod.f:29
subroutine init_err_msg(CALLER)
integer, dimension(:), allocatable k_of
Definition: indices_mod.f:47
integer mmax
Definition: physprop_mod.f:19
integer, dimension(:), allocatable j_of
Definition: indices_mod.f:46
subroutine calc_epg_des
Definition: calc_epg_des.f:15
logical, dimension(:), allocatable cut_cell_at
Definition: cutcell_mod.f:355
integer mype
Definition: compar_mod.f:24
integer ijkstart3
Definition: compar_mod.f:80
character(len=line_length), dimension(line_count) err_msg
double precision function ep_s(IJK, xxM)
Definition: fldvar_mod.f:178
logical mppic
Definition: mfix_pic_mod.f:14
type(iap1), dimension(:), allocatable pic
double precision, dimension(:), allocatable vol
Definition: geometry_mod.f:212
subroutine open_pe_log(IER)
Definition: open_files.f:270
double precision, dimension(:), allocatable ro_g
Definition: fldvar_mod.f:32
double precision, dimension(:), allocatable rop_g
Definition: fldvar_mod.f:38
double precision, parameter zero
Definition: param1_mod.f:27
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)