Skip to content

Commit 238bc44

Browse files
committed
stop writing blank entries to output, patch up some autotests as a result
1 parent cbe51da commit 238bc44

File tree

3 files changed

+88
-102
lines changed

3 files changed

+88
-102
lines changed

autotest/test_gwf_mvr01.py

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -379,48 +379,29 @@ def check_output(idx, test):
379379
times = bobj.get_times()
380380
records = bobj.get_data(totim=times[-1])
381381
adt = [("node", "<i4"), ("node2", "<i4"), ("q", "<f8")]
382-
assert len(records) == 25
383-
assert records[0].shape == (0,)
382+
assert len(records) == 5
384383

385-
assert records[1].shape == (2,)
384+
assert records[0].shape == (2,)
386385
a = np.array([(1, 2, -0.0), (2, 2, -0.0)], dtype=adt)
387-
assert np.array_equal(records[1], a)
386+
assert np.array_equal(records[0], a)
388387

389-
assert records[2].shape == (2,)
388+
assert records[1].shape == (2,)
390389
a = np.array([(1, 1, -0.0), (2, 1, -0.0)], dtype=adt)
391-
assert np.array_equal(records[2], a)
390+
assert np.array_equal(records[1], a)
392391

393-
assert records[3].shape == (2,)
392+
assert records[2].shape == (2,)
394393
a = np.array([(1, 3, -0.00545875), (2, 3, -0.00468419)], dtype=adt)
395-
assert np.allclose(records[3]["node"], a["node"])
396-
assert np.allclose(records[3]["node2"], a["node2"])
397-
assert np.allclose(records[3]["q"], a["q"], atol=0.001), "{}\n{}".format(
398-
records[3]["q"], a["q"]
394+
assert np.allclose(records[2]["node"], a["node"])
395+
assert np.allclose(records[2]["node2"], a["node2"])
396+
assert np.allclose(records[2]["q"], a["q"], atol=0.001), "{}\n{}".format(
397+
records[2]["q"], a["q"]
399398
)
400399

401-
assert records[4].shape == (0,)
402-
assert records[5].shape == (0,)
403-
assert records[6].shape == (0,)
404-
assert records[7].shape == (0,)
405-
assert records[8].shape == (3,)
400+
assert records[3].shape == (3,)
406401
a = np.array([(1, 1, -0.0), (1, 2, -0.0005), (1, 3, -0.0)], dtype=adt)
407-
assert np.array_equal(records[8], a)
408-
409-
assert records[9].shape == (0,)
410-
assert records[10].shape == (0,)
411-
assert records[11].shape == (0,)
412-
assert records[12].shape == (0,)
413-
assert records[13].shape == (0,)
414-
assert records[14].shape == (0,)
415-
assert records[15].shape == (0,)
416-
assert records[16].shape == (0,)
417-
assert records[17].shape == (0,)
418-
assert records[18].shape == (0,)
419-
assert records[19].shape == (0,)
420-
assert records[20].shape == (0,)
421-
assert records[21].shape == (0,)
422-
assert records[22].shape == (0,)
423-
assert records[23].shape == (9,)
402+
assert np.array_equal(records[3], a)
403+
404+
assert records[4].shape == (9,)
424405
a = np.array(
425406
[
426407
(1, 1, -1.0e-04),
@@ -435,14 +416,12 @@ def check_output(idx, test):
435416
],
436417
dtype=adt,
437418
)
438-
assert np.allclose(records[23]["node"], a["node"])
439-
assert np.allclose(records[23]["node2"], a["node2"])
440-
assert np.allclose(records[23]["q"], a["q"], atol=0.001), "{}\n{}".format(
441-
records[23]["q"], a["q"]
419+
assert np.allclose(records[4]["node"], a["node"])
420+
assert np.allclose(records[4]["node2"], a["node2"])
421+
assert np.allclose(records[4]["q"], a["q"], atol=0.001), "{}\n{}".format(
422+
records[4]["q"], a["q"]
442423
)
443424

444-
assert records[24].shape == (0,)
445-
446425

447426
@pytest.mark.parametrize("idx, name", enumerate(cases))
448427
def test_mf6model(idx, name, function_tmpdir, targets):

autotest/test_gwt_uztmvt2x2.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -622,14 +622,11 @@ def check_output(idx, test):
622622

623623
msg2 = "Mass received by SFR ('FROM-MVR') not as expected"
624624
for x in np.arange(len(fromMvrDat)):
625-
for y in np.arange(len(fromMvrDat[x + 1][0])):
626-
if fromMvrDat[x + 1][0][y][-1] == concCell[y]:
627-
continue
628-
else:
629-
for z in np.arange(len(mvtdat[x + 1][y])):
630-
assert np.isclose(
631-
mvtdat[x + 1][y][z][-1], (x + 1.0) * concCell[z]
632-
), msg2
625+
for y in np.arange(len(fromMvrDat[x + 1])):
626+
for z in np.arange(len(mvtdat[x + 1][y])):
627+
assert np.isclose(
628+
mvtdat[x + 1][y][z][-1], (x + 1.0) * concCell[z]
629+
), msg2
633630

634631

635632
# - No need to change any code below

src/Model/GroundWaterFlow/gwf-sfr.f90

Lines changed: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,16 +2442,15 @@ end subroutine sfr_cq
24422442

24432443
!> @ brief Output package flow terms.
24442444
!!
2445-
!! Output SFR package flow terms.
2446-
!!
2445+
!! Write flows to binary file and/or print flows to budget
24472446
!<
24482447
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
24492448
! -- modules
24502449
use TdisModule, only: kstp, kper, delt, pertim, totim
24512450
! -- dummy variables
24522451
class(SfrType) :: this !< SfrType object
24532452
integer(I4B), intent(in) :: icbcfl !< flag and unit number for cell-by-cell output
2454-
integer(I4B), intent(in) :: ibudfl !< flag indication if cell-by-cell data should be saved
2453+
integer(I4B), intent(in) :: ibudfl !< flag indicating if cell-by-cell data should be saved
24552454
! -- local variables
24562455
integer(I4B) :: ibinun
24572456
character(len=20), dimension(:), allocatable :: cellidstr
@@ -5233,6 +5232,11 @@ subroutine sfr_setup_budobj(this)
52335232
! so they can be written to the binary budget files, but these internal
52345233
! flows are not included as part of the budget table.
52355234
nbudterm = 8
5235+
!
5236+
! -- GWF models with a single reach should not have an entry
5237+
if (this%nconn == 0) nbudterm = nbudterm - 1
5238+
!
5239+
! -- Account for mover connection and aux vars in budget object
52365240
if (this%imover == 1) nbudterm = nbudterm + 2
52375241
if (this%naux > 0) nbudterm = nbudterm + 1
52385242
!
@@ -5243,29 +5247,33 @@ subroutine sfr_setup_budobj(this)
52435247
idx = 0
52445248
!
52455249
! -- Go through and set up each budget term
5246-
text = ' FLOW-JA-FACE'
5247-
idx = idx + 1
5248-
maxlist = this%nconn
5249-
naux = 1
5250-
auxtxt(1) = ' FLOW-AREA'
5251-
call this%budobj%budterm(idx)%initialize(text, &
5252-
this%name_model, &
5253-
this%packName, &
5254-
this%name_model, &
5255-
this%packName, &
5256-
maxlist, .false., .false., &
5257-
naux, auxtxt)
52585250
!
5259-
! -- store connectivity
5260-
call this%budobj%budterm(idx)%reset(this%nconn)
5261-
q = DZERO
5262-
do n = 1, this%maxbound
5263-
n1 = n
5264-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5265-
n2 = this%ja(i)
5266-
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5251+
! -- GWF models with a single reach do not have flow-ja-face connections
5252+
if (this%nconn /= 0) then
5253+
text = ' FLOW-JA-FACE'
5254+
idx = idx + 1
5255+
maxlist = this%nconn
5256+
naux = 1
5257+
auxtxt(1) = ' FLOW-AREA'
5258+
call this%budobj%budterm(idx)%initialize(text, &
5259+
this%name_model, &
5260+
this%packName, &
5261+
this%name_model, &
5262+
this%packName, &
5263+
maxlist, .false., .false., &
5264+
naux, auxtxt)
5265+
!
5266+
! -- store connectivity
5267+
call this%budobj%budterm(idx)%reset(this%nconn)
5268+
q = DZERO
5269+
do n = 1, this%maxbound
5270+
n1 = n
5271+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5272+
n2 = this%ja(i)
5273+
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5274+
end do
52675275
end do
5268-
end do
5276+
end if
52695277
!
52705278
! --
52715279
text = ' GWF'
@@ -5456,40 +5464,42 @@ subroutine sfr_fill_budobj(this)
54565464
idx = 0
54575465
!
54585466
! -- FLOW JA FACE
5459-
idx = idx + 1
5460-
call this%budobj%budterm(idx)%reset(this%nconn)
5461-
do n = 1, this%maxbound
5462-
n1 = n
5463-
q = DZERO
5464-
ca = DZERO
5465-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5466-
n2 = this%ja(i)
5467-
if (this%iboundpak(n) /= 0) then
5468-
! flow to downstream reaches
5469-
if (this%idir(i) < 0) then
5470-
qt = this%dsflow(n)
5471-
q = -this%qconn(i)
5472-
! flow from upstream reaches
5467+
if (this%nconn /= 0) then
5468+
idx = idx + 1
5469+
call this%budobj%budterm(idx)%reset(this%nconn)
5470+
do n = 1, this%maxbound
5471+
n1 = n
5472+
q = DZERO
5473+
ca = DZERO
5474+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5475+
n2 = this%ja(i)
5476+
if (this%iboundpak(n) /= 0) then
5477+
! flow to downstream reaches
5478+
if (this%idir(i) < 0) then
5479+
qt = this%dsflow(n)
5480+
q = -this%qconn(i)
5481+
! flow from upstream reaches
5482+
else
5483+
qt = this%usflow(n)
5484+
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5485+
if (this%idir(ii) > 0) cycle
5486+
if (this%ja(ii) /= n) cycle
5487+
q = this%qconn(ii)
5488+
exit
5489+
end do
5490+
end if
5491+
! calculate flow area
5492+
call this%sfr_calc_reach_depth(n, qt, d)
5493+
ca = this%calc_area_wet(n, d)
54735494
else
5474-
qt = this%usflow(n)
5475-
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5476-
if (this%idir(ii) > 0) cycle
5477-
if (this%ja(ii) /= n) cycle
5478-
q = this%qconn(ii)
5479-
exit
5480-
end do
5495+
q = DZERO
5496+
ca = DZERO
54815497
end if
5482-
! calculate flow area
5483-
call this%sfr_calc_reach_depth(n, qt, d)
5484-
ca = this%calc_area_wet(n, d)
5485-
else
5486-
q = DZERO
5487-
ca = DZERO
5488-
end if
5489-
this%qauxcbc(1) = ca
5490-
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5498+
this%qauxcbc(1) = ca
5499+
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5500+
end do
54915501
end do
5492-
end do
5502+
end if
54935503
!
54945504
! -- GWF (LEAKAGE)
54955505
idx = idx + 1

0 commit comments

Comments
 (0)