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 310 : 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 172 : 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 196 : 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 36 : const std::unordered_map<std::string, std::unique_ptr<CSGCell>> & getCellListMap() const 100 : { 101 36 : 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 : * @param ignore_identical_cell skip adding cell if an identical cell exists in cell list 125 : * @return reference to CSGCell that was added to CellList 126 : */ 127 : CSGCell & addCell(std::unique_ptr<CSGCell> cell, const bool ignore_identical_cell = false); 128 : 129 : /** 130 : * @brief rename the specified cell 131 : * 132 : * @param cell reference to CSGCell object that should be renamed 133 : * @param name new name 134 : */ 135 : void renameCell(const CSGCell & cell, const std::string & name); 136 : 137 : /// Operator overload for checking if two CSGCellList objects are equal 138 : bool operator==(const CSGCellList & other) const; 139 : 140 : /// Operator overload for checking if two CSGCellList objects are not equal 141 : bool operator!=(const CSGCellList & other) const; 142 : 143 : /// Mapping of cell names to pointers of stored cell objects 144 : std::unordered_map<std::string, std::unique_ptr<CSGCell>> _cells; 145 : 146 : // Only CSGBase should be calling the methods in CSGCellList 147 : friend class CSGBase; 148 : }; 149 : } // namespace CSG