Replacing position_rgb with C-side implementation.

This commit is contained in:
Patrick Shriwise 2018-10-09 09:46:00 -05:00
parent cb9e400074
commit 075473b475
2 changed files with 58 additions and 45 deletions

View file

@ -7,6 +7,7 @@
#include "hdf5.h"
#include "position.h"
#include "openmc/constants.h"
#include "openmc/particle.h"
namespace openmc {
@ -67,7 +68,9 @@ namespace openmc {
char path_plot[MAX_WORD_LEN];
};
extern "C" void position_rgb(Particle* p, ObjectPlot* pl, int rgb[3], int &id);
extern "C" void voxel_init(hid_t file_id, const hsize_t* dims, hid_t* dspace,
hid_t* dset, hid_t* memspace);
extern "C" void voxel_write_slice(int x, hid_t dspace, hid_t dset,

View file

@ -25,6 +25,16 @@ module plot
integer, parameter :: GREEN = 2
integer, parameter :: BLUE = 3
interface
subroutine position_rgb(p, pl, rgb, id) bind(C)
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
end subroutine position_rgb
end interface
contains
!===============================================================================
@ -60,56 +70,56 @@ contains
! 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
! 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
! integer :: j
! logical :: found_cell
p % n_coord = 1
! p % n_coord = 1
call find_cell(p, found_cell)
j = p % n_coord
if (check_overlaps) call check_cell_overlap(p)
! 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
! ! 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
! 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
! end subroutine position_rgb
!===============================================================================
! CREATE_PPM creates an image based on user input from a plots.xml <plot>