MFIX  2016-1
check_solids_model_prereqs.f
Go to the documentation of this file.
1 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
2 ! !
3 ! SUBROUTINE: CHECK_SOLIDS_MODEL_PREREQS !
4 ! Purpose: Check the distributed parallel namelist variables. !
5 ! !
6 ! Author: P. Nicoletti Date: 14-DEC-99 !
7 ! Reviewer: J.Musser Date: 16-Jan-14 !
8 ! !
9 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
11 
12 ! Modules
13 !---------------------------------------------------------------------//
14 ! Flag: Use DES E-L model
15  use discretelement, only: discrete_element
16 ! Flag: Use TFM and DEM solids models.
17  use discretelement, only: des_continuum_hybrid
18 ! Flag: gas/solids E-L simulation, otherwise granular flow.
19  use discretelement, only: des_continuum_coupled
20 ! Flag: Fluid affects particles, but particles do not impact fluid.
21  use discretelement, only: des_oneway_coupled
22 ! Number of discrete solids phases.
23  use discretelement, only: des_mmax
24 ! Print E-L data.
25  use discretelement, only: print_des_data
26 
27  use error_manager
28 
29 ! Maximum number of solids phases.
30  use param, only: dim_m
31 
32 ! Number of phases specified by the user.
33  use physprop, only: mmax, smax
34 ! User specified constant gas density
35  use physprop, only: ro_g0
36 
37 ! Flag: Use MPPIC E-L model
38  use mfix_pic, only: mppic
39 ! Flag: Method of manufactured solutions (MMS)
40  use mms, only: use_mms
41 
42  use run, only: solids_model
43 ! Flag: Use DES E-E solids model
44  use run, only: tfm_solids, tfm_count
45  use run, only: dem_solids, dem_count
46  use run, only: pic_solids, pic_count
47 ! Flag: Solve species eq.
48  USE run, only: species_eq, any_species_eq
49 ! Kinetic theory model for TFM solids.
50  use run, only: kt_type
51 
52 ! Number of scalar equations to solve
53  USE scalars, only: nscalar, phase4scalar
54 ! Phase associated with scalar transport.
55  USE scalars, only: phase4scalar
56  implicit none
57 
58 ! Local Variables
59 !---------------------------------------------------------------------//
60 ! Loop counter
61  INTEGER :: M ! Phase index
62 ! Error indicator for mmax
63  LOGICAL :: ERR_MMAX
64 ! Dummy integer
65  INTEGER :: N
66 !......................................................................!
67 
68 
69 ! Initialize the error manager.
70  CALL init_err_msg("CHECK_SOLIDS_MODEL_PREREQS")
71 
72 ! Moved this here but will need to discuss if this is best route
73 ! going forward
74  err_mmax = .false.
75  IF (mmax < 0) err_mmax = .true.
76  IF(trim(kt_type) == 'GHD') THEN
77  IF (mmax+1 > dim_m) err_mmax = .true.
78  ELSE
79  IF (mmax > dim_m) err_mmax = .true.
80  ENDIF
81  IF((use_mms).AND.(mmax > 1)) err_mmax = .true.
82 
83 ! Check MMAX
84  IF (err_mmax) THEN
85  WRITE(err_msg, 1000) ival(dim_m)
86  CALL flush_err_msg(abort=.true.)
87  ENDIF
88  1000 FORMAT('Error 1000: MMAX out of range. Min: 0, Max: ',a)
89 
90 ! Loop over the phases to see what was specified.
91  DO m=1, mmax
92  solids_model(m) = trim(adjustl(solids_model(m)))
93  SELECT CASE(solids_model(m))
94  CASE ('TFM'); tfm_count = tfm_count + 1
95  CASE ('DEM'); dem_count = dem_count + 1
96  CASE ('PIC'); pic_count = pic_count + 1
97 
98  CASE DEFAULT
99  WRITE(err_msg,1001) ivar('SOLIDS_MODEL',m), solids_model(m)
100  CALL flush_err_msg(abort=.true.)
101 
102  1001 FORMAT('Error 1001: Unknown solids model: ',a,' = ',a)
103 
104  END SELECT
105  ENDDO
106 
107 ! Set the number of discrete phases.
108  des_mmax = dem_count + pic_count
109 
110 ! Set the number of TFM phases. (should be equivalent to tfm_count)
111  mmax = mmax - des_mmax
112  smax = mmax ! USE smax in the TFM code for the number of TFM phases
113 ! For GHD theory increase MMAX by one to serve as 'mixture' phase
114  IF(trim(kt_type) == 'GHD') THEN
115  mmax = mmax + 1
116  tfm_count = tfm_count + 1
117  solids_model(mmax) = 'TFM'
118  ENDIF
119 
120 
121 ! Clear out the unused phases.
122  solids_model((mmax+des_mmax)+1:dim_m) = '---'
123 
124 ! Set the runtime flags:
125  tfm_solids = (tfm_count > 0)
126  dem_solids = (dem_count > 0)
127  pic_solids = (pic_count > 0)
128 
129 ! MPPIC and continuum solids don't mix.
130  IF(pic_solids .AND. tfm_solids)THEN
131  WRITE(err_msg, 1002)
132  CALL flush_err_msg(abort=.true.)
133  ENDIF
134  1002 FORMAT('Error 1002: MPPIC solids and continuum solids cannot ',&
135  'be combined.',/'Please correct the mfix.dat file.')
136 
137 
138 ! MPPIC and DEM solids don't mix.
139  IF(pic_solids .AND. dem_solids)THEN
140  WRITE(err_msg, 1003)
141  CALL flush_err_msg(abort=.true.)
142  ENDIF
143  1003 FORMAT('Error 1003: MPPIC solids and DES solids cannot be ', &
144  'combined.',/'Please correct the mfix.dat file.')
145 
146 ! temporary move for now since these rely on definition of mmax/smax
147 ! Set variable ANY_SPECIES_EQ
148  m = max(smax, des_mmax)
149  any_species_eq = any(species_eq(:m))
150 
151 ! Check phase specification for scalars
152  DO n = 1, nscalar
153  IF(phase4scalar(n) < 0 .OR. phase4scalar(n) > mmax) THEN
154  WRITE(err_msg,1004) ivar('Phase4Scalar',n), &
155  ival(phase4scalar(n))
156  CALL flush_err_msg(abort=.true.)
157  ENDIF
158  ENDDO
159  1004 FORMAT('Error 1004: Illegal or unknown input: ',a,' = ',a,/ &
160  'Please correct the mfix.dat file.')
161 
162 ! Set the DEM runtime flag.
163  discrete_element = dem_solids .OR. pic_solids
164 ! Set the MMPIC runtime flag.
165  mppic = pic_solids
166 ! Set the Hybird flag.
167  des_continuum_hybrid = (dem_solids .AND. tfm_solids)
168 ! Set flag for coupled simulations
169  des_continuum_coupled = .NOT.(ro_g0 == 0.0d0)
170 
171  IF(des_continuum_hybrid) CALL hybrid_hack
172 
173 ! Overwrite user settings if no Lagrangian solids
174  IF(.NOT.discrete_element) THEN
175  des_continuum_coupled = .false. ! This keyword might get removed.
176  print_des_data = .false.
177  des_oneway_coupled = .false.
178  ENDIF
179 
180  CALL finl_err_msg
181 
182  RETURN
183 
184  END SUBROUTINE check_solids_model_prereqs
185 
186 
187 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
188 ! !
189 ! SUBROUTINE: Hybrid_HACK !
190 ! Purpose: Check the distributed parallel namelist variables. !
191 ! !
192 ! Author: P. Nicoletti Date: 14-DEC-99 !
193 ! Reviewer: J.Musser Date: 16-Jan-14 !
194 ! !
195 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
196  SUBROUTINE hybrid_hack
198 ! Modules
199 !---------------------------------------------------------------------//
200 ! Maximum number of solids phases.
201  use param, only: dim_m
202  use error_manager
203  use run, only: solids_model
204 
205 ! Local variables
206 !---------------------------------------------------------------------//
207  integer :: TFM_MAX
208  integer :: DEM_MIN
209  integer :: M
210 !......................................................................!
211 
212 ! Initialize the error manager.
213  CALL init_err_msg("HYBRID_HACK")
214 
215 ! Initialize the loop variables.
216  tfm_max = -dim_m
217  dem_min = dim_m
218 
219 ! Loop over the phases to see what was specified.
220  DO m=1, dim_m
221  SELECT CASE(solids_model(m))
222  CASE ('TFM'); tfm_max = max(m, tfm_max)
223  CASE ('DEM'); dem_min = min(m, dem_min)
224  END SELECT
225  ENDDO
226 
227  write(*,*)' MAX TFM index: ', tfm_max
228  write(*,*)' MIN DEM index: ', dem_min
229 
230  IF(dem_min < tfm_max) THEN
231  WRITE(err_msg, 2000)
232  CALL flush_err_msg(abort=.true.)
233  ENDIF
234 
235  2000 FORMAT('Error 2000: Illegal phase specification for hybrid ', &
236  'model. All TFM',/'solids must be defined before DEM solids.',&
237  /'Please correct the mfix.dat file.')
238 
239  CALL finl_err_msg
240 
241  RETURN
242  END SUBROUTINE hybrid_hack
logical dem_solids
Definition: run_mod.f:257
character(len=32) function ivar(VAR, i1, i2, i3)
integer pic_count
Definition: run_mod.f:262
subroutine finl_err_msg
logical, dimension(0:dim_m) species_eq
Definition: run_mod.f:115
integer, parameter dim_m
Definition: param_mod.f:67
character(len=3), dimension(dim_m) solids_model
Definition: run_mod.f:253
subroutine init_err_msg(CALLER)
integer dem_count
Definition: run_mod.f:261
subroutine hybrid_hack
integer mmax
Definition: physprop_mod.f:19
double precision ro_g0
Definition: physprop_mod.f:59
Definition: mms_mod.f:12
logical any_species_eq
Definition: run_mod.f:118
integer tfm_count
Definition: run_mod.f:260
logical tfm_solids
Definition: run_mod.f:256
Definition: run_mod.f:13
Definition: param_mod.f:2
logical use_mms
Definition: mms_mod.f:15
character(len=line_length), dimension(line_count) err_msg
integer nscalar
Definition: scalars_mod.f:7
subroutine check_solids_model_prereqs
integer smax
Definition: physprop_mod.f:22
logical mppic
Definition: mfix_pic_mod.f:14
integer, dimension(1:dim_scalar) phase4scalar
Definition: scalars_mod.f:10
logical pic_solids
Definition: run_mod.f:258
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)