diff --git a/include/openmc/dagmc.h b/include/openmc/dagmc.h index 6d44f9e1b5..6e292488a0 100644 --- a/include/openmc/dagmc.h +++ b/include/openmc/dagmc.h @@ -91,7 +91,9 @@ public: void legacy_assign_material(std::string mat_string, std::unique_ptr& c) const; - //! Generate a string representing the ranges of IDs present in the DAGMC model + //! Generate a string representing the ranges of IDs present in the DAGMC model. + //! Contiguous chunks of IDs are represented as a range (i.e. 1-10). If there is + //! a single ID a chunk, it will be represented as a single number (i.e. 2, 4, 6, 8). //! \param[in] dim Dimension of the entities //! \return A string of the ID ranges for entities of dimension \p dim std::string dagmc_ids_for_dim(int dim) const; diff --git a/include/openmc/surface.h b/include/openmc/surface.h index d29bbee086..5d747b4894 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -30,7 +30,7 @@ namespace model { } // namespace model //============================================================================== -//! Coordinates for an axis-aligned cube that bounds a geometric object. +//! Coordinates for an axis-aligned cuboid that bounds a geometric object. //============================================================================== struct BoundingBox diff --git a/openmc/universe.py b/openmc/universe.py index 333441a8e5..8a12d1160f 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -720,7 +720,6 @@ class DAGMCUniverse(UniverseBase): return OrderedDict() def create_xml_subelement(self, xml_element, memo=None): - if memo and self in memo: return diff --git a/src/cell.cpp b/src/cell.cpp index 501fef4957..b85e4fd569 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -328,7 +328,6 @@ Cell::to_hdf5(hid_t cell_group) const { write_dataset(group, "universe", model::universes[universe_]->id_); - to_hdf5_inner(group); // Write fill information. diff --git a/src/dagmc.cpp b/src/dagmc.cpp index 34917a562a..5254035794 100644 --- a/src/dagmc.cpp +++ b/src/dagmc.cpp @@ -296,8 +296,8 @@ DAGUniverse::dagmc_ids_for_dim(int dim) const { // generate a vector of ids std::vector id_vec; - int n_cells = dagmc_instance_->num_entities(dim); - for (int i = 1; i <= n_cells; i++) { + int n_ents = dagmc_instance_->num_entities(dim); + for (int i = 1; i <= n_ents; i++) { id_vec.push_back(dagmc_instance_->id_by_index(dim, i)); } @@ -308,22 +308,30 @@ DAGUniverse::dagmc_ids_for_dim(int dim) const std::stringstream out; int i = 0; - int start_id = id_vec[0]; + int start_id = id_vec[0]; // initialize with first ID int stop_id; - while (i < n_cells) { + // loop over all cells in the universe + while (i < n_ents) { + stop_id = id_vec[i]; + // if the next ID is not in this contiguous set of IDS, + // figure out how to write the string representing this set if (id_vec[i + 1] > stop_id + 1) { + if (start_id != stop_id) { - // there are several IDs in a row, print condensed version + // there are several IDs in a row, print condensed version (i.e. 1-10, 12-20) out << start_id << "-" << stop_id; } else { - // only one ID in this contiguous block + // only one ID in this contiguous block (i.e. 3, 5, 7, 9) out << start_id; } - if (i < n_cells - 1) { out << ", "; } + // insert a comma as long as we aren't in the last ID set + if (i < n_ents - 1) { out << ", "; } + + // if we are at the end of a set, set the start ID to the first value + // in the next set. start_id = id_vec[++i]; - stop_id = start_id; } i++;