From 11eb891e21fdfd822d2bee175280bc315a46ac3d Mon Sep 17 00:00:00 2001 From: Paul Romano Date: Wed, 29 May 2019 15:09:12 -0500 Subject: [PATCH] Add a LocalCoord::rotate method as suggested by @pshriwise --- include/openmc/particle.h | 12 ++++++++---- src/geometry.cpp | 8 ++------ src/particle.cpp | 8 ++++++++ 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/openmc/particle.h b/include/openmc/particle.h index 62923c11f..a2b7ce557 100644 --- a/include/openmc/particle.h +++ b/include/openmc/particle.h @@ -9,6 +9,7 @@ #include // for unique_ptr #include #include +#include #include "openmc/constants.h" #include "openmc/position.h" @@ -38,7 +39,13 @@ constexpr double CACHE_INVALID {-1.0}; // Class declarations //============================================================================== -struct LocalCoord { +class LocalCoord { +public: + void rotate(const std::vector& rotation); + + //! clear data from a single coordinate level + void reset(); + Position r; //!< particle position Direction u; //!< particle direction int cell {-1}; @@ -48,9 +55,6 @@ struct LocalCoord { int lattice_y {-1}; int lattice_z {-1}; bool rotated {false}; //!< Is the level rotated? - - //! clear data from a single coordinate level - void reset(); }; //============================================================================== diff --git a/src/geometry.cpp b/src/geometry.cpp index a680d2bb7..fbb048650 100644 --- a/src/geometry.cpp +++ b/src/geometry.cpp @@ -182,9 +182,7 @@ find_cell_inner(Particle* p, const NeighborList* neighbor_list) // Apply rotation. if (!c.rotation_.empty()) { - coord.r = coord.r.rotate(c.rotation_); - coord.u = coord.u.rotate(c.rotation_); - coord.rotated = true; + coord.rotate(c.rotation_); } // Update the coordinate level and recurse. @@ -207,9 +205,7 @@ find_cell_inner(Particle* p, const NeighborList* neighbor_list) // Apply rotation. if (!c.rotation_.empty()) { - coord.r = coord.r.rotate(c.rotation_); - coord.u = coord.u.rotate(c.rotation_); - coord.rotated = true; + coord.rotate(c.rotation_); } // Determine lattice indices. diff --git a/src/particle.cpp b/src/particle.cpp index 7d862750d..988130ec2 100644 --- a/src/particle.cpp +++ b/src/particle.cpp @@ -33,6 +33,14 @@ namespace openmc { // LocalCoord implementation //============================================================================== +void +LocalCoord::rotate(const std::vector& rotation) +{ + this->r = this->r.rotate(rotation); + this->u = this->u.rotate(rotation); + this->rotated = true; +} + void LocalCoord::reset() {