18 #include "nlohmann/json.h" 20 #ifdef MOOSE_UNIT_TEST 21 #include "gtest/gtest.h" 40 typedef std::variant<std::reference_wrapper<const CSGSurface>,
41 std::reference_wrapper<const CSGCell>,
42 std::reference_wrapper<const CSGUniverse>,
43 std::reference_wrapper<const CSGRegion>,
44 std::reference_wrapper<const CSGLattice>>
70 std::unique_ptr<CSGBase>
clone()
const {
return std::make_unique<CSGBase>(*this); }
143 const std::string & mat_name,
203 std::vector<std::reference_wrapper<const CSGCell>>
getAllCells()
const 321 std::vector<std::reference_wrapper<const CSGCell>> & cells);
346 std::vector<std::reference_wrapper<const CSGCell>> & cells);
363 std::vector<std::reference_wrapper<const CSGCell>> & cells);
402 template <
typename LatticeType = CSGLattice>
403 const LatticeType &
addLattice(std::unique_ptr<LatticeType> lattice)
405 static_assert(std::is_base_of_v<CSGLattice, LatticeType>,
"Is not a CSGLattice");
407 auto universes = lattice->getUniverses();
408 for (
auto univ_list : universes)
411 mooseError(
"Cannot add lattice " + lattice->getName() +
" of type " + lattice->getType() +
412 ". Universe " + univ.getName() +
" is not in the CSGBase instance.");
414 if (lattice->getOuterType() ==
"UNIVERSE")
416 const CSGUniverse & outer_univ = lattice->getOuterUniverse();
418 mooseError(
"Cannot add lattice " + lattice->getName() +
" of type " + lattice->getType() +
419 ". Outer universe " + outer_univ.
getName() +
" is not in the CSGBase instance.");
422 return dynamic_cast<LatticeType &
>(lat_ref);
442 std::pair<int, int> index);
453 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> & universes);
512 template <
typename LatticeType = CSGLattice>
516 const LatticeType * typed_lattice =
dynamic_cast<const LatticeType *
>(&lattice);
518 mooseError(
"Cannot get lattice " +
name +
". Lattice is not of specified type " +
519 MooseUtils::prettyCppType<LatticeType>());
520 return *typed_lattice;
540 void joinOtherBase(std::unique_ptr<CSGBase> base,
const bool ignore_identical_components);
555 const bool ignore_identical_components,
556 const std::string & new_root_name_join);
573 const bool ignore_identical_components,
574 const std::string & new_root_name_base,
575 const std::string & new_root_name_join);
599 const std::tuple<Real, Real, Real> & values);
608 const std::tuple<Real, Real, Real> & distances)
620 const std::tuple<Real, Real, Real> & angles)
642 const std::tuple<Real, Real, Real> & values)
670 std::vector<std::string> & linked_universe_names,
671 std::vector<std::string> & linked_cell_names)
const;
747 std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs,
759 std::map<std::string, std::reference_wrapper<const CSGCell>> & identical_cell_refs,
772 std::map<std::string, std::reference_wrapper<const CSGUniverse>> & identical_universe_refs,
784 std::map<std::string, std::reference_wrapper<const CSGLattice>> & identical_lattice_refs,
836 const bool ignore_identical_universes,
837 const std::string & new_root_name_incoming);
853 const bool ignore_identical_universes,
854 const std::string & new_root_name_base,
855 const std::string & new_root_name_incoming);
908 #ifdef MOOSE_UNIT_TEST std::string name(const ElemQuality q)
void updateIncomingCSGReferences(CSGBase &incoming_base)
update references of incoming CSGbase to point to those of existing CSGBase object.
bool hasUniverse(const std::string &name) const
Check if a universe with given name exists in CSGBase object.
bool hasSurface(const std::string &name) const
return whether surface with given name exists in surface list
bool checkLatticeInBase(const CSGLattice &lattice) const
void setUniverseAtLatticeIndex(const CSGLattice &lattice, const CSGUniverse &universe, std::pair< int, int > index)
set location in the lattice to be the provided universe
CSGLattice & addLattice(std::unique_ptr< CSGLattice > lattice, const bool ignore_identical_lattice=false)
add an existing lattice to list.
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe
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.
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all the universes in CSGBase instance.
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
void replaceUniverseRefsByName(std::map< std::string, std::reference_wrapper< const CSGUniverse >> &identical_universe_refs, CSGBase &base)
update universe references of incoming CSGbase to point to those of existing CSGBase object based on ...
CSGUniverseList _universe_list
List of universes associated with CSG object.
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::unique_ptr< CSGBase > clone() const
Create a deep copy of this CSGBase instance.
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the lattice
const CSGLatticeList & getLatticeList() const
Get a const reference to the CSGLatticeList object.
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 setLatticeOuter(const CSGLattice &lattice, const std::string &outer_name)
Set the outer fill for the lattice to the material name provided.
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
void deleteLattice(const CSGLattice &lattice)
Remove a Lattice object passed in by reference from the stored lattice list.
const CSGSurface & getSurfaceByName(const std::string &name) const
Get a Surface object by name.
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all lattice objects.
bool operator==(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are equal.
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all the lattices in CSGBase instance.
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
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).
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the specified lattice
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
TransformationType
Enumeration of transformation types that can be applied to CSG objects.
void addTransformation(const CSGObjectVariant &csg_object, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSG object.
nlohmann::json generateOutput() const
generate the JSON representation output for the CSG object
CSGLatticeList creates a container for CSGLattice objects to pass to CSGBase.
void updateCellFill(const CSGCell &cell, const std::string &mat_name)
change the fill of the specified cell to a material fill
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).
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get list of references to all surfaces in surface list.
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.
void joinLatticeList(CSGLatticeList &lattice_list, const bool ignore_identical_lattices)
join a separate CSGLatticeList object to this one
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
CSGLattice is the abstract class for defining lattices.
bool hasLattice(const std::string &name) const
return whether lattice with given name exists in lattice list
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.
void renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface
void joinOtherBase(std::unique_ptr< CSGBase > base, const bool ignore_identical_components)
Join another CSGBase object to this one.
FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces)
Friends for unit testing.
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
const CSGUniverse & getRoot() const
Get the root universe.
void joinCellList(CSGCellList &cell_list, const bool ignore_identical_cells)
join a separate CSGCellList object to this one
CSGLatticeList & getLatticeList()
Get the CSGLatticeList object.
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...
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
void renameRootUniverse(const std::string &name)
rename the root universe for this instance (default is ROOT_UNIVERSE)
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf, const bool ignore_identical_surface=false)
add a surface object to existing SurfaceList.
const CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a unique surface pointer to this base instance
void removeCellsFromUniverse(const CSGUniverse &universe, std::vector< std::reference_wrapper< const CSGCell >> &cells)
Remove a list of cells from an existing universe.
void setLatticeUniverses(const CSGLattice &lattice, std::vector< std::vector< std::reference_wrapper< const CSGUniverse >>> &universes)
Set provided universes as the layout of the lattice.
void replaceLatticeRefsByName(std::map< std::string, std::reference_wrapper< const CSGLattice >> &identical_lattice_refs, CSGBase &base)
update lattice references of incoming CSGbase to point to those of existing CSGBase object based on C...
void replaceSurfaceRefsByName(std::map< std::string, std::reference_wrapper< const CSGSurface >> &identical_surface_refs, CSGBase &base)
update surface references of incoming CSGBase to point to those of existing CSGBase object based on C...
bool hasSurface(const std::string &name) const
Check if a surface with given name exists in CSGBase object.
CSGSurface & getSurface(const std::string &name)
Get a Surface object by name.
void joinUniverseList(CSGUniverseList &univ_list, const bool ignore_identical_universes)
join a separate CSGUniverseList object to this one; root universes from univ_list will be combined in...
bool hasCell(const std::string &name) const
Check if a cell with given name exists in CSGBase object.
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
bool checkUniverseInBase(const CSGUniverse &universe) const
bool hasLattice(const std::string &name) const
Check if a lattice with given name exists in CSGBase object.
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
std::variant< std::reference_wrapper< const CSGSurface >, std::reference_wrapper< const CSGCell >, std::reference_wrapper< const CSGUniverse >, std::reference_wrapper< const CSGRegion >, std::reference_wrapper< const CSGLattice > > CSGObjectVariant
Define a variant type that can hold references to different CSG object types.
bool checkSurfaceInBase(const CSGSurface &surface) const
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.
CSGCellList _cell_list
List of cells associated with CSG object.
void deleteUniverse(const CSGUniverse &univ)
Remove a Universe object passed in by reference from the stored universe list.
CSGCellList & getCellList()
Get a non-const reference to the CSGCellList object.
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
const CSGCell & getCellByName(const std::string &name) const
Get a Cell object by name.
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe
void resetLatticeOuter(const CSGLattice &lattice)
reset the outer fill for the lattice to VOID
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 ...
CSGUniverseList & getUniverseList()
Get a non-const reference to the CSGUniverseList object.
const CSGSurfaceList & getSurfaceList() const
Get a const reference to the CSGSurfaceList object.
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
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...
bool hasUniverse(const std::string &name) const
return whether universe with given name exists in universe list
CSGBase()
Default constructor.
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.
void replaceCellRefsByName(std::map< std::string, std::reference_wrapper< const CSGCell >> &identical_cell_refs, CSGBase &base)
update cell references of incoming CSGbase to point to those of existing CSGBase object based on CSGC...
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
void deleteCell(const CSGCell &cell)
Remove a Cell object passed in by reference from the stored cell list.
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
CSGSurfaceList & getSurfaceList()
Get a non-const reference to the CSGSurfaceList object.
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
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 renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model...
void deleteSurface(const CSGSurface &surface)
Remove a Surface object passed in by reference from the stored surface list.
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 resetCellFill(const CSGCell &cell)
reset the fill of the specified cell to void
const CSGUniverse & getUniverseByName(const std::string &name)
Get a universe object by name.
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.
RotationAxisType
Enumeration of axis types for rotations.
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.