TimeDependentPeriodicBoundary.h
Go to the documentation of this file.
1 //Copyright (c) 2013-2023, 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 TimeDependentPeriodicBoundary_H
27 #define TimeDependentPeriodicBoundary_H
28 
29 #include "BasePeriodicBoundary.h"
30 #include "ParticleHandler.h"
31 #include "Math/Vector.h"
32 #include "MpiDataClass.h"
33 #include <functional>
34 
54 {
55 public:
56 
61 
66 
70  TimeDependentPeriodicBoundary* copy() const override;
71 
76 
92  void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight,
93  std::function<Vec3D(Mdouble)> planewiseShift, std::function<Vec3D(Mdouble)> boost);
94 
99  void set(Vec3D normal, Vec3D positionLeft, Vec3D positionRight,
100  std::function<Vec3D(Mdouble)> shift, std::function<Vec3D(Mdouble)> boost);
101 
108  std::function<Vec3D(Mdouble)> shift, std::function<Vec3D(Mdouble)> boost);
109 
113  void setMaxShift(Mdouble maxShift);
114 
118  Vec3D getNormal() const;
119 
123  Mdouble getDistanceLeft() const;
124 
128  Mdouble getDistanceRight() const;
129 
133  Vec3D getShift(Mdouble time) const;
134 
138  Vec3D getPlanewiseShift(Mdouble time) const;
139 
143  Vec3D getBoost(Mdouble time) const;
144 
148  void moveLeft(Mdouble distanceLeft);
149 
153  void moveRight(Mdouble distanceRight);
154 
158  Mdouble getDistance(const BaseParticle& p) const override;
159 
163  Mdouble getDistance(const Vec3D &position) const override;
164 
171  virtual void shiftPosition(BaseParticle* p) const override;
172 
173  virtual void shiftAndBoostParticle(BaseParticle* p, Mdouble time) const;
174 
178  virtual void shiftPositions(Vec3D &position1, Vec3D &position2) const;
179 
184  virtual bool isClosestToLeftBoundary(const BaseParticle& p) const;
185 
190  virtual bool isClosestToLeftBoundary(const Vec3D& p) const override;
191 
196  virtual void createPeriodicParticles(ParticleHandler &pH) override;
197 
203  void createGhostParticle(BaseParticle *pReal);
204 
208  void createPeriodicParticle(BaseParticle* p, ParticleHandler &pH) override;
209 
214  virtual void checkBoundaryAfterParticlesMove(ParticleHandler& pH) override;
215 
219  virtual void read(std::istream& is) override;
220 
224  virtual void write(std::ostream& os) const override;
225 
229  virtual std::string getName() const override;
230 
231 protected:
236 
241 
246 
251  std::function<Vec3D (Mdouble)> planewiseShift_;
252 
256  std::function<Vec3D (Mdouble)> boost_;
257 
262 
263 };
264 #endif
Definition: BaseParticle.h:54
Definition: BasePeriodicBoundary.h:41
Container to store all BaseParticle.
Definition: ParticleHandler.h:48
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: TimeDependentPeriodicBoundary.h:54
void moveLeft(Mdouble distanceLeft)
Sets the distance from the origin of the 'left' periodic wall.
Definition: TimeDependentPeriodicBoundary.cc:172
virtual void write(std::ostream &os) const override
writes boundary properties to ostream
Definition: TimeDependentPeriodicBoundary.cc:358
void setMaxShift(Mdouble maxShift)
Set the maximum shift (will take fmod w.r.t. this)
Definition: TimeDependentPeriodicBoundary.cc:110
TimeDependentPeriodicBoundary()
default constructor
Definition: TimeDependentPeriodicBoundary.cc:37
~TimeDependentPeriodicBoundary()
destructor
Definition: TimeDependentPeriodicBoundary.cc:58
void moveRight(Mdouble distanceRight)
Sets the distance from the origin of the 'right' periodic wall.
Definition: TimeDependentPeriodicBoundary.cc:183
virtual void shiftPosition(BaseParticle *p) const override
shifts and boosts the particle
Definition: TimeDependentPeriodicBoundary.cc:209
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Definition: TimeDependentPeriodicBoundary.h:245
virtual void createPeriodicParticles(ParticleHandler &pH) override
Checks distance of particle to closer edge and creates a periodic copy if necessary.
Definition: TimeDependentPeriodicBoundary.cc:264
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Definition: TimeDependentPeriodicBoundary.cc:281
Vec3D getBoost(Mdouble time) const
Returns the planewise boost as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:160
void setPlanewiseShiftAndBoost(std::function< Vec3D(Mdouble)> shift, std::function< Vec3D(Mdouble)> boost)
Set the planewise shift and boost (projected onto the planewise direction) as functions of time....
Definition: TimeDependentPeriodicBoundary.cc:103
virtual void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift i...
Definition: TimeDependentPeriodicBoundary.cc:320
Vec3D normal_
outward unit normal vector for right edge
Definition: TimeDependentPeriodicBoundary.h:235
Mdouble getDistanceRight() const
Returns the distance of the right wall to the origin, in normal direction.
Definition: TimeDependentPeriodicBoundary.cc:134
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Definition: TimeDependentPeriodicBoundary.h:240
Mdouble getDistanceLeft() const
Returns the distance of the left wall to the origin, in normal direction.
Definition: TimeDependentPeriodicBoundary.cc:126
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'righ...
Definition: TimeDependentPeriodicBoundary.cc:247
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, std::function< Vec3D(Mdouble)> planewiseShift, std::function< Vec3D(Mdouble)> boost)
Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting...
Definition: TimeDependentPeriodicBoundary.cc:85
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Definition: TimeDependentPeriodicBoundary.h:251
virtual void read(std::istream &is) override
reads boundary properties from istream
Definition: TimeDependentPeriodicBoundary.cc:342
Vec3D getPlanewiseShift(Mdouble time) const
Returns the planewise shift as a function of time.
Definition: TimeDependentPeriodicBoundary.cc:144
TimeDependentPeriodicBoundary * copy() const override
copy method
Definition: TimeDependentPeriodicBoundary.cc:66
virtual std::string getName() const override
Returns the name of the object.
Definition: TimeDependentPeriodicBoundary.cc:373
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Definition: TimeDependentPeriodicBoundary.h:256
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
Definition: TimeDependentPeriodicBoundary.cc:303
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
Definition: TimeDependentPeriodicBoundary.h:261
virtual void shiftAndBoostParticle(BaseParticle *p, Mdouble time) const
Definition: TimeDependentPeriodicBoundary.cc:213
virtual void shiftPositions(Vec3D &position1, Vec3D &position2) const
shifts two positions (JMFT: Why, what is this for?)
Definition: TimeDependentPeriodicBoundary.cc:227
Vec3D getNormal() const
returns the vector normal to the periodic boundary
Definition: TimeDependentPeriodicBoundary.cc:118
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Definition: TimeDependentPeriodicBoundary.cc:188
Vec3D getShift(Mdouble time) const
Returns the vector going from the left to the right side of the periodic boundary.
Definition: TimeDependentPeriodicBoundary.cc:139
Definition: Vector.h:51