-
Notifications
You must be signed in to change notification settings - Fork 10
/
matgen_cavity.f90
63 lines (53 loc) · 1.07 KB
/
matgen_cavity.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
subroutine matgen_cavity(coef,jcoef,nx,ny,ndim,mdim,dx,dy)
implicit none
integer :: nx,ny,i,j,k,mdim,ndim
integer ,dimension(1:mdim) :: jcoef
real*8 ,dimension(1:ndim,1:mdim)::coef
real*8 :: dx,dy,aa,bb
k=1
do j=1,ny
do i=1,nx
coef(k,1) =2./dx/dx+2./dy/dy
coef(k,2) =-1./dx/dx
coef(k,3) =-1./dy/dy
k=k+1
enddo
enddo
k=1
do j=1,ny
do i=1,nx
if(i.eq.1)then
aa=-1./dx/dx
elseif(i.eq.nx)then
aa=-1./dx/dx
else
aa=0.0
endif
if(j.eq.1)then
bb=-1./dy/dy
elseif(j.eq.ny)then
bb=-1./dy/dy
else
bb=0.0
endif
coef(k,1)=coef(k,1)+aa+bb
k=k+1
enddo
enddo
k=1
do j=1,ny
do i=1,nx
if(i.eq.nx)then
coef(k,2)=0.0
endif
if(j.eq.ny)then
coef(k,3)=0.0
endif
k=k+1
enddo
enddo
jcoef(1)=0
jcoef(2)=1
jcoef(3)=nx
return
end