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 ()
 Destructor. More...
 
const CSGSurfaceaddSurface (std::unique_ptr< CSGSurface > surf)
 add a unique surface pointer to this base instance 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...
 
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...
 
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...
 
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...
 
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 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...
 
void joinOtherBase (std::unique_ptr< CSGBase > base)
 Join another CSGBase object to this one. More...
 
void joinOtherBase (std::unique_ptr< CSGBase > base, std::string &new_root_name_join)
 Join another CSGBase object to this one. More...
 
void joinOtherBase (std::unique_ptr< CSGBase > base, 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...
 

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) const
 Recursive method to retrieve all universes linked to current universe. More...
 
CSGSurfaceListgetSurfaceList ()
 Get the CSGSurfaceList object. More...
 
CSGCellListgetCellList ()
 Get the CSGCellList object. More...
 
CSGUniverseListgetUniverseList ()
 Get the CSGUniverseList object. More...
 
void joinSurfaceList (CSGSurfaceList &surf_list)
 join a separate CSGSurfaceList object to this one More...
 
void joinCellList (CSGCellList &cell_list)
 join a separate CSGCellList 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 checkCellInBase (const CSGCell &cell) const
 
bool checkUniverseInBase (const CSGUniverse &universe) const
 
 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...
 

Detailed Description

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

Definition at line 29 of file CSGBase.h.

Constructor & Destructor Documentation

◆ CSGBase()

CSG::CSGBase::CSGBase ( )

Default constructor.

Definition at line 15 of file CSGBase.C.

