From 3d8c6a9f4b7200ada54d30b7575624a154fb1a15 Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 23 Apr 2021 11:08:48 -0500 Subject: [PATCH] Some updates from self-review. --- openmc/summary.py | 1 + openmc/universe.py | 2 +- src/cell.cpp | 4 ++-- src/geometry.cpp | 5 ++--- src/material.cpp | 1 - src/particle.cpp | 10 ++++------ tests/regression_tests/dagmc/universes/test.py | 2 +- 7 files changed, 11 insertions(+), 14 deletions(-) diff --git a/openmc/summary.py b/openmc/summary.py index a1ee2dcd66..0af45b7701 100644 --- a/openmc/summary.py +++ b/openmc/summary.py @@ -123,6 +123,7 @@ class Summary: def _read_surfaces(self): for group in self._f['geometry/surfaces'].values(): surface = openmc.Surface.from_hdf5(group) + # surface may be None for DAGMC surfaces if surface: self._fast_surfaces[surface.id] = surface diff --git a/openmc/universe.py b/openmc/universe.py index c246e33bb0..40b7ca70f4 100644 --- a/openmc/universe.py +++ b/openmc/universe.py @@ -638,7 +638,7 @@ class DAGMCUniverse(UniverseBase): Path to the DAGMC file used to represent this universe. universe_id : int, optional Unique identifier of the universe. If not specified, an identifier will - automatically be assigned + automatically be assigned. name : str, optional Name of the universe. If not specified, the name is the empty string. auto_ids : bool diff --git a/src/cell.cpp b/src/cell.cpp index 23786727f1..501fef4957 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -193,6 +193,7 @@ Universe::to_hdf5(hid_t universes_group) const // Create a group for this universe. auto group = create_group(universes_group, fmt::format("universe {}", id_)); + // Write the geometry representation type. switch(type_) { case GeometryType::CSG : write_string(group, "geom_type", "csg", false); @@ -318,7 +319,7 @@ Cell::set_temperature(double T, int32_t instance, bool set_contained) void Cell::to_hdf5(hid_t cell_group) const { - // Create a group for this cell. + // Create a group for this cell. auto group = create_group(cell_group, fmt::format("cell {}", id_)); if (!name_.empty()) { @@ -984,7 +985,6 @@ void read_cells(pugi::xml_node node) model::cells.push_back(make_unique(cell_node)); } - // Fill the cell map. for (int i = 0; i < model::cells.size(); i++) { int32_t id = model::cells[i]->id_; diff --git a/src/geometry.cpp b/src/geometry.cpp index 7e7b3b1729..efa993b061 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -115,9 +115,8 @@ find_cell_inner(Particle& p, const NeighborList* neighbor_list) const auto& univ {model::universes[i_universe]}; found = univ->find_cell(p); } - if (!found) { - return found; - } + + if (!found) { return found; } i_cell = p.coord_[p.n_coord_ - 1].cell; // Announce the cell that the particle is entering. diff --git a/src/material.cpp b/src/material.cpp index 3ef8c70c26..4e6dfbdf1b 100644 --- a/src/material.cpp +++ b/src/material.cpp @@ -1236,7 +1236,6 @@ void read_materials_xml() for (pugi::xml_node material_node : root.children("material")) { model::materials.push_back(make_unique(material_node)); } - model::materials.shrink_to_fit(); } diff --git a/src/particle.cpp b/src/particle.cpp index 6fc27ebfa8..136963d578 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -392,12 +392,11 @@ Particle::cross_surface() #ifdef DAGMC // in DAGMC, we know what the next cell should be - auto surfp = dynamic_cast(model::surfaces[std::abs(surface_) - 1].get()); - if (surfp) { + if (surf->geom_type_ == GeometryType::DAG) { + auto surfp = dynamic_cast(surf); auto cellp = dynamic_cast(model::cells[cell_last_[n_coord_ - 1]].get()); - // TODO: off-by-one auto univp = static_cast(model::universes[coord_[n_coord_ - 1].universe].get()); - + // determine the next cell for this crossing int32_t i_cell = next_cell(univp, cellp, surfp) - 1; // save material and temp material_last_ = material_; @@ -505,9 +504,8 @@ Particle::cross_reflective_bc(const Surface& surf, Direction new_u) coord(0).cell = cell_last(n_coord_last() - 1); surface() = -surface(); - #ifdef DAGMC + // if we're crossing a CSG surface, make sure the DAG history is reset if (surf.geom_type_ != GeometryType::DAG) history_.reset(); - #endif // If a reflective surface is coincident with a lattice or universe // boundary, it is necessary to redetermine the particle's coordinates in diff --git a/tests/regression_tests/dagmc/universes/test.py b/tests/regression_tests/dagmc/universes/test.py index 2ae2b0e9f2..d94f6fe011 100644 --- a/tests/regression_tests/dagmc/universes/test.py +++ b/tests/regression_tests/dagmc/universes/test.py @@ -66,6 +66,6 @@ class DAGMCUniverseTest(PyAPITestHarness): model.export_to_xml() -def test_dagmc_universes(): +def test_univ(): harness = DAGMCUniverseTest('statepoint.10.h5') harness.main() \ No newline at end of file