Line data Source code
1 : #ifndef CRPROPA_BOUNDARY_H
2 : #define CRPROPA_BOUNDARY_H
3 :
4 : #include "crpropa/Module.h"
5 :
6 : namespace crpropa {
7 : /**
8 : * \addtogroup Condition
9 : * @{
10 : */
11 :
12 : /**
13 : @class PeriodicBox
14 : @brief Rectangular box with periodic boundaries.
15 :
16 : If a particle passes on of the sides it is placed at the opposite side and its initial (source) position changed accordingly.
17 : This implements periodic boundaries, that keep the particle inside the box and instead move the source away periodically.
18 : Particles can overshoot (be outside of the box during the step) since the step size is not limited by this module.
19 : */
20 2 : class PeriodicBox: public Module {
21 : private:
22 : Vector3d origin;
23 : Vector3d size;
24 :
25 : public:
26 : /** Default constructor
27 : */
28 : PeriodicBox();
29 : /** Constructor
30 : @param origin vector corresponding to the lower box corner
31 : @param size vector corresponding to the box sizes along each direction
32 : */
33 : PeriodicBox(Vector3d origin, Vector3d size);
34 : void process(Candidate *candidate) const;
35 : void setOrigin(Vector3d origin);
36 : void setSize(Vector3d size);
37 : std::string getDescription() const;
38 : };
39 :
40 : /**
41 : @class ReflectiveShell
42 : @brief Shell with reflective boundary
43 :
44 : If a particle crosses the boundary it is reflected back inside or outside (position and velocity) depending where it came from.
45 : Particles can overshoot (be outside of the box during the step) since the step size is not limited by this module.
46 : */
47 1 : class ReflectiveShell: public Module {
48 : private:
49 : Vector3d center;
50 : double radius;
51 :
52 : public:
53 : /** Constructor
54 : @param center vector corresponding to the center of the sphere
55 : @param r value corresponding to the radius of the shell
56 : */
57 : ReflectiveShell(Vector3d center, double r);
58 : double distance(const Vector3d &point) const;
59 : Vector3d normal(const Vector3d &point) const;
60 : void process(Candidate *candidate) const;
61 : void setCenter(Vector3d center);
62 : void setRadius(double r);
63 : std::string getDescription() const;
64 : };
65 :
66 : /**
67 : @class ReflectiveBox
68 : @brief Rectangular box with reflective boundaries.
69 :
70 : If a particle passes on of the sides it is reflected back inside (position and velocity) and its initial position changed as if the particle had come from that side.
71 : This implements periodic boundaries, that keep the particle inside the box and instead move the source away reflectively.
72 : Particles can overshoot (be outside of the box during the step) since the step size is not limited by this module.
73 : */
74 1 : class ReflectiveBox: public Module {
75 : private:
76 : Vector3d origin;
77 : Vector3d size;
78 :
79 : public:
80 : /** Default constructor
81 : */
82 : ReflectiveBox();
83 : /** Constructor
84 : @param origin vector corresponding to the lower box corner
85 : @param size vector corresponding to the box sizes along each direction
86 : */
87 : ReflectiveBox(Vector3d origin, Vector3d size);
88 : void process(Candidate *candidate) const;
89 : void setOrigin(Vector3d origin);
90 : void setSize(Vector3d size);
91 : std::string getDescription() const;
92 : };
93 :
94 : /**
95 : @class CubicBoundary
96 : @brief Flags a particle when exiting the cube.
97 :
98 : The particle is made inactive and flagged as "Rejected".
99 : By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
100 : This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
101 : */
102 4 : class CubicBoundary: public AbstractCondition {
103 : private:
104 : Vector3d origin;
105 : double size;
106 : double margin;
107 : bool limitStep;
108 :
109 : public:
110 : /** Default constructor
111 : */
112 : CubicBoundary();
113 : /** Constructor
114 : @param origin vector corresponding to the lower box corner
115 : @param size vector corresponding to the box sizes along each direction
116 : */
117 : CubicBoundary(Vector3d origin, double size);
118 : void process(Candidate *candidate) const;
119 : void setOrigin(Vector3d origin);
120 : void setSize(double size);
121 : void setMargin(double margin);
122 : void setLimitStep(bool limitStep);
123 : std::string getDescription() const;
124 : };
125 :
126 : /**
127 : @class SphericalBoundary
128 : @brief Flag a particle when leaving the sphere.
129 :
130 : The particle is made inactive and flagged as "Rejected".
131 : By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
132 : This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
133 : */
134 3 : class SphericalBoundary: public AbstractCondition {
135 : private:
136 : Vector3d center;
137 : double radius;
138 : double margin;
139 : bool limitStep;
140 :
141 : public:
142 : /** Default constructor
143 : */
144 : SphericalBoundary();
145 : /** Constructor
146 : @param center vector containing the coordinates of the center of the sphere
147 : @param radius radius of the sphere
148 : */
149 : SphericalBoundary(Vector3d center, double radius);
150 : void process(Candidate *candidate) const;
151 : void setCenter(Vector3d center);
152 : void setRadius(double size);
153 : void setMargin(double margin);
154 : void setLimitStep(bool limitStep);
155 : std::string getDescription() const;
156 : };
157 :
158 : /**
159 : @class EllipsoidalBoundary
160 : @brief Flags a particle when leaving the ellipsoid.
161 :
162 : This module flags particles when outside of the ellipsoid, defined by two focal points and a major axis (length).
163 : The particle is made inactive and flagged as "Rejected".
164 : By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
165 : This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
166 : */
167 3 : class EllipsoidalBoundary: public AbstractCondition {
168 : private:
169 : Vector3d focalPoint1;
170 : Vector3d focalPoint2;
171 : double majorAxis;
172 : double margin;
173 : bool limitStep;
174 :
175 : public:
176 : /** Default constructor
177 : */
178 : EllipsoidalBoundary();
179 : /** Constructor
180 : @param focalPoint1 one of the foci of the ellipsoid
181 : @param focalPoint2 the other foci of the ellipsoid
182 : @param majorAxis length of the major axis of the ellipsoid
183 : */
184 : EllipsoidalBoundary(Vector3d focalPoint1, Vector3d focalPoint2,
185 : double majorAxis);
186 : void process(Candidate *candidate) const;
187 : void setFocalPoints(Vector3d focalPoint1, Vector3d focalPoint2);
188 : void setMajorAxis(double size);
189 : void setMargin(double margin);
190 : void setLimitStep(bool limitStep);
191 : std::string getDescription() const;
192 : };
193 :
194 :
195 : /**
196 : @class CylindricalBoundary
197 : @brief Flags a particle when leaving the cylinder whose axis is along the z-axis.
198 : This module flags particles when outside of the cylinder, defined by a radius and a height.
199 : The particle is made inactive and by default is flagged "OutOfBounds".
200 : Optionally the module can ensure the candidate does not overshoot the boundary by more than a set margin.
201 : */
202 3 : class CylindricalBoundary: public AbstractCondition {
203 : private:
204 : Vector3d origin;
205 : double height;
206 : double radius;
207 : double margin;
208 : bool limitStep;
209 :
210 : public:
211 : /** Default constructor
212 : */
213 : CylindricalBoundary();
214 : /** Constructor
215 : @param origin vector corresponding to the lower part of the cylinder axis
216 : @param height height of the cylinder
217 : @param radius radius of the cylinder
218 : */
219 : CylindricalBoundary(Vector3d origin, double height,
220 : double radius);
221 : void process(Candidate *candidate) const;
222 : void setOrigin(Vector3d origin);
223 : void setHeight(double height);
224 : void setRadius(double radius);
225 : void setMargin(double margin);
226 : void setLimitStep(bool limitStep);
227 : std::string getDescription() const;
228 : };
229 : /** @}*/
230 :
231 : } // namespace crpropa
232 :
233 : #endif // CRPROPA_BOUNDARY_H
|