MercuryDPM  Alpha
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ShearBoxBoundary Class Reference

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

#include <ShearBoxBoundary.h>

+ Inheritance diagram for ShearBoxBoundary:

Public Member Functions

void set (std::function< double(double, double)> velocity, Mdouble left, Mdouble right, Mdouble down, Mdouble up)
 Sets all boundary properties. More...
 
void read (std::istream &is)
 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...
 
ShearBoxBoundarycopy () 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...
 
void setVelocity (std::function< double(double, double)>)
 
- 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,
double)> 
velocity_
 (signed) Vertical distance between the top wall and the origin More...
 

Detailed Description

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

See also [insert link to the original paper by LE]. Inherits from BaseBoundary.

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 ShearBoxBoundary.h.

Member Function Documentation

bool ShearBoxBoundary::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]pA pointer to the BaseParticle that is checked

Definition at line 259 of file ShearBoxBoundary.cc.

References getHorizontalDistance(), getVerticalDistance(), shiftHorizontalPosition(), and shiftVerticalPosition().

260 {
261  bool positive;
262  while (getVerticalDistance(*p, positive) < 0)
263  {
264  shiftVerticalPosition(p, positive);
265  }
266  while (getHorizontalDistance(*p, positive) < 0)
267  {
268  shiftHorizontalPosition(p, positive);
269  }
270  return false;
271 }
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
ShearBoxBoundary * ShearBoxBoundary::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 82 of file ShearBoxBoundary.cc.

83 {
84  return new ShearBoxBoundary(*this);
85 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
void ShearBoxBoundary::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]pA pointer to the BaseParticle that is checked
[out]pHA reference to the ParticleHandler where periodic copies will be added

Definition at line 177 of file ShearBoxBoundary.cc.

References ParticleHandler::addObject(), BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), getHorizontalDistance(), BaseParticle::getInteractionRadius(), ParticleHandler::getLargestParticle(), BaseParticle::getPeriodicFromParticle(), BaseParticle::setPeriodicFromParticle(), and shiftHorizontalPosition().

Referenced by createPeriodicParticles(), and createVerticalPeriodicParticles().

178 {
179  bool positive; // TRUE if the particle is closest to the left boundary
180  // wall (set by getVerticalDistance in the following if-statement)
181  // check if particle is close enough to either of the walls
183  {
184  // create a periodic copy of the particle
185  BaseParticle* F0 = p->copy();
186  pH.addObject(F0);
188 
189  // If Particle is doubly shifted, get correct original particle
190  BaseParticle* From = p;
191  while (From->getPeriodicFromParticle() != nullptr)
192  From = From->getPeriodicFromParticle();
193  F0->setPeriodicFromParticle(From);
194 
195  // shift the copy to the 'periodic' position
196  shiftHorizontalPosition(F0, positive);
197 
198  // NB: No extra creation of possible vertical copies of the horizontal copy
199  // here (as compared to createVerticalPeriodicParticles), because these would
200  // overlap with the extra creation of horizontal copies in createVerticalPeriodicParticles.
201  }
202 }
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 shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
virtual void addObject(BaseParticle *P)
Adds a BaseParticle to the ParticleHandler.
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Mdouble getInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
virtual BaseParticle * copy() const
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
void ShearBoxBoundary::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]pA pointer to the BaseParticle that is checked
[out]pHA reference to the ParticleHandler where periodic copies will be added

Definition at line 248 of file ShearBoxBoundary.cc.

References createHorizontalPeriodicParticles(), and createVerticalPeriodicParticles().

249 {
252 }
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 ShearBoxBoundary::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]pA pointer to the BaseParticle that is checked
[out]pHA reference to the ParticleHandler where periodic copies will be added

Definition at line 212 of file ShearBoxBoundary.cc.

References ParticleHandler::addObject(), BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), createHorizontalPeriodicParticles(), getHorizontalDistance(), BaseParticle::getInteractionRadius(), ParticleHandler::getLargestParticle(), BaseHandler< T >::getLastObject(), BaseParticle::getPeriodicFromParticle(), getVerticalDistance(), BaseParticle::setPeriodicFromParticle(), shiftHorizontalPosition(), and shiftVerticalPosition().

Referenced by createPeriodicParticles().

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

Definition at line 93 of file ShearBoxBoundary.cc.

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

Referenced by checkBoundaryAfterParticleMoved(), createHorizontalPeriodicParticles(), and createVerticalPeriodicParticles().

94 {
95  Mdouble left = p.getPosition().X - left_;
96  Mdouble right = right_ - p.getPosition().X;
97  if (left < right)
98  {
99  positive = true;
100  return left;
101  } else
102  {
103  positive = false;
104  return right;
105  }
106 }
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 ShearBoxBoundary::getName ( ) const
virtual

Returns the name of the object.

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

Implements BaseObject.

Definition at line 73 of file ShearBoxBoundary.cc.

74 {
75  return "ShearBoxBoundary";
76 }
Mdouble ShearBoxBoundary::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]pA reference to the BaseParticle
[out]positiveA boolean which is true when the bottom wall is closest
Returns
The distance to the closes wall in vertical direction

