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
246 {
247  bool positive;
248  while (getVerticalDistance(*p, positive) < 0)
249  {
250  shiftVerticalPosition(p, positive);
251  }
252  while (getHorizontalDistance(*p, positive) < 0)
253  {
254  shiftHorizontalPosition(p, positive);
255  }
256  return false;
257 }
float * p
Definition: Tutorial_Map_using.cpp:9
Mdouble getVerticalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest vertical wall.
Definition: ShearBoxBoundary.cc:95
void shiftHorizontalPosition(BaseParticle *p, bool positive)
Applies a horizontal shift to the given particle.
Definition: ShearBoxBoundary.cc:118
Mdouble getHorizontalDistance(BaseParticle &p, bool &positive)
Returns distance from given particle to the closest horizontal wall.
Definition: ShearBoxBoundary.cc:73
void shiftVerticalPosition(BaseParticle *p, bool positive)
Applies a vertical shift to the given particle.
Definition: ShearBoxBoundary.cc:141

References getHorizontalDistance(), getVerticalDistance(), p, 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.

63 {
64  return new ShearBoxBoundary(*this);
65 }
Class which creates a boundary with Lees-Edwards type periodic boundary conditions.
Definition: ShearBoxBoundary.h:22

◆ 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
162 {
163  bool positive; // TRUE if the particle is closest to the left boundary
164  // wall (set by getVerticalDistance in the following if-statement)
165  // check if particle is close enough to either of the walls
166  const Mdouble maxDistance = p->getMaxInteractionRadius() + pH.getLargestParticle()->getMaxInteractionRadius();
167  if (getHorizontalDistance(*p, positive) < maxDistance)
168  {
169  // create a periodic copy of the particle
170  BaseParticle* F0 = p->copy();
171  pH.addObject(F0);
173 
174  // If Particle is doubly shifted, get correct original particle
175  BaseParticle* From = p;
176  while (From->getPeriodicFromParticle() != nullptr)
177  From = From->getPeriodicFromParticle();
178  F0->setPeriodicFromParticle(From);
179 
180  // shift the copy to the 'periodic' position
181  shiftHorizontalPosition(F0, positive);
182 
183  // NB: No extra creation of possible vertical copies of the horizontal copy
184  // here (as compared to createVerticalPeriodicParticle), because these would
185  // overlap with the extra creation of horizontal copies in createVerticalPeriodicParticle.
186  }
187 }
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Definition: BaseInteractable.cc:364
Definition: BaseParticle.h:33
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:416
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e....
Definition: BaseParticle.h:345
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:324
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
Definition: ParticleHandler.cc:150
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Definition: ParticleHandler.cc:528

References ParticleHandler::addObject(), BaseInteractable::copyInteractionsForPeriodicParticles(), getHorizontalDistance(), ParticleHandler::getLargestParticle(), BaseParticle::getMaxInteractionRadius(), BaseParticle::getPeriodicFromParticle(), p, 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
235 {
238 }
void createVerticalPeriodicParticle(BaseParticle *p, ParticleHandler &pH)
Creates vertical periodic copies of given particle, if needed.
Definition: ShearBoxBoundary.cc:197
void createHorizontalPeriodicParticle(BaseParticle *p, ParticleHandler &pH)
Creates horizontal periodic copies of given particle, if needed.
Definition: ShearBoxBoundary.cc:161

References createHorizontalPeriodicParticle(), createVerticalPeriodicParticle(), and p.

◆ 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
198 {
199  bool positive; // TRUE if the particle is closest to the bottom boundary
200  // wall (set by getVerticalDistance in the following if-statement)
201  // check if particle is close enough to either of the walls
202  const Mdouble maxDistance = p->getMaxInteractionRadius() + pH.getLargestParticle()->getMaxInteractionRadius();
203  if (getVerticalDistance(*p, positive) < maxDistance)
204  {
205  // create a periodic copy of the particle
206  BaseParticle* F0 = p->copy();
207  pH.addObject(F0);
209 
210  // If Particle is doubly shifted, get correct original particle
211  BaseParticle* From = p;
212  while (From->getPeriodicFromParticle() != nullptr)
213  From = From->getPeriodicFromParticle();
214  F0->setPeriodicFromParticle(From);
215 
216  // shift the copy to the 'periodic' position
217  shiftVerticalPosition(F0, positive);
218  while (getHorizontalDistance(*F0, positive) < 0)
219  {
220  shiftHorizontalPosition(F0, positive);
221  }
222 
223  // Create horizontal periodic copies of the copy particle, if needed (i.e.,
224  // if the original particle is in one of the boundary corners).
226  }
227 }
T * getLastObject()
Gets a pointer to the last Object in this BaseHandler.
Definition: BaseHandler.h:642

