Skip to content

Commit

Permalink
fix(postprocessing): get_structured_faceflows fix to support 3d models (
Browse files Browse the repository at this point in the history
#1333)

* function was fixed to support multi-layer models
* test added to ensure face flow calculations work
  • Loading branch information
langevin-usgs authored Jan 21, 2022
1 parent 7ec884f commit 0616db5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 3 deletions.
40 changes: 38 additions & 2 deletions autotest/t029_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,41 @@ def test_flowja_residuals():
return


def test_structured_faceflows_3d():
model_ws = f"{base_dir}_test_faceflows_3d"
test_setup = FlopyTestSetup(verbose=True, test_dirs=model_ws)
name = 'mymodel'
sim = flopy.mf6.MFSimulation(sim_name=name, sim_ws=model_ws, exe_name='mf6')
tdis = flopy.mf6.ModflowTdis(sim)
ims = flopy.mf6.ModflowIms(sim)
gwf = flopy.mf6.ModflowGwf(sim, modelname=name, save_flows=True)
dis = flopy.mf6.ModflowGwfdis(gwf, nlay=3, nrow=10, ncol=10, top=0, botm=[-1, -2, -3])
ic = flopy.mf6.ModflowGwfic(gwf)
npf = flopy.mf6.ModflowGwfnpf(gwf, save_specific_discharge=True)
chd = flopy.mf6.ModflowGwfchd(gwf, stress_period_data=[[(0, 0, 0), 1.],
[(0, 9, 9), 0.]])
budget_file = name + '.bud'
head_file = name + '.hds'
oc = flopy.mf6.ModflowGwfoc(gwf,
budget_filerecord=budget_file,
head_filerecord=head_file,
saverecord=[('HEAD', 'ALL'), ('BUDGET', 'ALL')])
sim.write_simulation()
sim.run_simulation()

head = gwf.output.head().get_data()
bud = gwf.output.budget()
flowja = bud.get_data(text="FLOW-JA-FACE")[0]
frf, fff, flf = flopy.mf6.utils.get_structured_faceflows(
flowja,
grb_file=os.path.join(model_ws, "mymodel.dis.grb"),
)
assert frf.shape == head.shape, f"frf.shape {frf.shape} != head.shape {head.shape}"
assert fff.shape == head.shape, f"frf.shape {frf.shape} != head.shape {head.shape}"
assert flf.shape == head.shape, f"frf.shape {frf.shape} != head.shape {head.shape}"
return


def test_faceflows_empty():
flowja = np.zeros(10, dtype=np.float64)
with pytest.raises(ValueError):
Expand Down Expand Up @@ -375,5 +410,6 @@ def test_residuals_iaempty():
# test_mfgrddisv_modelgrid()
# test_mfgrddisu_MfGrdFile()
# test_mfgrddisu_modelgrid()
test_faceflows()
test_flowja_residuals()
# test_faceflows()
test_structured_faceflows_3d()
# test_flowja_residuals()
2 changes: 1 addition & 1 deletion flopy/mf6/utils/postprocessing.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def get_structured_faceflows(
shape = (grb.nlay, grb.nrow, grb.ncol)
frf = np.zeros(shape, dtype=float).flatten()
fff = np.zeros(shape, dtype=float).flatten()
flf = np.zeros(shape, dtype=float)
flf = np.zeros(shape, dtype=float).flatten()

# fill flow terms
vmult = [-1.0, -1.0, -1.0]
Expand Down

0 comments on commit 0616db5

Please sign in to comment.