From 9168b3a538a5f604010ad5df17ea7e868b8f913f Mon Sep 17 00:00:00 2001 From: Joshua Larsen Date: Fri, 14 Jul 2023 14:03:44 -0700 Subject: [PATCH] update(_set_neighbors): check for closed iverts and remove closing ivert (#1876) --- flopy/discretization/grid.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/flopy/discretization/grid.py b/flopy/discretization/grid.py index 428873846..5da4c9aa6 100644 --- a/flopy/discretization/grid.py +++ b/flopy/discretization/grid.py @@ -560,6 +560,8 @@ def _set_neighbors(self, reset=False, method="rook"): node_nums = [] if method == "rook": for poly in self.iverts: + if poly[0] == poly[-1]: + poly = poly[:-1] for v in range(len(poly)): geoms.append(tuple(sorted([poly[v - 1], poly[v]]))) node_nums += [node_num] * len(poly) @@ -567,6 +569,8 @@ def _set_neighbors(self, reset=False, method="rook"): else: # queen neighbors for poly in self.iverts: + if poly[0] == poly[-1]: + poly = poly[:-1] for vert in poly: geoms.append(vert) node_nums += [node_num] * len(poly)