forked from ShawnHoose/planet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
sponge_2d.f90
65 lines (45 loc) · 2.05 KB
/
sponge_2d.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
module sponge_module
implicit none
contains
subroutine sponge(uout,uout_l1,uout_l2,&
uout_h1,uout_h2,lo,hi,t,dt, &
dx,dy,domlo,domhi, &
E_added,xmom_added,ymom_added)
use bl_constants_module, only : M_PI
use meth_params_module , only : NVAR, URHO, UMX, UMY, UEDEN
implicit none
integer :: lo(2), hi(2), domlo(2), domhi(2)
integer :: uout_l1,uout_l2,uout_h1,uout_h2
double precision :: uout(uout_l1:uout_h1,uout_l2:uout_h2,NVAR)
double precision :: t,dt
double precision :: dx,dy
integer :: i,j
double precision :: rho, ke_old, ke_new, fac
double precision :: sponge_mult, sponge_center_density, sponge_start_factor, sponge_kappa
double precision :: sponge_start_density
double precision :: E_added,xmom_added,ymom_added
sponge_center_density = 2.d-7
sponge_start_factor = 2.0d0
sponge_kappa = 1000.d0
sponge_start_density = sponge_center_density * sponge_start_factor
do j = lo(2),hi(2)
do i = lo(1),hi(1)
rho = uout(i,j,URHO)
if (rho <= sponge_start_density) then
if (rho < sponge_center_density/sponge_start_factor) then
fac = 1.d0
else
fac = 0.5d0*(1.d0 - cos(M_PI*(sponge_start_density - rho)/ &
(sponge_start_density - sponge_center_density/sponge_start_factor)))
endif
sponge_mult = 1.d0 / (1.d0 + fac * sponge_kappa * dt)
ke_old = 0.5d0 * (uout(i,j,UMX)**2 + uout(i,j,UMY)**2) / rho
uout(i,j,UMX) = uout(i,j,UMX) * sponge_mult
uout(i,j,UMY) = uout(i,j,UMY) * sponge_mult
ke_new = 0.5d0 * (uout(i,j,UMX)**2 + uout(i,j,UMY)**2) / rho
uout(i,j,UEDEN) = uout(i,j,UEDEN) + (ke_new-ke_old)
endif
enddo
enddo
end subroutine sponge
end module sponge_module