MFIX  2016-1
set_bc_dem_mo.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Subroutine: SET_BC_DEM_MO !
4 ! !
5 ! !
6 ! Author: J.Musser Date: 23-Nov-09 !
7 ! !
8 ! Comments: !
9 ! !
10 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
11  SUBROUTINE set_bc_dem_mo
12 
13  use bc, only: bc_plane
14  use bc, only: bc_x_w, bc_x_e, bc_y_s, bc_y_n, bc_z_b, bc_z_t
15 
18 
19  use funits, only: dmp_log
20 
21  use mpi_utility
22  use error_manager
23  use functions
24 
25  use desgrid, only: dg_funijk
26  use desgrid, only: iofpos, jofpos, kofpos
28 
29  IMPLICIT NONE
30 
31 !-----------------------------------------------
32 ! Local variables
33 !-----------------------------------------------
34  INTEGER :: BCV, BCV_I ! BC loop counter
35 
36  INTEGER :: LC
37 
38  LOGICAL, parameter :: setDBG = .false.
39  LOGICAL :: dFlag
40 
41  INTEGER :: MAX_CELLS, BND1, BND2
42 
43  INTEGER, ALLOCATABLE :: LOC_DEM_BCMO_IJK(:)
44 
45  INTEGER :: I,J,K,IJK
46  INTEGER :: I_w, I_e, J_s, J_n, K_b, K_t
47 
48  CALL init_err_msg("SET_BC_DEM_MO")
49 
50 
51 ! Initialize the data structures:
52  allocate( dem_bcmo_ijkstart(dem_bcmo) )
53  allocate( dem_bcmo_ijkend(dem_bcmo) )
54 
56  dem_bcmo_ijkend = -1
57 
58  dflag = (dmp_log .AND. setdbg)
59  if(dflag) write(*,"(2/,2x,'DEM outlet count: ',I4)") dem_bcmo
60 
61 ! Loop over the outflow BCs to get an approximate count of the number
62 ! of fluid cells that are adjacent to the outlet.
63  max_cells = 0
64  DO bcv_i = 1, dem_bcmo
65  bcv = dem_bcmo_map(bcv_i)
66 
67 ! Set the search area to the dimensions of the inlet.
68  if(dflag) WRITE(*,"(/2x,'Adding cells for BCV: ',I3)") bcv
69  SELECT CASE (bc_plane(bcv))
70  CASE('N','S')
71  bnd1 = iofpos(bc_x_e(bcv)) - iofpos(bc_x_w(bcv))
72  bnd2 = kofpos(bc_z_t(bcv)) - kofpos(bc_z_b(bcv))
73 
74  CASE('E','W')
75  bnd1 = jofpos(bc_y_n(bcv)) - jofpos(bc_y_s(bcv))
76  bnd2 = kofpos(bc_z_t(bcv)) - kofpos(bc_z_b(bcv))
77 
78  CASE('T','B')
79  bnd1 = iofpos(bc_x_e(bcv)) - iofpos(bc_x_w(bcv))
80  bnd2 = jofpos(bc_y_n(bcv)) - jofpos(bc_y_s(bcv))
81  END SELECT
82 
83  max_cells = max_cells + &
84  2*(bnd1+1)*(bnd2+1) + 2*(bnd1+2) + 2*(bnd2+2)
85 
86  if(dflag) WRITE(*,"(4x,'Plane: ',A)") bc_plane(bcv)
87  if(dflag) WRITE(*,"(4x,'Cells: ', I8)") (bnd1+1)*(bnd2+1)
88  ENDDO
89 
90  if(dflag) write(*,"(2x,'Max Cells: ',I8)") max_cells
91 
92 ! Allocate an array to hold the IJK values. This array should be
93 ! more than enough to store all the IJKs.
94  allocate( loc_dem_bcmo_ijk(max_cells) )
95 
96 ! Loop over the IJKs for each BC and store only the IJKs that you
97 ! own as well as the start/end array positions for each BC.
98  lc = 1
99  DO bcv_i = 1, dem_bcmo
100 
101  dem_bcmo_ijkstart(bcv_i) = lc
102  bcv = dem_bcmo_map(bcv_i)
103 
104  if(dflag) write(*,"(/2x,'Searching for fluid cells:',I3)") bcv
105 
106  i_w = iofpos(bc_x_w(bcv)); i_e = iofpos(bc_x_e(bcv))
107  j_s = jofpos(bc_y_s(bcv)); j_n = jofpos(bc_y_n(bcv))
108  IF(do_k) THEN
109  k_b = kofpos(bc_z_b(bcv)); k_t = kofpos(bc_z_t(bcv))
110  ELSE
111  k_b = 1; k_t = 1
112  ENDIF
113 
114 ! Depending on the flow plane, the 'common' index needs shifted to
115 ! reference the fluid cell.
116  SELECT CASE (bc_plane(bcv))
117  CASE('N'); j_s = j_s+1; j_n = j_s
118  CASE('S'); j_s = j_s-1; j_n = j_s
119  CASE('E'); i_w = i_w+1; i_e = i_w
120  CASE('W'); i_w = i_w-1; i_e = i_w
121  CASE('T'); k_b = k_b+1; k_t = k_b
122  CASE('B'); k_b = k_b-1; k_t = k_b
123  END SELECT
124 
125  if(dflag) then
126  write(*,"(4x,'Search bounds: ')")
127  write(*,"(6x,'I_w/I_e:',2(2x,I6))") i_w, i_e
128  write(*,"(6x,'J_s/J_n:',2(2x,I6))") j_s, j_n
129  write(*,"(6x,'K_b/K_t:',2(2x,I6))") k_b, k_t
130  endif
131 
132 ! Store the IJKs.
133  DO k = k_b, k_t
134  DO j = j_s, j_n
135  DO i = i_w, i_e
136 ! Skip cells that this rank does not own or are considered dead.
137  IF(.NOT.dg_is_on_mype_plus1layers(i,j,k))cycle
138 
139  ijk = dg_funijk(i,j,k)
140  loc_dem_bcmo_ijk(lc) = ijk
141  lc = lc+1
142  ENDDO
143  ENDDO
144  ENDDO
145 
146  if(dflag) write(*,"(/2x,'Adding boundary cells:',I3)") bcv
147 
148  i_w = iofpos(bc_x_w(bcv))-1; i_e = iofpos(bc_x_e(bcv))+1
149  j_s = jofpos(bc_y_s(bcv))-1; j_n = jofpos(bc_y_n(bcv))+1
150 
151  IF(do_k) THEN
152  k_b = kofpos(bc_z_b(bcv))-1; k_t = kofpos(bc_z_t(bcv))+1
153  ELSE
154  k_b = 1; k_t = 1
155  ENDIF
156 
157 ! Depending on the flow plane, the 'common' index needs shifted to
158 ! reference the fluid cell.
159  SELECT CASE (bc_plane(bcv))
160  CASE('N','S'); j_s = j_s+1; j_n = j_n-1
161  CASE('E','W'); i_w = i_w+1; i_e = i_e-1
162  CASE('T','B'); k_b = k_b+1; k_t = k_t-1
163  END SELECT
164 
165  if(dflag) then
166  write(*,"(4x,'Search bounds: ')")
167  write(*,"(6x,'I_w/I_e:',2(2x,I6))") i_w, i_e
168  write(*,"(6x,'J_s/J_n:',2(2x,I6))") j_s, j_n
169  write(*,"(6x,'K_b/K_t:',2(2x,I6))") k_b, k_t
170  endif
171 
172 ! Store the IJKs.
173  DO k = k_b, k_t
174  DO j = j_s, j_n
175  DO i = i_w, i_e
176 ! Skip cells that this rank does not own or are considered dead.
177  IF(.NOT.dg_is_on_mype_plus1layers(i,j,k))cycle
178 
179  ijk = dg_funijk(i,j,k)
180  loc_dem_bcmo_ijk(lc) = ijk
181  lc = lc+1
182  ENDDO
183  ENDDO
184  ENDDO
185 
186  dem_bcmo_ijkend(bcv_i) = lc-1
187 
188  if(dflag) write(*,1111) bcv, bcv_i, &
189  dem_bcmo_ijkstart(bcv_i),dem_bcmo_ijkend(bcv_i)
190 
191  ENDDO
192 
193  1111 FORMAT(/2x,'DEM Mass Outflow:',/4x,'BC:',i4,3x,'MAP:',i4,&
194  /4x,'IJKSTART:',i6,/4x,'IJKEND: ',i6)
195 
196 ! Allocate the global store arrary array. This changes across MPI ranks.
197  IF(lc > 1) THEN
198  allocate( dem_bcmo_ijk(lc-1) )
199  dem_bcmo_ijk(1:lc-1) = loc_dem_bcmo_ijk(1:lc-1)
200  ELSE
201  allocate( dem_bcmo_ijk(1) )
202  dem_bcmo_ijk(1) = loc_dem_bcmo_ijk(1)
203  ENDIF
204 
205  deallocate(loc_dem_bcmo_ijk)
206 
207  CALL finl_err_msg
208 
209  RETURN
210  END SUBROUTINE set_bc_dem_mo
211 
212 
213 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
214 ! !
215 ! Module name: CHECK_DES_LE_BC !
216 ! !
217 ! Purpose: Check/set parameters for DES Lees Edeards BC. !
218 ! !
219 ! Author: J.Musser Date: 11-DEC-13 !
220 ! !
221 ! Comments: *** DES Lees Edwards BC funcionality has been lost. *** !
222 ! !
223 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
224  SUBROUTINE check_des_le_bc
226  use discretelement
227  use exit, only: mfix_exit
228  use mpi_utility
229 
230  IMPLICIT NONE
231 
232 ! Lees Edwards BC functionality has been lost in current DEM code
233  IF(des_le_bc) THEN
234  IF (des_continuum_coupled) THEN
235  WRITE(unit_log, 1064)
236  CALL mfix_exit(mype)
237  ENDIF
238  IF (des_neighbor_search .NE. 4) THEN
239  WRITE(unit_log, 1060)
240  CALL mfix_exit(mype)
241  ENDIF
242 ! not all possible shear directions are fully coded
243  IF (dimn .EQ. 2) THEN
244  IF(trim(des_le_shear_dir) .NE. 'DUDY' .AND. &
245  trim(des_le_shear_dir) .NE. 'DVDX') THEN
246  WRITE(unit_log, 1061)
247  CALL mfix_exit(mype)
248  ENDIF
249  ELSEIF(dimn.EQ.3) THEN
250  IF(trim(des_le_shear_dir) .NE. 'DUDY') THEN ! .AND. &
251 ! TRIM(DES_LE_SHEAR_DIR) .NE. 'DUDZ' .AND. &
252 ! TRIM(DES_LE_SHEAR_DIR) .NE. 'DVDX' .AND. &
253 ! TRIM(DES_LE_SHEAR_DIR) .NE. 'DVDZ' .AND. &
254 ! TRIM(DES_LE_SHEAR_DIR) .NE. 'DWDX' .AND. &
255 ! TRIM(DES_LE_SHEAR_DIR) .NE. 'DWDY') THEN
256  WRITE(unit_log, 1062)
257  CALL mfix_exit(mype)
258  ENDIF
259  ENDIF
260  IF (des_periodic_walls) THEN
261  des_periodic_walls = .false.
262  des_periodic_walls_x = .false.
263  des_periodic_walls_y = .false.
264  des_periodic_walls_z = .false.
265  WRITE(unit_log, 1063)
266  WRITE(*,1063)
267  ENDIF
268  ENDIF
269 
270  RETURN
271 
272  1060 FORMAT(/1x,70('*')//' From: CHECK_DES_DATA',/' Message: ',&
273  'Only the grid based search option is allowed when using',&
274  'using',/10x,'Lees & Edwards BC.',/1x,70('*')/)
275 
276  1061 FORMAT(/1x,70('*')//' From: CHECK_DES_DATA',/' Message: ',&
277  'Invalid option for DES_LE_SHEAR_DIR in mfix.dat. When',/10x,&
278  'DIMN=2 shear options are DUDY or DVDX',/1x,70('*')/)
279 
280  1062 FORMAT(/1x,70('*')//' From: CHECK_DES_DATA',/' Message: ',&
281  'Invalid option for DES_LE_SHEAR_DIR in mfix.dat. When',/10x,&
282  'DIMN=3 shear options are DUDY, DUDZ, DVDX, DVDZ, DWDX or',&
283  'DWDY.',/1x,70('*')/)
284 
285  1063 FORMAT(/1x,70('*')//' From: CHECK_DES_DATA',/' Message: ',&
286  'WARNING: DES_PERIODIC_WALLS set to false when DES_LE_BC.',&
287  /10x,'DES_LE_BC implies periodic walls, however, the ',&
288  'periodicity is handled',/10x, 'independently of ',&
289  'DES_PERIODIC_WALLS option and so it is shut off.',&
290  /1x,70('*')/)
291 
292  1064 FORMAT(/1x,70('*')//' From: CHECK_DES_DATA',/' Message: ',&
293  'DES_CONTINUUM_COUPLED cannot be true when using ',&
294  'DES_LE_BC.',/1x,70('*')/)
295 
296  END SUBROUTINE check_des_le_bc
double precision, dimension(dimension_bc) bc_y_n
Definition: bc_mod.f:42
logical dmp_log
Definition: funits_mod.f:6
integer, dimension(:), allocatable dem_bcmo_ijkstart
Definition: des_bc_mod.f:92
integer, dimension(:), allocatable dem_bcmo_ijk
Definition: des_bc_mod.f:95
integer, dimension(:), allocatable dem_bcmo_ijkend
Definition: des_bc_mod.f:93
logical function dg_is_on_mype_plus1layers(lI, lJ, lK)
Definition: desgrid_mod.f:403
subroutine finl_err_msg
subroutine check_des_le_bc
integer dem_bcmo
Definition: des_bc_mod.f:19
double precision, dimension(dimension_bc) bc_x_e
Definition: bc_mod.f:34
double precision, dimension(dimension_bc) bc_y_s
Definition: bc_mod.f:38
character, dimension(dimension_bc) bc_plane
Definition: bc_mod.f:217
subroutine init_err_msg(CALLER)
subroutine mfix_exit(myID, normal_termination)
Definition: exit.f:5
integer function iofpos(fpos)
Definition: desgrid_mod.f:348
Definition: exit.f:2
integer function kofpos(fpos)
Definition: desgrid_mod.f:372
double precision, dimension(dimension_bc) bc_z_b
Definition: bc_mod.f:46
double precision, dimension(dimension_bc) bc_z_t
Definition: bc_mod.f:50
integer function dg_funijk(fi, fj, fk)
Definition: desgrid_mod.f:141
integer function jofpos(fpos)
Definition: desgrid_mod.f:360
integer, dimension(dimension_bc) dem_bcmo_map
Definition: des_bc_mod.f:25
subroutine set_bc_dem_mo
Definition: set_bc_dem_mo.f:12
Definition: bc_mod.f:23
double precision, dimension(dimension_bc) bc_x_w
Definition: bc_mod.f:30