MercuryDPM  Trunk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
TimeDependentPeriodicBoundary Class Reference

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

#include <TimeDependentPeriodicBoundary.h>

+ Inheritance diagram for TimeDependentPeriodicBoundary:

Public Member Functions

 TimeDependentPeriodicBoundary ()
 default constructor More...
 
 ~TimeDependentPeriodicBoundary ()
 destructor More...
 
TimeDependentPeriodicBoundarycopy () const override
 copy method More...
 
 TimeDependentPeriodicBoundary (const TimeDependentPeriodicBoundary &other)
 copy constructor More...
 
void set (Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, std::function< Vec3D(Mdouble)> planewiseShift, std::function< Vec3D(Mdouble)> boost)
 Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting that it does (projected onto the planewise direction) More...
 
void set (Vec3D normal, Vec3D positionLeft, Vec3D positionRight, std::function< Vec3D(Mdouble)> shift, std::function< Vec3D(Mdouble)> boost)
 As above, but by specifying two positions that the boundaries go through instead of distanceLeft and distanceRight. More...
 
void setPlanewiseShiftAndBoost (std::function< Vec3D(Mdouble)> shift, std::function< Vec3D(Mdouble)> boost)
 Set the planewise shift and boost (projected onto the planewise direction) as functions of time. (Boost should be the derivative of shift) More...
 
void setMaxShift (Mdouble maxShift)
 Set the maximum shift (will take fmod w.r.t. this) 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 (Mdouble time) const
 Returns the vector going from the left to the right side of the periodic boundary. More...
 
Vec3D getPlanewiseShift (Mdouble time) const
 Returns the planewise shift as a function of time. More...
 
Vec3D getBoost (Mdouble time) const
 Returns the planewise boost as a function of time. 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 edge to the position. More...
 
virtual void shiftPosition (BaseParticle *p) const override
 shifts and boosts the particle More...
 
virtual void shiftAndBoostParticle (BaseParticle *p, Mdouble time) const
 
virtual void shiftPositions (Vec3D &position1, Vec3D &position2) const
 shifts two positions (JMFT: Why, what is this for?) More...
 
virtual bool isClosestToLeftBoundary (const BaseParticle &p) const
 Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'right' edge. More...
 
virtual bool isClosestToLeftBoundary (const Vec3D &p) const override
 Returns true if position checked is closer to the 'left' edge, and false if it is closer to the 'right' edge. More...
 
virtual void createPeriodicParticles (ParticleHandler &pH) override
 Checks distance of particle to closer edge and creates a periodic copy if necessary. More...
 
void createGhostParticle (BaseParticle *pReal)
 Creates and adds a ghost particle from a given real particle. More...
 
void createPeriodicParticle (BaseParticle *p, ParticleHandler &pH) override
 Creates a single periodic particle if required from a given particle. More...
 
virtual void checkBoundaryAfterParticlesMove (ParticleHandler &pH) override
 Loops over particles, checks if each particle has crossed either boundary edge, and applies a shift if that is the case. More...
 
virtual void read (std::istream &is) override
 reads boundary properties from istream More...
 
virtual 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...
 
- 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...
 
virtual void performActionsBeforeAddingParticles ()
 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 edge 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...
 
std::function< Vec3D(Mdouble)> planewiseShift_
 shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(time) + normal * (distanceRight_ - distanceLeft_) More...
 
std::function< Vec3D(Mdouble)> boost_
 boost from the left to right boundary More...
 
Mdouble maxShift_
 Maximum shifting (will take fmod(shift, maxshift) ) More...
 

Detailed Description

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

A TimeDependentPeriodicBoundary is like a PeriodicBoundary, but, when a particle crosses an edge,

  • it is shifted as well as being copied
  • it is given a boost

In general, the shift and the boost may depend on time in an arbitrary way. They are to be specified as std::function<Mdouble (Mdouble)>.

This sort of boundary is useful for studying shear flows.

