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

Defines a pair of periodic walls. Inherits from BaseBoundary. More...

#include <PeriodicBoundary.h>

+ Inheritance diagram for PeriodicBoundary:

Public Member Functions

 PeriodicBoundary ()
 default constructor More...
 
 ~PeriodicBoundary ()
 destructor More...
 
PeriodicBoundarycopy () const override
 copy method More...
 
void set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
 Defines a periodic wall. More...
 
void set (Vec3D normal, Vec3D positionLeft, Vec3D positionRight)
 
void set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, Vec3D shiftDirection)
 For general parallelogramic domains, the direction of the shift vector can to be set manually. More...
 
Vec3D getNormal () const
 returns the vector normal to the periodic boundary More...
 
Mdouble getDistanceLeft () const
 Returns the distance of the left wall to the origin, in normal direction. More...
 
Mdouble getDistanceRight () const
 Returns the distance of the right wall to the origin, in normal direction. More...
 
Vec3D getShift () const
 Returns the vector going from the left to the right side of the periodic boundary. More...
 
void moveLeft (Mdouble distanceLeft)
 Sets the distance from the origin of the 'left' periodic wall. More...
 
void moveRight (Mdouble distanceRight)
 Sets the distance from the origin of the 'right' periodic wall. More...
 
Mdouble getDistance (const BaseParticle &p) const
 Returns the distance of the wall to the particle. More...
 
Mdouble getDistance (const Vec3D &position) const
 Returns the distance of the wall to the position. More...
 
void shiftPosition (BaseParticle *p) const
 shifts the particle More...
 
void shiftPositions (Vec3D &postition1, Vec3D &postion2) const
 shifts two positions More...
 
bool isClosestToLeftBoundary (const BaseParticle &p) const
 Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is closest to the 'right' wall. More...
 
bool isClosestToLeftBoundary (const Vec3D &p) const
 
void read (std::istream &is) override
 reads boundary properties from istream More...
 
MERCURY_DEPRECATED void oldRead (std::istream &is)
 deprecated version of CubeInsertionBoundary::read(). More...
 
void write (std::ostream &os) const override
 writes boundary properties to ostream More...
 
virtual std::string getName () const override
 Returns the name of the object. More...
 
void createPeriodicParticles (BaseParticle *p, ParticleHandler &pH)
 Checks distance of particle to closest wall and creates periodic copy if necessary. More...
 
bool checkBoundaryAfterParticleMoved (BaseParticle *p, ParticleHandler &pH UNUSED)
 Checks if particle has crossed either boundary wall, and applies a shift if that is the case. NB: ALWAYS returns FALSE. 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

Vec3D normal_
 outward unit normal vector for right wall More...
 
Mdouble distanceLeft_
 position of left wall, s.t. normal*x=position_left More...
 
Mdouble distanceRight_
 position of right wall, s.t. normal*x=position_right More...
 
Mdouble scaleFactor_
 This is the normal to rescale the normal vector to a unit vectors. More...
 
Vec3D shift_
 shift from left to right boundary More...
 

Detailed Description

Defines a pair of periodic walls. Inherits from BaseBoundary.

The particles are in {x: position_left<=normal*x <position_right}, with normal being the outward unit normal vector of the right wall. If a particle moves outside these boundaries, it will be shifted.

Definition at line 41 of file PeriodicBoundary.h.

Constructor & Destructor Documentation

PeriodicBoundary::PeriodicBoundary ( )

default constructor

constructor

Definition at line 37 of file PeriodicBoundary.cc.

References DEBUG, distanceLeft_, distanceRight_, logger, scaleFactor_, and WARN.

Referenced by copy().

