MFIX  2016-1
set_bc_pic_mi.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Subroutine: SET_BC_PIC_MI !
4 ! Author: R. Garg Date: 11-Jun-14 !
5 ! !
6 ! Purpose: !
7 ! !
8 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
9  SUBROUTINE set_bc_pic_mi
10 
11 !-----------------------------------------------
12 ! Modules
13 !-----------------------------------------------
14  USE compar
15  USE constant
16  USE bc
17  USE pic_bc
18  USE discretelement
19  USE funits
20  USE geometry
21  USE indices
22  USE param
23  USE param1
24  USE physprop
25  USE run
26 
27  USE error_manager
28  USE toleranc
29 
30  IMPLICIT NONE
31 
32  INTEGER :: BCV
33 
34 !-----------------------------------------------
35 ! Local variables
36 !-----------------------------------------------
37  INTEGER BCV_I ! BC loop counter
38  INTEGER M ! Mass phase loop counter
39  INTEGER PHASE_CNT ! Number of solid phases at bc
40  INTEGER PHASE_LIST(dim_m) ! List of phases used in current bc
41 
42 ! the number of particles injected in a solids time step
43  DOUBLE PRECISION MAX_DIA ! Max diameter of incoming particles at bc
44 
45  LOGICAL, parameter :: setDBG = .false.
46  LOGICAL :: dFlag
47 
48 !-----------------------------------------------
49 
50  CALL init_err_msg("SET_BC_PIC_MI")
51 
52  dflag = (dmp_log .AND. setdbg)
53  if(dflag) write(*,"(2/,2x,'PIC inlet count: ',I4)") pic_bcmi
54 
55  pic_bcmi_incl_cutcell(:) = .false.
56 
57 ! Loop over BCs that are flagged for PIC mass inflow.
58  DO bcv_i = 1, pic_bcmi
59 
60 ! Get the user defined BC ID.
61  bcv = pic_bcmi_map(bcv_i)
62 
63  pic_bcmi_offset(bcv_i,:) = 1
64  pic_bcmi_normdir(bcv_i,:) = 0
65 
66  SELECT CASE(bc_plane(bcv))
67  CASE('E'); pic_bcmi_normdir(bcv_i,1) = 1
68  CASE('W')
69  pic_bcmi_normdir(bcv_i,1) = -1
70  pic_bcmi_offset(bcv_i,1) = 0
71 
72  CASE('N'); pic_bcmi_normdir(bcv_i,2) = 1
73  CASE('S')
74  pic_bcmi_normdir(bcv_i,2) = -1
75  pic_bcmi_offset(bcv_i,2) = 0
76 
77  CASE('T'); pic_bcmi_normdir(bcv_i,3) = 1
78  CASE('B')
79  pic_bcmi_normdir(bcv_i,3) = -1
80  pic_bcmi_offset(bcv_i,3) = 0
81  END SELECT
82 
83  if(dflag) write(*,"(2/,'Setting PIC_MI:',I3)") bcv_i
84 
85 ! The number of mass phases at this inlet. While a system may be
86 ! polydisperse, the inlet could consist of a single mass phase
87  phase_cnt = 0
88 ! The mass phase indices of incoming particles at this inlet
89  phase_list(:) = -1
90 ! The max diameter of incoming particles at this inlet
91  max_dia = zero
92 
93 ! Determine if the inlet is mono or polydisperse
94  DO m=1, des_mmax+mmax
95  IF(solids_model(m) /= 'PIC') cycle
96  IF(bc_rop_s(bcv,m) == undefined) cycle
97  IF(compare(bc_rop_s(bcv,m),zero)) cycle
98  phase_cnt = phase_cnt + 1
99  phase_list(phase_cnt) = m
100  max_dia = max(max_dia,d_p0(m))
101  ENDDO
102 
103  ENDDO
104 
105  CALL set_pic_bcmi_ijk
106 
107  CALL finl_err_msg
108 
109 
110  RETURN
111  END SUBROUTINE set_bc_pic_mi
112 
113 
114 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
115 ! !
116 ! Subroutine: SET_BC_PIC !
117 ! Author: R. Garg Date: 11-Jun-14 !
118 ! !
119 ! Purpose: Check the data provided for the des mass inflow boundary !
120 ! condition and flag errors if the data is improper. This module is !
121 ! also used to convert the provided information into the format !
122 ! necessary for the dependent subrountines to function properly. !
123 ! !
124 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
125  SUBROUTINE set_pic_bcmi_ijk
127 ! Modules
128 !---------------------------------------------------------------------//
129  use bc, only: bc_plane
130  use bc, only: bc_i_w, bc_i_e, bc_j_s, bc_j_n, bc_k_b, bc_k_t
131  USE cutcell, only: cut_cell_at
132  USE discretelement, only : des_mmax
133  use error_manager
134  use functions
135  use funits, only: dmp_log
136  use mpi_utility
137  use param, only: dim_m
140  use pic_bc, only: pic_bcmi_cnp
141  use pic_bc, only: pic_bcmi_rnp
142  use pic_bc, only: pic_bcmi_incl_cutcell
143  IMPLICIT NONE
144 
145 ! Local variables
146 !---------------------------------------------------------------------//
147  INTEGER, ALLOCATABLE :: LOC_PIC_BCMI_IJK(:)
148  INTEGER :: BCV, BCV_I
149  INTEGER :: LC
150  INTEGER :: MAX_CELLS
151  INTEGER :: BND1, BND2
152  LOGICAL, parameter :: setDBG = .false.
153  LOGICAL :: dFlag
154  INTEGER :: I,J,K,IJK
155  INTEGER :: I_w, I_e, J_s, J_n, K_b, K_t
156 !......................................................................!
157 
158 
159  CALL init_err_msg("SET_PIC_BCMI_IJK")
160 
161  dflag = (dmp_log .AND. setdbg)
162 
163  if(dflag) write(*,"(2/,2x,'From: SET_PIC_BCMI_IJK')")
164 
165 ! Loop over all inflow BCs to get an approximate count of the number
166 ! of fluid cells that are adjacent to them.
167  max_cells = 0
168  DO bcv_i = 1, pic_bcmi
169  bcv = pic_bcmi_map(bcv_i)
170 
171 ! Set the search area a little bigger than the inlet area.
172  if(dflag) WRITE(*,"(/2x,'Adding cells for BCV: ',I3)") bcv
173  SELECT CASE (bc_plane(bcv))
174  CASE('N','S')
175  bnd1 = min(bc_i_e(bcv)+1,imax1) - max(bc_i_w(bcv)-1,imin1)
176  bnd2 = min(bc_k_t(bcv)+1,kmax1) - max(bc_k_b(bcv)-1,kmin1)
177 
178  CASE('E','W')
179  bnd1 = min(bc_j_n(bcv)+1,jmax1) - max(bc_j_s(bcv)-1,jmin1)
180  bnd2 = min(bc_k_t(bcv)+1,kmax1) - max(bc_k_b(bcv)-1,kmin1)
181 
182  CASE('T','B')
183  bnd1 = min(bc_i_e(bcv)+1,imax1) - max(bc_i_w(bcv)-1,imin1)
184  bnd2 = min(bc_j_n(bcv)+1,jmax1) - max(bc_j_s(bcv)-1,jmin1)
185  END SELECT
186 
187  max_cells = max_cells + (bnd1 + 1)*(bnd2 + 1)
188  if(dflag) WRITE(*,"(4x,'Plane: ',A)") bc_plane(bcv)
189  if(dflag) WRITE(*,"(4x,'Cells: ', I8)") (bnd1+1)*(bnd2+1)
190  ENDDO
191 
192  if(dflag) write(*,"(2x,'Max Cells: ',I8)") max_cells
193 
194 ! Allocate an array to hold the IJK values. This array should be
195 ! more than enough to store all the IJKs.
196  allocate( loc_pic_bcmi_ijk(max_cells) )
197 
198 
199 ! Loop over the IJKs for each BC and store only the IJKs that you
200 ! own as well as the start/end array positions for each BC.
201  lc = 1
202  DO bcv_i = 1, pic_bcmi
203 
204  pic_bcmi_ijkstart(bcv_i) = lc
205  bcv = pic_bcmi_map(bcv_i)
206 
207  if(dflag) write(*,"(/2x,'Searching for fluid cells:',I3)") bcv
208 
209  i_w = max(bc_i_w(bcv),imin1); i_e = min(bc_i_e(bcv),imax1)
210  j_s = max(bc_j_s(bcv),jmin1); j_n = min(bc_j_n(bcv),jmax1)
211  k_b = max(bc_k_b(bcv),kmin1); k_t = min(bc_k_t(bcv),kmax1)
212 
213 ! Depending on the flow plane, the 'common' index needs set to reference
214 ! the fluid cell.
215  SELECT CASE (bc_plane(bcv))
216  CASE('N'); j_s = bc_j_s(bcv)+1; j_n = bc_j_n(bcv)+1
217  CASE('S'); j_s = bc_j_s(bcv)-1; j_n = bc_j_n(bcv)-1
218  CASE('E'); i_w = bc_i_w(bcv)+1; i_e = bc_i_e(bcv)+1
219  CASE('W'); i_w = bc_i_w(bcv)-1; i_e = bc_i_e(bcv)-1
220  CASE('T'); k_b = bc_k_b(bcv)+1; k_t = bc_k_t(bcv)+1
221  CASE('B'); k_b = bc_k_b(bcv)-1; k_t = bc_k_t(bcv)-1
222  END SELECT
223 
224  if(dflag) then
225  write(*,"(4x,'Search bounds: ')")
226  write(*,"(6x,'I_w/I_e:',2(2x,I6))") i_w, i_e
227  write(*,"(6x,'J_s/J_n:',2(2x,I6))") j_s, j_n
228  write(*,"(6x,'K_b/K_t:',2(2x,I6))") k_b, k_t
229  endif
230 
231 ! Store the IJKs.
232  DO k = k_b, k_t
233  DO j = j_s, j_n
234  DO i = i_w, i_e
235 ! Skip cells that this rank does not own or are considered dead.
236 ! Limit only to fluid cells
237  IF(.NOT.is_on_mype_wobnd(i,j,k)) cycle
238  ijk = funijk(i,j,k)
239 
240  IF(.NOT.fluid_at(ijk)) cycle
241 
242  !do not include this cell if the IO BC has been set to
243  !not include cutcells
244  IF(cut_cell_at(ijk).AND.(.NOT.pic_bcmi_incl_cutcell(bcv_i))) cycle
245  loc_pic_bcmi_ijk(lc) = ijk
246  lc = lc+1
247  ENDDO
248  ENDDO
249  ENDDO
250 
251  pic_bcmi_ijkend(bcv_i) = lc-1
252 
253  IF(dflag) write(*,1111) bcv, bcv_i, &
254  pic_bcmi_ijkstart(bcv_i), pic_bcmi_ijkend(bcv_i)
255 
256  ENDDO
257 
258  1111 FORMAT(/2x,'PIC Mass Inflow:',/4x,'BC:',i4,3x,'MAP:',i4, &
259  /4x,'IJKSTART:',i6,/4x,'IJKEND: ',i6)
260 
261 
262 ! Allocate the global store arrary array. This changes across MPI ranks.
263  IF(lc > 1) THEN
264  allocate( pic_bcmi_ijk(lc-1) )
265  allocate(pic_bcmi_cnp(lc-1, dim_m))
266  allocate(pic_bcmi_rnp(lc-1, dim_m))
267 
268  pic_bcmi_ijk(1:lc-1) = loc_pic_bcmi_ijk(1:lc-1)
269 
270  pic_bcmi_cnp(1:lc-1,:) = 0.d0
271  pic_bcmi_rnp(1:lc-1,:) = 0.d0
272  ELSE
273  allocate( pic_bcmi_ijk(1) )
274  allocate(pic_bcmi_cnp(1,1))
275  allocate(pic_bcmi_rnp(1,1))
276 
277  pic_bcmi_ijk(1) = loc_pic_bcmi_ijk(1)
278  ENDIF
279 
280  deallocate(loc_pic_bcmi_ijk)
281 
282  CALL finl_err_msg
283 
284  RETURN
285  END SUBROUTINE set_pic_bcmi_ijk
integer, dimension(dimension_bc) bc_k_b
Definition: bc_mod.f:70
integer pic_bcmi
Definition: pic_bc_mod.f:18
logical dmp_log
Definition: funits_mod.f:6
double precision, dimension(dim_m) d_p0
Definition: physprop_mod.f:25
subroutine finl_err_msg
logical function compare(V1, V2)
Definition: toleranc_mod.f:94
integer, dimension(dimension_bc) bc_i_w
Definition: bc_mod.f:54
integer, dimension(:), allocatable pic_bcmi_ijkstart
Definition: pic_bc_mod.f:34
integer, dimension(dimension_bc) bc_j_n
Definition: bc_mod.f:66
double precision, dimension(:,:), allocatable pic_bcmi_cnp
Definition: pic_bc_mod.f:51
integer, parameter dim_m
Definition: param_mod.f:67
subroutine set_bc_pic_mi
Definition: set_bc_pic_mi.f:10
logical, dimension(:), allocatable pic_bcmi_incl_cutcell
Definition: pic_bc_mod.f:57
integer, dimension(:), allocatable pic_bcmi_ijk
Definition: pic_bc_mod.f:37
character(len=3), dimension(dim_m) solids_model
Definition: run_mod.f:253
double precision, parameter undefined
Definition: param1_mod.f:18
character, dimension(dimension_bc) bc_plane
Definition: bc_mod.f:217
subroutine init_err_msg(CALLER)
integer, dimension(dimension_bc) bc_k_t
Definition: bc_mod.f:74
integer mmax
Definition: physprop_mod.f:19
integer, dimension(:,:), allocatable pic_bcmi_normdir
Definition: pic_bc_mod.f:40
integer, dimension(dimension_bc) bc_j_s
Definition: bc_mod.f:62
Definition: run_mod.f:13
Definition: param_mod.f:2
logical, dimension(:), allocatable cut_cell_at
Definition: cutcell_mod.f:355
integer, dimension(:), allocatable pic_bcmi_ijkend
Definition: pic_bc_mod.f:35
integer, dimension(:,:), allocatable pic_bcmi_offset
Definition: pic_bc_mod.f:47
double precision, dimension(:,:), allocatable pic_bcmi_rnp
Definition: pic_bc_mod.f:53
integer, dimension(dimension_bc) bc_i_e
Definition: bc_mod.f:58
double precision, parameter zero
Definition: param1_mod.f:27
double precision, dimension(dimension_bc, dim_m) bc_rop_s
Definition: bc_mod.f:92
Definition: bc_mod.f:23
subroutine set_pic_bcmi_ijk
integer, dimension(dimension_bc) pic_bcmi_map
Definition: pic_bc_mod.f:24