Fix plotting of individual universe levels. #1651
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempting to plot a specific universe level is risky right now after the changes in #1201. If the universe level is higher than the number of coordinates for the particle at a given pixel location in the image, it's possible that an invalid access in the particle coordinates can occur, resulting in a segfault. The relevant chunk of code is here:
openmc/src/plot.cpp
Lines 63 to 71 in 828e0aa
This PR corrects that by setting any pixel color to
NOT_FOUND
when the coordinate level of the particle is lower than the requested universe level. For density and temperature plots, the particle's coordinate level is always used.This also exposes the
model::n_coord_level
variable in the CAPI and theopenmc.lib
module to allow our plotting application to correctly populate the number of available universe levels.