mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-27 05:35:49 -04:00
Fix meaning of "masking" for plots (#2510)
This commit is contained in:
parent
4248beff1b
commit
45006584ca
6 changed files with 44 additions and 13 deletions
|
|
@ -270,7 +270,7 @@ class PlotBase(IDManagerMixin):
|
|||
Name of the plot
|
||||
pixels : Iterable of int
|
||||
Number of pixels to use in each direction
|
||||
filename :
|
||||
filename : str
|
||||
Path to write the plot to
|
||||
color_by : {'cell', 'material'}
|
||||
Indicate whether the plot should be colored by cell or by material
|
||||
|
|
@ -279,7 +279,7 @@ class PlotBase(IDManagerMixin):
|
|||
mask_components : Iterable of openmc.Cell or openmc.Material or int
|
||||
The cells or materials (or corresponding IDs) to mask
|
||||
mask_background : Iterable of int or str
|
||||
Color to apply to all cells/materials not listed in mask_components
|
||||
Color to apply to all cells/materials listed in mask_components
|
||||
show_overlaps : bool
|
||||
Indicate whether or not overlapping regions are shown
|
||||
overlap_color : Iterable of int or str
|
||||
|
|
@ -515,7 +515,7 @@ class PlotBase(IDManagerMixin):
|
|||
|
||||
|
||||
class Plot(PlotBase):
|
||||
'''Definition of a finite region of space to be plotted.
|
||||
"""Definition of a finite region of space to be plotted.
|
||||
|
||||
OpenMC is capable of generating two-dimensional slice plots, or
|
||||
three-dimensional voxel or projection plots. Colors that are used in plots can be given as
|
||||
|
|
@ -531,6 +531,33 @@ class Plot(PlotBase):
|
|||
|
||||
Attributes
|
||||
----------
|
||||
id : int
|
||||
Unique identifier
|
||||
name : str
|
||||
Name of the plot
|
||||
pixels : Iterable of int
|
||||
Number of pixels to use in each direction
|
||||
filename : str
|
||||
Path to write the plot to
|
||||
color_by : {'cell', 'material'}
|
||||
Indicate whether the plot should be colored by cell or by material
|
||||
background : Iterable of int or str
|
||||
Color of the background
|
||||
mask_components : Iterable of openmc.Cell or openmc.Material or int
|
||||
The cells or materials (or corresponding IDs) to mask
|
||||
mask_background : Iterable of int or str
|
||||
Color to apply to all cells/materials listed in mask_components
|
||||
show_overlaps : bool
|
||||
Indicate whether or not overlapping regions are shown
|
||||
overlap_color : Iterable of int or str
|
||||
Color to apply to overlapping regions
|
||||
colors : dict
|
||||
Dictionary indicating that certain cells/materials should be
|
||||
displayed with a particular color. The keys can be of type
|
||||
:class:`~openmc.Cell`, :class:`~openmc.Material`, or int (ID for a
|
||||
cell/material).
|
||||
level : int
|
||||
Universe depth to plot at
|
||||
width : Iterable of float
|
||||
Width of the plot in each basis direction
|
||||
origin : tuple or list of ndarray
|
||||
|
|
@ -543,7 +570,7 @@ class Plot(PlotBase):
|
|||
Dictionary defining type, id, linewidth and color of a mesh to be
|
||||
plotted on top of a plot
|
||||
|
||||
'''
|
||||
"""
|
||||
|
||||
def __init__(self, plot_id=None, name=''):
|
||||
super().__init__(plot_id, name)
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ def _get_legend_label(this, type):
|
|||
"""Gets a label for the element or nuclide or material and reaction plotted"""
|
||||
if isinstance(this, str):
|
||||
return f'{this} {type}'
|
||||
elif this.name is '':
|
||||
elif this.name == '':
|
||||
return f'Material {this.id} {type}'
|
||||
else:
|
||||
return f'{this.name} {type}'
|
||||
|
|
|
|||
14
src/plot.cpp
14
src/plot.cpp
|
|
@ -5,8 +5,8 @@
|
|||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "xtensor/xview.hpp"
|
||||
#include "xtensor/xmanipulation.hpp"
|
||||
#include "xtensor/xview.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include <fmt/ostream.h>
|
||||
#ifdef USE_LIBPNG
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
#endif
|
||||
|
||||
#include "openmc/constants.h"
|
||||
#include "openmc/container_util.h"
|
||||
#include "openmc/dagmc.h"
|
||||
#include "openmc/error.h"
|
||||
#include "openmc/file_utils.h"
|
||||
|
|
@ -647,7 +648,7 @@ void PlottableInterface::set_mask(pugi::xml_node plot_node)
|
|||
|
||||
// Alter colors based on mask information
|
||||
for (int j = 0; j < colors_.size(); j++) {
|
||||
if (std::find(iarray.begin(), iarray.end(), j) == iarray.end()) {
|
||||
if (contains(iarray, j)) {
|
||||
if (check_for_node(mask_node, "background")) {
|
||||
vector<int> bg_rgb = get_node_array<int>(mask_node, "background");
|
||||
colors_[j] = bg_rgb;
|
||||
|
|
@ -1306,12 +1307,15 @@ void ProjectionPlot::create_output() const
|
|||
bool inside_cell = false;
|
||||
|
||||
int32_t i_surface = std::abs(p.surface()) - 1;
|
||||
if (i_surface > 0 && model::surfaces[i_surface]->geom_type_ == GeometryType::DAG) {
|
||||
if (i_surface > 0 &&
|
||||
model::surfaces[i_surface]->geom_type_ == GeometryType::DAG) {
|
||||
#ifdef DAGMC
|
||||
int32_t i_cell = next_cell(i_surface, p.cell_last(p.n_coord() - 1), p.lowest_coord().universe);
|
||||
int32_t i_cell = next_cell(i_surface,
|
||||
p.cell_last(p.n_coord() - 1), p.lowest_coord().universe);
|
||||
inside_cell = i_cell >= 0;
|
||||
#else
|
||||
fatal_error("Not compiled for DAGMC, but somehow you have a DAGCell!");
|
||||
fatal_error(
|
||||
"Not compiled for DAGMC, but somehow you have a DAGCell!");
|
||||
#endif
|
||||
} else {
|
||||
inside_cell = exhaustive_find_cell(p);
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
f85c20735a0c08525fe48b19a8e075c074539ee6c8860268fa0cb515d842496b7086e5b94305ef78dcf2106bb193abdf438259ac8ff1d0245a2782eb6f5af873
|
||||
6385d2969ed54d47a09f75112595fc034a16f551346c92d87ed9e7841881baaee8e56190c347e97c3f919ef677bb5b858960d60fe985a00e2848a3bfbef7a12b
|
||||
|
|
@ -1 +1 @@
|
|||
926065ceb2a9b8292fe6270317c38c4373473cfea19d2a8392a32e5ece8e314c04b9f032921d987bd195ae4b6f674d359b0e38302e6ae4c93b4ac9573a384ac6
|
||||
125ce40fbff3e02e7f5f36a92a2e37abce9407154c825b6617242a4685dfc33c63041145b1f3114334338fbb86188331195ddc319ffce58fab2943d8e60f6da3
|
||||
|
|
@ -1 +1 @@
|
|||
6448093f8acaa2af02452ec1b29461ffaf89628bb002cc8873a3a6831fe5d613645a197033597e5a064896388f19d0782f05e78ce474354ae2a76c35ff4551d7
|
||||
24fb0f41ee018ea086962dbd6bcd0b536d11d4b34644bfef4f0e74f8b462fe41a84af39c7ff79046d5d7cfe209084eac54712fa0ec01038e97eb43df1abd0334
|
||||
Loading…
Add table
Add a link
Reference in a new issue