MFIX  2016-1
solve_pp_g.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Subroutine: SOLVE_Pp_g C
4 ! Purpose: Solve fluid pressure correction equation C
5 ! C
6 ! Author: M. Syamlal Date: 19-JUN-96 C
7 ! C
8 ! C
9 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
10  SUBROUTINE solve_pp_g(NORMG, RESG, IER)
11 
12 ! Modules
13 !---------------------------------------------------------------------//
14  use ambm, only: a_m, b_m, lock_ambm, unlock_ambm
15  use geometry, only: ijkmax2
17  use param, only: dimension_3, dimension_m
18  use param1, only: zero, one, undefined
19  use pgcor, only: pp_g
20  use physprop, only: mmax, ro_g0
21  use ps, only: point_source
22  use residual, only: resid, max_resid, ijk_resid
23  use residual, only: num_resid, den_resid
24  use residual, only: resid_p
25  use run, only: momentum_x_eq, momentum_y_eq
27  use usr_src, only: pressure_correction
28  IMPLICIT NONE
29 
30 ! Local parameters
31 !---------------------------------------------------------------------//
32 ! Parameter to make tolerance for residual scaled with max value
33 ! compatible with residual scaled with first iteration residual.
34 ! Increase it to tighten convergence.
35  DOUBLE PRECISION, PARAMETER :: DEN = 1.0d1 !5.0D2
36 
37 ! Dummy arguments
38 !---------------------------------------------------------------------//
39 ! Normalization factor for gas pressure correction residual.
40 ! At start of the iterate loop normg will either be 1 (i.e. not
41 ! normalized) or a user defined value given by norm_g. If norm_g
42 ! was set to zero then the normalization is based on dominate
43 ! term in the equation
44  DOUBLE PRECISION, INTENT(IN) :: NORMg
45 ! gas pressure correction residual
46  DOUBLE PRECISION, INTENT(OUT) :: RESg
47 ! Error index
48  INTEGER, INTENT(INOUT) :: IER
49 
50 ! Local variables
51 !---------------------------------------------------------------------//
52 ! phase index
53  INTEGER :: M
54 ! Normalization factor for gas pressure correction residual
55  DOUBLE PRECISION :: NORMGloc
56 ! linear equation solver method and iterations
57  INTEGER :: LEQM, LEQI
58 
59 ! temporary use of global arrays:
60 ! arraym1 (locally b_mmax)
61 ! vector B_M based on dominate term in correction equation
62  DOUBLE PRECISION :: B_MMAX(dimension_3, dimension_m)
63 ! Septadiagonal matrix A_m, vector B_m
64 ! DOUBLE PRECISION A_m(DIMENSION_3, -3:3, 0:DIMENSION_M)
65 ! DOUBLE PRECISION B_m(DIMENSION_3, 0:DIMENSION_M)
66 !---------------------------------------------------------------------//
67 
68  call lock_ambm
69 
70 ! initializing
71  pp_g(:) = zero
72  DO m = 0, mmax
73  CALL init_ab_m (a_m, b_m, ijkmax2, m)
74  ENDDO
75 
76 ! If gas momentum equations in x and y directions are not solved return
77  IF (.NOT.(momentum_x_eq(0) .OR. momentum_y_eq(0)) .AND.&
78  ro_g0 .NE. undefined) THEN
79  call unlock_ambm
80  RETURN
81  ENDIF
82 
83 ! Forming the sparse matrix equation.
84  CALL conv_pp_g (a_m, b_m)
85  CALL source_pp_g (a_m, b_m, b_mmax)
86  IF(point_source) CALL point_source_pp_g (b_m, b_mmax)
87  IF(call_usr_source(1)) CALL calc_usr_source(pressure_correction,&
88  a_m, b_m, lb_mmax=b_mmax, lm=0)
89 
90 ! call check_ab_m(a_m, b_m, 0, .false., ier)
91 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
92 
93 
94 ! Find average residual, maximum residual and location
95  normgloc = normg
96  IF(normg == zero) THEN
97 ! calculating the residual based on dominate term in correction equation
98 ! and use this to form normalization factor
99  CALL calc_resid_pp (b_mmax, one, num_resid(resid_p,0), &
100  den_resid(resid_p,0), resid(resid_p,0), max_resid(resid_p,0), &
101  ijk_resid(resid_p,0))
102  normgloc = resid(resid_p,0)/den
103  ENDIF
104  CALL calc_resid_pp (b_m, normgloc, num_resid(resid_p,0), &
105  den_resid(resid_p,0), resid(resid_p,0), max_resid(resid_p,0), &
106  ijk_resid(resid_p,0))
107  resg = resid(resid_p,0)
108 ! write(*,*) resid(resid_p, 0), max_resid(resid_p, 0), &
109 ! ijk_resid(resid_p, 0)
110 
111 
112 ! Solve P_g_prime equation
113  leqi = leq_it(1)
114  leqm = leq_method(1)
115 ! CALL ADJUST_LEQ(RESID(RESID_P,0),LEQ_IT(1),LEQ_METHOD(1),LEQI,LEQM,IER)
116 
117 ! call check_symmetry(A_m, 0, IER)
118 ! call test_lin_eq(A_M, LEQ_IT(1),LEQ_METHOD(1), LEQ_SWEEP(1), LEQ_TOL(1), LEQ_PC(1),0,IER)
119  CALL solve_lin_eq ('Pp_g', 1, pp_g, a_m, b_m, 0, leqi, leqm, &
120  leq_sweep(1), leq_tol(1), leq_pc(1), ier)
121 
122 ! call out_array(Pp_g, 'Pp_g')
123 
124  call unlock_ambm
125 
126  RETURN
127  END SUBROUTINE solve_pp_g
128 
129 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
130 ! C
131 ! Subroutine: POINT_SOURCE_Pp_g C
132 ! Purpose: Adds point sources to the Pressure correction equation. C
133 ! C
134 ! Notes: The off-diagonal coefficients are positive. The center C
135 ! coefficient and the source vector are negative. See C
136 ! conv_Pp_g C
137 ! C
138 ! Author: J. Musser Date: 10-JUN-13 C
139 ! Reviewer: Date: C
140 ! C
141 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
142  SUBROUTINE point_source_pp_g(B_M, B_mmax)
144 ! Modules
145 !-----------------------------------------------
146  use compar, only: dead_cell_at
147  use geometry, only: vol
148  use functions, only: fluid_at, funijk
149  use functions, only: is_on_mype_plus2layers
150  use param, only: dimension_3, dimension_m
151  use param1, only: small_number
152  use ps, only: ps_defined, dimension_ps
153  use ps, only: ps_massflow_g, ps_volume
154  use ps, only: ps_k_b, ps_k_t
155  use ps, only: ps_j_s, ps_j_n
156  use ps, only: ps_i_w, ps_i_e
157  IMPLICIT NONE
158 
159 ! Dummy arguments
160 !-----------------------------------------------
161 ! Vector b_m
162  DOUBLE PRECISION, INTENT(INOUT) :: B_m(dimension_3, 0:dimension_m)
163 ! maximum term in b_m expression
164  DOUBLE PRECISION, INTENT(INOUT) :: B_mmax(dimension_3, 0:dimension_m)
165 
166 ! Local Variables
167 !-----------------------------------------------
168 ! Indices
169  INTEGER :: IJK, I, J, K
170  INTEGER :: PSV
171 
172 ! terms of bm expression
173  DOUBLE PRECISION pSource
174 
175 !-----------------------------------------------
176  ps_lp: do psv = 1, dimension_ps
177 
178  if(.NOT.ps_defined(psv)) cycle ps_lp
179  if(ps_massflow_g(psv) < small_number) cycle ps_lp
180 
181  do k = ps_k_b(psv), ps_k_t(psv)
182  do j = ps_j_s(psv), ps_j_n(psv)
183  do i = ps_i_w(psv), ps_i_e(psv)
184 
185  if(.NOT.is_on_mype_plus2layers(i,j,k)) cycle
186  IF (dead_cell_at(i,j,k)) cycle ! skip dead cells
187 
188  ijk = funijk(i,j,k)
189  if(fluid_at(ijk)) then
190  psource = ps_massflow_g(psv) * (vol(ijk)/ps_volume(psv))
191 
192  b_m(ijk,0) = b_m(ijk,0) - psource
193  b_mmax(ijk,0) = max(abs(b_mmax(ijk,0)), abs(b_m(ijk,0)))
194  endif
195 
196  enddo
197  enddo
198  enddo
199 
200  enddo ps_lp
201 
202  RETURN
203  END SUBROUTINE point_source_pp_g
double precision, dimension(:,:,:), allocatable a_m
Definition: ambm_mod.f:27
integer, dimension(dimension_ps) ps_i_w
Definition: ps_mod.f:40
logical, dimension(0:dim_m) momentum_y_eq
Definition: run_mod.f:77
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
double precision, parameter one
Definition: param1_mod.f:29
integer dimension_3
Definition: param_mod.f:11
integer, parameter resid_p
Definition: residual_mod.f:10
integer ijkmax2
Definition: geometry_mod.f:80
subroutine init_ab_m(A_M, B_M, IJKMAX2A, M)
Definition: init_ab_m.f:21
logical, dimension(0:dim_m) momentum_x_eq
Definition: run_mod.f:74
double precision, dimension(:,:), allocatable den_resid
Definition: residual_mod.f:52
integer, dimension(dimension_ps) ps_j_n
Definition: ps_mod.f:43
double precision, dimension(:,:), allocatable num_resid
Definition: residual_mod.f:49
Definition: ambm_mod.f:16
character(len=4), dimension(dim_eqs) leq_sweep
Definition: leqsol_mod.f:20
double precision, parameter undefined
Definition: param1_mod.f:18
double precision, dimension(dimension_ps) ps_massflow_g
Definition: ps_mod.f:48
logical, dimension(dimension_ps) ps_defined
Definition: ps_mod.f:29
double precision, dimension(:), allocatable pp_g
Definition: pgcor_mod.f:19
double precision, dimension(dimension_ps) ps_volume
Definition: ps_mod.f:84
subroutine source_pp_g(A_M, B_M, B_MMAX)
Definition: source_pp_g.f:19
integer, dimension(dimension_ps) ps_k_b
Definition: ps_mod.f:44
double precision, dimension(:,:), allocatable max_resid
Definition: residual_mod.f:40
integer mmax
Definition: physprop_mod.f:19
integer, dimension(dim_eqs) leq_it
Definition: leqsol_mod.f:11
logical, dimension(:,:,:), allocatable dead_cell_at
Definition: compar_mod.f:127
subroutine conv_pp_g(A_M, B_M)
Definition: conv_pp_g.f:34
double precision ro_g0
Definition: physprop_mod.f:59
double precision, parameter small_number
Definition: param1_mod.f:24
subroutine solve_pp_g(NORMG, RESG, IER)
Definition: solve_pp_g.f:11
subroutine lock_ambm
Definition: ambm_mod.f:38
subroutine calc_resid_pp(B_M, NORM, NUM, DEN, RESID, MAX_RESID, IJK_RESID)
Definition: calc_resid.f:393
integer, dimension(dimension_ps) ps_k_t
Definition: ps_mod.f:45
double precision, dimension(dim_eqs) leq_tol
Definition: leqsol_mod.f:23
Definition: run_mod.f:13
Definition: param_mod.f:2
integer, dimension(:,:), allocatable ijk_resid
Definition: residual_mod.f:46
Definition: ps_mod.f:22
integer, dimension(dim_eqs) leq_method
Definition: leqsol_mod.f:14
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 b_m
Definition: ambm_mod.f:28
logical point_source
Definition: ps_mod.f:27
integer, dimension(dimension_ps) ps_j_s
Definition: ps_mod.f:42
double precision, dimension(:), allocatable vol
Definition: geometry_mod.f:212
integer dimension_m
Definition: param_mod.f:18
integer, dimension(dimension_ps) ps_i_e
Definition: ps_mod.f:41
double precision, parameter zero
Definition: param1_mod.f:27
subroutine unlock_ambm
Definition: ambm_mod.f:52
subroutine point_source_pp_g(B_M, B_mmax)
Definition: solve_pp_g.f:143
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