24 const std::string & mat_name,
58 if (add_to_univ && (&fill_univ == add_to_univ))
60 " cannot be filled with the same universe to which it is being added.");
76 " is being updated that is different " +
77 "from the cell of the same name in the CSGBase instance.");
84 std::vector<std::reference_wrapper<const CSGCell>> & cells)
98 " that is different from the cell of the same name in the CSGBase instance.");
102 " that is different " +
103 "from the universe of the same name in the CSGBase instance.");
110 std::vector<std::reference_wrapper<const CSGCell>> & cells)
112 for (
auto & c : cells)
121 mooseError(
"A cell named " + cell.
getName() +
" is being removed from universe " +
123 " that is different from the cell of the same name in the CSGBase instance.");
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.");
135 std::vector<std::reference_wrapper<const CSGCell>> & cells)
137 for (
auto & c : cells)
159 const std::string & new_root_name_base,
160 const std::string & new_root_name_join)
164 joinUniverseList(base->getUniverseList(), new_root_name_base, new_root_name_join);
174 for (
auto & s : surf_list_map)
182 for (
auto & c : cell_list_map)
192 for (
auto & u : univ_list_map)
194 if (u.second->isRoot())
197 auto all_cells = u.second->getAllCells();
198 for (
auto & cell : all_cells)
213 for (
auto & u : all_univs)
215 if (u.second->isRoot())
218 auto all_cells = u.second->getAllCells();
228 const std::string & new_root_name_base,
229 const std::string & new_root_name_incoming)
235 auto root_cells = root.getAllCells();
241 for (
auto & u : all_univs)
243 if (u.second->isRoot())
246 auto all_cells = u.second->getAllCells();
260 auto sname = s.getName();
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.");
278 return &cell == &list_cell;
288 return &universe == &list_univ;
294 std::vector<std::string> linked_universe_names;
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.");
309 std::vector<std::string> & linked_universe_names)
const 311 linked_universe_names.push_back(univ.
getName());
313 for (
const CSGCell & cell : univ_cells)
314 if (cell.getFillType() ==
"UNIVERSE")
324 nlohmann::json csg_json;
326 csg_json[
"surfaces"] = {};
327 csg_json[
"cells"] = {};
328 csg_json[
"universes"] = {};
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;
343 for (
const CSGCell & c : all_cells)
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;
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());
364 csg_json[
"universes"][univ_name][
"root"] = u.isRoot();
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.
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.
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 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...
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.
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...
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 map of all names to surfaces in surface list.
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...
CSGBase()
Default constructor.
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a surface object to existing SurfaceList.
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
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.
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 map of all names to universes in universe list.