Skip to content

Commit e3527af

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

3 files changed

Lines changed: 85 additions & 98 deletions

File tree

autotest/test_gwf_mvr01.py

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

380-
assert records[1].shape == (2,)
379+
assert records[0].shape == (2,)
381380
a = np.array([(1, 2, -0.0), (2, 2, -0.0)], dtype=adt)
382-
assert np.array_equal(records[1], a)
381+
assert np.array_equal(records[0], a)
383382

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

388-
assert records[3].shape == (2,)
387+
assert records[2].shape == (2,)
389388
a = np.array([(1, 3, -0.00545875), (2, 3, -0.00468419)], dtype=adt)
390-
assert np.allclose(records[3]["node"], a["node"])
391-
assert np.allclose(records[3]["node2"], a["node2"])
392-
assert np.allclose(records[3]["q"], a["q"], atol=0.001), "{}\n{}".format(
393-
records[3]["q"], a["q"]
389+
assert np.allclose(records[2]["node"], a["node"])
390+
assert np.allclose(records[2]["node2"], a["node2"])
391+
assert np.allclose(records[2]["q"], a["q"], atol=0.001), "{}\n{}".format(
392+
records[2]["q"], a["q"]
394393
)
395394

396-
assert records[4].shape == (0,)
397-
assert records[5].shape == (0,)
398-
assert records[6].shape == (0,)
399-
assert records[7].shape == (0,)
400-
assert records[8].shape == (3,)
395+
assert records[3].shape == (3,)
401396
a = np.array([(1, 1, -0.0), (1, 2, -0.0005), (1, 3, -0.0)], dtype=adt)
402-
assert np.array_equal(records[8], a)
397+
assert np.array_equal(records[3], a)
403398

404-
assert records[9].shape == (0,)
405-
assert records[10].shape == (0,)
406-
assert records[11].shape == (0,)
407-
assert records[12].shape == (0,)
408-
assert records[13].shape == (0,)
409-
assert records[14].shape == (0,)
410-
assert records[15].shape == (0,)
411-
assert records[16].shape == (0,)
412-
assert records[17].shape == (0,)
413-
assert records[18].shape == (0,)
414-
assert records[19].shape == (0,)
415-
assert records[20].shape == (0,)
416-
assert records[21].shape == (0,)
417-
assert records[22].shape == (0,)
418-
assert records[23].shape == (9,)
399+
assert records[4].shape == (9,)
419400
a = np.array(
420401
[
421402
(1, 1, -1.0e-04),
@@ -430,14 +411,12 @@ def check_output(idx, test):
430411
],
431412
dtype=adt,
432413
)
433-
assert np.allclose(records[23]["node"], a["node"])
434-
assert np.allclose(records[23]["node2"], a["node2"])
435-
assert np.allclose(records[23]["q"], a["q"], atol=0.001), "{}\n{}".format(
436-
records[23]["q"], a["q"]
414+
assert np.allclose(records[4]["node"], a["node"])
415+
assert np.allclose(records[4]["node2"], a["node2"])
416+
assert np.allclose(records[4]["q"], a["q"], atol=0.001), "{}\n{}".format(
417+
records[4]["q"], a["q"]
437418
)
438419

439-
assert records[24].shape == (0,)
440-
441420

442421
@pytest.mark.parametrize("idx, name", enumerate(cases))
443422
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
@@ -582,14 +582,11 @@ def check_output(idx, test):
582582

583583
msg2 = "Mass received by SFR ('FROM-MVR') not as expected"
584584
for x in np.arange(len(fromMvrDat)):
585-
for y in np.arange(len(fromMvrDat[x + 1][0])):
586-
if fromMvrDat[x + 1][0][y][-1] == concCell[y]:
587-
continue
588-
else:
589-
for z in np.arange(len(mvtdat[x + 1][y])):
590-
assert np.isclose(
591-
mvtdat[x + 1][y][z][-1], (x + 1.0) * concCell[z]
592-
), msg2
585+
for y in np.arange(len(fromMvrDat[x + 1])):
586+
for z in np.arange(len(mvtdat[x + 1][y])):
587+
assert np.isclose(
588+
mvtdat[x + 1][y][z][-1], (x + 1.0) * concCell[z]
589+
), msg2
593590

594591

595592
# - No need to change any code below

src/Model/GroundWaterFlow/gwf-sfr.f90

Lines changed: 63 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -5048,6 +5048,11 @@ subroutine sfr_setup_budobj(this)
50485048
! so they can be written to the binary budget files, but these internal
50495049
! flows are not included as part of the budget table.
50505050
nbudterm = 8
5051+
!
5052+
! -- GWF models with a single reach should not have an entry
5053+
if (this%nconn == 0) nbudterm = nbudterm - 1
5054+
!
5055+
! -- Account for mover connection and aux vars in budget object
50515056
if (this%imover == 1) nbudterm = nbudterm + 2
50525057
if (this%naux > 0) nbudterm = nbudterm + 1
50535058
!
@@ -5058,29 +5063,33 @@ subroutine sfr_setup_budobj(this)
50585063
idx = 0
50595064
!
50605065
! -- Go through and set up each budget term
5061-
text = ' FLOW-JA-FACE'
5062-
idx = idx + 1
5063-
maxlist = this%nconn
5064-
naux = 1
5065-
auxtxt(1) = ' FLOW-AREA'
5066-
call this%budobj%budterm(idx)%initialize(text, &
5067-
this%name_model, &
5068-
this%packName, &
5069-
this%name_model, &
5070-
this%packName, &
5071-
maxlist, .false., .false., &
5072-
naux, auxtxt)
50735066
!
5074-
! -- store connectivity
5075-
call this%budobj%budterm(idx)%reset(this%nconn)
5076-
q = DZERO
5077-
do n = 1, this%maxbound
5078-
n1 = n
5079-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5080-
n2 = this%ja(i)
5081-
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5067+
! -- GWF models with a single reach do not have flow-ja-face connections
5068+
if (this%nconn /= 0) then
5069+
text = ' FLOW-JA-FACE'
5070+
idx = idx + 1
5071+
maxlist = this%nconn
5072+
naux = 1
5073+
auxtxt(1) = ' FLOW-AREA'
5074+
call this%budobj%budterm(idx)%initialize(text, &
5075+
this%name_model, &
5076+
this%packName, &
5077+
this%name_model, &
5078+
this%packName, &
5079+
maxlist, .false., .false., &
5080+
naux, auxtxt)
5081+
!
5082+
! -- store connectivity
5083+
call this%budobj%budterm(idx)%reset(this%nconn)
5084+
q = DZERO
5085+
do n = 1, this%maxbound
5086+
n1 = n
5087+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5088+
n2 = this%ja(i)
5089+
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5090+
end do
50825091
end do
5083-
end do
5092+
end if
50845093
!
50855094
! --
50865095
text = ' GWF'
@@ -5267,40 +5276,42 @@ subroutine sfr_fill_budobj(this)
52675276
idx = 0
52685277
!
52695278
! -- FLOW JA FACE
5270-
idx = idx + 1
5271-
call this%budobj%budterm(idx)%reset(this%nconn)
5272-
do n = 1, this%maxbound
5273-
n1 = n
5274-
q = DZERO
5275-
ca = DZERO
5276-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5277-
n2 = this%ja(i)
5278-
if (this%iboundpak(n) /= 0) then
5279-
! flow to downstream reaches
5280-
if (this%idir(i) < 0) then
5281-
qt = this%dsflow(n)
5282-
q = -this%qconn(i)
5283-
! flow from upstream reaches
5279+
if (this%nconn /= 0) then
5280+
idx = idx + 1
5281+
call this%budobj%budterm(idx)%reset(this%nconn)
5282+
do n = 1, this%maxbound
5283+
n1 = n
5284+
q = DZERO
5285+
ca = DZERO
5286+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5287+
n2 = this%ja(i)
5288+
if (this%iboundpak(n) /= 0) then
5289+
! flow to downstream reaches
5290+
if (this%idir(i) < 0) then
5291+
qt = this%dsflow(n)
5292+
q = -this%qconn(i)
5293+
! flow from upstream reaches
5294+
else
5295+
qt = this%usflow(n)
5296+
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5297+
if (this%idir(ii) > 0) cycle
5298+
if (this%ja(ii) /= n) cycle
5299+
q = this%qconn(ii)
5300+
exit
5301+
end do
5302+
end if
5303+
! calculate flow area
5304+
call this%sfr_calc_reach_depth(n, qt, d)
5305+
ca = this%calc_area_wet(n, d)
52845306
else
5285-
qt = this%usflow(n)
5286-
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5287-
if (this%idir(ii) > 0) cycle
5288-
if (this%ja(ii) /= n) cycle
5289-
q = this%qconn(ii)
5290-
exit
5291-
end do
5307+
q = DZERO
5308+
ca = DZERO
52925309
end if
5293-
! calculate flow area
5294-
call this%sfr_calc_reach_depth(n, qt, d)
5295-
ca = this%calc_area_wet(n, d)
5296-
else
5297-
q = DZERO
5298-
ca = DZERO
5299-
end if
5300-
this%qauxcbc(1) = ca
5301-
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5310+
this%qauxcbc(1) = ca
5311+
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5312+
end do
53025313
end do
5303-
end do
5314+
end if
53045315
!
53055316
! -- GWF (LEAKAGE)
53065317
idx = idx + 1

0 commit comments

Comments
 (0)