Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions autotest/t080_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import os
import platform
import numpy as np

try:
from shapely.geometry import Polygon
Expand Down Expand Up @@ -128,5 +129,57 @@ def test_mfusg():
return


def test_usg_iverts():
iverts = [
[4, 3, 2, 1, 0, None],
[7, 0, 1, 6, 5, None],
[11, 10, 9, 8, 2, 3],
[1, 6, 13, 12, 8, 2],
[15, 14, 13, 6, 5, None],
[10, 9, 18, 17, 16, None],
[8, 12, 20, 19, 18, 9],
[22, 14, 13, 12, 20, 21],
[24, 17, 18, 19, 23, None],
[21, 20, 19, 23, 25, None]
]
verts = [
[0.0, 22.5],
[5.1072, 22.5],
[7.5, 24.0324],
[7.5, 30.0],
[0.0, 30.0],
[0.0, 7.5],
[4.684, 7.5],
[0.0, 15.0],
[14.6582, 21.588],
[22.5, 24.3766],
[22.5, 30.0],
[15.0, 30.0],
[15.3597, 8.4135],
[7.5, 5.6289],
[7.5, 0.0],
[0.0, 0.0],
[30.0, 30.0],
[30.0, 22.5],
[25.3285, 22.5],
[24.8977, 7.5],
[22.5, 5.9676],
[22.5, 0.0],
[15.0, 0.0],
[30.0, 7.5],
[30.0, 15.0],
[30.0, 0.0]
]

grid = flopy.discretization.UnstructuredGrid(
verts, iverts, ncpl=[len(iverts)]
)

iverts = grid.iverts
if any(None in l for l in iverts):
raise ValueError("None type should not be returned in iverts list")


if __name__ == "__main__":
test_mfusg()
test_usg_iverts()
5 changes: 3 additions & 2 deletions flopy/discretization/unstructuredgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ def nvert(self):

@property
def iverts(self):
return self._iverts
if self._iverts is not None:
return [list(filter((None).__ne__, i)) for i in self._iverts]

@property
def verts(self):
Expand Down Expand Up @@ -559,7 +560,7 @@ def _build_grid_geometry_info(self):
yvertices = []

# build xy vertex and cell center info
for iverts in self._iverts:
for iverts in self.iverts:

xcellvert = []
ycellvert = []
Expand Down
25 changes: 18 additions & 7 deletions flopy/discretization/vertexgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,20 @@ def nvert(self):

@property
def iverts(self):
return [[t[0]] + list(t)[4:] for t in self._cell2d]
if self._cell2d is not None:
return [[t[0]] + list(t)[4:] for t in self.cell2d]
elif self._cell1d is not None:
return [[t[0]] + list(t)[3:] for t in self.cell1d]

@property
def cell1d(self):
if self._cell1d is not None:
return [list(filter((None).__ne__, t)) for t in self._cell1d]

@property
def cell2d(self):
if self._cell2d is not None:
return [list(filter((None).__ne__, t)) for t in self._cell2d]

@property
def verts(self):
Expand Down Expand Up @@ -342,16 +355,15 @@ def _build_grid_geometry_info(self):
zcenters = []
zvertices = []
vertexdict = {v[0]: [v[1], v[2], v[3]] for v in self._vertices}
for cell1d in self._cell1d:
for cell1d in self.cell1d:
cell1d = tuple(cell1d)
xcenters.append(cell1d[1])
ycenters.append(cell1d[2])
zcenters.append(cell1d[3])

vert_number = []
for i in cell1d[3:]:
if i is not None:
vert_number.append(int(i))
vert_number.append(int(i))

xcellvert = []
ycellvert = []
Expand All @@ -367,15 +379,14 @@ def _build_grid_geometry_info(self):
else:
vertexdict = {v[0]: [v[1], v[2]] for v in self._vertices}
# build xy vertex and cell center info
for cell2d in self._cell2d:
for cell2d in self.cell2d:
cell2d = tuple(cell2d)
xcenters.append(cell2d[1])
ycenters.append(cell2d[2])

vert_number = []
for i in cell2d[4:]:
if i is not None:
vert_number.append(int(i))
vert_number.append(int(i))

xcellvert = []
ycellvert = []
Expand Down
2 changes: 0 additions & 2 deletions flopy/utils/gridintersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ def ignore_shapely_warnings_for_object_array():
)
yield


elif SHAPELY_LT_18 and NUMPY_GE_121:

@contextlib.contextmanager
Expand All @@ -58,7 +57,6 @@ def ignore_shapely_warnings_for_object_array():
)
yield


else:

@contextlib.contextmanager
Expand Down