-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathh2dpr.f95
65 lines (51 loc) · 1.33 KB
/
h2dpr.f95
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
! 2D Heat Equation Using Peaceman-Rachford
!
! Dale Roberts <dale.o.roberts@gmail.com>
!
program h2dpr
implicit none
! External Functions
external sgtsv
! X Space Parameters
integer, parameter :: nJ = 40
real, parameter :: mX = 0
real, parameter :: pX = 1
! Y Space Parameters
integer, parameter :: nK = 40
real, parameter :: mY = 0
real, parameter :: pY = 1
! T Space Parameters
integer, parameter :: nT = 20
real, parameter :: mT = 0
real, parameter :: pT = 0.4
! Variables
integer :: t, s, r, info, fd
real :: U((nJ+1)*(nK+1)), b((nJ+1)*(nK+1))
real :: dl((nJ+1)*(nK+1)-1), dc((nJ+1)*(nK+1)), du((nJ+1)*(nK+1)-1)
real :: x, y, dx, dy, dt, mux, muy
dx = (pX-mX) / real(nJ)
dy = (pY-mY) / real(nK)
dt = (pT-mT) / real(nT)
mux = dt / (dx**2)
muy = dt / (dy**2)
! Set Initial Data
do s = 1, (nJ+1)
do r = 1, (nK+1)
x = mX + (s-1)*dx
y = mY + (r-1)*dy
U((s-1)*(nJ+1)+r) = max(0, 1.0/3.0 - sqrt((x-0.5)**2 + (y-0.5)**2))
end do
end do
! EXERCISE
! Output Data in Gnuplot format
open(fd, FILE='data.0', STATUS='NEW')
do s = 1, (nJ+1)
x = mX + (s-1)*dx
do r = 1, (nK+1)
y = mY + (r-1)*dy
write (fd, *) x, y, U((s-1)*(nJ+1)+r)
end do
write (fd, *) ''
end do
close(fd)
end program h2dpr