MercuryDPM  Beta
LeesEdwardsBoundary Class Reference

Class which creates a boundary with Lees-Edwards type periodic boundary conditions. More...

#include <LeesEdwardsBoundary.h>

Inheritance diagram for LeesEdwardsBoundary:

Public Member Functions

void set (std::function< double(double)> shift, std::function< double(double)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up)
Sets all boundary properties. More...

Reads all boundary properties from a stream. More...

void write (std::ostream &os) const
Writes all boundary properties to a stream. More...

virtual std::string getName () const
Returns the name of the object. More...

LeesEdwardsBoundarycopy () const
Creates a copy of the object. More...

Mdouble getHorizontalDistance (BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall. More...

Mdouble getVerticalDistance (BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall. More...

void shiftHorizontalPosition (BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle. More...

void shiftVerticalPosition (BaseParticle *p, bool positive)
Applies a vertical shift to the given particle. More...

bool checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH UNUSED)
Checks if particle crossed a boundary wall and if so, applies periodic shift. More...

void createPeriodicParticles (BaseParticle *p, ParticleHandler &pH)
Creates horizontal and vertical periodic copies of given particle, if needed. More...

void createHorizontalPeriodicParticles (BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed. More...

void createVerticalPeriodicParticles (BaseParticle *p, ParticleHandler &pH)
Creates vertical periodic copies of given particle, if needed. More...

Public Member Functions inherited from BaseBoundary
BaseBoundary ()
default constructor. More...

BaseBoundary (const BaseBoundary &b)
copy constructor More...

virtual ~BaseBoundary ()
destructor More...

virtual void createPeriodicParticles (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
Creates periodic copies of given particle in case of periodic boundaries. More...

virtual bool checkBoundaryAfterParticleMoved (BaseParticle *P UNUSED, ParticleHandler &pH UNUSED)
Checks if given particle passed the boundary. More...

virtual void checkBoundaryBeforeTimeStep (DPMBase *md UNUSED)
Fills a (3D) boundary with particles. More...

void setHandler (BoundaryHandler *handler)
Sets the boundary's BoundaryHandler. More...

BoundaryHandlergetHandler () const
Returns the boundary's BoundaryHandler. More...

Public Member Functions inherited from BaseObject
BaseObject ()
Default constructor. More...

BaseObject (const BaseObject &p)
Copy constructor, copies all the objects BaseObject contains. More...

virtual ~BaseObject ()
virtual destructor More...

virtual void moveInHandler (const unsigned int index)
Except that it is virtual, it does the same thing as setIndex() does. More...

void setIndex (const unsigned int index)
Allows one to assign an index to an object in the handler/container. More...

void setId (const unsigned int id)
Assigns a unique identifier to each object in the handler (container) which remains constant even after the object is deleted from the container/handler. More...

unsigned int getIndex () const
Returns the index of the object in the handler. More...

unsigned int getId () const
Returns the unique identifier of any particular object. More...

Private Attributes

Mdouble left_

Mdouble right_
(signed) Horizontal distance between the left wall and the origin More...

Mdouble down_
(signed) Horizontal distance between the right wall and the origin More...

Mdouble up_
(signed) Vertical distance between the bottom wall and the origin More...

std::function< double(double)> shift_
(signed) Vertical distance between the top wall and the origin More...

std::function< double(double)> velocity_

Detailed Description

Class which creates a boundary with Lees-Edwards type periodic boundary conditions.

Todo:

Add link to paper by Lees-Edwards in the documentation of this class.

Is implemented for 2D only now. Needs extension to 3D.

Definition at line 42 of file LeesEdwardsBoundary.h.

Member Function Documentation

 bool LeesEdwardsBoundary::checkBoundaryAfterParticleMoved ( BaseParticle * p, ParticleHandler &pH UNUSED )

Checks if particle crossed a boundary wall and if so, applies periodic shift.

Checks if the particle has to be shifted into the main domain (i.e., if the particle has crossed any of the boundary walls) and if so performs the shift

Parameters
 [in] p A pointer to the BaseParticle that is checked

Definition at line 263 of file LeesEdwardsBoundary.cc.

264 {
265  bool positive;
266  while (getVerticalDistance(*p, positive) < 0)
267  {
268  shiftVerticalPosition(p, positive);
269  }
270  while (getHorizontalDistance(*p, positive) < 0)
271  {
272  shiftHorizontalPosition(p, positive);
273  }
274  return false;
275 }
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.
 LeesEdwardsBoundary * LeesEdwardsBoundary::copy ( ) const
virtual

Creates a copy of the object.

Copy method; creates a copy on the heap and returns its pointer.

Returns
pointer to the copy on the heap

Implements BaseBoundary.

Definition at line 87 of file LeesEdwardsBoundary.cc.

88 {
89  return new LeesEdwardsBoundary(*this);
90 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
 void LeesEdwardsBoundary::createHorizontalPeriodicParticles ( BaseParticle * p, ParticleHandler & pH )

Creates horizontal periodic copies of given particle, if needed.

Check if periodic copies of the particle in horizontal direction have to be made (i.e., if the distance of the particle to either of the horizontal boundary walls is smaller than its radius plus the radius of the largest particle in the system), and if so makes them

Parameters
 [in] p A pointer to the BaseParticle that is checked [out] pH A reference to the ParticleHandler where periodic copies will be added

Definition at line 181 of file LeesEdwardsBoundary.cc.

Referenced by createPeriodicParticles(), and createVerticalPeriodicParticles().

182 {
183  bool positive; // TRUE if the particle is closest to the left boundary
184  // wall (set by getVerticalDistance in the following if-statement)
185  // check if particle is close enough to either of the walls
187  {
188  // create a periodic copy of the particle
189  BaseParticle* F0 = p->copy();
192
193  // If Particle is doubly shifted, get correct original particle
194  BaseParticle* From = p;
195  while (From->getPeriodicFromParticle() != nullptr)
196  From = From->getPeriodicFromParticle();
197  F0->setPeriodicFromParticle(From);
198
199  // shift the copy to the 'periodic' position
200  shiftHorizontalPosition(F0, positive);
201
202  // NB: No extra creation of possible vertical copies of the horizontal copy
203  // here (as compared to createVerticalPeriodicParticles), because these would
204  // overlap with the extra creation of horizontal copies in createVerticalPeriodicParticles.
205  }
206 }
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
void setPeriodicFromParticle(BaseParticle *p)
Assigns the pointer to the 'original' particle this one's a periodic copy of.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Adds a BaseParticle to the ParticleHandler.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
 void LeesEdwardsBoundary::createPeriodicParticles ( BaseParticle * p, ParticleHandler & pH )

Creates horizontal and vertical periodic copies of given particle, if needed.

Check if periodic copies of the particle have to be made for the contact detection and if so makes them

Parameters
 [in] p A pointer to the BaseParticle that is checked [out] pH A reference to the ParticleHandler where periodic copies will be added

Definition at line 252 of file LeesEdwardsBoundary.cc.

253 {
256 }
void createHorizontalPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed.
void createVerticalPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Creates vertical periodic copies of given particle, if needed.
 void LeesEdwardsBoundary::createVerticalPeriodicParticles ( BaseParticle * p, ParticleHandler & pH )

Creates vertical periodic copies of given particle, if needed.

Check if periodic copies of the particle in vertical direction have to be made (i.e., if the distance of the particle to either of the vertical boundary walls is smaller than its radius plus the radius of the largest particle in the system), and if so makes them

Parameters
 [in] p A pointer to the BaseParticle that is checked [out] pH A reference to the ParticleHandler where periodic copies will be added

Definition at line 216 of file LeesEdwardsBoundary.cc.

Referenced by createPeriodicParticles().

217 {
218  bool positive; // TRUE if the particle is closest to the bottom boundary
219  // wall (set by getVerticalDistance in the following if-statement)
220  // check if particle is close enough to either of the walls
222  {
223  // create a periodic copy of the particle
224  BaseParticle* F0 = p->copy();
227
228  // If Particle is doubly shifted, get correct original particle
229  BaseParticle* From = p;
230  while (From->getPeriodicFromParticle() != nullptr)
231  From = From->getPeriodicFromParticle();
232  F0->setPeriodicFromParticle(From);
233
234  // shift the copy to the 'periodic' position
235  shiftVerticalPosition(F0, positive);
236  while (getHorizontalDistance(*F0, positive) < 0)
237  {
238  shiftHorizontalPosition(F0, positive);
239  }
240
241  // Create horizontal periodic copies of the copy particle, if needed (i.e.,
242  // if the original particle is in one of the boundary corners).
244  }
245 }
BaseParticle * getLargestParticle() const
Gets a pointer to the largest BaseParticle (by interactionRadius) in this ParticleHandler.
void setPeriodicFromParticle(BaseParticle *p)
Assigns the pointer to the 'original' particle this one's a periodic copy of.
void createHorizontalPeriodicParticles(BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
Adds a BaseParticle to the ParticleHandler.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:452
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.
 Mdouble LeesEdwardsBoundary::getHorizontalDistance ( BaseParticle & p, bool & positive )

Returns distance from given particle to the closest horizontal wall.

Returns the distance between BaseParticle p and the closest boundary wall in horizontal direction

Parameters
 [in] p A reference to the BaseParticle [out] positive A boolean which is true when the left wall is closest
Returns
The distance to the closes wall in horizontal direction

Definition at line 98 of file LeesEdwardsBoundary.cc.

References BaseInteractable::getPosition(), left_, right_, and Vec3D::X.

99 {
100  Mdouble left = p.getPosition().X - left_;
101  Mdouble right = right_ - p.getPosition().X;
102  if (left < right)
103  {
104  positive = true;
105  return left;
106  } else
107  {
108  positive = false;
109  return right;
110  }
111 }
Mdouble X
the vector components
Definition: Vector.h:52
double Mdouble
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
 std::string LeesEdwardsBoundary::getName ( ) const
virtual

Returns the name of the object.

Returns
The name of this object (i.e. "LeesEdwardsBoundary")

Implements BaseObject.

Definition at line 78 of file LeesEdwardsBoundary.cc.

79 {
80  return "LeesEdwardsBoundary";
81 }
 Mdouble LeesEdwardsBoundary::getVerticalDistance ( BaseParticle & p, bool & positive )

Returns distance from given particle to the closest vertical wall.

Returns the distance between BaseParticle p and the closest wall in vertical direction

Parameters
 [in] p A reference to the BaseParticle [out] positive A boolean which is true when the bottom wall is closest
Returns
The distance to the closes wall in vertical direction

Definition at line 119 of file LeesEdwardsBoundary.cc.

References down_, BaseInteractable::getPosition(), up_, and Vec3D::Y.

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticles().

120 {
121  Mdouble down = p.getPosition().Y - down_;
122  Mdouble up = up_ - p.getPosition().Y;
123  if (down < up)
124  {
125  positive = true;
126  return down;
127  } else
128  {
129  positive = false;
130  return up;
131  }
132 }
double Mdouble
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Mdouble Y
Definition: Vector.h:52
 void LeesEdwardsBoundary::read ( std::istream & is )
virtual

Reads all boundary properties from a stream.

Reads all the properties of the LeesEdwardsBoundary from an std::istream

Parameters
 [in,out] is The stream from which the parameters are read

Implements BaseBoundary.

Definition at line 53 of file LeesEdwardsBoundary.cc.

References down_, left_, BaseBoundary::read(), right_, shift_, UNUSED, up_, and velocity_.

54 {
55  std::string dummy;
57  Mdouble shift;
58  Mdouble velocity;
59  is>>dummy>>left_>>dummy>>right_>>dummy>>down_>>dummy>>up_>>dummy>>shift>>dummy>>velocity;
60  shift_=[shift] (double time UNUSED) { return shift;};
61  velocity_=[velocity] (double time UNUSED) {return velocity;};
62 }
std::function< double(double)> shift_
(signed) Vertical distance between the top wall and the origin
std::function< double(double)> velocity_
double Mdouble
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
#define UNUSED
Definition: GeneralDefine.h:37
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Reads the object's id_ from given istream NB: purely virtual function.
Definition: BaseBoundary.cc:67
 void LeesEdwardsBoundary::set ( std::function< double(double)> shift, std::function< double(double)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up )

Sets all boundary properties.

Allows the user to set all the properties of the LeesEdwardsBoundary at once.

Parameters
 [in] velocity The difference in velocities at which the bottom and to wall move [in] left The (signed) distance between the origin and the left wall [in] right The (signed) distance between the origin and the right wall [in] down The (signed) distance between the origin and the top wall [in] up The (signed) distance between the origin and the bottom wall

Definition at line 39 of file LeesEdwardsBoundary.cc.

References down_, left_, right_, shift_, up_, and velocity_.

40 {
41  shift_ = shift;
42  velocity_ = velocity;
43  left_ = left;
44  right_ = right;
45  down_ = down;
46  up_ = up;
47 }
std::function< double(double)> shift_
(signed) Vertical distance between the top wall and the origin
std::function< double(double)> velocity_
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
 void LeesEdwardsBoundary::shiftHorizontalPosition ( BaseParticle * p, bool positive )

Applies a horizontal shift to the given particle.

Shifts the BaseParticle p in horizontal direction to its 'periodic' position, i.e. over the horizontal length of the boundary.

Parameters
 [in] p A reference to the BaseParticle that has to be shifted [in] positive A boolean which determines the direction of the shift NB: TRUE if particle is closest to the left boundary wall

Definition at line 141 of file LeesEdwardsBoundary.cc.

References left_, BaseInteractable::move(), and right_.

142 {
143  if (positive)
144  {
145  p->move(Vec3D(right_ - left_, 0.0, 0.0));
146  } else
147  {
148  p->move(Vec3D(left_ - right_, 0.0, 0.0));
149  }
150 }
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
 void LeesEdwardsBoundary::shiftVerticalPosition ( BaseParticle * p, bool positive )

Applies a vertical shift to the given particle.

Shifts the BaseParticle p in vertical direction to its 'periodic' position, i.e. over the vertical length of the boundary.

Parameters
 [in] p A reference to the BaseParticle that has to be shifted [in] positive A boolean which determines the direction of the shift NB: TRUE if particle is closest to the bottom boundary wall

Definition at line 159 of file LeesEdwardsBoundary.cc.

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticles().

160 {
161  Mdouble time = getHandler()->getDPMBase()->getTime();
162  if (positive)
163  {
164  p->move(Vec3D(shift_(time), up_ - down_, 0.0));
166  } else
167  {
168  p->move(Vec3D(-shift_(time), down_ - up_, 0.0));
170  }
171 }
std::function< double(double)> shift_
(signed) Vertical distance between the top wall and the origin
adds an increment to the velocity.
std::function< double(double)> velocity_
double Mdouble
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Implementation of a 3D vector (by Vitaliy).
Definition: Vector.h:45
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:158
 void LeesEdwardsBoundary::write ( std::ostream & os ) const
virtual

Writes all boundary properties to a stream.

Writes all the properties of the LeesEdwardsBoundary to an std::ostream

Parameters
 [out] os The stream to which the parameters are written

Implements BaseBoundary.

Definition at line 68 of file LeesEdwardsBoundary.cc.

69 {
71  Mdouble time = getHandler()->getDPMBase()->getTime();
72  os<<" left "<<left_<<" right "<<right_<<" down "<<down_<<" up "<<up_<<" shift "<<shift_(time)<<" vel "<<velocity_(time);
73 }
std::function< double(double)> shift_
(signed) Vertical distance between the top wall and the origin
std::function< double(double)> velocity_
void write(std::ostream &os) const =0
Adds object's id_ to given ostream NB: purely virtual function.
Definition: BaseBoundary.cc:76
double Mdouble
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:512
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:158

Member Data Documentation

 Mdouble LeesEdwardsBoundary::down_
private

(signed) Horizontal distance between the right wall and the origin

Definition at line 113 of file LeesEdwardsBoundary.h.

Referenced by getVerticalDistance(), read(), set(), shiftVerticalPosition(), and write().

 Mdouble LeesEdwardsBoundary::left_
private
 Mdouble LeesEdwardsBoundary::right_
private

(signed) Horizontal distance between the left wall and the origin

Definition at line 112 of file LeesEdwardsBoundary.h.

Referenced by getHorizontalDistance(), read(), set(), shiftHorizontalPosition(), and write().

 std::function LeesEdwardsBoundary::shift_
private

(signed) Vertical distance between the top wall and the origin

Definition at line 115 of file LeesEdwardsBoundary.h.

Referenced by read(), set(), shiftVerticalPosition(), and write().

 Mdouble LeesEdwardsBoundary::up_
private

(signed) Vertical distance between the bottom wall and the origin

Definition at line 114 of file LeesEdwardsBoundary.h.

Referenced by getVerticalDistance(), read(), set(), shiftVerticalPosition(), and write().

 std::function LeesEdwardsBoundary::velocity_
private

Definition at line 116 of file LeesEdwardsBoundary.h.

Referenced by read(), set(), shiftVerticalPosition(), and write().

The documentation for this class was generated from the following files: