-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathupdate.f90
74 lines (51 loc) · 1.87 KB
/
update.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
66
67
68
69
70
71
72
73
74
module update_module
use datatypes_module
use grid_module
use variables_module
use params_module
implicit none
private
public :: update
contains
subroutine update(U, g, fluxes, godunov_state, dt)
type(gridvar_t), intent(inout) :: U, g
type(gridedgevar_t), intent(inout) :: fluxes
type(gridedgevar_t), intent(in ) :: godunov_state
real (kind=dp_t), intent(in ) :: dt
type(gridvar_t) :: Uold
real (kind=dp_t) :: avisco, divU
integer :: i
! store the old state
call build(Uold, U%grid, U%nvar)
do i = U%grid%lo, U%grid%hi
Uold%data(i,:) = U%data(i,:)
enddo
! artifical viscosity
do i = U%grid%lo, U%grid%hi+1
divU = (U%data(i,iumomx) / U%data(i,iudens) - &
U%data(i-1,iumomx) / U%data(i-1,iudens))
avisco = cvisc*max(-divU, ZERO)
fluxes%data(i,:) = fluxes%data(i,:) + avisco*(U%data(i-1,:) - U%data(i,:))
enddo
! this is (A_l F_l - A_r F_r)/dV + any gradient terms
do i = U%grid%lo, U%grid%hi
U%data(i,:) = U%data(i,:) + &
(dt/U%grid%dV(i))*(U%grid%Al(i) *fluxes%data(i, :) - &
U%grid%Al(i+1)*fluxes%data(i+1,:))
if (U%grid%geometry == 1) then
U%data(i,iumomx) = U%data(i,iumomx) - &
(dt/U%grid%dx)*(godunov_state%data(i+1,iqpres) - &
godunov_state%data(i ,iqpres))
endif
enddo
! time-centered source terms (note: gravity is NOT currently time-centered)
do i = U%grid%lo, U%grid%hi
U%data(i,iumomx) = U%data(i,iumomx) + &
0.5_dp_t*dt*(U%data(i,iudens) + Uold%data(i,iudens))*g%data(i,1)
U%data(i,iuener) = U%data(i,iuener) + &
0.5_dp_t*dt*(U%data(i,iumomx) + Uold%data(i,iumomx))*g%data(i,1)
enddo
! clean-up
call destroy(Uold)
end subroutine update
end module update_module