IMEX_SfloW2D  0.9
Shallowwatergranularflowmodel
IMEX_Sflow_2d.f90
Go to the documentation of this file.
1 !********************************************************************************
26 !********************************************************************************
27 
30 
32 
33  USE geometry_2d, ONLY : init_grid
34 
35  USE geometry_2d, ONLY : dx,dy,b_cent
36 
38 
39  USE inpout_2d, ONLY : init_param
40  USE inpout_2d, ONLY : read_param
41  USE inpout_2d, ONLY : update_param
42  USE inpout_2d, ONLY : output_solution
43  USE inpout_2d, ONLY : output_runout
44  USE inpout_2d, ONLY : read_solution
45  USE inpout_2d, ONLY : close_units
46 
47  USE inpout_2d, ONLY : output_runout_flag
48 
49 
52  USE solver_2d, ONLY : imex_rk_solver
53  USE solver_2d, ONLY : timestep, timestep2
54  ! USE solver_2d, ONLY : check_solve
55 
56  USE inpout_2d, ONLY : restart
57 
58  USE parameters_2d, ONLY : t_start
59  USE parameters_2d, ONLY : t_end
60  USE parameters_2d, ONLY : t_output
61  USE parameters_2d, ONLY : t_runout
62  USE parameters_2d, ONLY : t_steady
63  USE parameters_2d, ONLY : dt0
64  USE parameters_2d, ONLY : riemann_flag
65  USE parameters_2d, ONLY : verbose_level
67 
68 
69  USE solver_2d, ONLY : q , dt
70  ! USE solver_2d, ONLY : solve_mask
71 
72  IMPLICIT NONE
73 
74  REAL*8 :: t
75  REAL*8 :: t1 , t2
76  REAL*8 :: dt_old , dt_old_old
77  LOGICAL :: stop_flag
78 
79 
80  CALL cpu_time(t1)
81 
82  CALL init_param
83 
84  CALL read_param
85 
86  CALL init_grid
87 
89 
90  CALL allocate_solver_variables
91 
92  IF ( restart ) THEN
93 
94  CALL read_solution
95 
96  ELSE
97 
98  IF( riemann_flag .EQV. .true. )THEN
99 
100  ! riemann problem defined in file.inp
101  CALL riemann_problem
102 
103  ELSE
104 
105  ! generic problem defined by initial conditions function (in init_2d.f90)
106  CALL initial_conditions
107 
108  ENDIF
109 
110  END IF
111 
112  t = t_start
113 
114  WRITE(*,*)
115  WRITE(*,*) '******** START COMPUTATION *********'
116  WRITE(*,*)
117 
118  IF ( verbose_level .GE. 1 ) THEN
119 
120  WRITE(*,*) 'Min q(1,:,:)=',minval(q(1,:,:))
121  WRITE(*,*) 'Max q(1,:,:)=',maxval(q(1,:,:))
122 
123  WRITE(*,*) 'Min B(:,:)=',minval(b_cent(:,:))
124  WRITE(*,*) 'Max B(:,:)=',maxval(b_cent(:,:))
125 
126 
127  WRITE(*,*) 'size B_cent',size(b_cent,1),size(b_cent,2)
128 
129  WRITE(*,*) 'SUM(q(1,:,:)=',sum(q(1,:,:))
130  WRITE(*,*) 'SUM(B_cent(:,:)=',sum(b_cent(:,:))
131 
132  END IF
133 
134  dt_old = dt0
135  dt_old_old = dt_old
136  t_steady = t_end
137  stop_flag = .false.
138 
139 
140  IF ( output_runout_flag ) CALL output_runout(t,stop_flag)
141 
142  CALL output_solution(t)
143 
144  IF ( solid_transport_flag ) THEN
145 
146  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A15,ES12.3E3,A15,ES12.3E3)") &
147  't =',t,'dt =',dt0, &
148  ' total volume = ',dx*dy*(sum(q(1,:,:)-b_cent(:,:))) , &
149  ' total sediment fraction = ',dx*dy*(sum(q(4,:,:)))
150 
151  ELSE
152 
153  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A15,ES12.3E3)") 't =',t,'dt =',dt0, &
154  ' total volume = ',dx*dy*(sum(q(1,:,:)-b_cent(:,:)))
155 
156  END IF
157 
158  DO WHILE ( ( t .LT. t_end ) .AND. ( t .LT. t_steady ) )
159 
160  CALL update_param
161 
162  ! CALL check_solve
163  ! WRITE(*,*) 'cells to solve:',COUNT(solve_mask)
164 
165 
166  ! CALL timestep
167  CALL timestep2
168 
169  IF ( t+dt .GT. t_end ) dt = t_end - t
170  IF ( t+dt .GT. t_output ) dt = t_output - t
171 
172  IF ( output_runout_flag ) THEN
173 
174  IF ( t+dt .GT. t_runout ) dt = t_runout - t
175 
176  END IF
177 
178  dt = min(dt,1.1d0*0.5d0*(dt_old+dt_old_old))
179 
180  dt_old_old = dt_old
181  dt_old = dt
182 
183  CALL imex_rk_solver
184 
185  t = t+dt
186 
187  IF ( solid_transport_flag ) THEN
188 
189  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A15,ES12.3E3,A15,ES12.3E3)") &
190  't =',t,'dt =',dt, &
191  ' total volume = ',dx*dy*(sum(q(1,:,:)-b_cent(:,:))) , &
192  ' total sediment fraction = ',dx*dy*(sum(q(4,:,:)))
193 
194  ELSE
195 
196  WRITE(*,fmt="(A3,F10.4,A5,F9.5,A15,ES12.3E3)") 't =',t,'dt =',dt, &
197  ' total volume = ',dx*dy*(sum(q(1,:,:)-b_cent(:,:)))
198 
199  END IF
200 
201  IF ( output_runout_flag ) THEN
202 
203  IF ( ( t .GE. t_runout ) .OR. ( t .GE. t_end ) ) THEN
204 
205  IF ( output_runout_flag ) CALL output_runout(t,stop_flag)
206 
207  IF ( stop_flag ) THEN
208 
209  t_steady = t_output
210  t_runout = t_output
211 
212  END IF
213 
214 
215  END IF
216 
217  END IF
218 
219  IF ( ( t .GE. t_output ) .OR. ( t .GE. t_end ) ) THEN
220 
221  CALL output_solution(t)
222 
223  END IF
224 
225  END DO
226 
227  CALL deallocate_solver_variables
228 
229  CALL close_units
230 
231  CALL cpu_time(t2)
232 
233  WRITE(*,*) 'Time taken by the code was',t2-t1,'seconds'
234 
235 END PROGRAM imex_sflow_2d
236 
real *8 dy
Control volumes size.
Definition: geometry_2d.f90:59
real *8 t_steady
end time when reached steady solution
real *8, dimension(:,:), allocatable b_cent
Topography at the centers of the control volumes.
Definition: geometry_2d.f90:35
subroutine read_solution
Read the solution from the restart unit.
Definition: inpout_2d.f90:2266
Parameters.
real *8 dx
Control volumes size.
Definition: geometry_2d.f90:56
real *8 t_end
end time for the run
Numerical solver.
Definition: solver_2d.f90:12
subroutine deallocate_solver_variables
Memory deallocation.
Definition: solver_2d.f90:338
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:2160
real *8 dt
Time step.
Definition: solver_2d.f90:67
subroutine initial_conditions
Problem initialization.
Definition: init_2d.f90:193
real *8 dt0
Initial time step.
Constitutive equations.
program imex_sflow_2d
Main Program.
subroutine init_grid
Finite volume grid initialization.
Definition: geometry_2d.f90:80
logical restart
Flag to start a run from a previous output: .
Definition: inpout_2d.f90:94
subroutine output_runout(time, stop_flag)
Write runout on file.
Definition: inpout_2d.f90:2956
subroutine output_solution(time)
Write the solution on the output unit.
Definition: inpout_2d.f90:2573
subroutine init_problem_param
Initialization of relaxation flags.
Grid module.
Definition: geometry_2d.f90:7
subroutine timestep2
Time-step computation.
Definition: solver_2d.f90:525
logical riemann_flag
Flag to choose the sort of problem to solve.
real *8 t_output
time of the next output
subroutine read_param
Read the input file.
Definition: inpout_2d.f90:529
integer verbose_level
subroutine timestep
Time-step computation.
Definition: solver_2d.f90:448
subroutine close_units
Definition: inpout_2d.f90:2851
real *8 t_runout
time of the next runout output
subroutine riemann_problem
Riemann problem initialization.
Definition: init_2d.f90:50
subroutine init_param
Initialization of the variables read from the input file.
Definition: inpout_2d.f90:213
subroutine imex_rk_solver
Runge-Kutta integration.
Definition: solver_2d.f90:598
logical solid_transport_flag
Flag to choose if we model solid phase transport.
subroutine allocate_solver_variables
Memory allocation.
Definition: solver_2d.f90:141
logical output_runout_flag
Flag to save the max runout at ouput times.
Definition: inpout_2d.f90:118
real *8 t_start
initial time for the run
real *8, dimension(:,:,:), allocatable q
Conservative variables.
Definition: solver_2d.f90:33