Definition at line 114 of file ShearBoxBoundary.cc.

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

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticles().

115 {
116  Mdouble down = p.getPosition().Y - down_;
117  Mdouble up = up_ - p.getPosition().Y;
118  if (down < up)
119  {
120  positive = true;
121  return down;
122  } else
123  {
124  positive = false;
125  return up;
126  }
127 }
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 Y
Definition: Vector.h:52
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
void ShearBoxBoundary::read ( std::istream &  is)
virtual

Reads all boundary properties from a stream.

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

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

Implements BaseBoundary.

Definition at line 52 of file ShearBoxBoundary.cc.

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

53 {
54  std::string dummy;
56  is>>dummy>>left_>>dummy>>right_>>dummy>>down_>>dummy>>up_;
57  velocity_=[] (double time UNUSED,double velocity UNUSED) {return 0.0;};
58 }
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
#define UNUSED
Definition: GeneralDefine.h:39
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
void read(std::istream &is)=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:67
void ShearBoxBoundary::set ( std::function< double(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 ShearBoxBoundary at once.

Parameters
[in]velocityThe difference in velocities at which the bottom and to wall move
[in]leftThe (signed) distance between the origin and the left wall
[in]rightThe (signed) distance between the origin and the right wall
[in]downThe (signed) distance between the origin and the top wall
[in]upThe (signed) distance between the origin and the bottom wall

Definition at line 39 of file ShearBoxBoundary.cc.

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

40 {
41  velocity_ = velocity;
42  left_ = left;
43  right_ = right;
44  down_ = down;
45  up_ = up;
46 }
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
void ShearBoxBoundary::setVelocity ( std::function< double(double, double)>  velocity)

Definition at line 273 of file ShearBoxBoundary.cc.

References velocity_.

274 {
275  velocity_ = velocity;
276 }
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
void ShearBoxBoundary::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]pA reference to the BaseParticle that has to be shifted
[in]positiveA boolean which determines the direction of the shift NB: TRUE if particle is closest to the left boundary wall

Definition at line 136 of file ShearBoxBoundary.cc.

References BaseInteractable::addVelocity(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseInteractable::getPosition(), DPMBase::getTime(), left_, BaseInteractable::move(), right_, velocity_, and Vec3D::Z.

Referenced by checkBoundaryAfterParticleMoved(), createHorizontalPeriodicParticles(), and createVerticalPeriodicParticles().

137 {
138  Mdouble time = getHandler()->getDPMBase()->getTime();
139  Mdouble z = p->getPosition().Z;
140  if (positive)
141  {
142  p->move(Vec3D(right_ - left_, 0.0, 0.0));
143  p->addVelocity(Vec3D(velocity_(time,z), 0.0, 0.0));
144  } else
145  {
146  p->move(Vec3D(left_ - right_, 0.0, 0.0));
147  p->addVelocity(Vec3D(velocity_(time,z), 0.0, 0.0));
148  }
149 }
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
double Mdouble
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
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:543
Mdouble Z
Definition: Vector.h:52
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Mdouble getTime() const
Access function for the time.
Definition: DPMBase.cc:169
void ShearBoxBoundary::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]pA reference to the BaseParticle that has to be shifted
[in]positiveA boolean which determines the direction of the shift NB: TRUE if particle is closest to the bottom boundary wall

Definition at line 158 of file ShearBoxBoundary.cc.

References down_, BaseInteractable::move(), and up_.

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticles().

159 {
160  if (positive)
161  {
162  p->move(Vec3D(0.0, up_ - down_, 0.0));
163  } else
164  {
165  p->move(Vec3D(0.0, down_ - up_, 0.0));
166  }
167 }
Mdouble up_
(signed) Vertical distance between the bottom 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.
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
void ShearBoxBoundary::write ( std::ostream &  os) const
virtual

Writes all boundary properties to a stream.

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

Parameters
[out]osThe stream to which the parameters are written

Implements BaseBoundary.

Definition at line 64 of file ShearBoxBoundary.cc.

References down_, left_, right_, up_, and BaseBoundary::write().

65 {
67  os<<" left "<<left_<<" right "<<right_<<" down "<<down_<<" up "<<up_;
68 }
void write(std::ostream &os) const =0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject...
Definition: BaseBoundary.cc:76
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Mdouble down_
(signed) Horizontal distance between the right wall and the origin

Member Data Documentation

Mdouble ShearBoxBoundary::down_
private

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

Definition at line 116 of file ShearBoxBoundary.h.

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

Mdouble ShearBoxBoundary::left_
private

Definition at line 114 of file ShearBoxBoundary.h.

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

Mdouble ShearBoxBoundary::right_
private

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

Definition at line 115 of file ShearBoxBoundary.h.

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

Mdouble ShearBoxBoundary::up_
private

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

Definition at line 117 of file ShearBoxBoundary.h.

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

std::function<double (double, double)> ShearBoxBoundary::velocity_
private

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

Definition at line 118 of file ShearBoxBoundary.h.

Referenced by read(), set(), setVelocity(), and shiftHorizontalPosition().


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