58
59 type(CoefficientsType), target :: phi_face
60
61 class(TVDSchemeType), target :: this
62 integer(I4B), intent(in) :: n
63 integer(I4B), intent(in) :: m
64 integer(I4B), intent(in) :: iposnm
65
66 integer(I4B) :: ipos, isympos, iup, idn, i2up, j
67 real(DP) :: qnm, qmax, qupj, elupdn, elup2up
68 real(DP) :: smooth, cdiff, alimiter
69 real(DP), pointer :: coef_up, coef_dn
70
71
72 isympos = this%dis%con%jas(iposnm)
73 qnm = this%fmi%gwfflowja(iposnm)
74 if (qnm > dzero) then
75
76 iup = m
77 idn = n
78
79 coef_up => phi_face%c_m
80 coef_dn => phi_face%c_n
81 else
82 iup = n
83 idn = m
84
85 coef_up => phi_face%c_n
86 coef_dn => phi_face%c_m
87 end if
88 elupdn = this%dis%con%cl1(isympos) + this%dis%con%cl2(isympos)
89
90
91 coef_up = done
92
93
94
95
96 i2up = 0
97 qmax = dzero
98 do ipos = this%dis%con%ia(iup) + 1, this%dis%con%ia(iup + 1) - 1
99 j = this%dis%con%ja(ipos)
100 if (this%ibound(j) == 0) cycle
101 qupj = this%fmi%gwfflowja(ipos)
102 isympos = this%dis%con%jas(ipos)
103 if (qupj > qmax) then
104 qmax = qupj
105 i2up = j
106 elup2up = this%dis%con%cl1(isympos) + this%dis%con%cl2(isympos)
107 end if
108 end do
109
110
111 if (i2up > 0) then
112 smooth = dzero
113 cdiff = abs(this%phi(idn) - this%phi(iup))
114 if (cdiff > dprec) then
115 smooth = (this%phi(iup) - this%phi(i2up)) / elup2up * &
116 elupdn / (this%phi(idn) - this%phi(iup))
117 end if
118 if (smooth > dzero) then
119 alimiter = dtwo * smooth / (done + smooth)
120 phi_face%rhs = -dhalf * alimiter * (this%phi(idn) - this%phi(iup))
121 end if
122 end if
123