MFIX  2016-1
reinitialize.f
Go to the documentation of this file.
1 MODULE reinit
2  CONTAINS
3 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
4 ! !
5 ! SUBROUTINE: REINITIALIZE !
6 ! Purpose: read and verify input data, open files !
7 ! !
8 ! Author: P. Nicoletti Date: 04-DEC-91 !
9 ! Reviewer: M.SYAMLAL, W.ROGERS, P.NICOLETTI Date: 24-JAN-92 !
10 ! !
11 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
12  SUBROUTINE reinitialize(filename)
13 
14  use run, only: reinitializing
15 
16  use error_manager
17 
18  IMPLICIT NONE
19 
20  CHARACTER(LEN=*), intent(in) :: filename
21 
22  INTEGER :: IER
23 
24  ier = 0
25  reinitializing = .true.
26 
27 ! Clean up reaction data if needed
28  CALL reinit_rxn_data
29 
30 ! Read in the namelist variables from the ascii input file.
31  CALL read_namelist(2, filename)
32 
33  CALL reinitialize0(ier)
34 
35  reinitializing = .false.
36 
37  IF(ier /=0) THEN
38  WRITE(err_msg, 2000)
39  ELSE
40  WRITE(err_msg, 2100)
41  ENDIF
42 
43  2000 FORMAT(2/70('*'),/'Reinitialization failed!',/'Correct all ', &
44  'reported errors and reinitialize again.',/70('*'))
45 
46  2100 FORMAT(2/,70('*'),/'Successfully reinitialized!'/70('*'))
47  CALL flush_err_msg(header=.false., footer=.false.)
48 
49  RETURN
50  END SUBROUTINE reinitialize
51 
52 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
53 ! !
54 ! SUBROUTINE: REINITIALIZE0 !
55 ! Purpose: read and verify input data, open files !
56 ! !
57 ! Author: P. Nicoletti Date: 04-DEC-91 !
58 ! Reviewer: M.SYAMLAL, W.ROGERS, P.NICOLETTI Date: 24-JAN-92 !
59 ! !
60 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
61  SUBROUTINE reinitialize0(pIER)
62 
63  USE cutcell, only: cartesian_grid
64  use coeff, only: init_coeff
65 
66  use error_manager
67 
68  IMPLICIT NONE
69 
70  INTEGER, INTENT(OUT) :: pIER
71  INTEGER :: IER
72 
73 ! Set the default error flag to ERROR state.
74  pier = 1
75 
76  CALL check_run_control()
77  IF(reinit_error()) RETURN
78 
79  CALL check_numerics()
80  IF(reinit_error()) RETURN
81 
83  IF(reinit_error()) RETURN
84 
85  CALL check_gas_phase
86  IF(reinit_error()) RETURN
87 
89  IF(reinit_error()) RETURN
90 
92  IF(reinit_error()) RETURN
94  IF(reinit_error()) RETURN
96  IF(reinit_error()) RETURN
98 
100  IF(reinit_error()) RETURN
102  IF(reinit_error()) RETURN
103 
104 ! Convert (mass, volume) flows to velocities.
105  CALL set_bc_flow
106  IF(reinit_error()) RETURN
107 
108 ! This is all that happens in SET_L_SCALE so it needs moved, maybe
109 ! this should go in int_fluid_var.?
110 ! CALL SET_L_SCALE
111 ! L_SCALE(:) = L_SCALE0
112 
113 ! Set constant physical properties
114  CALL set_constprop
115  IF(reinit_error()) RETURN
116 
117 ! Set initial conditions
118  CALL set_ic
119  IF(reinit_error()) RETURN
120 
121 ! Set point sources.
122  CALL set_ps
123  IF(reinit_error()) RETURN
124 
125 ! Set boundary conditions
126  CALL zero_norm_vel
127  IF(reinit_error()) RETURN
128  CALL set_bc0
129  IF(reinit_error()) RETURN
130  IF(cartesian_grid) CALL cg_set_bc0
131  IF(reinit_error()) RETURN
132 
133 ! Set gas mixture molecular weight
134  CALL set_mw_mix_g
135  IF(reinit_error()) RETURN
136 
137 ! Initialize densities.
138  CALL set_ro_g
139  IF(reinit_error()) RETURN
140  CALL set_ro_s
141  IF(reinit_error()) RETURN
142 
143 ! Initialize time dependent boundary conditions
144  CALL set_bc1
145  IF(reinit_error()) RETURN
146 
147 ! Check the field variable data and report errors.
148  IF(.NOT.cartesian_grid) CALL check_data_20
149  IF(reinit_error()) RETURN
150 
151 ! Parse residual strings
152  CALL parse_resid_string ()
153  IF(reinit_error()) RETURN
154 
155  CALL rrates_init(ier)
156  IF(reinit_error()) RETURN
157 
158 ! Calculate all the coefficients once before entering the time loop
159  CALL init_coeff(ier)
160  IF(reinit_error()) RETURN
161 
162 ! After reinitialization, the field vars should pass these checks too
163  CALL check_data_30()
164  IF(reinit_error()) RETURN
165 
166  CALL write_res0()
167  CALL write_out0()
168 
169 ! Made it here without error.
170  pier = 0
171 
172  RETURN
173  END SUBROUTINE reinitialize0
174 
175 
176 !vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv!
177 ! !
178 ! SUBROUTINE: REINIT_RXN_DATA !
179 ! Purpose: read and verify input data, open files !
180 ! !
181 ! Author: P. Nicoletti Date: 04-DEC-91 !
182 ! Reviewer: M.SYAMLAL, W.ROGERS, P.NICOLETTI Date: 24-JAN-92 !
183 ! !
184 !^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^!
185  SUBROUTINE reinit_rxn_data
187  use parse, only: rxn_name, des_rxn_name
188  use parse, only: rxn_chem_eq, des_rxn_chem_eq
189  use parse, only: usrdh, des_usrdh
190  use parse, only: usrfdh, des_usrfdh
191 
192  use rxns, only: no_of_rxns
193  use rxns, only: reaction
194  use des_rxns, only: no_of_des_rxns
195  use des_rxns, only: des_reaction
196 
197  use error_manager
198 
199  IMPLICIT NONE
200 
201  INTEGER :: LC
202 
203 ! Reaction Names: Allocate/Initialize
204  IF(allocated( rxn_name )) deallocate(rxn_name)
205 ! Chemical Equations: Allocate/Initialize
206  IF(allocated( rxn_chem_eq )) deallocate(rxn_chem_eq)
207 ! User defined heat of reaction: Allocate/Initialize
208  IF(allocated( usrdh ))deallocate(usrdh)
209 ! User defined heat of reaction partitions: Allocate/Initialize
210  IF(allocated( usrfdh )) deallocate(usrfdh)
211 
212 
213  IF(allocated(reaction)) THEN
214  DO lc=1,no_of_rxns
215  IF(allocated(reaction(lc)%HoR)) &
216  deallocate(reaction(lc)%HoR)
217  IF(allocated(reaction(lc)%rPhase)) &
218  deallocate(reaction(lc)%rPhase)
219  IF(allocated(reaction(lc)%Species)) &
220  deallocate(reaction(lc)%Species)
221  ENDDO
222  deallocate(reaction)
223  ENDIF
224  no_of_rxns = 0
225 
226 ! Reaction Names: Allocate/Initialize
227  IF(allocated( des_rxn_name )) deallocate(des_rxn_name)
228 ! Chemical Equations: Allocate/Initialize
229  IF(allocated( des_rxn_chem_eq )) deallocate(des_rxn_chem_eq)
230 ! User defined heat of reaction: Allocate/Initialize
231  IF(allocated( des_usrdh )) deallocate( des_usrdh)
232 ! User defined heat of reaction partitions: Allocate/Initialize
233  IF(Allocated( des_usrfdh )) deallocate( des_usrfdh)
234 
235  IF(allocated(des_reaction)) THEN
236  DO lc=1,no_of_des_rxns
237  IF(allocated(des_reaction(lc)%HoR)) &
238  deallocate(des_reaction(lc)%HoR)
239  IF(allocated(des_reaction(lc)%rPhase)) &
240  deallocate(des_reaction(lc)%rPhase)
241  IF(allocated(des_reaction(lc)%Species)) &
242  deallocate(des_reaction(lc)%Species)
243  ENDDO
244  deallocate(des_reaction)
245  ENDIF
246  no_of_des_rxns = 0
247 
248 
249  RETURN
250  END SUBROUTINE reinit_rxn_data
251 END MODULE reinit
subroutine reinitialize0(pIER)
Definition: reinitialize.f:62
subroutine write_res0
Definition: write_res0.f:23
subroutine set_bc_flow
Definition: set_bc_flow.f:16
subroutine check_chemical_rxns
subroutine check_run_control
character(len=32), dimension(:), allocatable rxn_name
Definition: parse_mod.f:34
subroutine set_ic
Definition: set_ic.f:11
subroutine check_solids_phases
subroutine set_ps
Definition: set_ps.f:12
subroutine check_data_20
Definition: check_data_20.f:27
Definition: rxns_mod.f:1
double precision, dimension(:,:), allocatable des_usrfdh
Definition: parse_mod.f:54
subroutine set_ro_g
Definition: set_ro_g.f:24
subroutine set_ro_s
Definition: set_ro_s.f:12
subroutine rrates_init()
Definition: rrates_init.f:17
subroutine zero_norm_vel
Definition: zero_norm_vel.f:18
subroutine check_output_control
subroutine check_numerics
subroutine check_boundary_conditions
character(len=32), dimension(:), allocatable des_rxn_name
Definition: parse_mod.f:48
subroutine set_constprop
Definition: set_constprop.f:15
subroutine check_internal_surfaces
subroutine init_coeff(IER)
Definition: coeff_mod.f:41
double precision, dimension(:), allocatable usrdh
Definition: parse_mod.f:38
integer no_of_rxns
Definition: rxns_mod.f:41
double precision, dimension(:), allocatable des_usrdh
Definition: parse_mod.f:52
subroutine set_bc1
Definition: set_bc1.f:10
integer no_of_des_rxns
Definition: des_rxns_mod.f:51
Definition: run_mod.f:13
subroutine check_data_30
Definition: check_data_30.f:11
subroutine set_bc0
Definition: set_bc0.f:13
logical cartesian_grid
Definition: cutcell_mod.f:13
Definition: parse_mod.f:1
character(len=512), dimension(:), allocatable des_rxn_chem_eq
Definition: parse_mod.f:50
subroutine check_initial_conditions
double precision, dimension(:,:), allocatable usrfdh
Definition: parse_mod.f:40
subroutine reinitialize(filename)
Definition: reinitialize.f:13
logical reinitializing
Definition: run_mod.f:208
character(len=512), dimension(:), allocatable rxn_chem_eq
Definition: parse_mod.f:36
subroutine check_odepack_stiff_chem
character(len=line_length), dimension(line_count) err_msg
subroutine parse_resid_string()
subroutine cg_set_bc0
Definition: CG_set_bc0.f:25
subroutine check_point_sources
subroutine read_namelist(READ_ACTION, FILENAME)
Definition: read_namelist.f:10
Definition: coeff_mod.f:9
subroutine write_out0
Definition: write_out0.f:10
subroutine set_mw_mix_g
Definition: set_mw_mix_g.f:18
logical function reinit_error()
subroutine check_gas_phase
subroutine flush_err_msg(DEBUG, HEADER, FOOTER, ABORT, LOG, CALL_TREE)
subroutine reinit_rxn_data
Definition: reinitialize.f:186