LCOV - code coverage report
Current view: top level - include/csg - CSGCellList.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #31782 (615931) with base 7edd10 Lines: 5 5 100.0 %
Date: 2025-11-11 23:21:15 Functions: 4 5 80.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             : #include "CSGCell.h"
      13             : 
      14             : namespace CSG
      15             : {
      16             : 
      17             : /**
      18             :  * CSGCellList creates a container for CSGCell objects to pass to CSGBase object
      19             :  */
      20             : class CSGCellList
      21             : {
      22             : protected:
      23             :   /**
      24             :    * Default constructor
      25             :    */
      26             :   CSGCellList();
      27             : 
      28             :   /**
      29             :    * Destructor
      30             :    */
      31         118 :   virtual ~CSGCellList() = default;
      32             : 
      33             :   /**
      34             :    * @brief Add a Material Cell object to cell list
      35             :    *
      36             :    * @param name unique cell name
      37             :    * @param mat_name material name
      38             :    * @param region cell region
      39             :    * @return reference to CSGCell with material fill that was created and
      40             :    * added to this CSGCellList
      41             :    */
      42             :   CSGCell &
      43             :   addMaterialCell(const std::string & name, const std::string & mat_name, const CSGRegion & region);
      44             : 
      45             :   /**
      46             :    * @brief Add a Void Cell object cell list
      47             :    *
      48             :    * @param name unique cell name
      49             :    * @param region cell region
      50             :    * @return reference to CSGCell with void fill that was created and
      51             :    * added to this CSGCellList
      52             :    */
      53             :   CSGCell & addVoidCell(const std::string & name, const CSGRegion & region);
      54             : 
      55             :   /**
      56             :    * @brief Add a Universe Cell object to cell list
      57             :    *
      58             :    * @param name unique cell name
      59             :    * @param univ universe
      60             :    * @param region cell region
      61             :    * @return reference to CSGCell with universe fill that was created and
      62             :    * added to this CSGCellList
      63             :    */
      64             :   CSGCell &
      65             :   addUniverseCell(const std::string & name, const CSGUniverse & univ, const CSGRegion & region);
      66             : 
      67             :   /**
      68             :    * @brief return whether cell with given name exists in cell list
      69             :    *
      70             :    * @param name name of cell
      71             :    * @return true if cell name exists, false otherwise
      72             :    */
      73          68 :   bool hasCell(const std::string & name) const { return _cells.find(name) != _cells.end(); }
      74             : 
      75             :   /**
      76             :    * @brief Get non-const map of all names to cells in cell list
      77             :    *
      78             :    * @return map of all names to CSGCell pointers
      79             :    */
      80          24 :   std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() { return _cells; }
      81             : 
      82             :   /**
      83             :    * @brief Get const map of all names to cells in cell list
      84             :    *
      85             :    * @return map of all names to CSGCell pointers
      86             :    */
      87          11 :   const std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() const
      88             :   {
      89          11 :     return _cells;
      90             :   }
      91             : 
      92             :   /**
      93             :    * @brief Get all the cells in CSGBase instance
      94             :    *
      95             :    * @return list of references to all CSGCell objects
      96             :    */
      97             :   std::vector<std::reference_wrapper<const CSGCell>> getAllCells() const;
      98             : 
      99             :   /**
     100             :    * @brief Get the CSGCell by name
     101             :    *
     102             :    * @param name
     103             :    * @return reference to CSGCell of the specified name
     104             :    */
     105             :   CSGCell & getCell(const std::string & name) const;
     106             : 
     107             :   /**
     108             :    * @brief add a cell to the CellList. Ownership of cell will be transferred to cell list object
     109             :    * that calls this function
     110             :    *
     111             :    * @param cell cell to add to the CellList.
     112             :    * @return reference to CSGCell that was added to CellList
     113             :    */
     114             :   CSGCell & addCell(std::unique_ptr<CSGCell> cell);
     115             : 
     116             :   /**
     117             :    * @brief rename the specified cell
     118             :    *
     119             :    * @param cell reference to CSGCell object that should be renamed
     120             :    * @param name new name
     121             :    */
     122             :   void renameCell(const CSGCell & cell, const std::string & name);
     123             : 
     124             :   /// Operator overload for checking if two CSGCellList objects are equal
     125             :   bool operator==(const CSGCellList & other) const;
     126             : 
     127             :   /// Operator overload for checking if two CSGCellList objects are not equal
     128             :   bool operator!=(const CSGCellList & other) const;
     129             : 
     130             :   /// Mapping of cell names to pointers of stored cell objects
     131             :   std::unordered_map<std::string, std::unique_ptr<CSGCell>> _cells;
     132             : 
     133             :   // Only CSGBase should be calling the methods in CSGCellList
     134             :   friend class CSGBase;
     135             : };
     136             : } // namespace CSG

Generated by: LCOV version 1.14