MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
LeesEdwardsBoundary.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 LEESEDWARDSBOUNDARY_H
27 #define LEESEDWARDSBOUNDARY_H
28 
29 #include "BaseBoundary.h"
30 
31 #include <functional>
32 
33 class ParticleHandler;
34 
43 {
44 public:
45 
47  {
48 #ifdef MERCURY_USE_MPI
49  MPIContainer& communicator = MPIContainer::Instance();
50  if (communicator.getNumberOfProcessors() > 1)
51  {
52  logger(WARN,"LeesEdwardsBoundaries are currently not implemented in parallel MercuryDPM");
53  }
54 #endif
55  }
56 
60  void
61  set(std::function<Mdouble(Mdouble)> shift, std::function<Mdouble(Mdouble)> velocity, Mdouble left, Mdouble right,
62  Mdouble down, Mdouble up);
63 
64  void updateBoundaries(Mdouble left, Mdouble right, Mdouble down, Mdouble up);
65 
69  void read(std::istream& is) override;
70 
74  void write(std::ostream& os) const override;
75 
79  std::string getName() const override;
80 
84  LeesEdwardsBoundary* copy() const override;
85 
89  Mdouble getHorizontalDistance(BaseParticle& p, bool& positive);
90 
94  Mdouble getVerticalDistance(BaseParticle& p, bool& positive);
95 
99  void shiftHorizontalPosition(BaseParticle* p, bool positive);
100 
104  void shiftVerticalPosition(BaseParticle* p, bool positive);
105 
110 
115 
116  void createPeriodicParticle(BaseParticle* p, ParticleHandler& pH) override;
117 
121  void createPeriodicParticles(ParticleHandler& pH) override;
122 
127 
132 
134 
136 
137  void setShift(std::function<Mdouble(Mdouble)>);
138 
139  void setVelocity(std::function<Mdouble(Mdouble)>);
140 
141 private:
146  std::function<Mdouble(Mdouble)> shift_;
147  std::function<Mdouble(Mdouble)> velocity_;
148 };
149 
150 #endif
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:125
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:130
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
double Mdouble
Definition: GeneralDefine.h:34
LeesEdwardsBoundary * copy() const override
Creates a copy of the object.
std::function< Mdouble(Mdouble)> shift_
(signed) Vertical distance between the top wall and the origin
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
void setVelocity(std::function< Mdouble(Mdouble)>)
std::size_t getNumberOfProcessors() const
Get the total number of processors participating in this simulation.
void createPeriodicParticles(ParticleHandler &pH) override
Creates horizontal and vertical periodic copies of given particle, if needed.
void read(std::istream &is) override
Reads all boundary properties from a stream.
void createHorizontalPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed.
std::function< Mdouble(Mdouble)> velocity_
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
void updateBoundaries(Mdouble left, Mdouble right, Mdouble down, Mdouble up)
void setShift(std::function< Mdouble(Mdouble)>)
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
void createVerticalPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Creates vertical periodic copies of given particle, if needed.
void checkBoundaryAfterParticleMoved(BaseParticle *p)
Checks if particle crossed a boundary wall and if so, applies periodic shift.
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
void write(std::ostream &os) const override
Writes all boundary properties to a stream.
Container to store all BaseParticle.
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
void checkBoundaryAfterParticlesMove(ParticleHandler &pH) override
Checks if particles need to be adjusted after their position has been updated.
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
void set(std::function< Mdouble(Mdouble)> shift, std::function< Mdouble(Mdouble)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up)
Sets all boundary properties.
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
std::string getName() const override
Returns the name of the object.
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.