MFIX  2016-1
mod_bc_j.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Module name: MOD_BC_J(BC, I_w, J_s, J_n, K_b, PLANE) !
4 ! Author: P. Nicoletti Date: 10-DEC-91 !
5 ! !
6 ! Purpose: modify the "J" values for the b.c. plane !
7 ! !
8 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
9  SUBROUTINE mod_bc_j(BCV)
10 
11  use bc, only: bc_i_w, bc_i_e
12  use bc, only: bc_j_s, bc_j_n
13  use bc, only: bc_k_b, bc_k_t
14  use bc, only: bc_plane
15 
16  USE geometry, only: icbc_flag
17 
18  USE compar
19  USE mpi_utility
20 
21  use error_manager
22  USE functions
23 
24  IMPLICIT NONE
25 
26 ! boundary condition index
27  INTEGER, INTENT(in) :: BCV
28 
29 ! Calculated cell indices in I,J,K directions
30  INTEGER :: J_s, J_n
31  INTEGER :: I_w, K_b
32 
33  INTEGER :: OWNER
34  INTEGER :: I, K
35  INTEGER :: IJK , IJPK
36 
37  INTEGER :: IER
38  LOGICAL :: ERROR
39  INTEGER :: J_FLUID, IJK_FLUID
40  INTEGER :: J_WALL, IJK_WALL
41 
42 
43 !-----------------------------------------------
44 
45  CALL init_err_msg("MOD_BC_J")
46 
47  j_s = bc_j_s(bcv)
48  j_n = bc_j_n(bcv)
49 
50  i_w = bc_i_w(bcv)
51  k_b = bc_k_b(bcv)
52 
53 ! Establish the OWNER of the BC
54  owner = merge(mype, 0, is_on_mype_owns(i_w,j_s,k_b))
55  CALL global_all_sum(owner)
56 
57  IF(mype == owner)THEN
58 
59  ijk = funijk(i_w, j_s, k_b)
60  ijpk = funijk(i_w, j_s+1, k_b)
61 
62  IF (wall_icbc_flag(ijk) .AND. icbc_flag(ijpk)(1:1)=='.') THEN
63  j_s = j_s
64  j_n = j_n
65  bc_plane(bcv) = 'N'
66 
67  ELSE IF (wall_icbc_flag(ijpk) .AND. icbc_flag(ijk)(1:1)=='.') THEN
68  j_s = j_s + 1
69  j_n = j_n + 1
70  bc_plane(bcv) = 'S'
71 
72  ELSE
73  bc_plane(bcv) = '.'
74  ENDIF
75  ENDIF
76 
77  CALL bcast(j_s,owner)
78  CALL bcast(j_n,owner)
79  CALL bcast(bc_plane(bcv),owner)
80 
81 ! If there is an error, send IJK/IPJK to all ranks. Report and exit.
82  IF(bc_plane(bcv) == '.') THEN
83  CALL bcast(ijpk,owner)
84  CALL bcast(ijk, owner)
85 
86  WRITE(err_msg, 1100) bcv, j_s, j_n, i_w, k_b, &
87  ijk, icbc_flag(ijk), ijpk, icbc_flag(ijpk)
88  CALL flush_err_msg(abort=.true.)
89  ENDIF
90 
91  1100 FORMAT('Error 1100: Cannot locate flow plane for boundary ', &
92  'condition ',i3,'.',2/3x,'J South = ',i6,' J North = ',i6,/&
93  3x,'I West = ',i6,' K Bottom = ',i6,2/' The following ', &
94  'should conttain a wall cell and fluid cell:',/3x,'IJK ',i9, &
95  ' :: ',a3,/3x,'IJPK ',i9,' :: ',a3,2/' Maybe no IC was ', &
96  'specified for the fluid cell.')
97 
98 ! Store the new values in the global data array.
99  bc_j_s(bcv) = j_s
100  bc_j_n(bcv) = j_n
101 
102 
103  j_wall = bc_j_s(bcv)
104  j_fluid = merge(j_wall-1, j_wall+1, bc_plane(bcv)=='S')
105 
106 
107 ! First pass through all of the BC region and verify that you have
108 ! inflow/outflow specified against a wall. Flag any errors.
109  error = .false.
110  DO k = bc_k_b(bcv), bc_k_t(bcv)
111  DO i = bc_i_w(bcv), bc_i_e(bcv)
112  IF(.NOT.is_on_mype_plus2layers(i,j_fluid,k)) cycle
113  IF(.NOT.is_on_mype_plus2layers(i,j_wall, k)) cycle
114  IF(dead_cell_at(i,j_fluid,k)) cycle
115  IF(dead_cell_at(i,j_wall, k)) cycle
116 
117  ijk_wall = funijk(i,j_wall, k)
118  ijk_fluid = funijk(i,j_fluid,k)
119 
120  IF(.NOT.(wall_icbc_flag(ijk_wall) .AND. &
121  icbc_flag(ijk_fluid)(1:1)=='.')) error = .true.
122 
123  ENDDO
124  ENDDO
125 
126 
127 ! Sync up the error flag across all processes.
128  CALL global_all_or(error)
129 
130 ! If an error is detected, have each rank open a log file and write
131 ! it's own message. Otherwise, we need to send all the data back to
132 ! PE_IO and that's too much work!
133  IF(error) THEN
134 
135  CALL open_pe_log(ier)
136 
137  WRITE(err_msg, 1200) bcv
138  CALL flush_err_msg(footer=.false.)
139 
140  1200 FORMAT('Error 1200: Illegal geometry for boundary condition:',i3)
141 
142  DO k = bc_k_b(bcv), bc_k_t(bcv)
143  DO i = bc_i_w(bcv), bc_i_e(bcv)
144 
145  IF(.NOT.is_on_mype_plus2layers(i,j_fluid,k)) cycle
146  IF(.NOT.is_on_mype_plus2layers(i,j_wall, k)) cycle
147  IF(dead_cell_at(i, j_fluid,k)) cycle
148  IF(dead_cell_at(i, j_wall, k)) cycle
149 
150  ijk_wall = funijk(i,j_wall ,k)
151  ijk_fluid = funijk(i,j_fluid,k)
152 
153  IF(.NOT.(wall_icbc_flag(ijk_wall) .AND. &
154  icbc_flag(ijk_fluid)(1:1)=='.')) THEN
155 
156  WRITE(err_msg, 1201) &
157  i, j_wall, k, ijk_wall, icbc_flag(ijk_wall), &
158  i, j_fluid, k, ijk_fluid, icbc_flag(ijk_fluid)
159  CALL flush_err_msg(header=.false., footer=.false.)
160  ENDIF
161 
162  1201 FORMAT(' ',/14x,'I',7x,'J',7x,'K',7x,'IJK',4x,'FLAG',/3x, &
163  'WALL ',3(2x,i6),2x,i9,3x,a,/3x,'FLUID',3(2x,i6),2x,i9,3x,a)
164 
165  ENDDO
166  ENDDO
167 
168  WRITE(err_msg,"('Please correct the mfix.dat file.')")
169  CALL flush_err_msg(header=.false., abort=.true.)
170 
171  ENDIF
172 
173  CALL finl_err_msg
174 
175  RETURN
176  END SUBROUTINE mod_bc_j
integer, dimension(dimension_bc) bc_k_b
Definition: bc_mod.f:70
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
character(len=3), dimension(:), pointer icbc_flag
Definition: geometry_mod.f:111
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
logical, dimension(:,:,:), allocatable dead_cell_at
Definition: compar_mod.f:127
subroutine mod_bc_j(BCV)
Definition: mod_bc_j.f:10
integer, dimension(dimension_bc) bc_j_s
Definition: bc_mod.f:62
integer mype
Definition: compar_mod.f:24
character(len=line_length), dimension(line_count) err_msg
subroutine open_pe_log(IER)
Definition: open_files.f:270
integer, dimension(dimension_bc) bc_i_e
Definition: bc_mod.f:58
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
Definition: bc_mod.f:23