From 3e787e682a45e329d1e88a2cc4bed6ea19aaed4c Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 10 Feb 2021 13:05:17 -0600 Subject: [PATCH] Adding warning to the openmc-plot-mesh-tally script and ensuring unstructured mesh filters aren't included in the app's combobox. --- scripts/openmc-plot-mesh-tally | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scripts/openmc-plot-mesh-tally b/scripts/openmc-plot-mesh-tally index fad2df4187..2a4fcd7434 100755 --- a/scripts/openmc-plot-mesh-tally +++ b/scripts/openmc-plot-mesh-tally @@ -2,6 +2,7 @@ """Python script to plot tally data generated by OpenMC.""" + import os import sys import argparse @@ -19,11 +20,18 @@ from matplotlib.figure import Figure import matplotlib.pyplot as plt import numpy as np -from openmc import StatePoint, MeshFilter +from openmc import StatePoint, MeshFilter, UnstructuredMesh _COMBOBOX_SELECTED = '<>' +def mesh_filter_check(filter): + """ + Check that the filter is a usable mesh filter + """ + return isinstance(filter, MeshFilter) and not isinstance(filter.mesh, UnstructuredMesh) + + class MeshPlotter(tk.Frame): def __init__(self, parent, filename): super().__init__(parent) @@ -289,10 +297,17 @@ class MeshPlotter(tk.Frame): # Create StatePoint object and read in data self.datafile = StatePoint(filename) + meshes = self.datafile.meshes + if any(isinstance(m, UnstructuredMesh) for m in meshes.values()): + warn_msg = "Unstructured meshes are present in the" \ + " statepoint file but are not currently" \ + " supported by this script" + messagebox.showwarning("Unstructured Meshes", message=warn_msg) + # Find which tallies are mesh tallies self.meshTallies = [] for itally, tally in self.datafile.tallies.items(): - if any([isinstance(f, MeshFilter) for f in tally.filters]): + if any([mesh_filter_check(f) for f in tally.filters]): self.meshTallies.append(itally) if not self.meshTallies: