File: N:\mfix\model\des\des_allocate_mod.f
1
2
3
4
5
6
7
8
9
10 MODULE DES_ALLOCATE
11
12 PUBLIC:: DES_ALLOCATE_ARRAYS, ADD_PAIR, PARTICLE_GROW, ALLOCATE_DEM_MI
13
14 CONTAINS
15
16
17
18
19
20
21
22 SUBROUTINE DES_ALLOCATE_ARRAYS
23
24
25
26
27 USE compar
28 USE constant
29 USE cutcell
30 USE derived_types, only: boxhandle, pic
31 USE des_bc
32 USE des_rxns
33 USE des_thermo
34 USE discretelement
35 USE functions
36
37 USE des_thermo_cond, only: DES_Qw_cond
38
39 USE funits
40 USE geometry
41 USE indices
42 USE mfix_pic
43 USE param
44 USE param1
45 USE physprop
46 USE pic_bc, only: pic_bcmo, pic_bcmi
47
48 USE run, only: ENERGY_EQ
49 USE run, only: ANY_SPECIES_EQ
50
51 USE particle_filter, only: DES_INTERP_SCHEME_ENUM
52 USE particle_filter, only: DES_INTERP_GARG
53 USE particle_filter, only: DES_INTERP_DPVM
54 USE particle_filter, only: DES_INTERP_GAUSS
55 USE particle_filter, only: DES_INTERP_LHAT
56 USE particle_filter, only: FILTER_SIZE
57 USE particle_filter, only: FILTER_CELL
58 USE particle_filter, only: FILTER_WEIGHT
59
60
61
62 USE error_manager
63
64 IMPLICIT NONE
65
66
67
68
69 INTEGER :: IJK
70
71
72 CALL INIT_ERR_MSG("DES_ALLOCATE_ARRAYS")
73
74
75
76
77 = merge(0, PARTICLES/numPEs, PARTICLES==UNDEFINED_I)
78 MAX_PIP = MAX(MAX_PIP,4)
79
80 WRITE(ERR_MSG,1000) trim(iVal(MAX_PIP))
81 CALL FLUSH_ERR_MSG(HEADER = .FALSE., FOOTER = .FALSE.)
82
83 1000 FORMAT('Initial DES Particle array size: ',A)
84
85
86
87
88
89 ALLOCATE( PARTICLE_STATE (MAX_PIP) )
90 ALLOCATE (iglobal_id(max_pip))
91
92
93 IF(PIC_BCMI /= 0 .OR. PIC_BCMO /=0) CALL ALLOCATE_PIC_MIO
94
95
96
97 Allocate( DES_RADIUS (MAX_PIP) )
98 Allocate( RO_Sol (MAX_PIP) )
99 Allocate( PVOL (MAX_PIP) )
100 Allocate( PMASS (MAX_PIP) )
101 Allocate( OMOI (MAX_PIP) )
102
103
104
105 Allocate( DES_POS_NEW (MAX_PIP,DIMN) )
106 Allocate( DES_VEL_NEW (MAX_PIP,DIMN) )
107 Allocate( OMEGA_NEW (MAX_PIP,DIMN) )
108
109 IF(PARTICLE_ORIENTATION) Allocate( ORIENTATION (DIMN,MAX_PIP) )
110
111 IF (DO_OLD) THEN
112 Allocate( DES_POS_OLD (MAX_PIP,DIMN) )
113 Allocate( DES_VEL_OLD (MAX_PIP,DIMN) )
114 Allocate( DES_ACC_OLD (MAX_PIP,DIMN) )
115 Allocate( OMEGA_OLD (MAX_PIP,DIMN) )
116 Allocate( ROT_ACC_OLD (MAX_PIP,DIMN))
117 ENDIF
118
119
120 IF(DES_USR_VAR_SIZE > 0) &
121 Allocate( DES_USR_VAR(DES_USR_VAR_SIZE,MAX_PIP) )
122
123
124 Allocate( PPOS (MAX_PIP,DIMN) )
125
126
127 Allocate( FC (MAX_PIP,DIMN) )
128
129
130 Allocate( TOW (MAX_PIP,DIMN) )
131
132
133
134 allocate(dg_pijk(max_pip)); dg_pijk=0
135 allocate(dg_pijkprv(max_pip)); dg_pijkprv=0
136
137
138 allocate(ighost_updated(max_pip))
139
140
141
142 Allocate( wall_collision_facet_id (COLLISION_ARRAY_MAX, MAX_PIP) )
143 wall_collision_facet_id(:,:) = -1
144 Allocate( wall_collision_PFT (DIMN, COLLISION_ARRAY_MAX, MAX_PIP) )
145
146
147 Allocate( WALL_NORMAL (NWALLS,DIMN) )
148
149 Allocate( NEIGHBOR_INDEX (MAX_PIP) )
150 Allocate( NEIGHBOR_INDEX_OLD (MAX_PIP) )
151 Allocate( NEIGHBORS (MAX_PIP) )
152 NEIGHBORS(:) = 0
153
154 Allocate( NEIGHBORS_OLD (MAX_PIP) )
155 Allocate( PFT_NEIGHBOR (3,MAX_PIP) )
156 Allocate( PFT_NEIGHBOR_OLD (3,MAX_PIP) )
157 #ifdef do_sap
158 Allocate( boxhandle(MAX_PIP) )
159 #endif
160
161
162
163 ALLOCATE(PIC(DIMENSION_3))
164 DO IJK=1,DIMENSION_3
165 NULLIFY(pic(ijk)%p)
166 ENDDO
167
168
169 Allocate( PINC (DIMENSION_3) )
170
171
172
173 Allocate( PIJK (MAX_PIP,5) )
174
175 ALLOCATE(DRAG_AM(DIMENSION_3))
176 ALLOCATE(DRAG_BM(DIMENSION_3, DIMN))
177 ALLOCATE(F_gp(MAX_PIP ))
178 F_gp(1:MAX_PIP) = ZERO
179
180
181 Allocate(DRAG_FC (MAX_PIP,DIMN) )
182
183
184 ALLOCATE(P_FORCE(DIMN, DIMENSION_3))
185
186
187 ALLOCATE(DES_VOL_NODE(DIMENSION_3))
188
189 ALLOCATE(F_GDS(DIMENSION_3))
190 ALLOCATE(VXF_GDS(DIMENSION_3))
191
192 SELECT CASE(DES_INTERP_SCHEME_ENUM)
193 CASE(DES_INTERP_DPVM, DES_INTERP_GAUSS, DES_INTERP_LHAT)
194 ALLOCATE(FILTER_CELL(FILTER_SIZE, MAX_PIP))
195 ALLOCATE(FILTER_WEIGHT(FILTER_SIZE, MAX_PIP))
196 CASE(DES_INTERP_GARG)
197 ALLOCATE(DES_ROPS_NODE(DIMENSION_3, DIMENSION_M))
198 ALLOCATE(DES_VEL_NODE(DIMENSION_3, DIMN, DIMENSION_M))
199 END SELECT
200
201
202 IF (DES_CONTINUUM_HYBRID) THEN
203 ALLOCATE(SDRAG_AM(DIMENSION_3,DIMENSION_M))
204 ALLOCATE(SDRAG_BM(DIMENSION_3, DIMN,DIMENSION_M))
205
206 ALLOCATE(F_SDS(DIMENSION_3,DIMENSION_M))
207 ALLOCATE(VXF_SDS(DIMENSION_3,DIMENSION_M))
208 ENDIF
209
210
211 IF(MPPIC) THEN
212 Allocate(PS_FORCE_PIC(3, DIMENSION_3))
213 ALLOCATE(DES_STAT_WT(MAX_PIP))
214 ALLOCATE(DES_VEL_MAX(DIMN))
215 ALLOCATE(PS_GRAD(3,MAX_PIP))
216 ALLOCATE(AVGSOLVEL_P(3, MAX_PIP))
217 ALLOCATE(EPG_P(MAX_PIP))
218
219 Allocate(PIC_U_s (DIMENSION_3, DIMENSION_M) )
220 Allocate(PIC_V_s (DIMENSION_3, DIMENSION_M) )
221 Allocate(PIC_W_s (DIMENSION_3, DIMENSION_M) )
222 Allocate(PIC_P_s (DIMENSION_3, DIMENSION_M) )
223 PIC_U_s = zero
224 PIC_V_s = zero
225 PIC_W_s = zero
226 PIC_P_s = zero
227 ENDIF
228
229
230 ALLOCATE(DES_VEL_AVG(DIMN) )
231
232
233 ALLOCATE(GLOBAL_GRAN_ENERGY(DIMN) )
234 ALLOCATE(GLOBAL_GRAN_TEMP(DIMN) )
235
236
237 ALLOCATE(BED_HEIGHT(DIMENSION_M))
238
239
240
241 IF(USE_COHESION) THEN
242
243
244 Allocate( PostCohesive (MAX_PIP) )
245 ENDIF
246
247
248
249
250
251 IF(ENERGY_EQ)THEN
252
253 Allocate( DES_T_s( MAX_PIP ) )
254
255 Allocate( DES_C_PS( MAX_PIP ) )
256
257
258 Allocate( DES_X_s( MAX_PIP, DIMENSION_N_S))
259
260 Allocate( Q_Source( MAX_PIP ) )
261
262 Allocate(avgDES_T_s(DIMENSION_3) )
263
264 IF(CALC_CONV_DES) THEN
265
266 Allocate(CONV_Sc(DIMENSION_3) )
267 Allocate(CONV_Sp(DIMENSION_3) )
268
269 Allocate(CONV_Qs(MAX_PIP))
270
271 Allocate(GAMMAxSA(MAX_PIP))
272 ENDIF
273
274
275 IF (INTG_ADAMS_BASHFORTH) &
276 Allocate( Q_Source0( MAX_PIP ) )
277
278 IF (ANY(CALC_COND_DES)) &
279 Allocate( DES_Qw_cond( DIMENSION_3, DIMENSION_M))
280 ENDIF
281
282
283
284
285
286
287 IF(ANY_SPECIES_EQ)THEN
288
289 Allocate( DES_R_s( MAX_PIP, DIMENSION_N_s) )
290
291
292 Allocate( DES_R_gp( DIMENSION_3, DIMENSION_N_g ) )
293 Allocate( DES_R_gc( DIMENSION_3, DIMENSION_N_g ) )
294 Allocate( DES_SUM_R_g( DIMENSION_3 ) )
295 Allocate( DES_R_PHASE( DIMENSION_3, DIMENSION_LM+DIMENSION_M-1 ) )
296 Allocate( DES_HOR_g( DIMENSION_3 ) )
297
298
299
300 IF (INTG_ADAMS_BASHFORTH) THEN
301
302 Allocate( dMdt_OLD( MAX_PIP ) )
303
304 Allocate( dXdt_OLD( MAX_PIP, DIMENSION_N_s) )
305 ENDIF
306
307
308 Allocate( RXNS_Qs( MAX_PIP ) )
309 ENDIF
310
311
312
313 CALL FINL_ERR_MSG
314
315 RETURN
316 END SUBROUTINE DES_ALLOCATE_ARRAYS
317
318
319
320
321
322
323
324
325
326
327
328
329
330 SUBROUTINE ALLOCATE_DEM_MI
331
332
333
334
335 USE param1, only: undefined
336 USE des_bc, only: dem_bcmi
337 USE des_bc, only: pi_factor, pi_count
338 use des_bc, only: numfrac_limit
339 use des_bc, only: dem_mi_time, dem_bc_poly_layout
340 use des_bc, only: dem_mi
341 use des_bc, only: dem_bcmi_ijkstart, dem_bcmi_ijkend
342 IMPLICIT NONE
343
344
345
346 Allocate( PI_FACTOR (DEM_BCMI) )
347
348 Allocate( PI_COUNT (DEM_BCMI) )
349
350 Allocate( DEM_MI_TIME (DEM_BCMI) )
351
352
353 Allocate( DEM_BC_POLY_LAYOUT( DEM_BCMI, NUMFRAC_LIMIT ) )
354
355 Allocate( DEM_MI(DEM_BCMI) )
356
357
358
359 (:) = -1
360 PI_COUNT(:) = -1
361 DEM_BC_POLY_LAYOUT(:,:) = -1
362
363 (:) = UNDEFINED
364
365 allocate( DEM_BCMI_IJKSTART(DEM_BCMI) )
366 allocate( DEM_BCMI_IJKEND(DEM_BCMI) )
367
368 DEM_BCMI_IJKSTART = -1
369 DEM_BCMI_IJKEND = -1
370
371
372
373
374
375
376 RETURN
377 END SUBROUTINE ALLOCATE_DEM_MI
378
379
380
381
382
383
384
385
386
387
388
389
390 SUBROUTINE ALLOCATE_PIC_MIO
391
392
393
394 USE pic_bc, only: pic_bcmi, pic_bcmo
395 USE pic_bc, only: pic_bcmi_ijkstart, pic_bcmi_ijkend
396 USE pic_bc, only: pic_bcmo_ijkstart, pic_bcmo_ijkend
397 USE pic_bc, only: pic_bcmi_normdir
398 USE pic_bc, only: pic_bcmi_offset
399 USE pic_bc, only: pic_bcmi_incl_cutcell
400 IMPLICIT NONE
401
402
403
404 IF(PIC_BCMI /= 0)THEN
405 allocate( PIC_BCMI_IJKSTART(PIC_BCMI) )
406 allocate( PIC_BCMI_IJKEND (PIC_BCMI) )
407 allocate( PIC_BCMI_NORMDIR (PIC_BCMI,3) )
408 ALLOCATE( PIC_BCMI_OFFSET (PIC_BCMI,3))
409 ALLOCATE( PIC_BCMI_INCL_CUTCELL(PIC_BCMI) )
410 PIC_BCMI_IJKSTART = -1
411 PIC_BCMI_IJKEND = -1
412 ENDIF
413
414
415 IF(PIC_BCMO > 0)THEN
416 allocate( PIC_BCMO_IJKSTART(PIC_BCMO) )
417 allocate( PIC_BCMO_IJKEND(PIC_BCMO) )
418 PIC_BCMO_IJKSTART = -1
419 PIC_BCMO_IJKEND = -1
420 ENDIF
421
422 RETURN
423 END SUBROUTINE ALLOCATE_PIC_MIO
424
425
426
427
428
429
430
431
432
433 DOUBLE PRECISION FUNCTION add_pair(ii,jj)
434 USE discretelement
435 IMPLICIT NONE
436 INTEGER, INTENT(IN) :: ii,jj
437
438 CALL NEIGHBOR_GROW(NEIGHBOR_INDEX(ii))
439
440 NEIGHBORS(NEIGHBOR_INDEX(ii)) = jj
441 NEIGHBOR_INDEX(ii) = NEIGHBOR_INDEX(ii) + 1
442 add_pair = NEIGHBOR_INDEX(ii)
443
444 RETURN
445 END FUNCTION add_pair
446
447
448
449
450
451
452
453
454 SUBROUTINE NEIGHBOR_GROW(new_neigh_max)
455 USE discretelement
456 USE geometry
457 IMPLICIT NONE
458
459 integer, intent(in) :: new_neigh_max
460
461 INTEGER :: lSIZE1
462 INTEGER, DIMENSION(:), ALLOCATABLE :: neigh_tmp
463 DOUBLE PRECISION, DIMENSION(:,:), ALLOCATABLE :: pf_tmp
464 INTEGER new_size
465
466 lSIZE1 = size(neighbors,1)
467
468 IF ( new_neigh_max .le. lSIZE1 ) RETURN
469
470 new_size = lSIZE1
471
472 DO WHILE(new_size < new_neigh_max)
473 new_size = 2*new_size
474 ENDDO
475
476 allocate(neigh_tmp(new_size))
477 neigh_tmp(1:lSIZE1) = neighbors(1:lSIZE1)
478 neigh_tmp(lSIZE1+1:) = 0
479 call move_alloc(neigh_tmp,neighbors)
480
481 allocate(neigh_tmp(new_size))
482 neigh_tmp(1:lSIZE1) = neighbors_old(1:lSIZE1)
483 neigh_tmp(lSIZE1+1:) = 0
484 call move_alloc(neigh_tmp,neighbors_old)
485
486 allocate(pf_tmp(3,new_size))
487 pf_tmp(:,1:lSIZE1) = pft_neighbor(:,1:lSIZE1)
488 pf_tmp(:,lSIZE1+1:) = 0
489 call move_alloc(pf_tmp,pft_neighbor)
490
491 allocate(pf_tmp(3,new_size))
492 pf_tmp(:,1:lSIZE1) = pft_neighbor_old(:,1:lSIZE1)
493 pf_tmp(:,lSIZE1+1:) = 0
494 call move_alloc(pf_tmp,pft_neighbor_old)
495
496
497 END SUBROUTINE NEIGHBOR_GROW
498
499
500
501
502
503
504
505
506 SUBROUTINE PARTICLE_GROW(new_max_pip)
507
508 USE des_rxns
509 USE des_thermo
510 USE derived_types, only: boxhandle
511 USE discretelement
512 USE mfix_pic
513 USE multi_sweep_and_prune, ONLY: boxhandle_grow
514 USE particle_filter
515 USE resize
516 USE run
517
518 IMPLICIT NONE
519
520 integer, intent(in) :: new_max_pip
521 integer :: old_size, new_size
522
523 IF (new_max_pip .le. size(des_radius)) RETURN
524 max_pip = max(max_pip, new_max_pip)
525
526 old_size = size(des_radius)
527
528 new_size = old_size
529
530 DO WHILE (new_size < new_max_pip)
531 new_size = 2*new_size
532 ENDDO
533
534 #ifdef do_sap
535 call boxhandle_grow(boxhandle,new_size)
536 #endif
537 call real_grow(des_radius,new_size)
538 call real_grow(RO_Sol,new_size)
539 call real_grow(PVOL,new_size)
540 call real_grow(PMASS,new_size)
541 call real_grow(OMOI,new_size)
542 call real_grow2_reverse(DES_POS_NEW,new_size)
543 call real_grow2_reverse(DES_VEL_NEW,new_size)
544 call real_grow2_reverse(OMEGA_NEW,new_size)
545 call real_grow2_reverse(PPOS,new_size)
546 call byte_grow(PARTICLE_STATE,new_size)
547 call integer_grow(iglobal_id,new_size)
548 call integer_grow2_reverse(pijk,new_size)
549 call integer_grow(dg_pijk,new_size)
550 call integer_grow(dg_pijkprv,new_size)
551 call logical_grow(ighost_updated,new_size)
552 call real_grow2_reverse(FC,new_size)
553 call real_grow2_reverse(TOW,new_size)
554 call real_grow(F_GP,new_size)
555 call integer_grow2(WALL_COLLISION_FACET_ID,new_size)
556 call real_grow3(WALL_COLLISION_PFT,new_size)
557 call real_grow2_reverse(DRAG_FC,new_size)
558
559 call integer_grow(NEIGHBOR_INDEX,new_size)
560 call integer_grow(NEIGHBOR_INDEX_OLD,new_size)
561
562 IF(PARTICLE_ORIENTATION) call real_grow2(ORIENTATION,new_size)
563
564 IF(FILTER_SIZE > 0) THEN
565 call integer_grow2(FILTER_CELL,new_size)
566 call real_grow2(FILTER_WEIGHT,new_size)
567 ENDIF
568
569 IF(MPPIC) THEN
570 call real_grow(DES_STAT_WT,new_size)
571 call real_grow2(PS_GRAD,new_size)
572 call real_grow2(AVGSOLVEL_P,new_size)
573 call real_grow(EPG_P,new_size)
574 ENDIF
575
576 IF(USE_COHESION) THEN
577 call real_grow(PostCohesive,new_size)
578 ENDIF
579
580 IF (DO_OLD) THEN
581 call real_grow2_reverse(DES_POS_OLD,new_size)
582 call real_grow2_reverse(DES_VEL_OLD,new_size)
583 call real_grow2_reverse(DES_ACC_OLD,new_size)
584 call real_grow2_reverse(OMEGA_OLD,new_size)
585 call real_grow2_reverse(ROT_ACC_OLD,new_size)
586 ENDIF
587
588 IF(ENERGY_EQ)THEN
589 call real_grow(DES_T_s,new_size)
590 call real_grow(DES_C_PS,new_size)
591 call real_grow2_reverse(DES_X_s,new_size)
592 call real_grow(Q_Source,new_size)
593 IF(CALC_CONV_DES) THEN
594 call real_grow(CONV_Qs, new_size)
595 call real_grow(GAMMAxSA, new_size)
596 ENDIF
597 IF(INTG_ADAMS_BASHFORTH) &
598 call real_grow(Q_Source0,new_size)
599 ENDIF
600
601 IF(ANY_SPECIES_EQ)THEN
602 call real_grow2_reverse( DES_R_s, new_size )
603
604 IF (INTG_ADAMS_BASHFORTH) THEN
605 call real_grow( dMdt_OLD, new_size )
606 call real_grow2_reverse( dXdt_OLD, new_size )
607 ENDIF
608
609 call real_grow( RXNS_Qs, new_size )
610 ENDIF
611
612 IF(DES_USR_VAR_SIZE > 0) &
613 call real_grow2(DES_USR_VAR,new_size)
614
615 CALL DES_INIT_PARTICLE_ARRAYS(old_size+1,new_size)
616
617 RETURN
618
619 END SUBROUTINE PARTICLE_GROW
620
621 END MODULE DES_ALLOCATE
622