mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-29 06:35:48 -04:00
Reorganized plotting so colors are stored in Plot objects rather than Cells/Materials, added ability to specify background color, added ability to specify plotting of only a subset of cells
This commit is contained in:
parent
1a9892144c
commit
c639961c9f
7 changed files with 93 additions and 52 deletions
|
|
@ -64,7 +64,6 @@ module geometry_header
|
|||
& surfaces(:) ! List of surfaces bounding cell -- note that
|
||||
! parentheses, union, etc operators will be listed
|
||||
! here too
|
||||
integer, allocatable :: rgb(:) ! plotting color
|
||||
end type Cell
|
||||
|
||||
! array index of universe 0
|
||||
|
|
|
|||
|
|
@ -261,14 +261,6 @@ contains
|
|||
c % material = cell_(i) % material
|
||||
c % fill = cell_(i) % fill
|
||||
|
||||
! Set plot color
|
||||
if (plotting) then
|
||||
allocate(c % rgb(3))
|
||||
c % rgb(1) = prn()*255
|
||||
c % rgb(2) = prn()*255
|
||||
c % rgb(3) = prn()*255
|
||||
end if
|
||||
|
||||
! Check to make sure that either material or fill was specified
|
||||
if (c % material == 0 .and. c % fill == 0) then
|
||||
message = "Neither material nor fill was specified for cell " // &
|
||||
|
|
@ -539,14 +531,6 @@ contains
|
|||
! Copy material id
|
||||
m % id = material_(i) % id
|
||||
|
||||
! Set plot color
|
||||
if (plotting) then
|
||||
allocate(m % rgb(3))
|
||||
m % rgb(1) = prn()*255
|
||||
m % rgb(2) = prn()*255
|
||||
m % rgb(3) = prn()*255
|
||||
end if
|
||||
|
||||
! Copy density -- the default value for the units is given in the
|
||||
! material_t.xml file and doesn't need to be specified here, hence case
|
||||
! default results in an error.
|
||||
|
|
@ -1143,6 +1127,7 @@ contains
|
|||
pl % id = plot_(i) % id
|
||||
pl % aspect = plot_(i) % aspect
|
||||
|
||||
! Copy plot pixel size
|
||||
if (size(plot_(i) % pixels) == 2) then
|
||||
pl % pixels = plot_(i) % pixels
|
||||
else
|
||||
|
|
@ -1150,17 +1135,18 @@ contains
|
|||
call fatal_error()
|
||||
end if
|
||||
|
||||
select case (plot_(i) % color)
|
||||
case ("cell")
|
||||
pl % color = PLOT_COLOR_CELLS
|
||||
case ("mat")
|
||||
pl % color = PLOT_COLOR_MATS
|
||||
case default
|
||||
message = "Unsupported plot color '" // plot_(i) % color &
|
||||
// "' in plot " // trim(to_str(pl % id))
|
||||
! Copy plot background color
|
||||
if (size(plot_(i) % background) == 3) then
|
||||
pl % not_found % rgb = plot_(i) % background
|
||||
else if (size(plot_(i) % background) == 0) then
|
||||
pl % not_found % rgb = (/ 0, 0, 0 /)
|
||||
else
|
||||
message = "Bad background RGB " &
|
||||
// "in plot " // trim(to_str(pl % id))
|
||||
call fatal_error()
|
||||
end select
|
||||
end if
|
||||
|
||||
! Copy plot type
|
||||
select case (plot_(i) % type)
|
||||
case ("slice")
|
||||
pl % type = PLOT_TYPE_SLICE
|
||||
|
|
@ -1172,6 +1158,7 @@ contains
|
|||
call fatal_error()
|
||||
end select
|
||||
|
||||
! Copy plot basis
|
||||
select case (plot_(i) % basis)
|
||||
case ("xy")
|
||||
pl % basis = PLOT_BASIS_XY
|
||||
|
|
@ -1206,6 +1193,34 @@ contains
|
|||
call fatal_error()
|
||||
end if
|
||||
|
||||
! Copy plot color type and initialize all colors randomly
|
||||
select case (plot_(i) % color)
|
||||
case ("cell")
|
||||
|
||||
pl % color_by = PLOT_COLOR_CELLS
|
||||
allocate(pl % colors(n_cells))
|
||||
do j = 1, n_cells
|
||||
pl % colors(j) % rgb(1) = prn()*255
|
||||
pl % colors(j) % rgb(2) = prn()*255
|
||||
pl % colors(j) % rgb(3) = prn()*255
|
||||
end do
|
||||
|
||||
case ("mat")
|
||||
|
||||
pl % color_by = PLOT_COLOR_MATS
|
||||
allocate(pl % colors(n_materials))
|
||||
do j = 1, n_materials
|
||||
pl % colors(j) % rgb(1) = prn()*255
|
||||
pl % colors(j) % rgb(2) = prn()*255
|
||||
pl % colors(j) % rgb(3) = prn()*255
|
||||
end do
|
||||
|
||||
case default
|
||||
message = "Unsupported plot color type '" // plot_(i) % color &
|
||||
// "' in plot " // trim(to_str(pl % id))
|
||||
call fatal_error()
|
||||
end select
|
||||
|
||||
! Copy user specified colors
|
||||
n_cols = size(plot_(i) % col_spec_)
|
||||
do j = 1, n_cols
|
||||
|
|
@ -1217,24 +1232,20 @@ contains
|
|||
|
||||
col_id = plot_(i) % col_spec_(j) % id
|
||||
|
||||
if (pl % color == PLOT_COLOR_CELLS) then
|
||||
if (pl % color_by == PLOT_COLOR_CELLS) then
|
||||
|
||||
if (dict_has_key(cell_dict, col_id)) then
|
||||
cells(col_id) % rgb(1) = plot_(i) % col_spec_(j) % rgb(1)
|
||||
cells(col_id) % rgb(2) = plot_(i) % col_spec_(j) % rgb(2)
|
||||
cells(col_id) % rgb(3) = plot_(i) % col_spec_(j) % rgb(3)
|
||||
pl % colors(col_id) % rgb = plot_(i) % col_spec_(j) % rgb
|
||||
else
|
||||
message = "Could not find cell " // trim(to_str(col_id)) // &
|
||||
" specified in plot " // trim(to_str(pl % id))
|
||||
call fatal_error()
|
||||
end if
|
||||
|
||||
else if (pl % color == PLOT_COLOR_MATS) then
|
||||
else if (pl % color_by == PLOT_COLOR_MATS) then
|
||||
|
||||
if (dict_has_key(material_dict, col_id)) then
|
||||
materials(col_id) % rgb(1) = plot_(i) % col_spec_(j) % rgb(1)
|
||||
materials(col_id) % rgb(2) = plot_(i) % col_spec_(j) % rgb(2)
|
||||
materials(col_id) % rgb(3) = plot_(i) % col_spec_(j) % rgb(3)
|
||||
pl % colors(col_id) % rgb = plot_(i) % col_spec_(j) % rgb
|
||||
else
|
||||
message = "Could not find material " // trim(to_str(col_id)) // &
|
||||
" specified in plot " // trim(to_str(pl % id))
|
||||
|
|
@ -1245,6 +1256,22 @@ contains
|
|||
|
||||
end do
|
||||
|
||||
! Alter colors based on mask information
|
||||
if (size(plot_(i) % mask_) /= 1) then
|
||||
message = "Mutliple masks" // &
|
||||
" specified in plot " // trim(to_str(pl % id))
|
||||
call fatal_error()
|
||||
else
|
||||
do j=1,size(pl % colors)
|
||||
if (.not. any(j .eq. plot_(i) % mask_(1) % components)) then
|
||||
pl % colors(j) % rgb = plot_(i) % mask_(1) % background
|
||||
end if
|
||||
end do
|
||||
end if
|
||||
|
||||
|
||||
|
||||
|
||||
end do
|
||||
|
||||
end subroutine read_plots_xml
|
||||
|
|
|
|||
|
|
@ -21,8 +21,6 @@ module material_header
|
|||
character(12) :: sab_name ! name of S(a,b) table
|
||||
integer :: sab_table = 0 ! index in sab_tables
|
||||
integer :: sab_nuclide = 0 ! index of nuclide which has S(a,b) table
|
||||
|
||||
integer, allocatable :: rgb(:) ! plotting color
|
||||
end type Material
|
||||
|
||||
end module material_header
|
||||
|
|
|
|||
|
|
@ -914,7 +914,7 @@ contains
|
|||
|
||||
write(ou,100) "Width:", trim(to_str(pl % width(1))) // &
|
||||
" " // trim(to_str(pl % width(2)))
|
||||
write(ou,100) "Coloring:", trim(to_str(pl % color))
|
||||
write(ou,100) "Coloring:", trim(to_str(pl % color_by))
|
||||
write(ou,100) "Basis:", trim(to_str(pl % basis))
|
||||
write(ou,100) "Pixels:", trim(to_str(pl % pixels(1))) // " " // &
|
||||
trim(to_str(pl % pixels(2)))
|
||||
|
|
@ -924,7 +924,7 @@ contains
|
|||
write(ou,100) "Width:", trim(to_str(pl % width(1))) // &
|
||||
" " // trim(to_str(pl % width(2))) // " " &
|
||||
// trim(to_str(pl % width(3)))
|
||||
write(ou,100) "Coloring:", trim(to_str(pl % color))
|
||||
write(ou,100) "Coloring:", trim(to_str(pl % color_by))
|
||||
write(ou,100) "Ray Spacing:", trim(to_str(pl % aspect))
|
||||
|
||||
end if
|
||||
|
|
|
|||
24
src/plot.F90
24
src/plot.F90
|
|
@ -106,19 +106,19 @@ contains
|
|||
call find_cell(found_cell)
|
||||
|
||||
if (.not. found_cell) then
|
||||
r = 255
|
||||
g = 255
|
||||
b = 255
|
||||
r = pl % not_found % rgb(1)
|
||||
g = pl % not_found % rgb(2)
|
||||
b = pl % not_found % rgb(3)
|
||||
else
|
||||
c => cells(p % coord % cell)
|
||||
if (pl % color == PLOT_COLOR_MATS) then
|
||||
r = materials(c % material) % rgb(1)
|
||||
g = materials(c % material) % rgb(2)
|
||||
b = materials(c % material) % rgb(3)
|
||||
else if (pl % color == PLOT_COLOR_CELLS) then
|
||||
r = c % rgb(1)
|
||||
g = c % rgb(2)
|
||||
b = c % rgb(3)
|
||||
if (pl % color_by == PLOT_COLOR_MATS) then
|
||||
c => cells(p % coord % cell)
|
||||
r = pl % colors(c % material) % rgb(1)
|
||||
g = pl % colors(c % material) % rgb(2)
|
||||
b = pl % colors(c % material) % rgb(3)
|
||||
else if (pl % color_by == PLOT_COLOR_CELLS) then
|
||||
r = pl % colors(p % coord % cell) % rgb(1)
|
||||
g = pl % colors(p % coord % cell) % rgb(2)
|
||||
b = pl % colors(p % coord % cell) % rgb(3)
|
||||
else
|
||||
r = 0
|
||||
g = 0
|
||||
|
|
|
|||
|
|
@ -3,18 +3,28 @@ module plot_header
|
|||
implicit none
|
||||
|
||||
!===============================================================================
|
||||
! PLOT hold plot information
|
||||
! ObjectColor holds color information for plotted objects
|
||||
!===============================================================================
|
||||
|
||||
type ObjectColor
|
||||
integer :: rgb(3)
|
||||
end type ObjectColor
|
||||
|
||||
!===============================================================================
|
||||
! PLOT holds plot information
|
||||
!===============================================================================
|
||||
|
||||
type Plot
|
||||
integer :: id ! Unique ID
|
||||
integer :: type ! Type
|
||||
integer :: color ! quantity to color regions by
|
||||
integer :: color_by ! quantity to color regions by
|
||||
real(8) :: origin(3) ! xyz center of plot location
|
||||
real(8) :: aspect ! spacing between rays in raytracer
|
||||
real(8) :: width(3) ! xyz widths of plot
|
||||
integer :: basis ! direction of plot slice
|
||||
integer :: pixels(2) ! pixel width/height of plot slice
|
||||
type(ObjectColor) :: not_found ! color for positions where no cell found
|
||||
type(ObjectColor),allocatable :: colors(:) ! colors of cells/mats
|
||||
end type Plot
|
||||
|
||||
integer :: PLOT_TYPE_SLICE = 1
|
||||
|
|
|
|||
|
|
@ -8,6 +8,11 @@
|
|||
<component name="rgb" type="integer-array" />
|
||||
</typedef>
|
||||
|
||||
<typedef name="mask_xml">
|
||||
<component name="components" type="integer-array" />
|
||||
<component name="background" type="integer-array" />
|
||||
</typedef>
|
||||
|
||||
<typedef name="plot_xml">
|
||||
<component name="id" type="integer" />
|
||||
<component name="type" type="word" length="10" default="'slice'"/>
|
||||
|
|
@ -17,7 +22,9 @@
|
|||
<component name="basis" type="word" length="3" default="'xy'" />
|
||||
<component name="pixels" type="integer-array" />
|
||||
<component name="aspect" type="double" default="0.1" />
|
||||
<component name="background" type="integer-array"/>
|
||||
<component name="col_spec_" tag="col_spec" type="col_spec_xml" dimension="1" />
|
||||
<component name="mask_" tag="mask" type="mask_xml" dimension="1" />
|
||||
</typedef>
|
||||
|
||||
<variable name="plot_" tag="plot" type="plot_xml" dimension="1" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue