[83c09a] | 1 | /*
|
---|
| 2 | * Box.hpp
|
---|
| 3 | *
|
---|
| 4 | * Created on: Jun 30, 2010
|
---|
| 5 | * Author: crueger
|
---|
| 6 | */
|
---|
| 7 |
|
---|
| 8 | #ifndef BOX_HPP_
|
---|
| 9 | #define BOX_HPP_
|
---|
| 10 |
|
---|
[cca9ef] | 11 | class RealSpaceMatrix;
|
---|
[3dcb1f] | 12 | class Vector;
|
---|
[c538d1] | 13 | class Shape;
|
---|
[29ac78] | 14 | class Plane;
|
---|
[83c09a] | 15 |
|
---|
[89e820] | 16 | #include <list>
|
---|
[77374e] | 17 | #include <vector>
|
---|
[57f243] | 18 | #include "LinearAlgebra/VectorSet.hpp"
|
---|
[89e820] | 19 |
|
---|
[abd8f7] | 20 | /**
|
---|
| 21 | * A simple class that can be used to store periodic Boxes
|
---|
| 22 | * in the form of a parallelepiped.
|
---|
| 23 | *
|
---|
| 24 | * Stores a matrix that can be used to translate from periodic
|
---|
| 25 | * [0,1) space as well as the inverse that is needed to
|
---|
| 26 | * translate back to that space.
|
---|
| 27 | */
|
---|
[83c09a] | 28 | class Box
|
---|
| 29 | {
|
---|
| 30 | public:
|
---|
[77374e] | 31 | typedef enum{
|
---|
| 32 | Wrap,
|
---|
| 33 | Bounce,
|
---|
| 34 | Ignore
|
---|
| 35 | } BoundaryCondition_t;
|
---|
| 36 |
|
---|
| 37 | typedef vector<BoundaryCondition_t> Conditions_t;
|
---|
| 38 |
|
---|
[83c09a] | 39 | Box();
|
---|
[7579a4b] | 40 | Box(const Box&);
|
---|
[83c09a] | 41 | virtual ~Box();
|
---|
| 42 |
|
---|
[abd8f7] | 43 | /**
|
---|
| 44 | * Get the matrix describing the form of the parallelepiped
|
---|
| 45 | */
|
---|
[cca9ef] | 46 | const RealSpaceMatrix &getM() const;
|
---|
[abd8f7] | 47 |
|
---|
| 48 | /**
|
---|
| 49 | * Get the inverse of the matrix M (see above).
|
---|
| 50 | */
|
---|
[cca9ef] | 51 | const RealSpaceMatrix &getMinv() const;
|
---|
[abd8f7] | 52 |
|
---|
| 53 | /**
|
---|
| 54 | * Set the form of the parallelepiped.
|
---|
| 55 | */
|
---|
[cca9ef] | 56 | void setM(RealSpaceMatrix);
|
---|
[7579a4b] | 57 |
|
---|
| 58 | Box &operator=(const Box&);
|
---|
[cca9ef] | 59 | Box &operator=(const RealSpaceMatrix&);
|
---|
[7579a4b] | 60 |
|
---|
[abd8f7] | 61 | /**
|
---|
| 62 | * Translate a point from [0,1) to the boxed space.
|
---|
| 63 | */
|
---|
[014475] | 64 | Vector translateIn(const Vector &point) const;
|
---|
[abd8f7] | 65 |
|
---|
| 66 | /**
|
---|
| 67 | * Translate a point from the boxed space to the [0,1) space.
|
---|
| 68 | */
|
---|
[014475] | 69 | Vector translateOut(const Vector &point) const;
|
---|
[3dcb1f] | 70 |
|
---|
[abd8f7] | 71 | /**
|
---|
| 72 | * Wrap a point so that it will lie within the space defined by the box.
|
---|
| 73 | */
|
---|
[014475] | 74 | Vector WrapPeriodically(const Vector &point) const;
|
---|
[abd8f7] | 75 |
|
---|
[0ff6b5] | 76 | /**
|
---|
| 77 | * Checks whether a given vector is inside the box.
|
---|
| 78 | */
|
---|
| 79 | bool isInside(const Vector &point) const;
|
---|
| 80 |
|
---|
[abd8f7] | 81 | /**
|
---|
| 82 | * Produce corresponding points in several adjacent boxes.
|
---|
[a630fd] | 83 | *
|
---|
| 84 | * n specifies the number of times the point is expanded.
|
---|
| 85 | * Carefull, needs O(n^3) time and produces as many vectors.
|
---|
[abd8f7] | 86 | */
|
---|
[7ac4af] | 87 | VECTORSET(std::list) explode(const Vector &point,int n) const;
|
---|
| 88 | VECTORSET(std::list) explode(const Vector &point) const;
|
---|
[527de2] | 89 |
|
---|
[abd8f7] | 90 | /**
|
---|
| 91 | * Calculate the distance of two points in the periodic space
|
---|
| 92 | * defined by this box
|
---|
| 93 | */
|
---|
[014475] | 94 | double periodicDistanceSquared(const Vector &point1,const Vector &point2) const;
|
---|
[abd8f7] | 95 |
|
---|
| 96 | /**
|
---|
| 97 | * Calculate the distance of two points in the periodic space
|
---|
| 98 | * defined by this box
|
---|
| 99 | */
|
---|
[014475] | 100 | double periodicDistance(const Vector &point1,const Vector &point2) const;
|
---|
[f429d7] | 101 |
|
---|
[c538d1] | 102 | Shape getShape() const;
|
---|
[77374e] | 103 | const Conditions_t getConditions();
|
---|
| 104 | void setCondition(int,BoundaryCondition_t);
|
---|
| 105 |
|
---|
[29ac78] | 106 | const vector<pair<Plane,Plane> > getBoundingPlanes();
|
---|
| 107 |
|
---|
[e1ab97] | 108 | void setCuboid(const Vector&);
|
---|
[c538d1] | 109 |
|
---|
[83c09a] | 110 | private:
|
---|
[77374e] | 111 | Conditions_t conditions;
|
---|
[cca9ef] | 112 | RealSpaceMatrix *M; //!< Defines the layout of the box
|
---|
| 113 | RealSpaceMatrix *Minv; //!< Inverse of M to avoid recomputation
|
---|
[83c09a] | 114 | };
|
---|
| 115 |
|
---|
| 116 | #endif /* BOX_HPP_ */
|
---|