From 470e26c78337585bb2b5e703ba4a464d3177865e Mon Sep 17 00:00:00 2001 From: Patrick Shriwise Date: Fri, 21 Jun 2019 00:27:18 -0500 Subject: [PATCH] Adding bbox defs for cells. --- include/openmc/cell.h | 2 ++ include/openmc/surface.h | 7 +++++++ src/cell.cpp | 10 ++++++++++ src/surface.cpp | 1 + 4 files changed, 20 insertions(+) diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 8329bc5101..b4848bb50b 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -217,6 +217,8 @@ public: std::pair distance(Position r, Direction u, int32_t on_surface) const; + BoundingBox bounding_box() const; + void to_hdf5(hid_t group_id) const; }; #endif diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 3c5ece4f9e..f218f7ac78 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -139,6 +139,8 @@ public: void to_hdf5(hid_t group_id) const; + virtual BoundingBox bounding_box(bool pos_side) const = 0; + protected: virtual void to_hdf5_inner(hid_t group_id) const = 0; }; @@ -159,6 +161,8 @@ public: //! Get the bounding box of this surface. BoundingBox bounding_box(bool pos_side) const; + void to_hdf5(hid_t group_id) const; + moab::DagMC* dagmc_ptr_; int32_t dag_index_; }; @@ -188,6 +192,9 @@ public: //! boundary condition. virtual bool periodic_translate(const PeriodicSurface* other, Position& r, Direction& u) const = 0; + + //! Get the bounding box for this surface. + virtual BoundingBox bounding_box(bool pos_side) const = 0; }; //============================================================================== diff --git a/src/cell.cpp b/src/cell.cpp index 9afae2d60c..ebf466bd6b 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -698,6 +698,16 @@ bool DAGCell::contains(Position r, Direction u, int32_t on_surface) const void DAGCell::to_hdf5(hid_t group_id) const { return; } +BoundingBox DAGCell::bounding_box() const +{ + moab::ErrorCode rval; + moab::EntityHandle vol = dagmc_ptr_->entity_by_index(3, dag_index_); + double min[3], max[3]; + rval = dagmc_ptr_->getobb(vol, min, max); + MB_CHK_ERR_CONT(rval); + return {min[0], max[0], min[1], max[1], min[2], max[2]}; +} + #endif //============================================================================== diff --git a/src/surface.cpp b/src/surface.cpp index e9d2f964ec..ae8a5b6c47 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -282,6 +282,7 @@ BoundingBox DAGSurface::bounding_box(bool pos_side) const } void DAGSurface::to_hdf5(hid_t group_id) const {} + #endif //============================================================================== // PeriodicSurface implementation