mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-28 06:05:58 -04:00
Applying C-side implementation of position_rgb.
This commit is contained in:
parent
075473b475
commit
539b9c10ec
4 changed files with 38 additions and 95 deletions
|
|
@ -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;
|
||||
|
|
|
|||
64
src/plot.F90
64
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 <plot>
|
||||
! 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
|
||||
|
||||
|
|
|
|||
35
src/plot.cpp
35
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue