-
Notifications
You must be signed in to change notification settings - Fork 3
/
SolveImpEqnUpdate_Temp.F90
75 lines (59 loc) · 2.07 KB
/
SolveImpEqnUpdate_Temp.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
75
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! !
! FILE: SolveImpEqnUpdate_Temp.F90 !
! CONTAINS: subroutine SolveImpEqnUpdate_Temp !
! !
! PURPOSE: Inverts the implicit equation for !
! temperature, and updates it to time t+dt !
! !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
subroutine SolveImpEqnUpdate_Temp
use param
use local_arrays, only : temp,rhs
use decomp_2d, only: xstart,xend
implicit none
real, dimension(nx) :: amkl,apkl,ackl, fkl
integer :: jc,kc,info,ipkv(nx),ic
real :: betadx,ackl_b
real :: amkT(nx-1),ackT(nx),apkT(nx-1),appk(nx-2)
! Calculate the coefficients of the tridiagonal matrix
! The coefficients are normalized to prevent floating
! point errors.
betadx=0.5d0*al*dt/pec
amkl(1)=0.d0
apkl(1)=0.d0
ackl(1)=1.d0
do kc=2,nxm
ackl_b=1.0d0/(1.-ac3ssk(kc)*betadx)
amkl(kc)=-am3ssk(kc)*betadx*ackl_b
ackl(kc)=1.0d0
apkl(kc)=-ap3ssk(kc)*betadx*ackl_b
enddo
amkl(nx)=0.d0
apkl(nx)=0.d0
ackl(nx)=1.d0
amkT=amkl(2:nx)
apkT=apkl(1:nxm)
ackT=ackl(1:nx)
! Call to LAPACK library to factor tridiagonal matrix.
! No solving is done in this call.
call dgttrf(nx,amkT,ackT,apkT,appk,ipkv,info)
do ic=xstart(3),xend(3)
do jc=xstart(2),xend(2)
! Normalize RHS of equation
fkl(1)= 0.d0
do kc=2,nxm
ackl_b=1.0/(1.-ac3ssk(kc)*betadx)
fkl(kc)=rhs(kc,jc,ic)*ackl_b
end do
fkl(nx)= 0.d0
! Solve equation using LAPACK library
call dgttrs('N',nx,1,amkT,ackT,apkT,appk,ipkv,fkl,nx,info)
! Update temperature field
do kc=2,nxm
temp(kc,jc,ic) = temp(kc,jc,ic) + fkl(kc)
end do
enddo
end do
return
end