An open source method of characteristics neutron transport code.
Cell.h
Go to the documentation of this file.
1 
9 #ifndef CELL_H_
10 #define CELL_H_
11 
12 #ifdef __cplusplus
13 #ifdef SWIG
14 #include "Python.h"
15 #endif
16 #include "Material.h"
17 #include "Region.h"
18 #include "Surface.h"
19 #include "Point.h"
20 #include <limits>
21 #include <string>
22 #endif
23 
24 /* Forward declarations to resolve circular dependencies */
25 class Universe;
26 class Surface;
27 class Region;
28 class Halfspace;
29 
30 int cell_id();
31 void reset_cell_id();
32 void maximize_cell_id(int cell_id);
33 
34 
39 enum cellType {
40 
43 
46 
49 };
50 
51 
56 class Cell {
57 
58 private:
59 
61  static int _n;
62 
64  int _uid;
65 
67  int _id;
68 
70  char* _name;
71 
73  cellType _cell_type;
74 
76  void* _fill;
77 
79  Region* _region;
80 
82  Region* _current_region;
83 
85  double _volume;
86 
88  int _num_instances;
89 
90  /* A boolean indicating whether to cell is rotated */
91  bool _rotated;
92 
93  /* An array with angles in degrees for rotations about x, y, and z */
94  double _rotation[3];
95 
96  /* A rotation matrix defined in terms of the rotation angles */
97  double _rotation_matrix[9];
98 
99  /* A boolean indicating whether to cell is translated */
100  bool _translated;
101 
102  /* An array with translations in x, y and z */
103  double _translation[3];
104 
106  int _num_rings;
107 
109  int _num_sectors;
110 
112  Cell* _parent;
113 
114  /* Vector of neighboring Cells */
115  std::vector<Cell*> _neighbors;
116 
117  void ringify(std::vector<Cell*>& subcells, double max_radius);
118  void sectorize(std::vector<Cell*>& subcells);
119 
120 public:
121  Cell(int id=0, const char* name="");
122  virtual ~Cell();
123  int getUid() const;
124  int getId() const;
125  char* getName() const;
126  cellType getType() const;
129  Region* getRegion();
130  double getVolume();
131  int getNumInstances();
132  bool isRotated();
133  bool isTranslated();
134  double getPhi(std::string units="degrees");
135  double getTheta(std::string units="degrees");
136  double getPsi(std::string units="degrees");
137  double* getRotationMatrix();
138  double* getTranslation();
139  void retrieveRotation(double* rotations, int num_axes,
140  std::string units="degrees");
141  void retrieveTranslation(double* translations, int num_axes);
142  int getNumRings();
143  int getNumSectors();
144  double getMinX();
145  double getMaxX();
146  double getMinY();
147  double getMaxY();
148  double getMinZ();
149  double getMaxZ();
156  int getNumSurfaces() const;
157  std::map<int, Halfspace*> getSurfaces() const;
158  std::vector<Cell*> getNeighbors() const;
159  bool hasParent();
160  Cell* getParent();
162 
163  int getNumZCylinders();
164 
165  std::map<int, Cell*> getAllCells();
166  std::map<int, Universe*> getAllUniverses();
167 
168  void setName(const char* name);
169  void setFill(Material* fill);
170  void setFill(Universe* fill);
171  void setRegion(Region* region);
172  void setVolume(double volume);
173  void incrementVolume(double volume);
174  void setNumInstances(int num_instances);
175  void incrementNumInstances();
176  void setRotation(double* rotation, int num_axes, std::string units="degrees");
177  void setTranslation(double* translation, int num_axes);
178  void setNumRings(int num_rings);
179  void setNumSectors(int num_sectors);
180  void setParent(Cell* parent);
181  void addSurface(int halfspace, Surface* surface);
182  void addSurfaceInRegion(int halfspace, Surface* surface);
183  void addLogicalNode(int region_type);
184  void goUpOneRegionLogical();
185  void removeSurface(Surface* surface);
186  void addNeighborCell(Cell* cell);
187 
188  bool isFissionable();
189  bool containsPoint(Point* point);
190  bool containsCoords(LocalCoords* coords);
191  double minSurfaceDist(Point* point, double azim, double polar);
192  double minSurfaceDist(LocalCoords* coords);
193 
194  Cell* clone(bool clone_region=true);
195  void subdivideCell(double max_radius);
196  void buildNeighbors();
197 
198  std::string toString();
199  void printString();
200 };
201 
202 
203 #endif /* CELL_H_ */
Material * getFillMaterial()
Return a pointer to the Material filling this Cell.
Definition: Cell.cpp:154
void setFill(Material *fill)
Sets the Material filling this Cell.
Definition: Cell.cpp:830
void setNumSectors(int num_sectors)
Set the Cell&#39;s number of sectors.
Definition: Cell.cpp:1021
double * getTranslation()
Return pointer to array for the translations along x, y and z.
Definition: Cell.cpp:332
Represents a Cell inside of a Universe.
Definition: Cell.h:56
The LocalCoords represents a set of local coordinates on some level of nested Universes making up the...
Definition: LocalCoords.h:46
int getUid() const
Return the Cell&#39;s unique ID.
Definition: Cell.cpp:118
double getPhi(std::string units="degrees")
Get the rotation angle about the x-axis in degrees.
Definition: Cell.cpp:228
int cell_id()
Returns an auto-generated unique Cell ID.
Definition: Cell.cpp:20
Definition: Cell.h:48
Region * getRegion()
Return the Cell&#39;s Region, its spatial domain.
Definition: Cell.cpp:178
double getMaxX()
Return the maximum reachable x-coordinate in the Cell.
Definition: Cell.cpp:409
Represents a general Surface in 3D.
Definition: Surface.h:70
void setTranslation(double *translation, int num_axes)
Set the Cell&#39;s translation along the x, y and z axes.
Definition: Cell.cpp:983
Cell * getParent()
Return this Cell&#39;s parent Cell.
Definition: Cell.cpp:725
double getMaxY()
Return the maximum reachable y-coordinate in the Cell.
Definition: Cell.cpp:461
boundaryType getMinXBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the minimum reachable x-coordinat...
Definition: Cell.cpp:540
boundaryType
The types of boundary conditions supported by OpenMOC for Surfaces.
Definition: boundary_type.h:15
void removeSurface(Surface *surface)
Removes a Surface from this Cell&#39;s container of bounding Surfaces.
Definition: Cell.cpp:1099
void addLogicalNode(int region_type)
Insert a logical node (intersection or union) into the cell region.
Definition: Cell.cpp:1117
int getNumInstances()
Return the number of instances of this Cell in the Geometry.
Definition: Cell.cpp:209
The Point class.
double getTheta(std::string units="degrees")
Get the rotation angle about the y-axis in degrees.
Definition: Cell.cpp:248
void incrementNumInstances()
Increment the number of instances of this Cell.
Definition: Cell.cpp:961
A Universe represents an unbounded space in 3D.
Definition: Universe.h:58
int getNumZCylinders()
Obtain and return the number of ZCylinders in the cell&#39;s surfaces.
Definition: Cell.cpp:1696
bool isFissionable()
Returns true if this Cell is filled with a fissionable Material.
Definition: Cell.cpp:1269
Cell(int id=0, const char *name="")
Constructor sets the unique and user-specifed IDs for this Cell.
Definition: Cell.cpp:59
void setName(const char *name)
Sets the name of the Cell.
Definition: Cell.cpp:811
boundaryType getMinYBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the minimum reachable y-coordinat...
Definition: Cell.cpp:586
void addSurface(int halfspace, Surface *surface)
Insert a Surface into this Cell&#39;s bounding Region, assuming that an intersection between the region a...
Definition: Cell.cpp:1052
double * getRotationMatrix()
Return pointer to array for the rotation matrix.
Definition: Cell.cpp:287
Definition: Cell.h:42
Class to represent a 2D/3D point in space.
Definition: Point.h:24
Cell * clone(bool clone_region=true)
Create a duplicate of the Cell.
Definition: Cell.cpp:1284
void printString()
Prints a string representation of all of the Cell&#39;s attributes to the console.
Definition: Cell.cpp:1687
bool isRotated()
Return a boolean indicating whether the Cell has been rotated.
Definition: Cell.cpp:198
A region of space that can be assigned to a Cell.
Definition: Region.h:43
std::map< int, Cell * > getAllCells()
Returns the std::map of Cell IDs and Cell pointers within any nested Universes filling this Cell...
Definition: Cell.cpp:762
boundaryType getMinZBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the minimum reachable z-coordinat...
Definition: Cell.cpp:632
cellType getType() const
Return the Cell type (FILL or MATERIAL).
Definition: Cell.cpp:145
void addNeighborCell(Cell *cell)
Add a neighboring Cell to this Cell&#39;s collection of neighbors.
Definition: Cell.cpp:1171
void setParent(Cell *parent)
Assign a parent Cell to this Cell.
Definition: Cell.cpp:1041
Cell * getOldestAncestor()
Get the oldest ancestor Cell for this Cell.
Definition: Cell.cpp:738
char * getName() const
Return the user-defined name of the Cell.
Definition: Cell.cpp:136
void retrieveRotation(double *rotations, int num_axes, std::string units="degrees")
Fills an array with the rotation angles for x, y and z.
Definition: Cell.cpp:307
void reset_cell_id()
Resets the auto-generated unique Cell ID counter to 1,000,000.
Definition: Cell.cpp:34
std::string toString()
Convert this Cell&#39;s attributes to a string format.
Definition: Cell.cpp:1640
bool hasParent()
Return true if the Cell has a parent and false otherwise.
Definition: Cell.cpp:711
void setVolume(double volume)
Set the volume/area of the Cell.
Definition: Cell.cpp:862
Universe * getFillUniverse()
Return a pointer to the Material filling this Cell.
Definition: Cell.cpp:166
int getNumRings()
Return the number of rings in the Cell.
Definition: Cell.cpp:365
virtual ~Cell()
Destructor clears vector of Surface pointers bounding the Cell.
Definition: Cell.cpp:101
void setRotation(double *rotation, int num_axes, std::string units="degrees")
Set the Cell&#39;s rotation angles about the x, y and z axes.
Definition: Cell.cpp:906
bool containsCoords(LocalCoords *coords)
Determines whether a Point is contained inside a Cell.
Definition: Cell.cpp:1218
void maximize_cell_id(int cell_id)
Maximize the auto-generated unique Cell ID counter.
Definition: Cell.cpp:48
double getMinY()
Return the minimum reachable y-coordinate in the Cell.
Definition: Cell.cpp:435
boundaryType getMaxYBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the maximum reachable y-coordinat...
Definition: Cell.cpp:609
int getId() const
Return the Cell&#39;s user-specified ID.
Definition: Cell.cpp:127
double minSurfaceDist(Point *point, double azim, double polar)
Computes the minimum distance to a Surface from a Point with a given trajectory at a certain angle...
Definition: Cell.cpp:1252
bool isTranslated()
Return a boolean indicating whether the Cell has been translated.
Definition: Cell.cpp:218
The Material class represents a unique material and its relevant nuclear data (i.e., multigroup cross-sections) for neutron transport.
Definition: Material.h:51
bool containsPoint(Point *point)
Determines whether a Point is contained inside a Cell.
Definition: Cell.cpp:1187
boundaryType getMaxZBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the maximum reachable z-coordinat...
Definition: Cell.cpp:655
The Region class.
void goUpOneRegionLogical()
Climb up the logical tree of regions.
Definition: Cell.cpp:1162
double getMinX()
Return the minimum reachable x-coordinate in the Cell.
Definition: Cell.cpp:383
void buildNeighbors()
Build a collection of neighboring Cells for optimized ray tracing.
Definition: Cell.cpp:1611
Definition: Cell.h:45
double getVolume()
Return the aggregate volume/area of all instances of this Cell.
Definition: Cell.cpp:189
double getMinZ()
Return the minimum reachable z-coordinate in the Cell.
Definition: Cell.cpp:487
void setNumInstances(int num_instances)
Set the number of instances of this Cell.
Definition: Cell.cpp:882
void setNumRings(int num_rings)
Set the Cell&#39;s number of rings.
Definition: Cell.cpp:1005
void addSurfaceInRegion(int halfspace, Surface *surface)
Insert a Surface into this Cell&#39;s bounding Region.
Definition: Cell.cpp:1081
boundaryType getMaxXBoundaryType()
Return the boundary condition (REFLECTIVE, VACUUM, or INTERFACE) at the maximum reachable x-coordinat...
Definition: Cell.cpp:563
void subdivideCell(double max_radius)
Subdivides a Cell into rings and sectors aligned with the z-axis.
Definition: Cell.cpp:1583
void incrementVolume(double volume)
Increment the volume/area of the Cell by some amount.
Definition: Cell.cpp:873
void retrieveTranslation(double *translations, int num_axes)
Fills an array with the translations along x, y and z.
Definition: Cell.cpp:351
int getNumSectors()
Return the number of sectors in the Cell.
Definition: Cell.cpp:374
A positive or negative halfspace Region.
Definition: Region.h:129
double getPsi(std::string units="degrees")
Get the rotation angle about the z-axis in degrees.
Definition: Cell.cpp:268
std::map< int, Halfspace * > getSurfaces() const
Return the std::map of Halfspace object pointers for all surfaces within the Region bounding the Cell...
Definition: Cell.cpp:690
std::vector< Cell * > getNeighbors() const
Return the std::vector of neighbor Cells to this Cell.
Definition: Cell.cpp:702
std::map< int, Universe * > getAllUniverses()
Returns the std::map of all nested Universe IDs and Universe pointers filling this Cell...
Definition: Cell.cpp:787
cellType
The type of cell.
Definition: Cell.h:39
void setRegion(Region *region)
Sets the Region this Cell lives in.
Definition: Cell.cpp:853
int getNumSurfaces() const
Return the number of Surfaces in the Cell.
Definition: Cell.cpp:677
double getMaxZ()
Return the maximum reachable z-coordinate in the Cell.
Definition: Cell.cpp:513