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) override
 Reads all boundary properties from a stream. More...
 
void write (std::ostream &os) const override
 Writes all boundary properties to a stream. More...
 
std::string getName () const override
 Returns the name of the object. More...
 
ShearBoxBoundarycopy () const override
 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 createPeriodicParticle (BaseParticle *p, ParticleHandler &pH) override
 Creates horizontal and vertical periodic copies of given particle, if needed. More...
 
void createHorizontalPeriodicParticle (BaseParticle *p, ParticleHandler &pH)
 Creates horizontal periodic copies of given particle, if needed. More...
 
void createVerticalPeriodicParticle (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...
 
 ~BaseBoundary () override
 destructor More...
 
virtual void createPeriodicParticle (BaseParticle *p UNUSED, ParticleHandler &pH UNUSED)
 Creates a periodic particle in case of periodic boundaries in serial build. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH UNUSED)
 Creates periodic copies of given particle in case of periodic boundaries. More...
 
virtual void checkBoundaryAfterParticlesMove (ParticleHandler &pH)
 Virtual function that does things to particles, each time step after particles have moved. More...
 
virtual void checkBoundaryBeforeTimeStep (DPMBase *md)
 Virtual function that does things before each time step. More...
 
virtual void actionsBeforeTimeLoop ()
 Virtual function that does something after DPMBase::setupInitialConditions but before the first time step. More...
 
virtual void modifyGhostAfterCreation (BaseParticle *particle, int i)
 
virtual void writeVTK (std::fstream &file)
 
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
 Default constructor. More...
 
 BaseObject (const BaseObject &p)=default
 Copy constructor, copies all the objects BaseObject contains. More...
 
virtual ~BaseObject ()=default
 virtual destructor More...
 
virtual void moveInHandler (unsigned int index)
 Except that it is virtual, it does the same thing as setIndex() does. More...
 
void setIndex (unsigned int index)
 Allows one to assign an index to an object in the handler/container. More...
 
void setId (unsigned long 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...
 
void setGroupId (unsigned groupId)
 
unsigned getGroupId () const
 

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.

Member Function Documentation

◆ checkBoundaryAfterParticleMoved()

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
267 {
268  bool positive;
269  while (getVerticalDistance(*p, positive) < 0)
270  {
271  shiftVerticalPosition(p, positive);
272  }
273  while (getHorizontalDistance(*p, positive) < 0)
274  {
275  shiftHorizontalPosition(p, positive);
276  }
277  return false;
278 }
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.
Definition: ShearBoxBoundary.cc:116
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
Definition: ShearBoxBoundary.cc:139
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
Definition: ShearBoxBoundary.cc:94
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
Definition: ShearBoxBoundary.cc:162

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

◆ copy()

ShearBoxBoundary * ShearBoxBoundary::copy ( ) const
overridevirtual

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.

84 {
85  return new ShearBoxBoundary(*this);
86 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: ShearBoxBoundary.h:43

◆ createHorizontalPeriodicParticle()

void ShearBoxBoundary::createHorizontalPeriodicParticle ( 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
183 {
184  bool positive; // TRUE if the particle is closest to the left boundary
185  // wall (set by getVerticalDistance in the following if-statement)
186  // check if particle is close enough to either of the walls
188  if (getHorizontalDistance(*p, positive) < maxDistance)
189  {
190  // create a periodic copy of the particle
191  BaseParticle* F0 = p->copy();
192  pH.addObject(F0);
194 
195  // If Particle is doubly shifted, get correct original particle
196  BaseParticle* From = p;
197  while (From->getPeriodicFromParticle() != nullptr)
198  From = From->getPeriodicFromParticle();
199  F0->setPeriodicFromParticle(From);
200 
201  // shift the copy to the 'periodic' position
202  shiftHorizontalPosition(F0, positive);
203 
204  // NB: No extra creation of possible vertical copies of the horizontal copy
205  // here (as compared to createVerticalPeriodicParticle), because these would
206  // overlap with the extra creation of horizontal copies in createVerticalPeriodicParticle.
207  }
208 }
double Mdouble
Definition: GeneralDefine.h:34
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Definition: BaseInteractable.cc:386
Definition: BaseParticle.h:54
void setPeriodicFromParticle(BaseParticle *p)
Assigns the pointer to the 'original' particle this one's a periodic copy of (used in periodic bounda...
Definition: BaseParticle.h:441
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:362
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:171
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:534

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

Referenced by createPeriodicParticle(), and createVerticalPeriodicParticle().

◆ createPeriodicParticle()

void ShearBoxBoundary::createPeriodicParticle ( BaseParticle p,
ParticleHandler pH 
)
override

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
256 {
259 }
void createVerticalPeriodicParticle(BaseParticle *p, ParticleHandler &pH)
Creates vertical periodic copies of given particle, if needed.
Definition: ShearBoxBoundary.cc:218
void createHorizontalPeriodicParticle(BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed.
Definition: ShearBoxBoundary.cc:182

References createHorizontalPeriodicParticle(), and createVerticalPeriodicParticle().

◆ createVerticalPeriodicParticle()

void ShearBoxBoundary::createVerticalPeriodicParticle ( 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
219 {
220  bool positive; // TRUE if the particle is closest to the bottom boundary
221  // wall (set by getVerticalDistance in the following if-statement)
222  // check if particle is close enough to either of the walls
224  if (getVerticalDistance(*p, positive) < maxDistance)
225  {
226  // create a periodic copy of the particle
227  BaseParticle* F0 = p->copy();
228  pH.addObject(F0);
230 
231  // If Particle is doubly shifted, get correct original particle
232  BaseParticle* From = p;
233  while (From->getPeriodicFromParticle() != nullptr)
234  From = From->getPeriodicFromParticle();
235  F0->setPeriodicFromParticle(From);
236 
237  // shift the copy to the 'periodic' position
238  shiftVerticalPosition(F0, positive);
239  while (getHorizontalDistance(*F0, positive) < 0)
240  {
241  shiftHorizontalPosition(F0, positive);
242  }
243 
244  // Create horizontal periodic copies of the copy particle, if needed (i.e.,
245  // if the original particle is in one of the boundary corners).
247  }
248 }
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:634

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

Referenced by createPeriodicParticle().

◆ getHorizontalDistance()

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
95 {
96  Mdouble left = p.getPosition().X - left_;
97  Mdouble right = right_ - p.getPosition().X;
98  if (left < right)
99  {
100  positive = true;
101  return left;
102  }
103  else
104  {
105  positive = false;
106  return right;
107  }
108 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Definition: BaseInteractable.h:218
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Definition: ShearBoxBoundary.h:115
Mdouble left_
Definition: ShearBoxBoundary.h:114
Mdouble X
the vector components
Definition: Vector.h:66

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

Referenced by checkBoundaryAfterParticleMoved(), createHorizontalPeriodicParticle(), and createVerticalPeriodicParticle().

◆ getName()

std::string ShearBoxBoundary::getName ( ) const
overridevirtual

Returns the name of the object.

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

Implements BaseObject.

75 {
76  return "ShearBoxBoundary";
77 }

◆ getVerticalDistance()

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
117 {
118  Mdouble down = p.getPosition().Y - down_;
119  Mdouble up = up_ - p.getPosition().Y;
120  if (down < up)
121  {
122  positive = true;
123  return down;
124  }
125  else
126  {
127  positive = false;
128  return up;
129  }
130 }
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Definition: ShearBoxBoundary.h:117
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Definition: ShearBoxBoundary.h:116
Mdouble Y
Definition: Vector.h:66

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

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticle().

◆ read()

void ShearBoxBoundary::read ( std::istream &  is)
overridevirtual

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.

54 {
55  std::string dummy;
57  is >> dummy >> left_ >> dummy >> right_ >> dummy >> down_ >> dummy >> up_;
58  velocity_ = [](double time UNUSED, double velocity UNUSED) { return 0.0; };
59 }
#define UNUSED
Definition: GeneralDefine.h:39
void read(std::istream &is) override=0
Reads the object's id_ from given istream NB: purely virtual function, overriding the version of Base...
Definition: BaseBoundary.cc:61
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
Definition: ShearBoxBoundary.h:118

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

◆ set()

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
41 {
42  velocity_ = velocity;
43  left_ = left;
44  right_ = right;
45  down_ = down;
46  up_ = up;
47 }

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

◆ setVelocity()

void ShearBoxBoundary::setVelocity ( std::function< double(double, double)>  velocity)
281 {
282  velocity_ = velocity;
283 }

References velocity_.

◆ shiftHorizontalPosition()

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
140 {
141  Mdouble time = getHandler()->getDPMBase()->getTime();
142  Mdouble z = p->getPosition().Z;
143  if (positive)
144  {
145  p->move(Vec3D(right_ - left_, 0.0, 0.0));
146  p->addVelocity(Vec3D(velocity_(time, z), 0.0, 0.0));
147  }
148  else
149  {
150  p->move(Vec3D(left_ - right_, 0.0, 0.0));
151  p->addVelocity(Vec3D(velocity_(time, z), 0.0, 0.0));
152  }
153 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:143
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
Definition: BaseInteractable.h:312
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
Definition: BaseInteractable.cc:215
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:808
Definition: Vector.h:51
Mdouble Z
Definition: Vector.h:66

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

Referenced by checkBoundaryAfterParticleMoved(), createHorizontalPeriodicParticle(), and createVerticalPeriodicParticle().

◆ shiftVerticalPosition()

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
163 {
164  if (positive)
165  {
166  p->move(Vec3D(0.0, up_ - down_, 0.0));
167  }
168  else
169  {
170  p->move(Vec3D(0.0, down_ - up_, 0.0));
171  }
172 }

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

Referenced by checkBoundaryAfterParticleMoved(), and createVerticalPeriodicParticle().

◆ write()

void ShearBoxBoundary::write ( std::ostream &  os) const
overridevirtual

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.

66 {
68  os << " left " << left_ << " right " << right_ << " down " << down_ << " up " << up_;
69 }
void write(std::ostream &os) const override=0
Adds object's id_ to given ostream NB: purely virtual function, overriding the version of BaseObject.
Definition: BaseBoundary.cc:70

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

Member Data Documentation

◆ down_

Mdouble ShearBoxBoundary::down_
private

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

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

◆ left_

Mdouble ShearBoxBoundary::left_
private

◆ right_

Mdouble ShearBoxBoundary::right_
private

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

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

◆ up_

Mdouble ShearBoxBoundary::up_
private

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

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

◆ velocity_

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

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

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


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