CSGCellList creates a container for CSGCell objects to pass to CSGBase object.
More...
#include <CSGCellList.h>
|
| | CSGCellList () |
| | Default constructor.
|
| |
| virtual | ~CSGCellList ()=default |
| | Destructor.
|
| |
| CSGCell & | addMaterialCell (const std::string &name, const std::string &mat_name, const CSGRegion ®ion) |
| | Add a Material Cell object to cell list.
|
| |
| CSGCell & | addVoidCell (const std::string &name, const CSGRegion ®ion) |
| | Add a Void Cell object cell list.
|
| |
| CSGCell & | addUniverseCell (const std::string &name, const CSGUniverse &univ, const CSGRegion ®ion) |
| | Add a Universe Cell object to cell list.
|
| |
| CSGCell & | addLatticeCell (const std::string &name, const CSGLattice &lattice, const CSGRegion ®ion) |
| | Add a Lattice Cell object to cell list.
|
| |
| bool | hasCell (const std::string &name) const |
| | return whether cell with given name exists in cell list
|
| |
| std::unordered_map< std::string, std::unique_ptr< CSGCell > > & | getCellListMap () |
| | Get non-const map of all names to cells in cell list.
|
| |
| const std::unordered_map< std::string, std::unique_ptr< CSGCell > > & | getCellListMap () const |
| | Get const map of all names to cells in cell list.
|
| |
| std::vector< std::reference_wrapper< const CSGCell > > | getAllCells () const |
| | Get all the cells in CSGBase instance.
|
| |
| CSGCell & | getCell (const std::string &name) const |
| | Get the CSGCell by name.
|
| |
| CSGCell & | addCell (std::unique_ptr< CSGCell > cell, const bool ignore_identical_cell=false) |
| | add a cell to the CellList.
|
| |
| void | renameCell (const CSGCell &cell, const std::string &name) |
| | rename the specified cell
|
| |
| bool | operator== (const CSGCellList &other) const |
| | Operator overload for checking if two CSGCellList objects are equal.
|
| |
| bool | operator!= (const CSGCellList &other) const |
| | Operator overload for checking if two CSGCellList objects are not equal.
|
| |
|
| std::unordered_map< std::string, std::unique_ptr< CSGCell > > | _cells |
| | Mapping of cell names to pointers of stored cell objects.
|
| |
CSGCellList creates a container for CSGCell objects to pass to CSGBase object.
Definition at line 20 of file CSGCellList.h.
◆ CSGCellList()
| CSG::CSGCellList::CSGCellList |
( |
| ) |
|
|
protected |
◆ ~CSGCellList()
| virtual CSG::CSGCellList::~CSGCellList |
( |
| ) |
|
|
protectedvirtualdefault |
◆ addCell()
| CSGCell & CSG::CSGCellList::addCell |
( |
std::unique_ptr< CSGCell > |
cell, |
|
|
const bool |
ignore_identical_cell = false |
|
) |
| |
|
protected |
add a cell to the CellList.
Ownership of cell will be transferred to cell list object that calls this function
- Parameters
-
| cell | cell to add to the CellList. |
| ignore_identical_cell | skip adding cell if an identical cell exists in cell list |
- Returns
- reference to CSGCell that was added to CellList
Definition at line 18 of file CSGCellList.C.
19{
20 auto cell_name = cell->getName();
21 if (ignore_identical_cell)
22
23 if (
auto it =
_cells.find(cell_name); it !=
_cells.end())
24 {
25 if (*cell == *it->second)
26 return *it->second;
27 else
29 cell_name,
30 " has the same name as an existing cell in CSGBase instance but cannot be "
31 "discarded as it is not an identical cell.");
32 }
33
34
35
36 auto [it, inserted] =
_cells.emplace(cell_name, std::move(cell));
37 if (!inserted)
38 mooseError(
"Cell with name " + cell_name +
" already exists in geometry.");
39
40 return *it->second;
41}
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Referenced by CSG::CSGBase::addEngUnit(), addLatticeCell(), addMaterialCell(), addUniverseCell(), addVoidCell(), CSG::CSGBase::CSGBase(), and renameCell().
◆ addLatticeCell()
Add a Lattice Cell object to cell list.
- Parameters
-
| name | unique cell name |
| lattice | lattice |
| region | cell region |
- Returns
- reference to CSGCell with lattice fill that was created and added to this CSGCellList
Definition at line 75 of file CSGCellList.C.
78{
79 return addCell(std::make_unique<CSGCell>(name, &lattice, region));
80}
CSGCell & addCell(std::unique_ptr< CSGCell > cell, const bool ignore_identical_cell=false)
add a cell to the CellList.
◆ addMaterialCell()
| CSGCell & CSG::CSGCellList::addMaterialCell |
( |
const std::string & |
name, |
|
|
const std::string & |
mat_name, |
|
|
const CSGRegion & |
region |
|
) |
| |
|
protected |
Add a Material Cell object to cell list.
- Parameters
-
| name | unique cell name |
| mat_name | material name |
| region | cell region |
- Returns
- reference to CSGCell with material fill that was created and added to this CSGCellList
Definition at line 59 of file CSGCellList.C.
62{
63 return addCell(std::make_unique<CSGCell>(name, mat_name, region));
64}
◆ addUniverseCell()
Add a Universe Cell object to cell list.
- Parameters
-
| name | unique cell name |
| univ | universe |
| region | cell region |
- Returns
- reference to CSGCell with universe fill that was created and added to this CSGCellList
Definition at line 67 of file CSGCellList.C.
70{
71 return addCell(std::make_unique<CSGCell>(name, &univ, region));
72}
◆ addVoidCell()
| CSGCell & CSG::CSGCellList::addVoidCell |
( |
const std::string & |
name, |
|
|
const CSGRegion & |
region |
|
) |
| |
|
protected |
Add a Void Cell object cell list.
- Parameters
-
| name | unique cell name |
| region | cell region |
- Returns
- reference to CSGCell with void fill that was created and added to this CSGCellList
Definition at line 53 of file CSGCellList.C.
54{
55 return addCell(std::make_unique<CSGCell>(name, region));
56}
◆ getAllCells()
| std::vector< std::reference_wrapper< const CSGCell > > CSG::CSGCellList::getAllCells |
( |
| ) |
const |
|
protected |
◆ getCell()
| CSGCell & CSG::CSGCellList::getCell |
( |
const std::string & |
name | ) |
const |
|
protected |
◆ getCellListMap() [1/2]
| std::unordered_map< std::string, std::unique_ptr< CSGCell > > & CSG::CSGCellList::getCellListMap |
( |
| ) |
|
|
inlineprotected |
◆ getCellListMap() [2/2]
| const std::unordered_map< std::string, std::unique_ptr< CSGCell > > & CSG::CSGCellList::getCellListMap |
( |
| ) |
const |
|
inlineprotected |
Get const map of all names to cells in cell list.
- Returns
- map of all names to CSGCell pointers
Definition at line 99 of file CSGCellList.h.
◆ hasCell()
| bool CSG::CSGCellList::hasCell |
( |
const std::string & |
name | ) |
const |
|
inlineprotected |
◆ operator!=()
| bool CSG::CSGCellList::operator!= |
( |
const CSGCellList & |
other | ) |
const |
|
protected |
Operator overload for checking if two CSGCellList objects are not equal.
Definition at line 132 of file CSGCellList.C.
133{
134 return !(*this == other);
135}
◆ operator==()
| bool CSG::CSGCellList::operator== |
( |
const CSGCellList & |
other | ) |
const |
|
protected |
Operator overload for checking if two CSGCellList objects are equal.
Definition at line 108 of file CSGCellList.C.
109{
111 const auto other_cells = other.getAllCells();
112
113
114 if (all_cells.size() != other_cells.size())
115 return false;
116
117
118
119 for (const auto & cell : all_cells)
120 {
121 const auto & cell_name = cell.get().getName();
122 if (!other.hasCell(cell_name))
123 return false;
124 const auto & other_cell = other.getCell(cell_name);
125 if (cell.get() != other_cell)
126 return false;
127 }
128 return true;
129}
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
◆ renameCell()
| void CSG::CSGCellList::renameCell |
( |
const CSGCell & |
cell, |
|
|
const std::string & |
name |
|
) |
| |
|
protected |
rename the specified cell
- Parameters
-
| cell | reference to CSGCell object that should be renamed |
| name | new name |
Definition at line 92 of file CSGCellList.C.
93{
94
95 auto prev_name = cell.getName();
96 auto it =
_cells.find(prev_name);
97 if (it ==
_cells.end() || it->second.get() != &cell)
98 mooseError(
"Cell " + prev_name +
" cannot be renamed to " + name +
99 " as it does not exist in this CSGBase instance.");
100
101 auto existing_cell = std::move(
_cells.find(prev_name)->second);
102 existing_cell->setName(name);
104 addCell(std::move(existing_cell));
105}
◆ CSGBase
◆ _cells
| std::unordered_map<std::string, std::unique_ptr<CSGCell> > CSG::CSGCellList::_cells |
|
protected |
The documentation for this class was generated from the following files: