diff --git a/include/openmc/cell.h b/include/openmc/cell.h index 0891c062f3..248c2b23d7 100644 --- a/include/openmc/cell.h +++ b/include/openmc/cell.h @@ -62,34 +62,84 @@ public: //---------------------------------------------------------------------------- // Methods + + //! \brief Determine if a cell contains the particle at a given location. + //! + //! The bounds of the cell are determined by a logical expression involving + //! surface half-spaces. The expression used is given in infix notation + //! + //! The function is split into two cases, one for simple cells (those + //! involving only the intersection of half-spaces) and one for complex cells. + //! Both cases use short circuiting; however, in the case fo complex cells, + //! the complexity increases with the binary operators involved. + //! \param r The 3D Cartesian coordinate to check. + //! \param u A direction used to "break ties" the coordinates are very + //! close to a surface. + //! \param on_surface The signed index of a surface that the coordinate is + //! known to be on. This index takes precedence over surface sense + //! calculations. + bool contains(Position r, Direction u, int32_t on_surface) const; + + //! Find the oncoming boundary of this cell. std::pair distance( Position r, Direction u, int32_t on_surface, Particle* p) const; - bool contains(Position r, Direction u, int32_t on_surface) const; + + //! Get the BoundingBox for this cell. BoundingBox bounding_box(int32_t cell_id) const; + + //! Get the CSG expression as a string std::string str() const; + + //! Get a vector containing all the surfaces in the region expression vector surfaces() const; //---------------------------------------------------------------------------- // Accessors + + //! Get Boolean of if the cell is simple or not bool is_simple() const { return simple_; } private: //---------------------------------------------------------------------------- // Private Methods + + //! Get a vector of the region expression in postfix notation vector generate_postfix(int32_t cell_id) const; + + //! Determine if a particle is inside the cell for a simple cell (only + //! intersection operators) bool contains_simple(Position r, Direction u, int32_t on_surface) const; + + //! Determine if a particle is inside the cell for a complex cell. + //! + //! Uses the comobination of half-spaces and binary operators to determine + //! if short circuiting can be used. Short cicuiting uses the relative and + //! absolute depth of parenthases in the expression. bool contains_complex(Position r, Direction u, int32_t on_surface) const; + + //! BoundingBox if the paritcle is in a simple cell. BoundingBox bounding_box_simple() const; + + //! BoundingBox if the particle is in a complex cell. BoundingBox bounding_box_complex(vector postfix) const; + + //! Enfource precedence: Parenthases, Complement, Intersection, Union void add_precedence(); + + //! Add parenthesis to enforce precedence std::vector::iterator add_parentheses( std::vector::iterator start); + + //! Remove complement operators from the expression void remove_complement_ops(); + + //! Remove complement operators by using DeMorgan's laws void apply_demorgan( vector::iterator start, vector::iterator stop); //---------------------------------------------------------------------------- // Private Data + //! Definition of spatial region as Boolean expression of half-spaces // TODO: Should this be a vector of some other type vector expression_; @@ -98,8 +148,6 @@ private: //============================================================================== -// TODO: Think about what data members really need to live in this class versus -// putting them in the Region class class Cell { public: //---------------------------------------------------------------------------- @@ -155,10 +203,10 @@ public: virtual BoundingBox bounding_box() const = 0; //! Get a vector of surfaces in the cell - virtual vector surfaces() const = 0; + virtual vector surfaces() const { return vector(); } //! Check if the cell region expression is simple - virtual bool is_simple() const = 0; + virtual bool is_simple() const { return true; } //---------------------------------------------------------------------------- // Accessors