https://mooseframework.inl.gov
Loading...
Searching...
No Matches
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 "CSGEngUnit.h"
12#include "CSGUniverse.h"
13#include "CSGLattice.h"
14#include "CSGUtils.h"
15
16namespace CSG
17{
18
19CSGCell::CSGCell(const std::string & name, const CSGRegion & region)
20 : _name(name), _fill_name(""), _region(region)
21{
23 _fill_type = "VOID";
24}
25
26CSGCell::CSGCell(const std::string & name, const std::string & mat_name, const CSGRegion & region)
27 : _name(name), _fill_name(mat_name), _region(region)
28{
30 _fill_type = "CSG_MATERIAL";
31}
32
33CSGCell::CSGCell(const std::string & name, const CSGUniverse * univ, const CSGRegion & region)
34 : _name(name), _fill_name(""), _region(region), _fill_universe(univ)
35{
37 _fill_type = "UNIVERSE";
38}
39
40CSGCell::CSGCell(const std::string & name, const CSGLattice * lattice, const CSGRegion & region)
41 : _name(name), _fill_name(""), _region(region), _fill_lattice(lattice)
42{
44 _fill_type = "LATTICE";
45}
46
47const std::string &
49{
50 if (getFillType() == "UNIVERSE")
51 return _fill_universe->getName();
52 else if (getFillType() == "LATTICE")
53 return _fill_lattice->getName();
54 else
55 return _fill_name;
56}
57
58const CSGUniverse &
60{
61 if (getFillType() != "UNIVERSE")
62 mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not UNIVERSE.");
63 else
64 return *_fill_universe;
65}
66
67const std::string &
69{
70 if (getFillType() != "CSG_MATERIAL")
71 mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not CSG_MATERIAL.");
72 else
73 return _fill_name;
74}
75
76const CSGLattice &
78{
79 if (getFillType() != "LATTICE")
80 mooseError("Cell '" + getName() + "' has " + getFillType() + " fill, not LATTICE.");
81 else
82 return *_fill_lattice;
83}
84
85void
87{
88 _fill_name = "";
89 _fill_universe = nullptr;
90 _fill_lattice = nullptr;
91 _fill_type = "VOID";
92}
93
94void
95CSGCell::updateCellFill(const std::string & mat_name)
96{
98 _fill_type = "CSG_MATERIAL";
99 _fill_name = mat_name;
100}
101
102void
104{
106 _fill_type = "UNIVERSE";
107 _fill_universe = univ;
108}
109
110void
112{
114 _fill_type = "LATTICE";
115 _fill_lattice = lattice;
116}
117
118void
120 std::map<std::string, std::reference_wrapper<const CSGSurface>> & identical_surface_refs)
121{
122 _region.updateSurfaceReferences(identical_surface_refs);
123}
124
125bool
127{
128 // If both objects are engineering units, delegate to CSGEngUnit::operator==. The
129 // isEngUnit() check keeps the common plain-cell path free of any dynamic_cast;
130 // the casts below only run once we know the objects are engineering units.
131 if (isEngUnit())
132 {
133 if (other.isEngUnit())
134 return *dynamic_cast<const CSGEngUnit *>(this) == *dynamic_cast<const CSGEngUnit *>(&other);
135 return false; // an engineering unit cannot equal a plain cell
136 }
137
138 const auto name_eq = this->getName() == other.getName();
139 const auto region_eq = this->getRegion() == other.getRegion();
140 const auto fill_type_eq =
141 (this->getFillType() == other.getFillType()) && (this->getFillName() == other.getFillName());
142 const auto transformations_eq = this->getTransformations() == other.getTransformations();
143 if (name_eq && region_eq && fill_type_eq && transformations_eq)
144 {
145 if (this->getFillType() == "CSG_MATERIAL")
146 return this->getFillMaterial() == other.getFillMaterial();
147 else if (this->getFillType() == "UNIVERSE")
148 return this->getFillUniverse() == other.getFillUniverse();
149 else if (this->getFillType() == "LATTICE")
150 return this->getFillLattice() == other.getFillLattice();
151 else
152 return true;
153 }
154 else
155 return false;
156}
157
158bool
160{
161 return !(*this == other);
162}
163
164} // namespace CSG
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application.
Definition MooseError.h:311
CSGCell creates an internal representation of a Constructive Solid Geometry (CSG) cell,...
Definition CSGCell.h:30
CSGRegion _region
Cell region, represented as a CSGRegion object.
Definition CSGCell.h:193
const CSGRegion & getRegion() const
Get the cell region.
Definition CSGCell.h:119
const std::string & getName() const
Get the cell name.
Definition CSGCell.h:112
bool operator==(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are equal.
Definition CSGCell.C:126
const CSGLattice & getFillLattice() const
Get the cell fill if fill type is LATTICE.
Definition CSGCell.C:77
const std::string getFillType() const
Get the type of fill for the cell.
Definition CSGCell.h:77
virtual bool isEngUnit() const
Whether this cell is an engineering unit.
Definition CSGCell.h:136
void resetCellFill()
Reset the cell fill to void.
Definition CSGCell.C:86
const CSGLattice * _fill_lattice
Fill object if fill is CSGLattice.
Definition CSGCell.h:199
void updateCellFill(const std::string &mat_name)
Set the cell fill to a material name.
Definition CSGCell.C:95
const CSGUniverse & getFillUniverse() const
Get the cell fill if fill type is UNIVERSE.
Definition CSGCell.C:59
bool operator!=(const CSGCell &other) const
Operator overload for checking if two CSGCell objects are not equal.
Definition CSGCell.C:159
const CSGUniverse * _fill_universe
Fill object if fill is CSGUniverse.
Definition CSGCell.h:196
CSGCell(const std::string &name, const CSGRegion &region)
Constructor for void cell.
Definition CSGCell.C:19
const std::string & getFillMaterial() const
Get the cell fill material name if fill fype is CSG_MATERIAL.
Definition CSGCell.C:68
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:119
const std::string & getFillName() const
Get the name of the fill, regardless of its type.
Definition CSGCell.C:48
std::string _fill_name
name of the fill object for CSG_MATERIAL fills
Definition CSGCell.h:190
MooseEnum _fill_type
An enum for type of fill for cell region.
Definition CSGCell.h:187
CSGEngUnit is the abstract base class for all "engineering unit" types in the CSG system.
Definition CSGEngUnit.h:33
CSGLattice is the abstract class for defining lattices.
Definition CSGLattice.h:35
const std::string & getName() const
Get the name of lattice.
Definition CSGLattice.h:60
CSGRegions creates an internal representation of a CSG region, which can refer to an intersection,...
Definition CSGRegion.h:23
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:275
const std::vector< std::pair< TransformationType, std::tuple< Real, Real, Real > > > & getTransformations() const
Get the list of transformations.
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
void checkValidCSGName(const std::string &name)
Check name of CSG component for disallowed characters and symbols.
Definition CSGUtils.C:36