MFIX  2016-1
cfassign.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Subroutine: CFASSIGN C
4 ! C
5 ! Purpose: Assign the necessary values for DEM computation. For C
6 ! example: C
7 ! - assigning DEM boundaries from the values entered for C
8 ! MFIX input in mfix.datat C
9 ! - assigning DEM gravity vector from MFIX input. C
10 ! - calculating DTSOLID based on particle properties: spring C
11 ! coefficient, damping factor & mass C
12 ! C
13 ! Reviewer: Sreekanth Pannala Date: 09-Nov-06 C
14 ! C
15 ! Reviewer: Rahul Garg Date: 25-Mar-14 C
16 ! Comments: Breaking this subroutine into several subroutines for DEM C
17 ! and PIC models C
18 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
19 
20  SUBROUTINE cfassign
21 
22 !-----------------------------------------------
23 ! Modules
24 !-----------------------------------------------
25  USE param1
27  USE discretelement
28  USE mfix_pic
29  use error_manager
30 ! Flag: DEM solids present.
31  use run, only: dem_solids
32 ! Runtime flag specifying MPPIC solids
33  use run, only: pic_solids
34 
35  IMPLICIT NONE
36 !-----------------------------------------------
37 ! Local Variables
38 !-----------------------------------------------
39 
40  CALL init_err_msg("CFASSIGN")
41 
42 ! The common assignments are done in this routine.
43 ! The model spcific assignmets are moved to the specific subroutines
44 
45  grav(1) = gravity_x
46  grav(2) = gravity_y
47  grav(3) = gravity_z
48  grav_mag = sqrt(dot_product(grav,grav))
49 
50  IF(dem_solids) CALL cfassign_dem
51  IF(pic_solids) CALL cfassign_pic
52 
53 ! Finalize the error manager.
54  CALL finl_err_msg
55 
56  RETURN
57  END SUBROUTINE cfassign
58 
59 
60 
61 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
62 ! C
63 ! Subroutine: CFASSIGN_PIC C
64 ! C
65 ! Purpose: PIC related cfassign source code moved here C
66 ! example: C
67 ! - calculating DTSOLID based on particle response time C
68 ! C
69 ! C
70 ! Reviewer: Rahul Garg Date: 25-Mar-14 C
71 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
72 
73  SUBROUTINE cfassign_pic
74 
75 
76 !-----------------------------------------------
77 ! Modules
78 !-----------------------------------------------
79  USE discretelement, only: des_mmax, dtsolid
80  use param1, only: large_number
81  USE physprop, only: mu_g0, mmax, d_p0, ro_s0
82  USE mfix_pic, only : dtpic_taup, des_tau_p
84  use error_manager
85  IMPLICIT NONE
86 !-----------------------------------------------
87 ! Local Variables
88 !-----------------------------------------------
89  INTEGER :: M, MMAX_TOT
90 !-----------------------------------------------
91 
92  CALL init_err_msg("CFASSIGN_PIC")
93 
94  mmax_tot = des_mmax+mmax
95  DO m = mmax+1, mmax_tot
96 ! account for a possible offset index when using d_p0 and ro_s.
97  des_tau_p(m) = ro_s0(m)*(d_p0(m)**2.d0)/(18.d0*mu_g0)
98  WRITE(err_msg,'(/A,I2,A,G17.8)') &
99  'TAU_P FOR ', m,'th SOLID PHASE= ', des_tau_p(m)
100  CALL flush_err_msg (header = .false., footer = .false.)
101 
102  ENDDO
103 
104  dtsolid = minval(des_tau_p(mmax+1:mmax_tot))
105  dtpic_taup = dtsolid !maximum dt for point-particles based on taup
106  if(mppic_pdrag_implicit) dtpic_taup = large_number
107 
108  WRITE(err_msg, 1000) dtsolid
109  CALL flush_err_msg(header = .false.)
110 
111  1000 format('MPPIC: Point-particle ',&
112  'approximation for particle-particle and ', /, &
113  'particle-wall collisions', /, &
114  'DTSOLID based on particle time response Taup', /, &
115  'DTSOLID = ', 2x, e17.10)
116 
117 ! Finalize the error manager.
118  CALL finl_err_msg
119 
120  END SUBROUTINE cfassign_pic
121 
122 
123 
124 
125 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
126 ! C
127 ! Subroutine: CFASSIGN_DEM C
128 ! C
129 ! Purpose: DEM related cfassign source code moved here C
130 ! example: C
131 ! - calculating DTSOLID based on particle properties: spring C
132 ! coefficient, damping factor & mass C
133 ! C
134 ! C
135 ! Reviewer: Rahul Garg Date: 25-Mar-14 C
136 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
137 
138  SUBROUTINE cfassign_dem
140 
141 !-----------------------------------------------
142 ! Modules
143 !-----------------------------------------------
144  USE param1
145  USE discretelement
146  use error_manager
147  IMPLICIT NONE
148 !-----------------------------------------------
149 ! Local Variables
150 !-----------------------------------------------
151 
152  CALL init_err_msg("CFASSIGN_DEM")
153 
154 ! WRITE(ERR_MSG,'(A)') 'Setting collision model parameters for DEM'
155 ! CALL FLUSH_ERR_MSG (Footer = .false.)
156 
157 ! Finalize the error manager.
158  CALL finl_err_msg
159  END SUBROUTINE cfassign_dem
160 
161 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
162 ! subroutine: compute_volume_of_nodes C
163 ! Author: Rahul Garg C
164 ! Dare: Dec 20, 2011 C
165 ! Purpose: Due to the staggered grid, the interpolaiton of mean fields C
166 ! is always first done at the nodes (of the scalar cell) for any quantity. C
167 ! For a quantity like drag force or ep_s, one needs to assign a geometric C
168 ! volume to a node. In the past this was done on-the-fly in drag_fgs.f. C
169 ! VCELL was the variable that was used and it used to be incorrecty set to C
170 ! the volume of the scalar cell that the particle belongs to. C
171 ! This will be ok for uniform grid and will not hold for non-uniform grids.C
172 ! In addition, at the edges (in 2-D, the node volume is only half of C
173 ! the standard cell volume. And for corner (in 2-D), it is only one fourth.C
174 ! This was also done on-the-fly earlier C
175 ! But again the volume of the cell was used, which was not correct C
176 ! also not extendable to cut-cell. So this routine computes the geoemetric C
177 ! volume of the nodes. C
178 ! C
179 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
180 
181  SUBROUTINE compute_volume_of_nodes
183 !-----------------------------------------------
184 ! Modules
185 !-----------------------------------------------
186  USE param
187  USE param1
188  USE parallel
189  USE physprop
190  USE fldvar
191  USE run
192  USE geometry
193  USE indices
194  USE bc
195  USE compar
196  USE sendrecv
197  USE discretelement
198  USE cutcell
199  USE functions
200  implicit none
201 !-----------------------------------------------
202 ! Local Variables
203 !-----------------------------------------------
204 ! ijk index of fluid grid and corresponding i, j, k indices
205  integer :: ijk, iraw, jraw, kraw
206 ! i, j, k and (i+1, j+1, k+1) indices corrected for any
207 ! cyclic ghost boundaries on fluid grid
208  INTEGER :: I, J, K, ip, jp, kp
209  integer :: ipjk, ijpk, ipjpk, ijkp, ipjkp, ijpkp, ipjpkp
210 ! volume of indicated grid
211  double precision :: vol_ijk, vol_ipjk, vol_ijpk, vol_ipjpk
212  double precision :: vol_ijkp, vol_ipjkp, vol_ijpkp, vol_ipjpkp
213  double precision :: vol_node_count, vol_node_actual_count
214 ! weighting factor
215  double precision :: avg_factor
216 ! not used?
217  double precision :: vol_node_uncorr
218 !-----------------------------------------------
219 
220  avg_factor = merge(0.25d0, 0.125d0, no_k)
221 
222 ! compute the volume at the grid nodes
223 ! grid nodes start from istart2 to iend1
224  vol_node_count = merge(4., 8., no_k)
225 
226  DO ijk = ijkstart3,ijkend3
227  des_vol_node(ijk) = zero
228  iraw = i_of(ijk)
229  jraw = j_of(ijk)
230  kraw = k_of(ijk)
231 
232 
233 
234 ! start at 1 (ghost cell) and go to last fluid cell. why start at a
235 ! ghost cell and not a fluid cell?
236 ! See below
237 
238 ! Since we are interested in nodes making up the interpolation stencil,
239 ! their numbering goes from 1 to iend1.
240 ! Think of a case with IMAX = 3. Here the nodes where the interpolation will be
241 ! done will run from 1 (=istart2) to 4 (=iend1).
242  IF(iraw.LT.istart2 .OR. iraw.GT.iend1) cycle
243  IF(jraw.LT.jstart2 .OR. jraw.GT.jend1) cycle
244  IF(kraw.LT.kstart2 .OR. kraw.GT.kend1) cycle
245 
246 ! this will force indices of ghost cells on cyclic borders back to
247 ! the corresponding fluid cells. since we are using i, j, k indices and
248 ! not just a composite ijk index we need these to be shifted to account
249 ! for periodicity
250  i = imap_c(iraw)
251  j = jmap_c(jraw)
252  k = kmap_c(kraw)
253  ip = imap_c(iraw+1)
254  jp = jmap_c(jraw+1)
255 
256 ! using a function like ip_of(ijk) should work the same as getting funijk
257 ! of the shifted i, j, k indices. however, small differences will
258 ! occur on the 'edges/corners'. so retaining the latter method at this
259 ! time. see j. galvin for discussion
260  ipjk = funijk(ip,j,k)
261  ijpk = funijk(i,jp,k)
262  ipjpk = funijk(ip,jp,k)
263 
264 ! the existing variable vol(ijk) is not used here for cut-cell reasons
265 ! see r. garg for discussion
266  vol_ijk = dx(i) *dy(j) *dz(k)
267  vol_ipjk = dx(ip)*dy(j) *dz(k)
268  vol_ijpk = dx(i) *dy(jp)*dz(k)
269  vol_ipjpk = dx(ip)*dy(jp)*dz(k)
270 
271  vol_node_uncorr = avg_factor*(vol_ijk + vol_ipjk + vol_ijpk + vol_ipjpk)
272  vol_node_actual_count = vol_node_count
273 
274  IF(.NOT.fluid_at(ijk)) THEN
275  vol_node_actual_count = vol_node_actual_count - 1
276  vol_ijk = zero
277  ENDIF
278 
279  IF(.NOT.fluid_at(ipjk)) THEN
280  vol_node_actual_count = vol_node_actual_count - 1
281  vol_ipjk = zero
282  ENDIF
283 
284  IF(.NOT.fluid_at(ijpk)) THEN
285  vol_node_actual_count = vol_node_actual_count - 1
286  vol_ijpk = zero
287  ENDIF
288 
289  IF(.NOT.fluid_at(ipjpk)) THEN
290  vol_node_actual_count = vol_node_actual_count - 1
291  vol_ipjpk = zero
292  ENDIF
293 
294 ! this will have non-zero values for non-fluid cells at the
295 ! west/south/bottom borders but not for east/north/top borders?
296  des_vol_node(ijk) = avg_factor*(vol_ijk + vol_ipjk + &
297  vol_ijpk + vol_ipjpk)
298 
299  IF (do_k) THEN
300  kp = kmap_c(kraw+1)
301  ijkp = funijk(i, j, kp)
302  ipjkp = funijk(ip,j, kp)
303  ijpkp = funijk(i, jp,kp)
304  ipjpkp = funijk(ip,jp,kp)
305 
306  vol_ijkp = dx(i) *dy(j) *dz(kp)
307  vol_ipjkp = dx(ip)*dy(j) *dz(kp)
308  vol_ijpkp = dx(i) *dy(jp)*dz(kp)
309  vol_ipjpkp = dx(ip)*dy(jp)*dz(kp)
310 
311  vol_node_uncorr = avg_factor*(vol_node_uncorr + vol_ijkp + &
312  vol_ipjkp + vol_ijpkp + vol_ipjpkp)
313 
314  IF(.NOT.fluid_at(ijkp)) THEN
315  vol_node_actual_count = vol_node_actual_count - 1
316  vol_ijkp = zero
317  ENDIF
318 
319  IF(.NOT.fluid_at(ipjkp)) THEN
320  vol_node_actual_count = vol_node_actual_count - 1
321  vol_ipjkp = zero
322  ENDIF
323 
324  IF(.NOT.fluid_at(ijpkp)) THEN
325  vol_node_actual_count = vol_node_actual_count - 1
326  vol_ijpkp = zero
327  ENDIF
328 
329  IF(.NOT.fluid_at(ipjpkp)) THEN
330  vol_node_actual_count = vol_node_actual_count - 1
331  vol_ipjpkp = zero
332  ENDIF
333 
334  des_vol_node(ijk) = des_vol_node(ijk) + avg_factor*&
335  (vol_ijkp + vol_ipjpkp + vol_ijpkp + vol_ipjkp)
336 
337  ENDIF
338 
339 
340  ENDDO ! end do ijk=ijkstart3,ijkend3
341 
342  RETURN
343  RETURN
344  END SUBROUTINE compute_volume_of_nodes
345 
integer, dimension(:), allocatable jmap_c
Definition: compar_mod.f:78
logical dem_solids
Definition: run_mod.f:257
integer, dimension(:), allocatable i_of
Definition: indices_mod.f:45
integer, dimension(:), allocatable kmap_c
Definition: compar_mod.f:78
subroutine cfassign_pic
Definition: cfassign.f:74
double precision, dimension(dim_m) d_p0
Definition: physprop_mod.f:25
integer ijkend3
Definition: compar_mod.f:80
integer kend1
Definition: compar_mod.f:80
subroutine finl_err_msg
integer iend1
Definition: compar_mod.f:80
double precision gravity_z
Definition: constant_mod.f:149
logical mppic_pdrag_implicit
Definition: mfix_pic_mod.f:78
integer istart2
Definition: compar_mod.f:80
double precision gravity_y
Definition: constant_mod.f:149
subroutine cfassign
Definition: cfassign.f:21
double precision mu_g0
Definition: physprop_mod.f:62
double precision, dimension(0:dim_j) dy
Definition: geometry_mod.f:70
double precision, dimension(0:dim_k) dz
Definition: geometry_mod.f:72
integer kstart2
Definition: compar_mod.f:80
subroutine cfassign_dem
Definition: cfassign.f:139
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
integer jstart2
Definition: compar_mod.f:80
double precision, dimension(0:dim_i) dx
Definition: geometry_mod.f:68
Definition: run_mod.f:13
integer, dimension(:), allocatable imap_c
Definition: compar_mod.f:78
double precision, parameter large_number
Definition: param1_mod.f:23
Definition: param_mod.f:2
double precision dtpic_taup
Definition: mfix_pic_mod.f:70
logical no_k
Definition: geometry_mod.f:28
logical do_k
Definition: geometry_mod.f:30
double precision, dimension(dim_m) des_tau_p
Definition: mfix_pic_mod.f:61
integer ijkstart3
Definition: compar_mod.f:80
character(len=line_length), dimension(line_count) err_msg
double precision, dimension(dim_m) ro_s0
Definition: physprop_mod.f:28
double precision gravity_x
Definition: constant_mod.f:149
logical pic_solids
Definition: run_mod.f:258
subroutine compute_volume_of_nodes
Definition: cfassign.f:182
double precision, parameter zero
Definition: param1_mod.f:27
integer jend1
Definition: compar_mod.f:80
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
Definition: bc_mod.f:23