mirror of
https://github.com/openmc-dev/openmc.git
synced 2026-07-26 13:15:39 -04:00
Merge pull request #340 from nhorelik/plot_level
Support for plotting cells/mats on middle universe levels
This commit is contained in:
commit
296ca14c9b
6 changed files with 61 additions and 12 deletions
|
|
@ -1173,7 +1173,7 @@ implemented in openMC:
|
|||
``<plot>`` Element
|
||||
------------------
|
||||
|
||||
Each plot must contain a combination of the following attributes or
|
||||
Each plot is specified by a combination of the following attributes or
|
||||
sub-elements:
|
||||
|
||||
:id:
|
||||
|
|
@ -1194,6 +1194,18 @@ sub-elements:
|
|||
|
||||
*Default*: ``cell``
|
||||
|
||||
:level:
|
||||
Universe depth to plot at (optional). This parameter controls how many
|
||||
universe levels deep to pull cell and material ids from when setting plot
|
||||
colors. If a given location does not have as many levels as specified,
|
||||
colors will be taken from the lowest level at that lcation. For example, if
|
||||
``level`` is set to zero colors will be taken from top-level (universe zero)
|
||||
cells only. However, if ``level`` is set to 1 colors will be taken from
|
||||
cells in universes that fill top-level fill-cells, and from top-level cells
|
||||
that contain materials.
|
||||
|
||||
*Default*: Whatever the deepest universe is in the model
|
||||
|
||||
:origin:
|
||||
Specifies the (x,y,z) coordinate of the center of the plot. Should be three
|
||||
floats separated by spaces.
|
||||
|
|
|
|||
|
|
@ -2731,16 +2731,14 @@ contains
|
|||
end select
|
||||
|
||||
! Set output file path
|
||||
filename = "plot"
|
||||
filename = trim(to_str(pl % id)) // "_plot"
|
||||
if (check_for_node(node_plot, "filename")) &
|
||||
call get_node_value(node_plot, "filename", filename)
|
||||
select case (pl % type)
|
||||
case (PLOT_TYPE_SLICE)
|
||||
pl % path_plot = trim(path_input) // trim(to_str(pl % id)) // &
|
||||
"_" // trim(filename) // ".ppm"
|
||||
pl % path_plot = trim(path_input) // trim(filename) // ".ppm"
|
||||
case (PLOT_TYPE_VOXEL)
|
||||
pl % path_plot = trim(path_input) // trim(to_str(pl % id)) // &
|
||||
"_" // trim(filename) // ".voxel"
|
||||
pl % path_plot = trim(path_input) // trim(filename) // ".voxel"
|
||||
end select
|
||||
|
||||
! Copy plot pixel size
|
||||
|
|
@ -2820,6 +2818,18 @@ contains
|
|||
end if
|
||||
end if
|
||||
|
||||
! Copy plot cell universe level
|
||||
if (check_for_node(node_plot, "level")) then
|
||||
call get_node_value(node_plot, "level", pl % level)
|
||||
|
||||
if (pl % level < 0) then
|
||||
call fatal_error("Bad universe level in plot " &
|
||||
&// trim(to_str(pl % id)))
|
||||
end if
|
||||
else
|
||||
pl % level = PLOT_LEVEL_LOWEST
|
||||
end if
|
||||
|
||||
! Copy plot color type and initialize all colors randomly
|
||||
temp_str = "cell"
|
||||
if (check_for_node(node_plot, "color")) &
|
||||
|
|
|
|||
|
|
@ -1428,6 +1428,12 @@ contains
|
|||
! Plot id
|
||||
write(ou,100) "Plot ID:", trim(to_str(pl % id))
|
||||
|
||||
! Plot filename
|
||||
write(ou,100) "Plot file:", trim(pl % path_plot)
|
||||
|
||||
! Plot level
|
||||
write(ou,100) "Universe depth:", trim(to_str(pl % level))
|
||||
|
||||
! Plot type
|
||||
if (pl % type == PLOT_TYPE_SLICE) then
|
||||
write(ou,100) "Plot Type:", "Slice"
|
||||
|
|
|
|||
28
src/plot.F90
28
src/plot.F90
|
|
@ -7,7 +7,7 @@ module plot
|
|||
use global
|
||||
use mesh, only: get_mesh_indices
|
||||
use output, only: write_message
|
||||
use particle_header, only: deallocate_coord, Particle
|
||||
use particle_header, only: deallocate_coord, Particle, LocalCoord
|
||||
use plot_header
|
||||
use ppmlib, only: Image, init_image, allocate_image, &
|
||||
deallocate_image, set_pixel
|
||||
|
|
@ -32,7 +32,7 @@ contains
|
|||
|
||||
! Display output message
|
||||
call write_message("Processing plot " // trim(to_str(pl % id)) &
|
||||
&// "...", 5)
|
||||
&// ": " // trim(pl % path_plot) // " ...", 5)
|
||||
|
||||
if (pl % type == PLOT_TYPE_SLICE) then
|
||||
! create 2d image
|
||||
|
|
@ -58,7 +58,9 @@ contains
|
|||
integer, intent(out) :: id
|
||||
|
||||
logical :: found_cell
|
||||
type(Cell), pointer :: c => null()
|
||||
integer :: level
|
||||
type(Cell), pointer :: c => null()
|
||||
type(LocalCoord), pointer :: coord => null()
|
||||
|
||||
call deallocate_coord(p % coord0 % next)
|
||||
p % coord => p % coord0
|
||||
|
|
@ -66,6 +68,16 @@ contains
|
|||
call find_cell(p, found_cell)
|
||||
if (check_overlaps) call check_cell_overlap(p)
|
||||
|
||||
! Loop through universes and stop on any specified level
|
||||
level = 0
|
||||
coord => p % coord0
|
||||
do
|
||||
if (level == pl % level) exit
|
||||
if (.not. associated(coord % next)) exit
|
||||
coord => coord % next
|
||||
level = level + 1
|
||||
end do
|
||||
|
||||
if (.not. found_cell) then
|
||||
! If no cell, revert to default color
|
||||
rgb = pl % not_found % rgb
|
||||
|
|
@ -73,19 +85,23 @@ contains
|
|||
else
|
||||
if (pl % color_by == PLOT_COLOR_MATS) then
|
||||
! Assign color based on material
|
||||
c => cells(p % coord % cell)
|
||||
c => cells(coord % cell)
|
||||
if (c % material == MATERIAL_VOID) then
|
||||
! By default, color void cells white
|
||||
rgb = 255
|
||||
id = -1
|
||||
else if (c % type == CELL_FILL) then
|
||||
! If we stopped on a middle universe level, treat as if not found
|
||||
rgb = pl % not_found % rgb
|
||||
id = -1
|
||||
else
|
||||
rgb = pl % colors(c % material) % rgb
|
||||
id = materials(c % material) % id
|
||||
end if
|
||||
else if (pl % color_by == PLOT_COLOR_CELLS) then
|
||||
! Assign color based on cell
|
||||
rgb = pl % colors(p % coord % cell) % rgb
|
||||
id = cells(p % coord % cell) % id
|
||||
rgb = pl % colors(coord % cell) % rgb
|
||||
id = cells(coord % cell) % id
|
||||
else
|
||||
rgb = 0
|
||||
id = -1
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ module plot_header
|
|||
integer :: basis ! direction of plot slice
|
||||
integer :: pixels(3) ! pixel width/height of plot slice
|
||||
integer :: meshlines_width ! pixel width of meshlines
|
||||
integer :: level ! universe depth to plot the cells of
|
||||
type(StructuredMesh), pointer :: meshlines_mesh => null() ! mesh to plot
|
||||
type(ObjectColor) :: meshlines_color ! Color for meshlines
|
||||
type(ObjectColor) :: not_found ! color for positions where no cell found
|
||||
|
|
@ -36,6 +37,9 @@ module plot_header
|
|||
! Plot type
|
||||
integer, parameter :: PLOT_TYPE_SLICE = 1
|
||||
integer, parameter :: PLOT_TYPE_VOXEL = 2
|
||||
|
||||
! Plot level
|
||||
integer, parameter :: PLOT_LEVEL_LOWEST = -1
|
||||
|
||||
! Plot basis plane
|
||||
integer, parameter :: PLOT_BASIS_XY = 1
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ element plots {
|
|||
attribute type { "slice" | "voxel" })? &
|
||||
(element color { ( "cell" | "mat" | "material" ) } |
|
||||
attribute color { ( "cell" | "mat" | "material" ) })? &
|
||||
(element level { xsd:int } | attribute level { xsd:int })? &
|
||||
(element origin { list { xsd:double+ } } |
|
||||
attribute origin { list { xsd:double+ } })? &
|
||||
(element width { list { xsd:double+ } } |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue