Skip to content

Commit c5e8574

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

File tree

3 files changed

+87
-101
lines changed

3 files changed

+87
-101
lines changed

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
@@ -2472,16 +2472,15 @@ end subroutine sfr_cq
24722472

24732473
!> @ brief Output package flow terms.
24742474
!!
2475-
!! Output SFR package flow terms.
2476-
!!
2475+
!! Write flows to binary file and/or print flows to budget
24772476
!<
24782477
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
24792478
! -- modules
24802479
use TdisModule, only: kstp, kper, delt, pertim, totim
24812480
! -- dummy variables
24822481
class(SfrType) :: this !< SfrType object
24832482
integer(I4B), intent(in) :: icbcfl !< flag and unit number for cell-by-cell output
2484-
integer(I4B), intent(in) :: ibudfl !< flag indication if cell-by-cell data should be saved
2483+
integer(I4B), intent(in) :: ibudfl !< flag indicating if cell-by-cell data should be saved
24852484
! -- local variables
24862485
integer(I4B) :: ibinun
24872486
character(len=20), dimension(:), allocatable :: cellidstr
@@ -4931,6 +4930,11 @@ subroutine sfr_setup_budobj(this)
49314930
! so they can be written to the binary budget files, but these internal
49324931
! flows are not included as part of the budget table.
49334932
nbudterm = 8
4933+
!
4934+
! -- GWF models with a single reach should not have an entry
4935+
if (this%nconn == 0) nbudterm = nbudterm - 1
4936+
!
4937+
! -- Account for mover connection and aux vars in budget object
49344938
if (this%imover == 1) nbudterm = nbudterm + 2
49354939
if (this%naux > 0) nbudterm = nbudterm + 1
49364940
!
@@ -4941,29 +4945,33 @@ subroutine sfr_setup_budobj(this)
49414945
idx = 0
49424946
!
49434947
! -- Go through and set up each budget term
4944-
text = ' FLOW-JA-FACE'
4945-
idx = idx + 1
4946-
maxlist = this%nconn
4947-
naux = 1
4948-
auxtxt(1) = ' FLOW-AREA'
4949-
call this%budobj%budterm(idx)%initialize(text, &
4950-
this%name_model, &
4951-
this%packName, &
4952-
this%name_model, &
4953-
this%packName, &
4954-
maxlist, .false., .false., &
4955-
naux, auxtxt)
49564948
!
4957-
! -- store connectivity
4958-
call this%budobj%budterm(idx)%reset(this%nconn)
4959-
q = DZERO
4960-
do n = 1, this%maxbound
4961-
n1 = n
4962-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4963-
n2 = this%ja(i)
4964-
call this%budobj%budterm(idx)%update_term(n1, n2, q)
4949+
! -- GWF models with a single reach do not have flow-ja-face connections
4950+
if (this%nconn /= 0) then
4951+
text = ' FLOW-JA-FACE'
4952+
idx = idx + 1
4953+
maxlist = this%nconn
4954+
naux = 1
4955+
auxtxt(1) = ' FLOW-AREA'
4956+
call this%budobj%budterm(idx)%initialize(text, &
4957+
this%name_model, &
4958+
this%packName, &
4959+
this%name_model, &
4960+
this%packName, &
4961+
maxlist, .false., .false., &
4962+
naux, auxtxt)
4963+
!
4964+
! -- store connectivity
4965+
call this%budobj%budterm(idx)%reset(this%nconn)
4966+
q = DZERO
4967+
do n = 1, this%maxbound
4968+
n1 = n
4969+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
4970+
n2 = this%ja(i)
4971+
call this%budobj%budterm(idx)%update_term(n1, n2, q)
4972+
end do
49654973
end do
4966-
end do
4974+
end if
49674975
!
49684976
! --
49694977
text = ' GWF'
@@ -5154,40 +5162,42 @@ subroutine sfr_fill_budobj(this)
51545162
idx = 0
51555163
!
51565164
! -- FLOW JA FACE
5157-
idx = idx + 1
5158-
call this%budobj%budterm(idx)%reset(this%nconn)
5159-
do n = 1, this%maxbound
5160-
n1 = n
5161-
q = DZERO
5162-
ca = DZERO
5163-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5164-
n2 = this%ja(i)
5165-
if (this%iboundpak(n) /= 0) then
5166-
! flow to downstream reaches
5167-
if (this%idir(i) < 0) then
5168-
qt = this%dsflow(n)
5169-
q = -this%qconn(i)
5170-
! flow from upstream reaches
5165+
if (this%nconn /= 0) then
5166+
idx = idx + 1
5167+
call this%budobj%budterm(idx)%reset(this%nconn)
5168+
do n = 1, this%maxbound
5169+
n1 = n
5170+
q = DZERO
5171+
ca = DZERO
5172+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5173+
n2 = this%ja(i)
5174+
if (this%iboundpak(n) /= 0) then
5175+
! flow to downstream reaches
5176+
if (this%idir(i) < 0) then
5177+
qt = this%dsflow(n)
5178+
q = -this%qconn(i)
5179+
! flow from upstream reaches
5180+
else
5181+
qt = this%usflow(n)
5182+
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5183+
if (this%idir(ii) > 0) cycle
5184+
if (this%ja(ii) /= n) cycle
5185+
q = this%qconn(ii)
5186+
exit
5187+
end do
5188+
end if
5189+
! calculate flow area
5190+
call this%sfr_calc_reach_depth(n, qt, d)
5191+
ca = this%calc_area_wet(n, d)
51715192
else
5172-
qt = this%usflow(n)
5173-
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5174-
if (this%idir(ii) > 0) cycle
5175-
if (this%ja(ii) /= n) cycle
5176-
q = this%qconn(ii)
5177-
exit
5178-
end do
5193+
q = DZERO
5194+
ca = DZERO
51795195
end if
5180-
! calculate flow area
5181-
call this%sfr_calc_reach_depth(n, qt, d)
5182-
ca = this%calc_area_wet(n, d)
5183-
else
5184-
q = DZERO
5185-
ca = DZERO
5186-
end if
5187-
this%qauxcbc(1) = ca
5188-
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5196+
this%qauxcbc(1) = ca
5197+
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5198+
end do
51895199
end do
5190-
end do
5200+
end if
51915201
!
51925202
! -- GWF (LEAKAGE)
51935203
idx = idx + 1

0 commit comments

Comments
 (0)