107
108 type(CoefficientsType), target :: phi_face
109
110 class(UTVDSchemeType), target :: this
111 integer(I4B), intent(in) :: n
112 integer(I4B), intent(in) :: m
113 integer(I4B), intent(in) :: iposnm
114
115 integer(I4B) :: iup, idn, isympos
116 real(DP) :: qnm
117 real(DP), pointer :: coef_up, coef_dn
118 real(DP), dimension(3) :: grad_c
119 real(DP), dimension(3) :: dnm
120 real(DP) :: smooth
121 real(DP) :: alimiter
122 real(DP) :: cl1, cl2
123 real(DP) :: cl_up, cl_dn
124 real(DP) :: relative_distance
125 real(DP) :: c_virtual
126 real(DP), pointer :: min_phi, max_phi
127
128 isympos = this%dis%con%jas(iposnm)
129 qnm = this%fmi%gwfflowja(iposnm)
130
131
132
133 if (n < m) then
134 cl1 = this%dis%con%cl1(isympos)
135 cl2 = this%dis%con%cl2(isympos)
136 else
137 cl1 = this%dis%con%cl2(isympos)
138 cl2 = this%dis%con%cl1(isympos)
139 end if
140
141
142 if (qnm > dzero) then
143
144 iup = m
145 idn = n
146
147 cl_up = cl2
148 cl_dn = cl1
149
150 coef_up => phi_face%c_m
151 coef_dn => phi_face%c_n
152 else
153 iup = n
154 idn = m
155
156 cl_up = cl1
157 cl_dn = cl2
158
159 coef_up => phi_face%c_n
160 coef_dn => phi_face%c_m
161 end if
162
163
164
165
166
167
168 if (iup > idn) then
169 dnm = -this%cached_node_distance(isympos, :)
170 else
171 dnm = this%cached_node_distance(isympos, :)
172 end if
173
174
175 coef_up = done
176
177
178
179
180 if (abs(this%phi(idn) - this%phi(iup)) < dsame) return
181
182
183 grad_c = this%gradient%get(iup)
184
185
186 c_virtual = this%phi(idn) - 2.0_dp * (dot_product(grad_c, dnm))
187
188
189
190
191 min_phi => this%min_max_phi%get_min(iup)
192 max_phi => this%min_max_phi%get_max(iup)
193
194 if (c_virtual > max_phi) then
195 c_virtual = max_phi
196 end if
197
198 if (c_virtual < max(min_phi, dzero)) then
199 c_virtual = max(min_phi, dzero)
200 end if
201
202
203 smooth = (this%phi(iup) - c_virtual) / (this%phi(idn) - this%phi(iup))
204
205
206 alimiter = this%limiter(smooth)
207
208
209 relative_distance = cl_up / (cl_up + cl_dn)
210 phi_face%rhs = -relative_distance * alimiter * (this%phi(idn) - this%phi(iup))
211
212
213
214
215
216
217
218