MFIX  2016-1
diffuse_mean_fields.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! Subroutine: DIFFUSE_MEAN_FIELDS !
4 ! Author: J.Musser Date: 11-NOV-14 !
5 ! !
6 ! Purpose: Given the field variable PHI (e.g., volume fraction), !
7 ! diffuse it across the Eulerian grid such that the Full Width at !
8 ! Half Maximum (FWHM) equals the user specified diffusion width. !
9 ! !
10 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
11  SUBROUTINE diffuse_mean_field(PHI, VNAME)
12 
13 ! Global Variables:
14 !---------------------------------------------------------------------//
15 ! Max bound for array sizes.
16  use geometry, only: ijkmax2
17 ! Coefficient matrix and force vector.
18  use ambm, only: a_m, b_m
19 ! Method to solve linear system and max iterations
20  use leqsol, only: leq_method, leq_it
21 ! Preconditioner, sweep method, convergence tolerance
22  use leqsol, only: leq_pc, leq_sweep, leq_tol
23 ! Size of fluid variable arrays.
24  use param, only: dimension_3
25 
26 ! Module procedures
27 !---------------------------------------------------------------------//
28 ! Routines to manage messages to user.
29  use error_manager
30  use machine, only: wall_time
31 
32  IMPLICIT NONE
33 
34 ! Dummy Arguments:
35 !---------------------------------------------------------------------//
36 ! Variable to diffuse
37  DOUBLE PRECISION, INTENT(INOUT) :: PHI(dimension_3)
38 ! Name of variable to diffuse
39  CHARACTER(LEN=*), INTENT(IN) :: VNAME
40 
41 ! Local Variables:
42 !---------------------------------------------------------------------//
43 ! Integer error flag
44  INTEGER :: IER
45 ! Linear equation solver method and iterations
46  INTEGER :: LEQM, LEQI
47 ! Start, stop and step size of diffusion time march
48  DOUBLE PRECISION :: DIF_TIME, DIF_STOP, DIF_DT
49 ! wall time at start
50  DOUBLE PRECISION :: WALL_START
51 ! Local flag to print debug messages
52  LOGICAL, PARAMETER :: setDBG = .true.
53  DOUBLE PRECISION, DIMENSION(:), ALLOCATABLE :: DIF
54 !......................................................................!
55 
56  IF(setdbg) THEN
57  WRITE(err_msg, "(/3x,'Diffusing Variable: ',A)") vname
58  CALL flush_err_msg(header=.false., footer=.false.)
59  wall_start = wall_time()
60  ENDIF
61 
62 ! Populate the diffusion coefficients
63  CALL calc_dif_des(dif, setdbg, ier)
64 
65  dif_stop = 1.0d0
66  dif_time = 0.0d0
67  dif_dt = dif_stop/5.0
68 
69 ! Integrate the diffusion equation (time, space)
70  DO WHILE(dif_time < dif_stop)
71 ! Initialize the coefficient matrix and force vector
72  CALL init_ab_m (a_m, b_m, ijkmax2, 0)
73 ! Calculate the coefficients
74  CALL dif_phi_des(0, dif, a_m, b_m)
75 ! Apply zero-flux BC at all walls
76  CALL dif_phi_bc_des(phi, 0, a_m, b_m)
77 ! Collect the center coefficient and force vector
78  CALL dif_phi_source_des(phi, 0, a_m, b_m, dif_dt)
79 ! Set the local method and iterations.
80  CALL adjust_leq(0.0d0, leq_it(10), leq_method(10), leqi, leqm)
81 ! Solve the linear system.
82  CALL solve_lin_eq (vname, 10, phi, a_m, b_m, 0, leqi, leqm, &
83  leq_sweep(10), leq_tol(10), leq_pc(10), ier)
84 ! Advance time.
85  dif_time = dif_time + dif_dt
86  ENDDO
87 
88 ! Debugging information
89  IF(setdbg) THEN
90  WRITE(err_msg, 9001) wall_time() - wall_start
91  CALL flush_err_msg(header=.false., footer=.false.)
92  ENDIF
93 
94  9001 FORMAT(5x,'Wall Time: ',g11.4)
95 
96  RETURN
97  END SUBROUTINE diffuse_mean_field
98 
99 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
100 ! !
101 ! Subroutine: CALC_DIF_DES !
102 ! Author: J.Musser Date: 11-NOV-14 !
103 ! !
104 ! Purpose: Calculate the diffusion coefficient for diffusing mean !
105 ! fields. Presently the diffusion coefficient is constant. !
106 ! !
107 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
108  SUBROUTINE calc_dif_des(DIF, lDBG, IER)
110  use param
111  use param1
112 
113  use compar, only: ijkstart3, ijkend3
115  use functions, only: fluid_at
116 
117  use error_manager
118 
119  IMPLICIT NONE
120 
121  DOUBLE PRECISION, INTENT(INOUT) :: DIF(dimension_3)
122  LOGICAL, INTENT(IN) :: lDBG
123  INTEGER, INTENT(INOUT) :: IER
124 
125 ! Fluid Cell indices
126  INTEGER :: IJK
127 
128  DOUBLE PRECISION :: lDIF
129 
130  ier = 0
131 
132 ! The diffusion coefficient is set so that over one second, the
133 ! quantity diffuses such that the Full Width at Half Maximum (FWHM)
134 ! equals what the user specified as the "filter wideth."
135  ldif = ((0.5*des_diffuse_width)**2) / &
136  (2.0*sqrt(2.0*log(2.0)))
137 
138 ! Store the diffusion coefficient in all fluid cells.
139  DO ijk = ijkstart3, ijkend3
140  dif(ijk) = zero
141  IF(fluid_at(ijk)) dif(ijk) = ldif
142  ENDDO
143 
144 ! Information included for debugging.
145  IF(ldbg) THEN
146  WRITE(err_msg, 9100) ival(ldif)
147  CALL flush_err_msg(header=.false., footer=.false.)
148  ENDIF
149 
150  9100 FORMAT(/3x,'Diffusion Coefficient: ',a)
151 
152  RETURN
153  END SUBROUTINE calc_dif_des
double precision, dimension(:,:,:), allocatable a_m
Definition: ambm_mod.f:27
subroutine dif_phi_des(M, DIF, A_M, B_M)
Definition: dif_phi_des.f:10
integer ijkend3
Definition: compar_mod.f:80
integer dimension_3
Definition: param_mod.f:11
integer ijkmax2
Definition: geometry_mod.f:80
subroutine init_ab_m(A_M, B_M, IJKMAX2A, M)
Definition: init_ab_m.f:21
double precision function wall_time()
Definition: machine_mod.f:135
Definition: ambm_mod.f:16
character(len=4), dimension(dim_eqs) leq_sweep
Definition: leqsol_mod.f:20
subroutine diffuse_mean_field(PHI, VNAME)
subroutine calc_dif_des(DIF, lDBG, IER)
integer, dimension(dim_eqs) leq_it
Definition: leqsol_mod.f:11
subroutine dif_phi_source_des(PHI, M, A_M, B_M, lDT)
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
double precision des_diffuse_width
Definition: param_mod.f:2
integer ijkstart3
Definition: compar_mod.f:80
character(len=line_length), dimension(line_count) err_msg
integer, dimension(dim_eqs) leq_method
Definition: leqsol_mod.f:14
double precision, dimension(:,:), allocatable b_m
Definition: ambm_mod.f:28
double precision, parameter zero
Definition: param1_mod.f:27
subroutine dif_phi_bc_des(PHI, M, A_M, B_M)
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
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