Skip to content

Commit 5e5c483

Browse files
committed
stop writing blank entries to output, patch up some autotests as a result
1 parent 888d93a commit 5e5c483

3 files changed

Lines changed: 87 additions & 101 deletions

File tree

autotest/test_gwf_mvr01.py

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

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

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

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

400-
assert records[4].shape == (0,)
401-
assert records[5].shape == (0,)
402-
assert records[6].shape == (0,)
403-
assert records[7].shape == (0,)
404-
assert records[8].shape == (3,)
399+
assert records[3].shape == (3,)
405400
a = np.array([(1, 1, -0.0), (1, 2, -0.0005), (1, 3, -0.0)], dtype=adt)
406-
assert np.array_equal(records[8], a)
401+
assert np.array_equal(records[3], a)
407402

408-
assert records[9].shape == (0,)
409-
assert records[10].shape == (0,)
410-
assert records[11].shape == (0,)
411-
assert records[12].shape == (0,)
412-
assert records[13].shape == (0,)
413-
assert records[14].shape == (0,)
414-
assert records[15].shape == (0,)
415-
assert records[16].shape == (0,)
416-
assert records[17].shape == (0,)
417-
assert records[18].shape == (0,)
418-
assert records[19].shape == (0,)
419-
assert records[20].shape == (0,)
420-
assert records[21].shape == (0,)
421-
assert records[22].shape == (0,)
422-
assert records[23].shape == (9,)
403+
assert records[4].shape == (9,)
423404
a = np.array(
424405
[
425406
(1, 1, -1.0e-04),
@@ -434,14 +415,12 @@ def check_output(idx, test):
434415
],
435416
dtype=adt,
436417
)
437-
assert np.allclose(records[23]["node"], a["node"])
438-
assert np.allclose(records[23]["node2"], a["node2"])
439-
assert np.allclose(records[23]["q"], a["q"], atol=0.001), "{}\n{}".format(
440-
records[23]["q"], a["q"]
418+
assert np.allclose(records[4]["node"], a["node"])
419+
assert np.allclose(records[4]["node2"], a["node2"])
420+
assert np.allclose(records[4]["q"], a["q"], atol=0.001), "{}\n{}".format(
421+
records[4]["q"], a["q"]
441422
)
442423

443-
assert records[24].shape == (0,)
444-
445424

446425
@pytest.mark.parametrize("idx, name", enumerate(cases))
447426
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
@@ -621,14 +621,11 @@ def check_output(idx, test):
621621

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

633630

634631
# - 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
@@ -2665,16 +2665,15 @@ end subroutine sfr_cq
26652665

26662666
!> @ brief Output package flow terms.
26672667
!!
2668-
!! Output SFR package flow terms.
2669-
!!
2668+
!! Write flows to binary file and/or print flows to budget
26702669
!<
26712670
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
26722671
! -- modules
26732672
use TdisModule, only: kstp, kper, delt, pertim, totim
26742673
! -- dummy variables
26752674
class(SfrType) :: this !< SfrType object
26762675
integer(I4B), intent(in) :: icbcfl !< flag and unit number for cell-by-cell output
2677-
integer(I4B), intent(in) :: ibudfl !< flag indication if cell-by-cell data should be saved
2676+
integer(I4B), intent(in) :: ibudfl !< flag indicating if cell-by-cell data should be saved
26782677
! -- local variables
26792678
integer(I4B) :: ibinun
26802679
character(len=20), dimension(:), allocatable :: cellidstr
@@ -5223,6 +5222,11 @@ subroutine sfr_setup_budobj(this)
52235222
! so they can be written to the binary budget files, but these internal
52245223
! flows are not included as part of the budget table.
52255224
nbudterm = 8
5225+
!
5226+
! -- GWF models with a single reach should not have an entry
5227+
if (this%nconn == 0) nbudterm = nbudterm - 1
5228+
!
5229+
! -- Account for mover connection and aux vars in budget object
52265230
if (this%imover == 1) nbudterm = nbudterm + 2
52275231
if (this%naux > 0) nbudterm = nbudterm + 1
52285232
!
@@ -5233,29 +5237,33 @@ subroutine sfr_setup_budobj(this)
52335237
idx = 0
52345238
!
52355239
! -- Go through and set up each budget term
5236-
text = ' FLOW-JA-FACE'
5237-
idx = idx + 1
5238-
maxlist = this%nconn
5239-
naux = 1
5240-
auxtxt(1) = ' FLOW-AREA'
5241-
call this%budobj%budterm(idx)%initialize(text, &
5242-
this%name_model, &
5243-
this%packName, &
5244-
this%name_model, &
5245-
this%packName, &
5246-
maxlist, .false., .false., &
5247-
naux, auxtxt)
52485240
!
5249-
! -- store connectivity
5250-
call this%budobj%budterm(idx)%reset(this%nconn)
5251-
q = DZERO
5252-
do n = 1, this%maxbound
5253-
n1 = n
5254-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5255-
n2 = this%ja(i)
5256-
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5241+
! -- GWF models with a single reach do not have flow-ja-face connections
5242+
if (this%nconn /= 0) then
5243+
text = ' FLOW-JA-FACE'
5244+
idx = idx + 1
5245+
maxlist = this%nconn
5246+
naux = 1
5247+
auxtxt(1) = ' FLOW-AREA'
5248+
call this%budobj%budterm(idx)%initialize(text, &
5249+
this%name_model, &
5250+
this%packName, &
5251+
this%name_model, &
5252+
this%packName, &
5253+
maxlist, .false., .false., &
5254+
naux, auxtxt)
5255+
!
5256+
! -- store connectivity
5257+
call this%budobj%budterm(idx)%reset(this%nconn)
5258+
q = DZERO
5259+
do n = 1, this%maxbound
5260+
n1 = n
5261+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5262+
n2 = this%ja(i)
5263+
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5264+
end do
52575265
end do
5258-
end do
5266+
end if
52595267
!
52605268
! --
52615269
text = ' GWF'
@@ -5446,40 +5454,42 @@ subroutine sfr_fill_budobj(this)
54465454
idx = 0
54475455
!
54485456
! -- FLOW JA FACE
5449-
idx = idx + 1
5450-
call this%budobj%budterm(idx)%reset(this%nconn)
5451-
do n = 1, this%maxbound
5452-
n1 = n
5453-
q = DZERO
5454-
ca = DZERO
5455-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5456-
n2 = this%ja(i)
5457-
if (this%iboundpak(n) /= 0) then
5458-
! flow to downstream reaches
5459-
if (this%idir(i) < 0) then
5460-
qt = this%dsflow(n)
5461-
q = -this%qconn(i)
5462-
! flow from upstream reaches
5457+
if (this%nconn /= 0) then
5458+
idx = idx + 1
5459+
call this%budobj%budterm(idx)%reset(this%nconn)
5460+
do n = 1, this%maxbound
5461+
n1 = n
5462+
q = DZERO
5463+
ca = DZERO
5464+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5465+
n2 = this%ja(i)
5466+
if (this%iboundpak(n) /= 0) then
5467+
! flow to downstream reaches
5468+
if (this%idir(i) < 0) then
5469+
qt = this%dsflow(n)
5470+
q = -this%qconn(i)
5471+
! flow from upstream reaches
5472+
else
5473+
qt = this%usflow(n)
5474+
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5475+
if (this%idir(ii) > 0) cycle
5476+
if (this%ja(ii) /= n) cycle
5477+
q = this%qconn(ii)
5478+
exit
5479+
end do
5480+
end if
5481+
! calculate flow area
5482+
call this%sfr_calc_reach_depth(n, qt, d)
5483+
ca = this%calc_area_wet(n, d)
54635484
else
5464-
qt = this%usflow(n)
5465-
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5466-
if (this%idir(ii) > 0) cycle
5467-
if (this%ja(ii) /= n) cycle
5468-
q = this%qconn(ii)
5469-
exit
5470-
end do
5485+
q = DZERO
5486+
ca = DZERO
54715487
end if
5472-
! calculate flow area
5473-
call this%sfr_calc_reach_depth(n, qt, d)
5474-
ca = this%calc_area_wet(n, d)
5475-
else
5476-
q = DZERO
5477-
ca = DZERO
5478-
end if
5479-
this%qauxcbc(1) = ca
5480-
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5488+
this%qauxcbc(1) = ca
5489+
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5490+
end do
54815491
end do
5482-
end do
5492+
end if
54835493
!
54845494
! -- GWF (LEAKAGE)
54855495
idx = idx + 1

0 commit comments

Comments
 (0)