diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 92b8d89b3..869d75989 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -41,8 +41,7 @@ namespace openmc { // ObjectColor holds color information for plotted objects //=============================================================================== - class ObjectColor { - public: + struct ObjectColor { int rgb[3]; }; @@ -50,8 +49,7 @@ namespace openmc { // ObjectPlot holds plot information //=============================================================================== - class ObjectPlot { - public: + struct ObjectPlot { int id; int type; int color_by; diff --git a/src/plot.F90 b/src/plot.F90 index d2ebab166..2bf390540 100644 --- a/src/plot.F90 +++ b/src/plot.F90 @@ -30,11 +30,11 @@ module plot import Particle, ObjectPlot, C_INT type(Particle), intent(inout) :: p type(ObjectPlot), intent(in) :: pl - integer(C_INT), intent(inout) :: rgb(3) - integer(C_INT), intent(inout) :: id + integer(C_INT), intent(out) :: rgb(3) + integer(C_INT), intent(out) :: id end subroutine position_rgb end interface - + contains !=============================================================================== @@ -65,62 +65,6 @@ contains err = 0 end function openmc_plot_geometry -!=============================================================================== -! POSITION_RGB computes the red/green/blue values for a given plot with the -! current particle's position -!=============================================================================== - - ! subroutine position_rgb(p, pl, rgb, id) - ! type(Particle), intent(inout) :: p - ! type(ObjectPlot), intent(in) :: pl - ! integer, intent(out) :: rgb(3) - ! integer, intent(out) :: id - - ! integer :: j - ! logical :: found_cell - - ! p % n_coord = 1 - - ! call find_cell(p, found_cell) - ! j = p % n_coord - ! if (check_overlaps) call check_cell_overlap(p) - - ! ! Set coordinate level if specified - ! if (pl % level >= 0) j = pl % level + 1 - - ! if (.not. found_cell) then - ! ! If no cell, revert to default color - ! rgb = pl % not_found % rgb - ! id = -1 - ! else - ! if (pl % color_by == PLOT_COLOR_MATS) then - ! ! Assign color based on material - ! associate (c => cells(p % coord(j) % cell + 1)) - ! if (c % type() == FILL_UNIVERSE) then - ! ! If we stopped on a middle universe level, treat as if not found - ! rgb = pl % not_found % rgb - ! id = -1 - ! else if (p % material == MATERIAL_VOID) then - ! ! By default, color void cells white - ! rgb = 255 - ! id = -1 - ! else - ! rgb = pl % colors(p % material) % rgb - ! id = materials(p % material) % id() - ! end if - ! end associate - ! else if (pl % color_by == PLOT_COLOR_CELLS) then - ! ! Assign color based on cell - ! rgb = pl % colors(p % coord(j) % cell + 1) % rgb - ! id = cells(p % coord(j) % cell + 1) % id() - ! else - ! rgb = 0 - ! id = -1 - ! end if - ! end if - - ! end subroutine position_rgb - !=============================================================================== ! CREATE_PPM creates an image based on user input from a plots.xml ! specification in the portable pixmap format (PPM) @@ -187,7 +131,6 @@ contains ! get pixel color call position_rgb(p, pl, rgb, id) - ! Create a pixel at (x,y) with color (r,g,b) data(:, x, y) = rgb end do @@ -436,7 +379,6 @@ contains do z = 1, pl % pixels(3) ! get voxel color call position_rgb(p, pl, rgb, id) - ! write to plot file data(z,y) = id diff --git a/src/plot.cpp b/src/plot.cpp index 0af83f154..a9db10fcb 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -19,18 +19,18 @@ const int NULLRGB[3] = {0, 0, 0}; //=============================================================================== // RUN_PLOT controls the logic for making one or many plots //=============================================================================== - + int openmc_plot_geometry() { int err; for(auto i : n_plots) { ObjectPlot* pl = plots[i]; - + std::stringstream ss; ss << "Processing plot " << pl->id << ": " << pl->path_plot << "..."; write_message(ss.str(), 5); - + if (pl->type == PLOT_TYPE::SLICE) { // create 2D image // create_ppm(pl); @@ -40,9 +40,9 @@ int openmc_plot_geometry() { // create_voxel(pl); continue; } - + } - + return 0; } @@ -110,7 +110,7 @@ void create_ppm(ObjectPlot* pl) { } //output_ppm(pl, data); - + } //=============================================================================== @@ -130,13 +130,15 @@ void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id) { if (settings::check_overlaps) { check_cell_overlap(p); } // Set coordinate level if specified - if (pl->level >= 0) j = pl->level + 1; + if (pl->level >= 0) {j = pl->level + 1;} Cell* c; if (!found_cell) { // If no cell, revert to default color - rgb = pl->not_found.rgb; + std::copy(pl->not_found.rgb, + pl->not_found.rgb + 3, + rgb); id = -1; } else { if (pl->color_by = PLOT_COLOR_BY::MATS) { @@ -144,32 +146,33 @@ void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id) { c = cells[p->coord[j].cell]; if (c->type_ == FILL_UNIVERSE) { // If we stopped on a middle universe level, treat as if not found - rgb = pl->not_found.rgb; + std::copy(pl->not_found.rgb, + pl->not_found.rgb + 3, + rgb); id = -1; } else if (p->material == MATERIAL_VOID) { // By default, color void cells white std::copy(WHITE, WHITE+3, rgb); id = -1; } else { - std::copy(pl->colors[p->material].rgb, - pl->colors[p->material].rgb + 3, + std::copy(pl->colors[p->material - 1].rgb, + pl->colors[p->material - 1].rgb + 3, rgb); - id = materials[p->material]->id; + id = materials[p->material - 1]->id; } } else if (pl->color_by == PLOT_COLOR_BY::CELLS) { // Assign color based on cell - std::copy(pl->colors[p->coord[j].cell].rgb, - pl->colors[p->coord[j].cell].rgb + 3, + std::copy(pl->colors[p->coord[j].cell - 1].rgb, + pl->colors[p->coord[j].cell - 1].rgb + 3, rgb); - id = cells[p->coord[j].cell]->id_; + id = cells[p->coord[j].cell - 1]->id_; } else { std::copy(NULLRGB, NULLRGB+3, rgb); id = -1; } } // endif found_cell - } void diff --git a/src/plot_header.F90 b/src/plot_header.F90 index e4b9c7feb..ad9aa3525 100644 --- a/src/plot_header.F90 +++ b/src/plot_header.F90 @@ -20,20 +20,20 @@ module plot_header !=============================================================================== type, bind(C) :: ObjectPlot - integer(C_INT) :: id ! Unique ID - integer(C_INT) :: type ! Type - integer(C_INT) :: color_by ! quantity to color regions by - real(C_DOUBLE) :: origin(3) ! xyz center of plot location - real(C_DOUBLE) :: width(3) ! xyz widths of plot - integer(C_INT) :: basis ! direction of plot slice - integer(C_INT) :: pixels(3) ! pixel width/height of plot slice - integer(C_INT) :: meshlines_width ! pixel width of meshlines - integer(C_INT) :: level ! universe depth to plot the cells of - integer(C_INT) :: index_meshlines_mesh = -1 ! index of mesh to plot - type(ObjectColor) :: meshlines_color ! Color for meshlines - type(ObjectColor) :: not_found ! color for positions where no cell found - type(ObjectColor) :: colors(MAX_COORD) ! colors of cells/mats - character(MAX_WORD_LEN) :: path_plot ! path for plot file + integer(C_INT) :: id ! Unique ID + integer(C_INT) :: type ! Type + integer(C_INT) :: color_by ! quantity to color regions by + real(C_DOUBLE) :: origin(3) ! xyz center of plot location + real(C_DOUBLE) :: width(3) ! xyz widths of plot + integer(C_INT) :: basis ! direction of plot slice + integer(C_INT) :: pixels(3) ! pixel width/height of plot slice + integer(C_INT) :: meshlines_width ! pixel width of meshlines + integer(C_INT) :: level ! universe depth to plot the cells of + integer(C_INT) :: index_meshlines_mesh = -1 ! index of mesh to plot + type(ObjectColor) :: meshlines_color ! Color for meshlines + type(ObjectColor) :: not_found ! color for positions where no cell found + type(ObjectColor) :: colors(MAX_COORD) ! colors of cells/mats + character(MAX_WORD_LEN, kind=C_CHAR) :: path_plot ! path for plot file end type ObjectPlot ! Plot type