Skip to content

Commit b27647c

Browse files
author
Rusty Holleman
committed
ugrid plot bug, openfoam extents bug
1 parent cb7ba89 commit b27647c

File tree

2 files changed

+28
-5
lines changed

2 files changed

+28
-5
lines changed

stompy/grid/unstructured_grid.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,8 +6026,12 @@ def plot_cells(self,ax=None,mask=None,values=None,clip=None,centers=False,labele
60266026
for c in np.nonzero(mask)[0]]
60276027
if not isinstance(centroid,np.ndarray) and centroid:
60286028
# override with representative point
6029-
xy = np.concatenate( [geometry.Polygon(poly).representative_point().coords
6030-
for poly in plot_polys])
6029+
# Note: xy is expected to be for all cells, and may be
6030+
# a shared array coming into this point...
6031+
# Not the most efficient.
6032+
xy=xy.copy()
6033+
xy[mask] = np.concatenate( [geometry.Polygon(poly).representative_point().coords
6034+
for poly in plot_polys])
60316035

60326036
coll = PolyCollection(plot_polys,**kwargs)
60336037
ax.add_collection(coll)

stompy/model/openfoam/depth_average.py

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def read_cell_bbox(self, proc=None, calc_volume=False):
242242
if calc_volume:
243243
VolCell_all = np.empty(owner.nb_cell, dtype=float)
244244

245-
# bounds of each cell, xxyyzz
245+
# bounds of each cell, xxyyzz, in original OF reference frame
246246
cell_bounds = np.full( (owner.nb_cell,6), np.nan )
247247

248248
for i in range(owner.nb_cell):
@@ -267,8 +267,10 @@ def read_cell_bbox(self, proc=None, calc_volume=False):
267267

268268
def set_raster_parameters(self,dx,dy=None,xxyy=None):
269269
if xxyy is None:
270+
# Note this pulls the z coordinate for bounds which
271+
# we implicitly convert to y.
270272
xxyy = [self.bboxes[:,0].min(),self.bboxes[:,1].max(),
271-
self.bboxes[:,2].min(),self.bboxes[:,3].max()]
273+
self.bboxes[:,4].min(),self.bboxes[:,5].max()]
272274
self.raster_xxyy = xxyy
273275
if dx<0:
274276
dx=int((xxyy[1] - xxyy[0])/-dx)
@@ -310,6 +312,7 @@ def precalc_raster_info_bbox(self,fld):
310312
for row in utils.progress(range(fld.shape[0])):
311313
ymin=fld_y[row]-fld.dy/2
312314
ymax=fld_y[row]+fld.dy/2
315+
# Note implicit z->y change of coodinates
313316
dy = (np.minimum(ymax,self.bboxes[:,5]) - np.maximum(ymin,self.bboxes[:,4])).clip(0)
314317
for col in range(fld.shape[1]):
315318
pix = row*fld.shape[1] + col # row-major ordering of pixels
@@ -673,7 +676,7 @@ def precalc_raster_weights_proc(meshpath, fld, precision=15, force=False):
673676
pnts[:,1].max(),
674677
pnts[:,2].min(),
675678
pnts[:,2].max()]
676-
bboxes[cIdx] = xxyyzz
679+
bboxes[cIdx] = xxyyzz # OF native reference frame
677680

678681
raster_weights = sparse.dok_matrix((fld.F.shape[0]*fld.F.shape[1],
679682
bboxes.shape[0]),
@@ -740,6 +743,22 @@ def cell_as_edges(cIdx, cell_faces, facefile, pointfile):
740743
return edges
741744

742745

746+
def cell_center_py(cell_faces, facefile, pointfile):
747+
assert False,"Not ready"
748+
# HERE - process as full mesh, not one cell at a time
749+
# facefile....
750+
# replicate cell center calculation
751+
xyz=pointfile.values.reshape([-1,3])
752+
faces=[] # [N,{xyz}] array per face
753+
for fIdx in cell_faces[cIdx]:
754+
face_nodes = facefile.faces[fIdx]["id_pts"][:]
755+
face = xyz[list(face_nodes)]
756+
faces.append(face)
757+
758+
# HERE:
759+
return
760+
761+
743762

744763
if __name__ == '__main__':
745764
import matplotlib.pyplot as plt

0 commit comments

Comments
 (0)