20 auto cell_name = cell->
getName();
21 if (ignore_identical_cell)
23 if (
auto it =
_cells.find(cell_name); it !=
_cells.end())
25 if (*cell == *it->second)
30 " has the same name as an existing cell in CSGBase instance but cannot be " 31 "discarded as it is not an identical cell.");
36 auto [it, inserted] =
_cells.emplace(cell_name, std::move(cell));
38 mooseError(
"Cell with name " + cell_name +
" already exists in geometry.");
47 mooseError(
"No cell by name " +
name +
" exists in the geometry.");
55 return addCell(std::make_unique<CSGCell>(
name, region));
60 const std::string & mat_name,
63 return addCell(std::make_unique<CSGCell>(
name, mat_name, region));
71 return addCell(std::make_unique<CSGCell>(
name, &univ, region));
79 return addCell(std::make_unique<CSGCell>(
name, &lattice, region));
82 std::vector<std::reference_wrapper<const CSGCell>>
85 std::vector<std::reference_wrapper<const CSGCell>> cells;
87 cells.push_back(*(it->second));
95 auto prev_name = cell.
getName();
96 auto it =
_cells.find(prev_name);
97 if (it ==
_cells.end() || it->second.get() != &cell)
99 " as it does not exist in this CSGBase instance.");
101 auto existing_cell = std::move(
_cells.find(prev_name)->second);
102 existing_cell->setName(
name);
104 addCell(std::move(existing_cell));
114 if (all_cells.size() != other_cells.size())
119 for (
const auto & cell : all_cells)
121 const auto & cell_name = cell.get().getName();
124 const auto & other_cell = other.
getCell(cell_name);
125 if (cell.get() != other_cell)
134 return !(*
this == other);
std::string name(const ElemQuality q)
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
const std::string & getName() const
Get the cell name.
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
CSGCellList creates a container for CSGCell objects to pass to CSGBase object.
CSGCellList()
Default constructor.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
bool operator!=(const CSGCellList &other) const
Operator overload for checking if two CSGCellList objects are not equal.
CSGCell & addVoidCell(const std::string &name, const CSGRegion ®ion)
Add a Void Cell object cell list.
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
CSGCell & addMaterialCell(const std::string &name, const std::string &mat_name, const CSGRegion ®ion)
Add a Material Cell object to cell list.
CSGCell & addUniverseCell(const std::string &name, const CSGUniverse &univ, const CSGRegion ®ion)
Add a Universe Cell object to cell list.
CSGLattice is the abstract class for defining lattices.
CSGCell & addLatticeCell(const std::string &name, const CSGLattice &lattice, const CSGRegion ®ion)
Add a Lattice Cell object to cell list.
bool operator==(const CSGCellList &other) const
Operator overload for checking if two CSGCellList objects are equal.
CSGCell & addCell(std::unique_ptr< CSGCell > cell, const bool ignore_identical_cell=false)
add a cell to the CellList.
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
bool hasCell(const std::string &name) const
return whether cell with given name exists in cell list