From 2e4809c8d55bc845d46436c86ce8d71a06e439ea Mon Sep 17 00:00:00 2001 From: shriwise Date: Sat, 11 Aug 2018 08:20:52 -0500 Subject: [PATCH] Updating CAD cell/surface methods to use new Position and Direction structs. --- include/openmc/cell.h | 9 ++++----- include/openmc/surface.h | 6 +++--- src/cell.cpp | 9 +++++++-- src/surface.cpp | 11 +++++++---- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 1e2bd2d98..a2910e74c 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -132,10 +132,10 @@ public: //! known to be on. This index takes precedence over surface sense //! calculations. virtual bool - contains(const double xyz[3], const double uvw[3], int32_t on_surface) const = 0; + contains(Position p, Direction u, int32_t on_surface) const = 0; virtual std::pair - distance(const double xyz[3], const double uvw[3], int32_t on_surface) const = 0; + distance(Position p, Direction u, int32_t on_surface) const = 0; //! Write all information needed to reconstruct the cell to an HDF5 group. //! @param group_id An HDF5 group id. @@ -182,7 +182,6 @@ public: //! \param group_id An HDF5 group id. void to_hdf5(hid_t group_id) const; - protected: bool contains_simple(Position r, Direction u, int32_t on_surface) const; bool contains_complex(Position r, Direction u, int32_t on_surface) const; @@ -195,8 +194,8 @@ class CADCell : public Cell moab::DagMC *dagmc_ptr; explicit CADCell(); - std::pair distance(const double xyz[3], const double uvw[3], int32_t on_surface) const; - bool contains(const double xyz[3], const double uvw[3], int32_t on_surface) const; + std::pair distance(Position p, Direction u, int32_t on_surface) const; + bool contains(Position p, Direction u, int32_t on_surface) const; void to_hdf5(hid_t group_id) const; diff --git a/include/openmc/surface.h b/include/openmc/surface.h index 8a6b340ed..3f7e6ac3f 100644 --- a/include/openmc/surface.h +++ b/include/openmc/surface.h @@ -132,10 +132,10 @@ class CADSurface : public Surface public: moab::DagMC* dagmc_ptr; explicit CADSurface(); - double evaluate(const double xyz[3]) const; - double distance(const double xyz[3], const double uvw[3], + double evaluate(Position p) const; + double distance(Position p, Direction u, bool coincident) const; - void normal(const double xyz[3], double uvw[3]) const; + Direction normal(Position p) const; //! Get the bounding box of this surface. BoundingBox bounding_box() const; }; diff --git a/src/cell.cpp b/src/cell.cpp index 13081c9e3..1d71ff4da 100644 --- a/src/cell.cpp +++ b/src/cell.cpp @@ -597,8 +597,10 @@ CSGCell::contains_complex(Position r, Direction u, int32_t on_surface) const #ifdef CAD CADCell::CADCell() : Cell{} {}; -std::pair CADCell::distance(const double xyz[3], const double uvw[3], int32_t on_surface) const { +std::pair CADCell::distance(Position p, Direction u, int32_t on_surface) const { + double xyz[3] = {p.x, p.y, p.z}; + double uvw[3] = {u.x, u.y, u.z}; moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id); moab::EntityHandle hit_surf; double dist; @@ -611,7 +613,10 @@ std::pair CADCell::distance(const double xyz[3], const double u return result; } -bool CADCell::contains(const double xyz[3], const double uvw[3], int32_t on_surface) const { +bool CADCell::contains(Position p, Direction u, int32_t on_surface) const { + + double xyz[3] = {p.x, p.y, p.z}; + double uvw[3] = {u.x, u.y, u.z}; moab::EntityHandle vol = dagmc_ptr->entity_by_id(3, id); int result = 0; diff --git a/src/surface.cpp b/src/surface.cpp index 270c6723a..5c05d9d40 100644 --- a/src/surface.cpp +++ b/src/surface.cpp @@ -251,20 +251,23 @@ CSGSurface::to_hdf5(hid_t group_id) const #ifdef CAD CADSurface::CADSurface() :Surface{} {} // empty constructor -double CADSurface::evaluate(const double xyz[3]) const +double CADSurface::evaluate(Position r) const { return 0.0; } -double CADSurface::distance(const double xyz[3], const double uvw[3], bool coincident) const { +double CADSurface::distance(Position p, Direction u, bool coincident) const { return 0.0; } -void CADSurface::normal(const double xyz[3], double uvw[3]) const { +Direction CADSurface::normal(Position p) const { + double xyz[3] = {p.x, p.y, p.z}; + double uvw[3]; moab::EntityHandle surf = dagmc_ptr->entity_by_id(2, id); dagmc_ptr->get_angle(surf, xyz, uvw); - return; + Direction u = {uvw}; + return u; }