MFIX  2016-1
generate_particles_mod.f
Go to the documentation of this file.
2 
3  DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: particle_count
4 
5  CONTAINS
6 
7 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
8 ! C
9 ! SUBROUTINE: GENERATE_PARTICLE_CONFIG C
10 ! C
11 ! Purpose: Generate particle configuration based on maximum particle C
12 ! radius and filling from top to bottom within specified C
13 ! bounds C
14 ! C
15 ! C
16 ! Authors: Rahul Garg Date: 19-Mar-14 C
17 ! C
18 ! C
19 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
20  SUBROUTINE generate_particle_config
21 
22  use mfix_pic, only: mppic
23  use discretelement, only: pip, particles
24 ! Flag indicating that the IC region is defined.
25  use ic, only: ic_defined
26 ! Parameter for detecting unspecified values, zero, and one
27  use param1, only: one
28 ! Maximum number of initial conditions
29  use param, only: dimension_ic
30 ! IC Region gas volume fraction.
31  use ic, only: ic_ep_g
32 
33  use mpi_utility
34 
35 ! Use the error manager for posting error messages.
36 !---------------------------------------------------------------------//
37  use error_manager
38 
39  IMPLICIT NONE
40 
41  INTEGER :: ICV
42 
43 ! Initialize the error manager.
44  CALL init_err_msg("Generate_Particle_Config")
45 
46  DO icv = 1, dimension_ic
47 
48  IF(.NOT.ic_defined(icv)) cycle
49  IF(ic_ep_g(icv) == one) cycle
50 
51  IF(mppic) THEN
53  ELSE
55  ENDIF
56 
57  ENDDO
58 
59  CALL global_sum(pip,particles)
60 
61  WRITE(err_msg, 1004) particles
62  1004 FORMAT(/,'Total number of particles in the system: ',i15)
63 
64  CALL flush_err_msg(header=.false., footer=.false.)
65 
66  CALL finl_err_msg
67 
68  RETURN
69  END SUBROUTINE generate_particle_config
70 
71 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
72 ! !
73 ! SUBROUTINE: GENERATE_PARTICLE_CONFIG !
74 ! Authors: Rahul Garg Date: 21-Mar-2014 !
75 ! !
76 ! Purpose: Generate particle configuration for DEM solids for each IC !
77 ! region. Now using the particle linked lists for initial !
78 ! build !
79 ! This routine will ultimately supersede the older rouine !
80 ! that has not been deleted yet !
81 ! !
82 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
83  SUBROUTINE generate_particle_config_dem(ICV)
84 
85 ! Global Variables:
86 !---------------------------------------------------------------------//
87 ! particle radius and density
88  use discretelement, only: des_radius, ro_sol
89 ! particle position new and old
90  use discretelement, only: des_pos_new, des_pos_old
91 ! particle velocity new and old
92  use discretelement, only: des_vel_new, des_vel_old
93 ! Simulation dimension (2D/3D)
94  use discretelement, only: dimn
95 ! Number of particles in the system (current)
96  use discretelement, only: pip
97 ! Number of DEM solids phases.
98  use discretelement, only: des_mmax
99 ! Flag to use _OLD variables
100  use discretelement, only: do_old
101 ! Angular velocity
102  use discretelement, only: omega_old, omega_new, pijk
103 ! solid phase diameters and densities.
104  use physprop, only: d_p0, ro_s0, mmax
105 ! IC Region solids volume fraction.
106  use ic, only: ic_ep_s
107 
108 ! Constant: 3.14159...
109  use constant, only: pi
110 ! min and max physical co-ordinates of IC regions in each direction
111  use ic, only: ic_x_w, ic_x_e, ic_y_s, ic_y_n, ic_z_b, ic_z_t
112 ! initally specified velocity field and granular temperature
113  use ic, only: ic_u_s, ic_v_s, ic_w_s, ic_theta_m
114 ! Flag to extend the lattice distribution in a given IC to available area
115  use ic, only: ic_des_fit_to_region
116 ! Parameter for detecting unspecified values, zero, and one
117  use param1, only: undefined, undefined_i, zero, one, half
118 ! Parameter for small and large numbers
119  use param1, only: small_number, large_number
120 
121 ! to access random number generator subroutines
122  use randomno
123  use mpi_utility
124  use functions, only: set_normal
125 
126  use desgrid, only: dg_xstart, dg_ystart, dg_zstart
127  use desgrid, only: dg_xend, dg_yend, dg_zend
128 
129 ! direction wise spans of the domain and grid spacing in each direction
130  use geometry, only: xlength, ylength, zlength
131 
132  use cutcell, only : cartesian_grid
134  use run, only: solids_model
135  use des_allocate, only: particle_grow
136 
137  use desgrid, only: iofpos, jofpos, kofpos
138  use desgrid, only: dg_is_on_mype_owns
139  use toleranc, only: compare
140 
141  use discretelement, only: max_pip, max_radius, xe, yn, zt
142  use error_manager
143  use functions
144  use param, only: dim_m
146 
147  IMPLICIT NONE
148 
149 ! Dummy arguments
150 !---------------------------------------------------------------------//
151  INTEGER, INTENT(IN) :: ICV
152 
153 ! Local variables
154 !---------------------------------------------------------------------//
155 ! Starting positions in the axial directions
156  DOUBLE PRECISION :: xINIT, yINIT, zINIT
157 ! Fractor used to scale particle diameter
158  DOUBLE PRECISION :: lFAC
159 ! Particle position and velocity
160  DOUBLE PRECISION :: POS(3), VEL(3)
161 ! Number of particles in the lattice
162  INTEGER :: SEED_X, SEED_Y, SEED_Z
163 ! Loop indices phase/fluid cell
164  INTEGER :: M, MM, I, J, K, IJK, LB, UB
165 ! Loop indicies for seeding
166  INTEGER :: II, JJ, KK
167 ! Start and end bound for IC region.
168  DOUBLE PRECISION :: IC_START(3), IC_END(3)
169 ! Volume and lengths of the IC Region
170  DOUBLE PRECISION :: DOM_VOL, DOML(3)
171 ! Flag to skip the particle
172  LOGICAL :: SKIP
173 ! Diameter adjusted for space padding
174  DOUBLE PRECISION :: ADJ_DIA
175 ! Number of particles calculated from volume fracton
176  INTEGER :: rPARTS(dim_m), tPARTS
177 ! Spacing between particles.
178  DOUBLE PRECISION :: lDEL, lDX, lDY, lDZ
179 ! Flag that the setup failed to fit the particles to the IC region
180  LOGICAL :: FIT_FAILED
181 ! Number of seeded particles
182  INTEGER :: pCOUNT(dim_m), tCOUNT
183 
184  DOUBLE PRECISION :: SOLIDS_DATA(0:dim_m)
185 
186  LOGICAL :: VEL_FLUCT
187  DOUBLE PRECISION :: VEL_SIG
188  DOUBLE PRECISION, ALLOCATABLE :: randVEL(:,:)
189 
190  logical :: report = .true.
191  logical :: found
192 
193 !......................................................................!
194 
195  CALL init_err_msg("GENERATE_PARTICLE_CONFIG_DEM")
196 
197  WRITE(err_msg,"(2/,'Generating initial particle configuration:')")
198  CALL flush_err_msg(header=.false., footer=.false.)
199 
200  solids_data = zero
201  CALL get_ic_volume(icv, solids_data(0))
202 
203 ! setting particle seed spacing grid to be slightly greater than
204 ! the maximum particle diameter. seed at ~particle radii
205  lfac = 1.05d0
206 
207 ! Setup local arrays with IC region bounds.
208  ic_start(1)=ic_x_w(icv); ic_end(1)=ic_x_e(icv)
209  ic_start(2)=ic_y_s(icv); ic_end(2)=ic_y_n(icv)
210  ic_start(3)=ic_z_b(icv); ic_end(3)=ic_z_t(icv)
211 
212  doml = ic_end-ic_start
213  IF(no_k) doml(3)=dz(1)
214 
215 ! Volume of the IC region
216  dom_vol = doml(1)*doml(2)*doml(3)
217 
218  rparts=0
219  DO m=mmax+1,mmax+des_mmax
220  IF(solids_model(m) == 'DEM') THEN
221 ! Number of particles for phase M
222  rparts(m) = &
223  floor((6.0d0*ic_ep_s(icv,m)*dom_vol)/(pi*(d_p0(m)**3)))
224  ENDIF
225  ENDDO
226 
227 ! Total number of particles in this IC region.
228  tparts = sum(rparts)
229  IF(tparts == 0) RETURN
230 
231  adj_dia = 2.0d0*max_radius*lfac
232 
233 ! Attempt to seed particle throughout the IC region
234  fit_failed=.false.
235  IF(ic_des_fit_to_region(icv)) THEN
236  IF(no_k) THEN
237  ldel = (doml(1)-adj_dia)*(doml(2)-adj_dia)
238  ldel = (ldel/dble(tparts))**(1.0/2.0)
239  seed_x = max(1,ceiling((doml(1)-adj_dia)/ldel))
240  seed_y = max(1,ceiling((doml(2)-adj_dia)/ldel))
241  seed_z = 1
242  ELSE
243  ldel = (doml(1)-adj_dia)*(doml(2)-adj_dia)*(doml(3)-adj_dia)
244  ldel = (ldel/dble(tparts))**(1.0/3.0)
245  seed_x = max(1,ceiling((doml(1)-adj_dia)/ldel))
246  seed_y = max(1,ceiling((doml(2)-adj_dia)/ldel))
247  seed_z = max(1,ceiling((doml(3)-adj_dia)/ldel))
248  ENDIF
249  fit_failed=(dble(seed_x*seed_y*seed_z) < tparts)
250  ENDIF
251 
252 ! Generic filling
253  IF(.NOT.ic_des_fit_to_region(icv) .OR. fit_failed) THEN
254  seed_x = max(1,floor((ic_end(1)-ic_start(1)-adj_dia)/adj_dia))
255  seed_y = max(1,floor((ic_end(2)-ic_start(2)-adj_dia)/adj_dia))
256  seed_z = max(1,floor((ic_end(3)-ic_start(3)-adj_dia)/adj_dia))
257  ENDIF
258 
259  ldx = doml(1)/dble(seed_x)
260  ldy = doml(2)/dble(seed_y)
261  IF(do_k) THEN
262  ldz = doml(3)/dble(seed_z)
263  ELSE
264  ldz = 0.0d0
265  ENDIF
266 
267  xinit = ic_start(1)+half*ldx
268  yinit = ic_start(2)+half*ldy
269  zinit = ic_start(3)+half*ldz
270 
271  m=1
272  pcount = 0
273  tcount = 0
274 
275  vel_fluct = set_vel_fluct(icv,m)
276 
277  jj_lp: DO jj=1, seed_y
278  pos(2) = yinit + (jj-1)*ldy
279  IF(compare(pos(2),dg_ystart) .OR. compare(pos(2),dg_yend)) &
280  pos(2) = pos(2) + small_number
281 
282  kk_lp: DO kk=1, seed_z
283  pos(3) = zinit + (kk-1)*ldz
284  IF(do_k) THEN
285  IF(compare(pos(3),dg_zstart) .OR. compare(pos(3),dg_zend)) &
286  pos(3) = pos(3) + small_number
287  ENDIF
288 
289  ii_lp: DO ii=1, seed_x
290  pos(1) = xinit + (ii-1)*ldx
291  IF(compare(pos(1),dg_xstart) .OR. compare(pos(1),dg_xend)) &
292  pos(1) = pos(1) + small_number
293 
294 ! Exit if all particles were seeded.
295  IF(tcount > int(tparts)) THEN
296  EXIT jj_lp
297 ! Find the next phase that needs to be seeded
298  ELSEIF(pcount(m) > int(rparts(m))) THEN
299  mm_lp: DO mm=m+1,mmax+des_mmax
300  IF(rparts(mm) > 0.0) THEN
301  m=mm
302  EXIT mm_lp
303  ENDIF
304  ENDDO mm_lp
305  IF(m > mmax+des_mmax) EXIT jj_lp
306  vel_fluct = set_vel_fluct(icv,m)
307  ENDIF
308 
309  pcount(m) = pcount(m) + 1
310  tcount = tcount + 1
311 
312 ! Keep only particles that belong to this process.
313  IF(.NOT.dg_is_on_mype_owns(iofpos(pos(1)), &
314  jofpos(pos(2)),kofpos(pos(3)))) cycle
315 
316 ! Bin the parcel to the fuild grid.
317  k=1
318  IF(do_k) CALL pic_search(k, pos(3), zt, dimension_k, kmin2, kmax2)
319  CALL pic_search(j, pos(2), yn, dimension_j, jmin2, jmax2)
320  CALL pic_search(i, pos(1), xe, dimension_i, imin2, imax2)
321 
322 ! Skip cells that return invalid IJKs.
323  IF(dead_cell_at(i,j,k)) cycle
324 
325 ! Skip cells that are not part of the local fuild domain.
326  ijk = funijk(i,j,k)
327  IF(.NOT.fluid_at(ijk)) cycle
328 
329  IF(cartesian_grid) THEN
330  CALL check_if_particle_overlaps_stl(pos, i, j, k, skip)
331  IF(skip) cycle
332  ENDIF
333 
334  pip = pip + 1
335  CALL particle_grow(pip)
336  max_pip = max(pip,max_pip)
337 
338  CALL set_normal(pip)
339 
340  IF(vel_fluct) THEN
341  vel(1) = randvel(pcount(m),1)
342  vel(2) = randvel(pcount(m),2)
343  vel(3) = randvel(pcount(m),3)
344  ELSE
345  vel(1) = ic_u_s(icv,m)
346  vel(2) = ic_v_s(icv,m)
347  vel(3) = ic_w_s(icv,m)
348  ENDIF
349  IF(no_k) vel(3) = 0.0d0
350 
351 
352  des_pos_new(pip,:) = pos(:)
353  des_vel_new(pip,:) = vel(:)
354  omega_new(pip,:) = 0.0d0
355 
356  des_radius(pip) = d_p0(m)*half
357  ro_sol(pip) = ro_s0(m)
358 
359  pijk(pip,1) = i
360  pijk(pip,2) = j
361  pijk(pip,3) = k
362  pijk(pip,4) = ijk
363  pijk(pip,5) = m
364 
365  IF(do_old) THEN
366  des_vel_old(pip,:) = des_vel_new(pip,:)
367  des_pos_old(pip,:) = des_pos_new(pip,:)
368  omega_old(pip,:) = zero
369  ENDIF
370 
371  solids_data(m) = solids_data(m) + 1.0
372 
373  ENDDO ii_lp
374  ENDDO kk_lp
375  ENDDO jj_lp
376 
377 ! Collect the data
378  CALL global_all_sum(solids_data)
379 
380 ! Verify that the IC region volume is not zero.
381  IF(solids_data(0) <= 0.0d0) THEN
382  WRITE(err_msg,1000) icv, solids_data(0)
383  CALL flush_err_msg(abort=.true.)
384  ENDIF
385 
386 1000 FORMAT('Error 1000: Invalid IC region volume: IC=',i3,' VOL=',&
387  es15.4,/'Please correct the mfix.dat file.')
388 
389  WRITE(err_msg,2000) icv
390  CALL flush_err_msg(header=.false., footer=.false.)
391 
392  DO m=mmax+1, mmax+des_mmax
393  IF(solids_data(m) < small_number) cycle
394  WRITE(err_msg,2010) m, int(solids_data(m)), ic_ep_s(icv,m), &
395  (dble(solids_data(m))*(pi/6.0d0)*d_p0(m)**3)/solids_data(0)
396  CALL flush_err_msg(header=.false., footer=.false.)
397  ENDDO
398 
399  IF(allocated(randvel)) deallocate(randvel)
400 
401  CALL finl_err_msg
402 
403  RETURN
404 
405  2000 FORMAT(/2x,'|',43('-'),'|',/2x,'| IC Region: ',i3,28x,'|',/2x, &
406  '|',43('-'),'|',/2x,'| Phase | Number of | EPs | EP',&
407  's |',/2x,'| ID | Particles | Specified | Actual |', &
408  /2x,'|-------|',3(11('-'),'|'))
409 
410  2010 FORMAT(2x,'| ',i3,' |',1x,i9,1x,'|',2(1x,es9.2,1x,'|'),/2x, &
411  '|-------|',3(11('-'),'|'))
412 
413 
414  CONTAINS
415 
416 !......................................................................!
417 ! Function: SET_VEL_FLUCT !
418 ! Purpose: Set the flag for random velocity fluctuations. If needed !
419 ! the random velocities are calculated. !
420 !......................................................................!
421  LOGICAL FUNCTION set_vel_fluct(lICV, lM)
422  INTEGER, INTENT(IN) :: lICV, lM
423  DOUBLE PRECISION :: VEL_SIG
424  set_vel_fluct=(ic_theta_m(licv,lm) /= 0.0d0)
425  IF(set_vel_fluct) THEN
426  if(allocated(randvel)) deallocate(randvel)
427  allocate(randvel(100+int(rparts(lm)),3))
428  vel_sig = sqrt(ic_theta_m(licv,lm))
429  CALL nor_rno(randvel(:,1), ic_u_s(licv,lm),vel_sig)
430  CALL nor_rno(randvel(:,2), ic_v_s(licv,lm),vel_sig)
431  IF(do_k) CALL nor_rno(randvel(:,3),ic_w_s(licv,lm),vel_sig)
432  ENDIF
433 
434  END FUNCTION set_vel_fluct
435 
436  END SUBROUTINE generate_particle_config_dem
437 
438 
439 
440 
441 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
442 ! !
443 ! Subroutine: GENERATE_PARTICLE_CONFIG_MMPPIC !
444 ! Author: Rahul Garg Date: 3-May-2011 !
445 ! !
446 ! Purpose: Generates particle position distribution for MPPIC. !
447 ! !
448 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
449  SUBROUTINE generate_particle_config_mppic(ICV)
451 ! Global variables
452 !---------------------------------------------------------------------//
453 ! Number of DES solids phases.
454  use discretelement, only: des_mmax
455 ! Flag indicating that the IC region is defined.
456  use ic, only: ic_defined
457 ! IC Region bulk density (RO_s * EP_s)
458  use ic, only: ic_rop_s
459 ! IC Region gas volume fraction.
460  use ic, only: ic_ep_g
461 ! MPPIC specific IC region specification.
463 
464  use param1, only: undefined, undefined_i
465  use param1, only: zero, one, half
466 ! Maximum number of IC regions and solids phases
467  use param, only: dimension_ic
468  use param, only: dim_m
469  use physprop, only: mmax
470 
471 ! The accumulated number of particles in each IJK.
472  use mpi_utility, only: global_all_sum
473 
474  use error_manager
475 
476  use run, only: solids_model
477  IMPLICIT NONE
478 
479 ! Dummy arguments
480 !---------------------------------------------------------------------//
481  INTEGER, INTENT(IN) :: ICV
482 
483 ! Local variables
484 !---------------------------------------------------------------------//
485 ! Generic loop counters
486  INTEGER :: M
487 ! Actual volume of IC region
488  DOUBLE PRECISION :: IC_VOL
489 ! Solids data in IC Region by phase:
490  DOUBLE PRECISION :: SOLIDS_DATA(0:4*dim_m)
491 !......................................................................!
492 
493  CALL init_err_msg("GENERATE_PARTICLE_CONFIG_MPPIC")
494 
495  WRITE(err_msg,"(2/,'Generating initial parcel configuration:')")
496  CALL flush_err_msg(header=.false., footer=.false.)
497 
498 
499  solids_data = zero
500  CALL get_ic_volume(icv, solids_data(0))
501 
502  WRITE(err_msg,2000) icv
503  CALL flush_err_msg(header=.false., footer=.false.)
504 
505 ! Set up the individual solids phases.
506  DO m=mmax+1, des_mmax+mmax
507  IF(solids_model(m) == 'PIC') THEN
508  IF(ic_rop_s(icv,m) == zero) cycle
509 ! Seed parcels with constant stastical weight.
510  CALL gpc_mppic_const_npc(icv, m, solids_data(0), &
511  solids_data((4*m-3):(4*m)))
512  ENDIF
513  ENDDO
514 
515 ! Collect the data
516  CALL global_all_sum(solids_data)
517 
518 ! Verify that the IC region volume is not zero.
519  IF(solids_data(0) <= 0.0d0) THEN
520  WRITE(err_msg,1000) icv, solids_data(0)
521  CALL flush_err_msg(abort=.true.)
522  ENDIF
523 
524  1000 FORMAT('Error 1000: Invalid IC region volume: IC=',i3,' VOL=',&
525  es15.4,/'Please correct the mfix.dat file.')
526 
527 ! Report solids information for the IC region.
528  DO m=mmax+1, des_mmax+mmax
529  IF(solids_model(m) == 'PIC') THEN
530  WRITE(err_msg,2010) m, int(solids_data(4*m-3)),&
531  int(solids_data(4*m-3)*solids_data(4*m-2)), &
532  solids_data(4*m-2), solids_data(4*m-1), &
533  solids_data(4*m)/solids_data(0)
534  CALL flush_err_msg(header=.false., footer=.false.)
535  ENDIF
536  ENDDO
537 
538  CALL finl_err_msg
539 
540  RETURN
541 
542  2000 FORMAT(/2x,'|',67('-'),'|',/2x,'| IC Region: ',i3,52x,'|',/2x, &
543  '|',67('-'),'|',/2x,'| Phase | Num. Comp | Num. Real ', &
544  '| Stastical | EPs | EPs |',/2x,'| ID | ', &
545  'Parcels | Particles | Weight | Specified | Actual |', &
546  /2x,'|-------|',5(11('-'),'|'))
547 
548  2010 FORMAT(2x,'| ',i3,' |',2(1x,i9,1x,'|'),3(1x,es9.2,1x,'|'),/2x,&
549  '|-------|',5(11('-'),'|'))
550 
551  END SUBROUTINE generate_particle_config_mppic
552 
553 
554 
555 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
556 ! !
557 ! Subroutine: GENERATE_PARTICLE_CONFIG_MMPPIC !
558 ! Author: Rahul Garg Date: 3-May-2011 !
559 ! !
560 ! Purpose: generates particle position distribution for MPPIC !
561 ! !
562 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
563  SUBROUTINE gpc_mppic_const_npc(ICV, M, IC_VOL, sDATA)
565 ! Global variables
566 !---------------------------------------------------------------------//
567 ! Constant: 3.14159...
568  use constant, only: pi
569 ! Cut_cell identifier array
570  use cutcell, only: cut_cell_at
571  use cutcell, only : cartesian_grid
572  use discretelement, only: xe, yn, zt
573 
574  use des_allocate, only: particle_grow
575  use discretelement
576 
577 ! Flag indicating that the IC region is defined.
578  use ic, only: ic_defined
579 ! IC Region bulk density (RO_s * EP_s)
580  use ic, only: ic_ep_s
581  use ic, only: ic_i_w, ic_i_e, ic_j_s, ic_j_n, ic_k_b, ic_k_t
582 
583 ! initally specified velocity field and granular temperature
584  use ic, only: ic_u_s, ic_v_s, ic_w_s, ic_theta_m
585  use ic, only: ic_pic_const_npc
586  use ic, only: ic_pic_const_statwt
587 
588  use mfix_pic, only: des_stat_wt
589  use mpi_utility
590 
591 ! Maximum number of IC regions and solids phases
592  use param, only: dimension_ic
593  use param, only: dim_m
594  use param1, only: undefined, undefined_i, zero, one, half
595 
596 ! solid phase diameters and densities.
597  use physprop, only: d_p0, ro_s0
598  use run, only: solids_model
599 
600  use randomno
601  use error_manager
602  use functions
603  use run, only: solids_model
604  use des_allocate, only: particle_grow
605 
606  IMPLICIT NONE
607 
608 ! Dummy Arguments
609 !----------------------------------------------------------------------//
610 ! Index of IC region and solids phase
611  INTEGER, INTENT(IN) :: ICV, M
612 ! Specific volume of IC region (accounts for blocked cells)
613  DOUBLE PRECISION, INTENT(IN) :: IC_VOL
614 ! Data about solids in the IC region.
615  DOUBLE PRECISION, INTENT(OUT) :: sDATA(4)
616 
617 ! Local variables
618 !----------------------------------------------------------------------//
619  DOUBLE PRECISION :: EP_SM
620 
621 ! Number of real and comp. particles in a cell.
622  DOUBLE PRECISION :: rPARTS
623  INTEGER :: maxPARTS
624  DOUBLE PRECISION :: DOML(3), IC_START(3)
625 ! Parcel position with random
626  DOUBLE PRECISION :: POS(3)
627 ! Average velocity and standard deivation
628  DOUBLE PRECISION :: IC_VEL(3), VEL_SIG
629 ! Flag to not keep parcel.
630  LOGICAL :: SKIP
631 ! Arrasy for assigning random position and velocities
632  DOUBLE PRECISION, ALLOCATABLE :: randVEL(:,:)
633  DOUBLE PRECISION :: RAND(3)
634 ! Statistical weights
635  DOUBLE PRECISION :: STAT_WT, SUM_STAT_WT
636 ! Volume of a parcel and total solids volume
637  DOUBLE PRECISION :: sVOL, sVOL_TOT
638 ! Counter for seeded parcles.
639  INTEGER :: SEEDED
640 ! Generic loop indices and loop counters
641  INTEGER :: I, J, K, IJK, LC, LC_MAX
642 !......................................................................!
643 
644  CALL init_err_msg("GPC_MPPIC_CONST_NPC")
645 
646  maxparts=25
647  allocate(randvel(maxparts,3))
648 
649  ic_vel(1) = ic_u_s(icv,m)
650  ic_vel(2) = ic_v_s(icv,m)
651  ic_vel(3) = merge(ic_w_s(icv,m),0.0d0,do_k)
652 
653  vel_sig = sqrt(ic_theta_m(icv,m))
654 
655 ! Volume occupied by one particle
656  svol = (pi/6.0d0)*(d_p0(m)**3.d0)
657 
658  seeded = 0
659  svol_tot = 0.0d0
660  sum_stat_wt = 0.0d0
661 
662  DO k = ic_k_b(icv), ic_k_t(icv)
663  DO j = ic_j_s(icv), ic_j_n(icv)
664  DO i = ic_i_w(icv), ic_i_e(icv)
665 
666  IF(.not.is_on_mype_wobnd(i,j,k)) cycle
667  IF(dead_cell_at(i,j,k)) cycle
668 
669  ijk = funijk(i,j,k)
670  IF(.not.fluid_at(ijk)) cycle
671 
672  rparts = ic_ep_s(icv,m)*vol(ijk)/svol
673 
674 ! Seed parcels with a constant stastical weight
675  IF(ic_pic_const_statwt(icv,m) /= zero) THEN
676  stat_wt = ic_pic_const_statwt(icv,m)
677  lc_max = int(rparts/stat_wt)
678 
679 ! Seed parcels with a constant number per cell
680  ELSEIF(ic_pic_const_npc(icv,m) /= 0) THEN
681  lc_max = ic_pic_const_npc(icv,m)
682  stat_wt = rparts/dble(lc_max)
683  IF(cut_cell_at(ijk)) lc_max = max(1,int(vol(ijk)*dble(&
684  ic_pic_const_npc(icv,m))/(dx(i)*dy(j)*dz(k))))
685  ENDIF
686 
687 ! Increase particle buffer
688  IF(lc_max > maxparts) THEN
689  maxparts = 2*lc_max
690  if(allocated(randvel)) deallocate(randvel)
691  allocate(randvel(maxparts,3))
692  ENDIF
693 
694  DO lc=1, merge(2,3,no_k)
695  IF(vel_sig > zero) THEN
696  CALL nor_rno(randvel(1:lc_max,lc), ic_vel(lc), vel_sig)
697  ELSE
698  randvel(1:lc_max,lc) = ic_vel(lc)
699  ENDIF
700  ENDDO
701  IF(no_k) randvel(1:lc_max,3) = 0.0d0
702 
703  ic_start(1) = xe(i-1)
704  ic_start(2) = yn(j-1)
705  ic_start(3) = zero; IF(do_k) ic_start(3) = zt(k-1)
706 
707  doml(1) = dx(i)
708  doml(2) = dy(j)
709  doml(3) = zero; IF(do_k) doml(3) = dz(k)
710 
711  DO lc=1,lc_max
712 
713  CALL random_number(rand)
714  pos(:) = ic_start + doml*rand
715 
716  IF(cartesian_grid) THEN
717  CALL check_if_parcel_overlaps_stl(pos, skip)
718  DO WHILE(skip)
719  CALL random_number(rand)
720  pos(:) = ic_start + doml*rand
721  CALL check_if_parcel_overlaps_stl(pos, skip)
722  ENDDO
723  ENDIF
724 
725  pip = pip + 1
726  CALL particle_grow(pip)
727  max_pip = max(pip,max_pip)
728 
729  des_pos_new(pip,:) = pos(:)
730  des_vel_new(pip,:) = randvel(lc,:)
731 
732  des_radius(pip) = d_p0(m)*half
733  ro_sol(pip) = ro_s0(m)
734 
735  pijk(pip,1) = i
736  pijk(pip,2) = j
737  pijk(pip,3) = k
738  pijk(pip,4) = ijk
739  pijk(pip,5) = m
740 
741  sum_stat_wt = sum_stat_wt + stat_wt
742 
743  des_stat_wt(pip) = stat_wt
744  svol_tot = svol_tot + svol*stat_wt
745 
746  CALL set_normal(pip)
747 
748  seeded = seeded + 1
749 
750  ENDDO
751 
752  ENDDO
753  ENDDO
754  ENDDO
755 
756  IF(allocated(randvel)) deallocate(randvel)
757 
758  sdata(1) = dble(seeded)
759  sdata(2) = sum_stat_wt/dble(seeded)
760  sdata(3) = ic_ep_s(icv,m)
761  sdata(4) = svol_tot
762 
763  CALL finl_err_msg
764 
765  RETURN
766  END SUBROUTINE gpc_mppic_const_npc
767 
768 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
769 ! !
770 ! Subroutine: GET_IC_VOLUME !
771 ! Author: J.Musser Date: 26-Aug-2015 !
772 ! !
773 ! Purpose: Calculate the actual volume of the IC region. !
774 ! !
775 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
776  SUBROUTINE get_ic_volume(ICV, IC_VOL)
778 ! IC region index bounds
779  use ic, only: ic_i_w, ic_i_e
780  use ic, only: ic_j_s, ic_j_n
781  use ic, only: ic_k_b, ic_k_t
782 
783 ! Volume of computational cells.
784  use geometry, only: vol
785 
786  use functions
787  use compar, only: dead_cell_at
788 
789  IMPLICIT NONE
790 
791 ! Dummy Arguments
792 !---------------------------------------------------------------------//
793 ! Index of IC region
794  INTEGER, INTENT(IN) :: ICV
795 ! Total calculated volume of IC region
796  DOUBLE PRECISION, INTENT(OUT) :: IC_VOL
797 
798 ! Local variables
799 !---------------------------------------------------------------------//
800  INTEGER :: I, J, K, IJK
801 !......................................................................!
802 
803 
804  ic_vol = 0.0d0
805  DO k = ic_k_b(icv), ic_k_t(icv)
806  DO j = ic_j_s(icv), ic_j_n(icv)
807  DO i = ic_i_w(icv), ic_i_e(icv)
808 
809  IF(.NOT.is_on_mype_wobnd(i,j,k)) cycle
810  IF(dead_cell_at(i,j,k)) cycle
811 
812  ijk = funijk(i,j,k)
813  IF(fluid_at(ijk)) ic_vol = ic_vol + vol(ijk)
814 
815  ENDDO
816  ENDDO
817  ENDDO
818 
819  RETURN
820  END SUBROUTINE get_ic_volume
821 
822  END MODULE generate_particles
integer dimension_i
Definition: param_mod.f:7
double precision dg_xstart
Definition: desgrid_mod.f:62
integer, parameter dimension_ic
Definition: param_mod.f:59
integer, dimension(dimension_ic, dim_m) ic_pic_const_npc
Definition: ic_mod.f:142
double precision, dimension(dimension_ic, dim_m) ic_rop_s
Definition: ic_mod.f:74
double precision, dimension(dim_m) d_p0
Definition: physprop_mod.f:25
subroutine finl_err_msg
logical function compare(V1, V2)
Definition: toleranc_mod.f:94
integer, dimension(dimension_ic) ic_j_s
Definition: ic_mod.f:47
double precision, dimension(dimension_ic, dim_m) ic_theta_m
Definition: ic_mod.f:86
double precision, parameter one
Definition: param1_mod.f:29
subroutine check_if_particle_overlaps_stl(POS, fI, fJ, fK, REMOVE)
subroutine, public nor_rno(Y, mean, sigma)
Definition: randomno_mod.f:66
integer dimension_k
Definition: param_mod.f:9
integer, dimension(dimension_ic) ic_j_n
Definition: ic_mod.f:50
subroutine get_ic_volume(ICV, IC_VOL)
integer, parameter dim_m
Definition: param_mod.f:67
logical function set_vel_fluct(lICV, lM)
double precision dg_zstart
Definition: desgrid_mod.f:64
logical, dimension(dimension_ic) ic_defined
Definition: ic_mod.f:107
double precision, dimension(dimension_ic) ic_z_b
Definition: ic_mod.f:35
double precision, dimension(dimension_ic) ic_x_w
Definition: ic_mod.f:23
subroutine generate_particle_config_dem(ICV)
character(len=3), dimension(dim_m) solids_model
Definition: run_mod.f:253
double precision, parameter undefined
Definition: param1_mod.f:18
subroutine check_if_parcel_overlaps_stl(POS, OVERLAP_EXISTS)
subroutine init_err_msg(CALLER)
Definition: ic_mod.f:9
double precision, dimension(dimension_ic) ic_z_t
Definition: ic_mod.f:38
double precision, dimension(dimension_ic, dim_m) ic_w_s
Definition: ic_mod.f:104
integer, dimension(dimension_ic) ic_i_w
Definition: ic_mod.f:41
integer mmax
Definition: physprop_mod.f:19
logical, dimension(:,:,:), allocatable dead_cell_at
Definition: compar_mod.f:127
integer function iofpos(fpos)
Definition: desgrid_mod.f:348
double precision dg_xend
Definition: desgrid_mod.f:62
double precision, parameter small_number
Definition: param1_mod.f:24
integer, dimension(dimension_ic) ic_i_e
Definition: ic_mod.f:44
integer, dimension(dimension_ic) ic_k_b
Definition: ic_mod.f:53
double precision dg_zend
Definition: desgrid_mod.f:64
double precision, dimension(dimension_ic) ic_y_n
Definition: ic_mod.f:32
subroutine gpc_mppic_const_npc(ICV, M, IC_VOL, sDATA)
double precision xlength
Definition: geometry_mod.f:33
double precision, parameter half
Definition: param1_mod.f:28
Definition: run_mod.f:13
integer function kofpos(fpos)
Definition: desgrid_mod.f:372
double precision, parameter large_number
Definition: param1_mod.f:23
double precision dg_ystart
Definition: desgrid_mod.f:63
integer, dimension(dimension_ic) ic_k_t
Definition: ic_mod.f:56
Definition: param_mod.f:2
logical cartesian_grid
Definition: cutcell_mod.f:13
double precision, dimension(dimension_ic, dim_m) ic_v_s
Definition: ic_mod.f:98
double precision, dimension(dimension_ic, dim_m) ic_pic_const_statwt
Definition: ic_mod.f:147
subroutine generate_particle_config_mppic(ICV)
logical, dimension(:), allocatable cut_cell_at
Definition: cutcell_mod.f:355
double precision, dimension(dimension_ic) ic_x_e
Definition: ic_mod.f:26
integer, parameter undefined_i
Definition: param1_mod.f:19
subroutine pic_search(IDX, lPOS, ENT_POS, lDIMN, lSTART, lEND)
double precision dg_yend
Definition: desgrid_mod.f:63
character(len=line_length), dimension(line_count) err_msg
double precision, dimension(dimension_ic, dim_m) ic_u_s
Definition: ic_mod.f:92
logical, dimension(dimension_ic) ic_des_fit_to_region
Definition: ic_mod.f:137
double precision, dimension(:), allocatable particle_count
double precision, dimension(dimension_ic) ic_ep_g
Definition: ic_mod.f:62
logical function dg_is_on_mype_owns(lI, lJ, lK)
Definition: desgrid_mod.f:385
integer function jofpos(fpos)
Definition: desgrid_mod.f:360
logical mppic
Definition: mfix_pic_mod.f:14
double precision, dimension(dim_m) ro_s0
Definition: physprop_mod.f:28
subroutine, public particle_grow(new_max_pip)
double precision ylength
Definition: geometry_mod.f:35
double precision, parameter pi
Definition: constant_mod.f:158
double precision, dimension(:), allocatable vol
Definition: geometry_mod.f:212
double precision, dimension(dimension_ic) ic_y_s
Definition: ic_mod.f:29
double precision, dimension(:), allocatable des_stat_wt
Definition: mfix_pic_mod.f:54
double precision, dimension(dimension_ic, dim_m) ic_ep_s
Definition: ic_mod.f:77
double precision, parameter zero
Definition: param1_mod.f:27
double precision zlength
Definition: geometry_mod.f:37
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
integer dimension_j
Definition: param_mod.f:8