MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
PeriodicBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2017, The MercuryDPM Developers Team. All rights reserved.
2 //For the list of developers, see <http://www.MercuryDPM.org/Team>.
3 //
4 //Redistribution and use in source and binary forms, with or without
5 //modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name MercuryDPM nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 //
15 //THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
16 //ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 //WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 //DISCLAIMED. IN NO EVENT SHALL THE MERCURYDPM DEVELOPERS TEAM BE LIABLE FOR ANY
19 //DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 //(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 //LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 //ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 //(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
24 //SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 #ifndef PeriodicBoundary_H
27 #define PeriodicBoundary_H
28 
29 #include "BaseBoundary.h"
30 #include "Math/Vector.h"
31 
32 class ParticleHandler;
33 
42 {
43 public:
48 
53 
57  PeriodicBoundary* copy() const override;
58 
62  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
63 
64  void set(Vec3D normal, Vec3D positionLeft, Vec3D positionRight);
65 
69  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, Vec3D shiftDirection);
70 
74  Vec3D getNormal() const;
75 
79  Mdouble getDistanceLeft() const;
80 
84  Mdouble getDistanceRight() const;
85 
89  Vec3D getShift() const;
90 
94  void moveLeft(Mdouble distanceLeft);
95 
99  void moveRight(Mdouble distanceRight);
100 
104  Mdouble getDistance(const BaseParticle& p) const;
105 
109  Mdouble getDistance(const Vec3D &position) const;
110 
115  void shiftPosition(BaseParticle* p) const;
116 
117  /*
119  Vec3D getShiftedPosition(Vec3D &Position);
120  */
121 
125  void shiftPositions(Vec3D &postition1, Vec3D &postion2) const;
126 
131  bool isClosestToLeftBoundary(const BaseParticle& p) const;
132 
133  bool isClosestToLeftBoundary(const Vec3D& p) const;
134 
135  /*
137  void getCloseTogether(Vec3D &P, Vec3D &Q);
138  */
139 
143  void read(std::istream& is) override;
144 
149  void oldRead(std::istream& is);
150 
154  void write(std::ostream& os) const override;
155 
159  virtual std::string getName() const override;
160 
161  /*
162  Vec3D& getNormal();
163  */
164 
170 
176 
177 private:
198 };
199 #endif
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
virtual std::string getName() const override
Returns the name of the object.
MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of CubeInsertionBoundary::read().
double Mdouble
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
void createPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Checks distance of particle to closest wall and creates periodic copy if necessary.
void moveRight(Mdouble distanceRight)
Sets the distance from the origin of the 'right' periodic wall.
Mdouble getDistanceRight() const
Returns the distance of the right wall to the origin, in normal direction.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D getNormal() const
returns the vector normal to the periodic boundary
PeriodicBoundary * copy() const override
copy method
PeriodicBoundary()
default constructor
Vec3D getShift() const
Returns the vector going from the left to the right side of the periodic boundary.
Vec3D normal_
outward unit normal vector for right wall
#define MERCURY_DEPRECATED
Definition: GeneralDefine.h:37
~PeriodicBoundary()
destructor
Defines a pair of periodic walls. Inherits from BaseBoundary.
bool checkBoundaryAfterParticleMoved(BaseParticle *p, ParticleHandler &pH UNUSED)
Checks if particle has crossed either boundary wall, and applies a shift if that is the case...
Mdouble getDistance(const BaseParticle &p) const
Returns the distance of the wall to the particle.
void moveLeft(Mdouble distanceLeft)
Sets the distance from the origin of the 'left' periodic wall.
bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is clos...
void shiftPosition(BaseParticle *p) const
shifts the particle
#define UNUSED
Definition: GeneralDefine.h:39
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Container to store all BaseParticle.
Vec3D shift_
shift from left to right boundary
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
void write(std::ostream &os) const override
writes boundary properties to ostream
void read(std::istream &is) override
reads boundary properties from istream
void shiftPositions(Vec3D &postition1, Vec3D &postion2) const
shifts two positions