MFIX  2016-1
solve_epp.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvC
2 ! C
3 ! Subroutine: SOLVE_Epp C
4 ! Purpose: Solve solids volume fraction correction equation. C
5 ! C
6 ! Notes: MCP must be defined to call this routine. C
7 ! C
8 ! Author: M. Syamlal Date: 25-SEP-96 C
9 ! C
10 ! C
11 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^C
12  SUBROUTINE solve_epp(NORMS, RESS, IER)
13 
14 ! Modules
15 !---------------------------------------------------------------------//
16  use ambm, only: a_m, b_m, lock_ambm, unlock_ambm
17  use geometry, only: ijkmax2
19  use param, only: dimension_3, dimension_m
20  use param1, only: undefined_i, zero, one
21  use ps, only: point_source
22  use pscor, only: epp, mcp
23  use residual, only: resid, max_resid, ijk_resid
24  use residual, only: num_resid, den_resid
25  use residual, only: resid_p
26  use run, only: momentum_x_eq, momentum_y_eq
28  use usr_src, only: solids_correction
29  IMPLICIT NONE
30 
31 ! Local parameters
32 !---------------------------------------------------------------------//
33 ! Parameter to make tolerance for residual scaled with max value
34 ! compatible with residual scaled with first iteration residual.
35 ! Increase it to tighten convergence.
36  DOUBLE PRECISION, PARAMETER :: DEN = 1.0d1 !5.0D2
37 
38 ! Dummy arguments
39 !---------------------------------------------------------------------//
40 ! Normalization factor for solids volume fraction correction residual.
41 ! At start of the iterate loop norms will either be 1 (i.e. not
42 ! normalized) or a user defined value given by norm_s. If norm_s
43 ! was set to zero then the normalization is based on dominate
44 ! term in the equation
45  DOUBLE PRECISION, INTENT(IN) :: NORMs
46 ! solids volume fraction correction residual
47  DOUBLE PRECISION, INTENT(OUT) :: RESs
48 ! Error index
49  INTEGER, INTENT(INOUT) :: IER
50 
51 ! Local variables
52 !-----------------------------------------------
53 ! solids phase index locally assigned to mcp
54 ! mcp is the lowest index of those solids phases that are close_packed
55 ! and of the solids phase that is used for the solids correction
56 ! equation.
57  INTEGER :: M
58 ! Normalization factor for solids volume fraction correction residual
59  DOUBLE PRECISION :: NORMSloc
60 ! linear equation solver method and iterations
61  INTEGER :: LEQM, LEQI
62 
63 ! temporary use of global arrays:
64 ! arraym1 (locally b_mmax)
65 ! vector B_M based on dominate term in correction equation
66  DOUBLE PRECISION :: B_MMAX(dimension_3, dimension_m)
67 ! Septadiagonal matrix A_m, vector B_m
68 ! DOUBLE PRECISION A_m(DIMENSION_3, -3:3, 0:DIMENSION_M)
69 ! DOUBLE PRECISION B_m(DIMENSION_3, 0:DIMENSION_M)
70 !---------------------------------------------------------------------//
71 
72 ! Note that currently this subroutine is only called when MMAX=1 AND
73 ! MCP is defined. This combintion effectively means solids phase 1
74 ! can close pack.
75  IF (mcp == undefined_i) THEN
76 ! this error should be caught earlier in the routines so that this
77 ! branch should never be entered
78  RETURN
79  ELSE
80 ! the lowest solids phase index of those solids phases that can close
81 ! pack (i.e. close_packed=T) and the index of the solids phase that is
82 ! used to form the solids correction equation.
83  m = mcp
84  ENDIF
85  call lock_ambm
86 
87 ! Form the sparse matrix equation. Note that the index 0 is explicitly
88 ! used throughout this routine for creating the matrix equation.
89 ! However, the equation is based on the index of MCP.
90 
91 ! initializing
92  CALL init_ab_m (a_m, b_m, ijkmax2, 0)
93  epp(:) = zero
94 
95  CALL conv_source_epp (a_m, b_m, b_mmax, m)
96 
97 ! Add point source contributions.
98  IF(point_source) CALL point_source_epp (b_m, b_mmax, m)
99 
100 ! Add usr source contributions
101  IF(call_usr_source(2)) CALL calc_usr_source(solids_correction, &
102  a_m, b_m, lb_mmax=b_mmax, lm=m)
103 
104 ! call check_ab_m(a_m, b_m, 0, .false., ier)
105 ! call write_ab_m(a_m, b_m, ijkmax2, 0, ier)
106 ! call test_lin_eq(ijkmax2, ijmax2, imax2, a_m(1, -3, 0), 1, &
107 ! DO_K, ier)
108 
109 
110 ! Find average residual, maximum residual and location
111  normsloc = norms
112  IF(norms == zero) THEN
113 ! calculate the residual based on dominate term in correction equation
114 ! and use this to form normalization factor
115  CALL calc_resid_pp (b_mmax, one, num_resid(resid_p,m), &
116  den_resid(resid_p,m), resid(resid_p,m), &
117  max_resid(resid_p,m), ijk_resid(resid_p,m))
118  normsloc = resid(resid_p,m)/den
119  ENDIF
120 
121  CALL calc_resid_pp (b_m, normsloc, num_resid(resid_p,m), &
122  den_resid(resid_p,m), resid(resid_p,m), max_resid(resid_p,m), &
123  ijk_resid(resid_p,m))
124  ress = resid(resid_p,m)
125 ! write(*,*) resid(resid_p, 1), max_resid(resid_p, 1), &
126 ! ijk_resid(resid_p, 1)
127 
128 
129 ! Solve EP_s_prime equation
130  CALL adjust_leq(resid(resid_p,m), leq_it(2), leq_method(2),&
131  leqi, leqm)
132 ! note index 0 is used here since that is the index that was used for
133 ! creating this matrix equation
134  CALL solve_lin_eq ('EPp', 2, epp, a_m, b_m, 0, leqi, leqm, &
135  leq_sweep(2), leq_tol(2), leq_pc(2), ier)
136 
137 ! call out_array(EPp, 'EPp')
138 
139  call unlock_ambm
140 
141  RETURN
142  END SUBROUTINE solve_epp
double precision, dimension(:,:,:), allocatable a_m
Definition: ambm_mod.f:27
logical, dimension(0:dim_m) momentum_y_eq
Definition: run_mod.f:77
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
subroutine solve_epp(NORMS, RESS, IER)
Definition: solve_epp.f:13
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_source_epp(A_M, B_M, B_mmax, M)
double precision, dimension(:,:), allocatable num_resid
Definition: residual_mod.f:49
Definition: ambm_mod.f:16
double precision, dimension(:), allocatable epp
Definition: pscor_mod.f:25
character(len=4), dimension(dim_eqs) leq_sweep
Definition: leqsol_mod.f:20
double precision, dimension(:,:), allocatable max_resid
Definition: residual_mod.f:40
integer, dimension(dim_eqs) leq_it
Definition: leqsol_mod.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
subroutine adjust_leq(RESID, LEQ_ITL, LEQ_METHODL, LEQI, LEQM)
Definition: adjust_leq.f:21
double precision, dimension(dim_eqs) leq_tol
Definition: leqsol_mod.f:23
Definition: pscor_mod.f:1
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
integer, parameter undefined_i
Definition: param1_mod.f:19
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_m
Definition: param_mod.f:18
subroutine point_source_epp(B_M, B_MMAX, M)
double precision, parameter zero
Definition: param1_mod.f:27
subroutine unlock_ambm
Definition: ambm_mod.f:52
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