MFIX  2016-1
drag_gs_des1.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Subroutine: CALC_GS_DES1 !
4 ! Author: J.Musser Date: 21-NOV-14 !
5 ! !
6 ! Purpose: This routine is called from the DISCRETE side to calculate !
7 ! the gas-based forces acting on each particle using interpolated !
8 ! values for gas velocity, gas pressure, and gas volume fraction. !
9 ! !
10 ! Notes: !
11 ! !
12 ! F_gp is obtained from des_drag_gp subroutine is given as: !
13 ! F_GP = beta*VOL_P/EP_s where VOL_P is the particle volume. !
14 ! !
15 ! The drag force on each particle is equal to: !
16 ! D_FORCE = beta*VOL_P/EP_s*(Ug - Us) = F_GP *(Ug - Us) !
17 ! !
18 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
19  SUBROUTINE drag_gs_des1
20 
21 ! Modules
22 !---------------------------------------------------------------------//
23 ! Gas phase volume fraction
24  use fldvar, only: ep_g
25 ! Gas phase velocities
26  use fldvar, only: u_g, v_g, w_g
27 ! Function to deterine if a cell contains fluid.
28  use functions, only: fluid_at
29  use functions, only: is_normal
30 ! Flag for 3D simulatoins.
31  use geometry, only: do_k
32 ! Size of particle arrays on this processor.
33  use discretelement, only: max_pip
34 ! Flag: The fluid and discrete solids are explicitly coupled.
35  use discretelement, only: des_explicitly_coupled
36 ! IJK of fluid cell containing particles center
37  use discretelement, only: pijk
38 ! Drag force on each particle
39  use discretelement, only: f_gp
40 ! Particle velocity
41  use discretelement, only: des_vel_new
42 ! Total forces acting on particle
43  use discretelement, only: fc
44 ! Gas pressure force by fluid cell
45  use discretelement, only: p_force
46 ! Particle volume.
47  use discretelement, only: pvol
48 ! Particle drag force
49  use discretelement, only: drag_fc
50 ! Flag for MPPIC runs.
51  use mfix_pic, only: mppic
52 ! Flag to use implicit drag for MPPIC
54 ! Double precision values.
55  use param1, only: zero
56  use param, only: dimension_3
57 ! Flag to use interpolation
59 ! Interpolation cells and weights
61 ! Model B momentum equation
62  use run, only: model_b
63  use param, only: dimension_3
64  use compar
65  IMPLICIT NONE
66 
67 ! Local variables
68 !---------------------------------------------------------------------//
69 ! Cell-center gas velocities.
70  DOUBLE PRECISION :: UGC(dimension_3)
71  DOUBLE PRECISION :: VGC(dimension_3)
72  DOUBLE PRECISION :: WGC(dimension_3)
73 ! Loop counters: Particle, fluid cell, neighbor cells
74  INTEGER :: NP, IJK, LC
75 ! Interpolation weight
76  DOUBLE PRECISION :: WEIGHT
77 ! Interpolated gas phase quantities and particle velocity.
78  DOUBLE PRECISION :: lEPg, VELFP(3), lPF(3), vel_p(3)
79 ! Drag force acting on each particle.
80  DOUBLE PRECISION :: D_FORCE(3)
81 ! Flag for Model A momentum equation
82  LOGICAL :: MODEL_A
83 ! Loop bound for filter
84  INTEGER :: LP_BND
85 !......................................................................!
86 
87 ! Set flag for Model A momentum equation.
88  model_a = .NOT.model_b
89 ! Loop bounds for interpolation.
90  lp_bnd = merge(27,9,do_k)
91 
92 ! Calculate the cell center gas velocities.
93  CALL calc_cell_center_gas_vel(u_g, v_g, w_g, ugc, vgc, wgc)
94 
95 ! Calculate the gas phase forces acting on each particle.
96 
97 !$omp parallel default(none) private(np,lepg,velfp,ijk,weight,lpf,d_force,vel_p) &
98 !$omp shared(max_pip,des_interp_on,lp_bnd,filter_cell,filter_weight, &
99 !$omp ep_g,pijk,des_vel_new,f_gp,mppic,ugc,vgc,wgc,p_force, &
100 !$omp des_explicitly_coupled,drag_fc,mppic_pdrag_implicit,fc,model_a,pvol)
101 !$omp do
102  DO np=1,max_pip
103  IF(.NOT.is_normal(np)) cycle
104 
105  lepg = zero
106  velfp = zero
107  lpf = zero
108 
109 ! Calculate the gas volume fraction, velocity, and pressure force at
110 ! the particle's position.
111  IF(des_interp_on) THEN
112  DO lc=1,lp_bnd
113  ijk = filter_cell(lc,np)
114  weight = filter_weight(lc,np)
115 ! Gas phase volume fraction.
116  lepg = lepg + ep_g(ijk)*weight
117 ! Gas phase velocity.
118  velfp(1) = velfp(1) + ugc(ijk)*weight
119  velfp(2) = velfp(2) + vgc(ijk)*weight
120  velfp(3) = velfp(3) + wgc(ijk)*weight
121 ! Gas pressure force.
122  lpf = lpf + p_force(:,ijk)*weight
123  ENDDO
124  ELSE
125  ijk = pijk(np,4)
126  lepg = ep_g(ijk)
127  velfp(1) = ugc(ijk)
128  velfp(2) = vgc(ijk)
129  velfp(3) = wgc(ijk)
130  lpf = p_force(:,ijk)
131  ENDIF
132 
133 ! Avoid drag calculations in cells without fluid (cut-cell)
134  IF(.NOT.fluid_at(pijk(np,4))) THEN
135  drag_fc(np,:) = 0.0d0
136  f_gp(np) = 0.0d0
137 
138 ! For explicit coupling, use the drag coefficient calculated for the
139 ! gas phase drag calculations.
140  ELSEIF(des_explicitly_coupled) THEN
141  drag_fc(np,:) = f_gp(np)*(velfp - des_vel_new(np,:))
142  ELSE
143 
144 ! Calculate the drag coefficient.
145  vel_p = des_vel_new(np,:)
146  CALL des_drag_gp(np, vel_p, velfp, lepg)
147 
148 ! Calculate the gas-solids drag force on the particle
149  IF(mppic .AND. mppic_pdrag_implicit) THEN
150 ! implicit treatment of the drag term for mppic
151  d_force = f_gp(np)*velfp
152  ELSE
153 ! default case
154  d_force = f_gp(np)*(velfp - des_vel_new(np,:))
155  ENDIF
156 
157 ! Update the contact forces (FC) on the particle to include gas
158 ! pressure and gas-solids drag
159  fc(np,:) = fc(np,:) + d_force(:)
160  IF(model_a) fc(np,:) = fc(np,:) + lpf*pvol(np)
161 
162  ENDIF
163 
164  ENDDO
165 !$omp end parallel
166 
167  RETURN
168  END SUBROUTINE drag_gs_des1
169 
170 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
171 ! !
172 ! Subroutine: DRAG_GS_GAS1 !
173 ! Author: J.Musser Date: 21-NOV-14 !
174 ! !
175 ! !
176 ! Purpose: This routine is called from the CONTINUUM. It calculates !
177 ! the scalar cell center drag force acting on the fluid using !
178 ! interpolated values for the gas velocity and volume fraction. The !
179 ! The resulting sources are interpolated back to the fluid grid. !
180 ! !
181 ! NOTE: The loop over particles includes ghost particles so that MPI !
182 ! communications are needed to distribute overlapping force between !
183 ! neighboring grid cells. This is possible because only cells "owned" !
184 ! by the current process will have non-zero weights. !
185 ! !
186 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
187  SUBROUTINE drag_gs_gas1
189 ! Flag: The fluid and discrete solids are explicitly coupled.
190  use discretelement, only: des_explicitly_coupled
191 ! Size of particle array on this process.
192  use discretelement, only: max_pip
193 ! IJK of fluid cell containing particles center
194  use discretelement, only: pijk
195 ! Drag force on each particle
196  use discretelement, only: f_gp
197 ! Particle velocity
198  use discretelement, only: des_vel_new
199 ! Contribution to gas momentum equation due to drag
200  use discretelement, only: drag_bm
201 ! Scalar cell center total drag force
202  use discretelement, only: f_gds
203 ! Gas phase volume fraction
204  use fldvar, only: ep_g
205 ! Gas phase velocities
206  use fldvar, only: u_g, v_g, w_g
207  use fldvar, only: u_go, v_go, w_go
208  use functions, only: fluid_at
209  use functions, only: is_normal
210 ! Volume of scalar cell.
211  use geometry, only: vol
212 ! Flag for 3D simulatoins.
213  use geometry, only: do_k
214 ! Flag for MPPIC runs
215  use mfix_pic, only: mppic
216 ! Statical weight of each MPPIC parcel
217  use mfix_pic, only: des_stat_wt
218 ! Double precision values.
219  use param1, only: zero, one
220 ! Flag to use interpolation
221  use particle_filter, only: des_interp_on
222 ! Interpolation cells and weights
224 ! Array size for fluid variables
225  use param, only: dimension_3
226 ! MPI function for collecting interpolated data from ghost cells.
227  use sendrecvnode, only: des_collect_gdata
228 ! MPI wrapper for halo exchange.
229  use sendrecv, only: send_recv
230 
231  IMPLICIT NONE
232 
233 ! Local variables
234 !---------------------------------------------------------------------//
235 ! Cell-center gas velocities.
236  DOUBLE PRECISION :: UGC(dimension_3)
237  DOUBLE PRECISION :: VGC(dimension_3)
238  DOUBLE PRECISION :: WGC(dimension_3)
239 ! Loop counters: Particle, fluid cell, neighbor cells
240  INTEGER :: NP, IJK, LC
241 ! Interpolation weight
242  DOUBLE PRECISION :: WEIGHT
243 ! Interpolated gas phase quantities and particle velocity
244  DOUBLE PRECISION :: lEPg, VELFP(3), vel_p(3)
245 ! Loop bound for filter
246  INTEGER :: LP_BND
247 ! Drag force (intermediate calculation)
248  DOUBLE PRECISION :: lFORCE
249 ! Drag sources for fluid (intermediate calculation)
250  DOUBLE PRECISION :: lDRAG_BM(3)
251 !......................................................................!
252 
253 ! Initialize fluid cell values.
254  f_gds = zero
255  drag_bm = zero
256 
257 ! Loop bounds for interpolation.
258  lp_bnd = merge(27,9,do_k)
259 
260 ! Calculate the cell center gas velocities.
261  CALL calc_cell_center_gas_vel(u_g, v_g, w_g, ugc, vgc, wgc)
262 
263 ! Calculate the gas phase forces acting on each particle.
264 
265 !$omp parallel default(none) private(np,lepg,velfp,ijk,weight,ldrag_bm,lforce,vel_p) &
266 !$omp shared(max_pip,des_interp_on,lp_bnd,filter_cell,filter_weight, &
267 !$omp ep_g,pijk,des_vel_new,f_gp,vol,des_stat_wt,mppic,drag_bm,f_gds,ugc,vgc,wgc)
268 !$omp do
269  DO np=1,max_pip
270 
271  IF(.NOT.is_normal(np)) cycle
272  IF(.NOT.fluid_at(pijk(np,4))) cycle
273 
274  lepg = zero
275  velfp = zero
276 
277 ! Calculate the gas volume fraction, velocity, and at the
278 ! particle's position.
279  IF(des_interp_on) THEN
280  DO lc=1,lp_bnd
281  ijk = filter_cell(lc,np)
282  weight = filter_weight(lc,np)
283 ! Gas phase volume fraction.
284  lepg = lepg + ep_g(ijk)*weight
285 ! Gas phase velocity.
286  velfp(1) = velfp(1) + ugc(ijk)*weight
287  velfp(2) = velfp(2) + vgc(ijk)*weight
288  velfp(3) = velfp(3) + wgc(ijk)*weight
289  ENDDO
290  ELSE
291  ijk = pijk(np,4)
292  lepg = ep_g(ijk)
293  velfp(1) = ugc(ijk)
294  velfp(2) = vgc(ijk)
295  velfp(3) = wgc(ijk)
296  ENDIF
297 
298 ! This avoids FP exceptions for some ghost particles.
299  IF(lepg == zero) lepg = ep_g(pijk(np,4))
300 
301 ! Calculate drag coefficient
302  vel_p = des_vel_new(np,:)
303  CALL des_drag_gp(np, vel_p, velfp, lepg)
304 
305  lforce = f_gp(np)
306  IF(mppic) lforce = lforce*des_stat_wt(np)
307 
308  ldrag_bm = lforce*des_vel_new(np,:)
309 
310  IF(des_interp_on) THEN
311  DO lc=1,lp_bnd
312  ijk = filter_cell(lc,np)
313  weight = filter_weight(lc,np)/vol(ijk)
314 
315 !$omp atomic
316  drag_bm(ijk,1) = drag_bm(ijk,1) + ldrag_bm(1)*weight
317 !$omp atomic
318  drag_bm(ijk,2) = drag_bm(ijk,2) + ldrag_bm(2)*weight
319 !$omp atomic
320  drag_bm(ijk,3) = drag_bm(ijk,3) + ldrag_bm(3)*weight
321 !$omp atomic
322  f_gds(ijk) = f_gds(ijk) + lforce*weight
323  ENDDO
324  ELSE
325  ijk = pijk(np,4)
326  weight = one/vol(ijk)
327 
328 !$omp atomic
329  drag_bm(ijk,1) = drag_bm(ijk,1) + ldrag_bm(1)*weight
330 !$omp atomic
331  drag_bm(ijk,2) = drag_bm(ijk,2) + ldrag_bm(2)*weight
332 !$omp atomic
333  drag_bm(ijk,3) = drag_bm(ijk,3) + ldrag_bm(3)*weight
334 
335 !$omp atomic
336  f_gds(ijk) = f_gds(ijk) + lforce*weight
337  ENDIF
338 
339  ENDDO
340 !$omp end parallel
341 
342 
343 ! Add in data stored in ghost cells from interpolation. This call must
344 ! preceed the SEND_RECV to avoid overwriting ghost cell data.
345  IF(des_interp_on) THEN
346  CALL des_collect_gdata(f_gds)
347  CALL des_collect_gdata(drag_bm)
348  ENDIF
349 
350 ! Update the drag force and sources in ghost layers.
351  CALL send_recv(f_gds, 2)
352  CALL send_recv(drag_bm, 2)
353 
354  RETURN
355  END SUBROUTINE drag_gs_gas1
356 
357 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
358 ! !
359 ! Subroutine: CALC_CELL_CENTER_GAS_VEL !
360 ! Author: J.Musser Date: 07-NOV-14 !
361 ! !
362 ! Purpose: Calculate the scalar cell center gas velocity. This code !
363 ! is common to the DEM and GAS calls for non-interpolated drag !
364 ! routines. !
365 ! !
366 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
367  SUBROUTINE calc_cell_center_gas_vel(lUg, lVg, lWg, UGC, VGC, WGC)
369 ! Modules
370 !---------------------------------------------------------------------//
371 ! Fluid grid loop bounds.
372  use compar, only: ijkstart3, ijkend3
373 ! Flags and correction factors for cut momentum cells.
377 ! Functions to average momentum to scalar cell center.
378  use fun_avg, only: avg_x_e, avg_y_n, avg_z_t
379 ! Functions to lookup adjacent cells by index.
380  use functions, only: im_of, jm_of, km_of
381 ! Function to deterine if a cell contains fluid.
382  use functions, only: fluid_at
383 ! Flag for 3D simulatoins.
384  use geometry, only: do_k
385  use indices, only: i_of
386 ! Double precision parameters.
387  use param, only: dimension_3
388  use param1, only: zero
389 
390  IMPLICIT NONE
391 
392 ! Dummy arguments
393 !---------------------------------------------------------------------//
394  DOUBLE PRECISION, INTENT(IN) :: lUg(dimension_3)
395  DOUBLE PRECISION, INTENT(IN) :: lVg(dimension_3)
396  DOUBLE PRECISION, INTENT(IN) :: lWg(dimension_3)
397  DOUBLE PRECISION, INTENT(OUT) :: UGC(dimension_3)
398  DOUBLE PRECISION, INTENT(OUT) :: VGC(dimension_3)
399  DOUBLE PRECISION, INTENT(OUT) :: WGC(dimension_3)
400 ! Local variables:
401 !---------------------------------------------------------------------//
402 ! Indices of adjacent cells
403  INTEGER :: IJK, IMJK, IJMK, IJKM
404 !......................................................................!
405 
406 
407 ! Calculate the cell center gas velocity components.
408  DO ijk=ijkstart3, ijkend3
409  IF(fluid_at(ijk)) THEN
410  imjk = im_of(ijk)
411  IF(cut_u_treatment_at(imjk)) THEN
412  ugc(ijk) = (theta_ue_bar(imjk)*lug(imjk) + &
413  theta_ue(imjk)*lug(ijk))
414  ELSE
415  ugc(ijk) = avg_x_e(lug(imjk),lug(ijk),i_of(ijk))
416  ENDIF
417 
418  ijmk = jm_of(ijk)
419  IF(cut_v_treatment_at(ijmk)) THEN
420  vgc(ijk) = (theta_vn_bar(ijmk)*lvg(ijmk) + &
421  theta_vn(ijmk)*lvg(ijk))
422  ELSE
423  vgc(ijk) = avg_y_n(lvg(ijmk),lvg(ijk))
424  ENDIF
425 
426  IF(do_k) THEN
427  ijkm = km_of(ijk)
428  IF(cut_w_treatment_at(ijkm)) THEN
429  wgc(ijk) = (theta_wt_bar(ijkm)*lwg(ijkm) + &
430  theta_wt(ijkm)* lwg(ijk))
431  ELSE
432  wgc(ijk) = avg_z_t(lwg(ijkm),lwg(ijk))
433  ENDIF
434  ELSE
435  wgc(ijk) = zero
436  ENDIF
437  ELSE
438  ugc(ijk) = zero
439  vgc(ijk) = zero
440  wgc(ijk) = zero
441  ENDIF
442  ENDDO
443 
444  RETURN
445  END SUBROUTINE calc_cell_center_gas_vel
integer, dimension(:), allocatable i_of
Definition: indices_mod.f:45
integer ijkend3
Definition: compar_mod.f:80
integer, dimension(:,:), allocatable filter_cell
double precision, dimension(:), allocatable ep_g
Definition: fldvar_mod.f:15
double precision, parameter one
Definition: param1_mod.f:29
integer dimension_3
Definition: param_mod.f:11
subroutine drag_gs_gas1
Definition: drag_gs_des1.f:188
logical mppic_pdrag_implicit
Definition: mfix_pic_mod.f:78
subroutine des_drag_gp(NP, PARTICLE_VEL, FLUID_VEL, EPg)
Definition: drag_gp_des.f:21
double precision, dimension(:), allocatable theta_wt
Definition: cutcell_mod.f:293
double precision, dimension(:), allocatable v_go
Definition: fldvar_mod.f:102
logical, dimension(:), allocatable cut_u_treatment_at
Definition: cutcell_mod.f:350
double precision, dimension(:), allocatable u_go
Definition: fldvar_mod.f:90
double precision, dimension(:), allocatable theta_wt_bar
Definition: cutcell_mod.f:294
double precision, dimension(:,:), allocatable filter_weight
double precision, dimension(:), allocatable theta_vn_bar
Definition: cutcell_mod.f:252
double precision, dimension(:), allocatable theta_vn
Definition: cutcell_mod.f:251
double precision, dimension(:), allocatable v_g
Definition: fldvar_mod.f:99
double precision, dimension(:), allocatable theta_ue
Definition: cutcell_mod.f:210
double precision, dimension(:), allocatable w_g
Definition: fldvar_mod.f:111
Definition: run_mod.f:13
double precision, dimension(:), allocatable w_go
Definition: fldvar_mod.f:114
Definition: param_mod.f:2
logical, dimension(:), allocatable cut_w_treatment_at
Definition: cutcell_mod.f:352
logical do_k
Definition: geometry_mod.f:30
double precision, dimension(:), allocatable theta_ue_bar
Definition: cutcell_mod.f:211
logical, dimension(:), allocatable cut_v_treatment_at
Definition: cutcell_mod.f:351
integer ijkstart3
Definition: compar_mod.f:80
double precision, dimension(:), allocatable u_g
Definition: fldvar_mod.f:87
logical model_b
Definition: run_mod.f:88
logical mppic
Definition: mfix_pic_mod.f:14
double precision, dimension(:), allocatable vol
Definition: geometry_mod.f:212
double precision, dimension(:), allocatable des_stat_wt
Definition: mfix_pic_mod.f:54
subroutine drag_gs_des1
Definition: drag_gs_des1.f:20
subroutine calc_cell_center_gas_vel(lUg, lVg, lWg, UGC, VGC, WGC)
Definition: drag_gs_des1.f:368
double precision, parameter zero
Definition: param1_mod.f:27