LCOV - code coverage report
Current view: top level - include/csg - CSGCell.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31730 (e8b711) with base e0c998 Lines: 8 8 100.0 %
Date: 2025-10-29 16:49:47 Functions: 9 9 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : //* This file is part of the MOOSE framework
       2             : //* https://www.mooseframework.org
       3             : //*
       4             : //* All rights reserved, see COPYRIGHT for full restrictions
       5             : //* https://github.com/idaholab/moose/blob/master/COPYRIGHT
       6             : //*
       7             : //* Licensed under LGPL 2.1, please see LICENSE for details
       8             : //* https://www.gnu.org/licenses/lgpl-2.1.html
       9             : 
      10             : #pragma once
      11             : 
      12             : #ifdef MOOSE_UNIT_TEST
      13             : #include "gtest/gtest.h"
      14             : #endif
      15             : 
      16             : #include "CSGRegion.h"
      17             : 
      18             : namespace CSG
      19             : {
      20             : 
      21             : class CSGUniverse;
      22             : 
      23             : /**
      24             :  * CSGCell creates an internal representation of a Constructive Solid Geometry (CSG)
      25             :  * cell, which represents a region of space filled by a material or void
      26             :  */
      27             : class CSGCell
      28             : {
      29             : public:
      30             :   /**
      31             :    * Constructor for void cell
      32             :    *
      33             :    * @param name name of cell
      34             :    * @param region cell region
      35             :    */
      36             :   CSGCell(const std::string & name, const CSGRegion & region);
      37             : 
      38             :   /**
      39             :    * Constructor for Material Cell
      40             :    *
      41             :    * @param name name of cell
      42             :    * @param mat_name name of the CSG material (not a MOOSE material) to use as the cell fill
      43             :    * @param region cell region
      44             :    */
      45             :   CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region);
      46             : 
      47             :   /**
      48             :    * Constructor for Universe Cell
      49             :    *
      50             :    * @param name name of cell
      51             :    * @param univ universe to be the fill
      52             :    * @param region cell region
      53             :    */
      54             :   CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region);
      55             : 
      56             :   /**
      57             :    * Destructor
      58             :    */
      59         352 :   virtual ~CSGCell() = default;
      60             : 
      61             :   /**
      62             :    * @brief Get the type of fill for the cell
      63             :    *
      64             :    * @return fill type
      65             :    */
      66         350 :   const std::string getFillType() const { return _fill_type; }
      67             : 
      68             :   /**
      69             :    * @brief Get the cell fill if fill type is UNIVERSE
      70             :    *
      71             :    * @return Reference to CSGUniverse fill
      72             :    */
      73             :   const CSGUniverse & getFillUniverse() const;
      74             : 
      75             :   /**
      76             :    * @brief Get the cell fill material name if fill fype is CSG_MATERIAL
      77             :    *
      78             :    * @return name of the cell's CSG material fill
      79             :    */
      80             :   const std::string & getFillMaterial() const;
      81             : 
      82             :   /**
      83             :    * @brief Get the name of the fill, regardless of its type
      84             :    *
      85             :    * @return std::string fill name
      86             :    */
      87         113 :   const std::string & getFillName() const { return _fill_name; }
      88             : 
      89             :   /**
      90             :    * @brief Get the cell name
      91             :    *
      92             :    * @return const std::string cell name
      93             :    */
      94         993 :   const std::string & getName() const { return _name; }
      95             : 
      96             :   /**
      97             :    * @brief Get the cell region
      98             :    *
      99             :    * @return const CSGRegion& region of the cell
     100             :    */
     101         259 :   const CSGRegion & getRegion() const { return _region; }
     102             : 
     103             :   /**
     104             :    * @brief Get the string representation of the cell region
     105             :    *
     106             :    * @return std::string string representation of the cell region
     107             :    */
     108          33 :   const std::string & getRegionAsString() const { return _region.toString(); }
     109             : 
     110             :   /// Operator overload for checking if two CSGCell objects are equal
     111             :   bool operator==(const CSGCell & other) const;
     112             : 
     113             :   /// Operator overload for checking if two CSGCell objects are not equal
     114             :   bool operator!=(const CSGCell & other) const;
     115             : 
     116             : protected:
     117             :   // set the name of the cell - intentionally not public because
     118             :   // name needs to be managed at the CSGCellList level
     119          15 :   void setName(const std::string & name) { _name = name; }
     120             : 
     121             :   // update the region of the cell to a new region - not public because
     122             :   // it needs to be called from CSGBase so that the surfaces can be checked first.
     123          13 :   void updateRegion(const CSGRegion & region) { _region = region; }
     124             : 
     125             :   /// Name of surface
     126             :   std::string _name;
     127             : 
     128             :   /// An enum for type of fill for cell region
     129             :   // TODO: add support for lattice fill
     130             :   MooseEnum _fill_type{"VOID CSG_MATERIAL UNIVERSE"};
     131             : 
     132             :   /// name of the fill object
     133             :   std::string _fill_name;
     134             : 
     135             :   /// Cell region, represented as a CSGRegion object
     136             :   CSGRegion _region;
     137             : 
     138             :   /// Fill object if fill is CSGUniverse
     139             :   const CSGUniverse * _fill_universe;
     140             : 
     141             :   friend class CSGCellList; // needed for setName() access
     142             :   friend class CSGBase;     // needed for updateRegion() access
     143             : 
     144             : #ifdef MOOSE_UNIT_TEST
     145             :   /// Friends for unit testing
     146             :   ///@{
     147             :   FRIEND_TEST(CSGCellTest, testSetName);
     148             :   FRIEND_TEST(CSGCellTest, testUpdateRegion);
     149             :   ///@}
     150             : #endif
     151             : };
     152             : } // namespace CSG

Generated by: LCOV version 1.14