MercuryDPM  Trunk
 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-2020, 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 "BasePeriodicBoundary.h"
30 #include "ParticleHandler.h"
31 #include "Math/Vector.h"
32 #include "MpiDataClass.h"
33 
42 {
43 public:
44 
49 
53  ~PeriodicBoundary() override;
54 
58  PeriodicBoundary* copy() const override;
59 
63  PeriodicBoundary(const PeriodicBoundary& other);
64 
68  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
69 
74  void set(Vec3D normal, Vec3D positionLeft, Vec3D positionRight);
75 
79  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, Vec3D shiftDirection);
80 
85  void setPlanewiseShift(Vec3D planewiseShift);
86 
90  Vec3D getNormal() const;
91 
95  Mdouble getDistanceLeft() const;
96 
100  Mdouble getDistanceRight() const;
101 
105  Vec3D getShift() const;
106 
110  void moveLeft(Mdouble distanceLeft);
111 
115  void moveRight(Mdouble distanceRight);
116 
120  Mdouble getDistance(const BaseParticle& p) const override;
121 
125  Mdouble getDistance(const Vec3D& position) const override;
126 
131  void shiftPosition(BaseParticle* p) const override;
132  void shiftPosition(Vec3D& p) const;
133 
137  virtual void shiftPositions(Vec3D& postition1, Vec3D& postion2) const;
138 
143  virtual bool isClosestToLeftBoundary(const BaseParticle& p) const;
144 
149  bool isClosestToLeftBoundary(const Vec3D& p) const override;
150 
154  void read(std::istream& is) override;
155 
160  void oldRead(std::istream& is);
161 
165  void write(std::ostream& os) const override;
166 
170  std::string getName() const override;
171 
176  void createPeriodicParticles(ParticleHandler& pH) override;
177 
181  void createGhostParticle(BaseParticle* pReal);
182 
186  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
187 
193 
194 protected:
203 
208 
213 
218 
219 };
220 
221 #endif
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
void shiftPosition(BaseParticle *p) const override
shifts the particle
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
double Mdouble
Definition: GeneralDefine.h:34
std::string getName() const override
Returns the name of the object.
MERCURY_DEPRECATED void oldRead(std::istream &is)
deprecated version of CubeInsertionBoundary::read().
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
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 edge, s.t. normal*x = distanceRight_
Vec3D getNormal() const
returns the vector normal to the periodic boundary
PeriodicBoundary * copy() const override
copy method
PeriodicBoundary()
default constructor
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
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
Defines a pair of periodic walls. Inherits from BaseBoundary.
void setPlanewiseShift(Vec3D planewiseShift)
Set the planewise shift (projected onto the planewise direction, and zero by default).
void moveLeft(Mdouble distanceLeft)
Sets the distance from the origin of the 'left' periodic wall.
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a give real particle.
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Checks if particle has crossed either boundary wall, and applies a shift if that is the case...
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Container to store all BaseParticle.
Vec3D shift_
shift from left to right boundary
Definition: Vector.h:49
void write(std::ostream &os) const override
writes boundary properties to ostream
void createPeriodicParticles(ParticleHandler &pH) override
Checks distance of particle to closest wall and creates periodic copy if necessary.
void read(std::istream &is) override
reads boundary properties from istream
~PeriodicBoundary() override
destructor
virtual void shiftPositions(Vec3D &postition1, Vec3D &postion2) const
shifts two positions