This repository has been archived by the owner on Jan 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathadd_dpdt.f
82 lines (71 loc) · 2.09 KB
/
add_dpdt.f
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
75
76
77
78
79
80
81
82
subroutine add_dpdt(scal,pthermo,divu,umac,dx,dt,lo,hi,bc)
implicit none
include 'spec.h'
real*8 scal(-2:nfine+1,nscal)
real*8 pthermo(-2:nfine+1)
real*8 divu( 0:nfine-1) ! divu normally has a ghost cell; be careful when passing in
real*8 umac(0 :nfine )
real*8 dx
real*8 dt
integer lo,hi,bc(2)
real*8 uadv,p_lo,p_hi
real*8 ugradp
real*8 dpdt
integer i
do i=lo,hi
uadv = 0.5d0 * (umac(i) + umac(i+1))
if (umac(i) .ge. 0.d0) then
p_lo = pthermo(i-1)
else
p_lo = pthermo(i)
endif
if (umac(i+1) .ge. 0.d0) then
p_hi = pthermo(i)
else
p_hi = pthermo(i+1)
endif
ugradp = uadv * (p_hi - p_lo) / dx
dpdt = (pthermo(i) - Pcgs) / dt
! dpdt = dpdt - ugradp
divu(i) = divu(i) + dpdt*dpdt_factor/pthermo(i)
end do
end
subroutine add_dpdt_nodal(scal,pthermo,divu,vel,dx,dt,lo,hi,bc)
implicit none
include 'spec.h'
real*8 scal(-2:nfine+1,nscal)
real*8 pthermo(-2:nfine+1)
real*8 divu(0:nfine-1)
real*8 vel(-2:nfine+1)
real*8 dx
real*8 dt
integer lo,hi,bc(2)
real*8 uadv,p_lo,p_hi
real*8 ugradp
real*8 dpdt
integer i
do i=lo,hi
uadv = vel(i)
if (i .eq. lo .and. bc(1) .eq. 1) then
! inflow
p_lo = pthermo(i)
p_hi = pthermo(i+1)
else if (i .eq. hi .and. bc(2) .eq. 2) then
! outflow
p_lo = pthermo(i-1)
p_hi = pthermo(i)
else
if (uadv .ge. 0) then
p_lo = pthermo(i-1)
p_hi = pthermo(i)
else
p_lo = pthermo(i)
p_hi = pthermo(i+1)
end if
end if
ugradp = uadv * (p_hi - p_lo) / dx
dpdt = (pthermo(i) - Pcgs) / dt
! dpdt = dpdt - ugradp
divu(i) = divu(i) + dpdt*dpdt_factor/pthermo(i)
end do
end