MercuryDPM  Trunk
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 () override
destructor More...

PeriodicBoundarycopy () const override
copy method More...

PeriodicBoundary (const PeriodicBoundary &other)
copy constructor More...

void set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions. More...

void set (Vec3D normal, Vec3D positionLeft, Vec3D positionRight)
As above, but by specifying two positions that the boundaries go through instead of distanceLeft and distanceRight. More...

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

void setPlanewiseShift (Vec3D planewiseShift)
Set the planewise shift (projected onto the planewise direction, and zero by default). 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 override
Returns the distance of the edge to the particle. More...

Mdouble getDistance (const Vec3D &position) const override
Returns the distance of the wall to the position. More...

void shiftPosition (BaseParticle *p) const override
shifts the particle More...

void shiftPosition (Vec3D &p) const

virtual void shiftPositions (Vec3D &postition1, Vec3D &postion2) const
shifts two positions More...

virtual bool isClosestToLeftBoundary (const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'right' edge. More...

bool isClosestToLeftBoundary (const Vec3D &p) const override

reads boundary properties from istream More...

void write (std::ostream &os) const override
writes boundary properties to ostream More...

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

void createPeriodicParticles (ParticleHandler &pH) override
Checks distance of particle to closest wall and creates periodic copy if necessary. More...

void createGhostParticle (BaseParticle *pReal)
Creates and adds a ghost particle from a give real particle. More...

void createPeriodicParticle (BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle. More...

void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
Checks if particle has crossed either boundary wall, and applies a shift if that is the case. More...

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

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

~BasePeriodicBoundary () override
destructor More...

void setPeriodicHandler (PeriodicBoundaryHandler *periodicHandler)
Sets the periodicBoundaryHandler, required for parallel periodic boundaries. More...

PeriodicBoundaryHandlergetPeriodicHandler () const
Returns the periodic boundary handler. More...

void createPeriodicParticles (ParticleHandler &pH) override
Creates periodic ocpies of given particle in case of periodic boundaries in serial build. More...

virtual void modifyPeriodicComplexity (std::vector< int > &complexity, int &totalPeriodicComplexity, BaseParticle *particle, int i) const
Modifies periodic complexity of a particle if necessary (i.e. maser boundary) More...

Actions that need to be performed before adding new ghost particles. More...

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 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

## Protected Attributes

Vec3D normal_
outward unit normal vector for right wall More...

Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_ More...

Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_ 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, and scaleFactor_.

Referenced by copy().

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  logger(DEBUG, "PeriodicBoundary::PeriodicBoundary() finished");
45 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
BasePeriodicBoundary()
default constructor.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
 PeriodicBoundary::~PeriodicBoundary ( )
override

destructor

destructor

Definition at line 50 of file PeriodicBoundary.cc.

References DEBUG, and logger.

51 {
52  logger(DEBUG, "PeriodicBoundary::~PeriodicBoundary() finished");
53 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
 PeriodicBoundary::PeriodicBoundary ( const PeriodicBoundary & other )

copy constructor

Copy constructor

Definition at line 66 of file PeriodicBoundary.cc.

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

67  : BasePeriodicBoundary(other)
68 {
69  normal_ = other.normal_;
70  scaleFactor_ = other.scaleFactor_;
73  shift_ = other.shift_;
74 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
BasePeriodicBoundary()
default constructor.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary

## Member Function Documentation

 void PeriodicBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler & pH )
overridevirtual

Checks if particle has crossed either boundary wall, and applies a shift if that is the case.

Loops through all particles to see if they have become ghosts. If that is the case their position is shifted. Note: This is only for a serial build - periodic particles work different in paralle

Parameters
 [in] param[out] pH the particle handler that contains all particles that need to be checked

Reimplemented from BasePeriodicBoundary.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 426 of file PeriodicBoundary.cc.

427 {
428 #ifdef MERCURY_USE_MPI
429  if (NUMBER_OF_PROCESSORS == 1)
430  {
431 #endif
432  for (auto p = pH.begin(); p != pH.end(); ++p)
433  {
434  if (getDistance((*p)->getPosition()) < 0)
435  {
436  shiftPosition(*p);
438  }
439  }
440 #ifdef MERCURY_USE_MPI
441  }
442 #endif
443 }
void shiftPosition(BaseParticle *p) const override
shifts the particle
const std::vector< T * >::const_iterator end() const
Gets the end of the const_iterator over all BaseBoundary in this BaseHandler.
Definition: BaseHandler.h:704
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
const std::vector< T * >::const_iterator begin() const
Gets the begin of the const_iterator over all Object in this BaseHandler.
Definition: BaseHandler.h:690
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
Vec3D shift_
shift from left to right boundary
static Mdouble getLengthSquared(const Vec3D &a)
Calculates the squared length of a Vec3D: .
Definition: Vector.h:316
virtual void hGridUpdateMove(BaseParticle *, Mdouble)
Definition: DPMBase.cc:1893
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
 PeriodicBoundary * PeriodicBoundary::copy ( ) const
overridevirtual

copy method

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

Implements BasePeriodicBoundary.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 58 of file PeriodicBoundary.cc.

References PeriodicBoundary().

59 {
60  return new PeriodicBoundary(*this);
61 }
PeriodicBoundary()
default constructor
 void PeriodicBoundary::createGhostParticle ( BaseParticle * pReal )

Creates and adds a ghost particle from a give real particle.

Definition at line 366 of file PeriodicBoundary.cc.

367 {
369
370  //Step 1: Copy the particle to new ghost particle.
371  BaseParticle* pGhost = pReal->copy();
372
373  //Step 2: Copy the interactions of the ghost particle.
374  pGhost->copyInteractionsForPeriodicParticles(*pReal);
375
376  //Step 3: Shift the ghost to the 'reflected' location.
377  shiftPosition(pGhost);
378
379  //Step 4: If Particle is double shifted, get correct original particle
380  BaseParticle* from = pReal;
381  while (from->getPeriodicFromParticle() != nullptr)
382  from = from->getPeriodicFromParticle();
383  pGhost->setPeriodicFromParticle(from);
384  pGhost->setPeriodicGhostParticle(true);
385
387 }
void shiftPosition(BaseParticle *p) const override
shifts the particle
Adds a BaseParticle to the ParticleHandler.
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:438
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:338
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorfism.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1329
BoundaryHandler * getHandler() const
Returns the boundary's BoundaryHandler.
void copyInteractionsForPeriodicParticles(const BaseInteractable &p)
Copies interactions to this BaseInteractable whenever a periodic copy made.
Container to store all BaseParticle.
void setPeriodicGhostParticle(bool flag)
Flags the status of the particle to be a ghost in periodic boundary or not.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
 void PeriodicBoundary::createPeriodicParticle ( BaseParticle * p, ParticleHandler & pH )
override

Creates a single periodic particle if required from a given particle.

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] p Particle to be checked and possibly periodically copied [in,out] pH System'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 356 of file PeriodicBoundary.cc.

Referenced by createPeriodicParticles().

357 {
358  //note that getDistance sets closestToLeftBoundary_ to true or false depending on which side is closest
360  if (getDistance(*p) < maxDistance)
361  {
363  }
364 }
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
double Mdouble
Definition: GeneralDefine.h:34
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Definition: BaseParticle.h:359
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a give real particle.
 void PeriodicBoundary::createPeriodicParticles ( ParticleHandler & pH )
override

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] p Particle to be checked and possibly periodically copied [in,out] pH System'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 401 of file PeriodicBoundary.cc.

402 {
403 #ifdef MERCURY_USE_MPI
404  if (NUMBER_OF_PROCESSORS == 1)
405  {
406 #endif
407  unsigned numberOfParticles = pH.getSize();
408
409  for (unsigned i = 0; i < numberOfParticles; i++)
410  {
412  }
413 #ifdef MERCURY_USE_MPI
414  }
415 #endif
416 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
const std::complex< Mdouble > i
Definition: ExtendedMath.h:50
T * getObject(const unsigned int id)
Gets a pointer to the Object at the specified index in the BaseHandler.
Definition: BaseHandler.h:613
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
 Mdouble PeriodicBoundary::getDistance ( const BaseParticle & p ) const
overridevirtual

Returns the distance of the edge to the particle.

Returns the distance to the closest edge 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] p A reference to the particle which distance to the periodic boundary is calculated

Implements BasePeriodicBoundary.

Definition at line 197 of file PeriodicBoundary.cc.

References BaseInteractable::getPosition().

198 {
199  return getDistance(p.getPosition());
200 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
 Mdouble PeriodicBoundary::getDistance ( const Vec3D & position ) const
overridevirtual

Returns the distance of the wall to the position.

Returns the distance to the edge closest to the position

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

Implements BasePeriodicBoundary.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 207 of file PeriodicBoundary.cc.

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

208 {
209  Mdouble distanceFromPlaneThroughOrigin = Vec3D::dot(position, normal_);
210  return std::min(distanceFromPlaneThroughOrigin - distanceLeft_,
211  distanceRight_ - distanceFromPlaneThroughOrigin);
212 }
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
 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 143 of file PeriodicBoundary.cc.

References distanceLeft_.

144 {
145  return distanceLeft_;
146 }
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
 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 151 of file PeriodicBoundary.cc.

References distanceRight_.

152 {
153  return distanceRight_;
154 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
 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.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 339 of file PeriodicBoundary.cc.

340 {
341  return "PeriodicBoundary";
342 }
 Vec3D PeriodicBoundary::getNormal ( ) const

returns the vector normal to the periodic boundary

Returns
The vector perpendicular to the periodic boundary

Definition at line 135 of file PeriodicBoundary.cc.

References normal_.

136 {
137  return normal_;
138 }
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 159 of file PeriodicBoundary.cc.

References shift_.

160 {
161  return shift_;
162 }
Vec3D shift_
shift from left to right boundary
 bool PeriodicBoundary::isClosestToLeftBoundary ( const BaseParticle & p ) const
virtual

Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'right' edge.

Definition at line 275 of file PeriodicBoundary.cc.

References BaseInteractable::getPosition().

Referenced by shiftPosition(), and shiftPositions().

276 {
278 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
 bool PeriodicBoundary::isClosestToLeftBoundary ( const Vec3D & p ) const
overridevirtual

Returns TRUE if position checked is closest to the 'left' edge, and FALSE if it is closest to the 'right' edge`.

Implements BasePeriodicBoundary.

Definition at line 286 of file PeriodicBoundary.cc.

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

287 {
288  const Mdouble distance = Vec3D::dot(p, normal_);
289  return (distanceRight_ - distance > distance - distanceLeft_);
290 }
double Mdouble
Definition: GeneralDefine.h:34
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
 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] distanceLeft The distance (from the origin) to which the left boundary is moved

Definition at line 170 of file PeriodicBoundary.cc.

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

171 {
172  distanceLeft_ = distanceLeft * scaleFactor_;
174 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
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] distanceRight The distance (from the origin) to which the right boundary is moved

Definition at line 182 of file PeriodicBoundary.cc.

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

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

Deprecated:

Definition at line 311 of file PeriodicBoundary.cc.

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

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

Reads the boundary properties from an istream

Parameters
 [in] is the istream

Reimplemented from BasePeriodicBoundary.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 296 of file PeriodicBoundary.cc.

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

297 {
299  std::string dummy;
300  is >> dummy >> normal_
301  >> dummy >> scaleFactor_
302  >> dummy >> distanceLeft_
303  >> dummy >> distanceRight_
304  >> dummy >> shift_;
305 }
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Reads the object's id_ from given istream.
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary
 void PeriodicBoundary::set ( Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight )

Defines a PeriodicBoundary by its normal and positions.

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] normal The normal vector pointing from the left wall into the domain [in] distanceLeft The (signed) distance between the left wall and the origin [in] distanceRight The (signed) distance between the right wall and the origin

Definition at line 84 of file PeriodicBoundary.cc.

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

85 {
86  // factor is used to set normal to unit length
87  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
88  normal_ = normal * scaleFactor_;
89  distanceLeft_ = distanceLeft * scaleFactor_;
90  distanceRight_ = distanceRight * scaleFactor_;
91  logger.assert_always(distanceRight_ > distanceLeft_,
92  "PeriodicBoundary::set: left distance needs to be smaller than right distance");
94 }
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:76
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary
 void PeriodicBoundary::set ( Vec3D normal, Vec3D positionLeft, Vec3D positionRight )

As above, but by specifying two positions that the boundaries go through instead of distanceLeft and distanceRight.

Definition at line 96 of file PeriodicBoundary.cc.

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

97 {
98  set(normal, Vec3D::dot(positionLeft, normal), Vec3D::dot(positionRight, normal));
99 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight)
Defines a PeriodicBoundary by its normal and positions.
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
 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] normal The normal vector pointing from the left wall into the domain [in] distanceLeft The (signed) distance between the left wall and the origin [in] distanceRight The (signed) distance between the right wall and the origin [in] shiftDirection The vector over which particles will be shifted when moving through the PeriodicBoundary

Definition at line 110 of file PeriodicBoundary.cc.

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

111 {
112  // factor is used to set normal to unit length
113  scaleFactor_ = 1. / std::sqrt(Vec3D::dot(normal, normal));
114  normal_ = normal * scaleFactor_;
115  distanceLeft_ = distanceLeft * scaleFactor_;
116  distanceRight_ = distanceRight * scaleFactor_;
117  // factor is used to set shift vector to correct length
118  scaleFactor_ = (distanceRight_ - distanceLeft_) * Vec3D::dot(shiftDirection, normal_);
119  shift_ = shiftDirection * scaleFactor_;
120 }
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:76
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary
 void PeriodicBoundary::setPlanewiseShift ( Vec3D planewiseShift )

Set the planewise shift (projected onto the planewise direction, and zero by default).

Sets the shift_ vector through setting the planewise shift. We delete the component of planewiseShift that is parallel to normal_.

Definition at line 126 of file PeriodicBoundary.cc.

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

127 {
128  planewiseShift -= Vec3D::dot(planewiseShift, normal_) / Vec3D::dot(normal_, normal_) * normal_;
129  shift_ = normal_ * (distanceRight_ - distanceLeft_) + planewiseShift;
130 }
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary
 void PeriodicBoundary::shiftPosition ( BaseParticle * p ) const
overridevirtual

shifts the particle

Parameters
 [in] p A 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] p A pointer to the particle which will be shifted.

Implements BasePeriodicBoundary.

Definition at line 219 of file PeriodicBoundary.cc.

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

220 {
221  if (isClosestToLeftBoundary(*p))
222  {
223  p->move(shift_);
224  }
225  else
226  {
227  p->move(-shift_);
228  }
229 }
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
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::shiftPosition ( Vec3D & p ) const

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

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

Definition at line 236 of file PeriodicBoundary.cc.

References isClosestToLeftBoundary(), and shift_.

237 {
239  {
240  p += shift_;
241  }
242  else
243  {
244  p -= shift_;
245  }
246 }
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
Vec3D shift_
shift from left to right boundary
 void PeriodicBoundary::shiftPositions ( Vec3D & position1, Vec3D & position2 ) const
virtual

shifts two positions

Shifts two given positions by the shift_ vector.

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

Definition at line 255 of file PeriodicBoundary.cc.

References isClosestToLeftBoundary(), and shift_.

256 {
257  if (isClosestToLeftBoundary(position1))
258  {
259  position1 += shift_;
260  position2 += shift_;
261  }
262  else
263  {
264  position1 -= shift_;
265  position2 -= shift_;
266  }
267 }
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns TRUE if particle checked is closest to the 'left' edge, and FALSE if it is closest to the 'ri...
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] os the ostream

Reimplemented from BasePeriodicBoundary.

Reimplemented in SubcriticalMaserBoundaryTEST.

Definition at line 325 of file PeriodicBoundary.cc.

Referenced by SubcriticalMaserBoundaryTEST::write().

326 {
328  os << " normal " << normal_
329  << " scaleFactor " << scaleFactor_
330  << " distanceLeft " << distanceLeft_
331  << " distanceRight " << distanceRight_
332  << " shift " << shift_;
333 }
void write(std::ostream &os) const override
Adds object's id_ to given ostream.
Mdouble scaleFactor_
This is the normal to rescale the normal vector to a unit vectors.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Vec3D normal_
outward unit normal vector for right wall
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D shift_
shift from left to right boundary

## Member Data Documentation

 Mdouble PeriodicBoundary::distanceLeft_
protected

position of left edge, s.t. normal*x = distanceLeft_

Definition at line 202 of file PeriodicBoundary.h.

 Mdouble PeriodicBoundary::distanceRight_
protected

position of right edge, s.t. normal*x = distanceRight_

Definition at line 207 of file PeriodicBoundary.h.

 Vec3D PeriodicBoundary::normal_
protected

outward unit normal vector for right wall

Definition at line 198 of file PeriodicBoundary.h.

 Mdouble PeriodicBoundary::scaleFactor_
protected

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

Definition at line 212 of file PeriodicBoundary.h.