https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CSGBase.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include "CSGSurfaceList.h"
13#include "CSGRegion.h"
14#include "CSGCellList.h"
15#include "CSGUniverseList.h"
16#include "CSGLatticeList.h"
18#include "CSGEngUnitList.h"
19#include "nlohmann/json.h"
20
21#ifdef MOOSE_UNIT_TEST
22#include "gtest/gtest.h"
23#endif
24
25namespace CSG
26{
27
32{
33 X = 0, // X axis
34 Y = 1, // Y axis
35 Z = 2 // Z axis
36};
37
41typedef std::variant<std::reference_wrapper<const CSGSurface>,
42 std::reference_wrapper<const CSGCell>,
43 std::reference_wrapper<const CSGUniverse>,
44 std::reference_wrapper<const CSGRegion>,
45 std::reference_wrapper<const CSGLattice>,
46 std::reference_wrapper<const CSGEngUnit>>
48
54{
55public:
59 CSGBase();
60
64 CSGBase(const CSGBase & other_base);
65
69 ~CSGBase();
70
77 std::unique_ptr<CSGBase> clone() const;
78
86 const CSGSurface & addSurface(std::unique_ptr<CSGSurface> surf);
87
94 void deleteSurface(const CSGSurface & surface);
95
101 std::vector<std::reference_wrapper<const CSGSurface>> getAllSurfaces() const
102 {
104 }
105
112 const CSGSurface & getSurfaceByName(const std::string & name) const
113 {
114 return _surface_list.getSurface(name);
115 }
116
123 bool hasSurface(const std::string & name) const { return _surface_list.hasSurface(name); }
124
131 void renameSurface(const CSGSurface & surface, const std::string & name);
132
143 const CSGCell & createCell(const std::string & name,
144 const std::string & mat_name,
145 const CSGRegion & region,
146 const CSGUniverse * add_to_univ = nullptr);
147
157 const CSGCell & createCell(const std::string & name,
158 const CSGRegion & region,
159 const CSGUniverse * add_to_univ = nullptr);
160
171 const CSGCell & createCell(const std::string & name,
172 const CSGUniverse & fill_univ,
173 const CSGRegion & region,
174 const CSGUniverse * add_to_univ = nullptr);
175
186 const CSGCell & createCell(const std::string & name,
187 const CSGLattice & fill_lattice,
188 const CSGRegion & region,
189 const CSGUniverse * add_to_univ = nullptr);
190
197 void deleteCell(const CSGCell & cell);
198
204 std::vector<std::reference_wrapper<const CSGCell>> getAllCells() const
205 {
206 return _cell_list.getAllCells();
207 }
208
215 const CSGCell & getCellByName(const std::string & name) const { return _cell_list.getCell(name); }
216
223 bool hasCell(const std::string & name) const { return _cell_list.hasCell(name); }
224
231 void renameCell(const CSGCell & cell, const std::string & name);
232
239 void updateCellRegion(const CSGCell & cell, const CSGRegion & region);
240
246 void resetCellFill(const CSGCell & cell);
247
254 void updateCellFill(const CSGCell & cell, const std::string & mat_name);
255
262 void updateCellFill(const CSGCell & cell, const CSGUniverse * univ);
263
270 void updateCellFill(const CSGCell & cell, const CSGLattice * lattice);
271
277 const CSGUniverse & getRootUniverse() const { return _universe_list.getRoot(); }
278
284 void renameRootUniverse(const std::string & name)
285 {
287 }
288
295 void renameUniverse(const CSGUniverse & universe, const std::string & name);
296
303 const CSGUniverse & createUniverse(const std::string & name)
304 {
305 return _universe_list.addUniverse(name);
306 }
307
315 const CSGUniverse & createUniverse(const std::string & name,
316 std::vector<std::reference_wrapper<const CSGCell>> & cells);
317
324 void deleteUniverse(const CSGUniverse & univ);
325
332 void addCellToUniverse(const CSGUniverse & universe, const CSGCell & cell);
333
340 void addCellsToUniverse(const CSGUniverse & universe,
341 std::vector<std::reference_wrapper<const CSGCell>> & cells);
342
349 void removeCellFromUniverse(const CSGUniverse & universe, const CSGCell & cell);
350
357 void removeCellsFromUniverse(const CSGUniverse & universe,
358 std::vector<std::reference_wrapper<const CSGCell>> & cells);
359
365 std::vector<std::reference_wrapper<const CSGUniverse>> getAllUniverses() const
366 {
368 }
369
376 const CSGUniverse & getUniverseByName(const std::string & name)
377 {
378 return _universe_list.getUniverse(name);
379 }
380
387 bool hasUniverse(const std::string & name) const { return _universe_list.hasUniverse(name); }
388
397 template <typename LatticeType = CSGLattice>
398 const LatticeType & addLattice(std::unique_ptr<LatticeType> lattice)
399 {
400 static_assert(std::is_base_of_v<CSGLattice, LatticeType>, "Is not a CSGLattice");
401 // make sure all universes are a part of this base instance
402 auto universes = lattice->getUniverses();
403 for (auto univ_list : universes)
404 for (const CSGUniverse & univ : univ_list)
405 if (!checkUniverseInBase(univ))
406 mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
407 ". Universe " + univ.getName() + " is not in the CSGBase instance.");
408
409 if (lattice->getOuterType() == "UNIVERSE")
410 {
411 const CSGUniverse & outer_univ = lattice->getOuterUniverse();
412 if (!checkUniverseInBase(outer_univ))
413 mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
414 ". Outer universe " + outer_univ.getName() + " is not in the CSGBase instance.");
415 }
416 auto & lat_ref = _lattice_list.addLattice(std::move(lattice));
417 return dynamic_cast<LatticeType &>(lat_ref);
418 }
419
426 void deleteLattice(const CSGLattice & lattice);
427
435 void setUniverseAtLatticeIndex(const CSGLattice & lattice,
436 const CSGUniverse & universe,
437 std::pair<int, int> index);
438
447 const CSGLattice & lattice,
448 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> & universes);
449
456 void renameLattice(const CSGLattice & lattice, const std::string & name)
457 {
458 _lattice_list.renameLattice(lattice, name);
459 }
460
468 void setLatticeOuter(const CSGLattice & lattice, const std::string & outer_name);
469
477 void setLatticeOuter(const CSGLattice & lattice, const CSGUniverse & outer_univ);
478
484 void resetLatticeOuter(const CSGLattice & lattice);
485
491 std::vector<std::reference_wrapper<const CSGLattice>> getAllLattices() const
492 {
494 }
495
508 template <typename LatticeType = CSGLattice>
509 const LatticeType & getLatticeByName(const std::string & name)
510 {
511 const CSGLattice & lattice = _lattice_list.getLattice(name);
512 const LatticeType * typed_lattice = dynamic_cast<const LatticeType *>(&lattice);
513 if (!typed_lattice)
514 mooseError("Cannot get lattice " + name + ". Lattice is not of specified type " +
515 MooseUtils::prettyCppType<LatticeType>());
516 return *typed_lattice;
517 }
518
525 bool hasLattice(const std::string & name) const { return _lattice_list.hasLattice(name); }
526
538 template <typename T>
539 const T & addEngUnit(std::unique_ptr<T> unit, const CSGUniverse * add_to_univ = nullptr)
540 {
541 static_assert(std::is_base_of_v<CSGEngUnit, T>, "T must derive from CSGEngUnit");
542 static_assert(std::is_base_of_v<CSGSurface, T> || std::is_base_of_v<CSGCell, T> ||
543 std::is_base_of_v<CSGUniverse, T>,
544 "T must also derive from CSGSurface, CSGCell, or CSGUniverse");
545 // create raw pointer so we can transfer ownership to the proper type list without destroying
546 // it, and also can store the pointer in the CSGEngUnitList (non-owning list)
547 T * raw = unit.get();
548
549 // must check if an engineering unit of the same name (regardless of type) exists already before
550 // adding it to any list so that we don't add to a type-list before knowing if it is actually
551 // allowable as a unit. The addX checks below will check that the name doesn't conflict with a
552 // real type unit too.
553 if (_eng_unit_list.hasEngUnit(raw->getName()))
555 "An engineering unit with name '", raw->getName(), "' already exists in geometry.");
556
557 // Transfer ownership to the appropriate type list
558 if constexpr (std::is_base_of_v<CSGSurface, T>)
559 _surface_list.addSurface(std::move(unit));
560 else if constexpr (std::is_base_of_v<CSGCell, T>)
561 {
562 // must add a cell unit to the appropriate universe
563 auto & cell = _cell_list.addCell(std::move(unit));
564 if (add_to_univ)
565 addCellToUniverse(*add_to_univ, cell);
566 else
568 }
569 else if constexpr (std::is_base_of_v<CSGUniverse, T>)
570 _universe_list.addUniverse(std::move(unit));
571
572 // Register non-owning pointer in the CSGEngUnitList if no name conflicts identified above.
573 _eng_unit_list.addEngUnit(cast_ref<CSGEngUnit &>(*raw));
574 return *raw;
575 }
576
582 void deleteEngUnit(const CSGEngUnit & unit);
583
596 template <typename EngUnitType = CSGEngUnit>
597 const EngUnitType & getEngUnitByName(const std::string & name) const
598 {
599 const CSGEngUnit & unit = _eng_unit_list.getEngUnit(name);
600 const EngUnitType * typed_unit = dynamic_cast<const EngUnitType *>(&unit);
601 if (!typed_unit)
602 mooseError("Cannot get engineering unit " + name +
603 ". Engineering unit is not of specified type " +
604 MooseUtils::prettyCppType<EngUnitType>());
605 return *typed_unit;
606 }
607
614 bool hasEngUnit(const std::string & name) const { return _eng_unit_list.hasEngUnit(name); }
615
622 void renameEngUnit(const CSGEngUnit & unit, const std::string & name);
623
629 std::vector<std::reference_wrapper<const CSGEngUnit>> getAllEngUnits() const
630 {
632 }
633
639 std::vector<std::reference_wrapper<const CSGSurfaceEngUnit>> getAllSurfaceEngUnits() const
640 {
642 }
643
649 std::vector<std::reference_wrapper<const CSGCellEngUnit>> getAllCellEngUnits() const
650 {
652 }
653
659 std::vector<std::reference_wrapper<const CSGUniverseEngUnit>> getAllUniverseEngUnits() const
660 {
662 }
663
678
691 const CSGCell & expandEngUnit(const CSGCellEngUnit & unit);
692
706 const CSGUniverse & expandEngUnit(const CSGUniverseEngUnit & unit);
707
715 void expandAllEngUnits();
716
723 bool areCSGObjectsLinked() const;
724
732 void checkGeometry() const;
733
743 void joinOtherBase(std::unique_ptr<CSGBase> base, const bool ignore_identical_components);
744
757 void joinOtherBase(std::unique_ptr<CSGBase> base,
758 const bool ignore_identical_components,
759 const std::string & new_root_name_join);
760
775 void joinOtherBase(std::unique_ptr<CSGBase> base,
776 const bool ignore_identical_components,
777 const std::string & new_root_name_base,
778 const std::string & new_root_name_join);
779
785 nlohmann::json generateOutput() const;
786
788 bool operator==(const CSGBase & other) const;
789
791 bool operator!=(const CSGBase & other) const;
792
800 void addTransformation(const CSGObjectVariant & csg_object,
802 const std::tuple<Real, Real, Real> & values);
803
816 void addTransformation(const CSGEngUnit & unit,
818 const std::tuple<Real, Real, Real> & values)
819 {
820 addTransformation(CSGObjectVariant{std::cref(unit)}, type, values);
821 }
822
829 void applyTranslation(const CSGObjectVariant & csg_object,
830 const std::tuple<Real, Real, Real> & distances)
831 {
833 }
834
847 void applyTranslation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & distances)
848 {
850 }
851
858 void applyRotation(const CSGObjectVariant & csg_object,
859 const std::tuple<Real, Real, Real> & angles)
860 {
862 }
863
875 void applyRotation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & angles)
876 {
878 }
879
887 void
888 applyAxisRotation(const CSGObjectVariant & csg_object, RotationAxisType axis, const Real angle);
889
902 void applyAxisRotation(const CSGEngUnit & unit, RotationAxisType axis, const Real angle)
903 {
904 applyAxisRotation(CSGObjectVariant{std::cref(unit)}, axis, angle);
905 }
906
913 void applyScaling(const CSGObjectVariant & csg_object,
914 const std::tuple<Real, Real, Real> & values)
915 {
917 }
918
930 void applyScaling(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & values)
931 {
933 }
934
935private:
945 CSGSurface & getSurface(const std::string & name) { return _surface_list.getSurface(name); }
946
957 void expandAllEngUnitsCycle(std::set<std::set<std::string>> & all_type_sets);
958
960 void checkUniverseLinking() const;
961
963 void checkCellUniverseMembership() const;
964
974 void getLinkedCSGObjects(const CSGUniverse & univ,
975 std::set<std::string> & linked_universe_names,
976 std::set<std::string> & linked_cell_names,
977 std::set<std::string> & linked_surface_names) const;
978
984 const CSGSurfaceList & getSurfaceList() const { return _surface_list; }
985
992
998 const CSGCellList & getCellList() const { return _cell_list; }
999
1006
1013
1020
1026 const CSGLatticeList & getLatticeList() const { return _lattice_list; }
1027
1034
1042 void updateIncomingCSGReferences(CSGBase & incoming_base);
1043
1053 std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs,
1054 CSGBase & base);
1055
1065 std::map<std::string, std::reference_wrapper<const CSGCell>> & identical_cell_refs,
1066 CSGBase & base);
1067
1078 std::map<std::string, std::reference_wrapper<const CSGUniverse>> & identical_universe_refs,
1079 CSGBase & base);
1080
1090 std::map<std::string, std::reference_wrapper<const CSGLattice>> & identical_lattice_refs,
1091 CSGBase & base);
1092
1099
1107 void joinSurfaceList(CSGSurfaceList & surf_list, const bool ignore_identical_surfaces);
1108
1116 void joinCellList(CSGCellList & cell_list, const bool ignore_identical_cells);
1117
1125 void joinLatticeList(CSGLatticeList & lattice_list, const bool ignore_identical_lattices);
1126
1135 void joinUniverseList(CSGUniverseList & univ_list, const bool ignore_identical_universes);
1136
1148 void joinUniverseList(CSGUniverseList & univ_list,
1149 const bool ignore_identical_universes,
1150 const std::string & new_root_name_incoming);
1151
1165 void joinUniverseList(CSGUniverseList & univ_list,
1166 const bool ignore_identical_universes,
1167 const std::string & new_root_name_base,
1168 const std::string & new_root_name_incoming);
1169
1174 void rebuildEngUnitList();
1175
1177 void replaceUniverseRefs(const CSGUniverse & old_univ, const CSGUniverse & new_univ);
1178
1180 void replaceCellRefs(const CSGCell & old_cell, const CSGCell & new_cell);
1181
1183 void replaceSurfaceRefsWithRegion(const CSGSurface & old_surf, const CSGRegion & sub_region);
1184
1186 void checkRegionSurfaces(const CSGRegion & region) const;
1187
1189 bool checkSurfaceInBase(const CSGSurface & surface) const;
1190
1192 bool checkCellInBase(const CSGCell & cell) const;
1193
1195 bool checkEngUnitInBase(const CSGEngUnit & unit) const;
1196
1198 bool checkUniverseInBase(const CSGUniverse & universe) const;
1199
1201 bool checkLatticeInBase(const CSGLattice & lattice) const;
1202
1204 void prepareSurfaceDeletion(const CSGSurface & surface) const;
1205
1207 void prepareCellDeletion(const CSGCell & cell);
1208
1210 void prepareUniverseDeletion(const CSGUniverse & universe) const;
1211
1220 {
1221 return dynamic_cast<const CSGSurfaceEngUnit *>(&surf);
1222 }
1223
1231 const CSGCellEngUnit * cellToEngUnit(const CSGCell & cell) const
1232 {
1233 return dynamic_cast<const CSGCellEngUnit *>(&cell);
1234 }
1235
1244 {
1245 return dynamic_cast<const CSGUniverseEngUnit *>(&univ);
1246 }
1247
1254 const CSGCell & addCellToList(const CSGCell & cell);
1255
1262 const CSGUniverse & addUniverseToList(const CSGUniverse & univ);
1263
1270 const CSGLattice & addLatticeToList(const CSGLattice & lattice);
1271
1274
1277
1280
1283
1286
1287#ifdef MOOSE_UNIT_TEST
1290 FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces);
1291 FRIEND_TEST(CSGBaseTest, testAddGetSurface);
1292 FRIEND_TEST(CSGBaseTest, testUniverseLinking);
1293 FRIEND_TEST(CSGBaseTest, testEngUnitLinking);
1294 FRIEND_TEST(CSGBaseTest, testCellUniverseMembership);
1295 FRIEND_TEST(CSGBaseTest, testCellEngUnitAddErrors);
1296 FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors);
1298#endif
1299};
1300} // namespace CSG
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
std::array< Real, 2 > values
Definition MortarUtils.C:52
CSGBase creates an internal representation of a Constructive Solid Geometry (CSG) model.
Definition CSGBase.h:54
FRIEND_TEST(CSGBaseTest, testUniverseLinking)
const CSGSurfaceList & getSurfaceList() const
Get a const reference to the CSGSurfaceList object.
Definition CSGBase.h:984
CSGUniverseList & getUniverseList()
Get a non-const reference to the CSGUniverseList object.
Definition CSGBase.h:1019
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 ...
Definition CSGBase.C:918
void prepareCellDeletion(const CSGCell &cell)
warn and remove cell from any universe that contains it
Definition CSGBase.C:340
FRIEND_TEST(CSGBaseTest, testCellEngUnitAddErrors)
bool checkCellInBase(const CSGCell &cell) const
check that cell being accessed is a part of this CSGBase instance
Definition CSGBase.C:1109
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
Definition CSGBase.C:137
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
Definition CSGBase.h:998
CSGCellList _cell_list
List of cells associated with CSG object.
Definition CSGBase.h:1276
void deleteCell(const CSGCell &cell)
Remove a Cell object passed in by reference from the stored cell list.
Definition CSGBase.C:362
const CSGSurface & getSurfaceByName(const std::string &name) const
Get a Surface object by name.
Definition CSGBase.h:112
void applyScaling(const CSGEngUnit &unit, const std::tuple< Real, Real, Real > &values)
Scale a CSGEngUnit object in the specified x, y, and z directions.
Definition CSGBase.h:930
CSGLatticeList & getLatticeList()
Get the CSGLatticeList object.
Definition CSGBase.h:1033
std::unique_ptr< CSGBase > clone() const
Create a deep copy of this CSGBase instance.
Definition CSGBase.C:79
bool checkUniverseInBase(const CSGUniverse &universe) const
check that universe being accessed is a part of this CSGBase instance
Definition CSGBase.C:1119
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
Definition CSGBase.C:203
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...
Definition CSGBase.C:1016
std::vector< std::reference_wrapper< const CSGEngUnit > > getAllEngUnits() const
Get all engineering units of all types in CSGBase.
Definition CSGBase.h:629
void updateIncomingCSGReferences(CSGBase &incoming_base)
update references of incoming CSGbase to point to those of existing CSGBase object.
Definition CSGBase.C:843
void renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface
Definition CSGBase.C:1166
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition CSGBase.C:178
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...
Definition CSGBase.C:955
std::vector< std::reference_wrapper< const CSGUniverseEngUnit > > getAllUniverseEngUnits() const
Get all universe-like engineering units.
Definition CSGBase.h:659
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
Definition CSGBase.h:204
void applyAxisRotation(const CSGEngUnit &unit, RotationAxisType axis, const Real angle)
Apply a rotation to a CSGEngUnit object about a specified axis (X, Y, Z).
Definition CSGBase.h:902
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.
Definition CSGBase.h:829
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition CSGBase.h:1273
bool hasUniverse(const std::string &name) const
Check if a universe with given name exists in CSGBase object.
Definition CSGBase.h:387
CSGSurfaceList & getSurfaceList()
Get a non-const reference to the CSGSurfaceList object.
Definition CSGBase.h:991
void applyRotation(const CSGEngUnit &unit, const std::tuple< Real, Real, Real > &angles)
Apply a rotation to a CSG object using (phi, theta, psi) angle notation (in degrees).
Definition CSGBase.h:875
void expandAllEngUnitsCycle(std::set< std::set< std::string > > &all_type_sets)
Recursive implementation of expandAllEngUnits().
Definition CSGBase.C:1355
bool hasLattice(const std::string &name) const
Check if a lattice with given name exists in CSGBase object.
Definition CSGBase.h:525
const CSGUniverseList & getUniverseList() const
Get a const reference to the CSGUniverseList object.
Definition CSGBase.h:1012
void expandAllEngUnits()
Expand all registered engineering units into basic CSG objects.
Definition CSGBase.C:1348
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).
Definition CSGBase.C:762
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition CSGBase.h:1282
void checkRegionSurfaces(const CSGRegion &region) const
check that surfaces used in this region are a part of this CSGBase instance
Definition CSGBase.C:1087
void renameEngUnit(const CSGEngUnit &unit, const std::string &name)
Rename the specified engineering unit.
Definition CSGBase.C:1149
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition CSGBase.h:365
CSGEngUnitList _eng_unit_list
Container for all associated engineering units.
Definition CSGBase.h:1285
void checkGeometry() const
Check that the geometry is valid for output and conversion to downstream codes.
Definition CSGBase.C:1256
const CSGUniverse & getUniverseByName(const std::string &name)
Get a universe object by name.
Definition CSGBase.h:376
const CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a unique surface pointer to this base instance
Definition CSGBase.C:97
FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces)
Friends for unit testing.
void setUniverseAtLatticeIndex(const CSGLattice &lattice, const CSGUniverse &universe, std::pair< int, int > index)
set location in the lattice to be the provided universe
Definition CSGBase.C:619
void joinCellList(CSGCellList &cell_list, const bool ignore_identical_cells)
join a separate CSGCellList object to this one
Definition CSGBase.C:982
void joinLatticeList(CSGLatticeList &lattice_list, const bool ignore_identical_lattices)
join a separate CSGLatticeList object to this one
Definition CSGBase.C:990
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:575
void joinOtherBase(std::unique_ptr< CSGBase > base, const bool ignore_identical_components)
Join another CSGBase object to this one.
Definition CSGBase.C:792
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe
Definition CSGBase.C:1193
FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors)
void resetCellFill(const CSGCell &cell)
reset the fill of the specified cell to void
Definition CSGBase.C:394
const EngUnitType & getEngUnitByName(const std::string &name) const
Get a engineering unit object of the specified type by name.
Definition CSGBase.h:597
bool hasEngUnit(const std::string &name) const
Check if an engineeering unit with given name exists in CSGBase object.
Definition CSGBase.h:614
void rebuildEngUnitList()
rebuilds the list of raw pointers to engineering units by iterating through the surface,...
Definition CSGBase.C:998
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:398
void prepareUniverseDeletion(const CSGUniverse &universe) const
error if universe is the root, used in any lattice, or used as a cell fill
Definition CSGBase.C:477
void replaceUniverseRefs(const CSGUniverse &old_univ, const CSGUniverse &new_univ)
Replace all cell fills and lattice elements/outers referencing old_univ with new_univ.
Definition CSGBase.C:1562
void addTransformation(const CSGEngUnit &unit, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSGEngUnit object.
Definition CSGBase.h:816
bool hasSurface(const std::string &name) const
Check if a surface with given name exists in CSGBase object.
Definition CSGBase.h:123
const CSGLatticeList & getLatticeList() const
Get a const reference to the CSGLatticeList object.
Definition CSGBase.h:1026
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.
Definition CSGBase.h:913
bool areCSGObjectsLinked() const
Check whether all universes, cells, and surfaces in this CSGBase are reachable from the root universe...
Definition CSGBase.C:1265
CSGRegion expandEngUnit(const CSGSurfaceEngUnit &unit)
Expand a surface-like engineering unit into basic CSGSurface(s) and return the CSGRegion representing...
Definition CSGBase.C:1402
void deleteLattice(const CSGLattice &lattice)
Remove a Lattice object passed in by reference from the stored lattice list.
Definition CSGBase.C:241
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
Definition CSGBase.C:1180
void applyTranslation(const CSGEngUnit &unit, const std::tuple< Real, Real, Real > &distances)
Apply a translation to a CSGEngUnit object in the specified x, y, and z directions.
Definition CSGBase.h:847
void renameRootUniverse(const std::string &name)
rename the root universe for this instance (default is ROOT_UNIVERSE)
Definition CSGBase.h:284
const LatticeType & getLatticeByName(const std::string &name)
Get a lattice object of the specified type by name.
Definition CSGBase.h:509
const CSGEngUnitList & getEngUnitList() const
Get a const reference to the CSGEngUnitList object.
Definition CSGBase.h:1098
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:548
void resetLatticeOuter(const CSGLattice &lattice)
reset the outer fill for the lattice to VOID
Definition CSGBase.C:608
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
Definition CSGBase.h:303
bool hasCell(const std::string &name) const
Check if a cell with given name exists in CSGBase object.
Definition CSGBase.h:223
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition CSGBase.h:277
const CSGUniverseEngUnit * universeToEngUnit(const CSGUniverse &univ) const
Returns the CSGUniverseEngUnit pointer if univ is an eng unit, nullptr otherwise.
Definition CSGBase.h:1243
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all lattice objects.
Definition CSGBase.h:491
void checkCellUniverseMembership() const
Check that each cell belongs to at most one universe.
Definition CSGBase.C:1237
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
Definition CSGBase.C:556
std::vector< std::reference_wrapper< const CSGCellEngUnit > > getAllCellEngUnits() const
Get all cell-like engineering units in CSGBase.
Definition CSGBase.h:649
void replaceCellRefs(const CSGCell &old_cell, const CSGCell &new_cell)
Replace all old_cell references with new_cell across all universes in the base.
Definition CSGBase.C:1592
bool checkSurfaceInBase(const CSGSurface &surface) const
check that surface being accessed is a part of this CSGBase instance
Definition CSGBase.C:1099
void setLatticeUniverses(const CSGLattice &lattice, std::vector< std::vector< std::reference_wrapper< const CSGUniverse > > > &universes)
Set provided universes as the layout of the lattice.
Definition CSGBase.C:635
bool operator==(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are equal.
Definition CSGBase.C:1751
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...
Definition CSGBase.C:903
void deleteSurface(const CSGSurface &surface)
Remove a Surface object passed in by reference from the stored surface list.
Definition CSGBase.C:122
~CSGBase()
Destructor.
Definition CSGBase.C:76
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).
Definition CSGBase.h:858
FRIEND_TEST(CSGBaseTest, testAddGetSurface)
void replaceSurfaceRefsWithRegion(const CSGSurface &old_surf, const CSGRegion &sub_region)
Replace all region occurrences of old_surf with the tokens from sub_region across all cells in the ba...
Definition CSGBase.C:1607
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition CSGBase.C:526
const CSGSurfaceEngUnit * surfaceToEngUnit(const CSGSurface &surf) const
Returns the CSGSurfaceEngUnit pointer if surf is an eng unit, nullptr otherwise.
Definition CSGBase.h:1219
void prepareSurfaceDeletion(const CSGSurface &surface) const
error if surface is referenced in any cell region
Definition CSGBase.C:107
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.
Definition CSGBase.h:101
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...
Definition CSGBase.C:893
void updateCellRegion(const CSGCell &cell, const CSGRegion &region)
change the region of the specified cell
Definition CSGBase.C:377
std::vector< std::reference_wrapper< const CSGSurfaceEngUnit > > getAllSurfaceEngUnits() const
Get all surface-like engineering units in CSGBase.
Definition CSGBase.h:639
void setLatticeOuter(const CSGLattice &lattice, const std::string &outer_name)
Set the outer fill for the lattice to the material name provided.
Definition CSGBase.C:583
const T & addEngUnit(std::unique_ptr< T > unit, const CSGUniverse *add_to_univ=nullptr)
Add an engineering unit (surface-, cell-, or universe-like object) to this CSGBase.
Definition CSGBase.h:539
const CSGCell & createCell(const std::string &name, const std::string &mat_name, const CSGRegion &region, const CSGUniverse *add_to_univ=nullptr)
Create a Material Cell object.
Definition CSGBase.C:264
bool checkEngUnitInBase(const CSGEngUnit &unit) const
check that engineering unit being accessed is a part of this CSGBase instance
Definition CSGBase.C:1139
bool operator!=(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are not equal.
Definition CSGBase.C:1769
CSGBase()
Default constructor.
Definition CSGBase.C:18
const CSGCellEngUnit * cellToEngUnit(const CSGCell &cell) const
Returns the CSGCellEngUnit pointer if cell is an eng unit, nullptr otherwise.
Definition CSGBase.h:1231
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the lattice
Definition CSGBase.h:456
FRIEND_TEST(CSGBaseTest, testCellUniverseMembership)
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition CSGBase.C:974
void deleteEngUnit(const CSGEngUnit &unit)
Remove an engineering unit passed in by reference from the stored engineering unit list.
Definition CSGBase.C:1327
CSGSurface & getSurface(const std::string &name)
Get a Surface object by name.
Definition CSGBase.h:945
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
Definition CSGBase.C:1207
FRIEND_TEST(CSGBaseTest, testEngUnitLinking)
bool checkLatticeInBase(const CSGLattice &lattice) const
check that lattice being accessed is a part of this CSGBase instance
Definition CSGBase.C:1129
void getLinkedCSGObjects(const CSGUniverse &univ, std::set< std::string > &linked_universe_names, std::set< std::string > &linked_cell_names, std::set< std::string > &linked_surface_names) const
Recursive method to retrieve all universes, cells, and surfaces linked to current universe.
Definition CSGBase.C:1286
const CSGCell & getCellByName(const std::string &name) const
Get a Cell object by name.
Definition CSGBase.h:215
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition CSGBase.h:1279
nlohmann::json generateOutput() const
generate the JSON representation output for the CSG object
Definition CSGBase.C:1622
CSGCellList & getCellList()
Get a non-const reference to the CSGCellList object.
Definition CSGBase.h:1005
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:654
void updateCellFill(const CSGCell &cell, const std::string &mat_name)
change the fill of the specified cell to a material fill
Definition CSGBase.C:410
void deleteUniverse(const CSGUniverse &univ)
Remove a Universe object passed in by reference from the stored universe list.
Definition CSGBase.C:511
CSGCellEngUnit is an abstract base class for "engineering units" that are cell-like.
CSGCellList creates a container for CSGCell objects to pass to CSGBase object.
Definition CSGCellList.h:21
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all the cells in CSGBase instance.
Definition CSGCellList.C:83
bool hasCell(const std::string &name) const
return whether cell with given name exists in cell list
Definition CSGCellList.h:85
CSGCell & getCell(const std::string &name) const
Get the CSGCell by name.
Definition CSGCellList.C:44
CSGCell & addCell(std::unique_ptr< CSGCell > cell, const bool ignore_identical_cell=false)
add a cell to the CellList.
Definition CSGCellList.C:18
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell,...
Definition CSGCell.h:30
CSGEngUnitList is a non-owning index of CSGEngUnit objects stored in the type lists (CSGSurfaceList,...
CSGEngUnit & addEngUnit(CSGEngUnit &unit)
Register an engineering unit in this index.
std::vector< std::reference_wrapper< const CSGSurfaceEngUnit > > getAllSurfaceEngUnits() const
Get all surface-like engineering units.
CSGEngUnit & getEngUnit(const std::string &name) const
Get an engineering unit by name.
std::vector< std::reference_wrapper< const CSGUniverseEngUnit > > getAllUniverseEngUnits() const
Get all universe-like engineering units.
std::vector< std::reference_wrapper< const CSGEngUnit > > getAllEngUnits() const
Get all engineering units of all types in the list.
std::vector< std::reference_wrapper< const CSGCellEngUnit > > getAllCellEngUnits() const
Get all cell-like engineering units.
bool hasEngUnit(const std::string &name) const
Return whether an engineering unit with the given name exists in this list.
CSGEngUnit is the abstract base class for all "engineering unit" types in the CSG system.
Definition CSGEngUnit.h:33
CSGLatticeList creates a container for CSGLattice objects to pass to CSGBase.
CSGLattice & addLattice(std::unique_ptr< CSGLattice > lattice, const bool ignore_identical_lattice=false)
add an existing lattice to list.
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the specified lattice
CSGLattice & getLattice(const std::string &name) const
Get a Lattice from the list by its name.
bool hasLattice(const std::string &name) const
return whether lattice with given name exists in lattice list
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all the lattices in CSGBase instance.
CSGLattice is the abstract class for defining lattices.
Definition CSGLattice.h:35
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection,...
Definition CSGRegion.h:23
CSGSurfaceEngUnit is an abstract base class for "engineering units" that can be used as surfaces in c...
CSGSurfaceList is a container for storing CSGSurface objects in the CSGBase object.
CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf, const bool ignore_identical_surface=false)
add a surface object to existing SurfaceList.
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get list of references to all surfaces in surface list.
CSGSurface & getSurface(const std::string &name) const
Get a surface by name.
bool hasSurface(const std::string &name) const
return whether surface with given name exists in surface list
CSGSurface creates an internal representation of a Constructive Solid Geometry (CSG) surface,...
Definition CSGSurface.h:27
CSGUniverseEngUnit is an abstract base class for "engineering units" that are universe-like.
CSGUniverseList creates a container for CSGUniverse objects to pass to CSGBase.
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all the universes in CSGBase instance.
const CSGUniverse & getRoot() const
Get the root universe.
bool hasUniverse(const std::string &name) const
return whether universe with given name exists in universe list
CSGUniverse & getUniverse(const std::string &name) const
Get a Universe from the list by its name.
CSGUniverse & addUniverse(const std::string &name)
create an empty universe
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe,...
Definition CSGUniverse.h:28
const std::string & getName() const
Get the name of the universe.
Definition CSGUniverse.h:80
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 >, std::reference_wrapper< const CSGEngUnit > > CSGObjectVariant
Define a variant type that can hold references to different CSG object types.
Definition CSGBase.h:47
TransformationType
Enumeration of transformation types that can be applied to CSG objects.
RotationAxisType
Enumeration of axis types for rotations.
Definition CSGBase.h:32