https://mooseframework.inl.gov
CSGCell.C
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 #include "CSGCell.h"
11 #include "CSGUniverse.h"
12 #include "CSGLattice.h"
13 #include "CSGUtils.h"
14 
15 namespace CSG
16 {
17 
18 CSGCell::CSGCell(const std::string & name, const CSGRegion & region)
19  : _name(name), _fill_name(""), _region(region)
20 {
22  _fill_type = "VOID";
23 }
24 
25 CSGCell::CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region)
26  : _name(name), _fill_name(mat_name), _region(region)
27 {
29  _fill_type = "CSG_MATERIAL";
30 }
31 
32 CSGCell::CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region)
33  : _name(name), _fill_name(""), _region(region), _fill_universe(univ)
34 {
36  _fill_type = "UNIVERSE";
37 }
38 
39 CSGCell::CSGCell(const std::string & name, const CSGLattice * lattice, const CSGRegion & region)
40  : _name(name), _fill_name(""), _region(region), _fill_lattice(lattice)
41 {
43  _fill_type = "LATTICE";
44 }
45 
46 const std::string &
48 {
49  if (getFillType() == "UNIVERSE")
50  return _fill_universe->getName();
51  else if (getFillType() == "LATTICE")
52  return _fill_lattice->getName();
53  else
54  return _fill_name;
55 }
56 
57 const CSGUniverse &
59 {
60  if (getFillType() != "UNIVERSE")
61  mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not UNIVERSE.");
62  else
63  return *_fill_universe;
64 }
65 
66 const std::string &
68 {
69  if (getFillType() != "CSG_MATERIAL")
70  mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not CSG_MATERIAL.");
71  else
72  return _fill_name;
73 }
74 
75 const CSGLattice &
77 {
78  if (getFillType() != "LATTICE")
79  mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not LATTICE.");
80  else
81  return *_fill_lattice;
82 }
83 
84 void
86 {
87  _fill_name = "";
88  _fill_universe = nullptr;
89  _fill_lattice = nullptr;
90  _fill_type = "VOID";
91 }
92 
93 void
94 CSGCell::updateCellFill(const std::string & mat_name)
95 {
96  resetCellFill();
97  _fill_type = "CSG_MATERIAL";
98  _fill_name = mat_name;
99 }
100 
101 void
103 {
104  resetCellFill();
105  _fill_type = "UNIVERSE";
106  _fill_universe = univ;
107 }
108 
109 void
111 {
112  resetCellFill();
113  _fill_type = "LATTICE";
114  _fill_lattice = lattice;
115 }
116 
117 void
119  std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs)
120 {
121  _region.updateSurfaceReferences(identical_surface_refs);
122 }
123 
124 bool
125 CSGCell::operator==(const CSG::CSGCell & other) const
126 {
127  const auto name_eq = this->getName() == other.getName();
128  const auto region_eq = this->getRegion() == other.getRegion();
129  const auto fill_type_eq =
130  (this->getFillType() == other.getFillType()) && (this->getFillName() == other.getFillName());
131  const auto transformations_eq = this->getTransformations() == other.getTransformations();
132  if (name_eq && region_eq && fill_type_eq && transformations_eq)
133  {
134  if (this->getFillType() == "CSG_MATERIAL")
135  return this->getFillMaterial() == other.getFillMaterial();
136  else if (this->getFillType() == "UNIVERSE")
137  return this->getFillUniverse() == other.getFillUniverse();
138  else if (this->getFillType() == "LATTICE")
139  return this->getFillLattice() == other.getFillLattice();
140  else
141  return true;
142  }
143  else
144  return false;
145 }
146 
147 bool
148 CSGCell::operator!=(const CSG::CSGCell & other) const
149 {
150  return !(*this == other);
151 }
152 
153 } // namespace CSG
std::string name(const ElemQuality q)
const CSGLattice & getFillLattice() const
Get the cell fill if fill type is LATTICE.
Definition: CSGCell.C:76
void updateCellRegionSurfaces(std::map< std::string, std::reference_wrapper< const CSGSurface >> &identical_surface_refs)
Update surface references of cell region based on map of input surface references.
Definition: CSGCell.C:118
const CSGUniverse & getFillUniverse() const
Get the cell fill if fill type is UNIVERSE.
Definition: CSGCell.C:58
const std::string & getName() const
Get the cell name.
Definition: CSGCell.h:112
const std::string getFillType() const
Get the type of fill for the cell.
Definition: CSGCell.h:77
void updateCellFill(const std::string &mat_name)
Set the cell fill to a material name.
Definition: CSGCell.C:94
MooseEnum _fill_type
An enum for type of fill for cell region.
Definition: CSGCell.h:176
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection...
Definition: CSGRegion.h:22
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
CSGUniverse creates an internal representation of a Constructive Solid Geometry (CSG) universe...
Definition: CSGUniverse.h:27
const std::string & getName() const
Get the name of lattice.
Definition: CSGLattice.h:62
void resetCellFill()
Reset the cell fill to void.
Definition: CSGCell.C:85
const std::string & getFillName() const
Get the name of the fill, regardless of its type.
Definition: CSGCell.C:47
CSGRegion _region
Cell region, represented as a CSGRegion object.
Definition: CSGCell.h:182
CSGLattice is the abstract class for defining lattices.
Definition: CSGLattice.h:34
const std::string & getName() const
Get the name of the universe.
Definition: CSGUniverse.h:80
void updateSurfaceReferences(std::map< std::string, std::reference_wrapper< const CSGSurface >> &identical_surface_refs)
Update surface references of region based on map of input surface references.
Definition: CSGRegion.C:252
CSGCell(const std::string &name, const CSGRegion &region)
Constructor for void cell.
Definition: CSGCell.C:18
const CSGLattice * _fill_lattice
Fill object if fill is CSGLattice.
Definition: CSGCell.h:188
void checkValidCSGName(const std::string &name)
Check name of CSG component for disallowed characters and symbols.
Definition: CSGUtils.C:36
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell...
Definition: CSGCell.h:29
bool operator!=(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are not equal.
Definition: CSGCell.C:148
std::string _fill_name
name of the fill object for CSG_MATERIAL fills
Definition: CSGCell.h:179
const CSGRegion & getRegion() const
Get the cell region.
Definition: CSGCell.h:119
const CSGUniverse * _fill_universe
Fill object if fill is CSGUniverse.
Definition: CSGCell.h:185
const std::string & getFillMaterial() const
Get the cell fill material name if fill fype is CSG_MATERIAL.
Definition: CSGCell.C:67
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.
bool operator==(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are equal.
Definition: CSGCell.C:125