https://mooseframework.inl.gov
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CSG::CSGBase Class Reference

CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model. More...

#include <CSGBase.h>

Public Member Functions

 CSGBase ()
 Default constructor. More...
 
 CSGBase (const CSGBase &other_base)
 Copy constructor. More...
 
 ~CSGBase ()
 Destructor. More...
 
std::unique_ptr< CSGBaseclone () const
 Create a deep copy of this CSGBase instance. More...
 
const CSGSurfaceaddSurface (std::unique_ptr< CSGSurface > surf)
 add a unique surface pointer to this base instance More...
 
void deleteSurface (const CSGSurface &surface)
 Remove a Surface object passed in by reference from the stored surface list. More...
 
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces () const
 Get all surface objects. More...
 
const CSGSurfacegetSurfaceByName (const std::string &name) const
 Get a Surface object by name. More...
 
bool hasSurface (const std::string &name) const
 Check if a surface with given name exists in CSGBase object. More...
 
void renameSurface (const CSGSurface &surface, const std::string &name)
 rename the specified surface More...
 
const CSGCellcreateCell (const std::string &name, const std::string &mat_name, const CSGRegion &region, const CSGUniverse *add_to_univ=nullptr)
 Create a Material Cell object. More...
 
const CSGCellcreateCell (const std::string &name, const CSGRegion &region, const CSGUniverse *add_to_univ=nullptr)
 Create a Void Cell object. More...
 
const CSGCellcreateCell (const std::string &name, const CSGUniverse &fill_univ, const CSGRegion &region, const CSGUniverse *add_to_univ=nullptr)
 Create a Universe Cell object. More...
 
const CSGCellcreateCell (const std::string &name, const CSGLattice &fill_lattice, const CSGRegion &region, const CSGUniverse *add_to_univ=nullptr)
 Create a Lattice Cell object. More...
 
void deleteCell (const CSGCell &cell)
 Remove a Cell object passed in by reference from the stored cell list. More...
 
std::vector< std::reference_wrapper< const CSGCell > > getAllCells () const
 Get all cell objects. More...
 
const CSGCellgetCellByName (const std::string &name) const
 Get a Cell object by name. More...
 
bool hasCell (const std::string &name) const
 Check if a cell with given name exists in CSGBase object. More...
 
void renameCell (const CSGCell &cell, const std::string &name)
 rename the specified cell More...
 
void updateCellRegion (const CSGCell &cell, const CSGRegion &region)
 change the region of the specified cell More...
 
void resetCellFill (const CSGCell &cell)
 reset the fill of the specified cell to void More...
 
void updateCellFill (const CSGCell &cell, const std::string &mat_name)
 change the fill of the specified cell to a material fill More...
 
void updateCellFill (const CSGCell &cell, const CSGUniverse *univ)
 change the fill of the specified cell to a universe fill More...
 
void updateCellFill (const CSGCell &cell, const CSGLattice *lattice)
 change the fill of the specified cell to a lattice fill More...
 
const CSGUniversegetRootUniverse () const
 Get the Root Universe object. More...
 
void renameRootUniverse (const std::string &name)
 rename the root universe for this instance (default is ROOT_UNIVERSE) More...
 
void renameUniverse (const CSGUniverse &universe, const std::string &name)
 rename the specified universe More...
 
const CSGUniversecreateUniverse (const std::string &name)
 Create an empty Universe object. More...
 
const CSGUniversecreateUniverse (const std::string &name, std::vector< std::reference_wrapper< const CSGCell >> &cells)
 Create a Universe object from list of cells. More...
 
void deleteUniverse (const CSGUniverse &univ)
 Remove a Universe object passed in by reference from the stored universe list. More...
 
void addCellToUniverse (const CSGUniverse &universe, const CSGCell &cell)
 Add a cell to an existing universe. More...
 
