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://www.mooseframework.org
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
734 void joinOtherBase(std::unique_ptr<CSGBase> base, const bool ignore_identical_components);
735
748 void joinOtherBase(std::unique_ptr<CSGBase> base,
749 const bool ignore_identical_components,
750 const std::string & new_root_name_join);
751
766 void joinOtherBase(std::unique_ptr<CSGBase> base,
767 const bool ignore_identical_components,
768 const std::string & new_root_name_base,
769 const std::string & new_root_name_join);
770
776 nlohmann::json generateOutput() const;
777
779 bool operator==(const CSGBase & other) const;
780
782 bool operator!=(const CSGBase & other) const;
783
791 void addTransformation(const CSGObjectVariant & csg_object,
793 const std::tuple<Real, Real, Real> & values);
794
807 void addTransformation(const CSGEngUnit & unit,
809 const std::tuple<Real, Real, Real> & values)
810 {
811 addTransformation(CSGObjectVariant{std::cref(unit)}, type, values);
812 }
813
820 void applyTranslation(const CSGObjectVariant & csg_object,
821 const std::tuple<Real, Real, Real> & distances)
822 {
824 }
825
838 void applyTranslation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & distances)
839 {
841 }
842
849 void applyRotation(const CSGObjectVariant & csg_object,
850 const std::tuple<Real, Real, Real> & angles)
851 {
853 }
854
866 void applyRotation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & angles)
867 {
869 }
870
878 void
879 applyAxisRotation(const CSGObjectVariant & csg_object, RotationAxisType axis, const Real angle);
880
893 void applyAxisRotation(const CSGEngUnit & unit, RotationAxisType axis, const Real angle)
894 {
895 applyAxisRotation(CSGObjectVariant{std::cref(unit)}, axis, angle);
896 }
897
904 void applyScaling(const CSGObjectVariant & csg_object,
905 const std::tuple<Real, Real, Real> & values)
906 {
908 }
909
921 void applyScaling(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & values)
922 {
924 }
925
926private:
936 CSGSurface & getSurface(const std::string & name) { return _surface_list.getSurface(name); }
937
948 void expandAllEngUnitsCycle(std::set<std::set<std::string>> & all_type_sets);
949
951 void checkUniverseLinking() const;
952
962 void getLinkedCSGObjects(const CSGUniverse & univ,
963 std::set<std::string> & linked_universe_names,
964 std::set<std::string> & linked_cell_names,
965 std::set<std::string> & linked_surface_names) const;
966
972 const CSGSurfaceList & getSurfaceList() const { return _surface_list; }
973
980
986 const CSGCellList & getCellList() const { return _cell_list; }
987
994
1001
1008
1014 const CSGLatticeList & getLatticeList() const { return _lattice_list; }
1015
1022
1030 void updateIncomingCSGReferences(CSGBase & incoming_base);
1031
1041 std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs,
1042 CSGBase & base);
1043
1053 std::map<std::string, std::reference_wrapper<const CSGCell>> & identical_cell_refs,
1054 CSGBase & base);
1055
1066 std::map<std::string, std::reference_wrapper<const CSGUniverse>> & identical_universe_refs,
1067 CSGBase & base);
1068
1078 std::map<std::string, std::reference_wrapper<const CSGLattice>> & identical_lattice_refs,
1079 CSGBase & base);
1080
1087
1095 void joinSurfaceList(CSGSurfaceList & surf_list, const bool ignore_identical_surfaces);
1096
1104 void joinCellList(CSGCellList & cell_list, const bool ignore_identical_cells);
1105
1113 void joinLatticeList(CSGLatticeList & lattice_list, const bool ignore_identical_lattices);
1114
1123 void joinUniverseList(CSGUniverseList & univ_list, const bool ignore_identical_universes);
1124
1136 void joinUniverseList(CSGUniverseList & univ_list,
1137 const bool ignore_identical_universes,
1138 const std::string & new_root_name_incoming);
1139
1153 void joinUniverseList(CSGUniverseList & univ_list,
1154 const bool ignore_identical_universes,
1155 const std::string & new_root_name_base,
1156 const std::string & new_root_name_incoming);
1157
1162 void rebuildEngUnitList();
1163
1165 void replaceUniverseRefs(const CSGUniverse & old_univ, const CSGUniverse & new_univ);
1166
1168 void replaceCellRefs(const CSGCell & old_cell, const CSGCell & new_cell);
1169
1171 void replaceSurfaceRefsWithRegion(const CSGSurface & old_surf, const CSGRegion & sub_region);
1172
1174 void checkRegionSurfaces(const CSGRegion & region) const;
1175
1177 bool checkSurfaceInBase(const CSGSurface & surface) const;
1178
1180 bool checkCellInBase(const CSGCell & cell) const;
1181
1183 bool checkEngUnitInBase(const CSGEngUnit & unit) const;
1184
1186 bool checkUniverseInBase(const CSGUniverse & universe) const;
1187
1189 bool checkLatticeInBase(const CSGLattice & lattice) const;
1190
1192 void prepareSurfaceDeletion(const CSGSurface & surface) const;
1193
1195 void prepareCellDeletion(const CSGCell & cell);
1196
1198 void prepareUniverseDeletion(const CSGUniverse & universe) const;
1199
1208 {
1209 return dynamic_cast<const CSGSurfaceEngUnit *>(&surf);
1210 }
1211
1219 const CSGCellEngUnit * cellToEngUnit(const CSGCell & cell) const
1220 {
1221 return dynamic_cast<const CSGCellEngUnit *>(&cell);
1222 }
1223
1232 {
1233 return dynamic_cast<const CSGUniverseEngUnit *>(&univ);
1234 }
1235
1242 const CSGCell & addCellToList(const CSGCell & cell);
1243
1250 const CSGUniverse & addUniverseToList(const CSGUniverse & univ);
1251
1258 const CSGLattice & addLatticeToList(const CSGLattice & lattice);
1259
1262
1265
1268
1271
1274
1275#ifdef MOOSE_UNIT_TEST
1278 FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces);
1279 FRIEND_TEST(CSGBaseTest, testAddGetSurface);
1280 FRIEND_TEST(CSGBaseTest, testUniverseLinking);
1281 FRIEND_TEST(CSGBaseTest, testEngUnitLinking);
1282 FRIEND_TEST(CSGBaseTest, testCellEngUnitAddErrors);
1283 FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors);
1285#endif
1286};
1287} // 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:972
CSGUniverseList & getUniverseList()
Get a non-const reference to the CSGUniverseList object.
Definition CSGBase.h:1007
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:917
void prepareCellDeletion(const CSGCell &cell)
warn and remove cell from any universe that contains it
Definition CSGBase.C:339
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:1108
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
Definition CSGBase.C:136
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
Definition CSGBase.h:986
CSGCellList _cell_list
List of cells associated with CSG object.
Definition CSGBase.h:1264
void deleteCell(const CSGCell &cell)
Remove a Cell object passed in by reference from the stored cell list.
Definition CSGBase.C:361
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:921
CSGLatticeList & getLatticeList()
Get the CSGLatticeList object.
Definition CSGBase.h:1021
std::unique_ptr< CSGBase > clone() const
Create a deep copy of this CSGBase instance.
Definition CSGBase.C:78
bool checkUniverseInBase(const CSGUniverse &universe) const
check that universe being accessed is a part of this CSGBase instance
Definition CSGBase.C:1118
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
Definition CSGBase.C:202
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:1015
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:842
void renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface
Definition CSGBase.C:1165
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition CSGBase.C:177
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:954
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:893
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:820
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition CSGBase.h:1261
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:979
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:866
void expandAllEngUnitsCycle(std::set< std::set< std::string > > &all_type_sets)
Recursive implementation of expandAllEngUnits().
Definition CSGBase.C:1323
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:1000
void expandAllEngUnits()
Expand all registered engineering units into basic CSG objects.
Definition CSGBase.C:1316
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:761
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition CSGBase.h:1270
void checkRegionSurfaces(const CSGRegion &region) const
check that surfaces used in this region are a part of this CSGBase instance
Definition CSGBase.C:1086
void renameEngUnit(const CSGEngUnit &unit, const std::string &name)
Rename the specified engineering unit.
Definition CSGBase.C:1148
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:1273
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:96
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:618
void joinCellList(CSGCellList &cell_list, const bool ignore_identical_cells)
join a separate CSGCellList object to this one
Definition CSGBase.C:981
void joinLatticeList(CSGLatticeList &lattice_list, const bool ignore_identical_lattices)
join a separate CSGLatticeList object to this one
Definition CSGBase.C:989
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:574
void joinOtherBase(std::unique_ptr< CSGBase > base, const bool ignore_identical_components)
Join another CSGBase object to this one.
Definition CSGBase.C:791
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe
Definition CSGBase.C:1192
FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors)
void resetCellFill(const CSGCell &cell)
reset the fill of the specified cell to void
Definition CSGBase.C:393
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:997
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:476
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:1530
void addTransformation(const CSGEngUnit &unit, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSGEngUnit object.
Definition CSGBase.h:807
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:1014
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:904
bool areCSGObjectsLinked() const
Check whether all universes, cells, and surfaces in this CSGBase are reachable from the root universe...
Definition CSGBase.C:1236
CSGRegion expandEngUnit(const CSGSurfaceEngUnit &unit)
Expand a surface-like engineering unit into basic CSGSurface(s) and return the CSGRegion representing...
Definition CSGBase.C:1370
void deleteLattice(const CSGLattice &lattice)
Remove a Lattice object passed in by reference from the stored lattice list.
Definition CSGBase.C:240
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
Definition CSGBase.C:1179
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:838
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:1086
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:547
void resetLatticeOuter(const CSGLattice &lattice)
reset the outer fill for the lattice to VOID
Definition CSGBase.C:607
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:1231
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all lattice objects.
Definition CSGBase.h:491
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
Definition CSGBase.C:555
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:1560
bool checkSurfaceInBase(const CSGSurface &surface) const
check that surface being accessed is a part of this CSGBase instance
Definition CSGBase.C:1098
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:634
bool operator==(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are equal.
Definition CSGBase.C:1720
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:902
void deleteSurface(const CSGSurface &surface)
Remove a Surface object passed in by reference from the stored surface list.
Definition CSGBase.C:121
~CSGBase()
Destructor.
Definition CSGBase.C:75
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:849
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:1575
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition CSGBase.C:525
const CSGSurfaceEngUnit * surfaceToEngUnit(const CSGSurface &surf) const
Returns the CSGSurfaceEngUnit pointer if surf is an eng unit, nullptr otherwise.
Definition CSGBase.h:1207
void prepareSurfaceDeletion(const CSGSurface &surface) const
error if surface is referenced in any cell region
Definition CSGBase.C:106
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:892
void updateCellRegion(const CSGCell &cell, const CSGRegion &region)
change the region of the specified cell
Definition CSGBase.C:376
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:582
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:263
bool checkEngUnitInBase(const CSGEngUnit &unit) const
check that engineering unit being accessed is a part of this CSGBase instance
Definition CSGBase.C:1138
bool operator!=(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are not equal.
Definition CSGBase.C:1738
CSGBase()
Default constructor.
Definition CSGBase.C:17
const CSGCellEngUnit * cellToEngUnit(const CSGCell &cell) const
Returns the CSGCellEngUnit pointer if cell is an eng unit, nullptr otherwise.
Definition CSGBase.h:1219
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the lattice
Definition CSGBase.h:456
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition CSGBase.C:973
void deleteEngUnit(const CSGEngUnit &unit)
Remove an engineering unit passed in by reference from the stored engineering unit list.
Definition CSGBase.C:1295
CSGSurface & getSurface(const std::string &name)
Get a Surface object by name.
Definition CSGBase.h:936
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
Definition CSGBase.C:1206
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:1128
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:1257
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:1267
nlohmann::json generateOutput() const
generate the JSON representation output for the CSG object
Definition CSGBase.C:1590
CSGCellList & getCellList()
Get a non-const reference to the CSGCellList object.
Definition CSGBase.h:993
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:653
void updateCellFill(const CSGCell &cell, const std::string &mat_name)
change the fill of the specified cell to a material fill
Definition CSGBase.C:409
void deleteUniverse(const CSGUniverse &univ)
Remove a Universe object passed in by reference from the stored universe list.
Definition CSGBase.C:510
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