Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix plotting of individual universe levels. #1651

Merged
merged 6 commits into from Sep 4, 2020

Conversation

pshriwise
Copy link
Contributor

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

void
PropertyData::set_value(size_t y, size_t x, const Particle& p, int level) {
Cell* c = model::cells[p.coord_[level].cell].get();
data_(y,x,0) = (p.sqrtkT_ * p.sqrtkT_) / K_BOLTZMANN;
if (c->type_ != Fill::UNIVERSE && p.material_ != MATERIAL_VOID) {
Material* m = model::materials[p.material_].get();
data_(y,x,1) = m->density_gpcc_;
}
}

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 the openmc.lib module to allow our plotting application to correctly populate the number of available universe levels.

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @pshriwise!

@paulromano paulromano merged commit 342ccf9 into openmc-dev:develop Sep 4, 2020
@pshriwise pshriwise deleted the fix_plot_levels branch November 16, 2021 22:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants