Skip to content

Commit

Permalink
turns out rounding is sufficient, no need for final filtering step
Browse files Browse the repository at this point in the history
  • Loading branch information
wpbonelli committed May 2, 2024
1 parent f1697a1 commit 79d9bb0
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 34 deletions.
19 changes: 7 additions & 12 deletions autotest/test_gridgen.py
Expand Up @@ -888,10 +888,8 @@ def test_flopy_issue_1492(function_tmpdir):
)
og_grid = gwf.modelgrid

# Create and build the gridgen model with a refined area in the middle
# Create and build the gridgen model
g = Gridgen(dis, model_ws=function_tmpdir)
# polys = [Polygon([(4, 4), (6, 4), (6, 6), (4, 6)])]
# g.add_refinement_features(polys, "polygon", 3, range(nlay))
g.build()

# retrieve a dictionary of arguments to be passed
Expand Down Expand Up @@ -935,19 +933,16 @@ def test_flopy_issue_1492(function_tmpdir):
success, _ = sim.run_simulation(silent=False)
assert success

head = gwf.output.head().get_data()
bud = gwf.output.budget()
spdis = bud.get_data(text="DATA-SPDIS")[0]
# debugging duplicate vertices
grid = gwf.modelgrid
og_verts = pd.DataFrame(
og_grid.verts, columns=["x", "y"]
) # .round(3).sort_values(by=["x", "y"], ignore_index=True).drop_duplicates(ignore_index=True)
mg_verts = pd.DataFrame(
grid.verts, columns=["x", "y"]
) # .round(3).sort_values(by=["x", "y"], ignore_index=True).drop_duplicates(ignore_index=True)
og_verts = pd.DataFrame(og_grid.verts, columns=["x", "y"])
mg_verts = pd.DataFrame(grid.verts, columns=["x", "y"])

plot_debug = False
if plot_debug:
head = gwf.output.head().get_data()
bud = gwf.output.budget()
spdis = bud.get_data(text="DATA-SPDIS")[0]
pmv = flopy.plot.PlotMapView(gwf)
pmv.plot_array(head)
pmv.plot_grid(colors="white")
Expand Down
25 changes: 6 additions & 19 deletions flopy/utils/cvfdutil.py
Expand Up @@ -183,7 +183,10 @@ def to_cvfd(
xcyc[icell, 1] = yc
ivertlist = []
for p in points:
pt = (round(p[0], 9), round(p[1], 9))
pt = (
round(p[0], duplicate_decimals),
round(p[1], duplicate_decimals),
)
if pt in vertexdict:
ivert = vertexdict[pt]
else:
Expand Down Expand Up @@ -247,24 +250,8 @@ def to_cvfd(
if verbose:
print("Done checking for hanging nodes.")

# drop duplicate vertices
def filter_verts():
return (
pd.DataFrame(np.array(vertexdict_keys), columns=["x", "y"])
.round(duplicate_decimals)
.drop_duplicates(["x", "y"], ignore_index=False)
.to_numpy()
)

verts = filter_verts()

def filter_iverts():
vtups = [tuple(v) for v in verts.tolist()]
vdict = {k: v for k, v in vertexdict.items() if k in vtups}
for vl in vertexlist:
yield [v for v in vl if v in vdict.values()]

iverts = list(filter_iverts())
verts = np.array(vertexdict_keys)
iverts = vertexlist

return verts, iverts

Expand Down
4 changes: 1 addition & 3 deletions flopy/utils/gridgen.py
Expand Up @@ -1891,9 +1891,7 @@ def _mkvertdict(self):
idx = attributes.index("nodenumber")
for i in range(len(shapes)):
nodenumber = int(records[i][idx]) - 1
points = shapes[i].points
# import pdb; pdb.set_trace()
self._vertdict[nodenumber] = points
self._vertdict[nodenumber] = shapes[i].points

@staticmethod
def read_qtg_nod(
Expand Down

0 comments on commit 79d9bb0

Please sign in to comment.