MFIX  2016-1
solve_vel_star.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Subroutine: SOLVE_VEL_STAR C
4 ! Purpose: Solve starred velocity components C
5 ! C
6 ! Author: M. Syamlal Date: 25-APR-96 C
7 ! C
8 ! Revision Number: 2 C
9 ! Purpose: allow multiparticle in D_E, D_N and D_T claculations C
10 ! and account for the averaged Solid-Solid drag C
11 ! Author: S. Dartevelle, LANL Date: 28-FEb-04 C
12 ! C
13 ! C
14 ! Literature/Document References: C
15 ! C
16 ! C
17 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
18  SUBROUTINE solve_vel_star(IER)
19 
20 ! Modules
21 !---------------------------------------------------------------------//
22  use compar, only: ijkstart3, ijkend3
23  use discretelement, only: des_continuum_hybrid, discrete_element, des_continuum_coupled
24  use fldvar, only: u_g, v_g, w_g, u_s, v_s, w_s
25  use geometry, only: do_k, ijkmax2
27  use param, only: dimension_3, dimension_m
28  use param1, only: zero, dimension_lm
29  use pgcor, only: d_e, d_t, d_n
30  use ps, only: point_source
31  use pscor, only: e_e, e_t, e_n, mcp
32  use physprop,only: mmax
34  use run, only: kt_type_enum, ghd_2007
36  use ur_facs, only: ur_fac
37  ! Use ambm
38  ! Use tmp_array1, VxF_gs => Arraym1
39  ! Use tmp_array, VxF_ss => ArrayLM
42  use usr_src, only: gas_u_mom, gas_v_mom, gas_w_mom
43  use usr_src, only: solids_u_mom, solids_v_mom, solids_w_mom
44  IMPLICIT NONE
45 
46 ! Dummy arguments
47 !---------------------------------------------------------------------//
48 ! Error index
49  INTEGER, INTENT(INOUT) :: IER
50 
51 ! Local variables
52 !---------------------------------------------------------------------//
53 ! fluid cell index
54  INTEGER :: IJK
55 ! temporary velocity arrays
56  DOUBLE PRECISION, DIMENSION(:), allocatable :: U_gtmp, V_gtmp, W_gtmp
57  DOUBLE PRECISION, DIMENSION(:,:), allocatable :: U_stmp, V_stmp, W_stmp
58 ! linear equation solver method and iterations
59  INTEGER :: LEQM, LEQI
60 
61  LOGICAL :: DO_SOLIDS
62 
63 ! temporary use of global arrays:
64 ! arraym1 (locally vxf_gs)
65 ! the volume x average gas-solids drag at momentum cell centers
66 ! DOUBLE PRECISION :: VXF_GS(DIMENSION_3, DIMENSION_M)
67 ! arraylm (locally vxf_ss)
68 ! the volume x average solids-solids drag at momentum cell centers
69 ! DOUBLE PRECISION :: VXF_SS(DIMENSION_3, DIMENSION_LM)
70 ! Septadiagonal matrix A_m, vector b_m
71 ! DOUBLE PRECISION A_m(DIMENSION_3, -3:3, 0:DIMENSION_M)
72 ! DOUBLE PRECISION B_m(DIMENSION_3, 0:DIMENSION_M)
73 !---------------------------------------------------------------------//
74 
75  allocate(u_gtmp(dimension_3))
76  allocate(v_gtmp(dimension_3))
77  allocate(w_gtmp(dimension_3))
78  allocate(u_stmp(dimension_3,dimension_m))
79  allocate(v_stmp(dimension_3,dimension_m))
80  allocate(w_stmp(dimension_3,dimension_m))
81 
82  ! call lock_ambm ! locks arrys a_m and b_m
83  ! call lock_tmp_array1 ! locks arraym1 (locally vxf_gs)
84  ! call lock_tmp_array2 ! locks arraylm (locally vxf_ss)
85 
86  CALL init(u_gtmp, v_gtmp, w_gtmp, u_stmp, v_stmp, w_stmp)
87 
88  do_solids = .NOT.(discrete_element .OR. qmomk) .OR. &
89  des_continuum_hybrid
90 
91 !!$omp parallel sections default(shared)
92  CALL u_m_star(u_gtmp,u_stmp)
93 !!$omp section
94  CALL v_m_star(v_gtmp,v_stmp)
95 !!$omp section
96  CALL w_m_star(w_gtmp,w_stmp)
97 !!$omp end parallel sections
98 
99  CALL save(u_gtmp, v_gtmp, w_gtmp, u_stmp, v_stmp, w_stmp)
100 
101 ! modification for GHD theory to compute species velocity: Ui = Joi/(mi ni) + U.
102  IF(kt_type_enum == ghd_2007) THEN
103  CALL calc_external_forces()
104  CALL ghdmassflux() ! to compute solid species mass flux
105  CALL updatespeciesvelocities() ! located at end of ghdMassFlux.f file
106  ENDIF
107 
108  ! call unlock_ambm
109  ! call unlock_tmp_array1
110  ! call unlock_tmp_array2
111 
112  deallocate(u_gtmp)
113  deallocate(v_gtmp)
114  deallocate(w_gtmp)
115  deallocate(u_stmp)
116  deallocate(v_stmp)
117  deallocate(w_stmp)
118 
119  RETURN
120 
121  CONTAINS
122 
123 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
124 ! C
125 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
126  SUBROUTINE init(U_g_tmp, V_g_tmp, W_g_tmp, U_s_tmp, V_s_tmp, W_s_tmp)
127  IMPLICIT NONE
128 !---------------------------------------------------------------------//
129  DOUBLE PRECISION, DIMENSION(:), intent(out) :: U_g_tmp, V_g_tmp, W_g_tmp
130  DOUBLE PRECISION, DIMENSION(:,:), intent(out) :: U_s_tmp, V_s_tmp, W_s_tmp
131 !---------------------------------------------------------------------//
132  ! solids phase index
133  INTEGER :: M
134 !---------------------------------------------------------------------//
135 
136  ! Store the velocities so that the order of solving the momentum
137  ! equations does not matter
138  DO ijk = ijkstart3, ijkend3
139  u_g_tmp(ijk) = u_g(ijk)
140  v_g_tmp(ijk) = v_g(ijk)
141  w_g_tmp(ijk) = w_g(ijk)
142  ENDDO
143  DO m = 1, mmax
144  IF(kt_type_enum /= ghd_2007 .OR. &
145  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
146  DO ijk = ijkstart3, ijkend3
147  u_s_tmp(ijk, m) = u_s(ijk, m)
148  v_s_tmp(ijk, m) = v_s(ijk, m)
149  w_s_tmp(ijk, m) = w_s(ijk, m)
150  ENDDO
151  ENDIF
152  ENDDO
153 
154  END SUBROUTINE init
155 
156 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
157 ! C
158 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
159  SUBROUTINE save(U_g_tmp, V_g_tmp, W_g_tmp, U_s_tmp, V_s_tmp, W_s_tmp)
160  IMPLICIT NONE
161 !---------------------------------------------------------------------//
162  DOUBLE PRECISION, DIMENSION(:), intent(in) :: U_g_tmp, V_g_tmp, W_g_tmp
163  DOUBLE PRECISION, DIMENSION(:,:), intent(in) :: U_s_tmp, V_s_tmp, W_s_tmp
164 !---------------------------------------------------------------------//
165  ! solids phase index
166  INTEGER :: M
167 !---------------------------------------------------------------------//
168 
169  ! Now update all velocity components
170  DO ijk = ijkstart3, ijkend3
171  u_g(ijk) = u_g_tmp(ijk)
172  v_g(ijk) = v_g_tmp(ijk)
173  w_g(ijk) = w_g_tmp(ijk)
174  ENDDO
175  DO m = 1, mmax
176  IF(kt_type_enum /= ghd_2007 .OR. &
177  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
178  DO ijk = ijkstart3, ijkend3
179  u_s(ijk, m) = u_s_tmp(ijk, m)
180  v_s(ijk, m) = v_s_tmp(ijk, m)
181  w_s(ijk, m) = w_s_tmp(ijk, m)
182  ENDDO
183  ENDIF
184  ENDDO
185 
186  END SUBROUTINE save
187 
188 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
189 ! C
190 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
191  SUBROUTINE u_m_star(U_g_tmp, U_s_tmp)
192  IMPLICIT NONE
193 !---------------------------------------------------------------------//
194  DOUBLE PRECISION, DIMENSION(:), INTENT(OUT) :: U_g_tmp
195  DOUBLE PRECISION, DIMENSION(:, :), INTENT(OUT) :: U_s_tmp
196 !---------------------------------------------------------------------//
197  ! solids phase index
198  INTEGER :: M
199  DOUBLE PRECISION, DIMENSION(:, :), ALLOCATABLE :: VXF_GS, VXF_SS, B_M
200  DOUBLE PRECISION, DIMENSION(:, :, :), ALLOCATABLE :: A_M
201 !---------------------------------------------------------------------//
202 
203  allocate(vxf_gs(dimension_3,dimension_m))
204  allocate(vxf_ss(dimension_3,dimension_lm))
205  ALLOCATE(a_m(dimension_3, -3:3, 0:dimension_m))
206  ALLOCATE(b_m(dimension_3, 0:dimension_m))
207 
208 ! Calculate U_m_star and residuals
209 ! ---------------------------------------------------------------->>>
210  DO m = 0, mmax
211  CALL init_ab_m (a_m, b_m, ijkmax2, m)
212  IF (m >= 1) vxf_gs(:,m) = zero
213  ENDDO
214 
215 ! calculate the convection-diffusion terms for the gas and solids phase
216 ! u-momentum equations
217  CALL conv_dif_u_g (a_m, b_m)
218  IF(do_solids) CALL conv_dif_u_s (a_m, b_m)
219 
220 ! calculate the source terms for the gas and solids phase u-momentum
221 ! equations
222  CALL source_u_g (a_m, b_m)
223  IF(point_source) CALL point_source_u_g (a_m, b_m)
224  IF(call_usr_source(3)) CALL calc_usr_source(gas_u_mom, a_m, b_m)
225  IF(do_solids) THEN
226  CALL source_u_s (a_m, b_m)
227  IF(point_source) CALL point_source_u_s (a_m, b_m)
228  IF(call_usr_source(3)) CALL calc_usr_source(solids_u_mom, a_m, b_m)
229  ENDIF
230 
231 ! evaluate local variable vxf_gs and vxf_ss. both terms are sent to the
232 ! subroutine calc_d (pressure correction equation coefficients). the
233 ! former is also used in the subroutine partial_elim_u while the latter
234 ! is effectively re-evaluated within said subroutine
235  CALL vf_gs_x (vxf_gs)
236  IF(do_solids .AND. (kt_type_enum /= ghd_2007)) THEN
237  IF (mmax > 0) CALL vf_ss_x (vxf_ss)
238  ENDIF
239 
240 ! calculate coefficients for the pressure correction equation
241  IF(kt_type_enum == ghd_2007) THEN
242  CALL calc_d_ghd_e (a_m, vxf_gs, d_e)
243  ELSE
244  CALL calc_d_e (a_m, vxf_gs, vxf_ss, d_e, ier)
245  ENDIF
246 
247  IF(do_solids) THEN
248 ! calculate coefficients for a solids volume correction equation
249  IF (mmax > 0) CALL calc_e_e (a_m, mcp, e_e)
250 
251 ! calculate modifications to the A matrix center coefficient and B
252 ! source vector for partial elimination
253  IF(kt_type_enum == ghd_2007) THEN
254  IF (mmax > 0) CALL partial_elim_ghd_u (u_g,u_s,vxf_gs,a_m,b_m)
255  ELSE
256  IF (mmax > 0) CALL partial_elim_u (u_g,u_s,vxf_gs,a_m,b_m)
257  ENDIF
258  ENDIF
259 
260 ! handle special case where center coefficient is zero
261  CALL adjust_a_u_g (a_m, b_m)
262  IF(do_solids) CALL adjust_a_u_s (a_m, b_m)
263 
264 ! calculate modifications to the A matrix center coefficient and B
265 ! source vector for treating DEM drag terms
266  IF(des_continuum_coupled) THEN
267  CALL gas_drag_u(a_m, b_m, ier)
268  IF (des_continuum_hybrid) &
269  CALL solid_drag_u(a_m, b_m)
270  ENDIF
271 
272  IF(qmomk .AND. qmomk_coupled) THEN
273  CALL qmomk_gas_drag(a_m, b_m, ier, 1, 0, 0)
274  ENDIF
275 
276  IF (momentum_x_eq(0)) THEN
277  CALL calc_resid_u (u_g, v_g, w_g, a_m, b_m, 0, &
279  resid(resid_u,0), max_resid(resid_u,0), &
280  ijk_resid(resid_u,0))
281  CALL under_relax_u (u_g, a_m, b_m, 0, ur_fac(3))
282 ! call check_ab_m(a_m, b_m, 0, .false., ier)
283 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
284 ! write(*,*) &
285 ! resid(resid_u, 0), max_resid(resid_u, 0), &
286 ! ijk_resid(resid_u, 0)
287  ENDIF
288 
289  IF(do_solids) THEN
290  DO m = 1, mmax
291  IF(kt_type_enum /= ghd_2007 .OR. &
292  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
293  IF (momentum_x_eq(m)) THEN
294  CALL calc_resid_u (u_s(1,m), v_s(1,m), w_s(1,m), a_m,&
295  b_m, m, num_resid(resid_u,m), &
296  den_resid(resid_u,m), resid(resid_u,m), &
298  CALL under_relax_u (u_s(1,m), a_m, b_m, m, &
299  ur_fac(3))
300 ! call check_ab_m(a_m, b_m, m, .false., ier)
301 ! write(*,*) &
302 ! resid(resid_u, m), max_resid(resid_u, m), &
303 ! ijk_resid(resid_u, m)
304 ! call write_ab_m(a_m, b_m, ijkmax2, m, ier)
305  ENDIF ! end if (momentum_x_eq(m))
306  ENDIF ! end if check for GHD Theory
307  ENDDO ! end do (m=1,mmax)
308  ENDIF
309 
310  IF (momentum_x_eq(0)) THEN
311 ! call test_lin_eq(ijkmax2, ijmax2, imax2, a_m(1, -3, 0), 1,&
312 ! DO_K,ier)
313  CALL adjust_leq (resid(resid_u,0), leq_it(3), leq_method(3), &
314  leqi, leqm)
315  CALL solve_lin_eq ('U_g', 3, u_g_tmp, a_m, b_m, 0, leqi, leqm, &
316  leq_sweep(3), leq_tol(3), leq_pc(3), ier)
317 ! call out_array(u_g, 'u_g')
318  ENDIF
319 
320  IF(do_solids) THEN
321  DO m = 1, mmax
322  IF(kt_type_enum /= ghd_2007 .OR. &
323  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
324  IF (momentum_x_eq(m)) THEN
325 ! call test_lin_eq(ijkmax2, ijmax2, imax2, &
326 ! a_m(1, -3, M), 1, DO_K,ier)
327  CALL adjust_leq (resid(resid_u,m), leq_it(3),&
328  leq_method(3), leqi, leqm)
329  CALL solve_lin_eq ('U_s', 3, u_s_tmp(1,m), a_m, &
330  b_m, m, leqi, leqm, leq_sweep(3), leq_tol(3),&
331  leq_pc(3), ier)
332 ! call out_array(u_s(1,m), 'u_s')
333  ENDIF ! end if (momentum_x_eq(m))
334  ENDIF ! end if check for GHD Theory
335  ENDDO ! end do (m=1,mmax)
336  ENDIF
337 ! End U_m_star and residuals
338 ! ----------------------------------------------------------------<<<
339 
340  deallocate(vxf_gs)
341  deallocate(vxf_ss)
342  deallocate(a_m)
343  deallocate(b_m)
344 
345  END SUBROUTINE u_m_star
346 
347 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
348 ! C
349 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
350  SUBROUTINE v_m_star(V_g_tmp, V_s_tmp)
351  IMPLICIT NONE
352 !---------------------------------------------------------------------//
353  DOUBLE PRECISION, DIMENSION(:), INTENT(OUT) :: V_g_tmp
354  DOUBLE PRECISION, DIMENSION(:, :), INTENT(OUT) :: V_s_tmp
355 !---------------------------------------------------------------------//
356  ! solids phase index
357  INTEGER :: M
358  DOUBLE PRECISION, DIMENSION(:, :), ALLOCATABLE :: VXF_GS, VXF_SS, B_M
359  DOUBLE PRECISION, DIMENSION(:, :, :), ALLOCATABLE :: A_M
360 !---------------------------------------------------------------------//
361 
362  allocate(vxf_gs(dimension_3,dimension_m))
363  allocate(vxf_ss(dimension_3,dimension_lm))
364  ALLOCATE(a_m(dimension_3, -3:3, 0:dimension_m))
365  ALLOCATE(b_m(dimension_3, 0:dimension_m))
366 
367 ! Calculate V_m_star and residuals
368 ! ---------------------------------------------------------------->>>
369  DO m = 0, mmax
370  CALL init_ab_m (a_m, b_m, ijkmax2, m)
371  IF (m >= 1) vxf_gs(:,m) = zero
372  ENDDO
373 
374 ! convection-diffusion terms
375  CALL conv_dif_v_g (a_m, b_m, ier)
376 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
377  IF(do_solids) CALL conv_dif_v_s (a_m, b_m, ier)
378 
379 ! source terms
380  CALL source_v_g (a_m, b_m)
381  IF(point_source) CALL point_source_v_g (a_m, b_m)
382  IF(call_usr_source(4)) CALL calc_usr_source(gas_v_mom, a_m, b_m)
383 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
384  IF(do_solids) THEN
385  CALL source_v_s (a_m, b_m)
386  IF(point_source) CALL point_source_v_s (a_m, b_m)
387  IF(call_usr_source(4)) CALL calc_usr_source(solids_v_mom, a_m, b_m)
388  ENDIF
389 
390 ! evaluate local vxf_gs and vxf_ss
391  CALL vf_gs_y (vxf_gs)
392  IF(do_solids .AND. (kt_type_enum /= ghd_2007)) THEN
393  IF (mmax > 0) CALL vf_ss_y (vxf_ss)
394  ENDIF
395 
396 ! calculate coefficients for the pressure correction equation
397  IF(kt_type_enum == ghd_2007) THEN
398  CALL calc_d_ghd_n (a_m, vxf_gs, d_n)
399  ELSE
400  CALL calc_d_n (a_m, vxf_gs, vxf_ss, d_n, ier)
401  ENDIF
402 
403  IF(do_solids) THEN
404 ! calculate coefficients for a solids pressure correction equation
405  IF (mmax > 0) CALL calc_e_n (a_m, mcp, e_n)
406 
407 ! calculate modifications to the A matrix center coefficient and B
408 ! source vector for partial elimination
409  IF(kt_type_enum == ghd_2007) THEN
410  IF (mmax > 0) CALL partial_elim_ghd_v (v_g,v_s,vxf_gs,a_m,b_m)
411  ELSE
412  IF (mmax > 0) CALL partial_elim_v (v_g,v_s,vxf_gs,a_m,b_m)
413  ENDIF
414  ENDIF
415 
416 ! handle special case where center coefficient is zero
417  CALL adjust_a_v_g (a_m, b_m)
418 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
419  IF(do_solids) CALL adjust_a_v_s (a_m, b_m)
420 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
421 
422 ! modification to matrix equation for DEM drag terms
423  IF(des_continuum_coupled) THEN
424  CALL gas_drag_v(a_m, b_m, ier)
425  IF (des_continuum_hybrid) &
426  CALL solid_drag_v(a_m, b_m)
427  ENDIF
428 
429  IF(qmomk .AND. qmomk_coupled) THEN
430  CALL qmomk_gas_drag(a_m, b_m, ier, 0, 1, 0)
431  ENDIF
432 
433 
434  IF (momentum_y_eq(0)) THEN
435  CALL calc_resid_v (u_g, v_g, w_g, a_m, b_m, 0, &
437  resid(resid_v,0), max_resid(resid_v,0), &
438  ijk_resid(resid_v,0))
439  CALL under_relax_v (v_g, a_m, b_m, 0, ur_fac(4))
440 ! call check_ab_m(a_m, b_m, 0, .false., ier)
441 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
442 ! write(*,*) &
443 ! resid(resid_v, 0), max_resid(resid_v, 0), &
444 ! ijk_resid(resid_v, 0)
445  ENDIF
446 
447  IF(do_solids) THEN
448  DO m = 1, mmax
449  IF(kt_type_enum /= ghd_2007 .OR. &
450  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
451  IF (momentum_y_eq(m)) THEN
452  CALL calc_resid_v (u_s(1,m), v_s(1,m), w_s(1,m), a_m,&
453  b_m, m, num_resid(resid_v,m), &
454  den_resid(resid_v,m),resid(resid_v,m), &
456  CALL under_relax_v (v_s(1,m),a_m,b_m,m,ur_fac(4))
457 ! call check_ab_m(a_m, b_m, m, .false., ier)
458 ! write(*,*) &
459 ! resid(resid_v, m), max_resid(resid_v, m),
460 ! ijk_resid(resid_v, m)
461 ! call write_ab_m(a_m, b_m, ijkmax2, m, ier)
462  ENDIF ! end if (momentum_y_eq(m))
463  ENDIF ! end if check for GHD Theory
464  ENDDO ! end do (m=1,mmax)
465  ENDIF
466 
467  IF (momentum_y_eq(0)) THEN
468 ! call test_lin_eq(ijkmax2, ijmax2, imax2, a_m(1, -3, 0), &
469 ! 1, DO_K, ier)
470  CALL adjust_leq (resid(resid_v,0), leq_it(4), leq_method(4), &
471  leqi, leqm)
472  CALL solve_lin_eq ('V_g', 4, v_g_tmp, a_m, b_m, 0, leqi, leqm, &
473  leq_sweep(4), leq_tol(4), leq_pc(4), ier)
474 ! call out_array(v_g, 'v_g')
475  ENDIF
476 
477  IF(do_solids) THEN
478  DO m = 1, mmax
479  IF(kt_type_enum /= ghd_2007 .OR. &
480  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
481  IF (momentum_y_eq(m)) THEN
482 ! call test_lin_eq(ijkmax2, ijmax2, imax2, &
483 ! a_m(1, -3, M), 1, DO_K, ier)
484  CALL adjust_leq (resid(resid_v,m), leq_it(4), &
485  leq_method(4), leqi, leqm)
486  CALL solve_lin_eq ('V_s', 4, v_s_tmp(1,m), a_m, &
487  b_m, m, leqi, leqm, leq_sweep(4), leq_tol(4), &
488  leq_pc(4), ier)
489 ! call out_array(v_s(1,m), 'v_s')
490  ENDIF ! end if (momentum_y_eq(m))
491  ENDIF ! end if check for GHD Theory
492  ENDDO ! end do (m=1,mmax)
493  ENDIF
494 ! End V_m_star and residuals
495 ! ----------------------------------------------------------------<<<
496 
497  deallocate(vxf_gs)
498  deallocate(vxf_ss)
499  deallocate(a_m)
500  deallocate(b_m)
501 
502  END SUBROUTINE v_m_star
503 
504 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
505 ! C
506 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
507  SUBROUTINE w_m_star(W_g_tmp, W_s_tmp)
508  IMPLICIT NONE
509 !---------------------------------------------------------------------//
510  DOUBLE PRECISION, DIMENSION(:), INTENT(OUT) :: W_g_tmp
511  DOUBLE PRECISION, DIMENSION(:, :), INTENT(OUT) :: W_s_tmp
512 !---------------------------------------------------------------------//
513  ! solids phase index
514  INTEGER :: M
515  DOUBLE PRECISION, DIMENSION(:, :), ALLOCATABLE :: VXF_GS, VXF_SS, B_M
516  DOUBLE PRECISION, DIMENSION(:, :, :), ALLOCATABLE :: A_M
517 !---------------------------------------------------------------------//
518 
519  ALLOCATE(vxf_gs(dimension_3,dimension_m))
520  ALLOCATE(vxf_ss(dimension_3,dimension_lm))
521  ALLOCATE(a_m(dimension_3, -3:3, 0:dimension_m))
522  ALLOCATE(b_m(dimension_3, 0:dimension_m))
523 
524 ! Calculate W_m_star and residuals
525 ! ---------------------------------------------------------------->>>
526  IF (do_k)THEN
527  DO m = 0, mmax
528  CALL init_ab_m (a_m, b_m, ijkmax2, m)
529  IF (m >= 1) vxf_gs(:,m) = zero
530  ENDDO
531 
532 ! convection diffusion
533  CALL conv_dif_w_g (a_m, b_m)
534  IF(do_solids) CALL conv_dif_w_s (a_m, b_m)
535 
536 ! source terms
537  CALL source_w_g (a_m, b_m)
538  IF(point_source) CALL point_source_w_g (a_m, b_m)
539  IF(call_usr_source(5)) CALL calc_usr_source(gas_w_mom, a_m, b_m)
540 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
541  IF(do_solids) THEN
542  CALL source_w_s (a_m, b_m)
543  IF(point_source) CALL point_source_w_s (a_m, b_m)
544  IF(call_usr_source(5)) CALL calc_usr_source(solids_w_mom, a_m, b_m)
545  ENDIF
546 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
547 
548 ! evaluate local variable vxf_gs and vxf_ss
549  CALL vf_gs_z (vxf_gs)
550  IF(do_solids .AND. (kt_type_enum /= ghd_2007)) THEN
551  IF (mmax > 0) CALL vf_ss_z (vxf_ss)
552  ENDIF
553 
554 ! calculate coefficients for the pressure correction equation
555  IF(kt_type_enum == ghd_2007) THEN
556  CALL calc_d_ghd_t (a_m, vxf_gs, d_t)
557  ELSE
558  CALL calc_d_t (a_m, vxf_gs, vxf_ss, d_t, ier)
559  ENDIF
560 
561  IF(do_solids) THEN
562 ! calculate coefficients for a solids pressure correction equation
563  IF (mmax > 0) CALL calc_e_t (a_m, mcp, e_t)
564 
565 ! calculate modifications to the A matrix center coefficient and B
566 ! source vector for partial elimination
567  IF(kt_type_enum == ghd_2007) THEN
568  IF (mmax > 0) CALL partial_elim_ghd_w (w_g, w_s, vxf_gs, a_m, b_m)
569  ELSE
570  IF (mmax > 0) CALL partial_elim_w (w_g, w_s, vxf_gs, a_m, b_m)
571  ENDIF
572  ENDIF
573 
574 ! handle special case where center coefficient is zero
575  CALL adjust_a_w_g (a_m, b_m)
576  IF(do_solids) THEN
577  CALL adjust_a_w_s (a_m, b_m)
578  ENDIF
579 
580 ! modifications to matrix equation for DEM
581  IF(des_continuum_coupled) THEN
582  CALL gas_drag_w(a_m, b_m, ier)
583  IF (discrete_element .AND. des_continuum_hybrid) &
584  CALL solid_drag_w(a_m, b_m)
585  ENDIF
586 
587  IF(qmomk .AND. qmomk_coupled) THEN
588  CALL qmomk_gas_drag(a_m, b_m, ier, 0, 0, 1)
589  ENDIF
590 
591  IF (momentum_z_eq(0)) THEN
592  CALL calc_resid_w (u_g, v_g, w_g, a_m, b_m, 0, &
594  resid(resid_w,0), max_resid(resid_w,0), &
595  ijk_resid(resid_w,0))
596  CALL under_relax_w (w_g, a_m, b_m, 0, ur_fac(5))
597 ! call check_ab_m(a_m, b_m, 0, .false., ier)
598 ! write(*,*) &
599 ! resid(resid_w, 0), max_resid(resid_w, 0), &
600 ! ijk_resid(resid_w, 0)
601  ENDIF
602 
603  IF(do_solids) THEN
604  DO m = 1, mmax
605  IF(kt_type_enum /= ghd_2007 .OR. &
606  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
607  IF (momentum_z_eq(m)) THEN
608  CALL calc_resid_w (u_s(1,m), v_s(1,m), w_s(1,m),&
609  a_m, b_m, m, num_resid(resid_w,m), &
610  den_resid(resid_w,m), resid(resid_w,m), &
612  CALL under_relax_w (w_s(1,m), a_m, b_m, m, &
613  ur_fac(5))
614 ! call check_ab_m(a_m, b_m, m, .false., ier)
615 ! write(*,*) &
616 ! resid(resid_w, m), max_resid(resid_w, m), &
617 ! ijk_resid(resid_w, m)
618 ! call write_ab_m(a_m, b_m, ijkmax2, m, ier)
619  ENDIF ! end if (momentum_z_eq(m))
620  ENDIF ! end if check for GHD Theory
621  ENDDO ! end do (m=1,mmax)
622  ENDIF
623 
624  IF (momentum_z_eq(0)) THEN
625 ! call test_lin_eq(ijkmax2, ijmax2, imax2, a_m(1, -3, 0), &
626 ! 1, DO_K, ier)
627  CALL adjust_leq (resid(resid_w,0), leq_it(5), &
628  leq_method(5), leqi, leqm)
629  CALL solve_lin_eq ('W_g', 5, w_g_tmp, a_m, b_m, 0, leqi,&
630  leqm, leq_sweep(5), leq_tol(5), leq_pc(5), ier)
631 ! call out_array(w_g, 'w_g')
632  ENDIF
633 
634  IF(do_solids) THEN
635  DO m = 1, mmax
636  IF(kt_type_enum /= ghd_2007 .OR. &
637  (kt_type_enum == ghd_2007 .AND. m==mmax)) THEN
638  IF (momentum_z_eq(m)) THEN
639 ! call test_lin_eq(ijkmax2, ijmax2, imax2, &
640 ! a_m(1, -3, M), 1, DO_K, ier)
641  CALL adjust_leq (resid(resid_w,m), leq_it(5), &
642  leq_method(5), leqi, leqm)
643  CALL solve_lin_eq ('W_s', 5, w_s_tmp(1,m), &
644  a_m, b_m, m, leqi, leqm, leq_sweep(5), &
645  leq_tol(5), leq_pc(5), ier)
646 ! call out_array(w_s(1,m), 'w_s')
647  ENDIF ! end if (momentum_z_eq(m))
648  ENDIF ! end if check for GHD Theory
649  ENDDO ! end do (m=1,mmax)
650  ENDIF
651  ENDIF ! end if (do_k)
652 ! End W_m_star and residuals
653 ! ----------------------------------------------------------------<<<
654 
655  deallocate(vxf_gs)
656  deallocate(vxf_ss)
657  deallocate(a_m)
658  deallocate(b_m)
659 
660  END SUBROUTINE w_m_star
661 
662  END SUBROUTINE solve_vel_star
subroutine calc_resid_u(U_M, V_M, W_M, A_M, B_M, M, NUM, DEN, RESID, MAX_RESID, IJK_RESID)
Definition: calc_resid.f:722
subroutine vf_gs_y(VXF_GS)
Definition: vf_gs_y.f:19
subroutine partial_elim_u(VAR_G, VAR_S, VXF, A_M, B_M)
Definition: partial_elim.f:326
logical, dimension(0:dim_m) momentum_y_eq
Definition: run_mod.f:77
subroutine calc_d_ghd_e(A_M, VXF_GS, D_E)
Definition: calc_d_ghd.f:39
double precision, dimension(:,:), allocatable v_s
Definition: fldvar_mod.f:105
double precision, dimension(dim_eqs) ur_fac
Definition: ur_facs_mod.f:6
subroutine partial_elim_ghd_w(VAR_G, VAR_S, VXF, A_M, B_M)
double precision, dimension(:), allocatable e_n
Definition: pscor_mod.f:17
integer ijkend3
Definition: compar_mod.f:80
subroutine conv_dif_w_g(A_M, B_M)
Definition: conv_dif_w_g.f:14
subroutine solve_vel_star(IER)
subroutine solid_drag_w(A_M, B_M)
Definition: solid_drag.f:136
integer dimension_lm
Definition: param1_mod.f:13
double precision, dimension(:,:), allocatable d_n
Definition: pgcor_mod.f:14
Definition: pgcor_mod.f:1
subroutine calc_usr_source(lEQ_NO, A_M, B_M, lB_MMAX, lM, lN)
Definition: usr_src_mod.f:32
integer dimension_3
Definition: param_mod.f:11
subroutine point_source_v_s(A_M, B_M)
Definition: source_v_s.f:1142
integer ijkmax2
Definition: geometry_mod.f:80
subroutine init_ab_m(A_M, B_M, IJKMAX2A, M)
Definition: init_ab_m.f:21
subroutine adjust_a_w_g(A_M, B_M)
Definition: adjust_a_w_g.f:22
double precision, dimension(:,:), allocatable w_s
Definition: fldvar_mod.f:117
subroutine partial_elim_ghd_v(VAR_G, VAR_S, VXF, A_M, B_M)
logical, dimension(0:dim_m) momentum_x_eq
Definition: run_mod.f:74
double precision, dimension(:,:), allocatable den_resid
Definition: residual_mod.f:52
subroutine conv_dif_v_s(A_M, B_M, IER)
Definition: conv_dif_v_s.f:16
subroutine conv_dif_v_g(A_M, B_M, IER)
Definition: conv_dif_v_g.f:14
subroutine ghdmassflux()
Definition: ghdmassflux.f:21
subroutine adjust_a_u_s(A_M, B_M)
Definition: adjust_a_u_s.f:16
subroutine calc_d_n(A_M, VXF_GS, VXF_SS, D_N, IER)
Definition: calc_d_n.f:16
subroutine point_source_w_g(A_M, B_M)
Definition: source_w_g.f:1051
double precision, dimension(:,:), allocatable d_e
Definition: pgcor_mod.f:12
logical, dimension(0:dim_m) momentum_z_eq
Definition: run_mod.f:80
subroutine partial_elim_ghd_u(VAR_G, VAR_S, VXF, A_M, B_M)
subroutine source_v_g(A_M, B_M)
Definition: source_v_g.f:22
subroutine point_source_v_g(A_M, B_M)
Definition: source_v_g.f:935
subroutine updatespeciesvelocities()
Definition: ghdmassflux.f:410
double precision, dimension(:), allocatable e_t
Definition: pscor_mod.f:19
subroutine solid_drag_u(A_M, B_M)
Definition: solid_drag.f:10
double precision, dimension(:,:), allocatable num_resid
Definition: residual_mod.f:49
subroutine gas_drag_u(A_M, B_M, IER)
Definition: gas_drag.f:12
subroutine qmomk_gas_drag(A_M, B_M, IER, UV, VV, WV)
character(len=4), dimension(dim_eqs) leq_sweep
Definition: leqsol_mod.f:20
double precision, dimension(:,:), allocatable d_t
Definition: pgcor_mod.f:16
subroutine calc_d_t(A_M, VXF_GS, VXF_SS, D_T, IER)
Definition: calc_d_t.f:16
subroutine under_relax_w(VAR, A_M, B_M, M, UR)
Definition: under_relax.f:270
subroutine source_v_s(A_M, B_M)
Definition: source_v_s.f:32
subroutine vf_gs_x(VXF_GS)
Definition: vf_gs_x.f:12
double precision, dimension(:,:), allocatable u_s
Definition: fldvar_mod.f:93
subroutine adjust_a_v_g(A_M, B_M)
Definition: adjust_a_v_g.f:22
subroutine conv_dif_w_s(A_M, B_M)
Definition: conv_dif_w_s.f:16
subroutine point_source_u_g(A_M, B_M)
Definition: source_u_g.f:1023
subroutine partial_elim_w(VAR_G, VAR_S, VXF, A_M, B_M)
Definition: partial_elim.f:689
subroutine source_w_g(A_M, B_M)
Definition: source_w_g.f:24
subroutine u_m_star(U_g_tmp, U_s_tmp)
subroutine calc_e_n(A_M, MCP, E_N)
Definition: calc_e.f:101
subroutine save(U_g_tmp, V_g_tmp, W_g_tmp, U_s_tmp, V_s_tmp, W_s_t
integer, parameter resid_w
Definition: residual_mod.f:14
subroutine calc_d_ghd_n(A_M, VXF_GS, D_N)
Definition: calc_d_ghd.f:288
double precision, dimension(:,:), allocatable max_resid
Definition: residual_mod.f:40
subroutine calc_e_t(A_M, MCP, E_T)
Definition: calc_e.f:180
integer mmax
Definition: physprop_mod.f:19
integer, dimension(dim_eqs) leq_it
Definition: leqsol_mod.f:11
subroutine v_m_star(V_g_tmp, V_s_tmp)
subroutine vf_ss_z(VXF_SS)
Definition: vf_gs_z.f:100
subroutine source_u_g(A_M, B_M)
Definition: source_u_g.f:24
integer, parameter resid_v
Definition: residual_mod.f:13
double precision, dimension(:), allocatable v_g
Definition: fldvar_mod.f:99
subroutine solid_drag_v(A_M, B_M)
Definition: solid_drag.f:75
subroutine adjust_leq(RESID, LEQ_ITL, LEQ_METHODL, LEQI, LEQM)
Definition: adjust_leq.f:21
double precision, dimension(:), allocatable w_g
Definition: fldvar_mod.f:111
subroutine gas_drag_w(A_M, B_M, IER)
Definition: gas_drag.f:289
double precision, dimension(dim_eqs) leq_tol
Definition: leqsol_mod.f:23
subroutine adjust_a_v_s(A_M, B_M)
Definition: adjust_a_v_s.f:14
Definition: pscor_mod.f:1
subroutine source_u_s(A_M, B_M)
Definition: source_u_s.f:30
Definition: run_mod.f:13
Definition: param_mod.f:2
integer mcp
Definition: pscor_mod.f:38
integer, dimension(:,:), allocatable ijk_resid
Definition: residual_mod.f:46
subroutine under_relax_v(VAR, A_M, B_M, M, UR)
Definition: under_relax.f:187
subroutine conv_dif_u_g(A_M, B_M)
Definition: conv_dif_u_g.f:14
subroutine calc_d_e(A_M, VXF_GS, VXF_SS, D_E, IER)
Definition: calc_d_e.f:16
integer, parameter resid_u
Definition: residual_mod.f:12
logical do_k
Definition: geometry_mod.f:30
subroutine calc_resid_w(U_M, V_M, W_M, A_M, B_M, M, NUM, DEN, RESID, MAX_RESID, IJK_RESID)
Definition: calc_resid.f:1130
subroutine calc_d_ghd_t(A_M, VXF_GS, D_T)
Definition: calc_d_ghd.f:537
integer ijkstart3
Definition: compar_mod.f:80
subroutine vf_gs_z(VXF_GS)
Definition: vf_gs_z.f:19
subroutine calc_resid_v(U_M, V_M, W_M, A_M, B_M, M, NUM, DEN, RESID, MAX_RESID, IJK_RESID)
Definition: calc_resid.f:925
double precision, dimension(:), allocatable u_g
Definition: fldvar_mod.f:87
subroutine w_m_star(W_g_tmp, W_s_tmp)
subroutine conv_dif_u_s(A_M, B_M)
Definition: conv_dif_u_s.f:15
subroutine vf_ss_y(VXF_SS)
Definition: vf_gs_y.f:97
subroutine adjust_a_u_g(A_M, B_M)
Definition: adjust_a_u_g.f:22
subroutine point_source_u_s(A_M, B_M)
Definition: source_u_s.f:1150
Definition: ps_mod.f:22
integer, dimension(dim_eqs) leq_method
Definition: leqsol_mod.f:14
subroutine calc_e_e(A_M, MCP, E_E)
Definition: calc_e.f:21
subroutine under_relax_u(VAR, A_M, B_M, M, UR)
Definition: under_relax.f:104
logical, dimension(dim_eqs) call_usr_source
Definition: usr_src_mod.f:7
double precision, dimension(:,:), allocatable resid
Definition: residual_mod.f:37
double precision, dimension(:), allocatable e_e
Definition: pscor_mod.f:15
logical point_source
Definition: ps_mod.f:27
subroutine calc_external_forces()
subroutine vf_ss_x(VXF_SS)
Definition: vf_gs_x.f:90
subroutine partial_elim_v(VAR_G, VAR_S, VXF, A_M, B_M)
Definition: partial_elim.f:511
subroutine source_w_s(A_M, B_M)
Definition: source_w_s.f:32
integer dimension_m
Definition: param_mod.f:18
subroutine gas_drag_v(A_M, B_M, IER)
Definition: gas_drag.f:150
double precision, parameter zero
Definition: param1_mod.f:27
subroutine point_source_w_s(A_M, B_M)
Definition: source_w_s.f:1191
subroutine adjust_a_w_s(A_M, B_M)
Definition: adjust_a_w_s.f:16
subroutine solve_lin_eq(VNAME, Vno, VAR, A_M, B_M, M, ITMAX, METHOD, SWEEP, TOL1, PC, IER)
Definition: solve_lin_eq.f:19
character(len=4), dimension(dim_eqs) leq_pc
Definition: leqsol_mod.f:26
subroutine init(U_g_tmp, V_g_tmp, W_g_tmp, U_s_tmp, V_s_tmp, W_s_t