Line data Source code
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"
17 : #include "CSGTransformationHelper.h"
18 : #include "nlohmann/json.h"
19 :
20 : #ifdef MOOSE_UNIT_TEST
21 : #include "gtest/gtest.h"
22 : #endif
23 :
24 : namespace CSG
25 : {
26 :
27 : /**
28 : * Enumeration of axis types for rotations
29 : */
30 : enum class RotationAxisType
31 : {
32 : X = 0, // X axis
33 : Y = 1, // Y axis
34 : Z = 2 // Z axis
35 : };
36 :
37 : /**
38 : * Define a variant type that can hold references to different CSG object types
39 : */
40 : typedef std::variant<std::reference_wrapper<const CSGSurface>,
41 : std::reference_wrapper<const CSGCell>,
42 : std::reference_wrapper<const CSGUniverse>,
43 : std::reference_wrapper<const CSGRegion>,
44 : std::reference_wrapper<const CSGLattice>>
45 : CSGObjectVariant;
46 :
47 : /**
48 : * CSGBase creates an internal representation of a Constructive Solid Geometry (CSG)
49 : * model.
50 : */
51 : class CSGBase
52 : {
53 : public:
54 : /**
55 : * Default constructor
56 : */
57 : CSGBase();
58 :
59 : /**
60 : * Copy constructor
61 : */
62 : CSGBase(const CSGBase & other_base);
63 :
64 : /**
65 : * Destructor
66 : */
67 : ~CSGBase();
68 :
69 : /// Create a deep copy of this CSGBase instance
70 12 : std::unique_ptr<CSGBase> clone() const { return std::make_unique<CSGBase>(*this); }
71 :
72 : /**
73 : * @brief add a unique surface pointer to this base instance
74 : *
75 : * @param surf pointer to surface to add
76 : *
77 : * @return reference to CSGSurface that was added
78 : */
79 568 : const CSGSurface & addSurface(std::unique_ptr<CSGSurface> surf)
80 : {
81 568 : return _surface_list.addSurface(std::move(surf));
82 : }
83 :
84 : /**
85 : * @brief Remove a Surface object passed in by reference from the stored surface list. Any CSG
86 : * components connected to surface will not be recursively removed.
87 : *
88 : * @param surface reference to surface to delete
89 : */
90 : void deleteSurface(const CSGSurface & surface);
91 :
92 : /**
93 : * @brief Get all surface objects
94 : *
95 : * @return list of references to all CSGSurface objects in CSGBase
96 : */
97 90 : std::vector<std::reference_wrapper<const CSGSurface>> getAllSurfaces() const
98 : {
99 90 : return _surface_list.getAllSurfaces();
100 : }
101 :
102 : /**
103 : * @brief Get a Surface object by name
104 : *
105 : * @param name surface name
106 : * @return reference to CSGSurface object
107 : */
108 6 : const CSGSurface & getSurfaceByName(const std::string & name) const
109 : {
110 6 : return _surface_list.getSurface(name);
111 : }
112 :
113 : /**
114 : * @brief Check if a surface with given name exists in CSGBase object
115 : *
116 : * @param name surface name
117 : * @return true if surface with given name exists in CSGBase
118 : */
119 12 : bool hasSurface(const std::string & name) const { return _surface_list.hasSurface(name); }
120 :
121 : /**
122 : * @brief rename the specified surface
123 : *
124 : * @param surface CSGSurface to rename
125 : * @param name new name
126 : */
127 88 : void renameSurface(const CSGSurface & surface, const std::string & name)
128 : {
129 88 : _surface_list.renameSurface(surface, name);
130 84 : }
131 :
132 : /**
133 : * @brief Create a Material Cell object
134 : *
135 : * @param name unique cell name
136 : * @param mat_name material name
137 : * @param region cell region
138 : * @param add_to_univ (optional) universe to which this cell will be added (default is root
139 : * universe)
140 : * @return reference to CSGCell that is created
141 : */
142 : const CSGCell & createCell(const std::string & name,
143 : const std::string & mat_name,
144 : const CSGRegion & region,
145 : const CSGUniverse * add_to_univ = nullptr);
146 :
147 : /**
148 : * @brief Create a Void Cell object
149 : *
150 : * @param name unique cell name
151 : * @param region cell region
152 : * @param add_to_univ (optional) universe to which this cell will be added (default is root
153 : * universe)
154 : * @return reference to CSGCell that is created
155 : */
156 : const CSGCell & createCell(const std::string & name,
157 : const CSGRegion & region,
158 : const CSGUniverse * add_to_univ = nullptr);
159 :
160 : /**
161 : * @brief Create a Universe Cell object
162 : *
163 : * @param name unique cell name
164 : * @param fill_univ universe that will fill the cell
165 : * @param region cell region
166 : * @param add_to_univ (optional) universe to which this cell will be added (default is root
167 : * universe)
168 : * @return reference to cell that is created
169 : */
170 : const CSGCell & createCell(const std::string & name,
171 : const CSGUniverse & fill_univ,
172 : const CSGRegion & region,
173 : const CSGUniverse * add_to_univ = nullptr);
174 :
175 : /**
176 : * @brief Create a Lattice Cell object
177 : *
178 : * @param name unique cell name
179 : * @param fill_lattice lattice that will fill the cell
180 : * @param region cell region
181 : * @param add_to_univ (optional) universe to which this cell will be added (default is root
182 : * universe)
183 : * @return reference to cell that is created
184 : */
185 : const CSGCell & createCell(const std::string & name,
186 : const CSGLattice & fill_lattice,
187 : const CSGRegion & region,
188 : const CSGUniverse * add_to_univ = nullptr);
189 :
190 : /**
191 : * @brief Remove a Cell object passed in by reference from the stored cell list. Any CSG
192 : * components connected to cell will not be recursively removed.
193 : *
194 : * @param cell reference to cell to delete
195 : */
196 : void deleteCell(const CSGCell & cell);
197 :
198 : /**
199 : * @brief Get all cell objects
200 : *
201 : * @return list of references to all CSGCell objects in CSGBase
202 : */
203 160 : std::vector<std::reference_wrapper<const CSGCell>> getAllCells() const
204 : {
205 160 : return _cell_list.getAllCells();
206 : }
207 :
208 : /**
209 : * @brief Get a Cell object by name
210 : *
211 : * @param name cell name
212 : * @return reference to CSGCell object
213 : */
214 32 : const CSGCell & getCellByName(const std::string & name) const { return _cell_list.getCell(name); }
215 :
216 : /**
217 : * @brief Check if a cell with given name exists in CSGBase object
218 : *
219 : * @param name cell name
220 : * @return true if cell with given name exists in CSGBase
221 : */
222 6 : bool hasCell(const std::string & name) const { return _cell_list.hasCell(name); }
223 :
224 : /**
225 : * @brief rename the specified cell
226 : *
227 : * @param cell reference to CSGCell to rename
228 : * @param name new name
229 : */
230 118 : void renameCell(const CSGCell & cell, const std::string & name)
231 : {
232 118 : _cell_list.renameCell(cell, name);
233 114 : }
234 :
235 : /**
236 : * @brief change the region of the specified cell
237 : *
238 : * @param cell cell to update the region for
239 : * @param region new region to assign to cell
240 : */
241 : void updateCellRegion(const CSGCell & cell, const CSGRegion & region);
242 :
243 : /**
244 : * @brief reset the fill of the specified cell to void
245 : *
246 : * @param cell cell to update the fill for
247 : */
248 : void resetCellFill(const CSGCell & cell);
249 :
250 : /**
251 : * @brief change the fill of the specified cell to a material fill
252 : *
253 : * @param cell cell to update the fill for
254 : * @param mat_name name of material fill
255 : */
256 : void updateCellFill(const CSGCell & cell, const std::string & mat_name);
257 :
258 : /**
259 : * @brief change the fill of the specified cell to a universe fill
260 : *
261 : * @param cell cell to update the fill for
262 : * @param univ pointer to universe fill
263 : */
264 : void updateCellFill(const CSGCell & cell, const CSGUniverse * univ);
265 :
266 : /**
267 : * @brief change the fill of the specified cell to a lattice fill
268 : *
269 : * @param cell cell to update the fill for
270 : * @param lattice pointer to lattice fill
271 : */
272 : void updateCellFill(const CSGCell & cell, const CSGLattice * lattice);
273 :
274 : /**
275 : * @brief Get the Root Universe object
276 : *
277 : * @return reference to root CSGUniverse
278 : */
279 450 : const CSGUniverse & getRootUniverse() const { return _universe_list.getRoot(); }
280 :
281 : /**
282 : * @brief rename the root universe for this instance (default is ROOT_UNIVERSE)
283 : *
284 : * @param name new name for the root universe
285 : */
286 2 : void renameRootUniverse(const std::string & name)
287 : {
288 2 : _universe_list.renameUniverse(_universe_list.getRoot(), name);
289 2 : }
290 :
291 : /**
292 : * @brief rename the specified universe
293 : *
294 : * @param universe reference to CSGUniverse to rename
295 : * @param name new name
296 : */
297 54 : void renameUniverse(const CSGUniverse & universe, const std::string & name)
298 : {
299 54 : _universe_list.renameUniverse(universe, name);
300 50 : }
301 :
302 : /**
303 : * @brief Create an empty Universe object
304 : *
305 : * @param name unique universe name
306 : * @return reference to CSGUniverse that is created
307 : */
308 102 : const CSGUniverse & createUniverse(const std::string & name)
309 : {
310 102 : return _universe_list.addUniverse(name);
311 : }
312 :
313 : /**
314 : * @brief Create a Universe object from list of cells
315 : *
316 : * @param name unique universe name
317 : * @param cells list of cells to add to universe
318 : * @return reference to CSGUniverse that is created
319 : */
320 : const CSGUniverse & createUniverse(const std::string & name,
321 : std::vector<std::reference_wrapper<const CSGCell>> & cells);
322 :
323 : /**
324 : * @brief Remove a Universe object passed in by reference from the stored universe list. Any CSG
325 : * components connected to universe will not be recursively removed.
326 : *
327 : * @param univ reference to universe to delete
328 : */
329 : void deleteUniverse(const CSGUniverse & univ);
330 :
331 : /**
332 : * @brief Add a cell to an existing universe
333 : *
334 : * @param universe universe to which to add the cell
335 : * @param cell cell to add
336 : */
337 : void addCellToUniverse(const CSGUniverse & universe, const CSGCell & cell);
338 :
339 : /**
340 : * @brief Add a list of cells to an existing universe
341 : *
342 : * @param universe universe to which to add the cells
343 : * @param cells list of references to cells to add
344 : */
345 : void addCellsToUniverse(const CSGUniverse & universe,
346 : std::vector<std::reference_wrapper<const CSGCell>> & cells);
347 :
348 : /**
349 : * @brief Remove a cell from an existing universe
350 : *
351 : * @param universe universe from which to remove the cell
352 : * @param cell cell to remove
353 : */
354 : void removeCellFromUniverse(const CSGUniverse & universe, const CSGCell & cell);
355 :
356 : /**
357 : * @brief Remove a list of cells from an existing universe
358 : *
359 : * @param universe universe from which to remove the cells
360 : * @param cells list of references to cells to remove
361 : */
362 : void removeCellsFromUniverse(const CSGUniverse & universe,
363 : std::vector<std::reference_wrapper<const CSGCell>> & cells);
364 :
365 : /**
366 : * @brief Get all universe objects
367 : *
368 : * @return list of references to CSGUniverse objects in this CSGBase instance
369 : */
370 166 : std::vector<std::reference_wrapper<const CSGUniverse>> getAllUniverses() const
371 : {
372 166 : return _universe_list.getAllUniverses();
373 : }
374 :
375 : /**
376 : * @brief Get a universe object by name
377 : *
378 : * @param name universe name
379 : * @return reference to CSGUniverse object
380 : */
381 316 : const CSGUniverse & getUniverseByName(const std::string & name)
382 : {
383 316 : return _universe_list.getUniverse(name);
384 : }
385 :
386 : /**
387 : * @brief Check if a universe with given name exists in CSGBase object
388 : *
389 : * @param name universe name
390 : * @return true if universe with given name exists in CSGBase
391 : */
392 12 : bool hasUniverse(const std::string & name) const { return _universe_list.hasUniverse(name); }
393 :
394 : /**
395 : * @brief add a unique lattice pointer to this base instance; universes that make the lattice
396 : * must already be a part of this CSGBase instance.
397 : *
398 : * @param lattice pointer to lattice to add
399 : *
400 : * @return reference to CSGLattice that was added
401 : */
402 : template <typename LatticeType = CSGLattice>
403 104 : const LatticeType & addLattice(std::unique_ptr<LatticeType> lattice)
404 : {
405 : static_assert(std::is_base_of_v<CSGLattice, LatticeType>, "Is not a CSGLattice");
406 : // make sure all universes are a part of this base instance
407 104 : auto universes = lattice->getUniverses();
408 270 : for (auto univ_list : universes)
409 556 : for (const CSGUniverse & univ : univ_list)
410 392 : if (!checkUniverseInBase(univ))
411 14 : mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
412 2 : ". Universe " + univ.getName() + " is not in the CSGBase instance.");
413 :
414 102 : if (lattice->getOuterType() == "UNIVERSE")
415 : {
416 12 : const CSGUniverse & outer_univ = lattice->getOuterUniverse();
417 12 : if (!checkUniverseInBase(outer_univ))
418 14 : mooseError("Cannot add lattice " + lattice->getName() + " of type " + lattice->getType() +
419 2 : ". Outer universe " + outer_univ.getName() + " is not in the CSGBase instance.");
420 : }
421 100 : auto & lat_ref = _lattice_list.addLattice(std::move(lattice));
422 190 : return dynamic_cast<LatticeType &>(lat_ref);
423 104 : }
424 :
425 : /**
426 : * @brief Remove a Lattice object passed in by reference from the stored lattice list. Any CSG
427 : * components connected to lattice will not be recursively removed.
428 : *
429 : * @param lattice reference to lattice to delete
430 : */
431 : void deleteLattice(const CSGLattice & lattice);
432 :
433 : /**
434 : * @brief set location in the lattice to be the provided universe
435 : *
436 : * @param lattice lattice to update
437 : * @param universe universe to set at the location
438 : * @param index index of the lattice element (int, int)
439 : */
440 : void setUniverseAtLatticeIndex(const CSGLattice & lattice,
441 : const CSGUniverse & universe,
442 : std::pair<int, int> index);
443 :
444 : /**
445 : * @brief Set provided universes as the layout of the lattice.
446 : *
447 : * @param lattice lattice to add universes to
448 : * @param universes list of list of universes in the proper layout for the lattice type and
449 : * dimensions
450 : */
451 : void setLatticeUniverses(
452 : const CSGLattice & lattice,
453 : std::vector<std::vector<std::reference_wrapper<const CSGUniverse>>> & universes);
454 :
455 : /**
456 : * @brief rename the lattice
457 : *
458 : * @param lattice lattice to rename
459 : * @param name new name
460 : */
461 22 : void renameLattice(const CSGLattice & lattice, const std::string & name)
462 : {
463 22 : _lattice_list.renameLattice(lattice, name);
464 18 : }
465 :
466 : /**
467 : * @brief Set the outer fill for the lattice to the material name provided. This will set the
468 : * outer type to CSG_MATERIAL regardless of its previous outer type.
469 : *
470 : * @param lattice lattice to update
471 : * @param outer_name name of material to use as outer fill between lattice elements
472 : */
473 : void setLatticeOuter(const CSGLattice & lattice, const std::string & outer_name);
474 :
475 : /**
476 : * @brief Set the outer fill for the lattice to the universe provided. This will set the outer
477 : * type to UNIVERSE regardless of its previous outer type.
478 : *
479 : * @param lattice lattice to update
480 : * @param outer_univ universe to use as outer fill between lattice elements
481 : */
482 : void setLatticeOuter(const CSGLattice & lattice, const CSGUniverse & outer_univ);
483 :
484 : /**
485 : * @brief reset the outer fill for the lattice to VOID
486 : *
487 : * @param lattice lattice to update
488 : */
489 : void resetLatticeOuter(const CSGLattice & lattice);
490 :
491 : /**
492 : * @brief Get all lattice objects
493 : *
494 : * @return list of references to CSGLattice objects in this CSGBase instance
495 : */
496 90 : std::vector<std::reference_wrapper<const CSGLattice>> getAllLattices() const
497 : {
498 90 : return _lattice_list.getAllLattices();
499 : }
500 :
501 : /**
502 : * @brief Get a lattice object of the specified type by name
503 : * This is a templated method with a default type of CSGLattice. If a specific lattice type
504 : * is needed, it can be specified when calling. If the type is unknown or not specified,
505 : * it will default to CSGLattice to get the base class reference.
506 : * NOTE: if CSGLattice is used as the template type, any lattice type-specific attributes or
507 : * methods may not be accessible, except using a reference cast.
508 : *
509 : * @param name lattice name
510 : * @return reference to CSGLattice object
511 : */
512 : template <typename LatticeType = CSGLattice>
513 40 : const LatticeType & getLatticeByName(const std::string & name)
514 : {
515 40 : const CSGLattice & lattice = _lattice_list.getLattice(name);
516 38 : const LatticeType * typed_lattice = dynamic_cast<const LatticeType *>(&lattice);
517 38 : if (!typed_lattice)
518 10 : mooseError("Cannot get lattice " + name + ". Lattice is not of specified type " +
519 : MooseUtils::prettyCppType<LatticeType>());
520 36 : return *typed_lattice;
521 : }
522 :
523 : /**
524 : * @brief Check if a lattice with given name exists in CSGBase object
525 : *
526 : * @param name lattice name
527 : * @return true if lattice with given name exists in CSGBase
528 : */
529 8 : bool hasLattice(const std::string & name) const { return _lattice_list.hasLattice(name); }
530 :
531 : /**
532 : * @brief Join another CSGBase object to this one. The cells of the root universe
533 : * of the incoming CSGBase will be added to the existing root universe of this
534 : * CSGBase.
535 : *
536 : * @param base pointer to a different CSGBase object
537 : * @param ignore_identical_surfaces if true, will skip adding identical surfaces to the CSGBase
538 : * object
539 : */
540 : void joinOtherBase(std::unique_ptr<CSGBase> base, const bool ignore_identical_surfaces);
541 :
542 : /**
543 : * @brief Join another CSGBase object to this one. For the incoming CSGBase object,
544 : * the root universe is added to this CSGBase object as a new non-root universe with
545 : * the specified new name.
546 : * Note: this newly created universe will not be connected to the root universe
547 : * of this CSGBase object by default.
548 : *
549 : * @param base pointer to a different CSGBase object
550 : * @param ignore_identical_surfaces if true, will skip adding identical surfaces to the CSGBase
551 : * object
552 : * @param new_root_name_join new name for the universe generated from the incoming root universe
553 : */
554 : void joinOtherBase(std::unique_ptr<CSGBase> base,
555 : const bool ignore_identical_surfaces,
556 : const std::string & new_root_name_join);
557 :
558 : /**
559 : * @brief Join another CSGBase object to this one. The root universe for the incoming CSGBase
560 : * object is added to this CSGBase object as a non-root universe with a new name. The root
561 : * universe of this CSGBase object will be renamed and designated as non-root.
562 : * Note: upon completion of this join method, the root universe of this CSGBase
563 : * object will be empty. Neither of the new non-root universes will be connected to the
564 : * new root universe by default.
565 : *
566 : * @param base pointer to a different CSGBase object
567 : * @param ignore_identical_surfaces if true, will skip adding identical surfaces to the CSGBase
568 : * object
569 : * @param new_root_name_base new name for universe generated from this root universe
570 : * @param new_root_name_join new name for the universe generated from the incoming root universe
571 : */
572 : void joinOtherBase(std::unique_ptr<CSGBase> base,
573 : const bool ignore_identical_surfaces,
574 : const std::string & new_root_name_base,
575 : const std::string & new_root_name_join);
576 :
577 : /**
578 : * @brief generate the JSON representation output for the CSG object
579 : *
580 : * @return nlohmann::json JSON object representing the CSG model
581 : */
582 : nlohmann::json generateOutput() const;
583 :
584 : /// Operator overload for checking if two CSGBase objects are equal
585 : bool operator==(const CSGBase & other) const;
586 :
587 : /// Operator overload for checking if two CSGBase objects are not equal
588 : bool operator!=(const CSGBase & other) const;
589 :
590 : /**
591 : * @brief Apply a transformation to a CSG object
592 : *
593 : * @param csg_object The CSG object to transform (Surface, Cell, Universe, Region, or Lattice)
594 : * @param type The type of transformation to apply (TRANSLATION, ROTATION, SCALE)
595 : * @param values tuple of transformation values (3 values for any transformation type)
596 : */
597 : void addTransformation(const CSGObjectVariant & csg_object,
598 : TransformationType type,
599 : const std::tuple<Real, Real, Real> & values);
600 :
601 : /**
602 : * @brief Apply a translation to a CSG object in the specified x, y, and z directions.
603 : *
604 : * @param csg_object The CSG object to translate (Surface, Cell, Universe, Region, or Lattice)
605 : * @param distances size 3 tuple with translation distances in x, y, and z directions {x, y, z}
606 : */
607 20 : void applyTranslation(const CSGObjectVariant & csg_object,
608 : const std::tuple<Real, Real, Real> & distances)
609 : {
610 20 : addTransformation(csg_object, TransformationType::TRANSLATION, distances);
611 20 : }
612 :
613 : /**
614 : * @brief Apply a rotation to a CSG object using (phi, theta, psi) angle notation (in degrees).
615 : *
616 : * @param csg_object The CSG object to rotate (Surface, Cell, Universe, Region, or Lattice)
617 : * @param angles size 3 tuple {phi, theta, psi} with rotation angles in degrees
618 : */
619 10 : void applyRotation(const CSGObjectVariant & csg_object,
620 : const std::tuple<Real, Real, Real> & angles)
621 : {
622 10 : addTransformation(csg_object, TransformationType::ROTATION, angles);
623 10 : }
624 :
625 : /**
626 : * @brief Apply a rotation to a CSG object about a specified axis (X, Y, Z).
627 : *
628 : * @param csg_object The CSG object to rotate (Surface, Cell, Universe, Region, or Lattice)
629 : * @param axis Axis type (X, Y, or Z) about which to rotate
630 : * @param angle angle in degrees to rotate about the specified axis
631 : */
632 : void
633 : applyAxisRotation(const CSGObjectVariant & csg_object, RotationAxisType axis, const Real angle);
634 :
635 : /**
636 : * @brief Scale a CSG object in the specified x, y, and z directions.
637 : *
638 : * @param csg_object The CSG object to scale (Surface, Cell, Universe, Region, or Lattice)
639 : * @param values size 3 tuple with scaling values in x, y, and z directions {x, y, z}
640 : */
641 10 : void applyScaling(const CSGObjectVariant & csg_object,
642 : const std::tuple<Real, Real, Real> & values)
643 : {
644 10 : addTransformation(csg_object, TransformationType::SCALE, values);
645 10 : }
646 :
647 : private:
648 : /**
649 : * @brief Get a Surface object by name.
650 : *
651 : * Note: This is a private method that returns a non-const reference. For the public method that
652 : * returns a const reference, use `getSurfaceByName`
653 : *
654 : * @param name surface name
655 : * @return reference to CSGSurface object
656 : */
657 2 : CSGSurface & getSurface(const std::string & name) { return _surface_list.getSurface(name); }
658 :
659 : /// Check universes linked to root universe match universes defined in _universe_list
660 : void checkUniverseLinking() const;
661 :
662 : /**
663 : * @brief Recursive method to retrieve all universes and cells linked to current universe
664 : *
665 : * @param univ Reference to universe under consideration
666 : * @param linked_universe_names List of universe names linked to current universe
667 : * @param linked_cell_names List of cell names linked to current universe
668 : */
669 : void getLinkedUniverses(const CSGUniverse & univ,
670 : std::vector<std::string> & linked_universe_names,
671 : std::vector<std::string> & linked_cell_names) const;
672 :
673 : /**
674 : * @brief Get a const reference to the CSGSurfaceList object
675 : *
676 : * @return CSGSurfaceList
677 : */
678 28 : const CSGSurfaceList & getSurfaceList() const { return _surface_list; }
679 :
680 : /**
681 : * @brief Get a non-const reference to the CSGSurfaceList object
682 : *
683 : * @return CSGSurfaceList
684 : */
685 116 : CSGSurfaceList & getSurfaceList() { return _surface_list; }
686 :
687 : /**
688 : * @brief Get a const reference to the CSGCellList object
689 : *
690 : * @return CSGCellList
691 : */
692 28 : const CSGCellList & getCellList() const { return _cell_list; }
693 :
694 : /**
695 : * @brief Get a non-const reference to the CSGCellList object
696 : *
697 : * @return CSGCellList
698 : */
699 114 : CSGCellList & getCellList() { return _cell_list; }
700 :
701 : /**
702 : * @brief Get a const reference to the CSGUniverseList object
703 : *
704 : * @return CSGUniverseList
705 : */
706 28 : const CSGUniverseList & getUniverseList() const { return _universe_list; }
707 :
708 : /**
709 : * @brief Get a non-const reference to the CSGUniverseList object
710 : *
711 : * @return CSGUniverseList
712 : */
713 112 : CSGUniverseList & getUniverseList() { return _universe_list; }
714 :
715 : /**
716 : * @brief Get a const reference to the CSGLatticeList object
717 : *
718 : * @return CSGLatticeList
719 : */
720 28 : const CSGLatticeList & getLatticeList() const { return _lattice_list; }
721 :
722 : /**
723 : * @brief Get the CSGLatticeList object
724 : *
725 : * @return CSGLatticeList
726 : */
727 112 : CSGLatticeList & getLatticeList() { return _lattice_list; }
728 :
729 : /**
730 : * @brief update cell regions of incoming CSGBase to point to surfaces contained within existing
731 : * CSGBase object
732 : *
733 : * @param surf_list CSGSurfaceList from a separate CSGBase object
734 : * @param cell_list CSGCellList from a separate CSGBase object
735 : */
736 : void updateIncomingCellRegions(CSGSurfaceList & surf_list, CSGCellList & cell_list);
737 :
738 : /**
739 : * @brief join a separate CSGSurfaceList object to this one
740 : *
741 : * @param surf_list CSGSurfaceList from a separate CSGBase object
742 : * @param ignore_identical_surfaces if true, will skip adding identical surfaces to the CSGBase
743 : * object
744 : */
745 : void joinSurfaceList(CSGSurfaceList & surf_list, const bool ignore_identical_surfaces);
746 :
747 : /**
748 : * @brief join a separate CSGCellList object to this one
749 : *
750 : * @param cell_list CSGCellList from a separate CSGBase object
751 : */
752 : void joinCellList(CSGCellList & cell_list);
753 :
754 : /**
755 : * @brief join a separate CSGLatticeList object to this one
756 : *
757 : * @param lattice_list CSGLatticeList from a separate CSGBase object
758 : */
759 : void joinLatticeList(CSGLatticeList & lattice_list);
760 :
761 : /**
762 : * @brief join a separate CSGUniverseList object to this one;
763 : * root universes from univ_list will be combined into this root universe
764 : *
765 : * @param univ_list CSGUniverseList from a separate CSGBase object
766 : */
767 : void joinUniverseList(CSGUniverseList & univ_list);
768 :
769 : /**
770 : * @brief join a separate CSGUniverseList object to this one;
771 : * the incoming root universe will be moved to a new universe of the new
772 : * name specified.
773 : *
774 : * @param univ_list CSGUniverseList from a separate CSGBase object
775 : * @param new_root_name_incoming new name for the universe generated from the incoming root
776 : * universe
777 : */
778 : void joinUniverseList(CSGUniverseList & univ_list, const std::string & new_root_name_incoming);
779 :
780 : /**
781 : * @brief join a separate CSGUniverseList object to this one;
782 : * both this root universe and the incoming root universe will be
783 : * maintained as separate universes of the specified names.
784 : * Note: upon completion of this join method, the root universe will be empty.
785 : *
786 : * @param univ_list CSGUniverseList from a separate CSGBase object
787 : * @param new_root_name_base new name for universe generated from this root universe
788 : * @param new_root_name_incoming new name for the universe generated from the incoming root
789 : * universe
790 : */
791 : void joinUniverseList(CSGUniverseList & univ_list,
792 : const std::string & new_root_name_base,
793 : const std::string & new_root_name_incoming);
794 :
795 : // check that surfaces used in this region are a part of this CSGBase instance
796 : void checkRegionSurfaces(const CSGRegion & region) const;
797 :
798 : // check that surface being accessed is a part of this CSGBase instance
799 : bool checkSurfaceInBase(const CSGSurface & surface) const;
800 :
801 : // check that cell being accessed is a part of this CSGBase instance
802 : bool checkCellInBase(const CSGCell & cell) const;
803 :
804 : // check that universe being accessed is a part of this CSGBase instance
805 : bool checkUniverseInBase(const CSGUniverse & universe) const;
806 :
807 : // check that lattice being accessed is a part of this CSGBase instance
808 : bool checkLatticeInBase(const CSGLattice & lattice) const;
809 :
810 : /**
811 : * @brief Add a new cell to the cell list based on a cell reference.
812 : * This method is called by the copy constructor of CSGBase
813 : *
814 : * @param cell reference to CSGCell that should be added to cell list
815 : */
816 : const CSGCell & addCellToList(const CSGCell & cell);
817 :
818 : /**
819 : * @brief Add a new universe to the universe list based on a universe reference.
820 : * This method is called by the copy constructor of CSGBase
821 : *
822 : * @param univ reference to CSGUniverse that should be added to universe list
823 : */
824 : const CSGUniverse & addUniverseToList(const CSGUniverse & univ);
825 :
826 : /**
827 : * @brief Add a new lattice to the lattice list based on a lattice reference.
828 : * This method is called by the copy constructor of CSGBase
829 : *
830 : * @param lattice reference to CSGLattice that should be added to universe list
831 : */
832 : const CSGLattice & addLatticeToList(const CSGLattice & lattice);
833 :
834 : /// List of surfaces associated with CSG object
835 : CSGSurfaceList _surface_list;
836 :
837 : /// List of cells associated with CSG object
838 : CSGCellList _cell_list;
839 :
840 : /// List of universes associated with CSG object
841 : CSGUniverseList _universe_list;
842 :
843 : /// List of lattices associated with CSG object
844 : CSGLatticeList _lattice_list;
845 :
846 : #ifdef MOOSE_UNIT_TEST
847 : /// Friends for unit testing
848 : ///@{
849 : FRIEND_TEST(CSGBaseTest, testCheckRegionSurfaces);
850 : FRIEND_TEST(CSGBaseTest, testAddGetSurface);
851 : FRIEND_TEST(CSGBaseTest, testUniverseLinking);
852 : ///@}
853 : #endif
854 : };
855 : } // namespace CSG
|