PeriodicBoundary.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef PeriodicBoundary_H
6 #define PeriodicBoundary_H
7 
8 #include "BasePeriodicBoundary.h"
9 #include "ParticleHandler.h"
10 #include "Math/Vector.h"
11 #include "MpiDataClass.h"
12 
20 {
21 public:
22 
27 
31  ~PeriodicBoundary() override;
32 
36  PeriodicBoundary* copy() const override;
37 
41  PeriodicBoundary(const PeriodicBoundary& other);
42 
46  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight);
47 
52  void set(Vec3D normal, Vec3D positionLeft, Vec3D positionRight);
53 
57  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, Vec3D shiftDirection);
58 
63  void setPlanewiseShift(Vec3D planewiseShift);
64 
68  Vec3D getNormal() const;
69 
73  Mdouble getDistanceLeft() const;
74 
78  Mdouble getDistanceRight() const;
79 
83  Vec3D getShift() const;
84 
88  void moveLeft(Mdouble distanceLeft);
89 
93  void moveRight(Mdouble distanceRight);
94 
98  Mdouble getDistance(const BaseParticle& p) const override;
99 
103  Mdouble getDistance(const Vec3D& position) const override;
104 
109  virtual void shiftPosition(BaseParticle* p) const override;
110  void shiftPosition(Vec3D& p) const;
111 
115  virtual void shiftPositions(Vec3D& postition1, Vec3D& postion2) const;
116 
121  virtual bool isClosestToLeftBoundary(const BaseParticle& p) const;
122 
127  bool isClosestToLeftBoundary(const Vec3D& p) const override;
128 
133  virtual void createPeriodicParticles(ParticleHandler &pH) override;
134 
138  void createGhostParticle(BaseParticle *pReal);
139 
144 
149  virtual void checkBoundaryAfterParticlesMove(ParticleHandler& pH) override;
150 
154  virtual void read(std::istream& is) override;
159  void oldRead(std::istream& is);
160 
164  void write(std::ostream& os) const override;
165 
169  std::string getName() const override;
170 
171 
172 protected:
181 
186 
191 
196 
197 };
198 
199 #endif
#define MERCURYDPM_DEPRECATED
Definition: GeneralDefine.h:16
float * p
Definition: Tutorial_Map_using.cpp:9
Definition: BaseParticle.h:33
Definition: BasePeriodicBoundary.h:20
Container to store pointers to all particles.
Definition: ParticleHandler.h:28
Defines a pair of periodic walls. Inherits from BaseBoundary.
Definition: PeriodicBoundary.h:20
Vec3D normal_
outward unit normal vector for right edge
Definition: PeriodicBoundary.h:176
void moveLeft(Mdouble distanceLeft)
Sets the distance from the origin of the 'left' periodic wall.
Definition: PeriodicBoundary.cc:149
PeriodicBoundary * copy() const override
copy method
Definition: PeriodicBoundary.cc:37
Vec3D getShift() const
Returns the vector going from the left to the right side of the periodic boundary.
Definition: PeriodicBoundary.cc:138
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Definition: PeriodicBoundary.cc:293
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Definition: PeriodicBoundary.h:190
Mdouble getDistanceRight() const
Returns the distance of the right wall to the origin, in normal direction.
Definition: PeriodicBoundary.cc:130
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: PeriodicBoundary.cc:176
virtual void shiftPosition(BaseParticle *p) const override
shifts the particle
Definition: PeriodicBoundary.cc:198
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
Definition: PeriodicBoundary.cc:122
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Definition: PeriodicBoundary.h:180
virtual void createPeriodicParticles(ParticleHandler &pH) override
Checks distance of particle to closer edge and creates a periodic copy if necessary.
Definition: PeriodicBoundary.cc:328
Vec3D shift_
shift from left to right boundary
Definition: PeriodicBoundary.h:195
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...
Definition: PeriodicBoundary.cc:254
void setPlanewiseShift(Vec3D planewiseShift)
Set the planewise shift (projected onto the planewise direction, and zero by default).
Definition: PeriodicBoundary.cc:105
virtual void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift i...
Definition: PeriodicBoundary.cc:353
Vec3D getNormal() const
returns the vector normal to the periodic boundary
Definition: PeriodicBoundary.cc:114
MERCURYDPM_DEPRECATED void oldRead(std::istream &is)
deprecated version of CubeInsertionBoundary::read().
Definition: PeriodicBoundary.cc:391
virtual void read(std::istream &is) override
reads boundary properties from istream
Definition: PeriodicBoundary.cc:376
virtual void shiftPositions(Vec3D &postition1, Vec3D &postion2) const
shifts two positions
Definition: PeriodicBoundary.cc:234
void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: PeriodicBoundary.cc:405
PeriodicBoundary()
default constructor
Definition: PeriodicBoundary.cc:16
~PeriodicBoundary() override
destructor
Definition: PeriodicBoundary.cc:29
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Definition: PeriodicBoundary.h:185
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
Definition: PeriodicBoundary.cc:63
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
Definition: PeriodicBoundary.cc:283
void moveRight(Mdouble distanceRight)
Sets the distance from the origin of the 'right' periodic wall.
Definition: PeriodicBoundary.cc:161
std::string getName() const override
Returns the name of the object.
Definition: PeriodicBoundary.cc:419
Definition: Kernel/Math/Vector.h:30
void normal(const Vector< double > &x, Vector< double > &normal)
Definition: free_surface_rotation.cc:65
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286