void addCellsToUniverse (const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
 Add a list of cells to an existing universe. More...
 
void removeCellFromUniverse (const CSGUniverse &universe, const CSGCell &cell)
 Remove a cell from an existing universe. More...
 
void removeCellsFromUniverse (const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
 Remove a list of cells from an existing universe. More...
 
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses () const
 Get all universe objects. More...
 
const CSGUniversegetUniverseByName (const std::string &name)
 Get a universe object by name. More...
 
bool hasUniverse (const std::string &name) const
 Check if a universe with given name exists in CSGBase object. More...
 
template<typename LatticeType = CSGLattice>
const LatticeType & addLattice (std::unique_ptr< LatticeType > lattice)
 add a unique lattice pointer to this base instance; universes that make the lattice must already be a part of this CSGBase instance. More...
 
void deleteLattice (const CSGLattice &lattice)
 Remove a Lattice object passed in by reference from the stored lattice list. More...
 
void setUniverseAtLatticeIndex (const CSGLattice &lattice, const CSGUniverse &universe, std::pair< int, int > index)
 set location in the lattice to be the provided universe More...
 
void setLatticeUniverses (const CSGLattice &lattice, std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> &universes)
 Set provided universes as the layout of the lattice. More...
 
void renameLattice (const CSGLattice &lattice, const std::string &name)
 rename the lattice More...
 
void setLatticeOuter (const CSGLattice &lattice, const std::string &outer_name)
 Set the outer fill for the lattice to the material name provided. More...
 
void setLatticeOuter (const CSGLattice &lattice, const CSGUniverse &outer_univ)
 Set the outer fill for the lattice to the universe provided. More...
 
void resetLatticeOuter (const CSGLattice &lattice)
 reset the outer fill for the lattice to VOID More...
 
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices () const
 Get all lattice objects. More...
 
template<typename LatticeType = CSGLattice>
const LatticeType & getLatticeByName (const std::string &name)
 Get a lattice object of the specified type by name This is a templated method with a default type of CSGLattice. More...
 
bool hasLattice (const std::string &name) const
 Check if a lattice with given name exists in CSGBase object. More...
 
void joinOtherBase (std::unique_ptr< CSGBase > base, const bool ignore_identical_surfaces)
 Join another CSGBase object to this one. More...
 
void joinOtherBase (std::unique_ptr< CSGBase > base, const bool ignore_identical_surfaces, const std::string &new_root_name_join)
 Join another CSGBase object to this one. More...
 
void joinOtherBase (std::unique_ptr< CSGBase > base, const bool ignore_identical_surfaces, const std::string &new_root_name_base, const std::string &new_root_name_join)
 Join another CSGBase object to this one. More...
 
nlohmann::json generateOutput () const
 generate the JSON representation output for the CSG object More...
 
bool operator== (const CSGBase &other) const
 Operator overload for checking if two CSGBase objects are equal. More...
 
bool operator!= (const CSGBase &other) const
 Operator overload for checking if two CSGBase objects are not equal. More...
 
void addTransformation (const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
 Apply a transformation to a CSG object. More...
 
void applyTranslation (const CSGObjectVariant &csg_object, const std::tuple< Real, Real, Real > &distances)
 Apply a translation to a CSG object in the specified x, y, and z directions. More...
 
void applyRotation (const CSGObjectVariant &csg_object, const std::tuple< Real, Real, Real > &angles)
 Apply a rotation to a CSG object using (phi, theta, psi) angle notation (in degrees). More...
 
void applyAxisRotation (const CSGObjectVariant &csg_object, RotationAxisType axis, const Real angle)
 Apply a rotation to a CSG object about a specified axis (X, Y, Z). More...
 
void applyScaling (const CSGObjectVariant &csg_object, const std::tuple< Real, Real, Real > &values)
 Scale a CSG object in the specified x, y, and z directions. More...
 

Private Member Functions

CSGSurfacegetSurface (const std::string &name)
 Get a Surface object by name. More...
 
void checkUniverseLinking () const
 Check universes linked to root universe match universes defined in _universe_list. More...
 
void getLinkedUniverses (const CSGUniverse &univ, std::vector< std::string > &linked_universe_names, std::vector< std::string > &linked_cell_names) const
 Recursive method to retrieve all universes and cells linked to current universe. More...
 
const CSGSurfaceListgetSurfaceList () const
 Get a const reference to the CSGSurfaceList object. More...
 
CSGSurfaceListgetSurfaceList ()
 Get a non-const reference to the CSGSurfaceList object. More...
 
const CSGCellListgetCellList () const
 Get a const reference to the CSGCellList object. More...
 
CSGCellListgetCellList ()
 Get a non-const reference to the CSGCellList object. More...
 
const CSGUniverseListgetUniverseList () const
 Get a const reference to the CSGUniverseList object. More...
 
CSGUniverseListgetUniverseList ()
 Get a non-const reference to the CSGUniverseList object. More...
 
const CSGLatticeListgetLatticeList () const
 Get a const reference to the CSGLatticeList object. More...
 
CSGLatticeListgetLatticeList ()
 Get the CSGLatticeList object. More...
 
void updateIncomingCellRegions (CSGSurfaceList &surf_list, CSGCellList &cell_list)
 update cell regions of incoming CSGBase to point to surfaces contained within existing CSGBase object More...
 
void joinSurfaceList (CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
 join a separate CSGSurfaceList object to this one More...
 
void joinCellList (CSGCellList &cell_list)
 join a separate CSGCellList object to this one More...
 
void joinLatticeList (CSGLatticeList &lattice_list)
 join a separate CSGLatticeList object to this one More...
 
void joinUniverseList (CSGUniverseList &univ_list)
 join a separate CSGUniverseList object to this one; root universes from univ_list will be combined into this root universe More...
 
void joinUniverseList (CSGUniverseList &univ_list, const std::string &new_root_name_incoming)
 join a separate CSGUniverseList object to this one; the incoming root universe will be moved to a new universe of the new name specified. More...
 
void joinUniverseList (CSGUniverseList &univ_list, const std::string &new_root_name_base, const std::string &new_root_name_incoming)
 join a separate CSGUniverseList object to this one; both this root universe and the incoming root universe will be maintained as separate universes of the specified names. More...
 
void checkRegionSurfaces (const CSGRegion &region) const
 
bool checkSurfaceInBase (const CSGSurface &surface) const
 
bool checkCellInBase (const CSGCell &cell) const
 
bool checkUniverseInBase (const CSGUniverse &universe) const
 
bool checkLatticeInBase (const CSGLattice &lattice) const
 
const CSGCelladdCellToList (const CSGCell &cell)
 Add a new cell to the cell list based on a cell reference. More...
 
const CSGUniverseaddUniverseToList (const CSGUniverse &univ)
 Add a new universe to the universe list based on a universe reference. More...
 
const CSGLatticeaddLatticeToList (const CSGLattice &lattice)
 Add a new lattice to the lattice list based on a lattice reference. More...
 
 FRIEND_TEST (CSGBaseTest, testCheckRegionSurfaces)
 Friends for unit testing. More...
 
 FRIEND_TEST (CSGBaseTest, testAddGetSurface)
 
 FRIEND_TEST (CSGBaseTest, testUniverseLinking)
 

Private Attributes

CSGSurfaceList _surface_list
 List of surfaces associated with CSG object. More...
 
CSGCellList _cell_list
 List of cells associated with CSG object. More...
 
CSGUniverseList _universe_list
 List of universes associated with CSG object. More...
 
CSGLatticeList _lattice_list
 List of lattices associated with CSG object. More...
 

Detailed Description

CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model.

Definition at line 51 of file CSGBase.h.

Constructor & Destructor Documentation

◆ CSGBase() [1/2]

CSG::CSGBase::CSGBase ( )

Default constructor.

Definition at line 17 of file CSGBase.C.

18  : _surface_list(CSGSurfaceList()),
19  _cell_list(CSGCellList()),
20  _universe_list(CSGUniverseList()),
21  _lattice_list(CSGLatticeList())
22 {
23 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ CSGBase() [2/2]

CSG::CSGBase::CSGBase ( const CSGBase other_base)

Copy constructor.

Definition at line 25 of file CSGBase.C.

26  : _surface_list(other_base.getSurfaceList()),
27  _cell_list(CSGCellList()),
28  _universe_list(CSGUniverseList()),
29  _lattice_list(CSGLatticeList())
30 {
31  // Iterate through all cell references from the other CSGBase instance and
32  // create new CSGCell pointers based on these references. This is done
33  // recursively to properly handle cells with universe fills
34  for (const auto & [name, cell] : other_base.getCellList().getCellListMap())
35  addCellToList(*cell);
36 
37  // Link all cells in other_base root universe to current root universe
38  for (auto & root_cell : other_base.getRootUniverse().getAllCells())
39  {
40  const auto & list_cell = _cell_list.getCell(root_cell.get().getName());
41  addCellToUniverse(getRootUniverse(), list_cell);
42  }
43 
44  // Iterate through all universe references from the other CSGBase instance and
45  // create new CSGUniverse pointers based on these references. This is done in case
46  // any universe exist in the universe list that are not connected to the cell list.
47  for (const auto & [name, univ] : other_base.getUniverseList().getUniverseListMap())
48  addUniverseToList(*univ);
49 
50  // Iterate through all lattice references from the other CSGBase instance and
51  // create new CSGLattice pointers based on these references.
52  for (const auto & [name, lattice] : other_base.getLatticeList().getLatticeListMap())
53  addLatticeToList(*lattice);
54 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition: CSGBase.C:120
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
Definition: CSGBase.C:85
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
Definition: CSGBase.C:138

◆ ~CSGBase()

CSG::CSGBase::~CSGBase ( )

Destructor.

Definition at line 56 of file CSGBase.C.

56 {}

Member Function Documentation

◆ addCellsToUniverse()

void CSG::CSGBase::addCellsToUniverse ( const CSGUniverse universe,
std::vector< std::reference_wrapper< const CSGCell >> &  cells 
)

Add a list of cells to an existing universe.

Parameters
universeuniverse to which to add the cells
cellslist of references to cells to add

Definition at line 441 of file CSGBase.C.

Referenced by createUniverse().

443 {
444  for (auto & c : cells)
445  addCellToUniverse(universe, c);
446 }
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ addCellToList()

const CSGCell & CSG::CSGBase::addCellToList ( const CSGCell cell)
private

Add a new cell to the cell list based on a cell reference.

This method is called by the copy constructor of CSGBase

Parameters
cellreference to CSGCell that should be added to cell list

Definition at line 85 of file CSGBase.C.

Referenced by addUniverseToList(), and CSGBase().

86 {
87  // If cell has already been created, we just return a reference to it
88  const auto name = cell.getName();
89  if (_cell_list.hasCell(name))
90  return _cell_list.getCell(name);
91 
92  // Otherwise if the cell has material or void cell, we can create it directly
93  const auto fill_type = cell.getFillType();
94  const auto region = cell.getRegion();
95  if (fill_type == "VOID")
96  return _cell_list.addVoidCell(name, region);
97  else if (fill_type == "CSG_MATERIAL")
98  {
99  const auto mat_name = cell.getFillMaterial();
100  return _cell_list.addMaterialCell(name, mat_name, region);
101  }
102  else if (fill_type == "LATTICE")
103  {
104  // add lattice recursively to capture all linked universes in the lattice
105  const CSGLattice & lattice = addLatticeToList(cell.getFillLattice());
106  return _cell_list.addLatticeCell(name, lattice, region);
107  }
108  // Otherwise if the cell has a universe fill, we need to recursively define
109  // all linked universes and cells first before defining this cell
110  else if (fill_type == "UNIVERSE")
111  {
112  const auto & univ = addUniverseToList(cell.getFillUniverse());
113  return _cell_list.addUniverseCell(name, univ, region);
114  }
115  else
116  mooseError("Cell " + name + " has unrecognized fill type " + fill_type);
117 }
std::string name(const ElemQuality q)
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
const std::string getFillType() const
Get the type of fill for the cell.
Definition: CSGCell.h:77
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGCell & addVoidCell(const std::string &name, const CSGRegion &region)
Add a Void Cell object cell list.
Definition: CSGCellList.C:37
CSGCell & addMaterialCell(const std::string &name, const std::string &mat_name, const CSGRegion &region)
Add a Material Cell object to cell list.
Definition: CSGCellList.C:43
CSGCell & addUniverseCell(const std::string &name, const CSGUniverse &univ, const CSGRegion &region)
Add a Universe Cell object to cell list.
Definition: CSGCellList.C:51
CSGCell & addLatticeCell(const std::string &name, const CSGLattice &lattice, const CSGRegion &region)
Add a Lattice Cell object to cell list.
Definition: CSGCellList.C:59
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition: CSGBase.C:120
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
const std::string & getFillMaterial() const
Get the cell fill material name if fill fype is CSG_MATERIAL.
Definition: CSGCell.C:67
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
Definition: CSGBase.C:138
bool hasCell(const std::string &name) const
return whether cell with given name exists in cell list
Definition: CSGCellList.h:85

◆ addCellToUniverse()

void CSG::CSGBase::addCellToUniverse ( const CSGUniverse universe,
const CSGCell cell 
)

Add a cell to an existing universe.

Parameters
universeuniverse to which to add the cell
cellcell to add

Definition at line 424 of file CSGBase.C.

Referenced by addCellsToUniverse(), createCell(), CSGBase(), and joinUniverseList().

425 {
426  // make sure cell is a part of this CSGBase instance
427  if (!checkCellInBase(cell))
428  mooseError("A cell named " + cell.getName() + " is being added to universe " +
429  universe.getName() +
430  " that is different from the cell of the same name in the CSGBase instance.");
431  // make sure universe is a part of this CSGBase instance
432  if (!checkUniverseInBase(universe))
433  mooseError("Cells are being added to a universe named " + universe.getName() +
434  " that is different " +
435  "from the universe of the same name in the CSGBase instance.");
436  auto & univ = _universe_list.getUniverse(universe.getName());
437  univ.addCell(cell);
438 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840
void addCell(const CSGCell &cell)
add cell to universe
Definition: CSGUniverse.C:28

◆ addLattice()

template<typename LatticeType = CSGLattice>
const LatticeType& CSG::CSGBase::addLattice ( std::unique_ptr< LatticeType >  lattice)
inline

add a unique lattice pointer to this base instance; universes that make the lattice must already be a part of this CSGBase instance.

Parameters
latticepointer to lattice to add
Returns
reference to CSGLattice that was added

Definition at line 403 of file CSGBase.h.

Referenced by addLatticeToList().

404  {
405  static_assert(std::is_base_of_v<CSGLattice, LatticeType>, "Is not a CSGLattice");
406  // make sure all universes are a part of this base instance
407  auto universes = lattice->getUniverses();
408  for (auto univ_list : universes)
409  for (const CSGUniverse & univ : univ_list)
410  if (!checkUniverseInBase(univ))
411  mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
412  ". Universe " + univ.getName() + " is not in the CSGBase instance.");
413 
414  if (lattice->getOuterType() == "UNIVERSE")
415  {
416  const CSGUniverse & outer_univ = lattice->getOuterUniverse();
417  if (!checkUniverseInBase(outer_univ))
418  mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
419  ". Outer universe " + outer_univ.getName() + " is not in the CSGBase instance.");
420  }
421  auto & lat_ref = _lattice_list.addLattice(std::move(lattice));
422  return dynamic_cast<LatticeType &>(lat_ref);
423  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGLattice & addLattice(std::unique_ptr< CSGLattice > lattice)
add an existing lattice to list.
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ addLatticeToList()

const CSGLattice & CSG::CSGBase::addLatticeToList ( const CSGLattice lattice)
private

Add a new lattice to the lattice list based on a lattice reference.

This method is called by the copy constructor of CSGBase

Parameters
latticereference to CSGLattice that should be added to universe list

Definition at line 138 of file CSGBase.C.

Referenced by addCellToList(), and CSGBase().

139 {
140  // If lattice has already been created, we just return a reference to it
141  const auto name = lattice.getName();
142  if (_lattice_list.hasLattice(name))
143  return _lattice_list.getLattice(name);
144 
145  // Clone the lattice (associated universes need to be transferred and set)
146  auto cloned_lattice = lattice.clone();
147 
148  // If lattice has associated universes, we need to add them to this CSGBase instance as well.
149  // addUniverseToList is called recursively in case associated universes have not been added to
150  // the universe list yet.
151  std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> current_univ_map;
152  for (const auto & univ_list : lattice.getUniverses())
153  {
154  std::vector<std::reference_wrapper<const CSGUniverse>> current_univ_list;
155  for (const auto & univ_ref : univ_list)
156  current_univ_list.push_back(addUniverseToList(univ_ref.get()));
157  current_univ_map.push_back(current_univ_list);
158  }
159 
160  // Set universes only if lattice has universes defined
161  if (current_univ_map.size() > 0)
162  cloned_lattice->setUniverses(current_univ_map);
163 
164  // Update reference to outer universe if it exists
165  if (lattice.getOuterType() == "UNIVERSE")
166  {
167  const auto & outer_univ_ref = addUniverseToList(lattice.getOuterUniverse());
168  cloned_lattice->updateOuter(outer_univ_ref);
169  }
170 
171  // Use addLattice to add the cloned lattice
172  return addLattice(std::move(cloned_lattice));
173 }
std::string name(const ElemQuality q)
bool hasLattice(const std::string &name) const
return whether lattice with given name exists in lattice list
const LatticeType & addLattice(std::unique_ptr< LatticeType > lattice)
add a unique lattice pointer to this base instance; universes that make the lattice must already be a...
Definition: CSGBase.h:403
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition: CSGBase.C:120
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
virtual std::unique_ptr< CSGLattice > clone() const =0
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ addSurface()

const CSGSurface& CSG::CSGBase::addSurface ( std::unique_ptr< CSGSurface surf)
inline

add a unique surface pointer to this base instance

Parameters
surfpointer to surface to add
Returns
reference to CSGSurface that was added

Definition at line 79 of file CSGBase.h.

80  {
81  return _surface_list.addSurface(std::move(surf));
82  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf, const bool ignore_identical_surface=false)
add a surface object to existing SurfaceList.

◆ addTransformation()

void CSG::CSGBase::addTransformation ( const CSGObjectVariant csg_object,
TransformationType  type,
const std::tuple< Real, Real, Real > &  values 
)

Apply a transformation to a CSG object.

Parameters
csg_objectThe CSG object to transform (Surface, Cell, Universe, Region, or Lattice)
typeThe type of transformation to apply (TRANSLATION, ROTATION, SCALE)
valuestuple of transformation values (3 values for any transformation type)

Definition at line 545 of file CSGBase.C.

Referenced by applyAxisRotation(), applyRotation(), applyScaling(), and applyTranslation().

548 {
549  // Use std::visit to handle each type in the variant
550  std::visit(
551  [&](const auto & obj)
552  {
553  using T = std::decay_t<decltype(obj.get())>;
554 
555  // Handle each CSG object type differently because each needs to check that it exists in
556  // this base instance
557  if constexpr (std::is_same_v<T, CSGCell>)
558  {
559  const CSGCell & cell = obj.get();
560  if (!checkCellInBase(cell))
561  mooseError("Cannot apply transformation to cell ",
562  cell.getName(),
563  " that is not in this CSGBase instance.");
564 
565  // Get non-const reference and apply transformation
566  CSGCell & mutable_cell = _cell_list.getCell(cell.getName());
567  mooseAssert(mutable_cell == cell, "Mutable cell does not match const cell passed in.");
568  mutable_cell.addTransformation(type, values);
569  }
570  else if constexpr (std::is_same_v<T, CSGSurface>)
571  {
572  const CSGSurface & surface = obj.get();
573  if (!checkSurfaceInBase(surface))
574  mooseError("Cannot apply transformation to surface ",
575  surface.getName(),
576  " that is not in this CSGBase instance.");
577 
578  // Get non-const reference and apply transformation
579  CSGSurface & mutable_surface = _surface_list.getSurface(surface.getName());
580  mooseAssert(mutable_surface == surface,
581  "Mutable surface does not match const surface passed in.");
582  mutable_surface.addTransformation(type, values);
583  }
584  else if constexpr (std::is_same_v<T, CSGUniverse>)
585  {
586  const CSGUniverse & universe = obj.get();
587  if (!checkUniverseInBase(universe))
588  mooseError("Cannot apply transformation to universe ",
589  universe.getName(),
590  " that is not in this CSGBase instance.");
591 
592  // Get non-const reference and apply transformation
593  CSGUniverse & mutable_universe = _universe_list.getUniverse(universe.getName());
594  mooseAssert(mutable_universe == universe,
595  "Mutable universe does not match const universe passed in.");
596  mutable_universe.addTransformation(type, values);
597  }
598  else if constexpr (std::is_same_v<T, CSGLattice>)
599  {
600  const CSGLattice & lattice = obj.get();
601  if (!checkLatticeInBase(lattice))
602  mooseError("Cannot apply transformation to lattice ",
603  lattice.getName(),
604  " that is not in this CSGBase instance.");
605 
606  // Get non-const reference and apply transformation
607  CSGLattice & mutable_lattice = _lattice_list.getLattice(lattice.getName());
608  mooseAssert(mutable_lattice == lattice,
609  "Mutable lattice does not match const lattice passed in.");
610  mutable_lattice.addTransformation(type, values);
611  }
612  else if constexpr (std::is_same_v<T, CSGRegion>)
613  {
614  // iterate on the surfaces of the region and apply the transformation to those surfaces
615  const CSGRegion & region = obj.get();
616  const auto surfaces = region.getSurfaces();
617  for (const CSGSurface & surface : surfaces)
618  {
619  if (!checkSurfaceInBase(surface))
620  mooseError("Cannot apply transformation to region with surface ",
621  surface.getName(),
622  " that is not in this CSGBase instance.");
623  addTransformation(surface, type, values);
624  }
625  }
626  else
627  mooseError("Transformation not implemented for this object type: ", typeid(T).name());
628  },
629  csg_object);
630 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
Definition: CSGBase.C:545
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
bool checkSurfaceInBase(const CSGSurface &surface) const
Definition: CSGBase.C:830
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ addUniverseToList()

const CSGUniverse & CSG::CSGBase::addUniverseToList ( const CSGUniverse univ)
private

Add a new universe to the universe list based on a universe reference.

This method is called by the copy constructor of CSGBase

Parameters
univreference to CSGUniverse that should be added to universe list

Definition at line 120 of file CSGBase.C.

Referenced by addCellToList(), addLatticeToList(), and CSGBase().

121 {
122  // If universe has already been created, we just return a reference to it
123  const auto name = univ.getName();
124  if (_universe_list.hasUniverse(name))
125  return _universe_list.getUniverse(name);
126 
127  // Otherwise we create a new universe based on its associated cells.
128  // addCellToList is called recursively in case associated cells have not
129  // been added to the cell list yet.
130  const auto univ_cells = univ.getAllCells();
131  std::vector<std::reference_wrapper<const CSGCell>> current_univ_cells;
132  for (const auto & univ_cell : univ_cells)
133  current_univ_cells.push_back(addCellToList(univ_cell));
134  return createUniverse(name, current_univ_cells);
135 }
std::string name(const ElemQuality q)
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
Definition: CSGUniverse.h:73
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
bool hasUniverse(const std::string &name) const
return whether universe with given name exists in universe list
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
Definition: CSGBase.C:85
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
Definition: CSGBase.h:308

◆ applyAxisRotation()

void CSG::CSGBase::applyAxisRotation ( const CSGObjectVariant csg_object,
RotationAxisType  axis,
const Real  angle 
)

Apply a rotation to a CSG object about a specified axis (X, Y, Z).

Parameters
csg_objectThe CSG object to rotate (Surface, Cell, Universe, Region, or Lattice)
axisAxis type (X, Y, or Z) about which to rotate
angleangle in degrees to rotate about the specified axis

Definition at line 633 of file CSGBase.C.

636 {
637  // convert to the Euler angles (phi, theta, psi) based on axis
638  Real phi = 0.0;
639  Real theta = 0.0;
640  Real psi = 0.0;
641 
642  switch (axis)
643  {
644  case RotationAxisType::X:
645  theta = angle;
646  break;
647  case RotationAxisType::Y:
648  phi = 90.0;
649  theta = angle;
650  psi = -90.0;
651  break;
652  case RotationAxisType::Z:
653  phi = angle;
654  break;
655  default:
656  mooseError("Invalid axis type provided for axis rotation.");
657  }
658 
659  addTransformation(csg_object, TransformationType::ROTATION, std::make_tuple(phi, theta, psi));
660 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
Definition: CSGBase.C:545
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ applyRotation()

void CSG::CSGBase::applyRotation ( const CSGObjectVariant csg_object,
const std::tuple< Real, Real, Real > &  angles 
)
inline

Apply a rotation to a CSG object using (phi, theta, psi) angle notation (in degrees).

Parameters
csg_objectThe CSG object to rotate (Surface, Cell, Universe, Region, or Lattice)
anglessize 3 tuple {phi, theta, psi} with rotation angles in degrees

Definition at line 619 of file CSGBase.h.

621  {
622  addTransformation(csg_object, TransformationType::ROTATION, angles);
623  }
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
Definition: CSGBase.C:545

◆ applyScaling()

void CSG::CSGBase::applyScaling ( const CSGObjectVariant csg_object,
const std::tuple< Real, Real, Real > &  values 
)
inline

Scale a CSG object in the specified x, y, and z directions.

Parameters
csg_objectThe CSG object to scale (Surface, Cell, Universe, Region, or Lattice)
valuessize 3 tuple with scaling values in x, y, and z directions {x, y, z}

Definition at line 641 of file CSGBase.h.

643  {
644  addTransformation(csg_object, TransformationType::SCALE, values);
645  }
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
Definition: CSGBase.C:545

◆ applyTranslation()

void CSG::CSGBase::applyTranslation ( const CSGObjectVariant csg_object,
const std::tuple< Real, Real, Real > &  distances 
)
inline

Apply a translation to a CSG object in the specified x, y, and z directions.

Parameters
csg_objectThe CSG object to translate (Surface, Cell, Universe, Region, or Lattice)
distancessize 3 tuple with translation distances in x, y, and z directions {x, y, z}

Definition at line 607 of file CSGBase.h.

609  {
610  addTransformation(csg_object, TransformationType::TRANSLATION, distances);
611  }
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
Definition: CSGBase.C:545

◆ checkCellInBase()

bool CSG::CSGBase::checkCellInBase ( const CSGCell cell) const
private

Definition at line 840 of file CSGBase.C.

Referenced by addCellToUniverse(), addTransformation(), deleteCell(), removeCellFromUniverse(), resetCellFill(), updateCellFill(), and updateCellRegion().

841 {
842  auto name = cell.getName();
843  // if no cell by this name exists, an error will be produced by getCell
844  auto & list_cell = _cell_list.getCell(name);
845  // return whether that the cell in the list is the same as the cell provided (in memory)
846  return &cell == &list_cell;
847 }
std::string name(const ElemQuality q)
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ checkLatticeInBase()

bool CSG::CSGBase::checkLatticeInBase ( const CSGLattice lattice) const
private

Definition at line 860 of file CSGBase.C.

Referenced by addTransformation(), deleteLattice(), resetLatticeOuter(), setLatticeOuter(), setLatticeUniverses(), setUniverseAtLatticeIndex(), and updateCellFill().

861 {
862  auto name = lattice.getName();
863  // if no lattice by this name exists, an error will be produced by getLattice
864  auto & list_lattice = _lattice_list.getLattice(name);
865  // return whether that the lattice in the list is the same as the lattice provided (in memory)
866  return &lattice == &list_lattice;
867 }
std::string name(const ElemQuality q)
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ checkRegionSurfaces()

void CSG::CSGBase::checkRegionSurfaces ( const CSGRegion region) const
private

Definition at line 818 of file CSGBase.C.

Referenced by createCell(), and updateCellRegion().

819 {
820  const auto surfs = region.getSurfaces();
821  for (const CSGSurface & s : surfs)
822  {
823  if (!checkSurfaceInBase(s))
824  mooseError("Region is being set with a surface named " + s.getName() +
825  " that is different from the surface of the same name in the CSGBase instance.");
826  }
827 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool checkSurfaceInBase(const CSGSurface &surface) const
Definition: CSGBase.C:830

◆ checkSurfaceInBase()

bool CSG::CSGBase::checkSurfaceInBase ( const CSGSurface surface) const
private

Definition at line 830 of file CSGBase.C.

Referenced by addTransformation(), checkRegionSurfaces(), and deleteSurface().

831 {
832  auto name = surface.getName();
833  // if no surface by this name exists, an error will be produced by getSurface
834  auto & list_surf = _surface_list.getSurface(name);
835  // return whether that the surface in the list is the same as the surface provided (in memory)
836  return &surface == &list_surf;
837 }
std::string name(const ElemQuality q)
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ checkUniverseInBase()

bool CSG::CSGBase::checkUniverseInBase ( const CSGUniverse universe) const
private

Definition at line 850 of file CSGBase.C.

Referenced by addCellToUniverse(), addLattice(), addTransformation(), deleteUniverse(), removeCellFromUniverse(), setLatticeOuter(), setLatticeUniverses(), setUniverseAtLatticeIndex(), and updateCellFill().

851 {
852  auto name = universe.getName();
853  // if no universe by this name exists, an error will be produced by getUniverse
854  auto & list_univ = _universe_list.getUniverse(name);
855  // return whether that the universe in the list is the same as the universe provided (in memory)
856  return &universe == &list_univ;
857 }
std::string name(const ElemQuality q)
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.

◆ checkUniverseLinking()

void CSG::CSGBase::checkUniverseLinking ( ) const
private

Check universes linked to root universe match universes defined in _universe_list.

Definition at line 870 of file CSGBase.C.

Referenced by generateOutput().

871 {
872  std::vector<std::string> linked_universe_names;
873  std::vector<std::string> linked_cell_names;
874 
875  // Recursively figure out which universe names are linked to root universe
876  getLinkedUniverses(getRootUniverse(), linked_universe_names, linked_cell_names);
877 
878  // Iterate through all universes in universe list and check that they exist in universes linked
879  // to root universe
880  for (const CSGUniverse & univ : getAllUniverses())
881  if (std::find(linked_universe_names.begin(), linked_universe_names.end(), univ.getName()) ==
882  linked_universe_names.end())
883  mooseWarning("Universe with name ", univ.getName(), " is not linked to root universe.");
884 
885  // Iterate through all cells in cell list and check that they exist in cells linked
886  // to root universe
887  for (const CSGCell & cell : getAllCells())
888  if (std::find(linked_cell_names.begin(), linked_cell_names.end(), cell.getName()) ==
889  linked_cell_names.end())
890  mooseWarning("Cell with name ", cell.getName(), " is not linked to root universe.");
891 }
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
Definition: KokkosUtils.h:40
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition: CSGBase.h:370
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:345
void getLinkedUniverses(const CSGUniverse &univ, std::vector< std::string > &linked_universe_names, std::vector< std::string > &linked_cell_names) const
Recursive method to retrieve all universes and cells linked to current universe.
Definition: CSGBase.C:894
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
Definition: CSGBase.h:203

◆ clone()

std::unique_ptr<CSGBase> CSG::CSGBase::clone ( ) const
inline

Create a deep copy of this CSGBase instance.

Definition at line 70 of file CSGBase.h.

70 { return std::make_unique<CSGBase>(*this); }

◆ createCell() [1/4]

const CSGCell & CSG::CSGBase::createCell ( const std::string &  name,
const std::string &  mat_name,
const CSGRegion region,
const CSGUniverse add_to_univ = nullptr 
)

Create a Material Cell object.

Parameters
nameunique cell name
mat_namematerial name
regioncell region
add_to_univ(optional) universe to which this cell will be added (default is root universe)
Returns
reference to CSGCell that is created

Definition at line 199 of file CSGBase.C.

203 {
204  checkRegionSurfaces(region);
205  auto & cell = _cell_list.addMaterialCell(name, mat_name, region);
206  if (add_to_univ)
207  addCellToUniverse(*add_to_univ, cell);
208  else
210  return cell;
211 }
CSGCell & addMaterialCell(const std::string &name, const std::string &mat_name, const CSGRegion &region)
Add a Material Cell object to cell list.
Definition: CSGCellList.C:43
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:818
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ createCell() [2/4]

const CSGCell & CSG::CSGBase::createCell ( const std::string &  name,
const CSGRegion region,
const CSGUniverse add_to_univ = nullptr 
)

Create a Void Cell object.

Parameters
nameunique cell name
regioncell region
add_to_univ(optional) universe to which this cell will be added (default is root universe)
Returns
reference to CSGCell that is created

Definition at line 214 of file CSGBase.C.

217 {
218  checkRegionSurfaces(region);
219  auto & cell = _cell_list.addVoidCell(name, region);
220  if (add_to_univ)
221  addCellToUniverse(*add_to_univ, cell);
222  else
224  return cell;
225 }
CSGCell & addVoidCell(const std::string &name, const CSGRegion &region)
Add a Void Cell object cell list.
Definition: CSGCellList.C:37
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:818
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ createCell() [3/4]

const CSGCell & CSG::CSGBase::createCell ( const std::string &  name,
const CSGUniverse fill_univ,
const CSGRegion region,
const CSGUniverse add_to_univ = nullptr 
)

Create a Universe Cell object.

Parameters
nameunique cell name
fill_univuniverse that will fill the cell
regioncell region
add_to_univ(optional) universe to which this cell will be added (default is root universe)
Returns
reference to cell that is created

Definition at line 228 of file CSGBase.C.

232 {
233  checkRegionSurfaces(region);
234  if (add_to_univ && (&fill_univ == add_to_univ))
235  mooseError("Cell " + name +
236  " cannot be filled with the same universe to which it is being added.");
237 
238  auto & cell = _cell_list.addUniverseCell(name, fill_univ, region);
239  if (add_to_univ)
240  addCellToUniverse(*add_to_univ, cell);
241  else
243  return cell;
244 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGCell & addUniverseCell(const std::string &name, const CSGUniverse &univ, const CSGRegion &region)
Add a Universe Cell object to cell list.
Definition: CSGCellList.C:51
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:818
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ createCell() [4/4]

const CSGCell & CSG::CSGBase::createCell ( const std::string &  name,
const CSGLattice fill_lattice,
const CSGRegion region,
const CSGUniverse add_to_univ = nullptr 
)

Create a Lattice Cell object.

Parameters
nameunique cell name
fill_latticelattice that will fill the cell
regioncell region
add_to_univ(optional) universe to which this cell will be added (default is root universe)
Returns
reference to cell that is created

Definition at line 247 of file CSGBase.C.

251 {
252  checkRegionSurfaces(region);
253 
254  // check that cell is not being added to a universe that exists in the lattice itself
255  if (add_to_univ)
256  for (auto univ_list : fill_lattice.getUniverses())
257  for (const auto & univ_ref : univ_list)
258  {
259  const CSGUniverse & univ_in_lattice = univ_ref.get();
260  if (&univ_in_lattice == add_to_univ)
261  mooseError("Cell " + name +
262  " cannot be filled with a lattice containing the same universe to which it is "
263  "being added.");
264  }
265 
266  auto & cell = _cell_list.addLatticeCell(name, fill_lattice, region);
267  if (add_to_univ)
268  addCellToUniverse(*add_to_univ, cell);
269  else
271  return cell;
272 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
CSGCell & addLatticeCell(const std::string &name, const CSGLattice &lattice, const CSGRegion &region)
Add a Lattice Cell object to cell list.
Definition: CSGCellList.C:59
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:818
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ createUniverse() [1/2]

const CSGUniverse& CSG::CSGBase::createUniverse ( const std::string &  name)
inline

Create an empty Universe object.

Parameters
nameunique universe name
Returns
reference to CSGUniverse that is created

Definition at line 308 of file CSGBase.h.

Referenced by addUniverseToList(), and joinUniverseList().

309  {
310  return _universe_list.addUniverse(name);
311  }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGUniverse & addUniverse(const std::string &name)
create an empty universe

◆ createUniverse() [2/2]

const CSGUniverse & CSG::CSGBase::createUniverse ( const std::string &  name,
std::vector< std::reference_wrapper< const CSGCell >> &  cells 
)

Create a Universe object from list of cells.

Parameters
nameunique universe name
cellslist of cells to add to universe
Returns
reference to CSGUniverse that is created

Definition at line 371 of file CSGBase.C.

373 {
374  auto & univ = _universe_list.addUniverse(name);
375  addCellsToUniverse(univ, cells); // performs a check that cells are a part of this base
376  return univ;
377 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void addCellsToUniverse(const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
Add a list of cells to an existing universe.
Definition: CSGBase.C:441
CSGUniverse & addUniverse(const std::string &name)
create an empty universe

◆ deleteCell()

void CSG::CSGBase::deleteCell ( const CSGCell cell)

Remove a Cell object passed in by reference from the stored cell list.

Any CSG components connected to cell will not be recursively removed.

Parameters
cellreference to cell to delete

Definition at line 275 of file CSGBase.C.

276 {
277  if (!checkCellInBase(cell))
278  mooseError("Cell with name ",
279  cell.getName(),
280  " cannot be deleted as it is different from the cell of the same name in the "
281  "CSGBase instance.");
282 
283  // Check if cell exists in any existing universes. Cell will be removed from these universes
284  for (const auto & univ_ref : _universe_list.getAllUniverses())
285  {
286  const auto & univ = univ_ref.get();
287  const auto & univ_cells = univ.getAllCells();
288  for (const auto & univ_cell : univ_cells)
289  if (cell == univ_cell.get() && univ != getRootUniverse())
290  {
291  mooseWarning("Removing cell ",
292  cell.getName(),
293  " from universe with name ",
294  univ.getName(),
295  " before cell deletion.");
296  auto & univ_to_modify = _universe_list.getUniverse(univ.getName());
297  univ_to_modify.removeCell(cell.getName());
298  }
299  }
300 
301  _cell_list.getCellListMap().erase(cell.getName());
302 }
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all the universes in CSGBase instance.
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::unordered_map< std::string, std::unique_ptr< CSGCell > > & getCellListMap()
Get non-const map of all names to cells in cell list.
Definition: CSGCellList.h:92
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:345
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition: CSGUniverse.C:59
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ deleteLattice()

void CSG::CSGBase::deleteLattice ( const CSGLattice lattice)

Remove a Lattice object passed in by reference from the stored lattice list.

Any CSG components connected to lattice will not be recursively removed.

Parameters
latticereference to lattice to delete

Definition at line 176 of file CSGBase.C.

177 {
178  if (!checkLatticeInBase(lattice))
179  mooseError("Lattice with name ",
180  lattice.getName(),
181  " cannot be deleted as it is different from the lattice of the same name in the "
182  "CSGBase instance.");
183 
184  // Check if lattice is used as fill in existing cells
185  for (const auto & cell_ref : _cell_list.getAllCells())
186  {
187  const auto & cell = cell_ref.get();
188  if ((cell.getFillType() == "LATTICE") && (cell.getFillLattice() == lattice))
189  mooseError("Cannot delete lattice with name ",
190  lattice.getName(),
191  " as it is used as the fill of cell with name ",
192  cell.getName());
193  }
194 
195  _lattice_list.getLatticeListMap().erase(lattice.getName());
196 }
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition: CSGCellList.C:67
std::unordered_map< std::string, std::unique_ptr< CSGLattice > > & getLatticeListMap()
Get map of all names to lattices in lattice list.
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ deleteSurface()

void CSG::CSGBase::deleteSurface ( const CSGSurface surface)

Remove a Surface object passed in by reference from the stored surface list.

Any CSG components connected to surface will not be recursively removed.

Parameters
surfacereference to surface to delete

Definition at line 59 of file CSGBase.C.

60 {
61  if (!checkSurfaceInBase(surface))
62  mooseError("Surface with name ",
63  surface.getName(),
64  " cannot be deleted as it is different from the surface of the same name in the "
65  "CSGBase instance.");
66 
67  // Check if surface is used in region definition of existing cells
68  for (const auto & cell_ref : _cell_list.getAllCells())
69  {
70  const auto & cell = cell_ref.get();
71  const auto & cell_region = cell.getRegion();
72  const auto & region_surfaces = cell_region.getSurfaces();
73  for (const auto & region_surf : region_surfaces)
74  if (region_surf.get() == surface)
75  mooseError("Cannot delete surface with name ",
76  surface.getName(),
77  " as it is used in region definition of cell with name ",
78  cell.getName());
79  }
80 
81  _surface_list.getSurfaceListMap().erase(surface.getName());
82 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition: CSGCellList.C:67
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
bool checkSurfaceInBase(const CSGSurface &surface) const
Definition: CSGBase.C:830
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > & getSurfaceListMap()
Get non-const map of all names to surfaces in surface list.

◆ deleteUniverse()

void CSG::CSGBase::deleteUniverse ( const CSGUniverse univ)

Remove a Universe object passed in by reference from the stored universe list.

Any CSG components connected to universe will not be recursively removed.

Parameters
univreference to universe to delete

Definition at line 380 of file CSGBase.C.

381 {
382  if (!checkUniverseInBase(univ))
383  mooseError("Universe with name ",
384  univ.getName(),
385  " cannot be deleted as it is different from the universe of the same name in the "
386  "CSGBase instance.");
387 
388  // Check if universe is the root universe
389  if (univ == getRootUniverse())
390  mooseError("Cannot delete root universe from CSGBase instance");
391 
392  // Check if universe is used in any existing lattices
393  for (const auto & lat : _lattice_list.getAllLattices())
394  {
395  const auto & lattice_univs = lat.get().getUniqueUniverses();
396  for (const auto & lat_univ : lattice_univs)
397  if (univ == lat_univ.get())
398  mooseError("Cannot delete universe with name ",
399  univ.getName(),
400  " as it is used in lattice with name ",
401  lat.get().getName());
402  if ((lat.get().getOuterType() == "UNIVERSE") && (lat.get().getOuterUniverse() == univ))
403  mooseError("Cannot delete universe with name ",
404  univ.getName(),
405  " as it is used as the outer universe of lattice with name ",
406  lat.get().getName());
407  }
408 
409  // Check if universe is used as fill in existing cells
410  for (const auto & cell_ref : _cell_list.getAllCells())
411  {
412  const auto & cell = cell_ref.get();
413  if ((cell.getFillType() == "UNIVERSE") && (cell.getFillUniverse() == univ))
414  mooseError("Cannot delete universe with name ",
415  univ.getName(),
416  " as it is used as the fill of cell with name ",
417  cell.getName());
418  }
419 
420  _universe_list.getUniverseListMap().erase(univ.getName());
421 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition: CSGCellList.C:67
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all the lattices in CSGBase instance.
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
std::unordered_map< std::string, std::unique_ptr< CSGUniverse > > & getUniverseListMap()
Get non-const map of all names to universes in universe list.

◆ FRIEND_TEST() [1/3]

CSG::CSGBase::FRIEND_TEST ( CSGBaseTest  ,
testCheckRegionSurfaces   
)
private

Friends for unit testing.

◆ FRIEND_TEST() [2/3]

CSG::CSGBase::FRIEND_TEST ( CSGBaseTest  ,
testAddGetSurface   
)
private

◆ FRIEND_TEST() [3/3]

CSG::CSGBase::FRIEND_TEST ( CSGBaseTest  ,
testUniverseLinking   
)
private

◆ generateOutput()

nlohmann::json CSG::CSGBase::generateOutput ( ) const

generate the JSON representation output for the CSG object

Returns
nlohmann::json JSON object representing the CSG model

Definition at line 925 of file CSGBase.C.

926 {
927  // Check that orphaned universes do not exist in universe list of CSGBase object
929 
930  nlohmann::json csg_json;
931 
932  csg_json["surfaces"] = {};
933  csg_json["cells"] = {};
934  csg_json["universes"] = {};
935 
936  // get all surfaces information
937  auto all_surfs = getAllSurfaces();
938  for (const CSGSurface & s : all_surfs)
939  {
940  const auto & surf_name = s.getName();
941  const auto & coeffs = s.getCoeffs();
942  csg_json["surfaces"][surf_name] = {{"type", s.getSurfaceType()}, {"coefficients", {}}};
943  for (const auto & c : coeffs)
944  csg_json["surfaces"][surf_name]["coefficients"][c.first] = c.second;
945  // include any information about transformations if present
946  if (s.getTransformations().size() > 0)
947  csg_json["surfaces"][surf_name]["transformations"] = s.getTransformationsAsStrings();
948  }
949 
950  // Print out cell information
951  auto all_cells = getAllCells();
952  for (const CSGCell & c : all_cells)
953  {
954  const auto & cell_name = c.getName();
955  const auto & cell_region_infix = c.getRegion().toInfixJSON();
956  const auto & cell_region_postfix = c.getRegion().toPostfixStringList();
957  const auto & cell_filltype = c.getFillType();
958  const auto & fill_name = c.getFillName();
959  csg_json["cells"][cell_name]["filltype"] = cell_filltype;
960  csg_json["cells"][cell_name]["region_infix"] = cell_region_infix;
961  csg_json["cells"][cell_name]["region_postfix"] = cell_region_postfix;
962  csg_json["cells"][cell_name]["fill"] = fill_name;
963  // include any information about transformations if present
964  if (c.getTransformations().size())
965  csg_json["cells"][cell_name]["transformations"] = c.getTransformationsAsStrings();
966  }
967 
968  // Print out universe information
969  auto all_univs = getAllUniverses();
970  for (const CSGUniverse & u : all_univs)
971  {
972  const auto & univ_name = u.getName();
973  const auto & univ_cells = u.getAllCells();
974  csg_json["universes"][univ_name]["cells"] = {};
975  for (const CSGCell & c : univ_cells)
976  csg_json["universes"][univ_name]["cells"].push_back(c.getName());
977  if (u.isRoot())
978  csg_json["universes"][univ_name]["root"] = u.isRoot();
979  // include any information about transformations if present
980  if (u.getTransformations().size())
981  csg_json["universes"][univ_name]["transformations"] = u.getTransformationsAsStrings();
982  }
983 
984  // print out lattice information if lattices exist
985  auto all_lats = getAllLattices();
986  if (all_lats.size())
987  {
988  csg_json["lattices"] = {};
989  for (const CSGLattice & lat : all_lats)
990  {
991  const auto & lat_name = lat.getName();
992  csg_json["lattices"][lat_name] = {};
993  csg_json["lattices"][lat_name]["type"] = lat.getType();
994  const auto & outer_type = lat.getOuterType();
995  csg_json["lattices"][lat_name]["outertype"] = outer_type;
996  if (outer_type == "UNIVERSE")
997  csg_json["lattices"][lat_name]["outer"] = lat.getOuterUniverse().getName();
998  else if (outer_type == "CSG_MATERIAL")
999  csg_json["lattices"][lat_name]["outer"] = lat.getOuterMaterial();
1000  // write out any additional attributes
1001  csg_json["lattices"][lat_name]["attributes"] = {};
1002  const auto & lat_attrs = lat.getAttributes();
1003  for (const auto & attr : lat_attrs)
1004  csg_json["lattices"][lat_name]["attributes"][attr.first] = attr.second;
1005  // write the map of universe names: list of lists
1006  csg_json["lattices"][lat_name]["universes"] = lat.getUniverseNameMap();
1007  // include any information about transformations if present
1008  if (lat.getTransformations().size())
1009  csg_json["lattices"][lat_name]["transformations"] = lat.getTransformationsAsStrings();
1010  }
1011  }
1012 
1013  return csg_json;
1014 }
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition: CSGBase.h:370
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all lattice objects.
Definition: CSGBase.h:496
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
Definition: CSGBase.C:870
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
Definition: CSGBase.h:203
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.
Definition: CSGBase.h:97

◆ getAllCells()

std::vector<std::reference_wrapper<const CSGCell> > CSG::CSGBase::getAllCells ( ) const
inline

Get all cell objects.

Returns
list of references to all CSGCell objects in CSGBase

Definition at line 203 of file CSGBase.h.

Referenced by checkUniverseLinking(), and generateOutput().

204  {
205  return _cell_list.getAllCells();
206  }
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition: CSGCellList.C:67
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ getAllLattices()

std::vector<std::reference_wrapper<const CSGLattice> > CSG::CSGBase::getAllLattices ( ) const
inline

Get all lattice objects.

Returns
list of references to CSGLattice objects in this CSGBase instance

Definition at line 496 of file CSGBase.h.

Referenced by generateOutput().

497  {
498  return _lattice_list.getAllLattices();
499  }
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all the lattices in CSGBase instance.
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ getAllSurfaces()

std::vector<std::reference_wrapper<const CSGSurface> > CSG::CSGBase::getAllSurfaces ( ) const
inline

Get all surface objects.

Returns
list of references to all CSGSurface objects in CSGBase

Definition at line 97 of file CSGBase.h.

Referenced by generateOutput().

98  {
100  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get list of references to all surfaces in surface list.

◆ getAllUniverses()

std::vector<std::reference_wrapper<const CSGUniverse> > CSG::CSGBase::getAllUniverses ( ) const
inline

Get all universe objects.

Returns
list of references to CSGUniverse objects in this CSGBase instance

Definition at line 370 of file CSGBase.h.

Referenced by checkUniverseLinking(), and generateOutput().

371  {
373  }
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all the universes in CSGBase instance.
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841

◆ getCellByName()

const CSGCell& CSG::CSGBase::getCellByName ( const std::string &  name) const
inline

Get a Cell object by name.

Parameters
namecell name
Returns
reference to CSGCell object

Definition at line 214 of file CSGBase.h.

214 { return _cell_list.getCell(name); }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ getCellList() [1/2]

const CSGCellList& CSG::CSGBase::getCellList ( ) const
inlineprivate

Get a const reference to the CSGCellList object.

Returns
CSGCellList

Definition at line 692 of file CSGBase.h.

Referenced by CSGBase(), and operator==().

692 { return _cell_list; }
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ getCellList() [2/2]

CSGCellList& CSG::CSGBase::getCellList ( )
inlineprivate

Get a non-const reference to the CSGCellList object.

Returns
CSGCellList

Definition at line 699 of file CSGBase.h.

699 { return _cell_list; }
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ getLatticeByName()

template<typename LatticeType = CSGLattice>
const LatticeType& CSG::CSGBase::getLatticeByName ( const std::string &  name)
inline

Get a lattice object of the specified type by name This is a templated method with a default type of CSGLattice.

If a specific lattice type is needed, it can be specified when calling. If the type is unknown or not specified, it will default to CSGLattice to get the base class reference. NOTE: if CSGLattice is used as the template type, any lattice type-specific attributes or methods may not be accessible, except using a reference cast.

Parameters
namelattice name
Returns
reference to CSGLattice object

Definition at line 513 of file CSGBase.h.

514  {
515  const CSGLattice & lattice = _lattice_list.getLattice(name);
516  const LatticeType * typed_lattice = dynamic_cast<const LatticeType *>(&lattice);
517  if (!typed_lattice)
518  mooseError("Cannot get lattice " + name + ". Lattice is not of specified type " +
519  MooseUtils::prettyCppType<LatticeType>());
520  return *typed_lattice;
521  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ getLatticeList() [1/2]

const CSGLatticeList& CSG::CSGBase::getLatticeList ( ) const
inlineprivate

Get a const reference to the CSGLatticeList object.

Returns
CSGLatticeList

Definition at line 720 of file CSGBase.h.

Referenced by CSGBase(), and operator==().

720 { return _lattice_list; }
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ getLatticeList() [2/2]

CSGLatticeList& CSG::CSGBase::getLatticeList ( )
inlineprivate

Get the CSGLatticeList object.

Returns
CSGLatticeList

Definition at line 727 of file CSGBase.h.

727 { return _lattice_list; }
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ getLinkedUniverses()

void CSG::CSGBase::getLinkedUniverses ( const CSGUniverse univ,
std::vector< std::string > &  linked_universe_names,
std::vector< std::string > &  linked_cell_names 
) const
private

Recursive method to retrieve all universes and cells linked to current universe.

Parameters
univReference to universe under consideration
linked_universe_namesList of universe names linked to current universe
linked_cell_namesList of cell names linked to current universe

Definition at line 894 of file CSGBase.C.

Referenced by checkUniverseLinking().

897 {
898  linked_universe_names.push_back(univ.getName());
899  const auto & univ_cells = univ.getAllCells();
900  for (const CSGCell & cell : univ_cells)
901  {
902  linked_cell_names.push_back(cell.getName());
903  if (cell.getFillType() == "UNIVERSE")
904  getLinkedUniverses(cell.getFillUniverse(), linked_universe_names, linked_cell_names);
905  else if (cell.getFillType() == "LATTICE")
906  {
907  const auto & lattice = cell.getFillLattice();
908  for (const auto & univ_list : lattice.getUniverses())
909  for (const auto & univ_ref : univ_list)
910  {
911  const CSGUniverse & lattice_univ = univ_ref.get();
912  getLinkedUniverses(lattice_univ, linked_universe_names, linked_cell_names);
913  }
914 
915  if (lattice.getOuterType() == "UNIVERSE")
916  {
917  const CSGUniverse & outer_univ = lattice.getOuterUniverse();
918  getLinkedUniverses(outer_univ, linked_universe_names, linked_cell_names);
919  }
920  }
921  }
922 }
void getLinkedUniverses(const CSGUniverse &univ, std::vector< std::string > &linked_universe_names, std::vector< std::string > &linked_cell_names) const
Recursive method to retrieve all universes and cells linked to current universe.
Definition: CSGBase.C:894

◆ getRootUniverse()

const CSGUniverse& CSG::CSGBase::getRootUniverse ( ) const
inline

Get the Root Universe object.

Returns
reference to root CSGUniverse

Definition at line 279 of file CSGBase.h.

Referenced by checkUniverseLinking(), createCell(), CSGBase(), deleteCell(), deleteUniverse(), and joinUniverseList().

279 { return _universe_list.getRoot(); }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
const CSGUniverse & getRoot() const
Get the root universe.

◆ getSurface()

CSGSurface& CSG::CSGBase::getSurface ( const std::string &  name)
inlineprivate

Get a Surface object by name.

Note: This is a private method that returns a non-const reference. For the public method that returns a const reference, use getSurfaceByName

Parameters
namesurface name
Returns
reference to CSGSurface object

Definition at line 657 of file CSGBase.h.

657 { return _surface_list.getSurface(name); }
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ getSurfaceByName()

const CSGSurface& CSG::CSGBase::getSurfaceByName ( const std::string &  name) const
inline

Get a Surface object by name.

Parameters
namesurface name
Returns
reference to CSGSurface object

Definition at line 108 of file CSGBase.h.

Referenced by updateIncomingCellRegions().

109  {
110  return _surface_list.getSurface(name);
111  }
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ getSurfaceList() [1/2]

const CSGSurfaceList& CSG::CSGBase::getSurfaceList ( ) const
inlineprivate

Get a const reference to the CSGSurfaceList object.

Returns
CSGSurfaceList

Definition at line 678 of file CSGBase.h.

Referenced by operator==().

678 { return _surface_list; }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ getSurfaceList() [2/2]

CSGSurfaceList& CSG::CSGBase::getSurfaceList ( )
inlineprivate

Get a non-const reference to the CSGSurfaceList object.

Returns
CSGSurfaceList

Definition at line 685 of file CSGBase.h.

685 { return _surface_list; }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ getUniverseByName()

const CSGUniverse& CSG::CSGBase::getUniverseByName ( const std::string &  name)
inline

Get a universe object by name.

Parameters
nameuniverse name
Returns
reference to CSGUniverse object

Definition at line 381 of file CSGBase.h.

382  {
383  return _universe_list.getUniverse(name);
384  }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.

◆ getUniverseList() [1/2]

const CSGUniverseList& CSG::CSGBase::getUniverseList ( ) const
inlineprivate

Get a const reference to the CSGUniverseList object.

Returns
CSGUniverseList

Definition at line 706 of file CSGBase.h.

Referenced by CSGBase(), and operator==().

706 { return _universe_list; }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841

◆ getUniverseList() [2/2]

CSGUniverseList& CSG::CSGBase::getUniverseList ( )
inlineprivate

Get a non-const reference to the CSGUniverseList object.

Returns
CSGUniverseList

Definition at line 713 of file CSGBase.h.

713 { return _universe_list; }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841

◆ hasCell()

bool CSG::CSGBase::hasCell ( const std::string &  name) const
inline

Check if a cell with given name exists in CSGBase object.

Parameters
namecell name
Returns
true if cell with given name exists in CSGBase

Definition at line 222 of file CSGBase.h.

222 { return _cell_list.hasCell(name); }
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool hasCell(const std::string &name) const
return whether cell with given name exists in cell list
Definition: CSGCellList.h:85

◆ hasLattice()

bool CSG::CSGBase::hasLattice ( const std::string &  name) const
inline

Check if a lattice with given name exists in CSGBase object.

Parameters
namelattice name
Returns
true if lattice with given name exists in CSGBase

Definition at line 529 of file CSGBase.h.

529 { return _lattice_list.hasLattice(name); }
bool hasLattice(const std::string &name) const
return whether lattice with given name exists in lattice list
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ hasSurface()

bool CSG::CSGBase::hasSurface ( const std::string &  name) const
inline

Check if a surface with given name exists in CSGBase object.

Parameters
namesurface name
Returns
true if surface with given name exists in CSGBase

Definition at line 119 of file CSGBase.h.

Referenced by updateIncomingCellRegions().

119 { return _surface_list.hasSurface(name); }
bool hasSurface(const std::string &name) const
return whether surface with given name exists in surface list
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835

◆ hasUniverse()

bool CSG::CSGBase::hasUniverse ( const std::string &  name) const
inline

Check if a universe with given name exists in CSGBase object.

Parameters
nameuniverse name
Returns
true if universe with given name exists in CSGBase

Definition at line 392 of file CSGBase.h.

392 { return _universe_list.hasUniverse(name); }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
bool hasUniverse(const std::string &name) const
return whether universe with given name exists in universe list

◆ joinCellList()

void CSG::CSGBase::joinCellList ( CSGCellList cell_list)
private

join a separate CSGCellList object to this one

Parameters
cell_listCSGCellList from a separate CSGBase object

Definition at line 734 of file CSGBase.C.

Referenced by joinOtherBase().

735 {
736  auto & cell_list_map = cell_list.getCellListMap();
737  for (auto & c : cell_list_map)
738  _cell_list.addCell(std::move(c.second));
739 }
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
Definition: CSGCellList.C:18
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838

◆ joinLatticeList()

void CSG::CSGBase::joinLatticeList ( CSGLatticeList lattice_list)
private

join a separate CSGLatticeList object to this one

Parameters
lattice_listCSGLatticeList from a separate CSGBase object

Definition at line 742 of file CSGBase.C.

Referenced by joinOtherBase().

743 {
744  auto & lat_list_map = lattice_list.getLatticeListMap();
745  for (auto & lat : lat_list_map)
746  _lattice_list.addLattice(std::move(lat.second));
747 }
CSGLattice & addLattice(std::unique_ptr< CSGLattice > lattice)
add an existing lattice to list.
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ joinOtherBase() [1/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base,
const bool  ignore_identical_surfaces 
)

Join another CSGBase object to this one.

The cells of the root universe of the incoming CSGBase will be added to the existing root universe of this CSGBase.

Parameters
basepointer to a different CSGBase object
ignore_identical_surfacesif true, will skip adding identical surfaces to the CSGBase object

Definition at line 663 of file CSGBase.C.

664 {
665  // If we are ignoring identical incoming surfaces, we need to update the cell regions to
666  // point to the references of the pre-existing surfaces
667  if (ignore_identical_surfaces)
668  updateIncomingCellRegions(base->getSurfaceList(), base->getCellList());
669  joinSurfaceList(base->getSurfaceList(), ignore_identical_surfaces);
670  joinCellList(base->getCellList());
671  joinLatticeList(base->getLatticeList());
672  joinUniverseList(base->getUniverseList());
673 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:734
void joinUniverseList(CSGUniverseList &univ_list)
join a separate CSGUniverseList object to this one; root universes from univ_list will be combined in...
Definition: CSGBase.C:750
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:726
void updateIncomingCellRegions(CSGSurfaceList &surf_list, CSGCellList &cell_list)
update cell regions of incoming CSGBase to point to surfaces contained within existing CSGBase object...
Definition: CSGBase.C:707
void joinLatticeList(CSGLatticeList &lattice_list)
join a separate CSGLatticeList object to this one
Definition: CSGBase.C:742

◆ joinOtherBase() [2/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base,
const bool  ignore_identical_surfaces,
const std::string &  new_root_name_join 
)

Join another CSGBase object to this one.

For the incoming CSGBase object, the root universe is added to this CSGBase object as a new non-root universe with the specified new name. Note: this newly created universe will not be connected to the root universe of this CSGBase object by default.

Parameters
basepointer to a different CSGBase object
ignore_identical_surfacesif true, will skip adding identical surfaces to the CSGBase object
new_root_name_joinnew name for the universe generated from the incoming root universe

Definition at line 676 of file CSGBase.C.

679 {
680  // If we are ignoring identical incoming surfaces, we need to update the cell regions to
681  // point to the references of the pre-existing surfaces
682  if (ignore_identical_surfaces)
683  updateIncomingCellRegions(base->getSurfaceList(), base->getCellList());
684  joinSurfaceList(base->getSurfaceList(), ignore_identical_surfaces);
685  joinCellList(base->getCellList());
686  joinLatticeList(base->getLatticeList());
687  joinUniverseList(base->getUniverseList(), new_root_name_join);
688 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:734
void joinUniverseList(CSGUniverseList &univ_list)
join a separate CSGUniverseList object to this one; root universes from univ_list will be combined in...
Definition: CSGBase.C:750
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:726
void updateIncomingCellRegions(CSGSurfaceList &surf_list, CSGCellList &cell_list)
update cell regions of incoming CSGBase to point to surfaces contained within existing CSGBase object...
Definition: CSGBase.C:707
void joinLatticeList(CSGLatticeList &lattice_list)
join a separate CSGLatticeList object to this one
Definition: CSGBase.C:742

◆ joinOtherBase() [3/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base,
const bool  ignore_identical_surfaces,
const std::string &  new_root_name_base,
const std::string &  new_root_name_join 
)

Join another CSGBase object to this one.

The root universe for the incoming CSGBase object is added to this CSGBase object as a non-root universe with a new name. The root universe of this CSGBase object will be renamed and designated as non-root. Note: upon completion of this join method, the root universe of this CSGBase object will be empty. Neither of the new non-root universes will be connected to the new root universe by default.

Parameters
basepointer to a different CSGBase object
ignore_identical_surfacesif true, will skip adding identical surfaces to the CSGBase object
new_root_name_basenew name for universe generated from this root universe
new_root_name_joinnew name for the universe generated from the incoming root universe

Definition at line 691 of file CSGBase.C.

695 {
696  // If we are ignoring identical incoming surfaces, we need to update the cell regions to
697  // point to the references of the pre-existing surfaces
698  if (ignore_identical_surfaces)
699  updateIncomingCellRegions(base->getSurfaceList(), base->getCellList());
700  joinSurfaceList(base->getSurfaceList(), ignore_identical_surfaces);
701  joinCellList(base->getCellList());
702  joinLatticeList(base->getLatticeList());
703  joinUniverseList(base->getUniverseList(), new_root_name_base, new_root_name_join);
704 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:734
void joinUniverseList(CSGUniverseList &univ_list)
join a separate CSGUniverseList object to this one; root universes from univ_list will be combined in...
Definition: CSGBase.C:750
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:726
void updateIncomingCellRegions(CSGSurfaceList &surf_list, CSGCellList &cell_list)
update cell regions of incoming CSGBase to point to surfaces contained within existing CSGBase object...
Definition: CSGBase.C:707
void joinLatticeList(CSGLatticeList &lattice_list)
join a separate CSGLatticeList object to this one
Definition: CSGBase.C:742

◆ joinSurfaceList()

void CSG::CSGBase::joinSurfaceList ( CSGSurfaceList surf_list,
const bool  ignore_identical_surfaces 
)
private

join a separate CSGSurfaceList object to this one

Parameters
surf_listCSGSurfaceList from a separate CSGBase object
ignore_identical_surfacesif true, will skip adding identical surfaces to the CSGBase object

Definition at line 726 of file CSGBase.C.

Referenced by joinOtherBase().

727 {
728  auto & surf_list_map = surf_list.getSurfaceListMap();
729  for (auto & s : surf_list_map)
730  _surface_list.addSurface(std::move(s.second), ignore_identical_surfaces);
731 }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf, const bool ignore_identical_surface=false)
add a surface object to existing SurfaceList.

◆ joinUniverseList() [1/3]

void CSG::CSGBase::joinUniverseList ( CSGUniverseList univ_list)
private

join a separate CSGUniverseList object to this one; root universes from univ_list will be combined into this root universe

Parameters
univ_listCSGUniverseList from a separate CSGBase object

Definition at line 750 of file CSGBase.C.

Referenced by joinOtherBase().

751 {
752  // case 1: incoming root is joined into existing root; no new universes are created
753  auto & univ_list_map = univ_list.getUniverseListMap();
754  auto & root = getRootUniverse(); // this root universe
755  for (auto & u : univ_list_map)
756  {
757  if (u.second->isRoot())
758  {
759  // add existing cells to current root instead of creating new universe
760  auto all_cells = u.second->getAllCells();
761  for (auto & cell : all_cells)
762  addCellToUniverse(root, cell);
763  }
764  else // unique non-root universe to add to list
765  _universe_list.addUniverse(std::move(u.second));
766  }
767 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:424

◆ joinUniverseList() [2/3]

void CSG::CSGBase::joinUniverseList ( CSGUniverseList univ_list,
const std::string &  new_root_name_incoming 
)
private

join a separate CSGUniverseList object to this one; the incoming root universe will be moved to a new universe of the new name specified.

Parameters
univ_listCSGUniverseList from a separate CSGBase object
new_root_name_incomingnew name for the universe generated from the incoming root universe

Definition at line 770 of file CSGBase.C.

771 {
772  // case 2: incoming root is turned into new universe and existing root remains root
773 
774  // add incoming universes to current Base
775  auto & all_univs = univ_list.getUniverseListMap();
776  for (auto & u : all_univs)
777  {
778  if (u.second->isRoot())
779  {
780  // create new universe from incoming root universe
781  auto all_cells = u.second->getAllCells();
782  createUniverse(new_root_name_incoming, all_cells);
783  }
784  else // unique non-root universe to add to list
785  _universe_list.addUniverse(std::move(u.second));
786  }
787 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
Definition: CSGBase.h:308

◆ joinUniverseList() [3/3]

void CSG::CSGBase::joinUniverseList ( CSGUniverseList univ_list,
const std::string &  new_root_name_base,
const std::string &  new_root_name_incoming 
)
private

join a separate CSGUniverseList object to this one; both this root universe and the incoming root universe will be maintained as separate universes of the specified names.

Note: upon completion of this join method, the root universe will be empty.

Parameters
univ_listCSGUniverseList from a separate CSGBase object
new_root_name_basenew name for universe generated from this root universe
new_root_name_incomingnew name for the universe generated from the incoming root universe

Definition at line 790 of file CSGBase.C.

793 {
794  // case 3: each root universe becomes a new universe and a new root is created
795 
796  // make a new universe from the existing root universe
797  auto & root = getRootUniverse();
798  auto root_cells = root.getAllCells();
799  createUniverse(new_root_name_base, root_cells);
800  removeCellsFromUniverse(root, root_cells);
801 
802  // add incoming universes to current Base
803  auto & all_univs = univ_list.getUniverseListMap();
804  for (auto & u : all_univs)
805  {
806  if (u.second->isRoot())
807  {
808  // create new universe from incoming root universe
809  auto all_cells = u.second->getAllCells();
810  createUniverse(new_root_name_incoming, all_cells);
811  }
812  else // unique non-root universe to add to list
813  _universe_list.addUniverse(std::move(u.second));
814  }
815 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:279
void removeCellsFromUniverse(const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
Remove a list of cells from an existing universe.
Definition: CSGBase.C:466
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
Definition: CSGBase.h:308

◆ operator!=()

bool CSG::CSGBase::operator!= ( const CSGBase other) const

Operator overload for checking if two CSGBase objects are not equal.

Definition at line 1032 of file CSGBase.C.

1033 {
1034  return !(*this == other);
1035 }

◆ operator==()

bool CSG::CSGBase::operator== ( const CSGBase other) const

Operator overload for checking if two CSGBase objects are equal.

Definition at line 1017 of file CSGBase.C.

1018 {
1019  const auto & surf_list = this->getSurfaceList();
1020  const auto & other_surf_list = other.getSurfaceList();
1021  const auto & cell_list = this->getCellList();
1022  const auto & other_cell_list = other.getCellList();
1023  const auto & univ_list = this->getUniverseList();
1024  const auto & other_univ_list = other.getUniverseList();
1025  const auto & lat_list = this->getLatticeList();
1026  const auto & other_lat_list = other.getLatticeList();
1027  return (surf_list == other_surf_list) && (cell_list == other_cell_list) &&
1028  (univ_list == other_univ_list) && (lat_list == other_lat_list);
1029 }
const CSGLatticeList & getLatticeList() const
Get a const reference to the CSGLatticeList object.
Definition: CSGBase.h:720
const CSGSurfaceList & getSurfaceList() const
Get a const reference to the CSGSurfaceList object.
Definition: CSGBase.h:678
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
Definition: CSGBase.h:692
const CSGUniverseList & getUniverseList() const
Get a const reference to the CSGUniverseList object.
Definition: CSGBase.h:706

◆ removeCellFromUniverse()

void CSG::CSGBase::removeCellFromUniverse ( const CSGUniverse universe,
const CSGCell cell 
)

Remove a cell from an existing universe.

Parameters
universeuniverse from which to remove the cell
cellcell to remove

Definition at line 449 of file CSGBase.C.

Referenced by removeCellsFromUniverse().

450 {
451  // make sure cell is a part of this CSGBase instance
452  if (!checkCellInBase(cell))
453  mooseError("A cell named " + cell.getName() + " is being removed from universe " +
454  universe.getName() +
455  " that is different from the cell of the same name in the CSGBase instance.");
456  // make sure universe is a part of this CSGBase instance
457  if (!checkUniverseInBase(universe))
458  mooseError("Cells are being removed from a universe named " + universe.getName() +
459  " that is different " +
460  "from the universe of the same name in the CSGBase instance.");
461  auto & univ = _universe_list.getUniverse(universe.getName());
462  univ.removeCell(cell.getName());
463 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition: CSGUniverse.C:59
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ removeCellsFromUniverse()

void CSG::CSGBase::removeCellsFromUniverse ( const CSGUniverse universe,
std::vector< std::reference_wrapper< const CSGCell >> &  cells 
)

Remove a list of cells from an existing universe.

Parameters
universeuniverse from which to remove the cells
cellslist of references to cells to remove

Definition at line 466 of file CSGBase.C.

Referenced by joinUniverseList().

468 {
469  for (auto & c : cells)
470  removeCellFromUniverse(universe, c);
471 }
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
Definition: CSGBase.C:449

◆ renameCell()

void CSG::CSGBase::renameCell ( const CSGCell cell,
const std::string &  name 
)
inline

rename the specified cell

Parameters
cellreference to CSGCell to rename
namenew name

Definition at line 230 of file CSGBase.h.

231  {
232  _cell_list.renameCell(cell, name);
233  }
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
Definition: CSGCellList.C:76

◆ renameLattice()

void CSG::CSGBase::renameLattice ( const CSGLattice lattice,
const std::string &  name 
)
inline

rename the lattice

Parameters
latticelattice to rename
namenew name

Definition at line 461 of file CSGBase.h.

462  {
463  _lattice_list.renameLattice(lattice, name);
464  }
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the specified lattice
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844

◆ renameRootUniverse()

void CSG::CSGBase::renameRootUniverse ( const std::string &  name)
inline

rename the root universe for this instance (default is ROOT_UNIVERSE)

Parameters
namenew name for the root universe

Definition at line 286 of file CSGBase.h.

287  {
289  }
std::string name(const ElemQuality q)
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
const CSGUniverse & getRoot() const
Get the root universe.
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe

◆ renameSurface()

void CSG::CSGBase::renameSurface ( const CSGSurface surface,
const std::string &  name 
)
inline

rename the specified surface

Parameters
surfaceCSGSurface to rename
namenew name

Definition at line 127 of file CSGBase.h.

128  {
129  _surface_list.renameSurface(surface, name);
130  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:835
void renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface

◆ renameUniverse()

void CSG::CSGBase::renameUniverse ( const CSGUniverse universe,
const std::string &  name 
)
inline

rename the specified universe

Parameters
universereference to CSGUniverse to rename
namenew name

Definition at line 297 of file CSGBase.h.

298  {
299  _universe_list.renameUniverse(universe, name);
300  }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:841
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe

◆ resetCellFill()

void CSG::CSGBase::resetCellFill ( const CSGCell cell)

reset the fill of the specified cell to void

Parameters
cellcell to update the fill for

Definition at line 317 of file CSGBase.C.

318 {
319  if (!checkCellInBase(cell))
320  mooseError("The fill of cell with name " + cell.getName() +
321  " that is being updated is different " +
322  "from the cell of the same name in the CSGBase instance.");
323  auto & list_cell = _cell_list.getCell(cell.getName());
324  list_cell.resetCellFill();
325 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void resetCellFill()
Reset the cell fill to void.
Definition: CSGCell.C:85
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ resetLatticeOuter()

void CSG::CSGBase::resetLatticeOuter ( const CSGLattice lattice)

reset the outer fill for the lattice to VOID

Parameters
latticelattice to update

Definition at line 499 of file CSGBase.C.

500 {
501  auto name = lattice.getName();
502  if (!checkLatticeInBase(lattice))
503  mooseError("Cannot reset outer for lattice " + name +
504  ". Lattice is different from the lattice of the same name in the "
505  "CSGBase instance.");
507 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void resetOuter()
reset the outer fill around the lattice elements to be VOID
Definition: CSGLattice.C:145
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ setLatticeOuter() [1/2]

void CSG::CSGBase::setLatticeOuter ( const CSGLattice lattice,
const std::string &  outer_name 
)

Set the outer fill for the lattice to the material name provided.

This will set the outer type to CSG_MATERIAL regardless of its previous outer type.

Parameters
latticelattice to update
outer_namename of material to use as outer fill between lattice elements

Definition at line 474 of file CSGBase.C.

475 {
476  auto name = lattice.getName();
477  if (!checkLatticeInBase(lattice))
478  mooseError("Cannot set outer for lattice " + name +
479  ". Lattice is different from the lattice of the same name in the "
480  "CSGBase instance.");
481  _lattice_list.getLattice(name).updateOuter(outer_name);
482 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void updateOuter(const std::string &outer_name)
Update the outer of the lattice to be the provided material name.
Definition: CSGLattice.C:137
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ setLatticeOuter() [2/2]

void CSG::CSGBase::setLatticeOuter ( const CSGLattice lattice,
const CSGUniverse outer_univ 
)

Set the outer fill for the lattice to the universe provided.

This will set the outer type to UNIVERSE regardless of its previous outer type.

Parameters
latticelattice to update
outer_univuniverse to use as outer fill between lattice elements

Definition at line 485 of file CSGBase.C.

486 {
487  auto name = lattice.getName();
488  if (!checkLatticeInBase(lattice))
489  mooseError("Cannot set outer universe for lattice " + name +
490  ". Lattice is different from the lattice of the same name in the "
491  "CSGBase instance.");
492  if (!checkUniverseInBase(outer_univ))
493  mooseError("Cannot set outer universe for lattice " + name + ". Outer universe " +
494  outer_univ.getName() + " is not in the CSGBase instance.");
495  _lattice_list.getLattice(name).updateOuter(outer_univ);
496 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void updateOuter(const std::string &outer_name)
Update the outer of the lattice to be the provided material name.
Definition: CSGLattice.C:137
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ setLatticeUniverses()

void CSG::CSGBase::setLatticeUniverses ( const CSGLattice lattice,
std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> &  universes 
)

Set provided universes as the layout of the lattice.

Parameters
latticelattice to add universes to
universeslist of list of universes in the proper layout for the lattice type and dimensions

Definition at line 526 of file CSGBase.C.

529 {
530  auto name = lattice.getName();
531  if (!checkLatticeInBase(lattice))
532  mooseError("Cannot set universes for lattice " + name +
533  ". Lattice is different from the lattice of the same name in the "
534  "CSGBase instance.");
535  // make sure all universes are a part of this base instance
536  for (auto univ_list : universes)
537  for (const CSGUniverse & univ : univ_list)
538  if (!checkUniverseInBase(univ))
539  mooseError("Cannot set universes for lattice " + name + ". Universe " + univ.getName() +
540  " is not in the CSGBase instance.");
541  _lattice_list.getLattice(name).setUniverses(universes);
542 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
virtual void setUniverses(std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> universes)=0
assign the vectors of universes as the lattice elements
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ setUniverseAtLatticeIndex()

void CSG::CSGBase::setUniverseAtLatticeIndex ( const CSGLattice lattice,
const CSGUniverse universe,
std::pair< int, int index 
)

set location in the lattice to be the provided universe

Parameters
latticelattice to update
universeuniverse to set at the location
indexindex of the lattice element (int, int)

Definition at line 510 of file CSGBase.C.

513 {
514  auto name = lattice.getName();
515  if (!checkLatticeInBase(lattice))
516  mooseError("Cannot set universe at index for lattice " + name +
517  ". Lattice is different from the lattice of the same name in the "
518  "CSGBase instance.");
519  if (!checkUniverseInBase(universe))
520  mooseError("Cannot add universe " + universe.getName() + " to lattice " + lattice.getName() +
521  ". Universe is not in the CSGBase instance.");
522  _lattice_list.getLattice(name).setUniverseAtIndex(universe, index);
523 }
std::string name(const ElemQuality q)
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void setUniverseAtIndex(const CSGUniverse &universe, const std::pair< int, int > index)
replace the element at specified index in the lattice with the provided CSGUniverse.
Definition: CSGLattice.C:30
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition: CSGBase.h:844
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.

◆ updateCellFill() [1/3]

void CSG::CSGBase::updateCellFill ( const CSGCell cell,
const std::string &  mat_name 
)

change the fill of the specified cell to a material fill

Parameters
cellcell to update the fill for
mat_namename of material fill

Definition at line 328 of file CSGBase.C.

329 {
330  if (!checkCellInBase(cell))
331  mooseError("The region of cell with name " + cell.getName() +
332  " that is being updated is different " +
333  "from the cell of the same name in the CSGBase instance.");
334  auto & list_cell = _cell_list.getCell(cell.getName());
335  list_cell.updateCellFill(mat_name);
336 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void updateCellFill(const std::string &mat_name)
Set the cell fill to a material name.
Definition: CSGCell.C:94
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ updateCellFill() [2/3]

void CSG::CSGBase::updateCellFill ( const CSGCell cell,
const CSGUniverse univ 
)

change the fill of the specified cell to a universe fill

Parameters
cellcell to update the fill for
univpointer to universe fill

Definition at line 339 of file CSGBase.C.

340 {
341  if (!checkUniverseInBase(*univ))
342  mooseError("Universe with name ",
343  univ->getName(),
344  " is being used as a cell fill that is different from the universe of the same name "
345  "in the CSGBase instance.");
346  if (!checkCellInBase(cell))
347  mooseError("The fill of cell with name " + cell.getName() +
348  " that is being updated is different " +
349  "from the cell of the same name in the CSGBase instance.");
350  auto & list_cell = _cell_list.getCell(cell.getName());
351  list_cell.updateCellFill(univ);
352 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void updateCellFill(const std::string &mat_name)
Set the cell fill to a material name.
Definition: CSGCell.C:94
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool checkUniverseInBase(const CSGUniverse &universe) const
Definition: CSGBase.C:850
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ updateCellFill() [3/3]

void CSG::CSGBase::updateCellFill ( const CSGCell cell,
const CSGLattice lattice 
)

change the fill of the specified cell to a lattice fill

Parameters
cellcell to update the fill for
latticepointer to lattice fill

Definition at line 355 of file CSGBase.C.

356 {
357  if (!checkLatticeInBase(*lattice))
358  mooseError("Lattice with name ",
359  lattice->getName(),
360  " is being used as a cell fill that is different from the lattice of the same name "
361  "in the CSGBase instance.");
362  if (!checkCellInBase(cell))
363  mooseError("The fill of cell with name " + cell.getName() +
364  " that is being updated is different " +
365  "from the cell of the same name in the CSGBase instance.");
366  auto & list_cell = _cell_list.getCell(cell.getName());
367  list_cell.updateCellFill(lattice);
368 }
bool checkLatticeInBase(const CSGLattice &lattice) const
Definition: CSGBase.C:860
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void updateCellFill(const std::string &mat_name)
Set the cell fill to a material name.
Definition: CSGCell.C:94
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ updateCellRegion()

void CSG::CSGBase::updateCellRegion ( const CSGCell cell,
const CSGRegion region 
)

change the region of the specified cell

Parameters
cellcell to update the region for
regionnew region to assign to cell

Definition at line 305 of file CSGBase.C.

306 {
307  checkRegionSurfaces(region);
308  if (!checkCellInBase(cell))
309  mooseError("The region of cell with name " + cell.getName() +
310  " that is being updated is different " +
311  "from the cell of the same name in the CSGBase instance.");
312  auto & list_cell = _cell_list.getCell(cell.getName());
313  list_cell.updateRegion(region);
314 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void updateRegion(const CSGRegion &region)
Definition: CSGCell.h:170
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:818
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:838
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:840

◆ updateIncomingCellRegions()

void CSG::CSGBase::updateIncomingCellRegions ( CSGSurfaceList surf_list,
CSGCellList cell_list 
)
private

update cell regions of incoming CSGBase to point to surfaces contained within existing CSGBase object

Parameters
surf_listCSGSurfaceList from a separate CSGBase object
cell_listCSGCellList from a separate CSGBase object

Definition at line 707 of file CSGBase.C.

Referenced by joinOtherBase().

708 {
709  // Iterate through all incoming surfaces and track which ones have names already
710  // defined within this CSGSurfaceList object
711  std::map<std::string, std::reference_wrapper<const CSGSurface>> identical_surface_refs;
712  auto & surf_list_map = surf_list.getSurfaceListMap();
713  for (const auto & s : surf_list_map)
714  if (hasSurface(s.first))
715  identical_surface_refs.insert({s.first, getSurfaceByName(s.first)});
716 
717  if (!identical_surface_refs.empty())
718  {
719  auto & cell_list_map = cell_list.getCellListMap();
720  for (auto & c : cell_list_map)
721  c.second->updateCellRegionSurfaces(identical_surface_refs);
722  }
723 }
const CSGSurface & getSurfaceByName(const std::string &name) const
Get a Surface object by name.
Definition: CSGBase.h:108
bool hasSurface(const std::string &name) const
Check if a surface with given name exists in CSGBase object.
Definition: CSGBase.h:119

Member Data Documentation

◆ _cell_list

CSGCellList CSG::CSGBase::_cell_list
private

◆ _lattice_list

CSGLatticeList CSG::CSGBase::_lattice_list
private

◆ _surface_list

CSGSurfaceList CSG::CSGBase::_surface_list
private

◆ _universe_list

CSGUniverseList CSG::CSGBase::_universe_list
private

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