38  : BaseBoundary()
39 {
40  distanceLeft_ = std::numeric_limits<double>::quiet_NaN();
41  distanceRight_ = std::numeric_limits<double>::quiet_NaN();
42  scaleFactor_ = std::numeric_limits<double>::quiet_NaN();
43 
44 #ifdef MERCURY_USE_MPI
45  MPIContainer& communicator = MPIContainer::Instance();
46  if (communicator.getNumberOfProcessors() > 1)
47  {
48  logger(WARN,"PeriodicBoundaries are currently not implemented in parallel MercuryDPM");
49  }
50 #endif
51  logger(DEBUG, "PeriodicBoundary::PeriodicBoundary() finished");
52  logger(DEBUG, "PeriodicBoundary::PeriodicBoundary() finished");
53 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
BaseBoundary()
default constructor.
Definition: BaseBoundary.cc:32
PeriodicBoundary::~PeriodicBoundary ( )

destructor

destructor

Definition at line 58 of file PeriodicBoundary.cc.

References DEBUG, and logger.

59 {
60  logger(DEBUG, "PeriodicBoundary::~PeriodicBoundary() finished");
61 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")

Member Function Documentation

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

Checks if particle has crossed either boundary wall, and applies a shift if that is the case. NB: ALWAYS returns FALSE.

Checks whether given particle has crossed the closest wall, and if so, shifts its position so as to have it appear at the other wall

Parameters
[in]pThe particle to be checked and possibly shifted
pHThe ParticleHandler, which is unused in this implementation
Returns
ALWAYS returns FALSE for periodic boundaries. Only returns TRUE when particle gets actually deleted, e.g. in certain DeletionBoundary implementations.

Definition at line 391 of file PeriodicBoundary.cc.

References getDistance(), and shiftPosition().

392 {
393  if (getDistance(*p) < 0)
394  {
395  shiftPosition(p);
396  }
397  return false;
398 }
Mdouble getDistance(const BaseParticle &p) const
Returns the distance of the wall to the particle.
void shiftPosition(BaseParticle *p) const
shifts the particle
PeriodicBoundary * PeriodicBoundary::copy ( ) const
overridevirtual

copy method

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

Implements BaseBoundary.

Definition at line 66 of file PeriodicBoundary.cc.

References PeriodicBoundary().

67 {
68  return new PeriodicBoundary(*this);
69 }
PeriodicBoundary()
default constructor
void PeriodicBoundary::createPeriodicParticles ( BaseParticle p,
ParticleHandler pH 
)

Checks distance of particle to closest wall and creates periodic copy if necessary.

Checks the distance of given particle to the closest of both periodic walls, and creates a periodic copy of the particle if needed (i.e. if the particle is closer to the periodic wall than the radius of the largest particle in the system).

Parameters
[in]pParticle to be checked and possibly periodically copied
[in,out]pHSystem's ParticleHandler, (1) from which the interaction radius of its largest particle is retrieved to determine the maximum distance from the wall at which a particle should still have a periodic copy created, and (2) to which a possible periodic copy of the particle will be added

Definition at line 358 of file PeriodicBoundary.cc.

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

359 {
360  //note that getDistance sets closestToLeftBoundary_ to true or false depending on which side is closest
362  {
363  //Step 1: Copy the particle to new ghost particle.
364  BaseParticle* pGhost = p->copy();
365 
366  //Step 2: Copy the interactions of the ghost particle.
368 
369  //Step 3: Shift the ghost to the 'reflected' location.
370  shiftPosition(pGhost);
371 
372  //Step 4: If Particle is double shifted, get correct original particle
373  BaseParticle* from = p;
374  while (from->getPeriodicFromParticle() != nullptr)
375  from = from->getPeriodicFromParticle();
376  pGhost->setPeriodicFromParticle(from);
377 
378  pH.addObject(pGhost);
379  }
380 }
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.
Mdouble getDistance(const BaseParticle &p) const
Returns the distance of the wall to the particle.
virtual void addObject(BaseParticle *P)
Adds a BaseParticle to the ParticleHandler.
void shiftPosition(BaseParticle *p) const
shifts the particle
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.
Mdouble PeriodicBoundary::getDistance ( const BaseParticle p) const

Returns the distance of the wall to the particle.

Returns the distance to the closest wall of the boundary to the particle. Since this function should be called before calculating any Particle-Wall interactions, it can also be used to set the shift vector in case of curved walls. Positive means that the particle is insid-> the periodic domain, negative means that it is outsid-> the periodic domain.

Parameters
[in]pA reference to the particle which distance to the periodic boundary is calculated

Definition at line 182 of file PeriodicBoundary.cc.

References BaseInteractable::getPosition().

Referenced by checkBoundaryAfterParticleMoved(), DPMBase::checkParticleForInteractionLocalPeriodic(), and createPeriodicParticles().

183 {
184  return getDistance(p.getPosition());
185 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble getDistance(const BaseParticle &p) const
Returns the distance of the wall to the particle.
Mdouble PeriodicBoundary::getDistance ( const Vec3D position) const

Returns the distance of the wall to the position.

Returns the distance to the wall closest to the position

Parameters
[in]positionA reference to the position which distance to the periodic boundary is to be calculated

Definition at line 192 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), and normal_.

193 {
194  Mdouble distanceFromPlaneThroughOrigin = Vec3D::dot(position, normal_);
195  return std::min(distanceFromPlaneThroughOrigin - distanceLeft_, distanceRight_ - distanceFromPlaneThroughOrigin);
196 }
double Mdouble
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:167
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Mdouble PeriodicBoundary::getDistanceLeft ( ) const

Returns the distance of the left wall to the origin, in normal direction.

Returns
The distance of the left wall to the origin, in normal direction

Definition at line 128 of file PeriodicBoundary.cc.

References distanceLeft_.

129 {
130  return distanceLeft_;
131 }
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Mdouble PeriodicBoundary::getDistanceRight ( ) const

Returns the distance of the right wall to the origin, in normal direction.

Returns
The distance of the left wall to the origin, in normal direction

Definition at line 136 of file PeriodicBoundary.cc.

References distanceRight_.

137 {
138  return distanceRight_;
139 }
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
std::string PeriodicBoundary::getName ( ) const
overridevirtual

Returns the name of the object.

Returns the name of the object class

Returns
the object's class' name, i.e. 'CubeInsertionBoundary'

Implements BaseObject.

Definition at line 334 of file PeriodicBoundary.cc.

335 {
336  return "PeriodicBoundary";
337 }
Vec3D PeriodicBoundary::getNormal ( ) const

returns the vector normal to the periodic boundary

Returns
The vector perpendicular to the periodic boundary

Definition at line 120 of file PeriodicBoundary.cc.

References normal_.

121 {
122  return normal_;
123 }
Vec3D normal_
outward unit normal vector for right wall
Vec3D PeriodicBoundary::getShift ( ) const

Returns the vector going from the left to the right side of the periodic boundary.

Returns
The vector going from the left to the right sid-> of the periodic boundary

Definition at line 144 of file PeriodicBoundary.cc.

References shift_.

145 {
146  return shift_;
147 }
Vec3D shift_
shift from left to right boundary
bool PeriodicBoundary::isClosestToLeftBoundary ( const BaseParticle p) const

Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is closest to the 'right' wall.

Definition at line 254 of file PeriodicBoundary.cc.

References BaseInteractable::getPosition().

Referenced by shiftPosition(), and shiftPositions().

255 {
257 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is clos...
bool PeriodicBoundary::isClosestToLeftBoundary ( const Vec3D p) const

Definition at line 264 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), and normal_.

265 {
266  const Mdouble distance = Vec3D::dot(p, normal_);
267  return (distanceRight_ - distance > distance - distanceLeft_);
268 }
double Mdouble
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:167
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
void PeriodicBoundary::moveLeft ( Mdouble  distanceLeft)

Sets the distance from the origin of the 'left' periodic wall.

Allows the left periodic boundary to be moved to a new position and automatically changes its shift value

Parameters
[in]distanceLeftThe distance (from the origin) to which the left boundary is moved

Definition at line 155 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, scaleFactor_, and shift_.

156 {
157  distanceLeft_ = distanceLeft * scaleFactor_;
159 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::moveRight ( Mdouble  distanceRight)

Sets the distance from the origin of the 'right' periodic wall.

Allows the right periodic wall to be moved to a new position and automatically changes its shift value

Parameters
[in]distanceRightThe distance (from the origin) to which the right boundary is moved

Definition at line 167 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, scaleFactor_, and shift_.

168 {
169  distanceRight_ = distanceRight * scaleFactor_;
171 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::oldRead ( std::istream &  is)

deprecated version of CubeInsertionBoundary::read().

Deprecated version of read().

Deprecated:
Should be gone by Mercury 2.0. Instead, use CubeInsertionBoundary::read().

Definition at line 306 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, scaleFactor_, and shift_.

307 {
308  std::string dummy;
309  is >> dummy >> normal_
310  >> dummy >> scaleFactor_
311  >> dummy >> distanceLeft_
312  >> dummy >> distanceRight_
313  >> dummy >> shift_;
314 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::read ( std::istream &  is)
overridevirtual

reads boundary properties from istream

Reads the boundary properties from an istream

Parameters
[in]isthe istream

Implements BaseBoundary.

Definition at line 291 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, BaseBoundary::read(), scaleFactor_, and shift_.

292 {
293  BaseBoundary::read(is);
294  std::string dummy;
295  is >> dummy >> normal_
296  >> dummy >> scaleFactor_
297  >> dummy >> distanceLeft_
298  >> dummy >> distanceRight_
299  >> dummy >> shift_;
300 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
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 PeriodicBoundary::set ( Vec3D  normal,
Mdouble  distanceLeft,
Mdouble  distanceRight 
)

Defines a periodic wall.

Defines the boundary, given a normal vector such that all particles are within {x: position_left<=normal*x<position_right}. The shift vector is set assuming that the domain is rectangular (shift parallel to normal).

Parameters
[in]normalThe normal vector pointing from the left wall into the domain
[in]distanceLeftThe (signed) distance between the left wall and the origin
[in]distanceRightThe (signed) distance between the right wall and the origin

Definition at line 79 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), logger, normal_, scaleFactor_, and shift_.

Referenced by BoundaryHandler::readOldObject(), DPMBase::readParAndIniFiles(), set(), ChuteBottom::setupInitialConditions(), and Chute::setupSideWalls().

80 {
81  // factor is used to set normal to unit length
82  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
83  normal_ = normal * scaleFactor_;
84  distanceLeft_ = distanceLeft * scaleFactor_;
85  distanceRight_ = distanceRight * scaleFactor_;
86  logger.assert_always(distanceRight_ > distanceLeft_,
87  "PeriodicBoundary::set: left distance needs to be smaller than right distance");
89 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:167
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::set ( Vec3D  normal,
Vec3D  positionLeft,
Vec3D  positionRight 
)

Definition at line 91 of file PeriodicBoundary.cc.

References Vec3D::dot(), and set().

92 {
93  set(normal, Vec3D::dot(positionLeft,normal), Vec3D::dot(positionRight,normal));
94 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a periodic wall.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:167
void PeriodicBoundary::set ( Vec3D  normal,
Mdouble  distanceLeft,
Mdouble  distanceRight,
Vec3D  shiftDirection 
)

For general parallelogramic domains, the direction of the shift vector can to be set manually.

like PeriodicBoundary::set(normal, distanceLeft, distanceRight), but including the possibility of setting the shift direction vector.

Parameters
[in]normalThe normal vector pointing from the left wall into the domain
[in]distanceLeftThe (signed) distance between the left wall and the origin
[in]distanceRightThe (signed) distance between the right wall and the origin
[in]shiftDirectionThe vector over which particles will be shifted when moving through the PeriodicBoundary

Definition at line 105 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, Vec3D::dot(), normal_, scaleFactor_, and shift_.

106 {
107  // factor is used to set normal to unit length
108  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
109  normal_ = normal * scaleFactor_;
110  distanceLeft_ = distanceLeft * scaleFactor_;
111  distanceRight_ = distanceRight * scaleFactor_;
112  // factor is used to set shift vector to correct length
113  scaleFactor_ = (distanceRight_ - distanceLeft_) * Vec3D::dot(shiftDirection, normal_);
114  shift_ = shiftDirection * scaleFactor_;
115 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:167
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::shiftPosition ( BaseParticle p) const

shifts the particle

Parameters
[in]pA pointer to the particle which will be shifted.

Shifts the particle either to the left or right, using the method isClosestToLeftBoundary to determine which sid-> it should be shifted to.

Parameters
[in]pA pointer to the particle which will be shifted.

Definition at line 203 of file PeriodicBoundary.cc.

References isClosestToLeftBoundary(), BaseInteractable::move(), and shift_.

Referenced by checkBoundaryAfterParticleMoved(), DPMBase::checkParticleForInteractionLocalPeriodic(), and createPeriodicParticles().

204 {
205  if (isClosestToLeftBoundary(*p))
206  {
207  p->move(shift_);
208  }
209  else
210  {
211  p->move(-shift_);
212  }
213 }
bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is clos...
Vec3D shift_
shift from left to right boundary
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
void PeriodicBoundary::shiftPositions ( Vec3D position1,
Vec3D position2 
) const

shifts two positions

Shifts two given positions by the shift_ vector.

Parameters
[in]position1The first position to be shifted
[in]position2The second position to be shifted
Todo:
(AT) see toDo of PeriodicBoundary::shiftPosition().

Definition at line 235 of file PeriodicBoundary.cc.

References isClosestToLeftBoundary(), and shift_.

236 {
237  if (isClosestToLeftBoundary(position1))
238  {
239  position1 += shift_;
240  position2 += shift_;
241  }
242  else
243  {
244  position1 -= shift_;
245  position2 -= shift_;
246  }
247 }
bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if last particle/position checked is closest to the 'left' wall, and FALSE if it is clos...
Vec3D shift_
shift from left to right boundary
void PeriodicBoundary::write ( std::ostream &  os) const
overridevirtual

writes boundary properties to ostream

Writes boundary's properties to an ostream

Parameters
[in]osthe ostream

Implements BaseBoundary.

Definition at line 320 of file PeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, scaleFactor_, shift_, and BaseBoundary::write().

321 {
323  os << " normal " << normal_
324  << " scaleFactor " << scaleFactor_
325  << " distanceLeft " << distanceLeft_
326  << " distanceRight " << distanceRight_
327  << " shift " << shift_;
328 }
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 scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right wall, s.t. normal*x=position_right
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left wall, s.t. normal*x=position_left
Vec3D shift_
shift from left to right boundary

Member Data Documentation

Mdouble PeriodicBoundary::distanceLeft_
private

position of left wall, s.t. normal*x=position_left

Definition at line 185 of file PeriodicBoundary.h.

Referenced by getDistance(), getDistanceLeft(), isClosestToLeftBoundary(), moveLeft(), moveRight(), oldRead(), PeriodicBoundary(), read(), set(), and write().

Mdouble PeriodicBoundary::distanceRight_
private

position of right wall, s.t. normal*x=position_right

Definition at line 189 of file PeriodicBoundary.h.

Referenced by getDistance(), getDistanceRight(), isClosestToLeftBoundary(), moveLeft(), moveRight(), oldRead(), PeriodicBoundary(), read(), set(), and write().

Vec3D PeriodicBoundary::normal_
private

outward unit normal vector for right wall

Definition at line 181 of file PeriodicBoundary.h.

Referenced by getDistance(), getNormal(), isClosestToLeftBoundary(), moveLeft(), moveRight(), oldRead(), read(), set(), and write().

Mdouble PeriodicBoundary::scaleFactor_
private

This is the normal to rescale the normal vector to a unit vectors.

Definition at line 193 of file PeriodicBoundary.h.

Referenced by moveLeft(), moveRight(), oldRead(), PeriodicBoundary(), read(), set(), and write().

Vec3D PeriodicBoundary::shift_
private

shift from left to right boundary

Definition at line 197 of file PeriodicBoundary.h.

Referenced by getShift(), moveLeft(), moveRight(), oldRead(), read(), set(), shiftPosition(), shiftPositions(), and write().


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