Skip to content

Commit 1e7c97b

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

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
@@ -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: 65 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,16 +2614,15 @@ end subroutine sfr_cq
26142614

26152615
!> @ brief Output package flow terms.
26162616
!!
2617-
!! Output SFR package flow terms.
2618-
!!
2617+
!! Write flows to binary file and/or print flows to budget
26192618
!<
26202619
subroutine sfr_ot_package_flows(this, icbcfl, ibudfl)
26212620
! -- modules
26222621
use TdisModule, only: kstp, kper, delt, pertim, totim
26232622
! -- dummy variables
26242623
class(SfrType) :: this !< SfrType object
26252624
integer(I4B), intent(in) :: icbcfl !< flag and unit number for cell-by-cell output
2626-
integer(I4B), intent(in) :: ibudfl !< flag indication if cell-by-cell data should be saved
2625+
integer(I4B), intent(in) :: ibudfl !< flag indicating if cell-by-cell data should be saved
26272626
! -- local variables
26282627
integer(I4B) :: ibinun
26292628
character(len=20), dimension(:), allocatable :: cellidstr
@@ -5097,6 +5096,11 @@ subroutine sfr_setup_budobj(this)
50975096
! so they can be written to the binary budget files, but these internal
50985097
! flows are not included as part of the budget table.
50995098
nbudterm = 8
5099+
!
5100+
! -- GWF models with a single reach should not have an entry
5101+
if (this%nconn == 0) nbudterm = nbudterm - 1
5102+
!
5103+
! -- Account for mover connection and aux vars in budget object
51005104
if (this%imover == 1) nbudterm = nbudterm + 2
51015105
if (this%naux > 0) nbudterm = nbudterm + 1
51025106
!
@@ -5107,29 +5111,33 @@ subroutine sfr_setup_budobj(this)
51075111
idx = 0
51085112
!
51095113
! -- Go through and set up each budget term
5110-
text = ' FLOW-JA-FACE'
5111-
idx = idx + 1
5112-
maxlist = this%nconn
5113-
naux = 1
5114-
auxtxt(1) = ' FLOW-AREA'
5115-
call this%budobj%budterm(idx)%initialize(text, &
5116-
this%name_model, &
5117-
this%packName, &
5118-
this%name_model, &
5119-
this%packName, &
5120-
maxlist, .false., .false., &
5121-
naux, auxtxt)
51225114
!
5123-
! -- store connectivity
5124-
call this%budobj%budterm(idx)%reset(this%nconn)
5125-
q = DZERO
5126-
do n = 1, this%maxbound
5127-
n1 = n
5128-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5129-
n2 = this%ja(i)
5130-
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5115+
! -- GWF models with a single reach do not have flow-ja-face connections
5116+
if (this%nconn /= 0) then
5117+
text = ' FLOW-JA-FACE'
5118+
idx = idx + 1
5119+
maxlist = this%nconn
5120+
naux = 1
5121+
auxtxt(1) = ' FLOW-AREA'
5122+
call this%budobj%budterm(idx)%initialize(text, &
5123+
this%name_model, &
5124+
this%packName, &
5125+
this%name_model, &
5126+
this%packName, &
5127+
maxlist, .false., .false., &
5128+
naux, auxtxt)
5129+
!
5130+
! -- store connectivity
5131+
call this%budobj%budterm(idx)%reset(this%nconn)
5132+
q = DZERO
5133+
do n = 1, this%maxbound
5134+
n1 = n
5135+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5136+
n2 = this%ja(i)
5137+
call this%budobj%budterm(idx)%update_term(n1, n2, q)
5138+
end do
51315139
end do
5132-
end do
5140+
end if
51335141
!
51345142
! --
51355143
text = ' GWF'
@@ -5317,40 +5325,42 @@ subroutine sfr_fill_budobj(this)
53175325
idx = 0
53185326
!
53195327
! -- FLOW JA FACE
5320-
idx = idx + 1
5321-
call this%budobj%budterm(idx)%reset(this%nconn)
5322-
do n = 1, this%maxbound
5323-
n1 = n
5324-
q = DZERO
5325-
ca = DZERO
5326-
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5327-
n2 = this%ja(i)
5328-
if (this%iboundpak(n) /= 0) then
5329-
! flow to downstream reaches
5330-
if (this%idir(i) < 0) then
5331-
qt = this%dsflow(n)
5332-
q = -this%qconn(i)
5333-
! flow from upstream reaches
5328+
if (this%nconn /= 0) then
5329+
idx = idx + 1
5330+
call this%budobj%budterm(idx)%reset(this%nconn)
5331+
do n = 1, this%maxbound
5332+
n1 = n
5333+
q = DZERO
5334+
ca = DZERO
5335+
do i = this%ia(n) + 1, this%ia(n + 1) - 1
5336+
n2 = this%ja(i)
5337+
if (this%iboundpak(n) /= 0) then
5338+
! flow to downstream reaches
5339+
if (this%idir(i) < 0) then
5340+
qt = this%dsflow(n)
5341+
q = -this%qconn(i)
5342+
! flow from upstream reaches
5343+
else
5344+
qt = this%usflow(n)
5345+
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5346+
if (this%idir(ii) > 0) cycle
5347+
if (this%ja(ii) /= n) cycle
5348+
q = this%qconn(ii)
5349+
exit
5350+
end do
5351+
end if
5352+
! calculate flow area
5353+
call this%sfr_calc_reach_depth(n, qt, d)
5354+
ca = this%calc_area_wet(n, d)
53345355
else
5335-
qt = this%usflow(n)
5336-
do ii = this%ia(n2) + 1, this%ia(n2 + 1) - 1
5337-
if (this%idir(ii) > 0) cycle
5338-
if (this%ja(ii) /= n) cycle
5339-
q = this%qconn(ii)
5340-
exit
5341-
end do
5356+
q = DZERO
5357+
ca = DZERO
53425358
end if
5343-
! calculate flow area
5344-
call this%sfr_calc_reach_depth(n, qt, d)
5345-
ca = this%calc_area_wet(n, d)
5346-
else
5347-
q = DZERO
5348-
ca = DZERO
5349-
end if
5350-
this%qauxcbc(1) = ca
5351-
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5359+
this%qauxcbc(1) = ca
5360+
call this%budobj%budterm(idx)%update_term(n1, n2, q, this%qauxcbc)
5361+
end do
53525362
end do
5353-
end do
5363+
end if
53545364
!
53555365
! -- GWF (LEAKAGE)
53565366
idx = idx + 1

0 commit comments

Comments
 (0)