From 075473b475d0acdee10133abecebae73b9634508 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Tue, 9 Oct 2018 09:46:00 -0500 Subject: [PATCH] Replacing position_rgb with C-side implementation. --- include/openmc/plot.h | 5 ++- src/plot.F90 | 98 ++++++++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 45 deletions(-) diff --git a/include/openmc/plot.h b/include/openmc/plot.h index 27b68b7b4..92b8d89b3 100644 --- a/include/openmc/plot.h +++ b/include/openmc/plot.h @@ -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, diff --git a/src/plot.F90 b/src/plot.F90 index bfc8bc225..d2ebab166 100644 --- a/src/plot.F90 +++ b/src/plot.F90 @@ -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