https://mooseframework.inl.gov
Protected Member Functions | Protected Attributes | Friends | List of all members
CSG::CSGCellList Class Reference

CSGCellList creates a container for CSGCell objects to pass to CSGBase object. More...

#include <CSGCellList.h>

Protected Member Functions

 CSGCellList ()
 Default constructor. More...
 
virtual ~CSGCellList ()=default
 Destructor. More...
 
CSGCelladdMaterialCell (const std::string &name, const std::string &mat_name, const CSGRegion &region)
 Add a Material Cell object to cell list. More...
 
CSGCelladdVoidCell (const std::string &name, const CSGRegion &region)
 Add a Void Cell object cell list. More...
 
CSGCelladdUniverseCell (const std::string &name, const CSGUniverse &univ, const CSGRegion &region)
 Add a Universe Cell object to cell list. More...
 
std::unordered_map< std::string, std::unique_ptr< CSGCell > > & getCellListMap ()
 Get map of all names to cells in cell list. More...
 
std::vector< std::reference_wrapper< const CSGCell > > getAllCells () const
 Get all the cells in CSGBase instance. More...
 
CSGCellgetCell (const std::string &name) const
 Get the CSGCell by name. More...
 
CSGCelladdCell (std::unique_ptr< CSGCell > cell)
 add a cell to the CellList. More...
 
void renameCell (const CSGCell &cell, const std::string &name)
 rename the specified cell More...
 

Protected Attributes

std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
 Mapping of cell names to pointers of stored cell objects. More...
 

Friends

class CSGBase
 

Detailed Description

CSGCellList creates a container for CSGCell objects to pass to CSGBase object.

Definition at line 20 of file CSGCellList.h.

Constructor & Destructor Documentation

◆ CSGCellList()

CSG::CSGCellList::CSGCellList ( )
protected

Default constructor.

Definition at line 15 of file CSGCellList.C.

15 {}

◆ ~CSGCellList()

virtual CSG::CSGCellList::~CSGCellList ( )
protectedvirtualdefault

Destructor.

Member Function Documentation

◆ addCell()

CSGCell & CSG::CSGCellList::addCell ( std::unique_ptr< CSGCell cell)
protected

add a cell to the CellList.

Ownership of cell will be transferred to cell list object that calls this function

Parameters
cellcell to add to the CellList.
Returns
reference to CSGCell that was added to CellList

Definition at line 18 of file CSGCellList.C.

Referenced by addMaterialCell(), addUniverseCell(), addVoidCell(), CSG::CSGBase::joinCellList(), and renameCell().

19 {
20  auto name = cell->getName();
21  auto [it, inserted] = _cells.emplace(name, std::move(cell));
22  if (!inserted)
23  mooseError("Cell with name " + name + " already exists in geometry.");
24  return *it->second;
25 }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Definition: CSGCellList.h:107

◆ 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
nameunique cell name
mat_namematerial name
regioncell region
Returns
reference to CSGCell with material fill that was created and added to this CSGCellList

Definition at line 43 of file CSGCellList.C.

Referenced by CSG::CSGBase::createCell().

46 {
47  return addCell(std::make_unique<CSGCell>(name, mat_name, region));
48 }
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
Definition: CSGCellList.C:18

◆ addUniverseCell()

CSGCell & CSG::CSGCellList::addUniverseCell ( const std::string &  name,
const CSGUniverse univ,
const CSGRegion region 
)
protected

Add a Universe Cell object to cell list.

Parameters
nameunique cell name
univuniverse
regioncell region
Returns
reference to CSGCell with universe fill that was created and added to this CSGCellList

Definition at line 51 of file CSGCellList.C.

Referenced by CSG::CSGBase::createCell().

54 {
55  return addCell(std::make_unique<CSGCell>(name, &univ, region));
56 }
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
Definition: CSGCellList.C:18

◆ addVoidCell()

CSGCell & CSG::CSGCellList::addVoidCell ( const std::string &  name,
const CSGRegion region 
)
protected

Add a Void Cell object cell list.

Parameters
nameunique cell name
regioncell region
Returns
reference to CSGCell with void fill that was created and added to this CSGCellList

Definition at line 37 of file CSGCellList.C.

Referenced by CSG::CSGBase::createCell().

38 {
39  return addCell(std::make_unique<CSGCell>(name, region));
40 }
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
Definition: CSGCellList.C:18

◆ getAllCells()

std::vector< std::reference_wrapper< const CSGCell > > CSG::CSGCellList::getAllCells ( ) const
protected

Get all the cells in CSGBase instance.

Returns
list of references to all CSGCell objects

Definition at line 59 of file CSGCellList.C.

Referenced by CSG::CSGBase::getAllCells().

60 {
61  std::vector<std::reference_wrapper<const CSGCell>> cells;
62  for (auto it = _cells.begin(); it != _cells.end(); ++it)
63  cells.push_back(*(it->second));
64  return cells;
65 }
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Definition: CSGCellList.h:107

◆ getCell()

CSGCell & CSG::CSGCellList::getCell ( const std::string &  name) const
protected

Get the CSGCell by name.

Parameters
name
Returns
reference to CSGCell of the specified name

Definition at line 28 of file CSGCellList.C.

Referenced by CSG::CSGBase::checkCellInBase(), CSG::CSGBase::getCellByName(), and CSG::CSGBase::updateCellRegion().

29 {
30  if (_cells.find(name) == _cells.end())
31  mooseError("No cell by name " + name + " exists in the geometry.");
32  else
33  return *(_cells.find(name)->second);
34 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Definition: CSGCellList.h:107

◆ getCellListMap()

std::unordered_map<std::string, std::unique_ptr<CSGCell> >& CSG::CSGCellList::getCellListMap ( )
inlineprotected

Get map of all names to cells in cell list.

Returns
map of all names to CSGCell pointers

Definition at line 72 of file CSGCellList.h.

Referenced by CSG::CSGBase::joinCellList().

72 { return _cells; }
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Definition: CSGCellList.h:107

◆ renameCell()

void CSG::CSGCellList::renameCell ( const CSGCell cell,
const std::string &  name 
)
protected

rename the specified cell

Parameters
cellreference to CSGCell object that should be renamed
namenew name

Definition at line 68 of file CSGCellList.C.

Referenced by CSG::CSGBase::renameCell().

69 {
70  // check that this cell passed in is actually in the same cell that is in the cell list
71  auto prev_name = cell.getName();
72  auto it = _cells.find(prev_name);
73  if (it == _cells.end() || it->second.get() != &cell)
74  mooseError("Cell " + prev_name + " cannot be renamed to " + name +
75  " as it does not exist in this CSGBase instance.");
76 
77  auto existing_cell = std::move(_cells.find(prev_name)->second);
78  existing_cell->setName(name);
79  _cells.erase(prev_name);
80  addCell(std::move(existing_cell));
81 }
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
Definition: CSGCellList.C:18
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
std::unordered_map< std::string, std::unique_ptr< CSGCell > > _cells
Mapping of cell names to pointers of stored cell objects.
Definition: CSGCellList.h:107

Friends And Related Function Documentation

◆ CSGBase

friend class CSGBase
friend

Definition at line 110 of file CSGCellList.h.

Member Data Documentation

◆ _cells

std::unordered_map<std::string, std::unique_ptr<CSGCell> > CSG::CSGCellList::_cells
protected

Mapping of cell names to pointers of stored cell objects.

Definition at line 107 of file CSGCellList.h.

Referenced by addCell(), getAllCells(), getCell(), getCellListMap(), and renameCell().


The documentation for this class was generated from the following files: