Skip to content

Commit

Permalink
"feat(improved support for insetting with rotated grids):
Browse files Browse the repository at this point in the history
* add support for generating grids with a specified rotation around features of interest
* add support for rotated LGR models (LGR parent and inset with same rotation)
* generalize logic of snapping inset grids to parent grids to ensure that the inset grid is symmetrical about nearfield features of interest when it is created from those (using a buffer; instead of by specifying offset and nrow, ncol)
* fix(grid.py::setup_structured_grid): some issues with delr/delc input, esp. when model.setup_grid is called more than once.
* refactor(grid.py::setup_structured_grid): kruft removal
* improved testing and error checking for various rotated grid cases:
  * inset and TMR parent with same rotation
  * inset rotated relative to TMR parent
  * LGR inset rotated relative to LGR parent (not allowed; raise error)
  • Loading branch information
aleaf committed Mar 8, 2024
1 parent 7990ada commit c67df40
Show file tree
Hide file tree
Showing 7 changed files with 621 additions and 153 deletions.
29 changes: 20 additions & 9 deletions mfsetup/discretization.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,10 @@ def fix_model_layer_conflicts(top_array, botm_array,
with np.errstate(invalid='ignore'):
too_thin = active & (thicknesses < minimum_thickness)
new_layer_elevs[i, too_thin] = new_layer_elevs[i - 1, too_thin] - minimum_thickness * 1.001
assert np.nanmax(np.diff(new_layer_elevs, axis=0)[ibound_array > 0]) * -1 >= minimum_thickness
try:
assert np.nanmax(np.diff(new_layer_elevs, axis=0)[ibound_array > 0]) * -1 >= minimum_thickness
except:
j=2
return new_layer_elevs[1:]


Expand Down Expand Up @@ -404,15 +407,23 @@ def make_ibound(top, botm, nodata=-9999,
def make_lgr_idomain(parent_modelgrid, inset_modelgrid):
"""Inactivate cells in parent_modelgrid that coincide
with area of inset_modelgrid."""
if parent_modelgrid.rotation != 0 or inset_modelgrid.rotation != 0:
raise NotImplementedError('Rotated grids not supported.')
if parent_modelgrid.rotation != inset_modelgrid.rotation:
raise ValueError('LGR parent and inset models must have same rotation.'
f'\nParent rotation: {parent_modelgrid.rotation}'
f'\nInset rotation: {inset_modelgrid.rotation}'
)
# upper left corner of inset model in parent model
# use the cell centers, to avoid edge situation
# where neighboring parent cell is accidentally selected
x0 = inset_modelgrid.xcellcenters[0, 0]
y0 = inset_modelgrid.ycellcenters[0, 0]
pi0, pj0 = parent_modelgrid.intersect(x0, y0, forgive=True)
# lower right corner of inset model
x1 = inset_modelgrid.xcellcenters[-1, -1]
y1 = inset_modelgrid.ycellcenters[-1, -1]
pi1, pj1 = parent_modelgrid.intersect(x1, y1, forgive=True)
idomain = np.ones(parent_modelgrid.shape, dtype=int)
l, b, r, t = inset_modelgrid.bounds
isinset = (parent_modelgrid.xcellcenters > l) & \
(parent_modelgrid.xcellcenters < r) & \
(parent_modelgrid.ycellcenters > b) & \
(parent_modelgrid.ycellcenters < t)
idomain[:, isinset] = 0
idomain[:, pi0:pi1+1, pj0:pj1+1] = 0
return idomain


Expand Down
Loading

0 comments on commit c67df40

Please sign in to comment.