SW_VAR_DENS_MODEL  0.9
Dept-averagedgas-particlemodel
SW_VAR_DENS_MODEL.f90
Go to the documentation of this file.
1 !********************************************************************************
24 !********************************************************************************
25 
28 
30 
31  USE geometry_2d, ONLY : init_grid
32  USE geometry_2d, ONLY : init_source
34 
35  USE geometry_2d, ONLY : dx,dy,b_cent
37 
38  USE init_2d, ONLY : riemann_problem
39  USE init_2d, ONLY : collapsing_volume
40 
41  USE inpout_2d, ONLY : init_param
42  USE inpout_2d, ONLY : read_param
43  USE inpout_2d, ONLY : update_param
44  USE inpout_2d, ONLY : output_solution
45  USE inpout_2d, ONLY : output_runout
46  USE inpout_2d, ONLY : read_solution
47  USE inpout_2d, ONLY : close_units
48 
49  USE inpout_2d, ONLY : output_runout_flag
50 
53  USE solver_2d, ONLY : imex_rk_solver
55  USE solver_2d, ONLY : timestep
56  USE solver_2d, ONLY : check_solve
57 
58  USE inpout_2d, ONLY : restart
59 
60  USE parameters_2d, ONLY : t_start
61  USE parameters_2d, ONLY : t_end
62  USE parameters_2d, ONLY : t_output
63  USE parameters_2d, ONLY : t_runout
64  USE parameters_2d, ONLY : t_steady
65  USE parameters_2d, ONLY : dt0
66  USE parameters_2d, ONLY : riemann_flag
68  USE parameters_2d, ONLY : verbose_level
69  USE parameters_2d, ONLY : n_solid
70  USE parameters_2d, ONLY : n_vars
73 
74  USE solver_2d, ONLY : q , qp , t, dt
75  USE solver_2d, ONLY : q1max
76 
77  USE constitutive_2d, ONLY : qc_to_qp
78 
79  USE solver_2d, ONLY : solve_mask
80 
81  IMPLICIT NONE
82 
83  REAL*8 :: t1 , t2
84  REAL*8 :: dt_old , dt_old_old
85  LOGICAL :: stop_flag
86  LOGICAL :: stop_flag_old
87 
88  INTEGER j,k
89 
90  CALL cpu_time(t1)
91 
92  CALL init_param
93 
94  CALL read_param
95 
96  CALL init_grid
97 
98  CALL init_problem_param
99 
100  CALL allocate_solver_variables
101 
102  IF ( restart ) THEN
103 
104  CALL read_solution
105 
106  ELSE
107 
108  IF ( collapsing_volume_flag ) THEN
109 
110  CALL collapsing_volume
111 
112  END IF
113 
114  IF( riemann_flag ) THEN
115 
116  ! riemann problem defined in file.inp
117  CALL riemann_problem
118 
119  ENDIF
120 
121  END IF
122 
123  IF ( radial_source_flag ) CALL init_source
124 
125  CALL check_solve
126 
127  IF ( topo_change_flag ) CALL topography_reconstruction
128 
129  t = t_start
130 
131  WRITE(*,*)
132  WRITE(*,*) '******** START COMPUTATION *********'
133  WRITE(*,*)
134 
135  IF ( verbose_level .GE. 1 ) THEN
136 
137  WRITE(*,*) 'Min q(1,:,:)=',minval(q(1,:,:))
138  WRITE(*,*) 'Max q(1,:,:)=',maxval(q(1,:,:))
139 
140  WRITE(*,*) 'Min B(:,:)=',minval(b_cent(:,:))
141  WRITE(*,*) 'Max B(:,:)=',maxval(b_cent(:,:))
142 
143 
144  WRITE(*,*) 'size B_cent',size(b_cent,1),size(b_cent,2)
145 
146  WRITE(*,*) 'SUM(q(1,:,:)=',sum(q(1,:,:))
147  WRITE(*,*) 'SUM(B_cent(:,:)=',sum(b_cent(:,:))
148 
149  END IF
150 
151  q1max(:,:) = q(1,:,:)
152 
153  dt_old = dt0
154  dt_old_old = dt_old
155  t_steady = t_end
156  stop_flag = .false.
157 
158  DO k = 1,comp_cells_y
159 
160  DO j = 1,comp_cells_x
161 
162  CALL qc_to_qp(q(1:n_vars,j,k) , qp(1:n_vars,j,k) )
163 
164  END DO
165 
166  END DO
167 
168  IF ( output_runout_flag ) CALL output_runout(t,stop_flag)
169 
170  CALL output_solution(t)
171 
172  IF ( sum(q(1,:,:)) .EQ. 0.d0 ) t_steady = t_output
173 
174  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A9,ES11.3E3,A11,ES11.3E3,A9,ES11.3E3,A15,ES11.3E3)") &
175  't =',t,'dt =',dt0, &
176  ' mass = ',dx*dy*sum(q(1,:,:)) , &
177  ' volume = ',dx*dy*sum(qp(1,:,:)) , &
178  ' area = ',dx*dy*count(q(1,:,:).GT.1.d-5) , &
179  ' solid mass = ',dx*dy*sum(q(5:4+n_solid,:,:))
180 
181  DO WHILE ( ( t .LT. t_end ) .AND. ( t .LT. t_steady ) )
182 
183  CALL update_param
184 
185  CALL check_solve
186 
187  IF ( verbose_level .GE. 1 ) THEN
188 
189  WRITE(*,*) 'cells to solve and reconstruct:' , count(solve_mask)
190 
191  END IF
192 
193  CALL timestep
194 
195  IF ( t+dt .GT. t_end ) dt = t_end - t
196  IF ( t+dt .GT. t_output ) dt = t_output - t
197 
198  IF ( output_runout_flag ) THEN
199 
200  IF ( t+dt .GT. t_runout ) dt = t_runout - t
201 
202  END IF
203 
204  dt = min(dt,1.1d0*0.5d0*(dt_old+dt_old_old))
205 
206  dt_old_old = dt_old
207  dt_old = dt
208 
209  CALL imex_rk_solver
210 
211  CALL update_erosion_deposition_cell(dt)
212 
213  IF ( topo_change_flag ) CALL topography_reconstruction
214 
215  q1max(:,:) = max( q1max(:,:) , q(1,:,:) )
216 
217  t = t+dt
218 
219 
220  DO k = 1,comp_cells_y
221 
222  DO j = 1,comp_cells_x
223 
224  CALL qc_to_qp(q(1:n_vars,j,k) , qp(1:n_vars,j,k) )
225 
226  END DO
227 
228  END DO
229 
230 
231  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A9,ES11.3E3,A11,ES11.3E3,A9,ES11.3E3,A15,ES11.3E3)")&
232  't =',t,'dt =',dt, &
233  ' mass = ',dx*dy*sum(q(1,:,:)) , &
234  ' volume = ',dx*dy*sum(qp(1,:,:)) , &
235  ' area = ',dx*dy*count(q(1,:,:).GT.1.d-7) , &
236  ' solid mass = ',dx*dy*sum(q(5:4+n_solid,:,:))
237 
238  IF ( output_runout_flag ) THEN
239 
240  IF ( ( t .GE. t_runout ) .OR. ( t .GE. t_steady ) ) THEN
241 
242  stop_flag_old = stop_flag
243 
244  IF ( output_runout_flag ) CALL output_runout(t,stop_flag)
245 
246  IF ( ( stop_flag ) .AND. (.NOT.stop_flag_old) ) THEN
247 
248  t_steady = min(t_end,t_output)
249  t_runout = t_steady
250 
251  END IF
252 
253  END IF
254 
255  END IF
256 
257  t_steady = t_end
258 
259  IF ( ( t .GE. t_output ) .OR. ( t .GE. t_end ) ) THEN
260 
261  CALL output_solution(t)
262 
263  CALL cpu_time(t2)
264 
265  WRITE(*,*) 'Time taken by the code is',t2-t1,'seconds'
266 
267  END IF
268 
269  END DO
270 
271  CALL deallocate_solver_variables
272 
273  CALL close_units
274 
275  CALL cpu_time(t2)
276 
277  WRITE(*,*) 'Time taken by the code is',t2-t1,'seconds'
278 
279 END PROGRAM sw_var_dens_model
280 
real *8 dy
Control volumes size.
Definition: geometry_2d.f90:93
real *8 t_steady
end time when reached steady solution
subroutine topography_reconstruction
Linear reconstruction.
real *8, dimension(:,:), allocatable b_cent
Topography at the centers of the control volumes.
Definition: geometry_2d.f90:41
integer comp_cells_x
Number of control volumes x in the comp. domain.
Definition: geometry_2d.f90:98
subroutine read_solution
Read the solution from the restart unit.
Definition: inpout_2d.f90:2428
Parameters.
real *8 dx
Control volumes size.
Definition: geometry_2d.f90:90
real *8 t_end
end time for the run
integer comp_cells_y
Number of control volumes y in the comp. domain.
Numerical solver.
Definition: solver_2d.f90:12
subroutine deallocate_solver_variables
Memory deallocation.
Definition: solver_2d.f90:452
Input/Output module.
Definition: inpout_2d.f90:13
Initial solution.
Definition: init_2d.f90:8
subroutine update_param
Read the input file.
Definition: inpout_2d.f90:2325
real *8 dt
Time step.
Definition: solver_2d.f90:121
integer n_vars
Number of conservative variables.
logical topo_change_flag
real *8 dt0
Initial time step.
subroutine update_erosion_deposition_cell(dt)
Evaluate the eroion/deposition terms.
Definition: solver_2d.f90:1880
Constitutive equations.
subroutine init_grid
Finite volume grid initialization.
logical restart
Flag to start a run from a previous output: .
Definition: inpout_2d.f90:115
subroutine output_runout(time, stop_flag)
Write runout on file.
Definition: inpout_2d.f90:3289
subroutine output_solution(time)
Write the solution on the output unit.
Definition: inpout_2d.f90:2819
subroutine init_problem_param
Initialization of relaxation flags.
subroutine init_source
Grid module.
Definition: geometry_2d.f90:7
real *8 t
time
Definition: solver_2d.f90:39
logical riemann_flag
Flag to choose the sort of problem to solve.
subroutine check_solve
Masking of cells to solve.
Definition: solver_2d.f90:548
program sw_var_dens_model
Main Program.
real *8 t_output
time of the next output
subroutine read_param
Read the input file.
Definition: inpout_2d.f90:584
integer verbose_level
subroutine timestep
Time-step computation.
Definition: solver_2d.f90:697
subroutine qc_to_qp(qc, qp)
Conservative to physical variables.
subroutine collapsing_volume
Collapsing volume initialization.
Definition: init_2d.f90:204
subroutine close_units
Definition: inpout_2d.f90:3184
real *8 t_runout
time of the next runout output
subroutine riemann_problem
Riemann problem initialization.
Definition: init_2d.f90:48
subroutine init_param
Initialization of the variables read from the input file.
Definition: inpout_2d.f90:254
subroutine imex_rk_solver
Runge-Kutta integration.
Definition: solver_2d.f90:828
logical, dimension(:,:), allocatable solve_mask
Definition: solver_2d.f90:112
real *8, dimension(:,:), allocatable q1max
Maximum over time of thickness.
Definition: solver_2d.f90:86
logical radial_source_flag
subroutine allocate_solver_variables
Memory allocation.
Definition: solver_2d.f90:216
logical collapsing_volume_flag
integer n_solid
Number of solid classes.
real *8, dimension(:,:,:), allocatable qp
Physical variables ( )
Definition: solver_2d.f90:107
logical output_runout_flag
Flag to save the max runout at ouput times.
Definition: inpout_2d.f90:139
real *8 t_start
initial time for the run
real *8, dimension(:,:,:), allocatable q
Conservative variables.
Definition: solver_2d.f90:42