MFIX  2016-1
set_bc_pic_mo.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Subroutine: SET_BC_PIC_MO !
4 ! !
5 ! !
6 ! Author: R.Garg Date: 23-June-14 !
7 ! !
8 ! Comments: !
9 ! !
10 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
11  SUBROUTINE set_bc_pic_mo
12 
13  use bc, only: bc_plane
14  use bc, only: bc_i_w, bc_i_e, bc_j_s, bc_j_n, bc_k_b, bc_k_t
15 
18 
19  use funits, only: dmp_log
20 
21  use mpi_utility
22  use error_manager
23  use functions
24 
25  IMPLICIT NONE
26 
27 !-----------------------------------------------
28 ! Local variables
29 !-----------------------------------------------
30  INTEGER :: BCV, BCV_I ! BC loop counter
31 
32  INTEGER :: LC
33 
34  LOGICAL, parameter :: setDBG = .false.
35  LOGICAL :: dFlag
36 
37  INTEGER :: MAX_CELLS, BND1, BND2
38 
39  INTEGER, ALLOCATABLE :: LOC_PIC_BCMO_IJK(:)
40 
41  INTEGER :: I,J,K,IJK
42  INTEGER :: I_w, I_e, J_s, J_n, K_b, K_t
43 
44  CALL init_err_msg("SET_BC_PIC_MO")
45 
46  dflag = (dmp_log .AND. setdbg)
47  if(dflag) write(*,"(2/,2x,'PIC outlet count: ',I4)") pic_bcmo
48 
49 ! Loop over the outflow BCs to get an approximate count of the number
50 ! of fluid cells that are adjacent to the outlet.
51  max_cells = 0
52  DO bcv_i = 1, pic_bcmo
53  bcv = pic_bcmo_map(bcv_i)
54 
55 ! Set the search area to the dimensions of the inlet.
56  if(dflag) WRITE(*,"(/2x,'Adding cells for BCV: ',I3)") bcv
57  SELECT CASE (bc_plane(bcv))
58  CASE('N','S')
59  bnd1 = bc_i_e(bcv) - bc_i_w(bcv)
60  bnd2 = bc_k_t(bcv) - bc_k_b(bcv)
61 
62  CASE('E','W')
63  bnd1 = bc_j_n(bcv) - bc_j_s(bcv)
64  bnd2 = bc_k_t(bcv) - bc_k_b(bcv)
65 
66  CASE('T','B')
67  bnd1 = bc_i_e(bcv) - bc_i_w(bcv)
68  bnd2 = bc_j_n(bcv) - bc_j_s(bcv)
69  END SELECT
70 
71  max_cells = max_cells + &
72  2*(bnd1+1)*(bnd2+1) + 2*(bnd1+2) + 2*(bnd2+2)
73 
74  if(dflag) WRITE(*,"(4x,'Plane: ',A)") bc_plane(bcv)
75  if(dflag) WRITE(*,"(4x,'Cells: ', I8)") (bnd1+1)*(bnd2+1)
76  ENDDO
77 
78  if(dflag) write(*,"(2x,'Max Cells: ',I8)") max_cells
79 
80 ! Allocate an array to hold the IJK values. This array should be
81 ! more than enough to store all the IJKs.
82  allocate( loc_pic_bcmo_ijk(max_cells) )
83 
84 ! Loop over the IJKs for each BC and store only the IJKs that you
85 ! own as well as the start/end array positions for each BC.
86  lc = 1
87  DO bcv_i = 1, pic_bcmo
88 
89  pic_bcmo_ijkstart(bcv_i) = lc
90  bcv = pic_bcmo_map(bcv_i)
91 
92  if(dflag) write(*,"(/2x,'Searching for fluid cells:',I3)") bcv
93 
94  i_w = bc_i_w(bcv); i_e = bc_i_e(bcv)
95  j_s = bc_j_s(bcv); j_n = bc_j_n(bcv)
96  k_b = bc_k_b(bcv); k_t = bc_k_t(bcv)
97 
98 ! Depending on the flow plane, the 'common' index needs shifted to
99 ! reference the fluid cell.
100  SELECT CASE (bc_plane(bcv))
101  CASE('N'); j_s = j_s+1; j_n = j_s
102  CASE('S'); j_s = j_s-1; j_n = j_s
103  CASE('E'); i_w = i_w+1; i_e = i_w
104  CASE('W'); i_w = i_w-1; i_e = i_w
105  CASE('T'); k_b = k_b+1; k_t = k_b
106  CASE('B'); k_b = k_b-1; k_t = k_b
107  END SELECT
108 
109  if(dflag) then
110  write(*,"(4x,'Search bounds: ')")
111  write(*,"(6x,'I_w/I_e:',2(2x,I6))") i_w, i_e
112  write(*,"(6x,'J_s/J_n:',2(2x,I6))") j_s, j_n
113  write(*,"(6x,'K_b/K_t:',2(2x,I6))") k_b, k_t
114  endif
115 
116 ! Store the IJKs.
117  DO k = k_b, k_t
118  DO j = j_s, j_n
119  DO i = i_w, i_e
120 ! Skip cells that this rank does not own or are considered dead.
121 ! Limit only to fluid cells
122  IF(.NOT.is_on_mype_wobnd(i,j,k)) cycle
123  ijk = funijk(i,j,k)
124 
125  IF(.NOT.fluid_at(ijk)) cycle
126 
127  loc_pic_bcmo_ijk(lc) = ijk
128  lc = lc+1
129  ENDDO
130  ENDDO
131  ENDDO
132 
133  pic_bcmo_ijkend(bcv_i) = lc-1
134 
135  if(dflag) write(*,1111) bcv, bcv_i, &
136  pic_bcmo_ijkstart(bcv_i),pic_bcmo_ijkend(bcv_i)
137 
138  ENDDO
139 
140  1111 FORMAT(/2x,'PIC Mass Outflow:',/4x,'BC:',i4,3x,'MAP:',i4,&
141  /4x,'IJKSTART:',i6,/4x,'IJKEND: ',i6)
142 
143 ! Allocate the global store arrary array. This changes across MPI ranks.
144  IF(lc > 1) THEN
145  allocate( pic_bcmo_ijk(lc-1) )
146  pic_bcmo_ijk(1:lc-1) = loc_pic_bcmo_ijk(1:lc-1)
147  ELSE
148  allocate( pic_bcmo_ijk(1) )
149  pic_bcmo_ijk(1) = loc_pic_bcmo_ijk(1)
150  ENDIF
151 
152  deallocate(loc_pic_bcmo_ijk)
153 
154  CALL finl_err_msg
155 
156  RETURN
157  END SUBROUTINE set_bc_pic_mo
158 
159 
integer, dimension(dimension_bc) bc_k_b
Definition: bc_mod.f:70
logical dmp_log
Definition: funits_mod.f:6
subroutine finl_err_msg
integer, dimension(dimension_bc) bc_i_w
Definition: bc_mod.f:54
integer, dimension(dimension_bc) bc_j_n
Definition: bc_mod.f:66
integer, dimension(:), allocatable pic_bcmo_ijkstart
Definition: pic_bc_mod.f:28
character, dimension(dimension_bc) bc_plane
Definition: bc_mod.f:217
subroutine set_bc_pic_mo
Definition: set_bc_pic_mo.f:12
subroutine init_err_msg(CALLER)
integer, dimension(dimension_bc) bc_k_t
Definition: bc_mod.f:74
integer, dimension(dimension_bc) bc_j_s
Definition: bc_mod.f:62
integer, dimension(dimension_bc) pic_bcmo_map
Definition: pic_bc_mod.f:25
integer, dimension(:), allocatable pic_bcmo_ijk
Definition: pic_bc_mod.f:31
integer pic_bcmo
Definition: pic_bc_mod.f:19
integer, dimension(dimension_bc) bc_i_e
Definition: bc_mod.f:58
Definition: bc_mod.f:23
integer, dimension(:), allocatable pic_bcmo_ijkend
Definition: pic_bc_mod.f:29