Skip to content

Commit

Permalink
fix(lgrutil): child delr/delc not correct if parent has variable row/…
Browse files Browse the repository at this point in the history
…col spacings (#1403)

* Fix child delr/delc calculations.  Parent row and column spacings were off by one cell.
* Add better Lgr access to parent and child grid information
* add lgr notebook
  • Loading branch information
langevin-usgs committed May 3, 2022
1 parent 85d4558 commit 69d6b15
Show file tree
Hide file tree
Showing 3 changed files with 612 additions and 4 deletions.
56 changes: 56 additions & 0 deletions autotest/t063_test_lgrutil.py
Expand Up @@ -104,5 +104,61 @@ def test_lgrutil():
return


def test_lgrutil2():
# Define parent grid information
xoffp = 0.0
yoffp = 0.0
nlayp = 1
nrowp = 5
ncolp = 5
dx = 100.0
dy = 100.0
dz = 100.0
delrp = dx * np.array([1.0, 0.75, 0.5, 0.75, 1.0], dtype=float)
delcp = dy * np.array([1.0, 0.75, 0.5, 0.75, 1.0], dtype=float)
topp = dz * np.ones((nrowp, ncolp), dtype=float)
botmp = np.empty((nlayp, nrowp, ncolp), dtype=float)
for k in range(nlayp):
botmp[k] = -(k + 1) * dz

# Define relation of child to parent
idomainp = np.ones((nlayp, nrowp, ncolp), dtype=int)
idomainp[:, 1:4, 1:4] = 0
ncpp = 3
ncppl = nlayp * [1]

lgr = Lgr(
nlayp,
nrowp,
ncolp,
delrp,
delcp,
topp,
botmp,
idomainp,
ncpp=ncpp,
ncppl=ncppl,
xllp=xoffp,
yllp=yoffp,
)

# check to make sure child delr and delc are calculated correctly for
# the case where the parent grid has variable row and column spacings
answer = [
25.0,
25.0,
25.0,
50.0 / 3.0,
50.0 / 3.0,
50.0 / 3.0,
25.0,
25.0,
25.0,
]
assert np.allclose(lgr.delr, answer), f"{lgr.delr} /= {answer}"
assert np.allclose(lgr.delc, answer), f"{lgr.delc} /= {answer}"


if __name__ == "__main__":
test_lgrutil()
test_lgrutil2()

0 comments on commit 69d6b15

Please sign in to comment.