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
72 std::unique_ptr<CSGBase> clone() const { return std::make_unique<CSGBase>(*this); }
73
81 const CSGSurface & addSurface(std::unique_ptr<CSGSurface> surf);
82
89 void deleteSurface(const CSGSurface & surface);
90
96 std::vector<std::reference_wrapper<const CSGSurface>> getAllSurfaces() const
97 {
99 }
100
107 const CSGSurface & getSurfaceByName(const std::string & name) const
108 {
109 return _surface_list.getSurface(name);
110 }
111
118 bool hasSurface(const std::string & name) const { return _surface_list.hasSurface(name); }
119
126 void renameSurface(const CSGSurface & surface, const std::string & name);
127
138 const CSGCell & createCell(const std::string & name,
139 const std::string & mat_name,
140 const CSGRegion & region,
141 const CSGUniverse * add_to_univ = nullptr);
142
152 const CSGCell & createCell(const std::string & name,
153 const CSGRegion & region,
154 const CSGUniverse * add_to_univ = nullptr);
155
166 const CSGCell & createCell(const std::string & name,
167 const CSGUniverse & fill_univ,
168 const CSGRegion & region,
169 const CSGUniverse * add_to_univ = nullptr);
170
181 const CSGCell & createCell(const std::string & name,
182 const CSGLattice & fill_lattice,
183 const CSGRegion & region,
184 const CSGUniverse * add_to_univ = nullptr);
185
192 void deleteCell(const CSGCell & cell);
193
199 std::vector<std::reference_wrapper<const CSGCell>> getAllCells() const
200 {
201 return _cell_list.getAllCells();
202 }
203
210 const CSGCell & getCellByName(const std::string & name) const { return _cell_list.getCell(name); }
211
218 bool hasCell(const std::string & name) const { return _cell_list.hasCell(name); }
219
226 void renameCell(const CSGCell & cell, const std::string & name);
227
234 void updateCellRegion(const CSGCell & cell, const CSGRegion & region);
235
241 void resetCellFill(const CSGCell & cell);
242
249 void updateCellFill(const CSGCell & cell, const std::string & mat_name);
250
257 void updateCellFill(const CSGCell & cell, const CSGUniverse * univ);
258
265 void updateCellFill(const CSGCell & cell, const CSGLattice * lattice);
266
272 const CSGUniverse & getRootUniverse() const { return _universe_list.getRoot(); }
273
279 void renameRootUniverse(const std::string & name)
280 {
282 }
283
290 void renameUniverse(const CSGUniverse & universe, const std::string & name);
291
298 const CSGUniverse & createUniverse(const std::string & name)
299 {
300 return _universe_list.addUniverse(name);
301 }
302
310 const CSGUniverse & createUniverse(const std::string & name,
311 std::vector<std::reference_wrapper<const CSGCell>> & cells);
312
319 void deleteUniverse(const CSGUniverse & univ);
320
327 void addCellToUniverse(const CSGUniverse & universe, const CSGCell & cell);
328
335 void addCellsToUniverse(const CSGUniverse & universe,
336 std::vector<std::reference_wrapper<const CSGCell>> & cells);
337
344 void removeCellFromUniverse(const CSGUniverse & universe, const CSGCell & cell);
345
352 void removeCellsFromUniverse(const CSGUniverse & universe,
353 std::vector<std::reference_wrapper<const CSGCell>> & cells);
354
360 std::vector<std::reference_wrapper<const CSGUniverse>> getAllUniverses() const
361 {
363 }
364
371 const CSGUniverse & getUniverseByName(const std::string & name)
372 {
373 return _universe_list.getUniverse(name);
374 }
375
382 bool hasUniverse(const std::string & name) const { return _universe_list.hasUniverse(name); }
383
392 template <typename LatticeType = CSGLattice>
393 const LatticeType & addLattice(std::unique_ptr<LatticeType> lattice)
394 {
395 static_assert(std::is_base_of_v<CSGLattice, LatticeType>, "Is not a CSGLattice");
396 // make sure all universes are a part of this base instance
397 auto universes = lattice->getUniverses();
398 for (auto univ_list : universes)
399 for (const CSGUniverse & univ : univ_list)
400 if (!checkUniverseInBase(univ))
401 mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
402 ". Universe " + univ.getName() + " is not in the CSGBase instance.");
403
404 if (lattice->getOuterType() == "UNIVERSE")
405 {
406 const CSGUniverse & outer_univ = lattice->getOuterUniverse();
407 if (!checkUniverseInBase(outer_univ))
408 mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
409 ". Outer universe " + outer_univ.getName() + " is not in the CSGBase instance.");
410 }
411 auto & lat_ref = _lattice_list.addLattice(std::move(lattice));
412 return dynamic_cast<LatticeType &>(lat_ref);
413 }
414
421 void deleteLattice(const CSGLattice & lattice);
422
430 void setUniverseAtLatticeIndex(const CSGLattice & lattice,
431 const CSGUniverse & universe,
432 std::pair<int, int> index);
433
442 const CSGLattice & lattice,
443 std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> & universes);
444
451 void renameLattice(const CSGLattice & lattice, const std::string & name)
452 {
453 _lattice_list.renameLattice(lattice, name);
454 }
455
463 void setLatticeOuter(const CSGLattice & lattice, const std::string & outer_name);
464
472 void setLatticeOuter(const CSGLattice & lattice, const CSGUniverse & outer_univ);
473
479 void resetLatticeOuter(const CSGLattice & lattice);
480
486 std::vector<std::reference_wrapper<const CSGLattice>> getAllLattices() const
487 {
489 }
490
503 template <typename LatticeType = CSGLattice>
504 const LatticeType & getLatticeByName(const std::string & name)
505 {
506 const CSGLattice & lattice = _lattice_list.getLattice(name);
507 const LatticeType * typed_lattice = dynamic_cast<const LatticeType *>(&lattice);
508 if (!typed_lattice)
509 mooseError("Cannot get lattice " + name + ". Lattice is not of specified type " +
510 MooseUtils::prettyCppType<LatticeType>());
511 return *typed_lattice;
512 }
513
520 bool hasLattice(const std::string & name) const { return _lattice_list.hasLattice(name); }
521
533 template <typename T>
534 const T & addEngUnit(std::unique_ptr<T> unit, const CSGUniverse * add_to_univ = nullptr)
535 {
536 static_assert(std::is_base_of_v<CSGEngUnit, T>, "T must derive from CSGEngUnit");
537 static_assert(std::is_base_of_v<CSGSurface, T> || std::is_base_of_v<CSGCell, T> ||
538 std::is_base_of_v<CSGUniverse, T>,
539 "T must also derive from CSGSurface, CSGCell, or CSGUniverse");
540 // create raw pointer so we can transfer ownership to the proper type list without destroying
541 // it, and also can store the pointer in the CSGEngUnitList (non-owning list)
542 T * raw = unit.get();
543
544 // must check if an engineering unit of the same name (regardless of type) exists already before
545 // adding it to any list so that we don't add to a type-list before knowing if it is actually
546 // allowable as a unit. The addX checks below will check that the name doesn't conflict with a
547 // real type unit too.
548 if (_eng_unit_list.hasEngUnit(raw->getName()))
550 "An engineering unit with name '", raw->getName(), "' already exists in geometry.");
551
552 // Transfer ownership to the appropriate type list
553 if constexpr (std::is_base_of_v<CSGSurface, T>)
554 _surface_list.addSurface(std::move(unit));
555 else if constexpr (std::is_base_of_v<CSGCell, T>)
556 {
557 // must add a cell unit to the appropriate universe
558 auto & cell = _cell_list.addCell(std::move(unit));
559 if (add_to_univ)
560 addCellToUniverse(*add_to_univ, cell);
561 else
563 }
564 else if constexpr (std::is_base_of_v<CSGUniverse, T>)
565 _universe_list.addUniverse(std::move(unit));
566
567 // Register non-owning pointer in the CSGEngUnitList if no name conflicts identified above.
568 _eng_unit_list.addEngUnit(static_cast<CSGEngUnit &>(*raw));
569 return *raw;
570 }
571
577 void deleteEngUnit(const CSGEngUnit & unit);
578
591 template <typename EngUnitType = CSGEngUnit>
592 const EngUnitType & getEngUnitByName(const std::string & name) const
593 {
594 const CSGEngUnit & unit = _eng_unit_list.getEngUnit(name);
595 const EngUnitType * typed_unit = dynamic_cast<const EngUnitType *>(&unit);
596 if (!typed_unit)
597 mooseError("Cannot get engineering unit " + name +
598 ". Engineering unit is not of specified type " +
599 MooseUtils::prettyCppType<EngUnitType>());
600 return *typed_unit;
601 }
602
609 bool hasEngUnit(const std::string & name) const { return _eng_unit_list.hasEngUnit(name); }
610
617 void renameEngUnit(const CSGEngUnit & unit, const std::string & name);
618
624 std::vector<std::reference_wrapper<const CSGEngUnit>> getAllEngUnits() const
625 {
627 }
628
634 std::vector<std::reference_wrapper<const CSGSurfaceEngUnit>> getAllSurfaceEngUnits() const
635 {
637 }
638
644 std::vector<std::reference_wrapper<const CSGCellEngUnit>> getAllCellEngUnits() const
645 {
647 }
648
654 std::vector<std::reference_wrapper<const CSGUniverseEngUnit>> getAllUniverseEngUnits() const
655 {
657 }
658
673
686 const CSGCell & expandEngUnit(const CSGCellEngUnit & unit);
687
701 const CSGUniverse & expandEngUnit(const CSGUniverseEngUnit & unit);
702
710 void expandAllEngUnits();
711
718 bool areUniversesLinked() const;
719
729 void joinOtherBase(std::unique_ptr<CSGBase> base, const bool ignore_identical_components);
730
743 void joinOtherBase(std::unique_ptr<CSGBase> base,
744 const bool ignore_identical_components,
745 const std::string & new_root_name_join);
746
761 void joinOtherBase(std::unique_ptr<CSGBase> base,
762 const bool ignore_identical_components,
763 const std::string & new_root_name_base,
764 const std::string & new_root_name_join);
765
771 nlohmann::json generateOutput() const;
772
774 bool operator==(const CSGBase & other) const;
775
777 bool operator!=(const CSGBase & other) const;
778
786 void addTransformation(const CSGObjectVariant & csg_object,
788 const std::tuple<Real, Real, Real> & values);
789
802 void addTransformation(const CSGEngUnit & unit,
804 const std::tuple<Real, Real, Real> & values)
805 {
806 addTransformation(CSGObjectVariant{std::cref(unit)}, type, values);
807 }
808
815 void applyTranslation(const CSGObjectVariant & csg_object,
816 const std::tuple<Real, Real, Real> & distances)
817 {
819 }
820
833 void applyTranslation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & distances)
834 {
836 }
837
844 void applyRotation(const CSGObjectVariant & csg_object,
845 const std::tuple<Real, Real, Real> & angles)
846 {
848 }
849
861 void applyRotation(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & angles)
862 {
864 }
865
873 void
874 applyAxisRotation(const CSGObjectVariant & csg_object, RotationAxisType axis, const Real angle);
875
888 void applyAxisRotation(const CSGEngUnit & unit, RotationAxisType axis, const Real angle)
889 {
890 applyAxisRotation(CSGObjectVariant{std::cref(unit)}, axis, angle);
891 }
892
899 void applyScaling(const CSGObjectVariant & csg_object,
900 const std::tuple<Real, Real, Real> & values)
901 {
903 }
904
916 void applyScaling(const CSGEngUnit & unit, const std::tuple<Real, Real, Real> & values)
917 {
919 }
920
921private:
931 CSGSurface & getSurface(const std::string & name) { return _surface_list.getSurface(name); }
932
943 void expandAllEngUnitsCycle(std::set<std::set<std::string>> & all_type_sets);
944
946 void checkUniverseLinking() const;
947
955 void getLinkedUniverses(const CSGUniverse & univ,
956 std::vector<std::string> & linked_universe_names,
957 std::vector<std::string> & linked_cell_names) const;
958
964 const CSGSurfaceList & getSurfaceList() const { return _surface_list; }
965
972
978 const CSGCellList & getCellList() const { return _cell_list; }
979
986
993
1000
1006 const CSGLatticeList & getLatticeList() const { return _lattice_list; }
1007
1014
1022 void updateIncomingCSGReferences(CSGBase & incoming_base);
1023
1033 std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs,
1034 CSGBase & base);
1035
1045 std::map<std::string, std::reference_wrapper<const CSGCell>> & identical_cell_refs,
1046 CSGBase & base);
1047
1058 std::map<std::string, std::reference_wrapper<const CSGUniverse>> & identical_universe_refs,
1059 CSGBase & base);
1060
1070 std::map<std::string, std::reference_wrapper<const CSGLattice>> & identical_lattice_refs,
1071 CSGBase & base);
1072
1079
1087 void joinSurfaceList(CSGSurfaceList & surf_list, const bool ignore_identical_surfaces);
1088
1096 void joinCellList(CSGCellList & cell_list, const bool ignore_identical_cells);
1097
1105 void joinLatticeList(CSGLatticeList & lattice_list, const bool ignore_identical_lattices);
1106
1115 void joinUniverseList(CSGUniverseList & univ_list, const bool ignore_identical_universes);
1116
1128 void joinUniverseList(CSGUniverseList & univ_list,
1129 const bool ignore_identical_universes,
1130 const std::string & new_root_name_incoming);
1131
1145 void joinUniverseList(CSGUniverseList & univ_list,
1146 const bool ignore_identical_universes,
1147 const std::string & new_root_name_base,
1148 const std::string & new_root_name_incoming);
1149
1154 void rebuildEngUnitList();
1155
1157 void replaceUniverseRefs(const CSGUniverse & old_univ, const CSGUniverse & new_univ);
1158
1160 void replaceCellRefs(const CSGCell & old_cell, const CSGCell & new_cell);
1161
1163 void replaceSurfaceRefsWithRegion(const CSGSurface & old_surf, const CSGRegion & sub_region);
1164
1166 void checkRegionSurfaces(const CSGRegion & region) const;
1167
1169 bool checkSurfaceInBase(const CSGSurface & surface) const;
1170
1172 bool checkCellInBase(const CSGCell & cell) const;
1173
1175 bool checkEngUnitInBase(const CSGEngUnit & unit) const;
1176
1178 bool checkUniverseInBase(const CSGUniverse & universe) const;
1179
1181 bool checkLatticeInBase(const CSGLattice & lattice) const;
1182
1184 void prepareSurfaceDeletion(const CSGSurface & surface) const;
1185
1187 void prepareCellDeletion(const CSGCell & cell);
1188
1190 void prepareUniverseDeletion(const CSGUniverse & universe) const;
1191
1200 {
1201 return dynamic_cast<const CSGSurfaceEngUnit *>(&surf);
1202 }
1203
1211 const CSGCellEngUnit * cellToEngUnit(const CSGCell & cell) const
1212 {
1213 return dynamic_cast<const CSGCellEngUnit *>(&cell);
1214 }
1215
1224 {
1225 return dynamic_cast<const CSGUniverseEngUnit *>(&univ);
1226 }
1227
1234 const CSGCell & addCellToList(const CSGCell & cell);
1235
1242 const CSGUniverse & addUniverseToList(const CSGUniverse & univ);
1243
1250 const CSGLattice & addLatticeToList(const CSGLattice & lattice);
1251
1254
1257
1260
1263
1266
1267#ifdef MOOSE_UNIT_TEST
1270 FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces);
1271 FRIEND_TEST(CSGBaseTest, testAddGetSurface);
1272 FRIEND_TEST(CSGBaseTest, testUniverseLinking);
1273 FRIEND_TEST(CSGBaseTest, testEngUnitLinking);
1274 FRIEND_TEST(CSGBaseTest, testCellEngUnitAddErrors);
1275 FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors);
1277#endif
1278};
1279} // 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:964
CSGUniverseList & getUniverseList()
Get a non-const reference to the CSGUniverseList object.
Definition CSGBase.h:999
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:899
void prepareCellDeletion(const CSGCell &cell)
warn and remove cell from any universe that contains it
Definition CSGBase.C:321
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:1090
const CSGCell & addCellToList(const CSGCell &cell)
Add a new cell to the cell list based on a cell reference.
Definition CSGBase.C:118
const CSGCellList & getCellList() const
Get a const reference to the CSGCellList object.
Definition CSGBase.h:978
CSGCellList _cell_list
List of cells associated with CSG object.
Definition CSGBase.h:1256
void deleteCell(const CSGCell &cell)
Remove a Cell object passed in by reference from the stored cell list.
Definition CSGBase.C:343
const CSGSurface & getSurfaceByName(const std::string &name) const
Get a Surface object by name.
Definition CSGBase.h:107
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:916
CSGLatticeList & getLatticeList()
Get the CSGLatticeList object.
Definition CSGBase.h:1013
std::unique_ptr< CSGBase > clone() const
Create a deep copy of this CSGBase instance.
Definition CSGBase.h:72
bool checkUniverseInBase(const CSGUniverse &universe) const
check that universe being accessed is a part of this CSGBase instance
Definition CSGBase.C:1100
const CSGLattice & addLatticeToList(const CSGLattice &lattice)
Add a new lattice to the lattice list based on a lattice reference.
Definition CSGBase.C:184
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:997
std::vector< std::reference_wrapper< const CSGEngUnit > > getAllEngUnits() const
Get all engineering units of all types in CSGBase.
Definition CSGBase.h:624
void updateIncomingCSGReferences(CSGBase &incoming_base)
update references of incoming CSGbase to point to those of existing CSGBase object.
Definition CSGBase.C:824
void renameSurface(const CSGSurface &surface, const std::string &name)
rename the specified surface
Definition CSGBase.C:1147
const CSGUniverse & addUniverseToList(const CSGUniverse &univ)
Add a new universe to the universe list based on a universe reference.
Definition CSGBase.C:159
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:936
std::vector< std::reference_wrapper< const CSGUniverseEngUnit > > getAllUniverseEngUnits() const
Get all universe-like engineering units.
Definition CSGBase.h:654
std::vector< std::reference_wrapper< const CSGCell > > getAllCells() const
Get all cell objects.
Definition CSGBase.h:199
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.
Definition CSGBase.C:1229
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:888
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:815
CSGSurfaceList _surface_list
List of surfaces associated with CSG object.
Definition CSGBase.h:1253
bool hasUniverse(const std::string &name) const
Check if a universe with given name exists in CSGBase object.
Definition CSGBase.h:382
CSGSurfaceList & getSurfaceList()
Get a non-const reference to the CSGSurfaceList object.
Definition CSGBase.h:971
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:861
void expandAllEngUnitsCycle(std::set< std::set< std::string > > &all_type_sets)
Recursive implementation of expandAllEngUnits().
Definition CSGBase.C:1288
bool hasLattice(const std::string &name) const
Check if a lattice with given name exists in CSGBase object.
Definition CSGBase.h:520
const CSGUniverseList & getUniverseList() const
Get a const reference to the CSGUniverseList object.
Definition CSGBase.h:992
void expandAllEngUnits()
Expand all registered engineering units into basic CSG objects.
Definition CSGBase.C:1281
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:743
CSGLatticeList _lattice_list
List of lattices associated with CSG object.
Definition CSGBase.h:1262
void checkRegionSurfaces(const CSGRegion &region) const
check that surfaces used in this region are a part of this CSGBase instance
Definition CSGBase.C:1068
void renameEngUnit(const CSGEngUnit &unit, const std::string &name)
Rename the specified engineering unit.
Definition CSGBase.C:1130
std::vector< std::reference_wrapper< const CSGUniverse > > getAllUniverses() const
Get all universe objects.
Definition CSGBase.h:360
CSGEngUnitList _eng_unit_list
Container for all associated engineering units.
Definition CSGBase.h:1265
const CSGUniverse & getUniverseByName(const std::string &name)
Get a universe object by name.
Definition CSGBase.h:371
const CSGSurface & addSurface(std::unique_ptr< CSGSurface > surf)
add a unique surface pointer to this base instance
Definition CSGBase.C:78
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:600
void joinCellList(CSGCellList &cell_list, const bool ignore_identical_cells)
join a separate CSGCellList object to this one
Definition CSGBase.C:963
void joinLatticeList(CSGLatticeList &lattice_list, const bool ignore_identical_lattices)
join a separate CSGLatticeList object to this one
Definition CSGBase.C:971
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:556
void joinOtherBase(std::unique_ptr< CSGBase > base, const bool ignore_identical_components)
Join another CSGBase object to this one.
Definition CSGBase.C:773
void renameUniverse(const CSGUniverse &universe, const std::string &name)
rename the specified universe
Definition CSGBase.C:1174
FRIEND_TEST(CSGBaseTest, testUnivEngUnitAddErrors)
void resetCellFill(const CSGCell &cell)
reset the fill of the specified cell to void
Definition CSGBase.C:375
const EngUnitType & getEngUnitByName(const std::string &name) const
Get a engineering unit object of the specified type by name.
Definition CSGBase.h:592
bool hasEngUnit(const std::string &name) const
Check if an engineeering unit with given name exists in CSGBase object.
Definition CSGBase.h:609
void rebuildEngUnitList()
rebuilds the list of raw pointers to engineering units by iterating through the surface,...
Definition CSGBase.C:979
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:393
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:458
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:1495
void addTransformation(const CSGEngUnit &unit, TransformationType type, const std::tuple< Real, Real, Real > &values)
Apply a transformation to a CSGEngUnit object.
Definition CSGBase.h:802
bool hasSurface(const std::string &name) const
Check if a surface with given name exists in CSGBase object.
Definition CSGBase.h:118
const CSGLatticeList & getLatticeList() const
Get a const reference to the CSGLatticeList object.
Definition CSGBase.h:1006
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:899
CSGRegion expandEngUnit(const CSGSurfaceEngUnit &unit)
Expand a surface-like engineering unit into basic CSGSurface(s) and return the CSGRegion representing...
Definition CSGBase.C:1335
void deleteLattice(const CSGLattice &lattice)
Remove a Lattice object passed in by reference from the stored lattice list.
Definition CSGBase.C:222
void renameCell(const CSGCell &cell, const std::string &name)
rename the specified cell
Definition CSGBase.C:1161
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:833
void renameRootUniverse(const std::string &name)
rename the root universe for this instance (default is ROOT_UNIVERSE)
Definition CSGBase.h:279
const LatticeType & getLatticeByName(const std::string &name)
Get a lattice object of the specified type by name.
Definition CSGBase.h:504
const CSGEngUnitList & getEngUnitList() const
Get a const reference to the CSGEngUnitList object.
Definition CSGBase.h:1078
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:529
void resetLatticeOuter(const CSGLattice &lattice)
reset the outer fill for the lattice to VOID
Definition CSGBase.C:589
const CSGUniverse & createUniverse(const std::string &name)
Create an empty Universe object.
Definition CSGBase.h:298
bool hasCell(const std::string &name) const
Check if a cell with given name exists in CSGBase object.
Definition CSGBase.h:218
const CSGUniverse & getRootUniverse() const
Get the Root Universe object.
Definition CSGBase.h:272
const CSGUniverseEngUnit * universeToEngUnit(const CSGUniverse &univ) const
Returns the CSGUniverseEngUnit pointer if univ is an eng unit, nullptr otherwise.
Definition CSGBase.h:1223
std::vector< std::reference_wrapper< const CSGLattice > > getAllLattices() const
Get all lattice objects.
Definition CSGBase.h:486
void removeCellFromUniverse(const CSGUniverse &universe, const CSGCell &cell)
Remove a cell from an existing universe.
Definition CSGBase.C:537
std::vector< std::reference_wrapper< const CSGCellEngUnit > > getAllCellEngUnits() const
Get all cell-like engineering units in CSGBase.
Definition CSGBase.h:644
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:1525
bool checkSurfaceInBase(const CSGSurface &surface) const
check that surface being accessed is a part of this CSGBase instance
Definition CSGBase.C:1080
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:616
bool operator==(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are equal.
Definition CSGBase.C:1685
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:884
void deleteSurface(const CSGSurface &surface)
Remove a Surface object passed in by reference from the stored surface list.
Definition CSGBase.C:103
~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:844
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:1540
void addCellToUniverse(const CSGUniverse &universe, const CSGCell &cell)
Add a cell to an existing universe.
Definition CSGBase.C:507
const CSGSurfaceEngUnit * surfaceToEngUnit(const CSGSurface &surf) const
Returns the CSGSurfaceEngUnit pointer if surf is an eng unit, nullptr otherwise.
Definition CSGBase.h:1199
void prepareSurfaceDeletion(const CSGSurface &surface) const
error if surface is referenced in any cell region
Definition CSGBase.C:88
std::vector< std::reference_wrapper< const CSGSurface > > getAllSurfaces() const
Get all surface objects.
Definition CSGBase.h:96
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:874
void updateCellRegion(const CSGCell &cell, const CSGRegion &region)
change the region of the specified cell
Definition CSGBase.C:358
std::vector< std::reference_wrapper< const CSGSurfaceEngUnit > > getAllSurfaceEngUnits() const
Get all surface-like engineering units in CSGBase.
Definition CSGBase.h:634
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:564
bool areUniversesLinked() const
Check whether all universes and cells in this CSGBase are reachable from the root universe through th...
Definition CSGBase.C:1212
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:534
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:245
bool checkEngUnitInBase(const CSGEngUnit &unit) const
check that engineering unit being accessed is a part of this CSGBase instance
Definition CSGBase.C:1120
bool operator!=(const CSGBase &other) const
Operator overload for checking if two CSGBase objects are not equal.
Definition CSGBase.C:1703
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:1211
void renameLattice(const CSGLattice &lattice, const std::string &name)
rename the lattice
Definition CSGBase.h:451
void joinSurfaceList(CSGSurfaceList &surf_list, const bool ignore_identical_surfaces)
join a separate CSGSurfaceList object to this one
Definition CSGBase.C:955
void deleteEngUnit(const CSGEngUnit &unit)
Remove an engineering unit passed in by reference from the stored engineering unit list.
Definition CSGBase.C:1260
CSGSurface & getSurface(const std::string &name)
Get a Surface object by name.
Definition CSGBase.h:931
void checkUniverseLinking() const
Check universes linked to root universe match universes defined in _universe_list.
Definition CSGBase.C:1188
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:1110
const CSGCell & getCellByName(const std::string &name) const
Get a Cell object by name.
Definition CSGBase.h:210
CSGUniverseList _universe_list
List of universes associated with CSG object.
Definition CSGBase.h:1259
nlohmann::json generateOutput() const
generate the JSON representation output for the CSG object
Definition CSGBase.C:1555
CSGCellList & getCellList()
Get a non-const reference to the CSGCellList object.
Definition CSGBase.h:985
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:635
void updateCellFill(const CSGCell &cell, const std::string &mat_name)
change the fill of the specified cell to a material fill
Definition CSGBase.C:391
void deleteUniverse(const CSGUniverse &univ)
Remove a Universe object passed in by reference from the stored universe list.
Definition CSGBase.C:492
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