From 4881f68cb53f6cd56bf22c6feb5fcb0c7806d7b3 Mon Sep 17 00:00:00 2001 From: Eirik Keilegavlen Date: Thu, 4 Jul 2019 10:11:04 +0200 Subject: [PATCH] Minor cleanup of visualization (#287) * Fix missing data type in vtk exporter * Fix plot_grid when ploting grid without values --- src/porepy/viz/exporter.py | 1 + src/porepy/viz/plot_grid.py | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/porepy/viz/exporter.py b/src/porepy/viz/exporter.py index 94fbc9af58..33c054140d 100644 --- a/src/porepy/viz/exporter.py +++ b/src/porepy/viz/exporter.py @@ -74,6 +74,7 @@ def dtype(self): np.dtype("bool"): vtk.VTK_CHAR, np.dtype("int64"): vtk.VTK_INT, np.dtype("float64"): vtk.VTK_DOUBLE, + np.dtype("int32"): vtk.VTK_INT, } return map_type[self.values.dtype] diff --git a/src/porepy/viz/plot_grid.py b/src/porepy/viz/plot_grid.py index c8a1c2d3ca..273c79f4a9 100644 --- a/src/porepy/viz/plot_grid.py +++ b/src/porepy/viz/plot_grid.py @@ -278,11 +278,18 @@ def plot_gb(gb, cell_value, vector_value, info, **kwargs): kwargs["color_map"] = color_map(extr_value) gb.assign_node_ordering() - for g, d in gb: - kwargs["rgb"] = np.divide(kwargs.get("rgb", [1, 0, 0]), d["node_number"] + 1) - plot_grid_xd( - g, d[pp.STATE].get(cell_value), d[pp.STATE].get(vector_value), ax, **kwargs - ) + if cell_value is not None: + for g, d in gb: + kwargs["rgb"] = np.divide( + kwargs.get("rgb", [1, 0, 0]), d["node_number"] + 1 + ) + plot_grid_xd( + g, + d[pp.STATE].get(cell_value), + d[pp.STATE].get(vector_value), + ax, + **kwargs + ) val = np.array([lim(g.nodes) for g, _ in gb])