Closed
Description
Describe the bug
The grid intersect routine is timing out on a relatively simple voronoi grid
To Reproduce
This script demonstrates the problem. It creates a simple voronoi grid and plots it. The next block, however, takes 2 mins on my computer, and doesn't finish in a reasonable amount of time if the grid if more finely discretized.
import pathlib as pl
import matplotlib.pyplot as plt
import numpy as np
from shapely.geometry import Polygon, LineString
import flopy
import flopy.utils.triangle
import flopy.utils.voronoi
ws = pl.Path('.')
tempdir = ws / "temp"
tempdir.mkdir(parents=True, exist_ok=True)
theta = np.arange(0.0, 2 * np.pi, 0.1)
radius = 80000.0
xoff = radius
yoff = radius
x = xoff + radius * np.cos(theta)
y = yoff + radius * np.sin(theta)
circle_poly = [(x, y) for x, y in zip(x, y)]
tri = flopy.utils.triangle.Triangle(maximum_area=2500**2, angle=30, model_ws=tempdir)
tri.add_polygon(circle_poly)
tri.build(verbose=False)
# And now for the voronoi grid
voronoi_grid = flopy.utils.voronoi.VoronoiGrid(tri)
fig = plt.figure(figsize=(5, 5))
ax = plt.subplot(1, 1, 1, aspect="equal")
voronoi_grid.plot(ax=ax, facecolor="none")
Now do some intersecting...
modelgrid = flopy.discretization.VertexGrid(**voronoi_grid.get_gridprops_vertexgrid(), nlay=1)
gi = flopy.utils.GridIntersect(modelgrid)
ls = LineString([p for p in circle_poly])
gi.intersects(ls)
Expected behavior
Seems like this intersection should only take a few seconds. Note, that it would be nice to be able to change the maximum_area down to 1000**2.