21 : _surface_list(other_base.getSurfaceList()),
58 if (fill_type ==
"VOID")
60 else if (fill_type ==
"CSG_MATERIAL")
86 std::vector<std::reference_wrapper<const CSGCell>> current_univ_cells;
87 for (
const auto & univ_cell : univ_cells)
94 const std::string & mat_name,
128 if (add_to_univ && (&fill_univ == add_to_univ))
130 " cannot be filled with the same universe to which it is being added.");
146 " is being updated that is different " +
147 "from the cell of the same name in the CSGBase instance.");
154 std::vector<std::reference_wrapper<const CSGCell>> & cells)
168 " that is different from the cell of the same name in the CSGBase instance.");
172 " that is different " +
173 "from the universe of the same name in the CSGBase instance.");
180 std::vector<std::reference_wrapper<const CSGCell>> & cells)
182 for (
auto & c : cells)
191 mooseError(
"A cell named " + cell.
getName() +
" is being removed from universe " +
193 " that is different from the cell of the same name in the CSGBase instance.");
196 mooseError(
"Cells are being removed from a universe named " + universe.
getName() +
197 " that is different " +
198 "from the universe of the same name in the CSGBase instance.");
205 std::vector<std::reference_wrapper<const CSGCell>> & cells)
207 for (
auto & c : cells)
229 const std::string & new_root_name_base,
230 const std::string & new_root_name_join)
234 joinUniverseList(base->getUniverseList(), new_root_name_base, new_root_name_join);
244 for (
auto & s : surf_list_map)
252 for (
auto & c : cell_list_map)
262 for (
auto & u : univ_list_map)
264 if (u.second->isRoot())
267 auto all_cells = u.second->getAllCells();
268 for (
auto & cell : all_cells)
283 for (
auto & u : all_univs)
285 if (u.second->isRoot())
288 auto all_cells = u.second->getAllCells();
298 const std::string & new_root_name_base,
299 const std::string & new_root_name_incoming)
305 auto root_cells = root.getAllCells();
311 for (
auto & u : all_univs)
313 if (u.second->isRoot())
316 auto all_cells = u.second->getAllCells();
330 auto sname = s.getName();
335 if (&s != &list_surf)
336 mooseError(
"Region is being set with a surface named " + sname +
337 " that is different from the surface of the same name in the CSGBase instance.");
348 return &cell == &list_cell;
358 return &universe == &list_univ;
364 std::vector<std::string> linked_universe_names;
372 if (
std::find(linked_universe_names.begin(), linked_universe_names.end(), univ.getName()) ==
373 linked_universe_names.end())
374 mooseWarning(
"Universe with name ", univ.getName(),
" is not linked to root universe.");
379 std::vector<std::string> & linked_universe_names)
const 381 linked_universe_names.push_back(univ.
getName());
383 for (
const CSGCell & cell : univ_cells)
384 if (cell.getFillType() ==
"UNIVERSE")
394 nlohmann::json csg_json;
396 csg_json[
"surfaces"] = {};
397 csg_json[
"cells"] = {};
398 csg_json[
"universes"] = {};
404 const auto & surf_name = s.getName();
405 const auto & coeffs = s.getCoeffs();
406 csg_json[
"surfaces"][surf_name] = {{
"type", s.getSurfaceType()}, {
"coefficients", {}}};
407 for (
const auto & c : coeffs)
408 csg_json[
"surfaces"][surf_name][
"coefficients"][c.first] = c.second;
413 for (
const CSGCell & c : all_cells)
415 const auto & cell_name = c.getName();
416 const auto & cell_region = c.getRegionAsString();
417 const auto & cell_filltype = c.getFillType();
418 const auto & fill_name = c.getFillName();
419 csg_json[
"cells"][cell_name][
"filltype"] = cell_filltype;
420 csg_json[
"cells"][cell_name][
"region"] = cell_region;
421 csg_json[
"cells"][cell_name][
"fill"] = fill_name;
428 const auto & univ_name = u.getName();
429 const auto & univ_cells = u.getAllCells();
430 csg_json[
"universes"][univ_name][
"cells"] = {};
431 for (
const CSGCell & c : univ_cells)
432 csg_json[
"universes"][univ_name][
"cells"].push_back(c.getName());
434 csg_json[
"universes"][univ_name][
"root"] = u.isRoot();
446 const auto & other_cell_list = other.
getCellList();
449 return (surf_list == other_surf_list) && (cell_list == other_cell_list) &&
450 (univ_list == other_univ_list);
456 return !(*
this == other);
std::string name(const ElemQuality q)
CSGCell & addCell(std::unique_ptr< CSGCell > cell)
add a cell to the CellList.
void joinCellList(CSGCellList &cell_list)
join a separate CSGCellList object to this one
KOKKOS_INLINE_FUNCTION const T * find(const T &target, const T *const begin, const T *const end)
Find a value in an array.
const CSGUniverse & getFillUniverse() const
Get the cell fill if fill type is UNIVERSE.
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
const std::string & getName() const
Get the cell name.
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
CSGUniverseList _universe_list
List of universes associated with CSG object.
const std::string getFillType() const
Get the type of fill for the cell.
void updateRegion(const CSGRegion ®ion)
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
CSGCellList creates a container for CSGCell objects to pass to CSGBase object.
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
std::unordered_map< std::string, std::unique_ptr< CSGCell > > & getCellListMap()
Get non-const map of all names to cells in cell list.
void mooseWarning(Args &&... args)
Emit a warning message with the given stringified, concatenated args.
const CSGCell & createCell(const std::string &name, const std::string &mat_name, const CSGRegion ®ion, const CSGUniverse *add_to_univ=nullptr)
Create a Material Cell object.
void joinUniverseList(CSGUniverseList &univ_list)
join a separate CSGUniverseList object to this one; root universes from univ_list will be combined in...
void joinOtherBase(std::unique_ptr< CSGBase > base)
Join another CSGBase object to this one.
CSGCell & addVoidCell(const std::string &name, const CSGRegion ®ion)
Add a Void Cell object cell list.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
bool operator==(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are equal.
const std::vector< std::reference_wrapper< const CSGCell > > & getAllCells() const
Get list of the all cells in the universe.
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
void getLinkedUniverses(const CSGUniverse &univ, std::vector< std::string > &linked_universe_names) const
Recursive method to retrieve all universes linked to current universe.
nlohmann::json generateOutput() const
generate the JSON representation output for the CSG object
CSGCell & addMaterialCell(const std::string &name, const std::string &mat_name, const CSGRegion ®ion)
Add a Material Cell object to cell list.
void removeCell(const std::string &name)
remove a cell of the specified name from the universe
CSGCell & addUniverseCell(const std::string &name, const CSGUniverse &univ, const CSGRegion ®ion)
Add a Universe Cell object to cell list.
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
const std::string & getName() const
Get the name of the universe.
void addCellsToUniverse(const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
Add a list of cells to an existing universe.
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
void updateCellRegion(const CSGCell &cell, const CSGRegion ®ion)
change the region of the specified cell
CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase.
const std::vector< std::reference_wrapper< const CSGSurface > > & getSurfaces() const
Get the list of surfaces associated with the region.
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
void joinSurfaceList(CSGSurfaceList &surf_list)
join a separate CSGSurfaceList object to this one
void removeCellsFromUniverse(const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
Remove a list of cells from an existing universe.
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
bool checkUniverseInBase(const CSGUniverse &universe) const
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
bool operator!=(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are not equal.
void checkRegionSurfaces(const CSGRegion ®ion) const
CSGCellList _cell_list
List of cells associated with CSG object.
std::unordered_map< std::string, std::unique_ptr< CSGSurface > > & getSurfaceListMap()
Get non-const map of all names to surfaces in surface list.
const CSGSurfaceList & getSurfaceList() const
Get a const reference to the CSGSurfaceList object.
bool checkCellInBase(const CSGCell &cell) const
CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object.
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface...
const CSGRegion & getRegion() const
Get the cell region.
bool hasUniverse(const std::string &name) const
return whether universe with given name exists in universe list
CSGBase()
Default constructor.
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a surface object to existing SurfaceList.
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
const std::string & getFillMaterial() const
Get the cell fill material name if fill fype is CSG_MATERIAL.
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model...
const CSGUniverseList & getUniverseList() const
Get a const reference to the CSGUniverseList object.
bool hasCell(const std::string &name) const
return whether cell with given name exists in cell list
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
void addCell(const CSGCell &cell)
add cell to universe
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.
std::unordered_map< std::string, std::unique_ptr< CSGUniverse > > & getUniverseListMap()
Get non-const map of all names to universes in universe list.