An open source method of characteristics neutron transport code.
Surface.h
Go to the documentation of this file.
1 
9 #ifndef SURFACE_H_
10 #define SURFACE_H_
11 
12 #ifdef __cplusplus
13 #ifdef SWIG
14 #include "Python.h"
15 #endif
16 #include "constants.h"
17 #include "LocalCoords.h"
18 #include "boundary_type.h"
19 #include <limits>
20 #include <map>
21 #include <vector>
22 #include <algorithm>
23 #endif
24 
25 
26 /* Forward declarations to resolve circular dependencies */
27 class LocalCoords;
28 class Cell;
29 
30 
31 int surface_id();
32 void reset_surface_id();
34 
35 
43 
46 
49 
52 
55 
58 };
59 
60 
61 
70 class Surface {
71 
72 protected:
73 
75  static int _n;
76 
78  int _uid;
79 
81  int _id;
82 
84  char* _name;
85 
88 
92 
93  /* Vector of neighboring Cells */
94  std::map<int, std::vector<Cell*>* > _neighbors;
95 
96 public:
97  Surface(const int id=0, const char* name="");
98  virtual ~Surface();
99 
100  int getUid() const;
101  int getId() const;
102  char* getName() const;
105 
106 
114  double getMin(int axis, int halfspace);
115 
116 
124  double getMax(int axis, int halfspace);
125 
131  virtual double getMinX(int halfspace) = 0;
132 
138  virtual double getMaxX(int halfspace) = 0;
139 
145  virtual double getMinY(int halfspace) = 0;
146 
152  virtual double getMaxY(int halfspace) = 0;
153 
159  virtual double getMinZ(int halfspace) = 0;
160 
166  virtual double getMaxZ(int halfspace) = 0;
167 
168  void setName(const char* name);
169  void setBoundaryType(const boundaryType boundary_type);
170  void addNeighborCell(int halfspace, Cell* cell);
171 
179  virtual double evaluate(const Point* point) const = 0;
180 
190  virtual int intersection(Point* point, double azim, double polar,
191  Point* points) = 0;
192 
193  bool isPointOnSurface(Point* point);
194  bool isCoordOnSurface(LocalCoords* coord);
195  double getMinDistance(Point* point, double azim, double polar);
196  double getMinDistance(LocalCoords* coord);
197 
204  virtual std::string toString() = 0;
205 
206  void printString();
207 };
208 
209 
214 class Plane: public Surface {
215 
216 protected:
217 
219  double _A;
220 
222  double _B;
223 
225  double _C;
226 
228  double _D;
229 
231  friend class Surface;
232 
234  friend class ZCylinder;
235 
236 public:
237 
238  Plane(const double A, const double B, const double C, const double D,
239  const int id=0, const char* name="");
240 
241  double getMinX(int halfspace);
242  double getMaxX(int halfspace);
243  double getMinY(int halfspace);
244  double getMaxY(int halfspace);
245  double getMinZ(int halfspace);
246  double getMaxZ(int halfspace);
247  double getA();
248  double getB();
249  double getC();
250  double getD();
251 
252  double evaluate(const Point* point) const;
253  int intersection(Point* point, double azim, double polar, Point* points);
254 
255  std::string toString();
256 };
257 
258 
263 class XPlane: public Plane {
264 
265 private:
266 
268  double _x;
269 
270 public:
271  XPlane(const double x, const int id=0, const char* name="");
272 
273  void setX(const double x);
274 
275  double getX();
276  double getMinX(int halfspace);
277  double getMaxX(int halfspace);
278 
279  std::string toString();
280 };
281 
282 
287 class YPlane: public Plane {
288 
289 private:
290 
292  double _y;
293 
294 public:
295  YPlane(const double y, const int id=0, const char* name="");
296 
297  void setY(const double y);
298 
299  double getY();
300  double getMinY(int halfspace);
301  double getMaxY(int halfspace);
302 
303  std::string toString();
304 };
305 
306 
311 class ZPlane: public Plane {
312 
313 private:
314 
316  double _z;
317 
318 public:
319  ZPlane(const double z, const int id=0, const char* name="");
320 
321  void setZ(const double z);
322 
323  double getZ();
324  double getMinZ(int halfspace);
325  double getMaxZ(int halfspace);
326 
327  std::string toString();
328 };
329 
330 
335 class ZCylinder: public Surface {
336 
337 private:
338 
340  Point _center;
341 
343  double _radius;
344 
346  double _A;
347 
349  double _B;
350 
352  double _C;
353 
355  double _D;
356 
358  double _E;
359 
361  friend class Surface;
362 
364  friend class Plane;
365 
366 public:
367  ZCylinder(const double x, const double y, const double radius,
368  const int id=0, const char* name="");
369 
370  double getX0();
371  double getY0();
372  double getRadius();
373  double getMinX(int halfspace);
374  double getMaxX(int halfspace);
375  double getMinY(int halfspace);
376  double getMaxY(int halfspace);
377  double getMinZ(int halfspace);
378  double getMaxZ(int halfspace);
379 
380  double evaluate(const Point* point) const;
381  int intersection(Point* point, double azim, double polar, Point* points);
382 
383  std::string toString();
384 };
385 
386 
397 inline double Surface::getMinDistance(Point* point, double azim, double polar) {
398 
399  /* Point array for intersections with this Surface */
400  Point intersections[2];
401 
402  /* Find the intersection Point(s) */
403  int num_inters = intersection(point, azim, polar, intersections);
404  double distance = INFINITY;
405 
406  /* If there is one intersection Point */
407  if (num_inters == 1)
408  distance = intersections[0].distanceToPoint(point);
409 
410  /* If there are two intersection Points */
411  else if (num_inters == 2) {
412  double dist1 = intersections[0].distanceToPoint(point);
413  double dist2 = intersections[1].distanceToPoint(point);
414 
415  /* Determine which intersection Point is nearest */
416  if (dist1 < dist2)
417  distance = dist1;
418  else
419  distance = dist2;
420  }
421 
422  return distance;
423 }
424 
425 
431 inline double Plane::evaluate(const Point* point) const {
432  double x = point->getX();
433  double y = point->getY();
434  double z = point->getZ();
435 
436  return (_A * x + _B * y + _C * z + _D);
437 }
438 
439 
444 inline double ZCylinder::getRadius() {
445  return this->_radius;
446 }
447 
448 
454 inline double ZCylinder::evaluate(const Point* point) const {
455  double x = point->getX();
456  double y = point->getY();
457  return (_A * x * x + _B * y * y + _C * x + _D * y + _E);
458 }
459 
460 
461 #endif /* SURFACE_H_ */
double getMaxY(int halfspace)
Returns the maximum y value for one of this ZCylinder&#39;s halfspaces.
Definition: Surface.cpp:836
int surface_id()
Returns an auto-generated unique surface ID.
Definition: Surface.cpp:16
double _A
Definition: Surface.h:219
double getMaxX(int halfspace)
Returns the maximum x value for one of this XPlane&#39;s halfspaces.
Definition: Surface.cpp:556
surfaceType _surface_type
Definition: Surface.h:87
void setName(const char *name)
Sets the name of the Surface.
Definition: Surface.cpp:187
int intersection(Point *point, double azim, double polar, Point *points)
Finds the intersection Point with this Plane from a given Point and trajectory defined by an azim/pol...
Definition: Surface.cpp:450
Represents a Cell inside of a Universe.
Definition: Cell.h:56
double getMinX(int halfspace)
Returns the minimum x value for one of this ZCylinder&#39;s halfspaces.
Definition: Surface.cpp:797
double getB()
Returns the B coefficient multiplying y in the surface equation.
Definition: Surface.cpp:418
The LocalCoords represents a set of local coordinates on some level of nested Universes making up the...
Definition: LocalCoords.h:46
int _id
Definition: Surface.h:81
double getX()
Returns the location of the XPlane on the x-axis.
Definition: Surface.cpp:533
int getUid() const
Return the Surface&#39;s unique ID.
Definition: Surface.cpp:99
double getMinY(int halfspace)
Returns the minimum y value of -INFINITY.
Definition: Surface.cpp:370
ZCylinder(const double x, const double y, const double radius, const int id=0, const char *name="")
Constructor.
Definition: Surface.cpp:758
virtual double getMaxY(int halfspace)=0
Returns the maximum y value for one of this Surface&#39;s halfspaces.
surfaceType getSurfaceType()
Return the type of Surface (ie, XPLANE, ZYCLINDER, etc).
Definition: Surface.cpp:126
double getD()
Returns the D constant coefficient.
Definition: Surface.cpp:436
virtual ~Surface()
Destructor.
Definition: Surface.cpp:80
double getY() const
Returns this Point&#39;s y-coordinate.
Definition: Point.h:76
Represents a general Surface in 3D.
Definition: Surface.h:70
void maximize_surface_id(int surface_id)
Maximize the auto-generated unique Surface ID counter.
Definition: Surface.cpp:40
double getZ()
Returns the location of the ZPlane on the z-axis.
Definition: Surface.cpp:696
char * getName() const
Return the user-defined name of the Surface.
Definition: Surface.cpp:117
boundaryType
The types of boundary conditions supported by OpenMOC for Surfaces.
Definition: boundary_type.h:15
Math constants and comparision tolerances.
Definition: Surface.h:48
surfaceType
The types of surfaces supported by OpenMOC.
Definition: Surface.h:40
void setX(const double x)
Set the location of this XPlane on the x-axis.
Definition: Surface.cpp:523
std::string toString()
Converts this ZPlane&#39;s attributes to a character array.
Definition: Surface.cpp:735
Definition: Surface.h:45
double getMinY(int halfspace)
Returns the minimum y value for one of this YPlane&#39;s halfspaces.
Definition: Surface.cpp:625
double getMaxY(int halfspace)
Returns the maximum y value for one of this YPlane&#39;s halfspaces.
Definition: Surface.cpp:638
Represents a Plane perpendicular to the y-axis.
Definition: Surface.h:287
Class to represent a 2D/3D point in space.
Definition: Point.h:24
Represents a Plane perpendicular to the xy-plane.
Definition: Surface.h:214
std::string toString()
Converts this XPlane&#39;s attributes to a character array.
Definition: Surface.cpp:572
virtual std::string toString()=0
Converts this Surface&#39;s attributes to a character array.
std::string toString()
Converts this YPlane&#39;s attributes to a character array.
Definition: Surface.cpp:653
Definition: Surface.h:42
double getA()
Returns the A coefficient multiplying x in the surface equation.
Definition: Surface.cpp:409
virtual double getMaxZ(int halfspace)=0
Returns the maximum z value for one of this Surface&#39;s halfspaces.
double evaluate(const Point *point) const
Evaluate a Point using the ZCylinder&#39;s quadratic Surface equation.
Definition: Surface.h:454
virtual double getMaxX(int halfspace)=0
Returns the maximum x value for one of this Surface&#39;s halfspaces.
Definition: Surface.h:54
double getMaxZ(int halfspace)
Returns the maximum z value for one of this ZPlane&#39;s halfspaces.
Definition: Surface.cpp:719
double getMinDistance(Point *point, double azim, double polar)
Finds the minimum distance to a Surface.
Definition: Surface.h:397
double getX() const
Returns this Point&#39;s x-coordinate.
Definition: Point.h:67
double evaluate(const Point *point) const
Evaluate a Point using the Plane&#39;s quadratic Surface equation.
Definition: Surface.h:431
double getMaxY(int halfspace)
Returns the maximum y value of INFINITY.
Definition: Surface.cpp:380
char * _name
Definition: Surface.h:84
void setZ(const double z)
Set the location of this ZPlane on the z-axis.
Definition: Surface.cpp:686
boundaryType _boundary_type
Definition: Surface.h:91
double _C
Definition: Surface.h:225
double getMinZ(int halfspace)
Returns the minimum z value for one of this ZPlane&#39;s halfspaces.
Definition: Surface.cpp:706
int _uid
Definition: Surface.h:78
std::string toString()
Converts this Plane&#39;s attributes to a character array.
Definition: Surface.cpp:492
Represents a Cylinder with axis parallel to the z-axis.
Definition: Surface.h:335
double getMaxZ(int halfspace)
Returns the maximum z value of INFINITY.
Definition: Surface.cpp:859
void reset_surface_id()
Resets the auto-generated unique Surface ID counter to 1,000,000.
Definition: Surface.cpp:26
double getC()
Returns the C coefficient multiplying z in the surface equation.
Definition: Surface.cpp:427
double getMinZ(int halfspace)
Returns the minimum z value of -INFINITY.
Definition: Surface.cpp:390
void setY(const double y)
Set the location of this YPlane on the y-axis.
Definition: Surface.cpp:605
double getMinZ(int halfspace)
Returns the minimum z value of -INFINITY.
Definition: Surface.cpp:849
boundaryType getBoundaryType()
Returns the type of boundary conditions for this Surface (REFLECTIVE, VACUUM or BOUNDARY_NONE).
Definition: Surface.cpp:136
double getMaxX(int halfspace)
Returns the maximum x value of INFINITY.
Definition: Surface.cpp:360
ZPlane(const double z, const int id=0, const char *name="")
Constructor for a Plane perpendicular to the z-axis.
Definition: Surface.cpp:674
double _D
Definition: Surface.h:228
Plane(const double A, const double B, const double C, const double D, const int id=0, const char *name="")
Constructor.
Definition: Surface.cpp:333
int getId() const
Return the Surface&#39;s user-defined ID.
Definition: Surface.cpp:108
double distanceToPoint(const Point *point)
Compute the distance from this Point to another Point of interest.
Definition: Point.h:157
void setBoundaryType(const boundaryType boundary_type)
Sets the boundary condition type (ie, VACUUM or REFLECTIVE) for this Surface.
Definition: Surface.cpp:207
std::string toString()
Converts this ZCylinder&#39;s attributes to a character array.
Definition: Surface.cpp:1100
virtual double getMinY(int halfspace)=0
Returns the minimum y value for one of this Surface&#39;s halfspaces.
double getZ() const
Returns this Point&#39;s z-coordinate.
Definition: Point.h:85
virtual double getMinZ(int halfspace)=0
Returns the minimum z value for one of this Surface&#39;s halfspaces.
virtual double evaluate(const Point *point) const =0
Evaluate a Point using the Surface&#39;s potential equation.
XPlane(const double x, const int id=0, const char *name="")
Constructor for a Plane perpendicular to the x-axis.
Definition: Surface.cpp:511
double getY0()
Return the y-coordinate of the ZCylinder&#39;s center Point.
Definition: Surface.cpp:787
YPlane(const double y, const int id=0, const char *name="")
Constructor for a Plane perpendicular to the y-axis.
Definition: Surface.cpp:593
virtual double getMinX(int halfspace)=0
Returns the minimum x value for one of this Surface&#39;s halfspaces.
double getMinY(int halfspace)
Returns the minimum y value for one of this ZCylinder&#39;s halfspaces.
Definition: Surface.cpp:823
Represents a Plane perpendicular to the z-axis.
Definition: Surface.h:311
double getMinX(int halfspace)
Returns the minimum x value of -INFINITY.
Definition: Surface.cpp:350
double getMaxX(int halfspace)
Returns the maximum x value for one of this ZCylinder&#39;s halfspaces.
Definition: Surface.cpp:810
virtual int intersection(Point *point, double azim, double polar, Point *points)=0
Finds the intersection Point with this Surface from a given Point and trajectory defined by an angle...
double getX0()
Return the x-coordinate of the ZCylinder&#39;s center Point.
Definition: Surface.cpp:778
Definition: Surface.h:51
Definition: Surface.h:57
Represents a Plane perpendicular to the x-axis.
Definition: Surface.h:263
double getMinX(int halfspace)
Returns the minimum x value for one of this XPlane&#39;s halfspaces.
Definition: Surface.cpp:543
int intersection(Point *point, double azim, double polar, Point *points)
Finds the intersection Point with this zcylinder from a given Point and trajectory defined by an azim...
Definition: Surface.cpp:873
double getY()
Returns the location of the YPlane on the y-axis.
Definition: Surface.cpp:615
double getMin(int axis, int halfspace)
Returns the minimum coordinate in the axis direction of the space defined by halfspace and this surfa...
Definition: Surface.cpp:148
double getMax(int axis, int halfspace)
Returns the maximum coordinate in the axis direction of the space defined by halfspace and this surfa...
Definition: Surface.cpp:169
bool isCoordOnSurface(LocalCoords *coord)
Return true or false if a LocalCoord is on or off of a Surface.
Definition: Surface.cpp:269
Surface(const int id=0, const char *name="")
Constructor assigns unique ID and user-defined ID for a Surface.
Definition: Surface.cpp:53
bool isPointOnSurface(Point *point)
Return true or false if a Point is on or off of a Surface.
Definition: Surface.cpp:254
The LocalCoords class.
void printString()
Prints a string representation of all of the Surface&#39;s objects to the console.
Definition: Surface.cpp:319
double _B
Definition: Surface.h:222
static int _n
Definition: Surface.h:75
double getMaxZ(int halfspace)
Returns the maximum z value of INFINITY.
Definition: Surface.cpp:400
void addNeighborCell(int halfspace, Cell *cell)
Adds a neighbor Cell to this Surface&#39;s collection of neighbors.
Definition: Surface.cpp:217
double getRadius()
Return the radius of the ZCylinder.
Definition: Surface.h:444