26 REAL*8,
ALLOCATABLE ::
b_ver(:,:)
200 IF ( verbose_level .GE. 1 )
WRITE(*,*)
'eps_sing = ',
eps_sing 299 pi_g = 4.d0 * datan(1.d0)
314 REAL*8 :: total_source
317 WRITE(*,*)
'dx,dy',
dx,
dy 444 REAL*8,
INTENT(IN),
DIMENSION(:) :: x1, f1
445 REAL*8,
INTENT(IN) :: x2
446 REAL*8,
INTENT(OUT) :: f2
448 REAL*8 :: grad , rel_pos
458 search:
DO n = 1, n1x-1
460 rel_pos = ( x2 - x1(n) ) / ( x1(n+1) - x1(n) )
462 IF ( ( rel_pos .GE. 0.d0 ) .AND. ( rel_pos .LE. 1.d0 ) )
THEN 464 grad = ( f1(n+1)-f1(n) ) / ( x1(n+1)-x1(n) )
465 f2 = f1(n) + ( x2-x1(n) ) * grad
469 ELSEIF ( rel_pos .LT. 0.d0 )
THEN 503 REAL*8,
INTENT(IN),
DIMENSION(:,:) :: x1, y1, f1
504 REAL*8,
INTENT(IN) :: x2, y2
505 REAL*8,
INTENT(OUT) :: f2
508 REAL*8 :: alfa_x , alfa_y
510 IF (
size(x1,1) .GT. 1 )
THEN 512 ix = floor( ( x2 - x1(1,1) ) / ( x1(2,1) - x1(1,1) ) ) + 1
513 ix = min( ix ,
SIZE(x1,1)-1 )
514 alfa_x = ( x1(ix+1,1) - x2 ) / ( x1(ix+1,1) - x1(ix,1) )
523 IF (
size(x1,2) .GT. 1 )
THEN 525 iy = floor( ( y2 - y1(1,1) ) / ( y1(1,2) - y1(1,1) ) ) + 1
526 iy = min( iy ,
SIZE(x1,2)-1 )
527 alfa_y = ( y1(1,iy+1) - y2 ) / ( y1(1,iy+1) - y1(1,iy) )
536 IF (
size(x1,1) .EQ. 1 )
THEN 538 f2 = alfa_y * f1(ix,iy) + ( 1.d0 - alfa_y ) * f1(ix,iy+1)
540 ELSEIF (
size(x1,2) .EQ. 1 )
THEN 542 f2 = alfa_x * f1(ix,iy) + ( 1.d0 - alfa_x ) * f1(ix+1,iy)
546 f2 = alfa_x * ( alfa_y * f1(ix,iy) + ( 1.d0 - alfa_y ) * f1(ix,iy+1) ) &
547 + ( 1.d0 - alfa_x ) * ( alfa_y * f1(ix+1,iy) + ( 1.d0 - alfa_y ) &
572 REAL*8,
INTENT(IN),
DIMENSION(:) :: x1, y1
573 REAL*8,
INTENT(IN),
DIMENSION(:,:) :: f1
574 REAL*8,
INTENT(IN) :: x2, y2
575 REAL*8,
INTENT(OUT) :: f2
578 REAL*8 :: alfa_x , alfa_y
580 IF (
size(x1) .GT. 1 )
THEN 582 ix = floor( ( x2 - x1(1) ) / ( x1(2) - x1(1) ) ) + 1
583 ix = max(0,min( ix ,
SIZE(x1)-1 ))
584 alfa_x = ( x1(ix+1) - x2 ) / ( x1(ix+1) - x1(ix) )
593 IF (
size(y1) .GT. 1 )
THEN 595 iy = floor( ( y2 - y1(1) ) / ( y1(2) - y1(1) ) ) + 1
596 iy = max(1,min( iy ,
SIZE(y1)-1 ))
597 alfa_y = ( y1(iy+1) - y2 ) / ( y1(iy+1) - y1(iy) )
606 IF ( ( alfa_x .LT. 0.d0 ) .OR. ( alfa_x .GT. 1.d0 ) &
607 .OR. ( alfa_y .LT. 0.d0 ) .OR. ( alfa_y .GT. 1.d0 ) )
THEN 615 IF (
size(x1) .EQ. 1 )
THEN 617 f2 = alfa_y * f1(ix,iy) + ( 1.d0 - alfa_y ) * f1(ix,iy+1)
619 ELSEIF (
size(y1) .EQ. 1 )
THEN 621 f2 = alfa_x * f1(ix,iy) + ( 1.d0 - alfa_x ) * f1(ix+1,iy)
625 f2 = alfa_x * ( alfa_y * f1(ix,iy) + ( 1.d0 - alfa_y ) * f1(ix,iy+1) ) &
626 + ( 1.d0 - alfa_x ) * ( alfa_y * f1(ix+1,iy) + ( 1.d0 - alfa_y ) &
653 REAL*8,
INTENT(IN),
DIMENSION(:,:) :: x1, y1, f1
654 REAL*8,
INTENT(IN) :: x2, y2
655 REAL*8,
INTENT(OUT) :: f_x , f_y
658 REAL*8 :: alfa_x , alfa_y
659 REAL*8 :: f_x1 , f_x2 , f_y1 , f_y2
662 IF (
size(x1,1) .GT. 1 )
THEN 664 ix = floor( ( x2 - x1(1,1) ) / ( x1(2,1) - x1(1,1) ) ) + 1
665 ix = min( ix ,
SIZE(x1,1)-1 )
666 alfa_x = ( x1(ix+1,1) - x2 ) / ( x1(ix+1,1) - x1(ix,1) )
675 IF (
size(x1,2) .GT. 1 )
THEN 677 iy = floor( ( y2 - y1(1,1) ) / ( y1(1,2) - y1(1,1) ) ) + 1
678 iy = min( iy ,
SIZE(x1,2)-1 )
679 alfa_y = ( y1(1,iy+1) - y2 ) / ( y1(1,iy+1) - y1(1,iy) )
691 IF (
size(x1,1) .GT. 1 )
THEN 693 f_x1 = ( f1(ix+1,iy) - f1(ix,iy) ) / ( x1(2,1) - x1(1,1) )
695 IF (
size(x1,2) .GT. 1 )
THEN 697 f_x2 = ( f1(ix+1,iy+1) - f1(ix,iy+1) ) / ( x1(2,1) - x1(1,1) )
703 f_x = alfa_y * f_x1 + ( 1.d0 - alfa_y ) * f_x2
708 IF (
size(x1,2) .GT. 1 )
THEN 710 f_y1 = ( f1(ix,iy+1) - f1(ix,iy) ) / ( y1(1,2) - y1(1,1) )
712 IF (
size(x1,1) .GT. 1 )
THEN 714 f_y2 = ( f1(ix+1,iy+1) - f1(ix+1,iy) ) / ( y1(1,2) - y1(1,1) )
720 f_y = alfa_x * f_y1 + ( 1.d0 - alfa_x ) * f_y2
742 REAL*8 :: B_stencil(3)
743 REAL*8 :: x_stencil(3)
744 REAL*8 :: y_stencil(3)
761 check_x_boundary:
IF (j.EQ.1)
THEN 766 x_stencil(2:3) =
x_comp(1:2)
769 b_stencil(2:3) =
b_cent(1:2,k)
788 x_stencil(1:3) =
x_comp(j-1:j+1)
789 b_stencil =
b_cent(j-1:j+1,k)
793 ENDIF check_x_boundary
799 END IF check_comp_cells_x
804 check_y_boundary:
IF (k.EQ.1)
THEN 808 y_stencil(2:3) =
y_comp(1:2)
811 b_stencil(2:3) =
b_cent(j,1:2)
829 y_stencil(1:3) =
y_comp(k-1:k+1)
830 b_stencil =
b_cent(j,k-1:k+1)
834 ENDIF check_y_boundary
840 ENDIF check_comp_cells_y
881 SUBROUTINE regrid_scalar(xin, yin, fin, xl, xr , yl, yr, fout)
884 REAL*8,
INTENT(IN),
DIMENSION(:) :: xin, yin
885 REAL*8,
INTENT(IN),
DIMENSION(:,:) :: fin
886 REAL*8,
INTENT(IN) :: xl, xr , yl , yr
887 REAL*8,
INTENT(OUT) :: fout
890 INTEGER :: ix1 , ix2 , iy1 , iy2
891 REAL*8 :: alfa_x , alfa_y
892 REAL*8 :: dXin , dYin
899 dxin = xin(2) - xin(1)
900 dyin = yin(2) - yin(1)
902 ix1 = max(1,ceiling( ( xl - xin(1) ) / dxin ))
903 ix2 = min(nxin,ceiling( ( xr -xin(1) ) / dxin )+1)
905 iy1 = max(1,ceiling( ( yl - yin(1) ) / dyin ))
906 iy2 = min(nyin,ceiling( ( yr - yin(1) ) / dyin ) + 1)
912 alfa_x = ( min(xr,xin(ix+1)) - max(xl,xin(ix)) ) / ( xr - xl )
916 alfa_y = ( min(yr,yin(iy+1)) - max(yl,yin(iy)) ) / ( yr - yl )
918 fout = fout + alfa_x * alfa_y * fin(ix,iy)
945 SUBROUTINE limit( v , z , limiter , slope_lim )
951 REAL*8,
INTENT(IN) :: v(3)
952 REAL*8,
INTENT(IN) :: z(3)
953 INTEGER,
INTENT(IN) :: limiter
955 REAL*8,
INTENT(OUT) :: slope_lim
959 REAL*8 :: sigma1 , sigma2
961 a = ( v(3) - v(2) ) / ( z(3) - z(2) )
962 b = ( v(2) - v(1) ) / ( z(2) - z(1) )
963 c = ( v(3) - v(1) ) / ( z(3) - z(1) )
965 SELECT CASE (limiter)
979 sigma1 =
minmod( a , 2.d0*b )
980 sigma2 =
minmod( 2.d0*a , b )
981 slope_lim =
maxmod( sigma1 , sigma2 )
1010 END SUBROUTINE limit 1013 REAL*8 FUNCTION minmod(a,b)
1017 REAL*8 :: a , b , sa , sb
1019 IF ( a*b .EQ. 0.d0 )
THEN 1028 minmod = 0.5d0 * ( sa+sb ) * min( abs(a) , abs(b) )
1034 REAL*8 function maxmod(a,b)
1038 REAL*8 :: a , b , sa , sb
1040 IF ( a*b .EQ. 0.d0 )
THEN 1049 maxmod = 0.5d0 * ( sa+sb ) * max( abs(a) , abs(b) )
1059 REAL*8,
INTENT(IN) :: xs,ys,rs
1063 REAL*8,
ALLOCATABLE :: x_subgrid(:) , y_subgrid(:)
1065 INTEGER,
ALLOCATABLE :: check_subgrid(:)
1067 INTEGER n_points , n_points2
1069 REAL*8 :: source_area
1074 n_points2 = n_points**2
1076 ALLOCATE( x_subgrid(n_points2) )
1077 ALLOCATE( y_subgrid(n_points2) )
1078 ALLOCATE( check_subgrid(n_points2) )
1085 x_subgrid(h:n_points2:n_points) = dble(h)
1086 y_subgrid((h-1)*n_points+1:h*n_points) = dble(h)
1090 x_subgrid = ( 2.d0 * x_subgrid - 1.d0 ) / ( 2.d0 * dble(n_points) )
1091 y_subgrid = ( 2.d0 * y_subgrid - 1.d0 ) / ( 2.d0 * dble(n_points) )
1093 x_subgrid = ( x_subgrid - 0.5d0 ) *
dx 1094 y_subgrid = ( y_subgrid - 0.5d0 ) *
dy 1100 IF ( (
x_stag(j+1) .LT. ( xs - rs ) ) .OR. &
1101 (
x_stag(j) .GT. ( xs + rs ) ) .OR. &
1102 (
y_stag(k+1) .LT. ( ys - rs ) ) .OR. &
1103 (
y_stag(k) .GT. ( ys + rs ) ) )
THEN 1105 cell_fract(j,k) = 0.d0
1111 WHERE ( (
x_comp(j) + x_subgrid - xs )**2 &
1112 + (
y_comp(k) + y_subgrid - ys )**2 < rs**2 )
1118 cell_fract(j,k) =
REAL(sum(check_subgrid))/n_points2
1126 source_area =
dx*
dy*sum(cell_fract)
1128 WRITE(*,*)
'Source area =',source_area,
' Error =',abs( 1.d0 - &
1129 dx*
dy*sum(cell_fract) / ( 4.d0*atan(1.d0)*rs**2 ) )
1131 DEALLOCATE( x_subgrid )
1132 DEALLOCATE( y_subgrid )
1133 DEALLOCATE( check_subgrid )
real *8, dimension(:,:), allocatable b_prime_x
Topography slope (x direction) at the centers of the control volumes.
real *8, dimension(:,:), allocatable b_interfacel
Reconstructed value at the left of the x-interface.
real *8 dy
Control volumes size.
real *8, dimension(:), allocatable x_comp
Location of the centers (x) of the control volume of the domain.
real *8 y0
Bottom of the physical domain.
subroutine topography_reconstruction
Linear reconstruction.
real *8, dimension(:,:), allocatable b_cent
Topography at the centers of the control volumes.
integer comp_cells_x
Number of control volumes x in the comp. domain.
real *8, dimension(:,:), allocatable sourcen_vect_y
real *8, dimension(:,:), allocatable grav_surf
gravity vector wrt surface coordinates for each cell
real *8, dimension(:,:), allocatable sourcee_vect_x
real *8, dimension(:), allocatable y_comp
Location of the centers (y) of the control volume of the domain.
integer n_topography_profile_y
real *8 dx
Control volumes size.
integer comp_cells_y
Number of control volumes y in the comp. domain.
logical, dimension(:,:), allocatable sourcee
logical, dimension(:,:), allocatable sourcew
real *8, dimension(:,:), allocatable curv_xy
curvature wrt mixed directions for each cell
real *8, dimension(:,:), allocatable sourcew_vect_y
real *8, dimension(:,:), allocatable b_interfacer
Reconstructed value at the right of the x-interface.
real *8 function minmod(a, b)
subroutine regrid_scalar(xin, yin, fin, xl, xr, yl, yr, fout)
Scalar regrid (2D)
integer n_topography_profile_x
real *8, dimension(:,:), allocatable sourcew_vect_x
real *8, dimension(:,:), allocatable b_interfaceb
Reconstructed value at the bottom of the y-interface.
integer comp_interfaces_y
Number of interfaces (comp_cells_y+1)
real *8 xn
Right of the physical domain.
subroutine init_grid
Finite volume grid initialization.
real *8, dimension(:,:), allocatable dist_sources
real *8, dimension(:,:), allocatable dist_sourcee
subroutine limit(v, z, limiter, slope_lim)
Slope limiter.
real *8 yn
Top of the physical domain.
real *8 x0
Left of the physical domain.
real *8, dimension(:,:), allocatable sourcee_vect_y
real *8, dimension(:,:), allocatable sources_vect_y
subroutine interp_2d_slope(x1, y1, f1, x2, y2, f_x, f_y)
Scalar interpolation (2D)
real *8, dimension(:,:), allocatable b_ver
Topography at the vertices of the control volumes.
real *8, dimension(:,:), allocatable grid_output
Solution in ascii grid format (ESRI)
real *8, dimension(:,:), allocatable sourcen_vect_x
integer, dimension(:,:), allocatable source_cell
real *8, dimension(:,:), allocatable dist_sourcew
real *8 theta
Van Leer limiter parameter.
real *8, dimension(:,:,:), allocatable topography_profile
real *8, dimension(:,:), allocatable b_prime_y
Topography slope (y direction) at the centers of the control volumes.
subroutine compute_cell_fract(xs, ys, rs, cell_fract)
real *8, dimension(:), allocatable x_stag
Location of the boundaries (x) of the control volumes of the domain.
real *8, dimension(:,:), allocatable sources_vect_x
subroutine interp_2d_scalarb(x1, y1, f1, x2, y2, f2)
Scalar interpolation (2D)
subroutine interp_2d_scalar(x1, y1, f1, x2, y2, f2)
Scalar interpolation (2D)
real *8, dimension(:,:), allocatable b_interfacet
Reconstructed value at the top of the y-interface.
logical, dimension(:,:), allocatable sourcen
real *8 dx2
Half x Control volumes size.
real *8, dimension(:,:,:), allocatable deposit
deposit for the different classes
real *8, dimension(:,:), allocatable dist_sourcen
integer comp_interfaces_x
Number of interfaces (comp_cells_x+1)
real *8 eps_sing
parameter for desingularization
real *8, dimension(:), allocatable y_stag
Location of the boundaries (x) of the control volumes of the domain.
subroutine interp_1d_scalar(x1, f1, x2, f2)
Scalar interpolation.
real *8 dy2
Half y Control volumes size.
real *8 function maxmod(a, b)
logical, dimension(:,:), allocatable sources