A monte carlo pin cell spectral code for nuclear engineering applications.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
Surface.h
Go to the documentation of this file.
1 
8 #ifndef SURFACE_H_
9 #define SURFACE_H_
10 
11 #include <limits>
12 #include <math.h>
13 #include "log.h"
14 #include "vector.h"
15 #include "Neutron.h"
16 
18 #define PI_OVER_TWO 1.57079633
19 
20 #define THREE_PI_OVER_TWO 4.71238898
21 
22 #define TWO_PI 6.28318531
23 
24 #define TINY_MOVE 1E-5
25 
26 
36 typedef enum surfaceTypes {
43 } surfaceType;
44 
45 
55 typedef enum boundaryTypes {
62 } boundaryType;
63 
64 
73 class Surface {
74 protected:
78  static int _n;
80  int _uid;
85 public:
86  Surface(const char* surface_name=(char*)"");
87  virtual ~Surface();
88 
89  char* getSurfaceName();
90  int getUid() const;
93 
94  void setBoundaryType(boundaryType type);
95 
102  virtual float evaluate(neutron* neutron) =0;
103 
112  virtual float evaluate(float x, float y, float z) =0;
113 
121  virtual float computeParametrizedDistance(neutron* neutron) =0;
122 
130  virtual bool onSurface(neutron* neutron) =0;
131 
139  virtual void reflectNeutron(neutron* neutron) =0;
140 };
141 
142 
149 class XPlane: public Surface {
150 private:
152  float _x;
153 public:
154  XPlane(const char* surface_name=(char*)"");
155  virtual ~XPlane();
156  float getX();
157  void setX(float x);
158  float evaluate(neutron* neutron);
159  float evaluate(float x, float y, float z);
161  bool onSurface(neutron* neutron);
163 };
164 
165 
172 class YPlane: public Surface {
173 private:
175  float _y;
176 public:
177  YPlane(const char* surface_name=(char*)"");
178  virtual ~YPlane();
179  float getY();
180  void setY(float y);
181  float evaluate(neutron* neutron);
182  float evaluate(float x, float y, float z);
184  bool onSurface(neutron* neutron);
186 };
187 
188 
195 class ZCylinder: public Surface {
196 protected:
198  float _r;
200  float _r_squared;
202  float _x0;
204  float _y0;
205 public:
206  ZCylinder(const char* surface_name=(char*)"");
207  virtual ~ZCylinder();
208  float getX0();
209  float getY0();
210  float getRadius();
211  void setX0(float x0);
212  void setY0(float y0);
213  void setRadius(float r);
214  float evaluate(neutron* neutron);
215  float evaluate(float x, float y, float z);
217  bool onSurface(neutron* neutron);
219 };
220 
221 #endif /* SURFACE_H_ */
The neutron C structure.
virtual float evaluate(neutron *neutron)=0
Returns the evaluation of a neutron's coordinates with respect to a quadratic surface ...
float _r_squared
Definition: Surface.h:200
Represents a neutron in a PINSPEC simulation.
Definition: Neutron.h:27
surfaceType _surface_type
Definition: Surface.h:82
void setY0(float y0)
Sets the y-coordinate of the cylinder's center.
Definition: Surface.cpp:385
float computeParametrizedDistance(neutron *neutron)
Computes the parametrized distance to the XPlane along a neutron's trajectory.
Definition: Surface.cpp:155
void setY(float y)
Sets the x-coordinate of the plane's intersection point with the y-axis.
Definition: Surface.cpp:234
Definition: Surface.h:40
YPlane(const char *surface_name=(char *)"")
The YPlane constructor.
Definition: Surface.cpp:207
surfaceType getSurfaceType() const
Returns this surface's type (XPLANE, YPLANE, CIRCLE, etc.)
Definition: Surface.cpp:47
surfaceTypes
Bounding surface types.
Definition: Surface.h:36
virtual ~Surface()
Surface destructor.
Definition: Surface.cpp:22
virtual ~YPlane()
YPlane destructor.
Definition: Surface.cpp:215
The Surface represents a quadratic surface in the xy-plane.
Definition: Surface.h:73
void reflectNeutron(neutron *neutron)
Perfectly reflects a neutron at a cylinder.
Definition: Surface.cpp:519
bool onSurface(neutron *neutron)
Checks whether a neutron is on the YPlane.
Definition: Surface.cpp:303
float _y
Definition: Surface.h:175
char * _surface_name
Definition: Surface.h:76
float getY0()
Returns the y-coordinate of the cylinder's center.
Definition: Surface.cpp:358
enum surfaceTypes surfaceType
Bounding surface type.
virtual ~XPlane()
XPlane destructor.
Definition: Surface.cpp:91
void setX0(float x0)
Sets the x-coordinate of the cylinder's center.
Definition: Surface.cpp:376
void setX(float x)
Sets the x-coordinate of the plane's intersection point with the x-axis.
Definition: Surface.cpp:109
void reflectNeutron(neutron *neutron)
Perfectly reflects a neutron at a xplane.
Definition: Surface.cpp:191
The YPlane is a a plane perpendicular to the y-axis.
Definition: Surface.h:172
float evaluate(neutron *neutron)
Returns the evaluation of a neutron's coordinates with respect to the quadratic surface representing...
Definition: Surface.cpp:406
virtual bool onSurface(neutron *neutron)=0
Determines whether or not a neutron at some location is on the surface.
virtual void reflectNeutron(neutron *neutron)=0
Perfectly reflects a neutron at the surface for REFLECTIVE boundary conditions.
bool onSurface(neutron *neutron)
Checks whether a neutron is on the XPlane.
Definition: Surface.cpp:179
virtual ~ZCylinder()
ZCylinder destructor.
Definition: Surface.cpp:342
char * getSurfaceName()
Return the name of the surface.
Definition: Surface.cpp:29
float getX0()
Returns the x-coordinate of the cylinder's center.
Definition: Surface.cpp:349
void reflectNeutron(neutron *neutron)
Perfectly reflects a neutron at a yplane.
Definition: Surface.cpp:316
float computeParametrizedDistance(neutron *neutron)
Computes the parametrized distance to the YPlane along a neutron's trajectory.
Definition: Surface.cpp:279
boundaryType _boundary_type
Definition: Surface.h:84
Definition: Surface.h:61
Definition: Surface.h:38
int _uid
Definition: Surface.h:80
The ZCylinder is the locus of a point equidistant from a fixed point.
Definition: Surface.h:195
void setBoundaryType(boundaryType type)
Sets the boundary type for this Surface.
Definition: Surface.cpp:69
float _x
Definition: Surface.h:152
int getUid() const
Returns the unique ID auto-generated for the surface.
Definition: Surface.cpp:38
boundaryTypes
Boundary condition types.
Definition: Surface.h:55
bool onSurface(neutron *neutron)
Checks whether a neutron is on the ZCylinder.
Definition: Surface.cpp:503
float _r
Definition: Surface.h:198
float getRadius()
Returns the radius of the cylinder.
Definition: Surface.cpp:367
XPlane(const char *surface_name=(char *)"")
The XPlane constructor.
Definition: Surface.cpp:83
virtual float computeParametrizedDistance(neutron *neutron)=0
Computes the parametrized distance between a neutron at some location with some trajectory and this s...
Utility functions for commonly used vector operations.
Definition: Surface.h:57
float evaluate(neutron *neutron)
Returns the evaluation of a neutron's coordinates with respect to the quadratic surface representing...
Definition: Surface.cpp:120
float getX()
Returns the x-coordinate of the plane's intersection point with the x-axis.
Definition: Surface.cpp:99
ZCylinder(const char *surface_name=(char *)"")
The ZCylinder constructor.
Definition: Surface.cpp:331
float _x0
Definition: Surface.h:202
The XPlane is a plane perpendicular to the y-axis.
Definition: Surface.h:149
Definition: Surface.h:42
Definition: Surface.h:59
Surface(const char *surface_name=(char *)"")
Surface class constructor.
Definition: Surface.cpp:11
boundaryType getBoundaryType() const
Returns this surface's boundary type.
Definition: Surface.cpp:58
Utility functions for writing log messages to the screen.
float computeParametrizedDistance(neutron *neutron)
Computes the parametrized distance to the ZCylinder along a neutron's trajectory. ...
Definition: Surface.cpp:439
void setRadius(float r)
Sets the radius of the cylinder's center.
Definition: Surface.cpp:394
float _y0
Definition: Surface.h:204
enum boundaryTypes boundaryType
Boundary condition type.
static int _n
Definition: Surface.h:78
float evaluate(neutron *neutron)
Returns the evaluation of a neutron's coordinates with respect to the quadratic surface representing...
Definition: Surface.cpp:245
float getY()
Returns the y-coordinate of the plane's intersection point with the y-axis.
Definition: Surface.cpp:224