Skip to content

Commit

Permalink
update(VertexGrid): added filter for None types on cell2d
Browse files Browse the repository at this point in the history
  • Loading branch information
jlarsen-usgs committed Dec 8, 2021
1 parent 771a965 commit 4ff0860
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
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: 1 addition & 1 deletion flopy/mf6/mfmodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ def modelgrid(self):
xcenters = None
ycenters = None
else:
iverts = [list(filter((None).__ne__, i))[4:] for i in cell2d]
iverts = [list(i)[4:] for i in cell2d]
xcenters = dis.cell2d.array["xc"]
ycenters = dis.cell2d.array["yc"]
vertices = dis.vertices.array
Expand Down

0 comments on commit 4ff0860

Please sign in to comment.