42 REAL(wp),
ALLOCATABLE ::
q(:,:,:)
44 REAL(wp),
ALLOCATABLE ::
q0(:,:,:)
46 REAL(wp),
ALLOCATABLE ::
q_fv(:,:,:)
86 REAL(wp),
ALLOCATABLE ::
q1max(:,:)
107 REAL(wp),
ALLOCATABLE ::
qp(:,:,:)
148 REAL(wp),
ALLOCATABLE ::
q_rk(:,:,:,:)
151 REAL(wp),
ALLOCATABLE ::
qp_rk(:,:,:,:)
157 REAL(wp),
ALLOCATABLE ::
nh(:,:,:,:)
202 REAL(wp) :: gamma , delta
206 ALLOCATE(
q( n_vars , comp_cells_x , comp_cells_y ) ,
q0( n_vars , &
207 comp_cells_x , comp_cells_y ) )
209 ALLOCATE(
qp( n_vars+2 , comp_cells_x , comp_cells_y ) )
211 q(1:n_vars,1:comp_cells_x,1:comp_cells_y) = 0.0_wp
212 qp(1:n_vars+2,1:comp_cells_x,1:comp_cells_y) = 0.0_wp
214 ALLOCATE(
q1max( comp_cells_x , comp_cells_y ) )
216 ALLOCATE(
q_fv( n_vars , comp_cells_x , comp_cells_y ) )
218 ALLOCATE(
q_interfacel( n_vars , comp_interfaces_x, comp_cells_y ) )
219 ALLOCATE(
q_interfacer( n_vars , comp_interfaces_x, comp_cells_y ) )
226 ALLOCATE(
h_interface_x( n_eqns , comp_interfaces_x, comp_cells_y ) )
227 ALLOCATE(
h_interface_y( n_eqns , comp_cells_x, comp_interfaces_y ) )
230 ALLOCATE(
q_interfaceb( n_vars , comp_cells_x, comp_interfaces_y ) )
231 ALLOCATE(
q_interfacet( n_vars , comp_cells_x, comp_interfaces_y ) )
239 ALLOCATE(
qp_interfacel( n_vars+2 , comp_interfaces_x, comp_cells_y ) )
240 ALLOCATE(
qp_interfacer( n_vars+2 , comp_interfaces_x, comp_cells_y ) )
241 ALLOCATE(
qp_interfaceb( n_vars+2 , comp_cells_x, comp_interfaces_y ) )
242 ALLOCATE(
qp_interfacet( n_vars+2 , comp_cells_x, comp_interfaces_y ) )
245 ALLOCATE(
q_cellnw( n_vars , comp_cells_x , comp_cells_y ) )
246 ALLOCATE(
q_cellne( n_vars , comp_cells_x , comp_cells_y ) )
247 ALLOCATE(
q_cellsw( n_vars , comp_cells_x , comp_cells_y ) )
248 ALLOCATE(
q_cellse( n_vars , comp_cells_x , comp_cells_y ) )
250 ALLOCATE(
qp_cellnw( n_vars+2 , comp_cells_x , comp_cells_y ) )
251 ALLOCATE(
qp_cellne( n_vars+2 , comp_cells_x , comp_cells_y ) )
252 ALLOCATE(
qp_cellsw( n_vars+2 , comp_cells_x , comp_cells_y ) )
253 ALLOCATE(
qp_cellse( n_vars+2 , comp_cells_x , comp_cells_y ) )
259 ALLOCATE(
solve_mask( comp_cells_x , comp_cells_y ) )
262 solve_mask(comp_cells_x,1:comp_cells_y) = .true.
264 solve_mask(1:comp_cells_x,comp_cells_y) = .true.
267 ALLOCATE(
solve_mask_x( comp_interfaces_x , comp_cells_y ) )
268 ALLOCATE(
solve_mask_y( comp_cells_x , comp_interfaces_y ) )
270 ALLOCATE(
source_xy( comp_cells_x , comp_cells_y ) )
276 ALLOCATE(
omega(n_rk) )
280 ALLOCATE(
mask22(n_eqns,n_eqns) )
281 ALLOCATE(
mask21(n_eqns,n_eqns) )
282 ALLOCATE(
mask11(n_eqns,n_eqns) )
283 ALLOCATE(
mask12(n_eqns,n_eqns) )
286 mask11(1:n_eqns,1:n_eqns) = .false.
287 mask12(1:n_eqns,1:n_eqns) = .false.
288 mask22(1:n_eqns,1:n_eqns) = .false.
289 mask21(1:n_eqns,1:n_eqns) = .false.
327 gamma = 1.0_wp - 1.0_wp / sqrt(2.0_wp)
328 delta = 1.0_wp - 1.0_wp / ( 2.0_wp * gamma )
330 IF ( n_rk .EQ. 1 )
THEN 340 ELSEIF ( n_rk .EQ. 2 )
THEN 352 ELSEIF ( n_rk .EQ. 3 )
THEN 371 omega(1) = 1.0_wp / 3.0_wp
372 omega(2) = 1.0_wp / 3.0_wp
373 omega(3) = 1.0_wp / 3.0_wp
375 ELSEIF ( n_rk .EQ. 4 )
THEN 403 ALLOCATE(
q_rk( n_vars , comp_cells_x , comp_cells_y , n_rk ) )
404 ALLOCATE(
qp_rk( n_vars+2 , comp_cells_x , comp_cells_y , n_rk ) )
405 ALLOCATE(
divflux( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
406 ALLOCATE(
nh( n_eqns , comp_cells_x , comp_cells_y , n_rk ) )
408 ALLOCATE(
residual_term( n_vars , comp_cells_x , comp_cells_y ) )
410 comp_cells_xy = comp_cells_x * comp_cells_y
412 ALLOCATE(
j_cent( comp_cells_xy ) )
413 ALLOCATE(
k_cent( comp_cells_xy ) )
415 ALLOCATE(
j_stag_x( comp_interfaces_x * comp_cells_y ) )
416 ALLOCATE(
k_stag_x( comp_interfaces_x * comp_cells_y ) )
418 ALLOCATE(
j_stag_y( comp_cells_x * comp_interfaces_y ) )
419 ALLOCATE(
k_stag_y( comp_cells_x * comp_interfaces_y ) )
528 ALLOCATE(
q_mg_old(n_vars , comp_cells_x , comp_cells_y) )
529 ALLOCATE(
q_mg_new(n_vars , 2*comp_cells_x , 2*comp_cells_y) )
554 WRITE(*,*)
'INT(q(1,:,:)=',sum(
q(1,:,:))*cell_size*cell_size
556 DO k = 1,2*comp_cells_y
558 yl = y0 + (k-1)*0.5_wp*cell_size
559 yr = y0 + (k)*0.5_wp*cell_size
561 DO j = 1,2*comp_cells_x
563 xl = x0 + (j-1)*0.5_wp*cell_size
564 xr = x0 + (j)*0.5_wp*cell_size
568 CALL regrid_scalar(x_stag, y_stag,
q(i,:,:), xl, xr , yl, yr,
q_mg_new(i,j,k) )
576 WRITE(*,*)
'size q_mg_new',
SIZE(
q_mg_new)
577 WRITE(*,*)
'SUM(q_mg_new(1,:,:)=',sum(
q_mg_new(1,:,:))*0.25_wp*cell_size*cell_size
606 WHERE (
q(1,2:comp_cells_x-1,2:comp_cells_y-1) .GT. 0.0_wp ) &
607 solve_mask(2:comp_cells_x,2:comp_cells_y) = .true.
616 solve_mask(2:comp_cells_x-1,2:comp_cells_y-1) = &
617 solve_mask(2:comp_cells_x-1,2:comp_cells_y-1) .OR. &
618 solve_mask(1:comp_cells_x-2,2:comp_cells_y-1) .OR. &
619 solve_mask(3:comp_cells_x,2:comp_cells_y-1) .OR. &
620 solve_mask(2:comp_cells_x-1,1:comp_cells_y-2) .OR. &
629 solve_mask_x(1:comp_interfaces_x,1:comp_cells_y) = .false.
630 solve_mask_y(1:comp_cells_x,1:comp_interfaces_y) = .false.
639 DO k = 1,comp_cells_y
641 DO j = 1,comp_cells_x
665 DO k = 1,comp_cells_y
667 DO j = 1,comp_interfaces_x
687 DO k = 1,comp_interfaces_y
689 DO j = 1,comp_cells_x
738 REAL(wp) :: dt_interface_x, dt_interface_y
746 IF (
cfl .NE. -1.0_wp )
THEN 755 IF (
q(1,j,k) .GT. 0.0_wp )
THEN 757 CALL qc_to_qp(
q(1:n_vars,j,k) ,
qp(1:n_vars+2,j,k) )
761 qp(1:n_vars+2,j,k) = 0.0_wp
818 IF ( max_a .GT. 0.0_wp )
THEN 820 dt_interface_x =
cfl *
dx / max_a
831 IF ( max_a .GT. 0.0_wp )
THEN 833 dt_interface_y =
cfl *
dy / max_a
841 dt_cfl = min( dt_interface_x , dt_interface_y )
877 REAL(wp) :: q_si(n_vars)
878 REAL(wp) :: q_guess(n_vars)
880 REAL(wp) :: Rj_not_impl(n_eqns)
882 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: beginning' 891 q0( 1:n_vars , j , k ) = &
892 q( 1:n_vars , j , k )
895 q_rk( 1:n_vars , j , k , 1:n_rk ) = 0.0_wp
896 qp_rk( 1:n_vars+2 , j , k , 1:n_rk ) = 0.0_wp
897 divflux(1:n_eqns , j , k , 1:n_rk ) = 0.0_wp
898 nh( 1:n_eqns, j , k , 1:n_rk ) = 0.0_wp
900 END DO init_cells_loop
903 runge_kutta:
DO i_rk = 1,n_rk
905 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: i_RK',
i_rk 926 IF ( verbose_level .GE. 2 )
THEN 928 WRITE(*,*)
'solver, imex_RK_solver: j',j,k
933 IF (
i_rk .EQ. 1 )
THEN 936 q_guess(1:n_vars) =
q0( 1:n_vars , j , k)
947 q_fv( 1:n_vars , j , k ) =
q0( 1:n_vars , j , k ) &
951 IF ( verbose_level .GE. 2 )
THEN 953 WRITE(*,*)
'q_guess',q_guess
954 IF ( q_guess(1) .GT. 0.0_wp )
THEN 957 WRITE(*,*)
'q_guess: qp',
qp(1:n_vars+2,j,k)
963 adiag_pos:
IF (
a_diag .NE. 0.0_wp )
THEN 965 pos_thick:
IF ( (
q_fv(1,j,k) .GT. 0.0_wp ) .OR. (
cell_fract(j,k) .GT. 0.0_wp ) )
THEN 969 q_guess(1:n_vars) =
q_fv(1:n_vars,j,k)
977 q_guess(1:n_vars) ,
q0(1:n_vars,j,k ) , &
979 divflux( 1:n_eqns , j , k , 1:n_rk ) , &
980 nh( 1:n_eqns , j , k , 1:n_rk ) )
982 IF ( comp_cells_y .EQ. 1 )
THEN 988 IF ( comp_cells_x .EQ. 1 )
THEN 996 dy_rel(j,k) , r_qj = q_guess , &
997 r_nh_term_impl =
nh(1:n_eqns,j,k,
i_rk) )
1002 q_guess(1:n_vars) =
q_fv( 1:n_vars , j , k )
1003 nh(1:n_eqns,j,k,
i_rk) = 0.0_wp
1009 IF (
a_diag .NE. 0.0_wp )
THEN 1012 nh(1:n_vars,j,k,
i_rk) = ( q_guess(1:n_vars) -
q_fv(1:n_vars,j,k) ) &
1018 q_rk( 1:n_vars , j , k ,
i_rk ) = q_guess
1020 IF ( verbose_level .GE. 2 )
THEN 1022 WRITE(*,*)
'imex_RK_solver: qc',q_guess
1024 IF ( q_guess(1) .GT. 0.0_wp )
THEN 1026 CALL qc_to_qp( q_guess ,
qp(1:n_vars+2,j,k) )
1027 WRITE(*,*)
'imex_RK_solver: qp',
qp(1:n_vars+2,j,k)
1037 IF (
q_rk(1,j,k,
i_rk) .GT. 0.0_wp )
THEN 1050 END DO solve_cells_loop
1060 q_rk(1:n_vars,1:comp_cells_x,1:comp_cells_y,
i_rk) , &
1061 qp_rk(1:n_vars+2,1:comp_cells_x,1:comp_cells_y,
i_rk) , &
1062 divflux(1:n_eqns,1:comp_cells_x,1:comp_cells_y,
i_rk) )
1078 IF ( verbose_level .GE. 1 )
THEN 1080 WRITE(*,*)
'cell jk =',j,k
1081 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
1082 IF (
q0(1,j,k) .GT. 0.0_wp )
THEN 1085 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars+2,j,k)
1092 .AND. ( sum(abs(
omega(:)-
a_dirk_ij(n_rk,:))) .EQ. 0.0_wp ) )
THEN 1095 q(1:n_vars,j,k) =
q_rk(1:n_vars,j,k,n_rk)
1104 negative_thickness_check:
IF (
q(1,j,k) .LT. 0.0_wp )
THEN 1106 IF (
q(1,j,k) .GT. -1.e-7_wp )
THEN 1109 q(2:n_vars,j,k) = 0.0_wp
1113 WRITE(*,*)
'j,k,n_RK',j,k,n_rk
1115 WRITE(*,*)
'before imex_RK_solver: qc',
q0(1:n_vars,j,k)
1116 IF (
q0(1,j,k) .GT. 0.0_wp )
THEN 1119 WRITE(*,*)
'before imex_RK_solver: qp',
qp(1:n_vars+2,j,k)
1122 WRITE(*,*)
'after imex_RK_solver: qc',
q(1:n_vars,j,k)
1124 WRITE(*,*)
'divFlux(1,j,k,1:n_RK)',
divflux(1,j,k,1:n_rk)
1128 WRITE(*,*)
qp(1:n_vars,j,k)
1131 WRITE(*,*)
'NH(1,j,k,1:n_RK)',
nh(1,j,k,1:n_rk)
1137 END IF negative_thickness_check
1173 SUBROUTINE solve_rk_step( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj, qj_old, &
1182 REAL(wp),
INTENT(IN) :: cell_fract_jk
1183 REAL(wp),
INTENT(IN) :: dx_rel_jk
1184 REAL(wp),
INTENT(IN) :: dy_rel_jk
1186 REAL(wp),
INTENT(INOUT) :: qj(n_vars)
1187 REAL(wp),
INTENT(IN) :: qj_old(n_vars)
1188 REAL(wp),
INTENT(IN) :: a_tilde(n_rk)
1189 REAL(wp),
INTENT(IN) :: a_dirk(n_rk)
1190 REAL(wp),
INTENT(IN) :: a_diag
1191 REAL(wp),
INTENT(IN) :: Rj_not_impl(n_eqns)
1192 REAL(wp),
INTENT(IN) :: divFluxj(n_eqns,n_rk)
1193 REAL(wp),
INTENT(IN) :: NHj(n_eqns,n_rk)
1195 REAL(wp) :: qj_init(n_vars)
1197 REAL(wp) :: qj_org(n_vars) , qj_rel(n_vars)
1199 REAL(wp) :: left_matrix(n_eqns,n_vars)
1200 REAL(wp) :: right_term(n_eqns)
1204 REAL(wp) :: coeff_f(n_eqns)
1206 REAL(wp) :: qj_rel_NR_old(n_vars)
1207 REAL(wp) :: scal_f_old
1208 REAL(wp) :: desc_dir(n_vars)
1209 REAL(wp) :: grad_f(n_vars)
1211 INTEGER :: pivot(n_vars)
1213 REAL(wp) :: left_matrix_small22(n_nh,n_nh)
1214 REAL(wp) :: left_matrix_small21(n_eqns-n_nh,n_nh)
1215 REAL(wp) :: left_matrix_small11(n_eqns-n_nh,n_vars-n_nh)
1218 REAL(wp) :: desc_dir_small2(n_nh)
1219 INTEGER :: pivot_small2(n_nh)
1221 REAL(wp) :: desc_dir_small1(n_vars-n_nh)
1228 REAL(wp),
PARAMETER :: STPMX=100.0_wp
1232 REAL(wp),
PARAMETER :: TOLF=1.e-10_wp , tolmin=1.e-6_wp
1237 REAL(wp) :: desc_dir2(n_vars)
1239 REAL(wp) :: desc_dir_temp(n_vars)
1245 coeff_f(1:n_eqns) = 1.0_wp
1247 grad_f(1:n_eqns) = 0.0_wp
1254 qj = qj_old -
dt * (matmul( divfluxj , a_tilde ) - matmul( nhj , a_dirk ))
1256 CALL eval_f( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj , qj_old , &
1257 a_diag , coeff_f , rj_not_impl , right_term , scal_f )
1259 IF ( verbose_level .GE. 3 )
THEN 1261 WRITE(*,*)
'solve_rk_step: non-normalized right_term' 1262 WRITE(*,*) right_term
1263 WRITE(*,*)
'scal_f',scal_f
1269 IF ( abs(right_term(i)) .GE. 1.0_wp ) coeff_f(i) = 1.0_wp/right_term(i)
1273 right_term = coeff_f * right_term
1275 scal_f = 0.5_wp * dot_product( right_term , right_term )
1277 IF ( verbose_level .GE. 3 )
THEN 1278 WRITE(*,*)
'solve_rk_step: after normalization',scal_f
1289 qj_org = max( abs(qj_org) , 1.e-3_wp )
1293 qj_org(1:n_vars) = 1.0_wp
1297 qj_rel = qj / qj_org
1303 tolx = epsilon(qj_rel)
1305 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solve_rk_step: nl_iter',nl_iter
1307 CALL eval_f( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj , qj_old , &
1308 a_diag , coeff_f , rj_not_impl , right_term , scal_f )
1310 IF ( verbose_level .GE. 2 )
THEN 1312 WRITE(*,*)
'solve_rk_step: right_term',right_term
1316 IF ( verbose_level .GE. 2 )
THEN 1318 WRITE(*,*)
'before_lnsrch: scal_f',scal_f
1324 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1326 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1331 IF ( (
normalize_f ) .AND. ( scal_f < 1.e-6_wp ) )
THEN 1333 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check scal_f',check
1340 IF ( count( implicit_flag ) .EQ. n_eqns )
THEN 1342 CALL eval_jacobian( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj_rel , &
1343 qj_org, coeff_f , left_matrix )
1345 desc_dir_temp = - right_term
1347 IF (
wp .EQ.
sp )
THEN 1349 CALL sgesv(n_eqns,1, left_matrix , n_eqns, pivot, desc_dir_temp , &
1354 CALL dgesv(n_eqns,1, left_matrix , n_eqns, pivot, desc_dir_temp , &
1359 desc_dir = desc_dir_temp
1363 CALL eval_jacobian( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj_rel , &
1364 qj_org,coeff_f , left_matrix )
1366 left_matrix_small11 = reshape(pack(left_matrix,
mask11), &
1367 [n_eqns-n_nh,n_eqns-n_nh])
1373 left_matrix_small22 = reshape(pack(left_matrix,
mask22), &
1376 left_matrix_small21 = reshape(pack(left_matrix,
mask21), &
1379 desc_dir_small1 = pack( right_term, .NOT.implicit_flag )
1380 desc_dir_small2 = pack( right_term , implicit_flag )
1384 desc_dir_small1(i) = desc_dir_small1(i) / left_matrix_small11(i,i)
1388 desc_dir_small2 = desc_dir_small2 - &
1389 matmul( desc_dir_small1 , left_matrix_small21 )
1391 IF (
wp .EQ.
sp )
THEN 1393 CALL sgesv(n_nh,1, left_matrix_small22 , n_nh , pivot_small2 , &
1394 desc_dir_small2 , n_nh, ok)
1398 CALL dgesv(n_nh,1, left_matrix_small22 , n_nh , pivot_small2 , &
1399 desc_dir_small2 , n_nh, ok)
1403 desc_dir = unpack( - desc_dir_small2 , implicit_flag , 0.0_wp ) &
1404 + unpack( - desc_dir_small1 , .NOT.implicit_flag , 0.0_wp )
1408 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'desc_dir',desc_dir
1410 qj_rel_nr_old = qj_rel
1416 stpmax = stpmx * max( sqrt( dot_product(qj_rel,qj_rel) ) , &
1417 dble(
SIZE(qj_rel) ) )
1419 grad_f = matmul( right_term , left_matrix )
1421 desc_dir2 = desc_dir
1423 CALL lnsrch( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj_rel_nr_old , &
1424 qj_org , qj_old , scal_f_old , grad_f , desc_dir , coeff_f , &
1425 qj_rel , scal_f , right_term , stpmax , check , rj_not_impl )
1429 qj_rel = qj_rel_nr_old + desc_dir
1431 qj = qj_rel * qj_org
1433 CALL eval_f( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj , qj_old , &
1434 a_diag , coeff_f , rj_not_impl , right_term , scal_f )
1438 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'after_lnsrch: scal_f',scal_f
1440 qj = qj_rel * qj_org
1442 IF ( verbose_level .GE. 3 )
THEN 1448 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN 1450 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
1458 check = ( maxval( abs(grad_f(:)) * max( abs( qj_rel(:) ),1.0_wp ) / &
1459 max( scal_f , 0.5_wp *
SIZE(qj_rel) ) ) < tolmin )
1461 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'2: check',check
1466 IF ( maxval( abs( qj_rel(:) - qj_rel_nr_old(:) ) / max( abs( qj_rel(:)) ,&
1467 1.0_wp ) ) < tolx )
THEN 1469 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check',check
1474 END DO newton_raphson_loop
1503 SUBROUTINE lnsrch( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj_rel_NR_old , &
1504 qj_org , qj_old , scal_f_old , grad_f , desc_dir , coeff_f , qj_rel , &
1505 scal_f , right_term , stpmax , check , rj_not_impl )
1509 REAL(wp),
INTENT(IN) :: cell_fract_jk
1510 REAL(wp),
INTENT(IN) :: dx_rel_jk
1511 REAL(wp),
INTENT(IN) :: dy_rel_jk
1514 REAL(wp),
DIMENSION(:),
INTENT(IN) :: qj_rel_NR_old
1517 REAL(wp),
DIMENSION(:),
INTENT(IN) :: qj_org
1520 REAL(wp),
DIMENSION(:),
INTENT(IN) :: qj_old
1523 REAL(wp),
DIMENSION(:),
INTENT(IN) :: grad_f
1526 REAL(wp),
INTENT(IN) :: scal_f_old
1529 REAL(wp),
DIMENSION(:),
INTENT(INOUT) :: desc_dir
1531 REAL(wp),
INTENT(IN) :: stpmax
1534 REAL(wp),
DIMENSION(:),
INTENT(IN) :: coeff_f
1537 REAL(wp),
DIMENSION(:),
INTENT(OUT) :: qj_rel
1540 REAL(wp),
INTENT(OUT) :: scal_f
1543 REAL(wp),
INTENT(OUT) :: right_term(n_eqns)
1546 LOGICAL,
INTENT(OUT) :: check
1548 REAL(wp),
INTENT(IN) :: Rj_not_impl(n_eqns)
1550 REAL(wp),
PARAMETER :: TOLX=epsilon(qj_rel)
1552 INTEGER,
DIMENSION(1) :: ndum
1553 REAL(wp) :: ALF , a,alam,alam2,alamin,b,disc
1555 REAL(wp) :: desc_dir_abs
1556 REAL(wp) :: rhs1 , rhs2 , slope, tmplam
1558 REAL(wp) :: scal_f_min , alam_min
1560 REAL(wp) :: qj(n_vars)
1564 IF (
size(grad_f) ==
size(desc_dir) .AND.
size(grad_f) ==
size(qj_rel) &
1565 .AND.
size(qj_rel) ==
size(qj_rel_nr_old) )
THEN 1571 WRITE(*,*)
'nrerror: an assert_eq failed with this tag:',
'lnsrch' 1572 stop
'program terminated by assert_eq4' 1578 desc_dir_abs = sqrt( dot_product(desc_dir,desc_dir) )
1580 IF ( desc_dir_abs > stpmax ) desc_dir(:) = desc_dir(:) * stpmax/desc_dir_abs
1582 slope = dot_product(grad_f,desc_dir)
1584 alamin = tolx / maxval(abs( desc_dir(:))/max( abs(qj_rel_nr_old(:)),1.0_wp ))
1586 IF ( alamin .EQ. 0.0_wp )
THEN 1588 qj_rel(:) = qj_rel_nr_old(:)
1596 scal_f_min = scal_f_old
1598 optimal_step_search:
DO 1600 IF ( verbose_level .GE. 4 )
THEN 1602 WRITE(*,*)
'alam',alam
1606 qj_rel = qj_rel_nr_old + alam * desc_dir
1608 qj = qj_rel * qj_org
1610 CALL eval_f( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj , qj_old , &
1611 a_diag , coeff_f , rj_not_impl , right_term , scal_f )
1613 IF ( verbose_level .GE. 4 )
THEN 1615 WRITE(*,*)
'lnsrch: effe_old,effe',scal_f_old,scal_f
1620 IF ( scal_f .LT. scal_f_min )
THEN 1627 IF ( scal_f .LE. 0.9 * scal_f_old )
THEN 1630 IF ( verbose_level .GE. 4 )
THEN 1632 WRITE(*,*)
'sufficient function decrease' 1636 EXIT optimal_step_search
1638 ELSE IF ( alam < alamin )
THEN 1641 IF ( verbose_level .GE. 4 )
THEN 1643 WRITE(*,*)
' convergence on Delta_x',alam,alamin
1647 qj_rel(:) = qj_rel_nr_old(:)
1651 EXIT optimal_step_search
1656 IF ( alam .EQ. 1.0_wp )
THEN 1658 tmplam = - slope / ( 2.0_wp * ( scal_f - scal_f_old - slope ) )
1662 rhs1 = scal_f - scal_f_old - alam*slope
1663 rhs2 = scal_f2 - scal_f_old - alam2*slope
1665 a = ( rhs1/alam**2 - rhs2/alam2**2 ) / ( alam - alam2 )
1666 b = ( -alam2*rhs1/alam**2 + alam*rhs2/alam2**2 ) / ( alam - alam2 )
1668 IF ( a .EQ. 0.0_wp )
THEN 1670 tmplam = - slope / ( 2.0_wp * b )
1674 disc = b*b - 3.0_wp*a*slope
1676 IF ( disc .LT. 0.0_wp )
THEN 1678 tmplam = 0.5_wp * alam
1680 ELSE IF ( b .LE. 0.0_wp )
THEN 1682 tmplam = ( - b + sqrt(disc) ) / ( 3.0_wp * a )
1686 tmplam = - slope / ( b + sqrt(disc) )
1692 IF ( tmplam .GT. 0.5_wp * alam ) tmplam = 0.5_wp * alam
1700 alam = max( tmplam , 0.5_wp * alam )
1702 END DO optimal_step_search
1725 SUBROUTINE eval_f( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj , qj_old , &
1726 a_diag , coeff_f , rj_not_impl , f_nl , scal_f )
1732 REAL(wp),
INTENT(IN) :: cell_fract_jk
1733 REAL(wp),
INTENT(IN) :: dx_rel_jk
1734 REAL(wp),
INTENT(IN) :: dy_rel_jk
1736 REAL(wp),
INTENT(IN) :: qj(n_vars)
1737 REAL(wp),
INTENT(IN) :: qj_old(n_vars)
1738 REAL(wp),
INTENT(IN) :: a_diag
1739 REAL(wp),
INTENT(IN) :: coeff_f(n_eqns)
1740 REAL(wp),
INTENT(IN) :: Rj_not_impl(n_eqns)
1742 REAL(wp),
INTENT(OUT) :: f_nl(n_eqns)
1743 REAL(wp),
INTENT(OUT) :: scal_f
1745 REAL(wp) :: nh_term_impl(n_eqns)
1746 REAL(wp) :: Rj(n_eqns)
1749 r_qj = qj , r_nh_term_impl=nh_term_impl )
1751 rj = rj_not_impl - a_diag * nh_term_impl
1753 f_nl = qj - qj_old +
dt * rj
1755 f_nl = coeff_f * f_nl
1757 scal_f = 0.5_wp * dot_product( f_nl , f_nl )
1779 SUBROUTINE eval_jacobian( cell_fract_jk , dx_rel_jk , dy_rel_jk , qj_rel , &
1780 qj_org , coeff_f, left_matrix)
1786 REAL(wp),
INTENT(IN) :: cell_fract_jk
1787 REAL(wp),
INTENT(IN) :: dx_rel_jk
1788 REAL(wp),
INTENT(IN) :: dy_rel_jk
1790 REAL(wp),
INTENT(IN) :: qj_rel(n_vars)
1791 REAL(wp),
INTENT(IN) :: qj_org(n_vars)
1792 REAL(wp),
INTENT(IN) :: coeff_f(n_eqns)
1794 REAL(wp),
INTENT(OUT) :: left_matrix(n_eqns,n_vars)
1796 REAL(wp) :: Jacob_relax(n_eqns,n_vars)
1797 COMPLEX(wp) :: nh_terms_cmplx_impl(n_eqns)
1798 COMPLEX(wp) :: qj_cmplx(n_vars) , qj_rel_cmplx(n_vars)
1799 COMPLEX(wp) :: qj_rel_cmplx_init(n_vars)
1805 h = n_vars * epsilon(1.0_wp)
1809 left_matrix(1:n_eqns,1:n_vars) = 0.0_wp
1810 jacob_relax(1:n_eqns,1:n_vars) = 0.0_wp
1816 qj_rel_cmplx_init(i) = cmplx(qj_rel(i),0.0_wp,
wp)
1822 left_matrix(i,i) = coeff_f(i) * qj_org(i)
1824 IF ( implicit_flag(i) )
THEN 1826 qj_rel_cmplx(1:n_vars) = qj_rel_cmplx_init(1:n_vars)
1827 qj_rel_cmplx(i) = cmplx(qj_rel(i), h,
wp)
1829 qj_cmplx = qj_rel_cmplx * qj_org
1832 c_qj = qj_cmplx , c_nh_term_impl = nh_terms_cmplx_impl )
1834 jacob_relax(1:n_eqns,i) = coeff_f(i) * &
1835 aimag(nh_terms_cmplx_impl) / h
1837 left_matrix(1:n_eqns,i) = left_matrix(1:n_eqns,i) -
dt *
a_diag &
1838 * jacob_relax(1:n_eqns,i)
1873 REAL(wp),
INTENT(IN) :: q_expl(n_vars,comp_cells_x,comp_cells_y)
1874 REAL(wp),
INTENT(IN) :: qp_expl(n_vars+2,comp_cells_x,comp_cells_y)
1875 REAL(wp),
INTENT(OUT) :: divFlux_iRK(n_eqns,comp_cells_x,comp_cells_y)
1877 INTEGER :: l , i, j, k
1923 divflux_irk(i,j,k) = 0.0_wp
1925 IF ( comp_cells_x .GT. 1 )
THEN 1927 divflux_irk(i,j,k) = divflux_irk(i,j,k) + &
1932 IF ( comp_cells_y .GT. 1 )
THEN 1934 divflux_irk(i,j,k) = divflux_irk(i,j,k) + &
1966 REAL(wp) :: fluxL(n_eqns)
1967 REAL(wp) :: fluxR(n_eqns)
1968 REAL(wp) :: fluxB(n_eqns)
1969 REAL(wp) :: fluxT(n_eqns)
1976 IF ( comp_cells_x .GT. 1 )
THEN 2018 IF ( comp_cells_y .GT. 1 )
THEN 2083 REAL(wp) :: fluxL(n_eqns)
2084 REAL(wp) :: fluxR(n_eqns)
2085 REAL(wp) :: fluxB(n_eqns)
2086 REAL(wp) :: fluxT(n_eqns)
2088 REAL(wp) :: flux_avg_x(n_eqns)
2089 REAL(wp) :: flux_avg_y(n_eqns)
2101 IF ( comp_cells_x .GT. 1 )
THEN 2117 fluxl , fluxr , flux_avg_x )
2119 eqns_loop:
DO i=1,n_eqns
2146 END DO interfaces_x_loop
2153 IF ( comp_cells_y .GT. 1 )
THEN 2198 END DO interfaces_y_loop
2225 SUBROUTINE average_kt( a1 , a2 , w1 , w2 , w_avg )
2229 REAL(wp),
INTENT(IN) :: a1(:) , a2(:)
2230 REAL(wp),
INTENT(IN) :: w1(:) , w2(:)
2231 REAL(wp),
INTENT(OUT) :: w_avg(:)
2240 IF ( a1(i) .EQ. a2(i) )
THEN 2242 w_avg(i) = 0.5_wp * ( w1(i) + w2(i) )
2247 w_avg(i) = ( a2(i) * w1(i) - a1(i) * w2(i) ) / ( a2(i) - a1(i) )
2267 WRITE(*,*)
'method not yet implemented in 2-d case' 2281 WRITE(*,*)
'method not yet implemented in 2-d case' 2324 REAL(wp),
INTENT(IN) :: q_expl(:,:,:)
2325 REAL(wp),
INTENT(IN) :: qp_expl(:,:,:)
2327 REAL(wp) :: qrecW(n_vars+2)
2328 REAL(wp) :: qrecE(n_vars+2)
2329 REAL(wp) :: qrecS(n_vars+2)
2330 REAL(wp) :: qrecN(n_vars+2)
2332 REAL(wp) :: source_bdry(n_vars+2)
2333 REAL(wp) :: qrec_prime_x(n_vars+2)
2334 REAL(wp) :: qrec_prime_y(n_vars+2)
2336 REAL(wp) :: qp2recW(3) , qp2recE(3)
2337 REAL(wp) :: qp2recS(3) , qp2recN(3)
2339 REAL(wp) :: qrec_stencil(3)
2340 REAL(wp) :: x_stencil(3)
2341 REAL(wp) :: y_stencil(3)
2357 qrecw(1:n_vars+2) = qp_expl(1:n_vars+2,j,k)
2358 qrece(1:n_vars+2) = qp_expl(1:n_vars+2,j,k)
2359 qrecs(1:n_vars+2) = qp_expl(1:n_vars+2,j,k)
2360 qrecn(1:n_vars+2) = qp_expl(1:n_vars+2,j,k)
2362 x_stencil(2) = x_comp(j)
2363 y_stencil(2) = y_comp(k)
2365 vars_loop:
DO i=1,n_vars
2367 qrec_stencil(2) = qp_expl(i,j,k)
2370 check_comp_cells_x:
IF ( comp_cells_x .GT. 1 )
THEN 2373 check_x_boundary:
IF (j.EQ.1)
THEN 2375 IF ( bcw(i)%flag .EQ. 0 )
THEN 2377 x_stencil(1) = x_stag(1)
2378 x_stencil(3) = x_comp(j+1)
2380 qrec_stencil(1) = bcw(i)%value
2381 qrec_stencil(3) = qp_expl(i,j+1,k)
2383 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2386 ELSEIF ( bcw(i)%flag .EQ. 1 )
THEN 2388 qrec_prime_x(i) = bcw(i)%value
2390 ELSEIF ( bcw(i)%flag .EQ. 2 )
THEN 2392 qrec_prime_x(i) = ( qp_expl(i,2,k) - qp_expl(i,1,k) ) / dx
2397 ELSEIF (j.EQ.comp_cells_x)
THEN 2399 IF ( bce(i)%flag .EQ. 0 )
THEN 2401 qrec_stencil(3) = bce(i)%value
2402 qrec_stencil(1)= qp_expl(i,j-1,k)
2404 x_stencil(3) = x_stag(comp_interfaces_x)
2405 x_stencil(1) = x_comp(j-1)
2407 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2410 ELSEIF ( bce(i)%flag .EQ. 1 )
THEN 2412 qrec_prime_x(i) = bce(i)%value
2414 ELSEIF ( bce(i)%flag .EQ. 2 )
THEN 2416 qrec_prime_x(i) = ( qp_expl(i,comp_cells_x,k) - &
2417 qp_expl(i,comp_cells_x-1,k) ) / dx
2424 x_stencil(1) = x_comp(j-1)
2425 x_stencil(3) = x_comp(j+1)
2427 qrec_stencil(1) = qp_expl(i,j-1,k)
2428 qrec_stencil(3) = qp_expl(i,j+1,k)
2430 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2433 ENDIF check_x_boundary
2437 qrecw(i) = qrec_stencil(2) - dq
2438 qrece(i) = qrec_stencil(2) + dq
2440 END IF check_comp_cells_x
2443 check_comp_cells_y:
IF ( comp_cells_y .GT. 1 )
THEN 2446 check_y_boundary:
IF (k.EQ.1)
THEN 2448 IF ( bcs(i)%flag .EQ. 0 )
THEN 2450 y_stencil(1) = y_stag(1)
2451 y_stencil(3) = y_comp(k+1)
2453 qrec_stencil(1) = bcs(i)%value
2454 qrec_stencil(3) = qp_expl(i,j,k+1)
2456 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2459 ELSEIF ( bcs(i)%flag .EQ. 1 )
THEN 2461 qrec_prime_y(i) = bcs(i)%value
2463 ELSEIF ( bcs(i)%flag .EQ. 2 )
THEN 2465 qrec_prime_y(i) = ( qp_expl(i,j,2) - qp_expl(i,j,1) ) / dy
2470 ELSEIF ( k .EQ. comp_cells_y )
THEN 2472 IF ( bcn(i)%flag .EQ. 0 )
THEN 2474 y_stencil(3) = y_stag(comp_interfaces_y)
2475 y_stencil(1) = y_comp(k-1)
2477 qrec_stencil(3) = bcn(i)%value
2478 qrec_stencil(1)= qp_expl(i,j,k-1)
2480 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2483 ELSEIF ( bcn(i)%flag .EQ. 1 )
THEN 2485 qrec_prime_y(i) = bcn(i)%value
2487 ELSEIF ( bcn(i)%flag .EQ. 2 )
THEN 2489 qrec_prime_y(i) = ( qp_expl(i,j,comp_cells_y) - &
2490 qp_expl(i,j,comp_cells_y-1) ) / dy
2497 y_stencil(1) = y_comp(k-1)
2498 y_stencil(3) = y_comp(k+1)
2500 qrec_stencil(1) = qp_expl(i,j,k-1)
2501 qrec_stencil(3) = qp_expl(i,j,k+1)
2503 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2506 ENDIF check_y_boundary
2510 qrecs(i) = qrec_stencil(2) - dq
2511 qrecn(i) = qrec_stencil(2) + dq
2513 ENDIF check_comp_cells_y
2517 add_vars_loop:
DO i=n_vars+1,n_vars+2
2521 check_comp_cells_x2:
IF ( comp_cells_x .GT. 1 )
THEN 2523 IF ( (j .GT. 1) .AND. (j .LT. comp_cells_x) )
THEN 2525 x_stencil(1:3) = x_comp(j-1:j+1)
2526 qrec_stencil(1:3) = qp_expl(i,j-1:j+1,k)
2528 CALL limit( qrec_stencil , x_stencil , limiter(i) , &
2533 qrecw(i) = qrec_stencil(2) - dq
2534 qrece(i) = qrec_stencil(2) + dq
2538 END IF check_comp_cells_x2
2541 check_comp_cells_y2:
IF ( comp_cells_y .GT. 1 )
THEN 2543 IF ( ( k .GT. 1 ) .AND. ( k .LT. comp_cells_y ) )
THEN 2545 y_stencil(1:3) = y_comp(k-1:k+1)
2546 qrec_stencil = qp_expl(i,j,k-1:k+1)
2548 CALL limit( qrec_stencil , y_stencil , limiter(i) , &
2553 qrecs(i) = qrec_stencil(2) - dq
2554 qrecn(i) = qrec_stencil(2) + dq
2558 ENDIF check_comp_cells_y2
2563 IF ( comp_cells_x .GT. 1 )
THEN 2565 IF ( ( j .GT. 1 ) .AND. ( j .LT. comp_cells_x ) )
THEN 2567 IF ( q_expl(1,j,k) .EQ. 0.0_wp )
THEN 2593 IF ( bcw(i)%flag .EQ. 0 )
THEN 2595 qrecw(i) = bcw(i)%value
2601 DO i=n_vars+1,n_vars+2
2603 CALL qp_to_qp2( qrecw(1:n_vars) , qp2recw )
2604 qrecw(i) = qp2recw(i-n_vars+1)
2606 CALL qp_to_qp2( qrece(1:n_vars) , qp2rece )
2607 qrece(i) = qp2rece(i-n_vars+1)
2611 ELSEIF ( j.EQ.comp_cells_x )
THEN 2616 IF ( bce(i)%flag .EQ. 0 )
THEN 2618 qrece(i) = bce(i)%value
2624 DO i=n_vars+1,n_vars+2
2626 CALL qp_to_qp2( qrecw(1:n_vars) , qp2recw )
2627 qrecw(i) = qp2recw(i-n_vars+1)
2629 CALL qp_to_qp2( qrece(1:n_vars) , qp2rece )
2630 qrece(i) = qp2rece(i-n_vars+1)
2653 ELSEIF ( j.EQ.comp_cells_x )
THEN 2674 IF ( comp_cells_y .GT. 1 )
THEN 2676 IF ( ( k .GT. 1 ) .AND. ( k .LT. comp_cells_y ) )
THEN 2678 IF ( q_expl(1,j,k) .EQ. 0.0_wp )
THEN 2700 IF ( k .EQ. 1 )
THEN 2705 IF ( bcs(i)%flag .EQ. 0 )
THEN 2707 qrecs(i) = bcs(i)%value
2713 DO i=n_vars+1,n_vars+2
2715 CALL qp_to_qp2( qrecs(1:n_vars) , qp2recs )
2716 qrecs(i) = qp2recs(i-n_vars+1)
2718 CALL qp_to_qp2( qrecn(1:n_vars) , qp2recn )
2719 qrecn(i) = qp2recn(i-n_vars+1)
2723 ELSEIF ( k .EQ. comp_cells_y )
THEN 2728 IF ( bcn(i)%flag .EQ. 0 )
THEN 2730 qrecn(i) = bcn(i)%value
2736 DO i=n_vars+1,n_vars+2
2738 CALL qp_to_qp2( qrecs(1:n_vars) , qp2recs )
2739 qrecs(i) = qp2recs(i-n_vars+1)
2741 CALL qp_to_qp2( qrecn(1:n_vars) , qp2recn )
2742 qrecn(i) = qp2recn(i-n_vars+1)
2756 IF ( k .EQ. 1 )
THEN 2762 ELSEIF ( k .EQ. comp_cells_y )
THEN 2814 REAL(wp) :: abslambdaL_min(n_vars) , abslambdaL_max(n_vars)
2815 REAL(wp) :: abslambdaR_min(n_vars) , abslambdaR_max(n_vars)
2816 REAL(wp) :: abslambdaB_min(n_vars) , abslambdaB_max(n_vars)
2817 REAL(wp) :: abslambdaT_min(n_vars) , abslambdaT_max(n_vars)
2818 REAL(wp) :: min_r(n_vars) , max_r(n_vars)
2824 IF ( comp_cells_x .GT. 1 )
THEN 2840 min_r = min(abslambdal_min , abslambdar_min , 0.0_wp)
2841 max_r = max(abslambdal_max , abslambdar_max , 0.0_wp)
2846 END DO x_interfaces_loop
2852 IF ( comp_cells_y .GT. 1 )
THEN 2868 min_r = min(abslambdab_min , abslambdat_min , 0.0_wp)
2869 max_r = max(abslambdab_max , abslambdat_max , 0.0_wp)
2874 END DO y_interfaces_loop
subroutine eval_speeds
Characteristic speeds.
real(wp), dimension(:,:), allocatable sourcew_vect_x
real(wp), dimension(:,:,:,:), allocatable q_rk
Intermediate solutions of the Runge-Kutta scheme.
real(wp), dimension(:,:,:), allocatable qp_cellnw
Reconstructed physical value at the NW corner of cell.
integer n_rk
Runge-Kutta order.
real(wp), dimension(:,:), allocatable sourcew_vect_y
integer, dimension(:), allocatable j_stag_y
real(wp), dimension(:,:,:), allocatable qp_interfacer
Reconstructed physical value at the right of the x-interface.
real(wp), dimension(:,:,:), allocatable a_interface_yneg
Local speeds at the bottom of the y-interface.
real(wp), dimension(:,:), allocatable sources_vect_x
subroutine reconstruction(q_expl, qp_expl)
Linear reconstruction.
integer comp_cells_x
Number of control volumes x in the comp. domain.
subroutine eval_flux_gforce
Numerical fluxes GFORCE.
subroutine eval_local_speeds_x(qpj, vel_min, vel_max)
Local Characteristic speeds x direction.
real(wp) a_diag
Implicit coeff. for the non-hyp. part for a single step of the R-K scheme.
real(wp) dy2
Half y Control volumes size.
real(wp), dimension(:,:,:), allocatable q_cellnw
Reconstructed value at the NW corner of cell.
logical, dimension(:,:), allocatable mask11
subroutine lnsrch(cell_fract_jk, dx_rel_jk, dy_rel_jk, qj_rel_NR_old, qj_org, qj_old, scal_f_old, grad_f, desc_dir, coeff_f, qj_rel, scal_f, right_term, stpmax, check, Rj_not_impl)
Search the descent stepsize.
real(wp), dimension(:,:,:), allocatable qp_interfacel
Reconstructed physical value at the left of the x-interface.
real(wp), dimension(:,:,:), allocatable a_interface_x_max
Max local speeds at the x-interface.
real(wp), dimension(:,:,:), allocatable q_cellne
Reconstructed value at the NE corner of cell.
integer, dimension(:), allocatable k_cent
real(wp), dimension(:,:,:), allocatable q_cellse
Reconstructed value at the SE corner of cell.
subroutine average_kt(a1, a2, w1, w2, w_avg)
averaged KT flux
real(wp), dimension(:,:,:), allocatable a_interface_ypos
Local speeds at the top of the y-interface.
subroutine qp_to_qp2(qpj, qp2j)
Additional Physical variables.
integer comp_cells_y
Number of control volumes y in the comp. domain.
real(wp), dimension(:,:,:,:), allocatable nh
Intermediate non-hyperbolic terms of the Runge-Kutta scheme.
subroutine deallocate_solver_variables
Memory deallocation.
logical, dimension(:,:), allocatable sourcee
logical, dimension(:,:), allocatable sourcew
subroutine solve_rk_step(cell_fract_jk, dx_rel_jk, dy_rel_jk, qj, qj_old, a_tilde, a_dirk, a_diag, Rj_not_impl, divFluxj, NHj)
Runge-Kutta single step integration.
type(bc), dimension(:), allocatable bcw
bcW&flag defines the west boundary condition:
real(wp), dimension(:), allocatable omega_tilde
Coefficients for the explicit part of the Runge-Kutta scheme.
real(wp), dimension(:,:,:), allocatable a_interface_y_max
Max local speeds at the y-interface.
real(wp) x0
Left of the physical domain.
real(wp), dimension(:,:), allocatable cell_fract
real(wp), dimension(:,:,:), allocatable h_interface_y
Semidiscrete numerical interface fluxes.
real(wp), dimension(:,:,:), allocatable q_mg_new
real(wp), dimension(:,:,:,:), allocatable divflux
Intermediate hyperbolic terms of the Runge-Kutta scheme.
real(wp), dimension(:,:), allocatable sourcee_vect_x
real(wp), dimension(:,:,:), allocatable q_cellsw
Reconstructed value at the SW corner of cell.
real(wp), dimension(:,:,:), allocatable qp_cellne
Reconstructed physical value at the NE corner of cell.
subroutine regrid_scalar(xin, yin, fin, xl, xr, yl, yr, fout)
Scalar regrid (2D)
integer, dimension(:), allocatable k_stag_x
real(wp) function minmod(a, b)
integer n_vars
Number of conservative variables.
subroutine eval_flux_lxf
Numerical fluxes Lax-Friedrichs.
real(wp), dimension(:,:,:), allocatable q_interfacel
Reconstructed value at the left of the x-interface.
integer comp_interfaces_y
Number of interfaces (comp_cells_y+1)
real(wp), dimension(:), allocatable x_comp
Location of the centers (x) of the control volume of the domain.
real(wp), dimension(:,:,:), allocatable qp
Physical variables ( )
integer, parameter max_nl_iter
subroutine eval_fluxes(qcj, qpj, dir, flux)
Hyperbolic Fluxes.
subroutine eval_f(cell_fract_jk, dx_rel_jk, dy_rel_jk, qj, qj_old, a_diag, coeff_f, Rj_not_impl, f_nl, scal_f)
Evaluate the nonlinear system.
real(wp), dimension(:,:,:), allocatable q_fv
Solution of the finite-volume semidiscrete cheme.
real(wp), dimension(:,:,:), allocatable q0
Conservative variables.
logical normalize_q
Flag for the normalization of the array q in the implicit solution scheme.
logical, dimension(:,:), allocatable mask21
logical, dimension(:,:), allocatable solve_mask_y
real(wp) cfl
Courant-Friedrichs-Lewy parameter.
real(wp), dimension(:,:), allocatable sourcee_vect_y
logical, dimension(:), allocatable implicit_flag
flag used for size of implicit non linear-system
real(wp), parameter tol_abs
subroutine limit(v, z, limiter, slope_lim)
Slope limiter.
real(wp), dimension(:), allocatable x_stag
Location of the boundaries (x) of the control volumes of the domain.
subroutine eval_source_bdry(time, vect_x, vect_y, source_bdry)
Internal boundary source fluxes.
real(wp), dimension(:,:,:), allocatable q_mg_old
subroutine eval_local_speeds_y(qpj, vel_min, vel_max)
Local Characteristic speeds y direction.
character(len=20) solver_scheme
Finite volume method: .
real(wp), dimension(:,:,:), allocatable qp_interfacet
Reconstructed physical value at the top of the y-interface.
real(wp) dx2
Half x Control volumes size.
integer, dimension(:,:), allocatable source_cell
real(wp), dimension(:,:), allocatable q1max
Maximum over time of thickness.
subroutine deallocate_multigrid
real(wp), dimension(:,:,:), allocatable q_interfacer
Reconstructed value at the right of the x-interface.
real(wp), dimension(:,:,:), allocatable qp_cellse
Reconstructed physical value at the SE corner of cell.
subroutine check_solve
Masking of cells to solve.
real(wp), dimension(:), allocatable a_tilde
Explicit coeff. for the hyperbolic part for a single step of the R-K scheme.
integer, dimension(:), allocatable k_stag_y
real(wp), dimension(:), allocatable y_stag
Location of the boundaries (x) of the control volumes of the domain.
real(wp), dimension(:,:,:), allocatable q_interfacet
Reconstructed value at the top of the y-interface.
logical, dimension(:,:), allocatable mask22
subroutine eval_jacobian(cell_fract_jk, dx_rel_jk, dy_rel_jk, qj_rel, qj_org, coeff_f, left_matrix)
Evaluate the jacobian.
real(wp), dimension(:,:,:), allocatable a_interface_xneg
Local speeds at the left of the x-interface.
real(wp), parameter tol_rel
subroutine timestep
Time-step computation.
integer solve_interfaces_x
subroutine qc_to_qp(qc, qp)
Conservative to physical variables.
integer, dimension(:), allocatable j_cent
integer solve_interfaces_y
subroutine eval_nonhyperbolic_terms(cell_fract_jk, dx_rel_jk, dy_rel_jk, c_qj, c_nh_term_impl, r_qj, r_nh_term_impl)
Non-Hyperbolic terms.
real(wp), dimension(:,:), allocatable dx_rel
real(wp), dimension(:,:), allocatable a_tilde_ij
Butcher Tableau for the explicit part of the Runge-Kutta scheme.
real(wp), dimension(:,:,:), allocatable residual_term
Sum of all the terms of the equations except the transient term.
real(wp), dimension(:,:,:), allocatable q_interfaceb
Reconstructed value at the bottom of the y-interface.
real(wp) dx
Control volumes size.
logical opt_search_nl
Flag for the search of optimal step size in the implicit solution scheme.
real(wp), dimension(:,:,:), allocatable qp_interfaceb
Reconstructed physical value at the bottom of the y-interface.
real(wp), dimension(:,:,:), allocatable qp_cellsw
Reconstructed physical value at the SW corner of cell.
logical normalize_f
Flag for the normalization of the array f in the implicit solution scheme.
integer, dimension(10) limiter
Limiter for the slope in the linear reconstruction: .
real(wp), dimension(:,:), allocatable sources_vect_y
integer, parameter wp
working precision
type(bc), dimension(:), allocatable bcn
bcN&flag defines the north boundary condition:
real(wp), dimension(:,:), allocatable sourcen_vect_y
logical, dimension(:,:), allocatable sourcen
real(wp), dimension(:,:,:), allocatable h_interface_x
Semidiscrete numerical interface fluxes.
integer n_eqns
Number of equations.
real(wp) max_dt
Largest time step allowed.
subroutine eval_flux_up
Upwind numerical fluxes.
real(wp), dimension(:,:,:), allocatable q
Conservative variables.
subroutine imex_rk_solver
Runge-Kutta integration.
type(bc), dimension(:), allocatable bcs
bcS&flag defines the south boundary condition:
logical, dimension(:,:), allocatable solve_mask
subroutine eval_hyperbolic_terms(q_expl, qp_expl, divFlux_iRK)
Semidiscrete finite volume central scheme.
subroutine remap_solution
real(wp), dimension(:,:,:,:), allocatable qp_rk
Intermediate physical solutions of the Runge-Kutta scheme.
integer comp_interfaces_x
Number of interfaces (comp_cells_x+1)
real(wp), dimension(:,:,:), allocatable a_interface_xpos
Local speeds at the right of the x-interface.
real(wp) y0
Bottom of the physical domain.
type(bc), dimension(:), allocatable bce
bcE&flag defines the east boundary condition:
subroutine qp_to_qc(qp, qc)
Physical to conservative variables.
logical, dimension(:,:), allocatable solve_mask_x
real(wp), dimension(:,:), allocatable a_dirk_ij
Butcher Tableau for the implicit part of the Runge-Kutta scheme.
integer, dimension(:), allocatable j_stag_x
subroutine eval_flux_kt
Semidiscrete numerical fluxes.
integer i_rk
loop counter for the RK iteration
subroutine allocate_solver_variables
Memory allocation.
real(wp) reconstr_coeff
Slope coefficient in the linear reconstruction.
real(wp), dimension(:), allocatable omega
Coefficients for the implicit part of the Runge-Kutta scheme.
logical, dimension(:,:), allocatable mask12
real(wp), dimension(:), allocatable a_dirk
Explicit coeff. for the non-hyp. part for a single step of the R-K scheme.
real(wp), dimension(:), allocatable y_comp
Location of the centers (y) of the control volume of the domain.
integer n_nh
Number of non-hyperbolic terms.
real(wp), dimension(:,:), allocatable sourcen_vect_x
logical, dimension(:,:), allocatable sources
real(wp), dimension(:,:), allocatable source_xy
Array defining fraction of cells affected by source term.
real(wp) dy
Control volumes size.
subroutine allocate_multigrid
real(wp), dimension(:,:), allocatable dy_rel