LCOV - code coverage report
Current view: top level - include/csg - CSGCellList.h (source / functions) Hit Total Coverage
Test: idaholab/moose framework: #32971 (54bef8) with base c6cf66 Lines: 5 5 100.0 %
Date: 2026-05-29 20:35:17 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         280 :   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 Add a Lattice Cell object to cell list
      69             :    *
      70             :    * @param name unique cell name
      71             :    * @param lattice lattice
      72             :    * @param region cell region
      73             :    * @return reference to CSGCell with lattice fill that was created and
      74             :    * added to this CSGCellList
      75             :    */
      76             :   CSGCell &
      77             :   addLatticeCell(const std::string & name, const CSGLattice & lattice, const CSGRegion & region);
      78             : 
      79             :   /**
      80             :    * @brief return whether cell with given name exists in cell list
      81             :    *
      82             :    * @param name name of cell
      83             :    * @return true if cell name exists, false otherwise
      84             :    */
      85         116 :   bool hasCell(const std::string & name) const { return _cells.find(name) != _cells.end(); }
      86             : 
      87             :   /**
      88             :    * @brief Get non-const map of all names to cells in cell list
      89             :    *
      90             :    * @return map of all names to CSGCell pointers
      91             :    */
      92         132 :   std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() { return _cells; }
      93             : 
      94             :   /**
      95             :    * @brief Get const map of all names to cells in cell list
      96             :    *
      97             :    * @return map of all names to CSGCell pointers
      98             :    */
      99          12 :   const std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() const
     100             :   {
     101          12 :     return _cells;
     102             :   }
     103             : 
     104             :   /**
     105             :    * @brief Get all the cells in CSGBase instance
     106             :    *
     107             :    * @return list of references to all CSGCell objects
     108             :    */
     109             :   std::vector<std::reference_wrapper<const CSGCell>> getAllCells() const;
     110             : 
     111             :   /**
     112             :    * @brief Get the CSGCell by name
     113             :    *
     114             :    * @param name
     115             :    * @return reference to CSGCell of the specified name
     116             :    */
     117             :   CSGCell & getCell(const std::string & name) const;
     118             : 
     119             :   /**
     120             :    * @brief add a cell to the CellList. Ownership of cell will be transferred to cell list object
     121             :    * that calls this function
     122             :    *
     123             :    * @param cell cell to add to the CellList.
     124             :    * @return reference to CSGCell that was added to CellList
     125             :    */
     126             :   CSGCell & addCell(std::unique_ptr<CSGCell> cell);
     127             : 
     128             :   /**
     129             :    * @brief rename the specified cell
     130             :    *
     131             :    * @param cell reference to CSGCell object that should be renamed
     132             :    * @param name new name
     133             :    */
     134             :   void renameCell(const CSGCell & cell, const std::string & name);
     135             : 
     136             :   /// Operator overload for checking if two CSGCellList objects are equal
     137             :   bool operator==(const CSGCellList & other) const;
     138             : 
     139             :   /// Operator overload for checking if two CSGCellList objects are not equal
     140             :   bool operator!=(const CSGCellList & other) const;
     141             : 
     142             :   /// Mapping of cell names to pointers of stored cell objects
     143             :   std::unordered_map<std::string, std::unique_ptr<CSGCell>> _cells;
     144             : 
     145             :   // Only CSGBase should be calling the methods in CSGCellList
     146             :   friend class CSGBase;
     147             : };
     148             : } // namespace CSG

Generated by: LCOV version 1.14