References ParticleHandler::addObject(), BaseInteractable::copyInteractionsForPeriodicParticles(), createHorizontalPeriodicParticle(), getHorizontalDistance(), ParticleHandler::getLargestParticle(), BaseHandler< T >::getLastObject(), BaseParticle::getMaxInteractionRadius(), BaseParticle::getPeriodicFromParticle(), getVerticalDistance(), p, 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
74 {
75  Mdouble left = p.getPosition().X - left_;
76  Mdouble right = right_ - p.getPosition().X;
77  if (left < right)
78  {
79  positive = true;
80  return left;
81  }
82  else
83  {
84  positive = false;
85  return right;
86  }
87 }
Mdouble right_
(signed) Horizontal distance between the left wall and the origin
Definition: ShearBoxBoundary.h:94
Mdouble left_
Definition: ShearBoxBoundary.h:93

References left_, p, and right_.

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.

54 {
55  return "ShearBoxBoundary";
56 }

◆ 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
96 {
97  Mdouble down = p.getPosition().Y - down_;
98  Mdouble up = up_ - p.getPosition().Y;
99  if (down < up)
100  {
101  positive = true;
102  return down;
103  }
104  else
105  {
106  positive = false;
107  return up;
108  }
109 }
Mdouble up_
(signed) Vertical distance between the bottom wall and the origin
Definition: ShearBoxBoundary.h:96
Mdouble down_
(signed) Horizontal distance between the right wall and the origin
Definition: ShearBoxBoundary.h:95

References down_, p, and up_.

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.

33 {
34  std::string dummy;
36  is >> dummy >> left_ >> dummy >> right_ >> dummy >> down_ >> dummy >> up_;
37  velocity_ = [](double time UNUSED, double velocity UNUSED) { return 0.0; };
38 }
#define UNUSED
Definition: GeneralDefine.h:18
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:40
std::function< double(double, double)> velocity_
(signed) Vertical distance between the top wall and the origin
Definition: ShearBoxBoundary.h:97
double velocity(const double &t)
Angular velocity as function of time t.
Definition: jeffery_orbit.cc:107
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286

References down_, left_, BaseBoundary::read(), right_, oomph::Global_string_for_annotation::string(), UNUSED, up_, Jeffery_Solution::velocity(), 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
20 {
22  left_ = left;
23  right_ = right;
24  down_ = down;
25  up_ = up;
26 }

References down_, left_, right_, up_, Jeffery_Solution::velocity(), and velocity_.

◆ setVelocity()

void ShearBoxBoundary::setVelocity ( std::function< double(double, double)>  velocity)
260 {
262 }

References Jeffery_Solution::velocity(), and 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
119 {
120  Mdouble time = getHandler()->getDPMBase()->getTime();
121  Mdouble z = p->getPosition().Z;
122  if (positive)
123  {
124  p->move(Vec3D(right_ - left_, 0.0, 0.0));
125  p->addVelocity(Vec3D(velocity_(time, z), 0.0, 0.0));
126  }
127  else
128  {
129  p->move(Vec3D(left_ - right_, 0.0, 0.0));
130  p->addVelocity(Vec3D(velocity_(time, z), 0.0, 0.0));
131  }
132 }
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
Definition: BaseBoundary.cc:122
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:733
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:799
Definition: Kernel/Math/Vector.h:30

References BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), DPMBase::getTime(), left_, p, right_, and velocity_.

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
142 {
143  if (positive)
144  {
145  p->move(Vec3D(0.0, up_ - down_, 0.0));
146  }
147  else
148  {
149  p->move(Vec3D(0.0, down_ - up_, 0.0));
150  }
151 }

References down_, p, 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.

45 {
47  os << " left " << left_ << " right " << right_ << " down " << down_ << " up " << up_;
48 }
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:49

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: