179
181
182 class(GwfHfbType) :: this
183 integer(I4B) :: kiter
184 class(MatrixBaseType), pointer :: matrix_sln
185 integer(I4B), intent(in), dimension(:) :: idxglo
186 real(DP), intent(inout), dimension(:) :: rhs
187 real(DP), intent(inout), dimension(:) :: hnew
188
189 integer(I4B) :: nodes, nja
190 integer(I4B) :: ihfb, n, m
191 integer(I4B) :: ipos
192 integer(I4B) :: idiag, isymcon
193 integer(I4B) :: ixt3d
194 real(DP) :: cond, condhfb, aterm
195 real(DP) :: fawidth, faheight, faarea
196 real(DP) :: topn, topm, botn, botm
197 real(DP) :: viscratio
198
199
201 nodes = this%dis%nodes
202 nja = this%dis%con%nja
203 if (associated(this%xt3d%ixt3d)) then
204 ixt3d = this%xt3d%ixt3d
205 else
206 ixt3d = 0
207 end if
208
209 if (ixt3d > 0) then
210
211 do ihfb = 1, this%nhfb
212 n = min(this%noden(ihfb), this%nodem(ihfb))
213 m = max(this%noden(ihfb), this%nodem(ihfb))
214
215 if (this%ibound(n) == 0 .or. this%ibound(m) == 0) cycle
216
217 if (this%ivsc /= 0) then
218 call this%vsc%get_visc_ratio(n, m, hnew(n), hnew(m), viscratio)
219 end if
220
221 if (this%hydchr(ihfb) >
dzero)
then
222 if (this%inewton == 0) then
223 ipos = this%idxloc(ihfb)
224 topn = this%top(n)
225 topm = this%top(m)
226 botn = this%bot(n)
227 botm = this%bot(m)
228 if (this%icelltype(n) == 1) then
229 if (hnew(n) < topn) topn = hnew(n)
230 end if
231 if (this%icelltype(m) == 1) then
232 if (hnew(m) < topm) topm = hnew(m)
233 end if
234 if (this%ihc(this%jas(ipos)) == 2) then
235 faheight = min(topn, topm) - max(botn, botm)
236 else
237 faheight =
dhalf * ((topn - botn) + (topm - botm))
238 end if
239
240 if (this%ihc(this%jas(ipos)) == 0) then
241 faarea = this%hwva(this%jas(ipos))
242 else
243 fawidth = this%hwva(this%jas(ipos))
244 faarea = fawidth * faheight
245 end if
246
247 condhfb = this%hydchr(ihfb) * viscratio * faarea
248 else
249 condhfb = this%hydchr(ihfb) * viscratio
250 end if
251 else
252 condhfb = this%hydchr(ihfb)
253 end if
254
255 call this%xt3d%xt3d_fhfb(kiter, nodes, nja, matrix_sln, idxglo, &
256 rhs, hnew, n, m, condhfb)
257 end do
258
259 else
260
261
262 if (this%inewton == 0) then
263 do ihfb = 1, this%nhfb
264 ipos = this%idxloc(ihfb)
265 aterm = matrix_sln%get_value_pos(idxglo(ipos))
266 n = this%noden(ihfb)
267 m = this%nodem(ihfb)
268 if (this%ibound(n) == 0 .or. this%ibound(m) == 0) cycle
269
270 if (this%ivsc /= 0) then
271 call this%vsc%get_visc_ratio(n, m, hnew(n), hnew(m), viscratio)
272 end if
273
274 if (this%icelltype(n) == 1 .or. this%icelltype(m) == 1 .or. &
275 this%ivsc /= 0) then
276
277
278 topn = this%top(n)
279 topm = this%top(m)
280 botn = this%bot(n)
281 botm = this%bot(m)
282 if (this%icelltype(n) == 1) then
283 if (hnew(n) < topn) topn = hnew(n)
284 end if
285 if (this%icelltype(m) == 1) then
286 if (hnew(m) < topm) topm = hnew(m)
287 end if
288 if (this%ihc(this%jas(ipos)) == 2) then
289 faheight = min(topn, topm) - max(botn, botm)
290 else
291 faheight =
dhalf * ((topn - botn) + (topm - botm))
292 end if
293
294 if (this%ihc(this%jas(ipos)) == 0) then
295 faarea = this%hwva(this%jas(ipos))
296 else
297 fawidth = this%hwva(this%jas(ipos))
298 faarea = fawidth * faheight
299 end if
300
301 if (this%hydchr(ihfb) >
dzero)
then
302 condhfb = this%hydchr(ihfb) * viscratio * faarea
303 cond = aterm * condhfb / (aterm + condhfb)
304 else
305 cond = -aterm * this%hydchr(ihfb)
306 end if
307
308
309 this%condsav(ihfb) = cond
310
311
312 idiag = this%ia(n)
313 call matrix_sln%add_value_pos(idxglo(idiag), aterm - cond)
314 call matrix_sln%set_value_pos(idxglo(ipos), cond)
315
316
317 isymcon = this%isym(ipos)
318 idiag = this%ia(m)
319 call matrix_sln%add_value_pos(idxglo(idiag), aterm - cond)
320 call matrix_sln%set_value_pos(idxglo(isymcon), cond)
321
322 end if
323 end do
324 end if
325
326 end if