From 39c52dcf94639a3bb9c8ca02a3e47aac032d08d8 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Wed, 28 Jul 2021 17:49:33 -0500 Subject: [PATCH] Incorporate cell instance levels into plotting. Return C_NONE if it is not a distributed cell. --- src/geometry.cpp | 5 +++++ src/plot.cpp | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/geometry.cpp b/src/geometry.cpp index 1cbb74935..563e5467b 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -66,11 +66,16 @@ bool check_cell_overlap(Particle& p, bool error) //============================================================================== int cell_instance_at_level(const Particle& p, int level) { + // throw error if the requested level is too deep for the geometry if (level > p.n_coord()) { fatal_error(fmt::format("Cell instance at level {} requested, but only {} levels exist in the model.", level, p.n_coord())); } + // determine the cell instance Cell& c {*model::cells[p.coord(level).cell]}; + + if (c.distribcell_index_ == C_NONE) return C_NONE; + int instance = 0; for (int i = 0; i < level; i++) { const auto& c_i {*model::cells[p.coord(i).cell]}; diff --git a/src/plot.cpp b/src/plot.cpp index 999cf3d29..c3ef36467 100644 --- a/src/plot.cpp +++ b/src/plot.cpp @@ -47,7 +47,7 @@ IdData::set_value(size_t y, size_t x, const Particle& p, int level) { data_(y, x, 1) = NOT_FOUND; } else { data_(y, x, 0) = model::cells.at(p.coord(level).cell)->id_; - data_(y, x, 1) = p.cell_instance(); + data_(y, x, 1) = level == p.n_coord() - 1 ? p.cell_instance() : cell_instance_at_level(p, level); } // set material data