See also Lees and Edwards (J. Phys. C 1921, doi:1088/0022-3719/5/15/006). Inherits from BaseBoundary.

Todo:

Add link to paper by Lees-Edwards in the documentation of this class.

Is implemented for 2D only now. Needs extension to 3D.

Definition at line 53 of file TimeDependentPeriodicBoundary.h.

Constructor & Destructor Documentation

TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary ( )

default constructor

constructor

Definition at line 37 of file TimeDependentPeriodicBoundary.cc.

References DEBUG, distanceLeft_, distanceRight_, MPIContainer::getNumberOfProcessors(), MPIContainer::Instance(), logger, maxShift_, and WARN.

Referenced by copy().

39 {
40  distanceLeft_ = std::numeric_limits<double>::quiet_NaN();
41  distanceRight_ = std::numeric_limits<double>::quiet_NaN();
42  maxShift_ = 0;
43 
44 
45 #ifdef MERCURY_USE_MPI
46  MPIContainer& communicator = MPIContainer::Instance();
47  if (communicator.getNumberOfProcessors() > 1)
48  {
49  logger(WARN,"LeesEdwardsBoundaries are currently not implemented in parallel MercuryDPM");
50  }
51 #endif
52  logger(DEBUG, "TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary() finished");
53 }
This class contains all information and functions required for communication between processors...
Definition: MpiContainer.h:129
static MPIContainer & Instance()
fetch the instance to be used for communication
Definition: MpiContainer.h:134
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
std::size_t getNumberOfProcessors() const
Get the total number of processors participating in this simulation.
BasePeriodicBoundary()
default constructor.
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary ( )

destructor

destructor

Definition at line 58 of file TimeDependentPeriodicBoundary.cc.

References DEBUG, and logger.

