LCOV - code coverage report
Current view: top level - include/crpropa/module - Boundary.h (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 6 6 100.0 %
Date: 2024-04-29 14:43:01 Functions: 0 0 -

          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 ReflectiveBox
      42             :  @brief Rectangular box with reflective boundaries.
      43             : 
      44             :  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.
      45             :  This implements periodic boundaries, that keep the particle inside the box and instead move the source away reflectively.
      46             :  Particles can overshoot (be outside of the box during the step) since the step size is not limited by this module.
      47             :  */
      48           1 : class ReflectiveBox: public Module {
      49             : private:
      50             :         Vector3d origin;
      51             :         Vector3d size;
      52             : 
      53             : public:
      54             :         /** Default constructor
      55             :          */
      56             :         ReflectiveBox();
      57             :         /** Constructor
      58             :          @param origin  vector corresponding to the lower box corner
      59             :          @param size    vector corresponding to the box sizes along each direction
      60             :          */
      61             :         ReflectiveBox(Vector3d origin, Vector3d size);
      62             :         void process(Candidate *candidate) const;
      63             :         void setOrigin(Vector3d origin);
      64             :         void setSize(Vector3d size);
      65             :         std::string getDescription() const;
      66             : };
      67             : 
      68             : /**
      69             :  @class CubicBoundary
      70             :  @brief Flags a particle when exiting the cube.
      71             : 
      72             :  The particle is made inactive and flagged as "Rejected".
      73             :  By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
      74             :  This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
      75             :  */
      76           4 : class CubicBoundary: public AbstractCondition {
      77             : private:
      78             :         Vector3d origin;
      79             :         double size;
      80             :         double margin;
      81             :         bool limitStep;
      82             : 
      83             : public:
      84             :         /** Default constructor
      85             :          */
      86             :         CubicBoundary();
      87             :         /** Constructor
      88             :          @param origin  vector corresponding to the lower box corner
      89             :          @param size    vector corresponding to the box sizes along each direction
      90             :          */
      91             :         CubicBoundary(Vector3d origin, double size);
      92             :         void process(Candidate *candidate) const;
      93             :         void setOrigin(Vector3d origin);
      94             :         void setSize(double size);
      95             :         void setMargin(double margin);
      96             :         void setLimitStep(bool limitStep);
      97             :         std::string getDescription() const;
      98             : };
      99             : 
     100             : /**
     101             :  @class SphericalBoundary
     102             :  @brief Flag a particle when leaving the sphere.
     103             : 
     104             :  The particle is made inactive and flagged as "Rejected".
     105             :  By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
     106             :  This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
     107             :  */
     108           3 : class SphericalBoundary: public AbstractCondition {
     109             : private:
     110             :         Vector3d center;
     111             :         double radius;
     112             :         double margin;
     113             :         bool limitStep;
     114             : 
     115             : public:
     116             :         /** Default constructor
     117             :          */
     118             :         SphericalBoundary();
     119             :         /** Constructor
     120             :          @param center          vector containing the coordinates of the center of the sphere
     121             :          @param radius          radius of the sphere
     122             :          */
     123             :         SphericalBoundary(Vector3d center, double radius);
     124             :         void process(Candidate *candidate) const;
     125             :         void setCenter(Vector3d center);
     126             :         void setRadius(double size);
     127             :         void setMargin(double margin);
     128             :         void setLimitStep(bool limitStep);
     129             :         std::string getDescription() const;
     130             : };
     131             : 
     132             : /**
     133             :  @class EllipsoidalBoundary
     134             :  @brief Flags a particle when leaving the ellipsoid.
     135             : 
     136             :  This module flags particles when outside of the ellipsoid, defined by two focal points and a major axis (length).
     137             :  The particle is made inactive and flagged as "Rejected".
     138             :  By default the module prevents overshooting the boundary by more than a margin of 0.1 kpc.
     139             :  This corresponds to the default minimum step size of the propagation modules (PropagationCK and SimplePropagation).
     140             :  */
     141           3 : class EllipsoidalBoundary: public AbstractCondition {
     142             : private:
     143             :         Vector3d focalPoint1;
     144             :         Vector3d focalPoint2;
     145             :         double majorAxis;
     146             :         double margin;
     147             :         bool limitStep;
     148             : 
     149             : public:
     150             :         /** Default constructor
     151             :          */
     152             :         EllipsoidalBoundary();
     153             :         /** Constructor
     154             :          @param focalPoint1             one of the foci of the ellipsoid
     155             :          @param focalPoint2             the other foci of the ellipsoid
     156             :          @param majorAxis               length of the major axis of the ellipsoid
     157             :          */
     158             :         EllipsoidalBoundary(Vector3d focalPoint1, Vector3d focalPoint2,
     159             :                         double majorAxis);
     160             :         void process(Candidate *candidate) const;
     161             :         void setFocalPoints(Vector3d focalPoint1, Vector3d focalPoint2);
     162             :         void setMajorAxis(double size);
     163             :         void setMargin(double margin);
     164             :         void setLimitStep(bool limitStep);
     165             :         std::string getDescription() const;
     166             : };
     167             : 
     168             : 
     169             : /**
     170             :  @class CylindricalBoundary
     171             :  @brief Flags a particle when leaving the cylinder whose axis is along the z-axis.
     172             :  This module flags particles when outside of the cylinder, defined by a radius and a height.
     173             :  The particle is made inactive and by default is flagged "OutOfBounds".
     174             :  Optionally the module can ensure the candidate does not overshoot the boundary by more than a set margin.
     175             :  */
     176           3 : class CylindricalBoundary: public AbstractCondition {
     177             : private:
     178             :         Vector3d origin;
     179             :         double height;
     180             :         double radius;
     181             :         double margin;
     182             :         bool limitStep;
     183             : 
     184             : public:
     185             :         /** Default constructor
     186             :          */
     187             :         CylindricalBoundary();
     188             :         /** Constructor
     189             :          @param origin  vector corresponding to the lower part of the cylinder axis
     190             :          @param height  height of the cylinder
     191             :          @param radius  radius of the cylinder
     192             :          */
     193             :         CylindricalBoundary(Vector3d origin, double height,
     194             :                         double radius);
     195             :         void process(Candidate *candidate) const;
     196             :         void setOrigin(Vector3d origin);
     197             :         void setHeight(double height);
     198             :         void setRadius(double radius);
     199             :         void setMargin(double margin);
     200             :         void setLimitStep(bool limitStep);
     201             :         std::string getDescription() const;
     202             : };
     203             : /** @}*/
     204             : 
     205             : } // namespace crpropa
     206             : 
     207             : #endif // CRPROPA_BOUNDARY_H

Generated by: LCOV version 1.14