21 USE geometry, ONLY : b_cent , b_prime , b_stag
33 REAL*8,
ALLOCATABLE :: q(:,:)
35 REAL*8,
ALLOCATABLE :: q0(:,:)
37 REAL*8,
ALLOCATABLE :: q_fv(:,:)
39 REAL*8,
ALLOCATABLE :: q_interfaceL(:,:)
41 REAL*8,
ALLOCATABLE :: q_interfaceR(:,:)
43 REAL*8,
ALLOCATABLE :: a_interfaceL(:,:)
45 REAL*8,
ALLOCATABLE :: a_interfaceR(:,:)
47 REAL*8,
ALLOCATABLE :: H_interface(:,:)
49 REAL*8,
ALLOCATABLE :: qp(:,:)
55 LOGICAL,
ALLOCATABLE :: mask22(:,:) , mask21(:,:) , mask11(:,:) , mask12(:,:)
58 REAL*8,
ALLOCATABLE :: a_tilde_ij(:,:)
60 REAL*8,
ALLOCATABLE :: a_dirk_ij(:,:)
63 REAL*8,
ALLOCATABLE :: omega_tilde(:)
65 REAL*8,
ALLOCATABLE :: omega(:)
68 REAL*8,
ALLOCATABLE :: a_tilde(:)
70 REAL*8,
ALLOCATABLE :: a_dirk(:)
75 REAL*8,
ALLOCATABLE :: q_rk(:,:,:)
77 REAL*8,
ALLOCATABLE :: F_x(:,:,:)
79 REAL*8,
ALLOCATABLE :: NH(:,:,:)
82 REAL*8,
ALLOCATABLE :: expl_terms(:,:,:)
85 REAL*8,
ALLOCATABLE :: Fxj(:,:)
87 REAL*8,
ALLOCATABLE :: NHj(:,:)
89 REAL*8,
ALLOCATABLE :: expl_terms_j(:,:)
91 LOGICAL :: normalize_q
92 LOGICAL :: normalize_f
93 LOGICAL :: opt_search_NL
95 REAL*8,
ALLOCATABLE :: residual_term(:,:)
120 ALLOCATE( q( n_vars , comp_cells ) , q0( n_vars , comp_cells ) )
122 ALLOCATE( q_fv( n_vars , comp_cells ) )
124 ALLOCATE( q_interfacel( n_vars , comp_interfaces ) )
125 ALLOCATE( q_interfacer( n_vars , comp_interfaces ) )
127 ALLOCATE( a_interfacel( n_eqns , comp_interfaces ) )
128 ALLOCATE( a_interfacer( n_eqns , comp_interfaces ) )
130 ALLOCATE( h_interface( n_eqns , comp_interfaces ) )
132 ALLOCATE( qp( n_vars , comp_cells ) )
134 ALLOCATE( a_tilde_ij(n_rk,n_rk) )
135 ALLOCATE( a_dirk_ij(n_rk,n_rk) )
136 ALLOCATE( omega_tilde(n_rk) )
137 ALLOCATE( omega(n_rk) )
139 ALLOCATE( mask22(n_eqns,n_eqns) )
140 ALLOCATE( mask21(n_eqns,n_eqns) )
141 ALLOCATE( mask11(n_eqns,n_eqns) )
142 ALLOCATE( mask12(n_eqns,n_eqns) )
144 mask11(1:n_eqns,1:n_eqns) = .false.
145 mask12(1:n_eqns,1:n_eqns) = .false.
146 mask22(1:n_eqns,1:n_eqns) = .false.
147 mask21(1:n_eqns,1:n_eqns) = .false.
153 IF ( .NOT.implicit_flag(i) .AND. .NOT.implicit_flag(j) ) &
155 IF ( implicit_flag(i) .AND. .NOT.implicit_flag(j) ) &
157 IF ( implicit_flag(i) .AND. implicit_flag(j) ) &
159 IF ( .NOT.implicit_flag(i) .AND. implicit_flag(j) ) &
172 gamma = 1.d0 - 1.d0 / sqrt(2.d0)
174 IF ( n_rk .EQ. 1 )
THEN
176 a_tilde_ij(1,1) = 1.d0
178 omega_tilde(1) = 1.d0
180 a_dirk_ij(1,1) = 0.d0
184 ELSEIF ( n_rk .EQ. 2 )
THEN
186 a_tilde_ij(2,1) = 1.0d0
188 omega_tilde(1) = 1.0d0
189 omega_tilde(2) = 0.0d0
191 a_dirk_ij(2,2) = 1.0d0
196 ELSEIF ( n_rk .EQ. 3 )
THEN
198 a_tilde_ij(2,1) = 0.5d0
199 a_tilde_ij(3,1) = 0.5d0
200 a_tilde_ij(3,2) = 0.5d0
202 omega_tilde(1) = 1.0d0 / 3.0d0
203 omega_tilde(2) = 1.0d0 / 3.0d0
204 omega_tilde(3) = 1.0d0 / 3.0d0
206 a_dirk_ij(1,1) = 0.25d0
207 a_dirk_ij(2,2) = 0.25d0
208 a_dirk_ij(3,1) = 1.0d0 / 3.0d0
209 a_dirk_ij(3,2) = 1.0d0 / 3.0d0
210 a_dirk_ij(3,3) = 1.0d0 / 3.0d0
212 omega(1) = 1.0d0 / 3.0d0
213 omega(2) = 1.0d0 / 3.0d0
214 omega(3) = 1.0d0 / 3.0d0
216 ELSEIF ( n_rk .EQ. 4 )
THEN
220 a_tilde_ij(2,1) = 0.5d0
221 a_tilde_ij(3,1) = 1.d0 / 3.d0
222 a_tilde_ij(4,2) = 1.0d0
224 omega_tilde(1) = 0.d0
225 omega_tilde(2) = 1.0d0
226 omega_tilde(3) = 0.0d0
227 omega_tilde(4) = 0.d0
229 a_dirk_ij(2,2) = 0.5d0
230 a_dirk_ij(3,3) = 1.0d0 / 3.0d0
231 a_dirk_ij(4,3) = 0.75d0
232 a_dirk_ij(4,4) = 0.25d0
241 ALLOCATE( a_tilde(n_rk) )
242 ALLOCATE( a_dirk(n_rk) )
244 ALLOCATE( q_rk( n_vars , comp_cells , n_rk ) )
245 ALLOCATE( f_x( n_eqns , comp_cells , n_rk ) )
246 ALLOCATE( nh( n_eqns , comp_cells , n_rk ) )
248 ALLOCATE( expl_terms( n_eqns , comp_cells , n_rk ) )
250 ALLOCATE( fxj(n_eqns,n_rk) )
251 ALLOCATE( nhj(n_eqns,n_rk) )
252 ALLOCATE( expl_terms_j(n_eqns,n_rk) )
254 ALLOCATE( residual_term( n_vars , comp_cells ) )
276 DEALLOCATE( q_interfacel )
277 DEALLOCATE( q_interfacer )
279 DEALLOCATE( a_interfacel )
280 DEALLOCATE( a_interfacer )
282 DEALLOCATE( h_interface )
286 DEALLOCATE( a_tilde_ij )
287 DEALLOCATE( a_dirk_ij )
288 DEALLOCATE( omega_tilde )
291 DEALLOCATE( implicit_flag )
293 DEALLOCATE( a_tilde )
303 DEALLOCATE( mask22 , mask21 , mask11 , mask12 )
305 DEALLOCATE( residual_term )
333 REAL*8 :: vel_max(n_vars)
334 REAL*8 :: vel_min(n_vars)
339 REAL*8 :: a_interface_max(n_eqns,comp_interfaces)
340 REAL*8 :: dt_interface
346 IF ( cfl .NE. -1.d0 )
THEN
348 IF ( reconstr_variables .EQ. 0 )
THEN
353 ELSEIF ( reconstr_variables .EQ. 0 )
THEN
370 a_interface_max(i,:) = max( a_interfacer(i,:) , -a_interfacel(i,:) )
386 dt_interface = cfl * dx / max( maxval(a_interface_max(:,j)) , &
387 maxval(a_interface_max(:,j+1)) )
389 dt = min( dt , dt_interface )
422 REAL*8 :: q_guess(n_vars)
426 REAL*8 :: nh_term(n_eqns)
430 q0( 1:n_vars , 1:comp_cells ) = q( 1:n_vars , 1:comp_cells )
432 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: beginning'
435 q_rk(1:n_vars,1:comp_cells,1:n_rk) = 0.d0
437 f_x(1:n_eqns,1:comp_cells,1:n_rk) = 0.d0
439 nh(1:n_eqns,1:comp_cells,1:n_rk) = 0.d0
441 expl_terms(1:n_eqns,1:comp_cells,1:n_rk) = 0.d0
445 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: i_RK',i_rk
451 a_tilde(1:i_rk-1) = a_tilde_ij(i_rk,1:i_rk-1)
452 a_dirk(1:i_rk-1) = a_dirk_ij(i_rk,1:i_rk-1)
455 a_diag = a_dirk_ij(i_rk,i_rk)
459 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solver, imex_RK_solver: j',j
461 IF ( i_rk .EQ. 1 )
THEN
463 q_guess(1:n_vars) = q0( 1:n_vars , j )
467 q_guess(1:n_vars) = q_rk( 1:n_vars , j , max(1,i_rk-1) )
471 fxj(1:n_eqns,1:n_rk) = f_x( 1:n_eqns , j , 1:n_rk )
473 nhj(1:n_eqns,1:n_rk) = nh( 1:n_eqns , j , 1:n_rk )
475 expl_terms_j(1:n_eqns,1:n_rk) = expl_terms( 1:n_eqns , j , 1:n_rk )
477 IF ( verbose_level .GE. 2 )
THEN
479 WRITE(*,*)
'q_guess',q_guess
480 CALL
qc_to_qp( q_guess , b_cent(j) , qp(1:n_vars,j) )
481 WRITE(*,*)
'q_guess: qp',qp(1:n_vars,j)
485 IF ( a_diag .NE. 0.d0 )
THEN
488 q0(1:n_vars,j ) , a_tilde , a_dirk , a_diag )
492 q_rk( 1:n_vars , j , i_rk ) = q_guess
496 IF ( a_diag .EQ. 0.d0 )
THEN
499 r_qj = q_guess , r_nh_term_impl = nh(1:n_eqns,j,i_rk) )
503 nh( 1:n_eqns , j , i_rk ) = 1.d0 / a_diag * ( ( q_guess - &
504 q0( 1:n_vars , j ) ) / dt + &
505 ( matmul(fxj,a_tilde) - matmul(nhj,a_dirk) ) )
509 IF ( verbose_level .GE. 2 )
THEN
511 WRITE(*,*)
'imex_RK_solver: qc',q_guess
512 CALL
qc_to_qp( q_guess, b_cent(j) , qp(1:n_vars,j) )
513 WRITE(*,*)
'imex_RK_solver: qp',qp(1:n_vars,j)
522 f_x(1:n_eqns,1:comp_cells,i_rk) )
526 expl_terms(1:n_eqns,:,i_rk) )
528 IF ( verbose_level .GE. 1 )
THEN
530 WRITE(*,*)
'Fx, expl_terms'
534 WRITE(*,*) f_x(1:n_vars,j,i_rk),expl_terms(2,j,i_rk)
546 residual_term(1:n_vars,j) = matmul( f_x(1:n_eqns,j,1:n_rk) &
547 + expl_terms(1:n_eqns,j,1:n_rk) , omega_tilde ) &
548 - matmul( nh(1:n_eqns,j,1:n_rk) , omega )
556 IF ( verbose_level .GE. 1 )
THEN
558 WRITE(*,*)
'cell j =',j
559 WRITE(*,*)
'before imex_RK_solver: qc',q0(1:n_vars,j)
560 CALL
qc_to_qp(q0(1:n_vars,j) , b_cent(j) , qp(1:n_vars,j))
561 WRITE(*,*)
'before imex_RK_solver: qp',qp(1:n_vars,j)
565 q(1:n_vars,j) = q0(1:n_vars,j) - dt * residual_term(1:n_vars,j)
567 IF ( verbose_level .GE. 1 )
THEN
569 CALL
qc_to_qp(q(1:n_vars,j) , b_cent(j) , qp(1:n_vars,j))
571 WRITE(*,*)
'after imex_RK_solver: qc',q(1:n_vars,j)
572 WRITE(*,*)
'after imex_RK_solver: qp',qp(1:n_vars,j)
605 SUBROUTINE solve_rk_step( Bj , Bprimej, qj, qj_old, a_tilde , a_dirk , a_diag )
607 USE parameters, ONLY : max_nl_iter , tol_rel , tol_abs
613 REAL*8,
INTENT(IN) :: bj
614 REAL*8,
INTENT(IN) :: bprimej
615 REAL*8,
INTENT(INOUT) :: qj(n_vars)
616 REAL*8,
INTENT(IN) :: qj_old(n_vars)
617 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
618 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
619 REAL*8,
INTENT(IN) :: a_diag
621 REAL*8 :: qj_org(n_vars) , qj_rel(n_vars)
623 REAL*8 :: left_matrix(n_eqns,n_vars)
624 REAL*8 :: right_term(n_eqns)
628 REAL*8 :: coeff_f(n_eqns)
630 REAL*8 :: qj_rel_nr_old(n_vars)
632 REAL*8 :: desc_dir(n_vars)
633 REAL*8 :: grad_f(n_vars)
635 INTEGER :: pivot(n_vars)
637 REAL*8 :: desc_dir_small(n_vars)
639 REAL*8 :: left_matrix_small22(n_nh,n_nh)
640 REAL*8 :: left_matrix_small21(n_eqns-n_nh,n_nh)
641 REAL*8 :: left_matrix_small11(n_eqns-n_nh,n_vars-n_nh)
642 REAL*8 :: left_matrix_small12(n_nh,n_vars-n_nh)
644 REAL*8 :: right_term_small2(n_nh)
645 REAL*8 :: desc_dir_small2(n_nh)
646 INTEGER :: pivot_small2(n_nh)
648 REAL*8 :: right_term_small1(n_eqns-n_nh)
649 REAL*8 :: desc_dir_small1(n_vars-n_nh)
650 INTEGER :: pivot_small1(n_vars-n_nh)
657 REAL*8,
PARAMETER :: stpmx=100.d0
661 REAL*8,
PARAMETER :: tolf=1.d-10 , tolmin=1.d-6
664 REAL*8 :: scal_f_init
666 REAL*8 :: qpj(n_vars)
668 REAL*8 :: desc_dir2(n_vars)
670 REAL*8 :: desc_dir_temp(n_vars)
673 normalize_f = .false.
674 opt_search_nl = .true.
676 coeff_f(1:n_eqns) = 1.d0
680 IF ( normalize_f )
THEN
682 qj = qj_old - dt * ( matmul(fxj,a_tilde) - matmul(nhj,a_dirk) )
684 CALL
eval_f( bj , bprimej , qj , qj_old , a_tilde , a_dirk , a_diag , &
685 coeff_f , right_term , scal_f )
687 IF ( verbose_level .GE. 3 )
THEN
689 WRITE(*,*)
'solve_rk_step: non-normalized right_term'
690 WRITE(*,*) right_term
691 WRITE(*,*)
'scal_f',scal_f
697 IF ( abs(right_term(i)) .GE. 1.d0 ) coeff_f(i) = 1.d0 / right_term(i)
701 right_term = coeff_f * right_term
703 scal_f = 0.5d0 * dot_product( right_term , right_term )
705 IF ( verbose_level .GE. 3 )
THEN
706 WRITE(*,*)
'solve_rk_step: after normalization',scal_f
725 IF ( normalize_q )
THEN
729 qj_org = max( abs(qj_org) , 1.d-3 )
733 qj_org(1:n_vars) = 1.d0
741 DO nl_iter=1,max_nl_iter
743 tolx = epsilon(qj_rel)
745 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'solve_rk_step: nl_iter',nl_iter
747 CALL
eval_f( bj , bprimej , qj , qj_old , a_tilde , a_dirk , a_diag , &
748 coeff_f , right_term , scal_f )
750 IF ( verbose_level .GE. 2 )
THEN
752 WRITE(*,*)
'solve_rk_step: right_term',right_term
756 IF ( verbose_level .GE. 2 )
THEN
758 WRITE(*,*)
'before_lnsrch: scal_f',scal_f
764 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN
766 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
771 IF ( ( normalize_f ) .AND. ( scal_f < 1.d-6 ) )
THEN
773 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check scal_f',check
780 IF ( count( implicit_flag ) .EQ. n_eqns )
THEN
782 CALL
eval_jacobian(bj,bprimej,qj_rel,qj_org,coeff_f,left_matrix)
784 desc_dir_temp = - right_term
786 CALL dgesv(n_eqns,1, left_matrix , n_eqns, pivot, desc_dir_temp , &
789 desc_dir = desc_dir_temp
793 CALL
eval_jacobian(bj,bprimej,qj_rel,qj_org,coeff_f,left_matrix)
795 left_matrix_small11 = reshape(pack(left_matrix, mask11), &
796 [n_eqns-n_nh,n_eqns-n_nh])
798 left_matrix_small12 = reshape(pack(left_matrix, mask12), &
801 left_matrix_small22 = reshape(pack(left_matrix, mask22), &
804 left_matrix_small21 = reshape(pack(left_matrix, mask21), &
808 desc_dir_small1 = pack( right_term, .NOT.implicit_flag )
809 desc_dir_small2 = pack( right_term , implicit_flag )
813 desc_dir_small1(i) = desc_dir_small1(i) / left_matrix_small11(i,i)
817 desc_dir_small2 = desc_dir_small2 - &
818 matmul( desc_dir_small1 , left_matrix_small21 )
820 CALL dgesv(n_nh,1, left_matrix_small22 , n_nh , pivot_small2 , &
821 desc_dir_small2 , n_nh, ok)
823 desc_dir = unpack( - desc_dir_small2 , implicit_flag , 0.0d0 ) &
824 + unpack( - desc_dir_small1 , .NOT.implicit_flag , 0.0d0 )
828 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'desc_dir',desc_dir
830 qj_rel_nr_old = qj_rel
833 IF ( ( opt_search_nl ) .AND. ( nl_iter .GT. 1 ) )
THEN
836 stpmax = stpmx * max( sqrt( dot_product(qj_rel,qj_rel) ) , &
837 dble(
SIZE(qj_rel) ) )
839 grad_f = matmul( right_term , left_matrix )
843 CALL
lnsrch( bj , bprimej , qj_rel_nr_old , qj_org , qj_old , &
844 scal_f_old , grad_f , desc_dir , coeff_f , qj_rel , scal_f , &
845 right_term , stpmax , check )
849 qj_rel = qj_rel_nr_old + desc_dir
853 CALL
eval_f( bj , bprimej , qj , qj_old , a_tilde , a_dirk , a_diag , &
854 coeff_f , right_term , scal_f )
858 IF ( verbose_level .GE. 2 )
WRITE(*,*)
'after_lnsrch: scal_f',scal_f
862 IF ( verbose_level .GE. 3 )
THEN
870 IF ( maxval( abs( right_term(:) ) ) < tolf )
THEN
872 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'1: check',check
880 check = ( maxval( abs(grad_f(:)) * max( abs( qj_rel(:) ),1.d0 ) / &
881 max( scal_f , 0.5d0 *
SIZE(qj_rel) ) ) < tolmin )
883 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'2: check',check
888 IF ( maxval( abs( qj_rel(:) - qj_rel_nr_old(:) ) / max( abs( qj_rel(:)) ,&
889 1.d0 ) ) < tolx )
THEN
891 IF ( verbose_level .GE. 3 )
WRITE(*,*)
'check',check
924 SUBROUTINE lnsrch( Bj , Bprimej , qj_rel_NR_old , qj_org , qj_old , &
925 scal_f_old , grad_f , desc_dir , coeff_f , qj_rel , scal_f , right_term ,&
930 REAL*8,
INTENT(IN) :: bj
932 REAL*8,
INTENT(IN) :: bprimej
935 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_rel_nr_old
938 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_org
941 REAL*8,
DIMENSION(:),
INTENT(IN) :: qj_old
944 REAL*8,
DIMENSION(:),
INTENT(IN) :: grad_f
947 REAL*8,
INTENT(IN) :: scal_f_old
950 REAL*8,
DIMENSION(:),
INTENT(INOUT) :: desc_dir
952 REAL*8,
INTENT(IN) :: stpmax
955 REAL*8,
DIMENSION(:),
INTENT(IN) :: coeff_f
958 REAL*8,
DIMENSION(:),
INTENT(OUT) :: qj_rel
961 REAL*8,
INTENT(OUT) :: scal_f
964 REAL*8,
INTENT(OUT) :: right_term(n_eqns)
967 LOGICAL,
INTENT(OUT) :: check
969 REAL*8,
PARAMETER :: tolx=epsilon(qj_rel)
971 INTEGER,
DIMENSION(1) :: ndum
972 REAL*8 :: alf , a,alam,alam2,alamin,b,disc
974 REAL*8 :: desc_dir_abs
975 REAL*8 :: rhs1 , rhs2 , slope, tmplam
977 REAL*8 :: scal_f_min , alam_min
983 IF (
size(grad_f) ==
size(desc_dir) .AND.
size(grad_f) ==
size(qj_rel) .AND. &
984 size(qj_rel) ==
size(qj_rel_nr_old) )
THEN
990 WRITE(*,*)
'nrerror: an assert_eq failed with this tag:',
'lnsrch'
991 stop
'program terminated by assert_eq4'
997 desc_dir_abs = sqrt( dot_product(desc_dir,desc_dir) )
999 IF ( desc_dir_abs > stpmax ) desc_dir(:) = desc_dir(:) * stpmax / desc_dir_abs
1001 slope = dot_product(grad_f,desc_dir)
1003 alamin = tolx / maxval( abs( desc_dir(:)) / max( abs(qj_rel_nr_old(:)),1.d0 ) )
1005 IF ( alamin .EQ. 0.d0)
THEN
1007 qj_rel(:) = qj_rel_nr_old(:)
1015 scal_f_min = scal_f_old
1017 optimal_step_search:
DO
1019 IF ( verbose_level .GE. 4 )
THEN
1021 WRITE(*,*)
'alam',alam
1025 qj_rel = qj_rel_nr_old + alam * desc_dir
1027 qj = qj_rel * qj_org
1029 CALL
eval_f( bj , bprimej , qj , qj_old , a_tilde , a_dirk , a_diag , &
1030 coeff_f , right_term , scal_f )
1032 IF ( verbose_level .GE. 4 )
THEN
1034 WRITE(*,*)
'lnsrch: effe_old,effe',scal_f_old,scal_f
1039 IF ( scal_f .LT. scal_f_min )
THEN
1046 IF ( scal_f .LE. 0.9 * scal_f_old )
THEN
1049 IF ( verbose_level .GE. 4 )
THEN
1051 WRITE(*,*)
'sufficient function decrease'
1055 EXIT optimal_step_search
1057 ELSE IF ( alam < alamin )
THEN
1060 IF ( verbose_level .GE. 4 )
THEN
1062 WRITE(*,*)
' convergence on Delta_x',alam,alamin
1066 qj_rel(:) = qj_rel_nr_old(:)
1070 EXIT optimal_step_search
1075 IF ( alam .EQ. 1.d0 )
THEN
1077 tmplam = - slope / ( 2.0d0 * ( scal_f - scal_f_old - slope ) )
1081 rhs1 = scal_f - scal_f_old - alam*slope
1082 rhs2 = scal_f2 - scal_f_old - alam2*slope
1084 a = ( rhs1/alam**2.d0 - rhs2/alam2**2.d0 ) / ( alam - alam2 )
1085 b = ( -alam2*rhs1/alam**2 + alam*rhs2/alam2**2 ) / ( alam - alam2 )
1087 IF ( a .EQ. 0.d0 )
THEN
1089 tmplam = - slope / ( 2.0d0 * b )
1093 disc = b*b - 3.0d0*a*slope
1095 IF ( disc .LT. 0.d0 )
THEN
1097 tmplam = 0.5d0 * alam
1099 ELSE IF ( b .LE. 0.d0 )
THEN
1101 tmplam = ( - b + sqrt(disc) ) / ( 3.d0 * a )
1105 tmplam = - slope / ( b + sqrt(disc) )
1111 IF ( tmplam .GT. 0.5d0*alam ) tmplam = 0.5d0 * alam
1119 alam = max( tmplam , 0.5d0*alam )
1121 END DO optimal_step_search
1145 SUBROUTINE eval_f( Bj , Bprimej , qj , qj_old , a_tilde , a_dirk , a_diag , &
1146 coeff_f , f_nl , scal_f )
1152 REAL*8,
INTENT(IN) :: bj
1153 REAL*8,
INTENT(IN) :: bprimej
1154 REAL*8,
INTENT(IN) :: qj(n_vars)
1155 REAL*8,
INTENT(IN) :: qj_old(n_vars)
1156 REAL*8,
INTENT(IN) :: a_tilde(n_rk)
1157 REAL*8,
INTENT(IN) :: a_dirk(n_rk)
1158 REAL*8,
INTENT(IN) :: a_diag
1159 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1160 REAL*8,
INTENT(OUT) :: f_nl(n_eqns)
1161 REAL*8,
INTENT(OUT) :: scal_f
1163 REAL*8 :: nh_term_impl(n_eqns)
1164 REAL*8 :: rj(n_eqns)
1167 r_nh_term_impl = nh_term_impl )
1169 rj = ( matmul(fxj,a_tilde) - matmul(nhj,a_dirk) ) - a_diag * nh_term_impl
1171 f_nl = qj - qj_old + dt * rj
1173 f_nl = coeff_f * f_nl
1175 scal_f = 0.5d0 * dot_product( f_nl , f_nl )
1203 REAL*8,
INTENT(IN) :: bj
1204 REAL*8,
INTENT(IN) :: bprimej
1205 REAL*8,
INTENT(IN) :: qj_rel(n_vars)
1206 REAL*8,
INTENT(IN) :: qj_org(n_vars)
1207 REAL*8,
INTENT(IN) :: coeff_f(n_eqns)
1208 REAL*8,
INTENT(OUT) :: left_matrix(n_eqns,n_vars)
1210 REAL*8 :: jacob_relax(n_eqns,n_vars)
1211 COMPLEX*16 :: nh_terms_cmplx_impl(n_eqns)
1212 COMPLEX*16 :: qj_cmplx(n_vars) , qj_rel_cmplx(n_vars)
1218 h = n_vars * epsilon(1.d0)
1222 left_matrix(1:n_eqns,1:n_vars) = 0.d0
1223 jacob_relax(1:n_eqns,1:n_vars) = 0.d0
1229 left_matrix(i,i) = coeff_f(i) * qj_org(i)
1231 IF ( implicit_flag(i) )
THEN
1233 qj_rel_cmplx(1:n_vars) = qj_rel(1:n_vars)
1234 qj_rel_cmplx(i) = dcmplx(qj_rel(i), h)
1236 qj_cmplx = qj_rel_cmplx * qj_org
1239 c_nh_term_impl = nh_terms_cmplx_impl )
1241 jacob_relax(1:n_eqns,i) = coeff_f(i) * &
1242 aimag(nh_terms_cmplx_impl) / h
1244 left_matrix(1:n_eqns,i) = left_matrix(1:n_eqns,i) - dt * a_diag &
1245 * jacob_relax(1:n_eqns,i)
1271 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells)
1272 REAL*8,
INTENT(OUT) :: expl_terms(n_eqns,comp_cells)
1274 REAL*8 :: qc(n_vars)
1275 REAL*8 :: expl_forces_term(n_eqns)
1281 qc = q_expl(1:n_vars,j)
1285 expl_terms(1:n_eqns,j) = expl_forces_term
1311 REAL*8,
INTENT(IN) :: q_expl(n_vars,comp_cells)
1312 REAL*8,
INTENT(OUT) :: f_x(n_eqns,comp_cells)
1314 REAL*8 :: q_old(n_vars,comp_cells)
1324 IF ( reconstr_variables .EQ. 0 )
THEN
1329 ELSEIF ( reconstr_variables .EQ. 0 )
THEN
1345 SELECT CASE ( solver_scheme )
1367 f_x(i,j) = ( h_interface(i,j+1) - h_interface(i,j) ) / dx
1371 h_new = q_expl(1,j) - dt * f_x(1,j) - b_cent(j)
1373 IF ( h_new .LT. 0.d0 )
THEN
1375 WRITE(*,*)
'j,h',j,h_new
1379 WRITE(*,*) b_cent(j+i) , b_prime(j+i) , q_expl(1,j+i) , q_expl(2,j+i)
1383 WRITE(*,*)
'w_interface(j) ',q_interfacel(1,j) , q_interfacer(1,j)
1384 WRITE(*,*)
'w_interface(j+1) ',q_interfacel(1,j+1) , q_interfacer(1,j+1)
1386 WRITE(*,*)
'uh_interface(j) ',q_interfacel(2,j) , q_interfacer(2,j)
1387 WRITE(*,*)
'uh_interface(j+1) ',q_interfacel(2,j+1) , q_interfacer(2,j+1)
1389 WRITE(*,*)
'a(j) ',a_interfacel(1,j) , a_interfacer(1,j)
1390 WRITE(*,*)
'a(j+1) ',a_interfacel(1,j+1) , a_interfacer(1,j+1)
1392 WRITE(*,*)
'H_interface ',h_interface(i,j) , h_interface(i,j+1)
1398 IF ( verbose_level .GE. 1 )
THEN
1400 WRITE(*,*)
'F_x',j,f_x(:,j), h_interface(1,j+1) , h_interface(1,j)
1438 REAL*8 :: fluxl(n_eqns)
1439 REAL*8 :: fluxr(n_eqns)
1441 REAL*8 :: flux_avg(n_eqns)
1443 REAL*8 :: nc_fluxl(n_eqns)
1444 REAL*8 :: nc_fluxr(n_eqns)
1446 REAL*8 :: nc_flux_avg(n_eqns)
1448 REAL*8 :: nc_terml(n_eqns)
1449 REAL*8 :: nc_termr(n_eqns)
1451 REAL*8 :: nc_term_avg(n_eqns)
1456 REAL*8 :: dt_loc , vel_loc
1458 DO j = 1 , comp_interfaces
1460 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacer(1:n_vars,j) , &
1463 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacel(1:n_vars,j) , &
1466 CALL
average_kt( a_interfacel(:,j) , a_interfacer(:,j) , fluxl , fluxr , &
1471 IF ( a_interfacel(i,j) .EQ. a_interfacer(i,j) )
THEN
1473 h_interface(i,j) = 0.d0
1477 h_interface(i,j) = flux_avg(i) &
1478 + ( a_interfacer(i,j) * a_interfacel(i,j) ) &
1479 / ( a_interfacer(i,j) - a_interfacel(i,j) ) &
1480 * ( q_interfacer(i,j) - q_interfacel(i,j) )
1503 REAL*8,
INTENT(IN) :: al(:) , ar(:)
1504 REAL*8,
INTENT(IN) :: wl(:) , wr(:)
1505 REAL*8,
INTENT(OUT) :: w_avg(:)
1514 IF ( al(i) .EQ. ar(i) )
THEN
1521 w_avg(i) = ( ar(i) * wl(i) - al(i) * wr(i) ) / ( ar(i) - al(i) )
1546 REAL*8 :: fluxl(n_eqns)
1547 REAL*8 :: fluxr(n_eqns)
1548 REAL*8 :: flux_lf(n_eqns)
1549 REAL*8 :: flux_lw(n_eqns)
1550 REAL*8 :: q_lw(n_vars)
1562 omega = 1.d0 / ( 1.d0 + cfl_loc )
1564 DO j = 1,comp_interfaces
1566 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacel(1:n_vars,j) , &
1569 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacer(1:n_vars,j) , &
1572 vel_loc = max( abs( a_interfacel(1,j) ) , abs( a_interfacer(1,j) ) )
1574 dt_loc = cfl_loc * dx / vel_loc
1578 flux_lf(i) = 0.5d0 * ( fluxl(i) + fluxr(i) ) - 0.5d0 * dx / &
1579 dt_loc * ( q_interfacer(i,j) - q_interfacel(i,j) )
1581 q_lw(i) = 0.5d0 * ( q_interfacer(i,j) + q_interfacel(i,j) ) &
1582 - 0.5d0 * dt_loc / dx * ( fluxr(i) - fluxl(i) )
1586 CALL
eval_fluxes( b_stag(j) , r_qj = q_lw, r_flux = flux_lw )
1590 h_interface(i,j) = ( 1.d0 - omega ) * flux_lf(i) + omega * flux_lw(i)
1615 REAL*8 :: fluxl(n_eqns)
1616 REAL*8 :: fluxr(n_eqns)
1617 REAL*8 :: flux_lf(n_eqns)
1624 DO j = 1,comp_interfaces
1626 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacel(1:n_eqns,j) , &
1629 CALL
eval_fluxes( b_stag(j) , r_qj = q_interfacer(1:n_eqns,j) , &
1632 vel_loc = max( abs( a_interfacel(1,j) ) , abs( a_interfacer(1,j) ) )
1634 dt_loc = 0.9d0 * dx / vel_loc
1638 flux_lf(i) = 0.5d0 * ( fluxr(i) + fluxl(i) ) - 0.5d0 * dx / &
1639 dt_loc *( q_interfacer(i,j) - q_interfacel(i,j) )
1645 h_interface(i,j) = flux_lf(i)
1671 USE geometry, ONLY : x_comp , x_stag
1676 REAL*8 :: qc(n_vars)
1677 REAL*8 :: qcl(n_vars)
1678 REAL*8 :: qcr(n_vars)
1680 REAL*8 :: qc_stencil(3)
1681 REAL*8 :: x_stencil(3)
1684 REAL*8 :: qp_check(n_vars)
1694 IF ( bcl(i)%flag .EQ. 0 )
THEN
1697 qc_stencil(1) = bcl(i)%value
1698 qc_stencil(2:3) = q(i,1:2)
1700 x_stencil(1) = x_stag(1)
1701 x_stencil(2:3) = x_comp(1:2)
1703 CALL
limit( qc_stencil , x_stencil , limiter(i) , qc_prime )
1705 ELSEIF ( bcl(i)%flag .EQ. 1 )
THEN
1708 qc_prime = bcl(i)%value
1710 ELSEIF ( bcl(i)%flag .EQ. 2 )
THEN
1713 qc_prime = ( q(i,2) - q(i,1) ) / ( x_comp(2) - x_comp(1) )
1719 dxl = x_comp(1) - x_stag(1)
1720 qcl(i) = q(i,1) - reconstr_coeff * dxl * qc_prime
1722 dxr = x_stag(2) - x_comp(1)
1723 qcr(i) = q(i,1) + reconstr_coeff * dxr * qc_prime
1728 IF ( qcr(i) .LT. b_stag(2) )
THEN
1730 qc_prime = ( b_stag(2) - q(i,1) ) / dxr
1732 qcl(i) = q(i,1) - reconstr_coeff * dxl * qc_prime
1734 qcr(i) = q(i,1) + reconstr_coeff * dxr * qc_prime
1738 IF ( qcl(i) .LT. b_stag(1) )
THEN
1740 qc_prime = ( q(i,1) - b_stag(1) ) / dxl
1742 qcl(i) = q(i,1) - reconstr_coeff * dxl * qc_prime
1744 qcr(i) = q(i,1) + reconstr_coeff * dxr * qc_prime
1753 CALL
qc_to_qp( qcl , b_stag(1) , qp_check )
1754 CALL
qp_to_qc( qp_check , b_stag(1) , qcl )
1756 CALL
qc_to_qp( qcr , b_stag(2) , qp_check )
1757 CALL
qp_to_qc( qp_check , b_stag(2) , qcr )
1761 q_interfacer(1:n_vars,1) = qcl
1763 q_interfacel(1:n_vars,2) = qcr
1768 IF ( bcl(i)%flag .EQ. 0 )
THEN
1770 q_interfacer(i,1) = bcl(i)%value
1771 q_interfacel(i,1) = bcl(i)%value
1773 ELSEIF ( bcl(i)%flag .EQ. 1 )
THEN
1775 q_interfacel(i,1) = q_interfacer(i,1)
1779 q_interfacel(i,1) = qcl(i)
1786 DO j = 2,comp_cells-1
1788 x_stencil(1:3) = x_comp(j-1:j+1)
1792 qc_stencil = q(i,j-1:j+1)
1794 CALL
limit( qc_stencil , x_stencil , limiter(i) , qc_prime )
1797 dxl = x_comp(j) - x_stag(j)
1798 qcl(i) = q(i,j) - reconstr_coeff * dxl * qc_prime
1801 dxr = x_stag(j+1) - x_comp(j)
1802 qcr(i) = q(i,j) + reconstr_coeff * dxr * qc_prime
1805 IF ( i .EQ. 1 )
THEN
1807 IF ( qcr(i) .LT. b_stag(j+1) )
THEN
1809 qc_prime = ( b_stag(j+1) - q(i,j) ) / dxr
1811 qcl(i) = q(i,j) - reconstr_coeff * dxl * qc_prime
1813 qcr(i) = q(i,j) + reconstr_coeff * dxr * qc_prime
1817 IF ( qcl(i) .LT. b_stag(j) )
THEN
1819 qc_prime = ( q(i,j) - b_stag(j) ) / dxl
1821 qcl(i) = q(i,j) - reconstr_coeff * dxl * qc_prime
1823 qcr(i) = q(i,j) + reconstr_coeff * dxr * qc_prime
1833 CALL
qc_to_qp( qcl , b_stag(j) , qp_check )
1834 CALL
qp_to_qc( qp_check , b_stag(j) , qcl )
1837 CALL
qc_to_qp( qcr , b_stag(j+1) , qp_check )
1838 CALL
qp_to_qc( qp_check , b_stag(j+1) , qcr )
1841 q_interfacer(:,j) = qcl
1843 q_interfacel(:,j+1) = qcr
1852 IF ( bcr(i)%flag .EQ. 0 )
THEN
1854 qc_stencil(1:2) = q(i,comp_cells-1:comp_cells)
1855 qc_stencil(3) = bcr(i)%value
1857 x_stencil(1:2) = x_comp(comp_cells-1:comp_cells)
1858 x_stencil(3) = x_stag(comp_interfaces)
1860 CALL
limit( qc_stencil , x_stencil , limiter(i) , qc_prime )
1862 ELSEIF ( bcr(i)%flag .EQ. 1 )
THEN
1864 qc_prime = bcr(i)%value
1866 ELSEIF ( bcr(i)%flag .EQ. 2 )
THEN
1868 qc_prime = ( q(i,comp_cells) - q(i,comp_cells-1) ) / &
1869 ( x_comp(comp_cells) - x_comp(comp_cells-1) )
1873 dxl = x_comp(comp_cells) - x_stag(comp_interfaces-1)
1874 qcl(i) = q(i,comp_cells) - reconstr_coeff * dxl * qc_prime
1876 dxr = x_stag(comp_interfaces) - x_comp(comp_cells)
1877 qcr(i) = q(i,comp_cells) + reconstr_coeff * dxr * qc_prime
1882 IF ( qcr(i) .LT. b_stag(comp_interfaces) )
THEN
1884 qc_prime = ( b_stag(comp_interfaces) - q(i,comp_cells) ) / dxr
1886 qcl(i) = q(i,comp_cells) - reconstr_coeff * dxl * qc_prime
1888 qcr(i) = q(i,comp_cells) + reconstr_coeff * dxr * qc_prime
1892 IF ( qcl(i) .LT. b_stag(comp_interfaces-1) )
THEN
1894 qc_prime = ( q(i,comp_cells) - b_stag(comp_cells) ) / dxl
1896 qcl(i) = q(i,comp_cells) - reconstr_coeff * dxl * qc_prime
1898 qcr(i) = q(i,comp_cells) + reconstr_coeff * dxr * qc_prime
1907 CALL
qc_to_qp( qcl , b_stag(comp_cells) , qp_check )
1908 CALL
qp_to_qc( qp_check , b_stag(comp_cells) , qcl )
1910 CALL
qc_to_qp( qcr , b_stag(comp_cells+1) , qp_check )
1911 CALL
qp_to_qc( qp_check , b_stag(comp_cells+1) , qcr )
1913 q_interfacer(:,comp_interfaces-1) = qcl
1914 q_interfacel(:,comp_interfaces) = qcr
1919 IF ( bcr(i)%flag .EQ. 0 )
THEN
1921 q_interfacel(i,comp_interfaces) = bcr(i)%value
1922 q_interfacer(i,comp_interfaces) = bcr(i)%value
1924 ELSEIF ( bcr(i)%flag .EQ. 1 )
THEN
1926 q_interfacer(i,comp_interfaces) = q_interfacel(i,comp_interfaces)
1930 q_interfacer(i,comp_interfaces) = qcr(i)
1958 USE geometry, ONLY : x_comp , x_stag
1963 REAL*8 :: qc(n_vars)
1964 REAL*8 :: qpl(n_vars)
1965 REAL*8 :: qpr(n_vars)
1966 REAL*8 :: qp_bdry(n_vars)
1968 REAL*8 :: qp_stencil(3)
1969 REAL*8 :: x_stencil(3)
1983 CALL
qc_to_qp( qc , b_cent(j) , qp(1:n_vars,j) )
1990 IF ( bcl(i)%flag .EQ. 0 )
THEN
1992 qp_stencil(1) = bcl(i)%value
1993 qp_stencil(2:3) = qp(i,1:2)
1995 x_stencil(1) = x_stag(1)
1996 x_stencil(2:3) = x_comp(1:2)
1998 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2000 ELSEIF ( bcl(i)%flag .EQ. 1 )
THEN
2002 qp_prime = bcl(i)%value
2004 ELSEIF ( bcl(i)%flag .EQ. 2 )
THEN
2006 qp_prime = ( qp(i,2) - qp(i,1) ) / ( x_comp(2) - x_comp(1) )
2012 dxl = x_comp(1) - x_stag(1)
2013 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2015 dxr = x_stag(2) - x_comp(1)
2016 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2021 IF(qpr(i).LT.b_stag(2))
THEN
2023 qp_prime=(b_stag(2)-qp(i,1))/dxr
2025 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2027 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2031 IF(qpl(i).LT.b_stag(1))
THEN
2033 qp_prime=(qp(i,1)-b_stag(1))/dxl
2035 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2037 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2047 IF ( bcl(i)%flag .EQ. 0 )
THEN
2049 qpl(i) = bcl(i)%value
2057 CALL
qp_to_qc( qpl , b_stag(1) , q_interfacer(1:n_vars,1) )
2058 CALL
qp_to_qc( qpr , b_stag(2) , q_interfacel(1:n_vars,2) )
2063 IF ( bcl(i)%flag .EQ. 0 )
THEN
2065 qp_bdry(i) = bcl(i)%value
2074 qp_bdry(i) = -qpl(i)
2086 CALL
qp_to_qc( qp_bdry , b_stag(1) , q_interfacel(:,1) )
2089 DO j = 2,comp_cells-1
2091 x_stencil(1:3) = x_comp(j-1:j+1)
2095 qp_stencil = qp(i,j-1:j+1)
2097 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2099 dxl = x_comp(j) - x_stag(j)
2100 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2102 dxr = x_stag(j+1) - x_comp(j)
2103 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2108 IF(qpr(i).LT.b_stag(j+1))
THEN
2110 qp_prime=(b_stag(j+1)-qp(i,j))/dxr
2112 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2114 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2118 IF(qpl(i).LT.b_stag(j))
THEN
2120 qp_prime=(qp(i,j)-b_stag(j))/dxl
2122 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2124 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2133 CALL
qp_to_qc( qpl , b_stag(j) , q_interfacer(:,j) )
2134 CALL
qp_to_qc( qpr , b_stag(j+1) , q_interfacel(:,j+1) )
2143 IF ( bcr(i)%flag .EQ. 0 )
THEN
2145 qp_stencil(1:2) = qp(i,comp_cells-1:comp_cells)
2146 qp_stencil(3) = bcr(i)%value
2148 x_stencil(1:2) = x_comp(comp_cells-1:comp_cells)
2149 x_stencil(3) = x_stag(comp_interfaces)
2151 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2153 ELSEIF ( bcr(i)%flag .EQ. 1 )
THEN
2155 qp_prime = bcr(i)%value
2157 ELSEIF ( bcr(i)%flag .EQ. 2 )
THEN
2159 qp_prime = ( qp(i,comp_cells) - qp(i,comp_cells-1) ) / &
2160 ( x_comp(comp_cells) - x_comp(comp_cells-1) )
2164 dxl = x_comp(comp_cells) - x_stag(comp_interfaces-1)
2165 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2167 dxr = x_stag(comp_interfaces) - x_comp(comp_cells)
2168 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2173 IF(qpr(i).LT.b_stag(comp_interfaces))
THEN
2175 qp_prime=(b_stag(comp_interfaces)-qp(i,comp_cells))/dxr
2177 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2179 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2183 IF(qpl(i).LT.b_stag(comp_interfaces-1))
THEN
2185 qp_prime=(qp(i,comp_cells)-b_stag(comp_cells))/dxl
2187 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2189 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2199 IF ( bcr(i)%flag .EQ. 0 )
THEN
2201 qpr(i) = bcr(i)%value
2208 CALL
qp_to_qc( qpl , b_stag(comp_interfaces-1) , q_interfacer(:,comp_interfaces-1) )
2209 CALL
qp_to_qc( qpr , b_stag(comp_interfaces) , q_interfacel(:,comp_interfaces) )
2213 IF ( bcr(i)%flag .EQ. 0 )
THEN
2215 qp_bdry(i) = bcr(i)%value
2224 qp_bdry(i) = -qpr(i)
2236 CALL
qp_to_qc( qp_bdry , b_stag(comp_interfaces) , &
2237 q_interfacer(:,comp_interfaces) )
2260 USE geometry, ONLY : x_comp , x_stag
2265 REAL*8 :: qc(n_vars)
2266 REAL*8 :: qpl(n_vars)
2267 REAL*8 :: qpr(n_vars)
2268 REAL*8 :: qp_bdry(n_vars)
2270 REAL*8 :: qp_stencil(3)
2271 REAL*8 :: x_stencil(3)
2285 CALL
qc_to_qp2( qc , b_cent(j) , qp(1:n_vars,j) )
2292 IF ( bcl(i)%flag .EQ. 0 )
THEN
2294 qp_stencil(1) = bcl(i)%value
2295 qp_stencil(2:3) = qp(i,1:2)
2297 x_stencil(1) = x_stag(1)
2298 x_stencil(2:3) = x_comp(1:2)
2300 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2302 ELSEIF ( bcl(i)%flag .EQ. 1 )
THEN
2304 qp_prime = bcl(i)%value
2306 ELSEIF ( bcl(i)%flag .EQ. 2 )
THEN
2308 qp_prime = ( qp(i,2) - qp(i,1) ) / ( x_comp(2) - x_comp(1) )
2314 dxl = x_comp(1) - x_stag(1)
2315 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2317 dxr = x_stag(2) - x_comp(1)
2318 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2321 IF ( i .EQ. 1 )
THEN
2323 IF ( qpr(i) .LT. 0.d0 )
THEN
2325 qp_prime = - qp(i,1) / dxr
2327 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2329 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2333 IF ( qpl(i) .LT. 0.d0 )
THEN
2335 qp_prime = qp(i,1) / dxl
2337 qpl(i) = qp(i,1) - reconstr_coeff * dxl * qp_prime
2339 qpr(i) = qp(i,1) + reconstr_coeff * dxr * qp_prime
2349 IF ( bcl(i)%flag .EQ. 0 )
THEN
2351 qpl(i) = bcl(i)%value
2359 CALL
qp2_to_qc( qpl , b_stag(1) , q_interfacer(1:n_vars,1) )
2360 CALL
qp2_to_qc( qpr , b_stag(2) , q_interfacel(1:n_vars,2) )
2365 IF ( bcl(i)%flag .EQ. 0 )
THEN
2367 qp_bdry(i) = bcl(i)%value
2376 qp_bdry(i) = -qpl(i)
2388 CALL
qp2_to_qc( qp_bdry , b_stag(1) , q_interfacel(:,1) )
2391 DO j = 2,comp_cells-1
2393 x_stencil(1:3) = x_comp(j-1:j+1)
2397 qp_stencil = qp(i,j-1:j+1)
2399 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2401 dxl = x_comp(j) - x_stag(j)
2402 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2404 dxr = x_stag(j+1) - x_comp(j)
2405 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2408 IF ( i .EQ. 1 )
THEN
2410 IF ( qpr(i) .LT. 0.d0 )
THEN
2412 qp_prime = - qp(i,j) / dxr
2414 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2416 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2420 IF ( qpl(i) .LT. 0.d0 )
THEN
2422 qp_prime = qp(i,j) / dxl
2424 qpl(i) = qp(i,j) - reconstr_coeff * dxl * qp_prime
2426 qpr(i) = qp(i,j) + reconstr_coeff * dxr * qp_prime
2435 CALL
qp2_to_qc( qpl , b_stag(j) , q_interfacer(:,j) )
2436 CALL
qp2_to_qc( qpr , b_stag(j+1) , q_interfacel(:,j+1) )
2445 IF ( bcr(i)%flag .EQ. 0 )
THEN
2447 qp_stencil(1:2) = qp(i,comp_cells-1:comp_cells)
2448 qp_stencil(3) = bcr(i)%value
2450 x_stencil(1:2) = x_comp(comp_cells-1:comp_cells)
2451 x_stencil(3) = x_stag(comp_interfaces)
2453 CALL
limit( qp_stencil , x_stencil , limiter(i) , qp_prime )
2455 ELSEIF ( bcr(i)%flag .EQ. 1 )
THEN
2457 qp_prime = bcr(i)%value
2459 ELSEIF ( bcr(i)%flag .EQ. 2 )
THEN
2461 qp_prime = ( qp(i,comp_cells) - qp(i,comp_cells-1) ) / &
2462 ( x_comp(comp_cells) - x_comp(comp_cells-1) )
2466 dxl = x_comp(comp_cells) - x_stag(comp_interfaces-1)
2467 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2469 dxr = x_stag(comp_interfaces) - x_comp(comp_cells)
2470 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2473 IF ( i .EQ. 1 )
THEN
2475 IF ( qpr(i) .LT. 0.d0 )
THEN
2477 qp_prime = - qp(i,comp_cells) / dxr
2479 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2481 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2485 IF ( qpl(i) .LT. 0.d0 )
THEN
2487 qp_prime = qp(i,comp_cells) / dxl
2489 qpl(i) = qp(i,comp_cells) - reconstr_coeff * dxl * qp_prime
2491 qpr(i) = qp(i,comp_cells) + reconstr_coeff * dxr * qp_prime
2501 IF ( bcr(i)%flag .EQ. 0 )
THEN
2503 qpr(i) = bcr(i)%value
2510 CALL
qp2_to_qc( qpl , b_stag(comp_interfaces-1) , q_interfacer(:,comp_interfaces-1) )
2511 CALL
qp2_to_qc( qpr , b_stag(comp_interfaces) , q_interfacel(:,comp_interfaces) )
2515 IF ( bcr(i)%flag .EQ. 0 )
THEN
2517 qp_bdry(i) = bcr(i)%value
2526 qp_bdry(i) = -qpr(i)
2538 CALL
qp2_to_qc( qp_bdry , b_stag(comp_interfaces) , &
2539 q_interfacer(:,comp_interfaces) )
2560 REAL*8 :: abslambdal_min(n_vars) , abslambdal_max(n_vars)
2561 REAL*8 :: abslambdar_min(n_vars) , abslambdar_max(n_vars)
2562 REAL*8 :: min_r(n_vars) , max_r(n_vars)
2566 DO j = 1 , comp_interfaces
2573 min_r = min(abslambdal_min , abslambdar_min , 0.0d0)
2574 max_r = max(abslambdal_max , abslambdar_max , 0.0d0)
2576 a_interfacel(:,j) = min_r
2577 a_interfacer(:,j) = max_r
2603 SUBROUTINE limit( v , z , limiter , slope_lim )
2609 REAL*8,
INTENT(IN) :: v(3)
2610 REAL*8,
INTENT(IN) :: z(3)
2611 INTEGER,
INTENT(IN) :: limiter
2613 REAL*8,
INTENT(OUT) :: slope_lim
2617 REAL*8 :: sigma1 , sigma2
2619 a = ( v(3) - v(2) ) / ( z(3) - z(2) )
2620 b = ( v(2) - v(1) ) / ( z(2) - z(1) )
2621 c = ( v(3) - v(1) ) / ( z(3) - z(1) )
2623 SELECT CASE (limiter)
2639 sigma1 =
minmod( a , 2.d0*b )
2640 sigma2 =
minmod( 2.d0*a , b )
2641 slope_lim =
maxmod( sigma1 , sigma2 )
2651 END SUBROUTINE limit
2658 REAL*8 :: a , b , sa , sb
2660 IF ( a*b .LE. 0.d0 )
THEN
2669 minmod = 0.5 * ( sa+sb ) * min( abs(a) , abs(b) )
2679 REAL*8 :: a , b , sa , sb
2681 IF ( a*b .EQ. 0.d0 )
THEN
2690 maxmod = 0.5 * ( sa+sb ) * max( abs(a) , abs(b) )
subroutine imex_rk_solver
Runge-Kutta integration.
subroutine qc_to_qp2(qc, B, qp)
Conservative to 2nd set of physical variables.
subroutine timestep
Time-step computation.
subroutine eval_explicit_forces(Bj, Bprimej, qj, expl_forces_term)
Explicit Forces term.
subroutine eval_f(Bj, Bprimej, qj, qj_old, a_tilde, a_dirk, a_diag, coeff_f, f_nl, scal_f)
Evaluate the nonlinear system.
subroutine eval_flux_kt
Semidiscrete numerical fluxes.
subroutine reconstruction_phys2
Linear reconstruction.
subroutine eval_hyperbolic_terms(q_expl, F_x)
Semidiscrete finite volume central scheme.
subroutine solve_rk_step(Bj, Bprimej, qj, qj_old, a_tilde, a_dirk, a_diag)
Runge-Kutta single step integration.
subroutine qp2_to_qc(qp, B, qc)
From 2nd set of physical to conservative variables.
subroutine eval_flux_lxf
Numerical fluxes Lax-Friedrichs.
subroutine deallocate_solver_variables
Memory deallocation.
subroutine qp_to_qc(qp, B, qc)
Physical to conservative variables.
subroutine eval_fluxes(Bj, c_qj, r_qj, c_flux, r_flux)
Hyperbolic Fluxes.
subroutine limit(v, z, limiter, slope_lim)
Slope limiter.
subroutine allocate_solver_variables
Memory allocation.
subroutine lnsrch(Bj, Bprimej, 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)
Search the descent stepsize.
subroutine qc_to_qp(qc, B, qp)
Conservative to physical variables.
subroutine reconstruction_phys1
Linear reconstruction.
subroutine reconstruction_cons
Linear reconstruction.
real *8 function maxmod(a, b)
subroutine eval_jacobian(Bj, Bprimej, qj_rel, qj_org, coeff_f, left_matrix)
Evaluate the jacobian.
subroutine eval_explicit_terms(q_expl, expl_terms)
Evaluate the explicit terms.
subroutine average_kt(aL, aR, wL, wR, w_avg)
subroutine eval_speeds
Characteristic speeds.
subroutine eval_flux_gforce
Numerical fluxes GFORCE.
subroutine eval_local_speeds2(qj, Bj, vel_min, vel_max)
Local Characteristic speeds.
real *8 function minmod(a, b)
subroutine eval_nonhyperbolic_terms(Bj, Bprimej, c_qj, c_nh_term_impl, r_qj, r_nh_term_impl)
Non-Hyperbolic terms.
subroutine eval_local_speeds(qj, Bj, vel_min, vel_max)
Local Characteristic speeds.