mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 13:45:36 -04:00
Adding warning to the openmc-plot-mesh-tally script and ensuring unstructured mesh filters aren't included in the app's combobox.
This commit is contained in:
parent
23e6e1b8b4
commit
3e787e682a
1 changed files with 17 additions and 2 deletions
|
|
@ -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 = '<<ComboboxSelected>>'
|
||||
|
||||
|
||||
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue