Skip to content

Commit ca91c82

Browse files
committed
Further simplifications
1 parent 58e531c commit ca91c82

2 files changed

Lines changed: 11 additions & 17 deletions

File tree

openmc_plotter/plotgui.py

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,10 @@ def getIDinfo(self, event):
310310
and 0 <= xPos and xPos < self.model.currentView.h_res:
311311
cell_id = int(self.model.cell_ids[yPos, xPos])
312312
mat_id = int(self.model.mat_ids[yPos, xPos])
313-
id = self._domainId(cell_id, mat_id)
313+
if cell_id < _OVERLAP:
314+
id = cell_id
315+
else:
316+
id = cell_id if self.model.currentView.colorby == 'cell' else mat_id
314317
instance = self.model.instances[yPos, xPos]
315318
temp = "{:g}".format(self.model.property_data[yPos, xPos, 0])
316319
density = "{:g}".format(self.model.property_data[yPos, xPos, 1])
@@ -338,13 +341,6 @@ def getIDinfo(self, event):
338341

339342
return id, instance, properties, domain, domain_kind
340343

341-
def _domainId(self, cell_id, mat_id):
342-
if self.model.currentView.colorby != 'cell':
343-
return mat_id
344-
if cell_id == _OVERLAP and mat_id < _OVERLAP:
345-
return mat_id
346-
return cell_id
347-
348344
def _cellLabel(self, cell_id):
349345
try:
350346
name = self.model.activeView.cells[cell_id].name
@@ -357,10 +353,10 @@ def _overlapInfo(self, id):
357353
return "OVERLAP"
358354

359355
overlap_idx = int(_OVERLAP - int(id) - 1)
360-
if overlap_idx not in self.model.overlap_map:
356+
if not 0 <= overlap_idx < len(self.model.overlap_info):
361357
return "OVERLAP (unknown region)"
362358

363-
universe, cell1, cell2 = self.model.overlap_map[overlap_idx]
359+
universe, cell1, cell2 = self.model.overlap_info[overlap_idx]
364360
label1 = self._cellLabel(cell1)
365361
label2 = self._cellLabel(cell2)
366362
return f"OVERLAP: Universe {universe}, Cells {label1} and {label2}"

openmc_plotter/plotmodel.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ def __init__(self, use_settings_pkl, model_path, default_res):
325325
self.map_view_params = None
326326

327327
# Map to be populated by overlap functions
328-
self.overlap_map = {}
328+
self.overlap_info = None
329329

330330
self.version = __version__
331331

@@ -533,16 +533,14 @@ def makePlot(self, view: Optional["PlotView"] = None,
533533
filter=filter_cpp,
534534
)
535535
self.map_view_params = self.view_params_payload(view)
536-
536+
537537
else:
538538
self.geom_data = geom_data
539539
self.property_data = property_data
540540
self.map_view_params = self.view_params_payload(view)
541541

542-
overlap_info, n = openmc.lib.slice_data_overlap_info()
543-
self.overlap_map = {}
544-
for i in range(n):
545-
self.overlap_map[i] = (overlap_info[i*3], overlap_info[i*3+1], overlap_info[i*3+2])
542+
# Get cell overlap information
543+
self.overlap_info = openmc.lib.slice_data_overlap_info()
546544

547545
# update current view
548546
cv = self.currentView = copy.deepcopy(view)
@@ -557,7 +555,7 @@ def makePlot(self, view: Optional["PlotView"] = None,
557555
domain = cv.materials
558556
source = self.modelMaterials
559557

560-
# Normalizes so that domain only sees -3, but
558+
# Normalizes so that domain only sees -3, but
561559
# overlap indices are still available in cell_ids
562560
self.ids[self.ids < _OVERLAP] = _OVERLAP # new line
563561

0 commit comments

Comments
 (0)