59 {
60  logger(DEBUG, "TimeDependentPeriodicBoundary::~TimeDependentPeriodicBoundary() finished");
61 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
TimeDependentPeriodicBoundary::TimeDependentPeriodicBoundary ( const TimeDependentPeriodicBoundary other)

copy constructor

Copy constructor

Definition at line 74 of file TimeDependentPeriodicBoundary.cc.

References boost_, distanceLeft_, distanceRight_, maxShift_, normal_, and planewiseShift_.

75 {
76  normal_ = other.normal_;
80  boost_ = other.boost_;
81  maxShift_ = other.maxShift_;
82 
83 }
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Vec3D normal_
outward unit normal vector for right edge

Member Function Documentation

void TimeDependentPeriodicBoundary::checkBoundaryAfterParticlesMove ( ParticleHandler pH)
overridevirtual

Loops over particles, checks if each particle has crossed either boundary edge, 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.

Definition at line 319 of file TimeDependentPeriodicBoundary.cc.

References BaseHandler< T >::begin(), BaseHandler< T >::end(), getDistance(), BaseHandler< T >::getDPMBase(), DPMBase::getTime(), NUMBER_OF_PROCESSORS, and shiftAndBoostParticle().

320 {
321 #ifdef MERCURY_USE_MPI
322  if (NUMBER_OF_PROCESSORS == 1)
323  {
324 #endif
325  for (auto p = pH.begin(); p != pH.end(); ++p)
326  {
327  if (getDistance((*p)->getPosition()) < 0)
328  {
330  }
331  }
332 #ifdef MERCURY_USE_MPI
333  }
334 #endif
335 }
virtual void shiftAndBoostParticle(BaseParticle *p, Mdouble time) const
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
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
#define NUMBER_OF_PROCESSORS
For the MPI communication routines this quantity is often required. defining this macro makes the cod...
Definition: GeneralDefine.h:62
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:805
TimeDependentPeriodicBoundary * TimeDependentPeriodicBoundary::copy ( ) const
overridevirtual

copy method

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

Implements BasePeriodicBoundary.

Definition at line 66 of file TimeDependentPeriodicBoundary.cc.

References TimeDependentPeriodicBoundary().

67 {
68  return new TimeDependentPeriodicBoundary(*this);
69 }
void TimeDependentPeriodicBoundary::createGhostParticle ( BaseParticle pReal)

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

Todo:
{JMFT: The time comes from p->getHandler()->getDPMBase()->getTime(), which will be undefined if p does not belong to a handler.}

Definition at line 280 of file TimeDependentPeriodicBoundary.cc.

References ParticleHandler::addObject(), BaseParticle::copy(), BaseInteractable::copyInteractionsForPeriodicParticles(), BaseHandler< T >::getDPMBase(), BaseBoundary::getHandler(), BaseParticle::getPeriodicFromParticle(), DPMBase::getTime(), DPMBase::particleHandler, BaseParticle::setPeriodicFromParticle(), and shiftAndBoostParticle().

Referenced by createPeriodicParticle().

281 {
283 
284  //Step 1: Copy the particle to new ghost particle.
285  BaseParticle* pGhost = pReal->copy();
286 
287  //Step 2: Copy the interactions of the ghost particle.
288  pGhost->copyInteractionsForPeriodicParticles(*pReal);
289 
290  //Step 3: Shift the ghost to the 'reflected' location.
291  shiftAndBoostParticle(pGhost, pH.getDPMBase()->getTime());
292 
293  //Step 4: If Particle is double shifted, get correct original particle
294  BaseParticle* from = pReal;
295  while (from->getPeriodicFromParticle() != nullptr)
296  from = from->getPeriodicFromParticle();
297  pGhost->setPeriodicFromParticle(from);
298 
299  pH.addObject(pGhost);
300 }
void addObject(BaseParticle *P) override
Adds a BaseParticle to the ParticleHandler.
virtual void shiftAndBoostParticle(BaseParticle *p, Mdouble time) const
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
BaseParticle * getPeriodicFromParticle() const
Returns the 'original' particle this one's a periodic copy of.
Definition: BaseParticle.h:341
virtual BaseParticle * copy() const =0
Particle copy method. It calls to copy constructor of this Particle, useful for polymorphism.
ParticleHandler particleHandler
An object of the class ParticleHandler, contains the pointers to all the particles created...
Definition: DPMBase.h:1395
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.
DPMBase * getDPMBase()
Gets the problem that is solved using this handler.
Definition: BaseHandler.h:725
Mdouble getTime() const
Returns the current simulation time.
Definition: DPMBase.cc:805
void TimeDependentPeriodicBoundary::createPeriodicParticle ( BaseParticle p,
ParticleHandler pH 
)
override

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

Definition at line 302 of file TimeDependentPeriodicBoundary.cc.

References createGhostParticle(), getDistance(), ParticleHandler::getLargestParticle(), and BaseParticle::getMaxInteractionRadius().

Referenced by createPeriodicParticles().

303 {
304  //note that getDistance sets closestToLeftBoundary_ to true or false depending on which side is closest
306  {
308  }
309 }
BaseParticle * getLargestParticle() const
Returns the pointer of the largest particle in the particle handler. When mercury is running in paral...
Mdouble getMaxInteractionRadius() const
Returns the particle's interaction radius, which might be different from radius_ (e.g., when dealing with wet particles)
Definition: BaseParticle.h:362
void createGhostParticle(BaseParticle *pReal)
Creates and adds a ghost particle from a given real particle.
Mdouble getDistance(const BaseParticle &p) const override
Returns the distance of the edge to the particle.
void TimeDependentPeriodicBoundary::createPeriodicParticles ( ParticleHandler pH)
overridevirtual

Checks distance of particle to closer edge and creates a periodic copy if necessary.

Definition at line 263 of file TimeDependentPeriodicBoundary.cc.

References createPeriodicParticle(), BaseHandler< T >::getObject(), BaseHandler< T >::getSize(), constants::i, and NUMBER_OF_PROCESSORS.

264 {
265 #ifdef MERCURY_USE_MPI
266  if (NUMBER_OF_PROCESSORS == 1)
267  {
268 #endif
269  unsigned numberOfParticles = pH.getSize();
270 
271  for(unsigned i = 0; i < numberOfParticles; i++)
272  {
274  }
275 #ifdef MERCURY_USE_MPI
276  }
277 #endif
278 }
unsigned int getSize() const
Gets the size of the particleHandler (including mpi and periodic particles)
Definition: BaseHandler.h:655
const std::complex< Mdouble > i
Definition: ExtendedMath.h:51
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
void createPeriodicParticle(BaseParticle *p, ParticleHandler &pH) override
Creates a single periodic particle if required from a given particle.
Vec3D TimeDependentPeriodicBoundary::getBoost ( Mdouble  time) const

Returns the planewise boost as a function of time.

Definition at line 159 of file TimeDependentPeriodicBoundary.cc.

References boost_.

Referenced by shiftAndBoostParticle().

160 {
161  return boost_(time);
162 }
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Mdouble TimeDependentPeriodicBoundary::getDistance ( const BaseParticle p) const
overridevirtual

Returns the distance of the edge to the particle.

Implements BasePeriodicBoundary.

Definition at line 187 of file TimeDependentPeriodicBoundary.cc.

References BaseInteractable::getPosition().

Referenced by checkBoundaryAfterParticlesMove(), and createPeriodicParticle().

188 {
189  return getDistance(p.getPosition());
190 }
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 TimeDependentPeriodicBoundary::getDistance ( const Vec3D position) const
overridevirtual

Returns the distance of the edge to the position.

Returns the distance to the edge closest to the position

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

Implements BasePeriodicBoundary.

Definition at line 197 of file TimeDependentPeriodicBoundary.cc.

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

198 {
199  Mdouble distanceFromPlaneThroughOrigin = Vec3D::dot(position, normal_);
200  return std::min(distanceFromPlaneThroughOrigin - distanceLeft_,
201  distanceRight_ - distanceFromPlaneThroughOrigin);
202 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
double Mdouble
Definition: GeneralDefine.h:34
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Vec3D normal_
outward unit normal vector for right edge
Mdouble TimeDependentPeriodicBoundary::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 126 of file TimeDependentPeriodicBoundary.cc.

References distanceLeft_.

127 {
128  return distanceLeft_;
129 }
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Mdouble TimeDependentPeriodicBoundary::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 134 of file TimeDependentPeriodicBoundary.cc.

References distanceRight_.

135 {
136  return distanceRight_;
137 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
std::string TimeDependentPeriodicBoundary::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 372 of file TimeDependentPeriodicBoundary.cc.

373 {
374  return "TimeDependentPeriodicBoundary";
375 }
Vec3D TimeDependentPeriodicBoundary::getNormal ( ) const

returns the vector normal to the periodic boundary

Returns
The vector perpendicular to the periodic boundary

Definition at line 118 of file TimeDependentPeriodicBoundary.cc.

References normal_.

119 {
120  return normal_;
121 }
Vec3D normal_
outward unit normal vector for right edge
Vec3D TimeDependentPeriodicBoundary::getPlanewiseShift ( Mdouble  time) const

Returns the planewise shift as a function of time.

Definition at line 144 of file TimeDependentPeriodicBoundary.cc.

References ERROR, Vec3D::getLength(), logger, maxShift_, and planewiseShift_.

Referenced by getShift().

145 {
146  if (maxShift_ == 0)
147  return planewiseShift_(time);
148  if (maxShift_ > 0)
149  {
150  Vec3D p = planewiseShift_(time);
151  Mdouble m = p.getLength();
152  Vec3D n = p / m;
153  return fmod(m, maxShift_) * n;
154  }
155  if (maxShift_ < 0)
156  logger(ERROR, "[TimeDependentPeriodicBoundary::getPlanewiseShift] maxShift_ = % is negative", maxShift_);
157 }
Logger< MERCURY_LOGLEVEL > logger("MercuryKernel")
Definition of different loggers with certain modules. A user can define its own custom logger here...
double Mdouble
Definition: GeneralDefine.h:34
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
static Mdouble getLength(const Vec3D &a)
Calculates the length of a Vec3D: .
Definition: Vector.cc:331
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Definition: Vector.h:49
Vec3D TimeDependentPeriodicBoundary::getShift ( Mdouble  time) const

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

Definition at line 139 of file TimeDependentPeriodicBoundary.cc.

References distanceLeft_, distanceRight_, getPlanewiseShift(), and normal_.

Referenced by shiftAndBoostParticle(), and shiftPositions().

140 {
142 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D normal_
outward unit normal vector for right edge
Vec3D getPlanewiseShift(Mdouble time) const
Returns the planewise shift as a function of time.
bool TimeDependentPeriodicBoundary::isClosestToLeftBoundary ( const BaseParticle p) const
virtual

Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'right' edge.

Definition at line 246 of file TimeDependentPeriodicBoundary.cc.

References BaseInteractable::getPosition().

Referenced by shiftAndBoostParticle(), and shiftPositions().

247 {
249 }
const Vec3D & getPosition() const
Returns the position of this BaseInteractable.
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'righ...
bool TimeDependentPeriodicBoundary::isClosestToLeftBoundary ( const Vec3D p) const
overridevirtual

Returns true if position checked is closer to the 'left' edge, and false if it is closer to the 'right' edge.

Implements BasePeriodicBoundary.

Definition at line 257 of file TimeDependentPeriodicBoundary.cc.

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

258 {
259  const Mdouble distance = Vec3D::dot(p, normal_);
260  return (distanceRight_ - distance > distance - distanceLeft_);
261 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
double Mdouble
Definition: GeneralDefine.h:34
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
Vec3D normal_
outward unit normal vector for right edge
void TimeDependentPeriodicBoundary::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 171 of file TimeDependentPeriodicBoundary.cc.

References distanceLeft_.

172 {
173  distanceLeft_ = distanceLeft;
174 }
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
void TimeDependentPeriodicBoundary::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 182 of file TimeDependentPeriodicBoundary.cc.

References distanceRight_.

183 {
184  distanceRight_ = distanceRight;
185 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
void TimeDependentPeriodicBoundary::read ( std::istream &  is)
overridevirtual

reads boundary properties from istream

Reads the boundary properties from an istream

Parameters
[in]isthe istream

Reimplemented from BasePeriodicBoundary.

Definition at line 341 of file TimeDependentPeriodicBoundary.cc.

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

342 {
344  std::string dummy;
345  is >> dummy >> normal_
346  >> dummy >> distanceLeft_
347  >> dummy >> distanceRight_
348  // >> dummy >> planewiseShift_
349  // >> dummy >> boost_
350  ;
351 }
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
void read(std::istream &is) override
Reads the object's id_ from given istream.
Vec3D normal_
outward unit normal vector for right edge
void TimeDependentPeriodicBoundary::set ( Vec3D  normal,
Mdouble  distanceLeft,
Mdouble  distanceRight,
std::function< Vec3D(Mdouble)>  planewiseShift,
std::function< Vec3D(Mdouble)>  boost 
)

Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting that it does (projected onto the planewise direction)

Parameters
[in]normalVector specifying the normal direction of the edges
[in]distanceLeftPosition of the first edge
[in]distanceRightPosition of the second edge
[in]shiftVector (projected to remove normal component) by which particles crossing an edge are to be shifted, as a function of time.
[in]boostVector (projected to remove normal component) by which particles crossing an edge are to be boosted, as a function of time.

Definition at line 85 of file TimeDependentPeriodicBoundary.cc.

References boost_, distanceLeft_, distanceRight_, maxShift_, normal_, and planewiseShift_.

87 {
88  normal_ = normal;
89  distanceLeft_ = distanceLeft,
90  distanceRight_ = distanceRight,
91  planewiseShift_ = planewiseShift;
92  boost_ = boost;
93  maxShift_ = maxShift_; //\todo TW this line cannot be right
94 }
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
Vec3D normal_
outward unit normal vector for right edge
void TimeDependentPeriodicBoundary::set ( Vec3D  normal,
Vec3D  positionLeft,
Vec3D  positionRight,
std::function< Vec3D(Mdouble)>  shift,
std::function< Vec3D(Mdouble)>  boost 
)

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

Definition at line 96 of file TimeDependentPeriodicBoundary.cc.

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

Referenced by set().

98 {
99  set(normal, Vec3D::dot(positionLeft,normal), Vec3D::dot(positionRight,normal),
100  planewiseShift, boost);
101 }
void set(Vec3D normal, Mdouble distanceLeft, Mdouble distanceRight, std::function< Vec3D(Mdouble)> planewiseShift, std::function< Vec3D(Mdouble)> boost)
Defines a TimeDependentPeriodicBoundary by its normal and positions, and by the shifting and boosting...
static Mdouble dot(const Vec3D &a, const Vec3D &b)
Calculates the dot product of two Vec3D: .
Definition: Vector.cc:76
void TimeDependentPeriodicBoundary::setMaxShift ( Mdouble  maxShift)

Set the maximum shift (will take fmod w.r.t. this)

Definition at line 110 of file TimeDependentPeriodicBoundary.cc.

References maxShift_.

111 {
112  maxShift_ = maxShift;
113 }
Mdouble maxShift_
Maximum shifting (will take fmod(shift, maxshift) )
void TimeDependentPeriodicBoundary::setPlanewiseShiftAndBoost ( std::function< Vec3D(Mdouble)>  shift,
std::function< Vec3D(Mdouble)>  boost 
)

Set the planewise shift and boost (projected onto the planewise direction) as functions of time. (Boost should be the derivative of shift)

Definition at line 103 of file TimeDependentPeriodicBoundary.cc.

References boost_, and planewiseShift_.

105 {
106  planewiseShift_ = planewiseShift;
107  boost_ = boost;
108 }
std::function< Vec3D(Mdouble)> boost_
boost from the left to right boundary
std::function< Vec3D(Mdouble)> planewiseShift_
shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(tim...
void TimeDependentPeriodicBoundary::shiftAndBoostParticle ( BaseParticle p,
Mdouble  time 
) const
virtual

Definition at line 212 of file TimeDependentPeriodicBoundary.cc.

References BaseInteractable::addVelocity(), getBoost(), getShift(), isClosestToLeftBoundary(), and BaseInteractable::move().

Referenced by checkBoundaryAfterParticlesMove(), and createGhostParticle().

213 {
214  if (isClosestToLeftBoundary(*p))
215  {
216  p->move(getShift(time));
217  p->addVelocity(getBoost(time));
218  }
219  else
220  {
221  p->move(-getShift(time));
222  p->addVelocity(-getBoost(time));
223  }
224 }
void addVelocity(const Vec3D &velocity)
adds an increment to the velocity.
Vec3D getBoost(Mdouble time) const
Returns the planewise boost as a function of time.
Vec3D getShift(Mdouble time) const
Returns the vector going from the left to the right side of the periodic boundary.
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'righ...
virtual void move(const Vec3D &move)
Moves this BaseInteractable by adding an amount to the position.
void TimeDependentPeriodicBoundary::shiftPosition ( BaseParticle p) const
overridevirtual

shifts and boosts the particle

Parameters
[in]pA pointer to the particle which will be shifted and boosted.
Todo:
{JMFT: The time comes from p->getHandler()->getDPMBase()->getTime(), which will be undefined if p does not belong to a handler.}

Shouldn't be used for TimeDependentPeriodicBoundary. Instead, use TimeDependentPeriodicBoundary::shiftandBoostParticle.

Implements BasePeriodicBoundary.

Definition at line 208 of file TimeDependentPeriodicBoundary.cc.

209 {
210 }
void TimeDependentPeriodicBoundary::shiftPositions ( Vec3D position1,
Vec3D position2 
) const
virtual

shifts two positions (JMFT: Why, what is this for?)

Definition at line 226 of file TimeDependentPeriodicBoundary.cc.

References getShift(), and isClosestToLeftBoundary().

227 {
228  if (isClosestToLeftBoundary(position1))
229  {
230  position1 += getShift(0); // TODO JMFT: ?!?!?!
231  position2 += getShift(0);
232  }
233  else
234  {
235  position1 -= getShift(0);
236  position2 -= getShift(0);
237  }
238 }
Vec3D getShift(Mdouble time) const
Returns the vector going from the left to the right side of the periodic boundary.
virtual bool isClosestToLeftBoundary(const BaseParticle &p) const
Returns true if particle checked is closer to the 'left' edge, and false if it is closer to the 'righ...
void TimeDependentPeriodicBoundary::write ( std::ostream &  os) const
overridevirtual

writes boundary properties to ostream

Writes boundary's properties to an ostream

Parameters
[in]osthe ostream

Reimplemented from BasePeriodicBoundary.

Definition at line 357 of file TimeDependentPeriodicBoundary.cc.

References distanceLeft_, distanceRight_, normal_, and BasePeriodicBoundary::write().

358 {
360  os << " normal " << normal_
361  << " distanceLeft " << distanceLeft_
362  << " distanceRight " << distanceRight_
363  // << " planewiseShift " << planewiseShift_
364  // << " boost " << boost_
365  ;
366 }
void write(std::ostream &os) const override
Adds object's id_ to given ostream.
Mdouble distanceRight_
position of right edge, s.t. normal*x = distanceRight_
Mdouble distanceLeft_
position of left edge, s.t. normal*x = distanceLeft_
Vec3D normal_
outward unit normal vector for right edge

Member Data Documentation

std::function<Vec3D (Mdouble)> TimeDependentPeriodicBoundary::boost_
protected

boost from the left to right boundary

Definition at line 256 of file TimeDependentPeriodicBoundary.h.

Referenced by getBoost(), set(), setPlanewiseShiftAndBoost(), and TimeDependentPeriodicBoundary().

Mdouble TimeDependentPeriodicBoundary::distanceLeft_
protected

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

Definition at line 240 of file TimeDependentPeriodicBoundary.h.

Referenced by getDistance(), getDistanceLeft(), getShift(), isClosestToLeftBoundary(), moveLeft(), read(), set(), TimeDependentPeriodicBoundary(), and write().

Mdouble TimeDependentPeriodicBoundary::distanceRight_
protected

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

Definition at line 245 of file TimeDependentPeriodicBoundary.h.

Referenced by getDistance(), getDistanceRight(), getShift(), isClosestToLeftBoundary(), moveRight(), read(), set(), TimeDependentPeriodicBoundary(), and write().

Mdouble TimeDependentPeriodicBoundary::maxShift_
protected

Maximum shifting (will take fmod(shift, maxshift) )

Definition at line 261 of file TimeDependentPeriodicBoundary.h.

Referenced by getPlanewiseShift(), set(), setMaxShift(), and TimeDependentPeriodicBoundary().

Vec3D TimeDependentPeriodicBoundary::normal_
protected

outward unit normal vector for right edge

Definition at line 235 of file TimeDependentPeriodicBoundary.h.

Referenced by getDistance(), getNormal(), getShift(), isClosestToLeftBoundary(), read(), set(), TimeDependentPeriodicBoundary(), and write().

std::function<Vec3D (Mdouble)> TimeDependentPeriodicBoundary::planewiseShift_
protected

shift from left to right boundary in the planewise direction (Note: total shift = planewiseShift_(time) + normal * (distanceRight_ - distanceLeft_)

Definition at line 251 of file TimeDependentPeriodicBoundary.h.

Referenced by getPlanewiseShift(), set(), setPlanewiseShiftAndBoost(), and TimeDependentPeriodicBoundary().


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