16  : _surface_list(CSGSurfaceList()), _cell_list(CSGCellList()), _universe_list(CSGUniverseList())
17 {
18 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:416
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419

◆ ~CSGBase()

CSG::CSGBase::~CSGBase ( )

Destructor.

Definition at line 20 of file CSGBase.C.

20 {}

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 109 of file CSGBase.C.

Referenced by createUniverse().

111 {
112  for (auto & c : cells)
113  addCellToUniverse(universe, c);
114 }
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:92

◆ 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 92 of file CSGBase.C.

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

93 {
94  // make sure cell is a part of this CSGBase instance
95  if (!checkCellInBase(cell))
96  mooseError("A cell named " + cell.getName() + " is being added to universe " +
97  universe.getName() +
98  " that is different from the cell of the same name in the CSGBase instance.");
99  // make sure universe is a part of this CSGBase instance
100  if (!checkUniverseInBase(universe))
101  mooseError("Cells are being added to a universe named " + universe.getName() +
102  " that is different " +
103  "from the universe of the same name in the CSGBase instance.");
104  auto & univ = _universe_list.getUniverse(universe.getName());
105  univ.addCell(cell);
106 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
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:282
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:272
void addCell(const CSGCell &cell)
add cell to universe
Definition: CSGUniverse.C:25

◆ 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 49 of file CSGBase.h.

50  {
51  return _surface_list.addSurface(std::move(surf));
52  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:416
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a surface object to existing SurfaceList.

◆ checkCellInBase()

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

Definition at line 272 of file CSGBase.C.

Referenced by addCellToUniverse(), removeCellFromUniverse(), and updateCellRegion().

273 {
274  auto name = cell.getName();
275  // if no cell by this name exists, an error will be produced by getCell
276  auto & list_cell = _cell_list.getCell(name);
277  // return whether that the cell in the list is the same as the cell provided (in memory)
278  return &cell == &list_cell;
279 }
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:419

◆ checkRegionSurfaces()

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

Definition at line 255 of file CSGBase.C.

Referenced by createCell(), and updateCellRegion().

256 {
257  auto & surfs = region.getSurfaces();
258  for (const CSGSurface & s : surfs)
259  {
260  auto sname = s.getName();
261  // if there is no surface by this name at all, there will be an error from getSurface
262  const auto & list_surf = _surface_list.getSurface(s.getName());
263  // if there is a surface by the same name, check that it is actually the surface being used
264  // (ie same surface points to same location in memory)
265  if (&s != &list_surf)
266  mooseError("Region is being set with a surface named " + sname +
267  " that is different from the surface of the same name in the CSGBase instance.");
268  }
269 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
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:416

◆ checkUniverseInBase()

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

Definition at line 282 of file CSGBase.C.

Referenced by addCellToUniverse(), and removeCellFromUniverse().

283 {
284  auto name = universe.getName();
285  // if no universe by this name exists, an error will be produced by getUniverse
286  auto & list_univ = _universe_list.getUniverse(name);
287  // return whether that the cell in the list is the same as the cell provided (in memory)
288  return &universe == &list_univ;
289 }
std::string name(const ElemQuality q)
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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 292 of file CSGBase.C.

Referenced by generateOutput().

293 {
294  std::vector<std::string> linked_universe_names;
295 
296  // Recursively figure out which universe names are linked to root universe
297  getLinkedUniverses(getRootUniverse(), linked_universe_names);
298 
299  // Iterate through all universes in universe list and check that they exist in universes linked
300  // to root universe list
301  for (const CSGUniverse & univ : getAllUniverses())
302  if (std::find(linked_universe_names.begin(), linked_universe_names.end(), univ.getName()) ==
303  linked_universe_names.end())
304  mooseWarning("Universe with name ", univ.getName(), " is not linked to root universe.");
305 }
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:30
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition: CSGBase.h:254
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
Definition: MooseError.h:357
void getLinkedUniverses(const CSGUniverse &univ, std::vector< std::string > &linked_universe_names) const
Recursive method to retrieve all universes linked to current universe.
Definition: CSGBase.C:308
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:171

◆ createCell() [1/3]

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 23 of file CSGBase.C.

27 {
28  checkRegionSurfaces(region);
29  auto & cell = _cell_list.addMaterialCell(name, mat_name, region);
30  if (add_to_univ)
31  addCellToUniverse(*add_to_univ, cell);
32  else
34  return cell;
35 }
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:171
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:255
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:92

◆ createCell() [2/3]

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 38 of file CSGBase.C.

41 {
42  checkRegionSurfaces(region);
43  auto & cell = _cell_list.addVoidCell(name, region);
44  if (add_to_univ)
45  addCellToUniverse(*add_to_univ, cell);
46  else
48  return cell;
49 }
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:171
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:255
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:92

◆ createCell() [3/3]

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 52 of file CSGBase.C.

56 {
57  checkRegionSurfaces(region);
58  if (add_to_univ && (&fill_univ == add_to_univ))
59  mooseError("Cell " + name +
60  " cannot be filled with the same universe to which it is being added.");
61 
62  auto & cell = _cell_list.addUniverseCell(name, fill_univ, region);
63  if (add_to_univ)
64  addCellToUniverse(*add_to_univ, cell);
65  else
67  return cell;
68 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
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:171
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:255
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition: CSGBase.C:92

◆ 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 200 of file CSGBase.h.

Referenced by joinUniverseList().

201  {
202  return _universe_list.addUniverse(name);
203  }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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 83 of file CSGBase.C.

85 {
86  auto & univ = _universe_list.addUniverse(name);
87  addCellsToUniverse(univ, cells); // performs a check that cells are a part of this base
88  return univ;
89 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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:109
CSGUniverse & addUniverse(const std::string &name)
create an empty universe

◆ 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

Definition at line 319 of file CSGBase.C.

320 {
321  // Check that orphaned universes do not exist in universe list of CSGBase object
323 
324  nlohmann::json csg_json;
325 
326  csg_json["surfaces"] = {};
327  csg_json["cells"] = {};
328  csg_json["universes"] = {};
329 
330  // get all surfaces information
331  auto all_surfs = getAllSurfaces();
332  for (const CSGSurface & s : all_surfs)
333  {
334  const auto & surf_name = s.getName();
335  const auto & coeffs = s.getCoeffs();
336  csg_json["surfaces"][surf_name] = {{"type", s.getSurfaceType()}, {"coefficients", {}}};
337  for (const auto & c : coeffs)
338  csg_json["surfaces"][surf_name]["coefficients"][c.first] = c.second;
339  }
340 
341  // Print out cell information
342  auto all_cells = getAllCells();
343  for (const CSGCell & c : all_cells)
344  {
345  const auto & cell_name = c.getName();
346  const auto & cell_region = c.getRegionAsString();
347  const auto & cell_filltype = c.getFillType();
348  const auto & fill_name = c.getFillName();
349  csg_json["cells"][cell_name]["filltype"] = cell_filltype;
350  csg_json["cells"][cell_name]["region"] = cell_region;
351  csg_json["cells"][cell_name]["fill"] = fill_name;
352  }
353 
354  // Print out universe information
355  auto all_univs = getAllUniverses();
356  for (const CSGUniverse & u : all_univs)
357  {
358  const auto & univ_name = u.getName();
359  const auto & univ_cells = u.getAllCells();
360  csg_json["universes"][univ_name]["cells"] = {};
361  for (const CSGCell & c : univ_cells)
362  csg_json["universes"][univ_name]["cells"].push_back(c.getName());
363  if (u.isRoot())
364  csg_json["universes"][univ_name]["root"] = u.isRoot();
365  }
366 
367  return csg_json;
368 }
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition: CSGBase.h:254
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
Definition: CSGBase.C:292
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
Definition: CSGBase.h:134
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.
Definition: CSGBase.h:59

◆ 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 134 of file CSGBase.h.

Referenced by generateOutput().

135  {
136  return _cell_list.getAllCells();
137  }
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition: CSGCellList.C:59
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419

◆ 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 59 of file CSGBase.h.

Referenced by generateOutput().

60  {
62  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:416
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 254 of file CSGBase.h.

Referenced by checkUniverseLinking(), and generateOutput().

255  {
257  }
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:422

◆ 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 145 of file CSGBase.h.

145 { 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:419

◆ getCellList()

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

Get the CSGCellList object.

Returns
CSGCellList

Definition at line 349 of file CSGBase.h.

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

◆ getLinkedUniverses()

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

Recursive method to retrieve all universes linked to current universe.

Parameters
univReference to universe under consideration
linked_universe_nameList of universe names linked to current universe

Definition at line 308 of file CSGBase.C.

Referenced by checkUniverseLinking().

310 {
311  linked_universe_names.push_back(univ.getName());
312  const auto & univ_cells = univ.getAllCells();
313  for (const CSGCell & cell : univ_cells)
314  if (cell.getFillType() == "UNIVERSE")
315  getLinkedUniverses(cell.getFillUniverse(), linked_universe_names);
316 }
void getLinkedUniverses(const CSGUniverse &univ, std::vector< std::string > &linked_universe_names) const
Recursive method to retrieve all universes linked to current universe.
Definition: CSGBase.C:308

◆ getRootUniverse()

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

Get the Root Universe object.

Returns
reference to root CSGUniverse

Definition at line 171 of file CSGBase.h.

Referenced by checkUniverseLinking(), createCell(), and joinUniverseList().

171 { return _universe_list.getRoot(); }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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 323 of file CSGBase.h.

323 { 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:416

◆ 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 70 of file CSGBase.h.

71  {
72  return _surface_list.getSurface(name);
73  }
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:416

◆ getSurfaceList()

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

Get the CSGSurfaceList object.

Returns
CSGSurfaceList

Definition at line 342 of file CSGBase.h.

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

◆ 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 265 of file CSGBase.h.

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

◆ getUniverseList()

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

Get the CSGUniverseList object.

Returns
CSGUniverseList

Definition at line 356 of file CSGBase.h.

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

◆ 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 179 of file CSGBase.C.

Referenced by joinOtherBase().

180 {
181  auto & cell_list_map = cell_list.getCellListMap();
182  for (auto & c : cell_list_map)
183  _cell_list.addCell(std::move(c.second));
184 }
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:419

◆ joinOtherBase() [1/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base)

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

Definition at line 142 of file CSGBase.C.

143 {
144  joinSurfaceList(base->getSurfaceList());
145  joinCellList(base->getCellList());
146  joinUniverseList(base->getUniverseList());
147 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:179
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:187
void joinSurfaceList(CSGSurfaceList &surf_list)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:168

◆ joinOtherBase() [2/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base,
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
new_root_name_joinnew name for the universe generated from the incoming root universe

Definition at line 150 of file CSGBase.C.

151 {
152  joinSurfaceList(base->getSurfaceList());
153  joinCellList(base->getCellList());
154  joinUniverseList(base->getUniverseList(), new_root_name_join);
155 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:179
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:187
void joinSurfaceList(CSGSurfaceList &surf_list)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:168

◆ joinOtherBase() [3/3]

void CSG::CSGBase::joinOtherBase ( std::unique_ptr< CSGBase base,
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
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 158 of file CSGBase.C.

161 {
162  joinSurfaceList(base->getSurfaceList());
163  joinCellList(base->getCellList());
164  joinUniverseList(base->getUniverseList(), new_root_name_base, new_root_name_join);
165 }
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
Definition: CSGBase.C:179
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:187
void joinSurfaceList(CSGSurfaceList &surf_list)
join a separate CSGSurfaceList object to this one
Definition: CSGBase.C:168

◆ joinSurfaceList()

void CSG::CSGBase::joinSurfaceList ( CSGSurfaceList surf_list)
private

join a separate CSGSurfaceList object to this one

Parameters
surf_listCSGSurfaceList from a separate CSGBase object

Definition at line 168 of file CSGBase.C.

Referenced by joinOtherBase().

169 {
170  // TODO: check if surface is a duplicate (by definition) and skip
171  // adding if duplicate; must update references to the surface in cell
172  // region definitions.
173  auto & surf_list_map = surf_list.getSurfaceListMap();
174  for (auto & s : surf_list_map)
175  _surface_list.addSurface(std::move(s.second));
176 }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:416
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
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 187 of file CSGBase.C.

Referenced by joinOtherBase().

188 {
189  // case 1: incoming root is joined into existing root; no new universes are created
190  auto & univ_list_map = univ_list.getUniverseListMap();
191  auto & root = getRootUniverse(); // this root universe
192  for (auto & u : univ_list_map)
193  {
194  if (u.second->isRoot())
195  {
196  // add existing cells to current root instead of creating new universe
197  auto all_cells = u.second->getAllCells();
198  for (auto & cell : all_cells)
199  addCellToUniverse(root, cell);
200  }
201  else // unique non-root universe to add to list
202  _universe_list.addUniverse(std::move(u.second));
203  }
204 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:171
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:92

◆ 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 207 of file CSGBase.C.

208 {
209  // case 2: incoming root is turned into new universe and existing root remains root
210 
211  // add incoming universes to current Base
212  auto & all_univs = univ_list.getUniverseListMap();
213  for (auto & u : all_univs)
214  {
215  if (u.second->isRoot())
216  {
217  // create new universe from incoming root universe
218  auto all_cells = u.second->getAllCells();
219  createUniverse(new_root_name_incoming, all_cells);
220  }
221  else // unique non-root universe to add to list
222  _universe_list.addUniverse(std::move(u.second));
223  }
224 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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:200

◆ 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 227 of file CSGBase.C.

230 {
231  // case 3: each root universe becomes a new universe and a new root is created
232 
233  // make a new universe from the existing root universe
234  auto & root = getRootUniverse();
235  auto root_cells = root.getAllCells();
236  createUniverse(new_root_name_base, root_cells);
237  removeCellsFromUniverse(root, root_cells);
238 
239  // add incoming universes to current Base
240  auto & all_univs = univ_list.getUniverseListMap();
241  for (auto & u : all_univs)
242  {
243  if (u.second->isRoot())
244  {
245  // create new universe from incoming root universe
246  auto all_cells = u.second->getAllCells();
247  createUniverse(new_root_name_incoming, all_cells);
248  }
249  else // unique non-root universe to add to list
250  _universe_list.addUniverse(std::move(u.second));
251  }
252 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition: CSGBase.h:171
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:134
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:200

◆ 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 117 of file CSGBase.C.

Referenced by removeCellsFromUniverse().

118 {
119  // make sure cell is a part of this CSGBase instance
120  if (!checkCellInBase(cell))
121  mooseError("A cell named " + cell.getName() + " is being removed from universe " +
122  universe.getName() +
123  " that is different from the cell of the same name in the CSGBase instance.");
124  // make sure universe is a part of this CSGBase instance
125  if (!checkUniverseInBase(universe))
126  mooseError("Cells are being removed from a universe named " + universe.getName() +
127  " that is different " +
128  "from the universe of the same name in the CSGBase instance.");
129  auto & univ = _universe_list.getUniverse(universe.getName());
130  univ.removeCell(cell.getName());
131 }
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
Definition: CSGUniverse.C:56
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:282
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:272

◆ 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 134 of file CSGBase.C.

Referenced by joinUniverseList().

136 {
137  for (auto & c : cells)
138  removeCellFromUniverse(universe, c);
139 }
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
Definition: CSGBase.C:117

◆ 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 153 of file CSGBase.h.

154  {
155  _cell_list.renameCell(cell, name);
156  }
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
Definition: CSGCellList.C:68

◆ 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 178 of file CSGBase.h.

179  {
181  }
std::string name(const ElemQuality q)
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition: CSGBase.h:422
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 81 of file CSGBase.h.

82  {
83  _surface_list.renameSurface(surface, name);
84  }
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition: CSGBase.h:416
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 189 of file CSGBase.h.

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

◆ 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 71 of file CSGBase.C.

72 {
73  checkRegionSurfaces(region);
74  if (!checkCellInBase(cell))
75  mooseError("The region of cell with name " + cell.getName() +
76  " is being updated that is different " +
77  "from the cell of the same name in the CSGBase instance.");
78  auto & list_cell = _cell_list.getCell(cell.getName());
79  list_cell.updateRegion(region);
80 }
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition: CSGCellList.C:28
void updateRegion(const CSGRegion &region)
Definition: CSGCell.h:123
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:323
void checkRegionSurfaces(const CSGRegion &region) const
Definition: CSGBase.C:255
CSGCellList _cell_list
List of cells associated with CSG object.
Definition: CSGBase.h:419
bool checkCellInBase(const CSGCell &cell) const
Definition: CSGBase.C:272

Member Data Documentation

◆ _cell_list

CSGCellList CSG::CSGBase::_cell_list
private

List of cells associated with CSG object.

Definition at line 419 of file CSGBase.h.

Referenced by checkCellInBase(), createCell(), getAllCells(), getCellByName(), getCellList(), joinCellList(), renameCell(), and updateCellRegion().

◆ _surface_list

CSGSurfaceList CSG::CSGBase::_surface_list
private

List of surfaces associated with CSG object.

Definition at line 416 of file CSGBase.h.

Referenced by addSurface(), checkRegionSurfaces(), getAllSurfaces(), getSurface(), getSurfaceByName(), getSurfaceList(), joinSurfaceList(), and renameSurface().

◆ _universe_list

CSGUniverseList CSG::CSGBase::_universe_list
private

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