diff --git a/src/geometry.F90 b/src/geometry.F90 index f386dcf008..571ed6d407 100644 --- a/src/geometry.F90 +++ b/src/geometry.F90 @@ -193,8 +193,9 @@ contains logical, intent(inout) :: found integer, optional :: search_cells(:) integer :: i ! index over cells - integer :: j ! coordinate level index - integer :: k ! distribcell instance + integer :: j, k ! coordinate level index + integer :: offset ! instance # of a distributed cell + integer :: distribcell_index integer :: i_xyz(3) ! indices in lattice integer :: n ! number of cells to search integer :: index_cell ! index in cells array @@ -249,30 +250,34 @@ contains ! Set the particle material p % last_material = p % material -! if (size(c % material) == 1) then + if (size(c % material) == 1) then ! Only one material for this cell; assign that one to the particle. p % material = c % material(1) -! else -! ! Distributed instances of this cell have different materials. -! ! Determine which instance this is and assign the matching material. -! offset = 0 -! do k = 1, p % n_coord -! if (cells(p % coord(k) % cell) % type == CELL_FILL) then -! offset = offset + cells(p % coord(k) % cell) % & -! offset(t % filters(i) % offset) -! elseif(cells(p % coord(k) % cell) % type == CELL_LATTICE) then -! if (lattices(p % coord(k + 1) % lattice) % obj & -! % are_valid_indices([& -! p % coord(k + 1) % lattice_x, & -! p % coord(k + 1) % lattice_y, & -! p % coord(k + 1) % lattice_z])) then -! offset = offset + lattices(p % coord(k + 1) % lattice) % obj % & -! offset(t % filters(i) % offset, & -! p % coord(k + 1) % lattice_x, & -! p % coord(k + 1) % lattice_y, & -! p % coord(k + 1) % lattice_z) -! end if -! end if + else + ! Distributed instances of this cell have different materials. + ! Determine which instance this is and assign the matching material. + distribcell_index = c % distribcell_index + offset = 0 + do k = 1, p % n_coord + if (cells(p % coord(k) % cell) % type == CELL_FILL) then + offset = offset + cells(p % coord(k) % cell) % & + offset(distribcell_index) + elseif (cells(p % coord(k) % cell) % type == CELL_LATTICE) then + if (lattices(p % coord(k + 1) % lattice) % obj & + % are_valid_indices([& + p % coord(k + 1) % lattice_x, & + p % coord(k + 1) % lattice_y, & + p % coord(k + 1) % lattice_z])) then + offset = offset + lattices(p % coord(k + 1) % lattice) % obj % & + offset(distribcell_index, & + p % coord(k + 1) % lattice_x, & + p % coord(k + 1) % lattice_y, & + p % coord(k + 1) % lattice_z) + end if + end if + end do + p % material = c % material(offset + 1) + end if elseif (c % type == CELL_FILL) then CELL_TYPE ! ====================================================================== diff --git a/src/plot.F90 b/src/plot.F90 index 99d7e3ae94..75d0bc9442 100644 --- a/src/plot.F90 +++ b/src/plot.F90 @@ -82,17 +82,17 @@ contains if (pl % color_by == PLOT_COLOR_MATS) then ! Assign color based on material c => cells(p % coord(j) % cell) - if (c % material(1) == MATERIAL_VOID) then - ! By default, color void cells white - rgb = 255 - id = -1 - else if (c % type == CELL_FILL) then + 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 if (p % material == MATERIAL_VOID) then + ! By default, color void cells white + rgb = 255 + id = -1 else - rgb = pl % colors(c % material(1)) % rgb - id = materials(c % material(1)) % id + rgb = pl % colors(p % material) % rgb + id = materials(p % material) % id end if else if (pl % color_by == PLOT_COLOR_CELLS) then ! Assign color based on cell